narraleaf-react 0.4.2 → 0.4.4
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/game/player/elements/say/UIDialog.d.ts +7 -3
- package/dist/game/player/elements/say/useDialog.d.ts +1 -6
- package/dist/game/player/gameState.d.ts +3 -0
- package/dist/game/player/lib/PlayerFrames.d.ts +2 -2
- package/dist/game/player/lib/isolated.d.ts +2 -3
- package/dist/main.js +29 -29
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Md=Object.create;var ya=Object.defineProperty;var Vd=Object.getOwnPropertyDescriptor;var Nd=Object.getOwnPropertyNames;var Gd=Object.getPrototypeOf,Fd=Object.prototype.hasOwnProperty;var Od=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Hd=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),Ud=(o,t)=>{for(var n in t)ya(o,n,{get:t[n],enumerable:!0})},Kd=(o,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Nd(t))!Fd.call(o,i)&&i!==n&&ya(o,i,{get:()=>t[i],enumerable:!(r=Vd(t,i))||r.enumerable});return o};var Bd=(o,t,n)=>(n=o!=null?Md(Gd(o)):{},Kd(t||!o||!o.__esModule?ya(n,"default",{value:o,enumerable:!0}):n,o));var Tf=Hd(Os=>{(function(){"use strict";var o=function(){this.init()};o.prototype={init:function(){var a=this||t;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var l=this||t;if(a=parseFloat(a),l.ctx||f(),typeof a<"u"&&a>=0&&a<=1){if(l._volume=a,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(a,t.ctx.currentTime);for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var d=l._howls[m]._getSoundIds(),h=0;h<d.length;h++){var g=l._howls[m]._soundById(d[h]);g&&g._node&&(g._node.volume=g._volume*a)}return l}return l._volume},mute:function(a){var l=this||t;l.ctx||f(),l._muted=a,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(a?0:l._volume,t.ctx.currentTime);for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var d=l._howls[m]._getSoundIds(),h=0;h<d.length;h++){var g=l._howls[m]._soundById(d[h]);g&&g._node&&(g._node.muted=a?!0:g._muted)}return l},stop:function(){for(var a=this||t,l=0;l<a._howls.length;l++)a._howls[l].stop();return a},unload:function(){for(var a=this||t,l=a._howls.length-1;l>=0;l--)a._howls[l].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,f()),a},codecs:function(a){return(this||t)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||t;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var l=new Audio;l.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return a}if(!l||typeof l.canPlayType!="function")return a;var m=l.canPlayType("audio/mpeg;").replace(/^no$/,""),d=a._navigator?a._navigator.userAgent:"",h=d.match(/OPR\/(\d+)/g),g=h&&parseInt(h[0].split("/")[1],10)<33,y=d.indexOf("Safari")!==-1&&d.indexOf("Chrome")===-1,T=d.match(/Version\/(.*?) /),v=y&&T&&parseInt(T[1],10)<15;return a._codecs={mp3:!!(!g&&(m||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!m,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!v&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},a},_unlockAudio:function(){var a=this||t;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var l=function(m){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var d=new Audio;d._unlocked=!0,a._releaseHtml5Audio(d)}catch{a.noAudio=!0;break}for(var h=0;h<a._howls.length;h++)if(!a._howls[h]._webAudio)for(var g=a._howls[h]._getSoundIds(),y=0;y<g.length;y++){var T=a._howls[h]._soundById(g[y]);T&&T._node&&!T._node._unlocked&&(T._node._unlocked=!0,T._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var S=0;S<a._howls.length;S++)a._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),a}},_obtainHtml5Audio:function(){var a=this||t;if(a._html5AudioPool.length)return a._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(a){var l=this||t;return a._unlocked&&l._html5AudioPool.push(a),l},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<a._howls.length;l++)if(a._howls[l]._webAudio){for(var m=0;m<a._howls[l]._sounds.length;m++)if(!a._howls[l]._sounds[m]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(a.autoSuspend){a._suspendTimer=null,a.state="suspending";var d=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(d,d)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!t.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var l=0;l<a._howls.length;l++)a._howls[l]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var t=new o,n=function(a){var l=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(a)};n.prototype={init:function(a){var l=this;return t.ctx||f(),l._autoplay=a.autoplay||!1,l._format=typeof a.format!="string"?a.format:[a.format],l._html5=a.html5||!1,l._muted=a.mute||!1,l._loop=a.loop||!1,l._pool=a.pool||5,l._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,l._rate=a.rate||1,l._sprite=a.sprite||{},l._src=typeof a.src!="string"?a.src:[a.src],l._volume=a.volume!==void 0?a.volume:1,l._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=a.onend?[{fn:a.onend}]:[],l._onfade=a.onfade?[{fn:a.onfade}]:[],l._onload=a.onload?[{fn:a.onload}]:[],l._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],l._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],l._onpause=a.onpause?[{fn:a.onpause}]:[],l._onplay=a.onplay?[{fn:a.onplay}]:[],l._onstop=a.onstop?[{fn:a.onstop}]:[],l._onmute=a.onmute?[{fn:a.onmute}]:[],l._onvolume=a.onvolume?[{fn:a.onvolume}]:[],l._onrate=a.onrate?[{fn:a.onrate}]:[],l._onseek=a.onseek?[{fn:a.onseek}]:[],l._onunlock=a.onunlock?[{fn:a.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var a=this,l=null;if(t.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var m=0;m<a._src.length;m++){var d,h;if(a._format&&a._format[m])d=a._format[m];else{if(h=a._src[m],typeof h!="string"){a._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}d=/^data:audio\/([^;,]+);/i.exec(h),d||(d=/\.([^.]+)$/.exec(h.split("?",1)[0])),d&&(d=d[1].toLowerCase())}if(d||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),d&&t.codecs(d)){l=a._src[m];break}}if(!l){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=l,a._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new r(a),a._webAudio&&s(a),a},play:function(a,l){var m=this,d=null;if(typeof a=="number")d=a,a=null;else{if(typeof a=="string"&&m._state==="loaded"&&!m._sprite[a])return null;if(typeof a>"u"&&(a="__default",!m._playLock)){for(var h=0,g=0;g<m._sounds.length;g++)m._sounds[g]._paused&&!m._sounds[g]._ended&&(h++,d=m._sounds[g]._id);h===1?a=null:d=null}}var y=d?m._soundById(d):m._inactiveSound();if(!y)return null;if(d&&!a&&(a=y._sprite||"__default"),m._state!=="loaded"){y._sprite=a,y._ended=!1;var T=y._id;return m._queue.push({event:"play",action:function(){m.play(T)}}),T}if(d&&!y._paused)return l||m._loadQueue("play"),y._id;m._webAudio&&t._autoResume();var v=Math.max(0,y._seek>0?y._seek:m._sprite[a][0]/1e3),S=Math.max(0,(m._sprite[a][0]+m._sprite[a][1])/1e3-v),C=S*1e3/Math.abs(y._rate),x=m._sprite[a][0]/1e3,w=(m._sprite[a][0]+m._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=x,y._stop=w,y._loop=!!(y._loop||m._sprite[a][2])};if(v>=w){m._ended(y);return}var A=y._node;if(m._webAudio){var P=function(){m._playLock=!1,_(),m._refreshBuffer(y);var W=y._muted||m._muted?0:y._volume;A.gain.setValueAtTime(W,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof A.bufferSource.start>"u"?y._loop?A.bufferSource.noteGrainOn(0,v,86400):A.bufferSource.noteGrainOn(0,v,S):y._loop?A.bufferSource.start(0,v,86400):A.bufferSource.start(0,v,S),C!==1/0&&(m._endTimers[y._id]=setTimeout(m._ended.bind(m,y),C)),l||setTimeout(function(){m._emit("play",y._id),m._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?P():(m._playLock=!0,m.once("resume",P),m._clearTimer(y._id))}else{var V=function(){A.currentTime=v,A.muted=y._muted||m._muted||t._muted||A.muted,A.volume=y._volume*t.volume(),A.playbackRate=y._rate;try{var W=A.play();if(W&&typeof Promise<"u"&&(W instanceof Promise||typeof W.then=="function")?(m._playLock=!0,_(),W.then(function(){m._playLock=!1,A._unlocked=!0,l?m._loadQueue():m._emit("play",y._id)}).catch(function(){m._playLock=!1,m._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):l||(m._playLock=!1,_(),m._emit("play",y._id)),A.playbackRate=y._rate,A.paused){m._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}a!=="__default"||y._loop?m._endTimers[y._id]=setTimeout(m._ended.bind(m,y),C):(m._endTimers[y._id]=function(){m._ended(y),A.removeEventListener("ended",m._endTimers[y._id],!1)},A.addEventListener("ended",m._endTimers[y._id],!1))}catch(se){m._emit("playerror",y._id,se)}};A.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(A.src=m._src,A.load());var J=window&&window.ejecta||!A.readyState&&t._navigator.isCocoonJS;if(A.readyState>=3||J)V();else{m._playLock=!0,m._state="loading";var I=function(){m._state="loaded",V(),A.removeEventListener(t._canPlayEvent,I,!1)};A.addEventListener(t._canPlayEvent,I,!1),m._clearTimer(y._id)}}return y._id},pause:function(a){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(a)}}),l;for(var m=l._getSoundIds(a),d=0;d<m.length;d++){l._clearTimer(m[d]);var h=l._soundById(m[d]);if(h&&!h._paused&&(h._seek=l.seek(m[d]),h._rateSeek=0,h._paused=!0,l._stopFade(m[d]),h._node))if(l._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),l._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||l._emit("pause",h?h._id:null)}return l},stop:function(a,l){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"stop",action:function(){m.stop(a)}}),m;for(var d=m._getSoundIds(a),h=0;h<d.length;h++){m._clearTimer(d[h]);var g=m._soundById(d[h]);g&&(g._seek=g._start||0,g._rateSeek=0,g._paused=!0,g._ended=!0,m._stopFade(d[h]),g._node&&(m._webAudio?g._node.bufferSource&&(typeof g._node.bufferSource.stop>"u"?g._node.bufferSource.noteOff(0):g._node.bufferSource.stop(0),m._cleanBuffer(g._node)):(!isNaN(g._node.duration)||g._node.duration===1/0)&&(g._node.currentTime=g._start||0,g._node.pause(),g._node.duration===1/0&&m._clearSound(g._node))),l||m._emit("stop",g._id))}return m},mute:function(a,l){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"mute",action:function(){m.mute(a,l)}}),m;if(typeof l>"u")if(typeof a=="boolean")m._muted=a;else return m._muted;for(var d=m._getSoundIds(l),h=0;h<d.length;h++){var g=m._soundById(d[h]);g&&(g._muted=a,g._interval&&m._stopFade(g._id),m._webAudio&&g._node?g._node.gain.setValueAtTime(a?0:g._volume,t.ctx.currentTime):g._node&&(g._node.muted=t._muted?!0:a),m._emit("mute",g._id))}return m},volume:function(){var a=this,l=arguments,m,d;if(l.length===0)return a._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):m=parseFloat(l[0])}else l.length>=2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));var y;if(typeof m<"u"&&m>=0&&m<=1){if(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,l)}}),a;typeof d>"u"&&(a._volume=m),d=a._getSoundIds(d);for(var T=0;T<d.length;T++)y=a._soundById(d[T]),y&&(y._volume=m,l[2]||a._stopFade(d[T]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(m,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=m*t.volume()),a._emit("volume",y._id))}else return y=d?a._soundById(d):a._sounds[0],y?y._volume:0;return a},fade:function(a,l,m,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(a,l,m,d)}}),h;a=Math.min(Math.max(0,parseFloat(a)),1),l=Math.min(Math.max(0,parseFloat(l)),1),m=parseFloat(m),h.volume(a,d);for(var g=h._getSoundIds(d),y=0;y<g.length;y++){var T=h._soundById(g[y]);if(T){if(d||h._stopFade(g[y]),h._webAudio&&!T._muted){var v=t.ctx.currentTime,S=v+m/1e3;T._volume=a,T._node.gain.setValueAtTime(a,v),T._node.gain.linearRampToValueAtTime(l,S)}h._startFadeInterval(T,a,l,m,g[y],typeof d>"u")}}return h},_startFadeInterval:function(a,l,m,d,h,g){var y=this,T=l,v=m-l,S=Math.abs(v/.01),C=Math.max(4,S>0?d/S:d),x=Date.now();a._fadeTo=m,a._interval=setInterval(function(){var w=(Date.now()-x)/d;x=Date.now(),T+=v*w,T=Math.round(T*100)/100,v<0?T=Math.max(m,T):T=Math.min(m,T),y._webAudio?a._volume=T:y.volume(T,a._id,!0),g&&(y._volume=T),(m<l&&T<=m||m>l&&T>=m)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(m,a._id),y._emit("fade",a._id))},C)},_stopFade:function(a){var l=this,m=l._soundById(a);return m&&m._interval&&(l._webAudio&&m._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(m._interval),m._interval=null,l.volume(m._fadeTo,a),m._fadeTo=null,l._emit("fade",a)),l},loop:function(){var a=this,l=arguments,m,d,h;if(l.length===0)return a._loop;if(l.length===1)if(typeof l[0]=="boolean")m=l[0],a._loop=m;else return h=a._soundById(parseInt(l[0],10)),h?h._loop:!1;else l.length===2&&(m=l[0],d=parseInt(l[1],10));for(var g=a._getSoundIds(d),y=0;y<g.length;y++)h=a._soundById(g[y]),h&&(h._loop=m,a._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=m,m&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,a.playing(g[y])&&(a.pause(g[y],!0),a.play(g[y],!0)))));return a},rate:function(){var a=this,l=arguments,m,d;if(l.length===0)d=a._sounds[0]._id;else if(l.length===1){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):m=parseFloat(l[0])}else l.length===2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));var y;if(typeof m=="number"){if(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,l)}}),a;typeof d>"u"&&(a._rate=m),d=a._getSoundIds(d);for(var T=0;T<d.length;T++)if(y=a._soundById(d[T]),y){a.playing(d[T])&&(y._rateSeek=a.seek(d[T]),y._playStart=a._webAudio?t.ctx.currentTime:y._playStart),y._rate=m,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(m,t.ctx.currentTime):y._node&&(y._node.playbackRate=m);var v=a.seek(d[T]),S=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,C=S*1e3/Math.abs(y._rate);(a._endTimers[d[T]]||!y._paused)&&(a._clearTimer(d[T]),a._endTimers[d[T]]=setTimeout(a._ended.bind(a,y),C)),a._emit("rate",y._id)}}else return y=a._soundById(d),y?y._rate:a._rate;return a},seek:function(){var a=this,l=arguments,m,d;if(l.length===0)a._sounds.length&&(d=a._sounds[0]._id);else if(l.length===1){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):a._sounds.length&&(d=a._sounds[0]._id,m=parseFloat(l[0]))}else l.length===2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));if(typeof d>"u")return 0;if(typeof m=="number"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,l)}}),a;var y=a._soundById(d);if(y)if(typeof m=="number"&&m>=0){var T=a.playing(d);T&&a.pause(d,!0),y._seek=m,y._ended=!1,a._clearTimer(d),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=m);var v=function(){T&&a.play(d,!0),a._emit("seek",d)};if(T&&!a._webAudio){var S=function(){a._playLock?setTimeout(S,0):v()};setTimeout(S,0)}else v()}else if(a._webAudio){var C=a.playing(d)?t.ctx.currentTime-y._playStart:0,x=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(x+C*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var l=this;if(typeof a=="number"){var m=l._soundById(a);return m?!m._paused:!1}for(var d=0;d<l._sounds.length;d++)if(!l._sounds[d]._paused)return!0;return!1},duration:function(a){var l=this,m=l._duration,d=l._soundById(a);return d&&(m=l._sprite[d._sprite][1]/1e3),m},state:function(){return this._state},unload:function(){for(var a=this,l=a._sounds,m=0;m<l.length;m++)l[m]._paused||a.stop(l[m]._id),a._webAudio||(a._clearSound(l[m]._node),l[m]._node.removeEventListener("error",l[m]._errorFn,!1),l[m]._node.removeEventListener(t._canPlayEvent,l[m]._loadFn,!1),l[m]._node.removeEventListener("ended",l[m]._endFn,!1),t._releaseHtml5Audio(l[m]._node)),delete l[m]._node,a._clearTimer(l[m]._id);var d=t._howls.indexOf(a);d>=0&&t._howls.splice(d,1);var h=!0;for(m=0;m<t._howls.length;m++)if(t._howls[m]._src===a._src||a._src.indexOf(t._howls[m]._src)>=0){h=!1;break}return i&&h&&delete i[a._src],t.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,l,m,d){var h=this,g=h["_on"+a];return typeof l=="function"&&g.push(d?{id:m,fn:l,once:d}:{id:m,fn:l}),h},off:function(a,l,m){var d=this,h=d["_on"+a],g=0;if(typeof l=="number"&&(m=l,l=null),l||m)for(g=0;g<h.length;g++){var y=m===h[g].id;if(l===h[g].fn&&y||!l&&y){h.splice(g,1);break}}else if(a)d["_on"+a]=[];else{var T=Object.keys(d);for(g=0;g<T.length;g++)T[g].indexOf("_on")===0&&Array.isArray(d[T[g]])&&(d[T[g]]=[])}return d},once:function(a,l,m){var d=this;return d.on(a,l,m,1),d},_emit:function(a,l,m){for(var d=this,h=d["_on"+a],g=h.length-1;g>=0;g--)(!h[g].id||h[g].id===l||a==="load")&&(setTimeout(function(y){y.call(this,l,m)}.bind(d,h[g].fn),0),h[g].once&&d.off(a,h[g].fn,h[g].id));return d._loadQueue(a),d},_loadQueue:function(a){var l=this;if(l._queue.length>0){var m=l._queue[0];m.event===a&&(l._queue.shift(),l._loadQueue()),a||m.action()}return l},_ended:function(a){var l=this,m=a._sprite;if(!l._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(l._ended.bind(l,a),100),l;var d=!!(a._loop||l._sprite[m][2]);if(l._emit("end",a._id),!l._webAudio&&d&&l.stop(a._id,!0).play(a._id),l._webAudio&&d){l._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=t.ctx.currentTime;var h=(a._stop-a._start)*1e3/Math.abs(a._rate);l._endTimers[a._id]=setTimeout(l._ended.bind(l,a),h)}return l._webAudio&&!d&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,l._clearTimer(a._id),l._cleanBuffer(a._node),t._autoSuspend()),!l._webAudio&&!d&&l.stop(a._id,!0),l},_clearTimer:function(a){var l=this;if(l._endTimers[a]){if(typeof l._endTimers[a]!="function")clearTimeout(l._endTimers[a]);else{var m=l._soundById(a);m&&m._node&&m._node.removeEventListener("ended",l._endTimers[a],!1)}delete l._endTimers[a]}return l},_soundById:function(a){for(var l=this,m=0;m<l._sounds.length;m++)if(a===l._sounds[m]._id)return l._sounds[m];return null},_inactiveSound:function(){var a=this;a._drain();for(var l=0;l<a._sounds.length;l++)if(a._sounds[l]._ended)return a._sounds[l].reset();return new r(a)},_drain:function(){var a=this,l=a._pool,m=0,d=0;if(!(a._sounds.length<l)){for(d=0;d<a._sounds.length;d++)a._sounds[d]._ended&&m++;for(d=a._sounds.length-1;d>=0;d--){if(m<=l)return;a._sounds[d]._ended&&(a._webAudio&&a._sounds[d]._node&&a._sounds[d]._node.disconnect(0),a._sounds.splice(d,1),m--)}}},_getSoundIds:function(a){var l=this;if(typeof a>"u"){for(var m=[],d=0;d<l._sounds.length;d++)m.push(l._sounds[d]._id);return m}else return[a]},_refreshBuffer:function(a){var l=this;return a._node.bufferSource=t.ctx.createBufferSource(),a._node.bufferSource.buffer=i[l._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,t.ctx.currentTime),l},_cleanBuffer:function(a){var l=this,m=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!a.bufferSource)return l;if(t._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),m))try{a.bufferSource.buffer=t._scratchBuffer}catch{}return a.bufferSource=null,l},_clearSound:function(a){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(a){this._parent=a,this.init()};r.prototype={init:function(){var a=this,l=a._parent;return a._muted=l._muted,a._loop=l._loop,a._volume=l._volume,a._rate=l._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++t._counter,l._sounds.push(a),a.create(),a},create:function(){var a=this,l=a._parent,m=t._muted||a._muted||a._parent._muted?0:a._volume;return l._webAudio?(a._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),a._node.gain.setValueAtTime(m,t.ctx.currentTime),a._node.paused=!0,a._node.connect(t.masterGain)):t.noAudio||(a._node=t._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(t._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=l._src,a._node.preload=l._preload===!0?"auto":l._preload,a._node.volume=m*t.volume(),a._node.load()),a},reset:function(){var a=this,l=a._parent;return a._muted=l._muted,a._loop=l._loop,a._volume=l._volume,a._rate=l._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++t._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,l=a._parent;l._duration=Math.ceil(a._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),a._node.removeEventListener(t._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,l=a._parent;l._duration===1/0&&(l._duration=Math.ceil(a._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var i={},s=function(a){var l=a._src;if(i[l]){a._duration=i[l].duration,p(a);return}if(/^data:[^;]+;base64,/.test(l)){for(var m=atob(l.split(",")[1]),d=new Uint8Array(m.length),h=0;h<m.length;++h)d[h]=m.charCodeAt(h);u(d.buffer,a)}else{var g=new XMLHttpRequest;g.open(a._xhr.method,l,!0),g.withCredentials=a._xhr.withCredentials,g.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){g.setRequestHeader(y,a._xhr.headers[y])}),g.onload=function(){var y=(g.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+g.status+".");return}u(g.response,a)},g.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete i[l],a.load())},c(g)}},c=function(a){try{a.send()}catch{a.onerror()}},u=function(a,l){var m=function(){l._emit("loaderror",null,"Decoding audio data failed.")},d=function(h){h&&l._sounds.length>0?(i[l._src]=h,p(l,h)):m()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(a).then(d).catch(m):t.ctx.decodeAudioData(a,d,m)},p=function(a,l){l&&!a._duration&&(a._duration=l.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._loadQueue())},f=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var a=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),m=l?parseInt(l[1],10):null;if(a&&m&&m<9){var d=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!d&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:n}}),typeof Os<"u"&&(Os.Howler=t,Os.Howl=n),typeof global<"u"?(global.HowlerGlobal=o,global.Howler=t,global.Howl=n,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=o,window.Howler=t,window.Howl=n,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var n=this;if(!n.ctx||!n.ctx.listener)return n;for(var r=n._howls.length-1;r>=0;r--)n._howls[r].stereo(t);return n},HowlerGlobal.prototype.pos=function(t,n,r){var i=this;if(!i.ctx||!i.ctx.listener)return i;if(n=typeof n!="number"?i._pos[1]:n,r=typeof r!="number"?i._pos[2]:r,typeof t=="number")i._pos=[t,n,r],typeof i.ctx.listener.positionX<"u"?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]);else return i._pos;return i},HowlerGlobal.prototype.orientation=function(t,n,r,i,s,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var p=u._orientation;if(n=typeof n!="number"?p[1]:n,r=typeof r!="number"?p[2]:r,i=typeof i!="number"?p[3]:i,s=typeof s!="number"?p[4]:s,c=typeof c!="number"?p[5]:c,typeof t=="number")u._orientation=[t,n,r,i,s,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(n,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,n,r,i,s,c);else return p;return u},Howl.prototype.init=function(t){return function(n){var r=this;return r._orientation=n.orientation||[1,0,0],r._stereo=n.stereo||null,r._pos=n.pos||null,r._pannerAttr={coneInnerAngle:typeof n.coneInnerAngle<"u"?n.coneInnerAngle:360,coneOuterAngle:typeof n.coneOuterAngle<"u"?n.coneOuterAngle:360,coneOuterGain:typeof n.coneOuterGain<"u"?n.coneOuterGain:0,distanceModel:typeof n.distanceModel<"u"?n.distanceModel:"inverse",maxDistance:typeof n.maxDistance<"u"?n.maxDistance:1e4,panningModel:typeof n.panningModel<"u"?n.panningModel:"HRTF",refDistance:typeof n.refDistance<"u"?n.refDistance:1,rolloffFactor:typeof n.rolloffFactor<"u"?n.rolloffFactor:1},r._onstereo=n.onstereo?[{fn:n.onstereo}]:[],r._onpos=n.onpos?[{fn:n.onpos}]:[],r._onorientation=n.onorientation?[{fn:n.onorientation}]:[],t.call(this,n)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,n){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,n)}}),r;var i=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof n>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var s=r._getSoundIds(n),c=0;c<s.length;c++){var u=r._soundById(s[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&o(u,i),i==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",u._id);else return u._stereo}return r},Howl.prototype.pos=function(t,n,r,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"pos",action:function(){s.pos(t,n,r,i)}}),s;if(n=typeof n!="number"?0:n,r=typeof r!="number"?-.5:r,typeof i>"u")if(typeof t=="number")s._pos=[t,n,r];else return s._pos;for(var c=s._getSoundIds(i),u=0;u<c.length;u++){var p=s._soundById(c[u]);if(p)if(typeof t=="number")p._pos=[t,n,r],p._node&&((!p._panner||p._panner.pan)&&o(p,"spatial"),typeof p._panner.positionX<"u"?(p._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.positionY.setValueAtTime(n,Howler.ctx.currentTime),p._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):p._panner.setPosition(t,n,r)),s._emit("pos",p._id);else return p._pos}return s},Howl.prototype.orientation=function(t,n,r,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"orientation",action:function(){s.orientation(t,n,r,i)}}),s;if(n=typeof n!="number"?s._orientation[1]:n,r=typeof r!="number"?s._orientation[2]:r,typeof i>"u")if(typeof t=="number")s._orientation=[t,n,r];else return s._orientation;for(var c=s._getSoundIds(i),u=0;u<c.length;u++){var p=s._soundById(c[u]);if(p)if(typeof t=="number")p._orientation=[t,n,r],p._node&&(p._panner||(p._pos||(p._pos=s._pos||[0,0,-.5]),o(p,"spatial")),typeof p._panner.orientationX<"u"?(p._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.orientationY.setValueAtTime(n,Howler.ctx.currentTime),p._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):p._panner.setOrientation(t,n,r)),s._emit("orientation",p._id);else return p._orientation}return s},Howl.prototype.pannerAttr=function(){var t=this,n=arguments,r,i,s;if(!t._webAudio)return t;if(n.length===0)return t._pannerAttr;if(n.length===1)if(typeof n[0]=="object")r=n[0],typeof i>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return s=t._soundById(parseInt(n[0],10)),s?s._pannerAttr:t._pannerAttr;else n.length===2&&(r=n[0],i=parseInt(n[1],10));for(var c=t._getSoundIds(i),u=0;u<c.length;u++)if(s=t._soundById(c[u]),s){var p=s._pannerAttr;p={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:p.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:p.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:p.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:p.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:p.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:p.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:p.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:p.panningModel};var f=s._panner;f||(s._pos||(s._pos=t._pos||[0,0,-.5]),o(s,"spatial"),f=s._panner),f.coneInnerAngle=p.coneInnerAngle,f.coneOuterAngle=p.coneOuterAngle,f.coneOuterGain=p.coneOuterGain,f.distanceModel=p.distanceModel,f.maxDistance=p.maxDistance,f.refDistance=p.refDistance,f.rolloffFactor=p.rolloffFactor,f.panningModel=p.panningModel}return t},Sound.prototype.init=function(t){return function(){var n=this,r=n._parent;n._orientation=r._orientation,n._stereo=r._stereo,n._pos=r._pos,n._pannerAttr=r._pannerAttr,t.call(this),n._stereo?r.stereo(n._stereo):n._pos&&r.pos(n._pos[0],n._pos[1],n._pos[2],n._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var n=this,r=n._parent;return n._orientation=r._orientation,n._stereo=r._stereo,n._pos=r._pos,n._pannerAttr=r._pannerAttr,n._stereo?r.stereo(n._stereo):n._pos?r.pos(n._pos[0],n._pos[1],n._pos[2],n._id):n._panner&&(n._panner.disconnect(0),n._panner=void 0,r._refreshBuffer(n)),t.call(this)}}(Sound.prototype.reset);var o=function(t,n){n=n||"spatial",n==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Ce={action:"displayable:action",applyTransform:"displayable:applyTransform",applyTransition:"displayable:applyTransition",init:"displayable:init"},jr={say:"character:say",action:"character:action",setName:"character:setName"},ge={action:"scene:action",init:"scene:init",exit:"scene:exit",jumpTo:"scene:jumpTo",setBackgroundMusic:"scene:setBackgroundMusic",preUnmount:"scene:preUnmount",transitionToScene:"scene:transitionToScene"};var ot={action:"image:action",setSrc:"image:setSrc",flush:"image:flush",initWearable:"image:initWearable",setAppearance:"image:setAppearance"},Cl={action:"condition:action"},wl={action:"script:action"},Pl={action:"menu:action"},nn={action:"sound:action",play:"sound:play",stop:"sound:stop",setVolume:"sound:setVolume",setRate:"sound:setRate",pause:"sound:pause",resume:"sound:resume"},ft={action:"control:action",do:"control:do",doAsync:"control:doAsync",any:"control:any",all:"control:all",allAsync:"control:allAsync",repeat:"control:repeat",sleep:"control:sleep"},$r={action:"text:action",setText:"text:setText",setFontSize:"text:setFontSize"},or={action:"persistent:action",set:"persistent:set",assign:"persistent:assign"},rr={action:"layer:action"},qn={action:"video:action",show:"video:show",hide:"video:hide",play:"video:play",pause:"video:pause",resume:"video:resume",stop:"video:stop",seek:"video:seek"};var El=(m=>(m[m.string=0]="string",m[m.number=1]="number",m[m.boolean=2]="boolean",m[m.object=3]="object",m[m.array=4]="array",m[m.function=5]="function",m[m.symbol=6]="symbol",m[m.undefined=7]="undefined",m[m.null=8]="null",m[m.date=9]="date",m[m.regexp=10]="regexp",m[m.other=11]="other",m))(El||{}),Ta=function(o){return typeof o=="string"?0:typeof o=="number"?1:typeof o=="boolean"?2:typeof o=="object"?Array.isArray(o)?4:o===null?8:o instanceof Date?9:o instanceof RegExp?10:3:typeof o=="function"?5:typeof o=="symbol"?6:typeof o>"u"?7:11};Ta.DataTypes=El;function U(o,t,...n){let r=(c,u)=>Object.prototype.hasOwnProperty.call(c,u),i={},s=(c,u,p)=>Ta(u)===3&&Ta(p)===3?u.constructor!==Object||p.constructor!==Object?p||u:U(u,p):Array.isArray(u)&&Array.isArray(p)?p&&p.length>0?[...p]:[...u]:u===void 0&&Array.isArray(p)?[...p]:p===void 0?Array.isArray(u)?[...u]:u:Array.isArray(p)?[...p]:p;for(let c in o)r(o,c)&&(i[c]=s(c,o[c],t[c]));for(let c in t)r(t,c)&&!r(i,c)&&(typeof t[c]=="object"&&t[c]!==null?t[c].constructor===Object?i[c]=U({},t[c]):Array.isArray(t[c])?i[c]=[...t[c]]:i[c]=t[c]:i[c]=t[c]);if(n.length){let[c,...u]=n;return U(i,c,...u)}return i}var dt=class dt{constructor(t=r=>r,n){this.solved=!1;this.aborted=!1;this.listeners=[];this.onRegisterSkipController=[];this.receiver=t,this.skipController=n,this.__stack=Sa()}static isAwaitable(t){return t instanceof dt}static fromPromise(t){let n=new dt;return t.then(r=>n.resolve(r)),n}static resolve(t){let n=new dt;return n.resolve(t),n}static delay(t){let n=new dt;return setTimeout(()=>n.resolve(),t),n}static create(t){let n=new dt;return t(n),n}static wait(t){let n=new dt;return t.then(()=>n.resolve()),n}static race(t){let n=new dt;return t.length===0?(n.resolve(void 0),n):(t.forEach(r=>{r.then(i=>{t.forEach(s=>{s!==r&&s.skipController?.abort()}),n.resolve(i)})}),n.registerSkipController(new K(()=>{t.forEach(r=>r.skipController?.abort())})),n)}static forward(t,n,r){let i=new dt().registerSkipController(r||new K(()=>n));t.then(()=>i.resolve(n));let s=t.skipController?.onAbort(()=>{i.skipController?.abort(),s?.cancel(),c?.cancel()}),c=i.skipController?.onAbort(()=>{t.skipController?.abort(),s?.cancel(),c?.cancel()});return i}registerSkipController(t){this.skipController=t;for(let n of this.onRegisterSkipController)n(t);return this}resolve(t){if(!this.solved){this.result=this.receiver(t),this.solved=!0,this.skipController&&this.skipController.cancel();for(let n of this.listeners)n(this.result)}}then(t){return this.solved?t(this.result):this.listeners.push(t),this}onSettled(t){return this.solved?t():(this.listeners.push(t),this.onSkipControllerRegister(n=>{n.onAbort(()=>{t()})})),this}onSkipControllerRegister(t){return this.skipController?t(this.skipController):this.onRegisterSkipController.push(t),this}abort(){return this.aborted=!0,this.skipController?this.skipController.abort():this.result}isSolved(){return this.solved&&!this.aborted}isAborted(){return this.aborted}isSettled(){return this.solved||this.aborted}};dt.nothing=t=>t;var b=dt;function kl(o){let t=new WeakSet;function n(r){if(r===null||typeof r!="object")return r;if(t.has(r))return;if(t.add(r),Array.isArray(r)){let s=[];for(let c of r)s.push(n(c));return s}let i={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=n(r[s]));return i}return n(o)}function Pn(o){return typeof o=="string"?o:`#${(o.r||0).toString(16).padStart(2,"0")}${(o.g||0).toString(16).padStart(2,"0")}${(o.b||0).toString(16).padStart(2,"0")}${o.a===void 0?"":o.a.toString(16).padStart(2,"0")}`}var re=class{constructor(){this.events={};this.maxListeners=10}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),this.events[t].length>this.maxListeners&&console.warn(`NarraLeaf-React: Event ${t} has more than ${this.maxListeners} listeners (total: ${this.events[t].length}), this may cause performance issues.`),this.emit("event:EventDispatcher.register",t,n),{type:t,listener:n,cancel:()=>{this.off(t,n)}}}depends(t){return{cancel:()=>{t.forEach(n=>n.cancel())}}}off(t,n){this.events[t]&&(this.events[t]=this.events[t].filter(r=>r!==n))}emit(t,...n){this.events[t]&&this.events[t].forEach(r=>{r(...n)})}once(t,n){let r=(...i)=>{n(...i),this.off(t,r)};return this.on(t,r)}async any(t,...n){if(this.events[t]||(this.events[t]=[]),this.events[t].length>0){await Promise.all(this.events[t].map(r=>r(...n)));return}return new Promise(r=>{let i="event:EventDispatcher.register",s=this.on(i,(c,u)=>{if(c===t){this.off(i,s);let p=u?.(...n);p!==null&&typeof p=="object"&&p.then?p.then(r):r(p)}}).listener})}setMaxListeners(t){return this.maxListeners=t,this}clear(){this.events={}}};function Sa(o=1){let t=new Error().stack;return t?t.split(`
|
|
1
|
+
var Md=Object.create;var Ta=Object.defineProperty;var Vd=Object.getOwnPropertyDescriptor;var Nd=Object.getOwnPropertyNames;var Gd=Object.getPrototypeOf,Fd=Object.prototype.hasOwnProperty;var Od=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Hd=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),Ud=(o,t)=>{for(var n in t)Ta(o,n,{get:t[n],enumerable:!0})},Kd=(o,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Nd(t))!Fd.call(o,i)&&i!==n&&Ta(o,i,{get:()=>t[i],enumerable:!(r=Vd(t,i))||r.enumerable});return o};var Bd=(o,t,n)=>(n=o!=null?Md(Gd(o)):{},Kd(t||!o||!o.__esModule?Ta(n,"default",{value:o,enumerable:!0}):n,o));var Tf=Hd(Hs=>{(function(){"use strict";var o=function(){this.init()};o.prototype={init:function(){var a=this||t;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var l=this||t;if(a=parseFloat(a),l.ctx||f(),typeof a<"u"&&a>=0&&a<=1){if(l._volume=a,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(a,t.ctx.currentTime);for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var d=l._howls[m]._getSoundIds(),h=0;h<d.length;h++){var g=l._howls[m]._soundById(d[h]);g&&g._node&&(g._node.volume=g._volume*a)}return l}return l._volume},mute:function(a){var l=this||t;l.ctx||f(),l._muted=a,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(a?0:l._volume,t.ctx.currentTime);for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var d=l._howls[m]._getSoundIds(),h=0;h<d.length;h++){var g=l._howls[m]._soundById(d[h]);g&&g._node&&(g._node.muted=a?!0:g._muted)}return l},stop:function(){for(var a=this||t,l=0;l<a._howls.length;l++)a._howls[l].stop();return a},unload:function(){for(var a=this||t,l=a._howls.length-1;l>=0;l--)a._howls[l].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,f()),a},codecs:function(a){return(this||t)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||t;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var l=new Audio;l.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return a}if(!l||typeof l.canPlayType!="function")return a;var m=l.canPlayType("audio/mpeg;").replace(/^no$/,""),d=a._navigator?a._navigator.userAgent:"",h=d.match(/OPR\/(\d+)/g),g=h&&parseInt(h[0].split("/")[1],10)<33,y=d.indexOf("Safari")!==-1&&d.indexOf("Chrome")===-1,T=d.match(/Version\/(.*?) /),v=y&&T&&parseInt(T[1],10)<15;return a._codecs={mp3:!!(!g&&(m||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!m,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!v&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},a},_unlockAudio:function(){var a=this||t;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var l=function(m){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var d=new Audio;d._unlocked=!0,a._releaseHtml5Audio(d)}catch{a.noAudio=!0;break}for(var h=0;h<a._howls.length;h++)if(!a._howls[h]._webAudio)for(var g=a._howls[h]._getSoundIds(),y=0;y<g.length;y++){var T=a._howls[h]._soundById(g[y]);T&&T._node&&!T._node._unlocked&&(T._node._unlocked=!0,T._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var S=0;S<a._howls.length;S++)a._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),a}},_obtainHtml5Audio:function(){var a=this||t;if(a._html5AudioPool.length)return a._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(a){var l=this||t;return a._unlocked&&l._html5AudioPool.push(a),l},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<a._howls.length;l++)if(a._howls[l]._webAudio){for(var m=0;m<a._howls[l]._sounds.length;m++)if(!a._howls[l]._sounds[m]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(a.autoSuspend){a._suspendTimer=null,a.state="suspending";var d=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(d,d)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!t.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var l=0;l<a._howls.length;l++)a._howls[l]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var t=new o,n=function(a){var l=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(a)};n.prototype={init:function(a){var l=this;return t.ctx||f(),l._autoplay=a.autoplay||!1,l._format=typeof a.format!="string"?a.format:[a.format],l._html5=a.html5||!1,l._muted=a.mute||!1,l._loop=a.loop||!1,l._pool=a.pool||5,l._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,l._rate=a.rate||1,l._sprite=a.sprite||{},l._src=typeof a.src!="string"?a.src:[a.src],l._volume=a.volume!==void 0?a.volume:1,l._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=a.onend?[{fn:a.onend}]:[],l._onfade=a.onfade?[{fn:a.onfade}]:[],l._onload=a.onload?[{fn:a.onload}]:[],l._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],l._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],l._onpause=a.onpause?[{fn:a.onpause}]:[],l._onplay=a.onplay?[{fn:a.onplay}]:[],l._onstop=a.onstop?[{fn:a.onstop}]:[],l._onmute=a.onmute?[{fn:a.onmute}]:[],l._onvolume=a.onvolume?[{fn:a.onvolume}]:[],l._onrate=a.onrate?[{fn:a.onrate}]:[],l._onseek=a.onseek?[{fn:a.onseek}]:[],l._onunlock=a.onunlock?[{fn:a.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var a=this,l=null;if(t.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var m=0;m<a._src.length;m++){var d,h;if(a._format&&a._format[m])d=a._format[m];else{if(h=a._src[m],typeof h!="string"){a._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}d=/^data:audio\/([^;,]+);/i.exec(h),d||(d=/\.([^.]+)$/.exec(h.split("?",1)[0])),d&&(d=d[1].toLowerCase())}if(d||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),d&&t.codecs(d)){l=a._src[m];break}}if(!l){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=l,a._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new r(a),a._webAudio&&s(a),a},play:function(a,l){var m=this,d=null;if(typeof a=="number")d=a,a=null;else{if(typeof a=="string"&&m._state==="loaded"&&!m._sprite[a])return null;if(typeof a>"u"&&(a="__default",!m._playLock)){for(var h=0,g=0;g<m._sounds.length;g++)m._sounds[g]._paused&&!m._sounds[g]._ended&&(h++,d=m._sounds[g]._id);h===1?a=null:d=null}}var y=d?m._soundById(d):m._inactiveSound();if(!y)return null;if(d&&!a&&(a=y._sprite||"__default"),m._state!=="loaded"){y._sprite=a,y._ended=!1;var T=y._id;return m._queue.push({event:"play",action:function(){m.play(T)}}),T}if(d&&!y._paused)return l||m._loadQueue("play"),y._id;m._webAudio&&t._autoResume();var v=Math.max(0,y._seek>0?y._seek:m._sprite[a][0]/1e3),S=Math.max(0,(m._sprite[a][0]+m._sprite[a][1])/1e3-v),C=S*1e3/Math.abs(y._rate),x=m._sprite[a][0]/1e3,w=(m._sprite[a][0]+m._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=x,y._stop=w,y._loop=!!(y._loop||m._sprite[a][2])};if(v>=w){m._ended(y);return}var A=y._node;if(m._webAudio){var P=function(){m._playLock=!1,_(),m._refreshBuffer(y);var W=y._muted||m._muted?0:y._volume;A.gain.setValueAtTime(W,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof A.bufferSource.start>"u"?y._loop?A.bufferSource.noteGrainOn(0,v,86400):A.bufferSource.noteGrainOn(0,v,S):y._loop?A.bufferSource.start(0,v,86400):A.bufferSource.start(0,v,S),C!==1/0&&(m._endTimers[y._id]=setTimeout(m._ended.bind(m,y),C)),l||setTimeout(function(){m._emit("play",y._id),m._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?P():(m._playLock=!0,m.once("resume",P),m._clearTimer(y._id))}else{var V=function(){A.currentTime=v,A.muted=y._muted||m._muted||t._muted||A.muted,A.volume=y._volume*t.volume(),A.playbackRate=y._rate;try{var W=A.play();if(W&&typeof Promise<"u"&&(W instanceof Promise||typeof W.then=="function")?(m._playLock=!0,_(),W.then(function(){m._playLock=!1,A._unlocked=!0,l?m._loadQueue():m._emit("play",y._id)}).catch(function(){m._playLock=!1,m._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):l||(m._playLock=!1,_(),m._emit("play",y._id)),A.playbackRate=y._rate,A.paused){m._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}a!=="__default"||y._loop?m._endTimers[y._id]=setTimeout(m._ended.bind(m,y),C):(m._endTimers[y._id]=function(){m._ended(y),A.removeEventListener("ended",m._endTimers[y._id],!1)},A.addEventListener("ended",m._endTimers[y._id],!1))}catch(se){m._emit("playerror",y._id,se)}};A.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(A.src=m._src,A.load());var J=window&&window.ejecta||!A.readyState&&t._navigator.isCocoonJS;if(A.readyState>=3||J)V();else{m._playLock=!0,m._state="loading";var I=function(){m._state="loaded",V(),A.removeEventListener(t._canPlayEvent,I,!1)};A.addEventListener(t._canPlayEvent,I,!1),m._clearTimer(y._id)}}return y._id},pause:function(a){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(a)}}),l;for(var m=l._getSoundIds(a),d=0;d<m.length;d++){l._clearTimer(m[d]);var h=l._soundById(m[d]);if(h&&!h._paused&&(h._seek=l.seek(m[d]),h._rateSeek=0,h._paused=!0,l._stopFade(m[d]),h._node))if(l._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),l._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||l._emit("pause",h?h._id:null)}return l},stop:function(a,l){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"stop",action:function(){m.stop(a)}}),m;for(var d=m._getSoundIds(a),h=0;h<d.length;h++){m._clearTimer(d[h]);var g=m._soundById(d[h]);g&&(g._seek=g._start||0,g._rateSeek=0,g._paused=!0,g._ended=!0,m._stopFade(d[h]),g._node&&(m._webAudio?g._node.bufferSource&&(typeof g._node.bufferSource.stop>"u"?g._node.bufferSource.noteOff(0):g._node.bufferSource.stop(0),m._cleanBuffer(g._node)):(!isNaN(g._node.duration)||g._node.duration===1/0)&&(g._node.currentTime=g._start||0,g._node.pause(),g._node.duration===1/0&&m._clearSound(g._node))),l||m._emit("stop",g._id))}return m},mute:function(a,l){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"mute",action:function(){m.mute(a,l)}}),m;if(typeof l>"u")if(typeof a=="boolean")m._muted=a;else return m._muted;for(var d=m._getSoundIds(l),h=0;h<d.length;h++){var g=m._soundById(d[h]);g&&(g._muted=a,g._interval&&m._stopFade(g._id),m._webAudio&&g._node?g._node.gain.setValueAtTime(a?0:g._volume,t.ctx.currentTime):g._node&&(g._node.muted=t._muted?!0:a),m._emit("mute",g._id))}return m},volume:function(){var a=this,l=arguments,m,d;if(l.length===0)return a._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):m=parseFloat(l[0])}else l.length>=2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));var y;if(typeof m<"u"&&m>=0&&m<=1){if(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,l)}}),a;typeof d>"u"&&(a._volume=m),d=a._getSoundIds(d);for(var T=0;T<d.length;T++)y=a._soundById(d[T]),y&&(y._volume=m,l[2]||a._stopFade(d[T]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(m,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=m*t.volume()),a._emit("volume",y._id))}else return y=d?a._soundById(d):a._sounds[0],y?y._volume:0;return a},fade:function(a,l,m,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(a,l,m,d)}}),h;a=Math.min(Math.max(0,parseFloat(a)),1),l=Math.min(Math.max(0,parseFloat(l)),1),m=parseFloat(m),h.volume(a,d);for(var g=h._getSoundIds(d),y=0;y<g.length;y++){var T=h._soundById(g[y]);if(T){if(d||h._stopFade(g[y]),h._webAudio&&!T._muted){var v=t.ctx.currentTime,S=v+m/1e3;T._volume=a,T._node.gain.setValueAtTime(a,v),T._node.gain.linearRampToValueAtTime(l,S)}h._startFadeInterval(T,a,l,m,g[y],typeof d>"u")}}return h},_startFadeInterval:function(a,l,m,d,h,g){var y=this,T=l,v=m-l,S=Math.abs(v/.01),C=Math.max(4,S>0?d/S:d),x=Date.now();a._fadeTo=m,a._interval=setInterval(function(){var w=(Date.now()-x)/d;x=Date.now(),T+=v*w,T=Math.round(T*100)/100,v<0?T=Math.max(m,T):T=Math.min(m,T),y._webAudio?a._volume=T:y.volume(T,a._id,!0),g&&(y._volume=T),(m<l&&T<=m||m>l&&T>=m)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(m,a._id),y._emit("fade",a._id))},C)},_stopFade:function(a){var l=this,m=l._soundById(a);return m&&m._interval&&(l._webAudio&&m._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(m._interval),m._interval=null,l.volume(m._fadeTo,a),m._fadeTo=null,l._emit("fade",a)),l},loop:function(){var a=this,l=arguments,m,d,h;if(l.length===0)return a._loop;if(l.length===1)if(typeof l[0]=="boolean")m=l[0],a._loop=m;else return h=a._soundById(parseInt(l[0],10)),h?h._loop:!1;else l.length===2&&(m=l[0],d=parseInt(l[1],10));for(var g=a._getSoundIds(d),y=0;y<g.length;y++)h=a._soundById(g[y]),h&&(h._loop=m,a._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=m,m&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,a.playing(g[y])&&(a.pause(g[y],!0),a.play(g[y],!0)))));return a},rate:function(){var a=this,l=arguments,m,d;if(l.length===0)d=a._sounds[0]._id;else if(l.length===1){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):m=parseFloat(l[0])}else l.length===2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));var y;if(typeof m=="number"){if(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,l)}}),a;typeof d>"u"&&(a._rate=m),d=a._getSoundIds(d);for(var T=0;T<d.length;T++)if(y=a._soundById(d[T]),y){a.playing(d[T])&&(y._rateSeek=a.seek(d[T]),y._playStart=a._webAudio?t.ctx.currentTime:y._playStart),y._rate=m,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(m,t.ctx.currentTime):y._node&&(y._node.playbackRate=m);var v=a.seek(d[T]),S=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,C=S*1e3/Math.abs(y._rate);(a._endTimers[d[T]]||!y._paused)&&(a._clearTimer(d[T]),a._endTimers[d[T]]=setTimeout(a._ended.bind(a,y),C)),a._emit("rate",y._id)}}else return y=a._soundById(d),y?y._rate:a._rate;return a},seek:function(){var a=this,l=arguments,m,d;if(l.length===0)a._sounds.length&&(d=a._sounds[0]._id);else if(l.length===1){var h=a._getSoundIds(),g=h.indexOf(l[0]);g>=0?d=parseInt(l[0],10):a._sounds.length&&(d=a._sounds[0]._id,m=parseFloat(l[0]))}else l.length===2&&(m=parseFloat(l[0]),d=parseInt(l[1],10));if(typeof d>"u")return 0;if(typeof m=="number"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,l)}}),a;var y=a._soundById(d);if(y)if(typeof m=="number"&&m>=0){var T=a.playing(d);T&&a.pause(d,!0),y._seek=m,y._ended=!1,a._clearTimer(d),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=m);var v=function(){T&&a.play(d,!0),a._emit("seek",d)};if(T&&!a._webAudio){var S=function(){a._playLock?setTimeout(S,0):v()};setTimeout(S,0)}else v()}else if(a._webAudio){var C=a.playing(d)?t.ctx.currentTime-y._playStart:0,x=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(x+C*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var l=this;if(typeof a=="number"){var m=l._soundById(a);return m?!m._paused:!1}for(var d=0;d<l._sounds.length;d++)if(!l._sounds[d]._paused)return!0;return!1},duration:function(a){var l=this,m=l._duration,d=l._soundById(a);return d&&(m=l._sprite[d._sprite][1]/1e3),m},state:function(){return this._state},unload:function(){for(var a=this,l=a._sounds,m=0;m<l.length;m++)l[m]._paused||a.stop(l[m]._id),a._webAudio||(a._clearSound(l[m]._node),l[m]._node.removeEventListener("error",l[m]._errorFn,!1),l[m]._node.removeEventListener(t._canPlayEvent,l[m]._loadFn,!1),l[m]._node.removeEventListener("ended",l[m]._endFn,!1),t._releaseHtml5Audio(l[m]._node)),delete l[m]._node,a._clearTimer(l[m]._id);var d=t._howls.indexOf(a);d>=0&&t._howls.splice(d,1);var h=!0;for(m=0;m<t._howls.length;m++)if(t._howls[m]._src===a._src||a._src.indexOf(t._howls[m]._src)>=0){h=!1;break}return i&&h&&delete i[a._src],t.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,l,m,d){var h=this,g=h["_on"+a];return typeof l=="function"&&g.push(d?{id:m,fn:l,once:d}:{id:m,fn:l}),h},off:function(a,l,m){var d=this,h=d["_on"+a],g=0;if(typeof l=="number"&&(m=l,l=null),l||m)for(g=0;g<h.length;g++){var y=m===h[g].id;if(l===h[g].fn&&y||!l&&y){h.splice(g,1);break}}else if(a)d["_on"+a]=[];else{var T=Object.keys(d);for(g=0;g<T.length;g++)T[g].indexOf("_on")===0&&Array.isArray(d[T[g]])&&(d[T[g]]=[])}return d},once:function(a,l,m){var d=this;return d.on(a,l,m,1),d},_emit:function(a,l,m){for(var d=this,h=d["_on"+a],g=h.length-1;g>=0;g--)(!h[g].id||h[g].id===l||a==="load")&&(setTimeout(function(y){y.call(this,l,m)}.bind(d,h[g].fn),0),h[g].once&&d.off(a,h[g].fn,h[g].id));return d._loadQueue(a),d},_loadQueue:function(a){var l=this;if(l._queue.length>0){var m=l._queue[0];m.event===a&&(l._queue.shift(),l._loadQueue()),a||m.action()}return l},_ended:function(a){var l=this,m=a._sprite;if(!l._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(l._ended.bind(l,a),100),l;var d=!!(a._loop||l._sprite[m][2]);if(l._emit("end",a._id),!l._webAudio&&d&&l.stop(a._id,!0).play(a._id),l._webAudio&&d){l._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=t.ctx.currentTime;var h=(a._stop-a._start)*1e3/Math.abs(a._rate);l._endTimers[a._id]=setTimeout(l._ended.bind(l,a),h)}return l._webAudio&&!d&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,l._clearTimer(a._id),l._cleanBuffer(a._node),t._autoSuspend()),!l._webAudio&&!d&&l.stop(a._id,!0),l},_clearTimer:function(a){var l=this;if(l._endTimers[a]){if(typeof l._endTimers[a]!="function")clearTimeout(l._endTimers[a]);else{var m=l._soundById(a);m&&m._node&&m._node.removeEventListener("ended",l._endTimers[a],!1)}delete l._endTimers[a]}return l},_soundById:function(a){for(var l=this,m=0;m<l._sounds.length;m++)if(a===l._sounds[m]._id)return l._sounds[m];return null},_inactiveSound:function(){var a=this;a._drain();for(var l=0;l<a._sounds.length;l++)if(a._sounds[l]._ended)return a._sounds[l].reset();return new r(a)},_drain:function(){var a=this,l=a._pool,m=0,d=0;if(!(a._sounds.length<l)){for(d=0;d<a._sounds.length;d++)a._sounds[d]._ended&&m++;for(d=a._sounds.length-1;d>=0;d--){if(m<=l)return;a._sounds[d]._ended&&(a._webAudio&&a._sounds[d]._node&&a._sounds[d]._node.disconnect(0),a._sounds.splice(d,1),m--)}}},_getSoundIds:function(a){var l=this;if(typeof a>"u"){for(var m=[],d=0;d<l._sounds.length;d++)m.push(l._sounds[d]._id);return m}else return[a]},_refreshBuffer:function(a){var l=this;return a._node.bufferSource=t.ctx.createBufferSource(),a._node.bufferSource.buffer=i[l._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,t.ctx.currentTime),l},_cleanBuffer:function(a){var l=this,m=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!a.bufferSource)return l;if(t._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),m))try{a.bufferSource.buffer=t._scratchBuffer}catch{}return a.bufferSource=null,l},_clearSound:function(a){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(a){this._parent=a,this.init()};r.prototype={init:function(){var a=this,l=a._parent;return a._muted=l._muted,a._loop=l._loop,a._volume=l._volume,a._rate=l._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++t._counter,l._sounds.push(a),a.create(),a},create:function(){var a=this,l=a._parent,m=t._muted||a._muted||a._parent._muted?0:a._volume;return l._webAudio?(a._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),a._node.gain.setValueAtTime(m,t.ctx.currentTime),a._node.paused=!0,a._node.connect(t.masterGain)):t.noAudio||(a._node=t._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(t._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=l._src,a._node.preload=l._preload===!0?"auto":l._preload,a._node.volume=m*t.volume(),a._node.load()),a},reset:function(){var a=this,l=a._parent;return a._muted=l._muted,a._loop=l._loop,a._volume=l._volume,a._rate=l._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++t._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,l=a._parent;l._duration=Math.ceil(a._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),a._node.removeEventListener(t._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,l=a._parent;l._duration===1/0&&(l._duration=Math.ceil(a._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var i={},s=function(a){var l=a._src;if(i[l]){a._duration=i[l].duration,p(a);return}if(/^data:[^;]+;base64,/.test(l)){for(var m=atob(l.split(",")[1]),d=new Uint8Array(m.length),h=0;h<m.length;++h)d[h]=m.charCodeAt(h);u(d.buffer,a)}else{var g=new XMLHttpRequest;g.open(a._xhr.method,l,!0),g.withCredentials=a._xhr.withCredentials,g.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){g.setRequestHeader(y,a._xhr.headers[y])}),g.onload=function(){var y=(g.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+g.status+".");return}u(g.response,a)},g.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete i[l],a.load())},c(g)}},c=function(a){try{a.send()}catch{a.onerror()}},u=function(a,l){var m=function(){l._emit("loaderror",null,"Decoding audio data failed.")},d=function(h){h&&l._sounds.length>0?(i[l._src]=h,p(l,h)):m()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(a).then(d).catch(m):t.ctx.decodeAudioData(a,d,m)},p=function(a,l){l&&!a._duration&&(a._duration=l.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._loadQueue())},f=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var a=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),m=l?parseInt(l[1],10):null;if(a&&m&&m<9){var d=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!d&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:n}}),typeof Hs<"u"&&(Hs.Howler=t,Hs.Howl=n),typeof global<"u"?(global.HowlerGlobal=o,global.Howler=t,global.Howl=n,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=o,window.Howler=t,window.Howl=n,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var n=this;if(!n.ctx||!n.ctx.listener)return n;for(var r=n._howls.length-1;r>=0;r--)n._howls[r].stereo(t);return n},HowlerGlobal.prototype.pos=function(t,n,r){var i=this;if(!i.ctx||!i.ctx.listener)return i;if(n=typeof n!="number"?i._pos[1]:n,r=typeof r!="number"?i._pos[2]:r,typeof t=="number")i._pos=[t,n,r],typeof i.ctx.listener.positionX<"u"?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]);else return i._pos;return i},HowlerGlobal.prototype.orientation=function(t,n,r,i,s,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var p=u._orientation;if(n=typeof n!="number"?p[1]:n,r=typeof r!="number"?p[2]:r,i=typeof i!="number"?p[3]:i,s=typeof s!="number"?p[4]:s,c=typeof c!="number"?p[5]:c,typeof t=="number")u._orientation=[t,n,r,i,s,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(n,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,n,r,i,s,c);else return p;return u},Howl.prototype.init=function(t){return function(n){var r=this;return r._orientation=n.orientation||[1,0,0],r._stereo=n.stereo||null,r._pos=n.pos||null,r._pannerAttr={coneInnerAngle:typeof n.coneInnerAngle<"u"?n.coneInnerAngle:360,coneOuterAngle:typeof n.coneOuterAngle<"u"?n.coneOuterAngle:360,coneOuterGain:typeof n.coneOuterGain<"u"?n.coneOuterGain:0,distanceModel:typeof n.distanceModel<"u"?n.distanceModel:"inverse",maxDistance:typeof n.maxDistance<"u"?n.maxDistance:1e4,panningModel:typeof n.panningModel<"u"?n.panningModel:"HRTF",refDistance:typeof n.refDistance<"u"?n.refDistance:1,rolloffFactor:typeof n.rolloffFactor<"u"?n.rolloffFactor:1},r._onstereo=n.onstereo?[{fn:n.onstereo}]:[],r._onpos=n.onpos?[{fn:n.onpos}]:[],r._onorientation=n.onorientation?[{fn:n.onorientation}]:[],t.call(this,n)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,n){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,n)}}),r;var i=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof n>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var s=r._getSoundIds(n),c=0;c<s.length;c++){var u=r._soundById(s[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&o(u,i),i==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",u._id);else return u._stereo}return r},Howl.prototype.pos=function(t,n,r,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"pos",action:function(){s.pos(t,n,r,i)}}),s;if(n=typeof n!="number"?0:n,r=typeof r!="number"?-.5:r,typeof i>"u")if(typeof t=="number")s._pos=[t,n,r];else return s._pos;for(var c=s._getSoundIds(i),u=0;u<c.length;u++){var p=s._soundById(c[u]);if(p)if(typeof t=="number")p._pos=[t,n,r],p._node&&((!p._panner||p._panner.pan)&&o(p,"spatial"),typeof p._panner.positionX<"u"?(p._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.positionY.setValueAtTime(n,Howler.ctx.currentTime),p._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):p._panner.setPosition(t,n,r)),s._emit("pos",p._id);else return p._pos}return s},Howl.prototype.orientation=function(t,n,r,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"orientation",action:function(){s.orientation(t,n,r,i)}}),s;if(n=typeof n!="number"?s._orientation[1]:n,r=typeof r!="number"?s._orientation[2]:r,typeof i>"u")if(typeof t=="number")s._orientation=[t,n,r];else return s._orientation;for(var c=s._getSoundIds(i),u=0;u<c.length;u++){var p=s._soundById(c[u]);if(p)if(typeof t=="number")p._orientation=[t,n,r],p._node&&(p._panner||(p._pos||(p._pos=s._pos||[0,0,-.5]),o(p,"spatial")),typeof p._panner.orientationX<"u"?(p._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.orientationY.setValueAtTime(n,Howler.ctx.currentTime),p._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):p._panner.setOrientation(t,n,r)),s._emit("orientation",p._id);else return p._orientation}return s},Howl.prototype.pannerAttr=function(){var t=this,n=arguments,r,i,s;if(!t._webAudio)return t;if(n.length===0)return t._pannerAttr;if(n.length===1)if(typeof n[0]=="object")r=n[0],typeof i>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return s=t._soundById(parseInt(n[0],10)),s?s._pannerAttr:t._pannerAttr;else n.length===2&&(r=n[0],i=parseInt(n[1],10));for(var c=t._getSoundIds(i),u=0;u<c.length;u++)if(s=t._soundById(c[u]),s){var p=s._pannerAttr;p={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:p.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:p.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:p.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:p.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:p.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:p.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:p.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:p.panningModel};var f=s._panner;f||(s._pos||(s._pos=t._pos||[0,0,-.5]),o(s,"spatial"),f=s._panner),f.coneInnerAngle=p.coneInnerAngle,f.coneOuterAngle=p.coneOuterAngle,f.coneOuterGain=p.coneOuterGain,f.distanceModel=p.distanceModel,f.maxDistance=p.maxDistance,f.refDistance=p.refDistance,f.rolloffFactor=p.rolloffFactor,f.panningModel=p.panningModel}return t},Sound.prototype.init=function(t){return function(){var n=this,r=n._parent;n._orientation=r._orientation,n._stereo=r._stereo,n._pos=r._pos,n._pannerAttr=r._pannerAttr,t.call(this),n._stereo?r.stereo(n._stereo):n._pos&&r.pos(n._pos[0],n._pos[1],n._pos[2],n._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var n=this,r=n._parent;return n._orientation=r._orientation,n._stereo=r._stereo,n._pos=r._pos,n._pannerAttr=r._pannerAttr,n._stereo?r.stereo(n._stereo):n._pos?r.pos(n._pos[0],n._pos[1],n._pos[2],n._id):n._panner&&(n._panner.disconnect(0),n._panner=void 0,r._refreshBuffer(n)),t.call(this)}}(Sound.prototype.reset);var o=function(t,n){n=n||"spatial",n==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Ce={action:"displayable:action",applyTransform:"displayable:applyTransform",applyTransition:"displayable:applyTransition",init:"displayable:init"},jr={say:"character:say",action:"character:action",setName:"character:setName"},ge={action:"scene:action",init:"scene:init",exit:"scene:exit",jumpTo:"scene:jumpTo",setBackgroundMusic:"scene:setBackgroundMusic",preUnmount:"scene:preUnmount",transitionToScene:"scene:transitionToScene"};var rt={action:"image:action",setSrc:"image:setSrc",flush:"image:flush",initWearable:"image:initWearable",setAppearance:"image:setAppearance"},Cl={action:"condition:action"},wl={action:"script:action"},Pl={action:"menu:action"},nn={action:"sound:action",play:"sound:play",stop:"sound:stop",setVolume:"sound:setVolume",setRate:"sound:setRate",pause:"sound:pause",resume:"sound:resume"},ft={action:"control:action",do:"control:do",doAsync:"control:doAsync",any:"control:any",all:"control:all",allAsync:"control:allAsync",repeat:"control:repeat",sleep:"control:sleep"},$r={action:"text:action",setText:"text:setText",setFontSize:"text:setFontSize"},or={action:"persistent:action",set:"persistent:set",assign:"persistent:assign"},rr={action:"layer:action"},qn={action:"video:action",show:"video:show",hide:"video:hide",play:"video:play",pause:"video:pause",resume:"video:resume",stop:"video:stop",seek:"video:seek"};var El=(m=>(m[m.string=0]="string",m[m.number=1]="number",m[m.boolean=2]="boolean",m[m.object=3]="object",m[m.array=4]="array",m[m.function=5]="function",m[m.symbol=6]="symbol",m[m.undefined=7]="undefined",m[m.null=8]="null",m[m.date=9]="date",m[m.regexp=10]="regexp",m[m.other=11]="other",m))(El||{}),va=function(o){return typeof o=="string"?0:typeof o=="number"?1:typeof o=="boolean"?2:typeof o=="object"?Array.isArray(o)?4:o===null?8:o instanceof Date?9:o instanceof RegExp?10:3:typeof o=="function"?5:typeof o=="symbol"?6:typeof o>"u"?7:11};va.DataTypes=El;function U(o,t,...n){let r=(c,u)=>Object.prototype.hasOwnProperty.call(c,u),i={},s=(c,u,p)=>va(u)===3&&va(p)===3?u.constructor!==Object||p.constructor!==Object?p||u:U(u,p):Array.isArray(u)&&Array.isArray(p)?p&&p.length>0?[...p]:[...u]:u===void 0&&Array.isArray(p)?[...p]:p===void 0?Array.isArray(u)?[...u]:u:Array.isArray(p)?[...p]:p;for(let c in o)r(o,c)&&(i[c]=s(c,o[c],t[c]));for(let c in t)r(t,c)&&!r(i,c)&&(typeof t[c]=="object"&&t[c]!==null?t[c].constructor===Object?i[c]=U({},t[c]):Array.isArray(t[c])?i[c]=[...t[c]]:i[c]=t[c]:i[c]=t[c]);if(n.length){let[c,...u]=n;return U(i,c,...u)}return i}var dt=class dt{constructor(t=r=>r,n){this.solved=!1;this.aborted=!1;this.listeners=[];this.onRegisterSkipController=[];this.receiver=t,this.skipController=n,this.__stack=xa()}static isAwaitable(t){return t instanceof dt}static fromPromise(t){let n=new dt;return t.then(r=>n.resolve(r)),n}static resolve(t){let n=new dt;return n.resolve(t),n}static delay(t){let n=new dt;return setTimeout(()=>n.resolve(),t),n}static create(t){let n=new dt;return t(n),n}static wait(t){let n=new dt;return t.then(()=>n.resolve()),n}static race(t){let n=new dt;return t.length===0?(n.resolve(void 0),n):(t.forEach(r=>{r.then(i=>{t.forEach(s=>{s!==r&&s.skipController?.abort()}),n.resolve(i)})}),n.registerSkipController(new K(()=>{t.forEach(r=>r.skipController?.abort())})),n)}static forward(t,n,r){let i=new dt().registerSkipController(r||new K(()=>n));t.then(()=>i.resolve(n));let s=t.skipController?.onAbort(()=>{i.skipController?.abort(),s?.cancel(),c?.cancel()}),c=i.skipController?.onAbort(()=>{t.skipController?.abort(),s?.cancel(),c?.cancel()});return i}registerSkipController(t){this.skipController=t;for(let n of this.onRegisterSkipController)n(t);return this}resolve(t){if(!this.solved){this.result=this.receiver(t),this.solved=!0,this.skipController&&this.skipController.cancel();for(let n of this.listeners)n(this.result)}}then(t){return this.solved?t(this.result):this.listeners.push(t),this}onSettled(t){return this.solved?t():(this.listeners.push(t),this.onSkipControllerRegister(n=>{n.onAbort(()=>{t()})})),this}onSkipControllerRegister(t){return this.skipController?t(this.skipController):this.onRegisterSkipController.push(t),this}abort(){return this.aborted=!0,this.skipController?this.skipController.abort():this.result}isSolved(){return this.solved&&!this.aborted}isAborted(){return this.aborted}isSettled(){return this.solved||this.aborted}};dt.nothing=t=>t;var b=dt;function kl(o){let t=new WeakSet;function n(r){if(r===null||typeof r!="object")return r;if(t.has(r))return;if(t.add(r),Array.isArray(r)){let s=[];for(let c of r)s.push(n(c));return s}let i={};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=n(r[s]));return i}return n(o)}function Pn(o){return typeof o=="string"?o:`#${(o.r||0).toString(16).padStart(2,"0")}${(o.g||0).toString(16).padStart(2,"0")}${(o.b||0).toString(16).padStart(2,"0")}${o.a===void 0?"":o.a.toString(16).padStart(2,"0")}`}var re=class{constructor(){this.events={};this.maxListeners=10}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),this.events[t].length>this.maxListeners&&console.warn(`NarraLeaf-React: Event ${t} has more than ${this.maxListeners} listeners (total: ${this.events[t].length}), this may cause performance issues.`),this.emit("event:EventDispatcher.register",t,n),{type:t,listener:n,cancel:()=>{this.off(t,n)}}}depends(t){return{cancel:()=>{t.forEach(n=>n.cancel())}}}off(t,n){this.events[t]&&(this.events[t]=this.events[t].filter(r=>r!==n))}emit(t,...n){this.events[t]&&this.events[t].forEach(r=>{r(...n)})}once(t,n){let r=(...i)=>{n(...i),this.off(t,r)};return this.on(t,r)}async any(t,...n){if(this.events[t]||(this.events[t]=[]),this.events[t].length>0){await Promise.all(this.events[t].map(r=>r(...n)));return}return new Promise(r=>{let i="event:EventDispatcher.register",s=this.on(i,(c,u)=>{if(c===t){this.off(i,s);let p=u?.(...n);p!==null&&typeof p=="object"&&p.then?p.then(r):r(p)}}).listener})}setMaxListeners(t){return this.maxListeners=t,this}clear(){this.events={}}};function xa(o=1){let t=new Error().stack;return t?t.split(`
|
|
2
2
|
`).slice(o+1).join(`
|
|
3
|
-
`).trim():""}function xa(o){return new Promise(t=>setTimeout(t,o))}var Zr=class Zr{constructor(t){this.abortHandler=t;this.events=new re;this.aborted=!1}abort(...t){this.aborted||(this.aborted=!0,this.abortHandler(...t),this.events.emit(Zr.EventTypes["event:skipController.abort"]))}isAborted(){return this.aborted}cancel(){this.aborted=!0}onAbort(t){return this.events.on("event:skipController.abort",t)}};Zr.EventTypes={"event:skipController.abort":"event:skipController.abort"};var K=Zr;function Dl(o,t){let n=0;return function(...r){let i=Date.now();if(!(i-n<t))return n=i,o(...r)}}var va=class{constructor(){this.locked=!1;this.listeners=[];this.unlockListeners=[]}lock(){return this.locked=!0,this}unlock(){this.locked=!1;for(let t of this.listeners)t();for(let t of this.unlockListeners)t();return this.listeners=[],this}onUnlock(t){return this.unlockListeners.push(t),t}offUnlock(t){this.unlockListeners=this.unlockListeners.filter(n=>n!==t)}async nextUnlock(){if(this.locked)return new Promise(t=>{this.listeners.push(t)})}isLocked(){return this.locked}},Xn=class{constructor(){this.locks=[]}unlock(t){return t.unlock(),this.off(t),t}register(t){let n=t||new va;return this.locks.push(n),n}off(t){this.locks=this.locks.filter(n=>n!==t)}async nextUnlock(){let t=this.locks.map(n=>n.nextUnlock());return Promise.all(t)}isLocked(){return this.locks.some(t=>t.isLocked())}};function Jr(o,t,n={}){return o?t:n}function Rl(o,t){if(t<=0)return o;let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{o(...r)},t)}}var zr=class{constructor(){this.taskToken=null}scheduleTask(t,n){this.taskToken&&this.taskToken.cancel();let r=!1,i=setTimeout(()=>{r||t()},n);return this.taskToken={cancel:()=>{clearTimeout(i),r=!0},isCancelled:()=>r},this.taskToken}cancelTask(){return this.taskToken&&(this.taskToken.cancel(),this.taskToken=null),this}};function Il(o,t){let n=[];for(let r=0;r<Math.max(o.length,t.length);r++)r<o.length&&n.push(o[r]),r<t.length&&n.push(t[r]);return n}async function Ll(o,t){return new Promise((n,r)=>{fetch(o,t).then(i=>i.blob()).then(i=>{let s=new FileReader;s.onload=()=>{n(s.result)},s.readAsDataURL(i)}).catch(r)})}var ir=class{constructor(t,n){this.concurrency=t;this.delay=n;this.tasks=[]}addTask(t){this.tasks.push(t)}async start(){let t=async()=>{if(this.tasks.length===0)return;let n=this.tasks.splice(0,this.concurrency);await Promise.all(n.map(r=>r())),await xa(this.delay),await t()};await t()}};function rn(o){let t,n=Promise.resolve().then(()=>{t=o()});return()=>{n.then(()=>{t&&t()})}}function _l(o,t){let n={};for(let r in o)t.includes(r)||(n[r]=o[r]);return n}var rt=class o{constructor(t={},n={}){this.serializer=t;this.deserializer=n}serialize(t){let n={};for(let r of Object.keys(t))r in this.serializer&&t[r]!==void 0?n[r]=this.serializer[r]?.(t[r]):n[r]=t[r];return n}deserialize(t){let n={};for(let r of Object.keys(t))typeof this.deserializer[r]=="function"&&t[r]!==void 0?n[r]=this.deserializer[r](t[r]):n[r]=t[r];return n}extend(t,n){let r={...this.serializer,...t},i={...this.deserializer,...n};return new o(r,i)}};function Ml(o){return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].includes(o)}var on=class extends b{constructor(n){super();this.tasks=[];n&&this.registerSkipController(n)}addTask(n){return n?(this.tasks.push(n),this):this}abort(){this.current&&this.current.abort(),this.tasks.forEach(([n,r])=>{r&&r.abort()}),super.abort()}resolve(){}run(){return this.current?this:(this.onTaskComplete(),this)}onTaskComplete(){if(this.tasks.length===0){super.resolve();return}let[n,r]=this.tasks.shift(),i=new b(b.nothing,r);this.current=i,this.current.then(()=>this.onTaskComplete()),n(i)}};function Vl(o){return o.constructor.name==="AsyncFunction"||Object.prototype.toString.call(o)==="[object AsyncFunction]"}function ba(o){let t={};for(let n in o)o[n]!==void 0&&(t[n]=o[n]);return t}function Aa(o,t=new WeakSet){if(o===null||typeof o!="object"||Array.isArray(o)||o instanceof Date||o instanceof RegExp||Object.getPrototypeOf(o)!==Object.prototype||t.has(o))return!1;t.add(o);for(let n in o)if(Object.prototype.hasOwnProperty.call(o,n)){let r=o[n];if(r!==null&&typeof r=="object"&&!Aa(r,t)||typeof r=="function"||typeof r=="symbol")return!1}return!0}var qr=class{constructor(t=""){this.prefix=t;this.counter=0}next(){return`${this.prefix?this.prefix+"-":""}${this.counter++}`}};function Nl(o=16){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length;for(let i=0;i<o;i++)t+=n.charAt(Math.floor(Math.random()*r));return t}function Gl(o=16){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",n="";for(let r=0;r<o;r++)n+=t[Math.floor(Math.random()*t.length)];return n}var Fl=()=>()=>{},Xr=class{constructor(t=""){this.prefix=t;this.counter=0}generateId(){return`${this.prefix?this.prefix+"-":""}${this.counter++}`}},Yr=class{constructor(){this.hooks={}}hook(t,n){return this.hooks[t]=this.hooks[t]||[],this.hooks[t].push(n),{cancel:()=>this.unhook(t,n)}}unhook(t,n){this.hooks[t]=this.hooks[t]?.filter(r=>r!==n)||[]}trigger(t,n){let r=this.hooks[t];if(!r)return()=>{};let i=r.map(s=>s(...n));return()=>{i.forEach(s=>s&&s())}}rawTrigger(t,n){let r=this.hooks[t];if(!r)return()=>{};let i=r.map(s=>s(...n()));return()=>{i.forEach(s=>s&&s())}}};var sr=class{constructor(t,n,r){this.callee=t,this.type=n,this.contentNode=r,this.__stack=Sa(),this._id=""}executeAction(t){return{type:this.type,node:this.contentNode.getChild()}}getId(){return this._id}setId(t){this._id=t}setContent(t){return this.contentNode.setContent(t),this}setContentNode(t){return this.contentNode=t,this}getFutureActions(t,n){let r=this.contentNode.getChild();return r&&r.action?[r.action]:[]}};sr.ActionTypes={action:"action"};var $=class extends sr{constructor(t,n,r){super(t,n,r),this.callee=t.getSelf(),this.contentNode.action=this}unknownTypeError(){throw new Error("Unknown action type: "+this.type)}resolveAwaitable(t,n){let r=n||new b(i=>i);return(async()=>await t(r.resolve.bind(r),r))(),r}is(t,n){return this instanceof t&&this.type===n}};var Ca=class{constructor(t){this.type=t,this.content=void 0}setContent(t){return this.content=t,this}getContent(){return this.content}},D=class o extends Ca{static create(t){return new o().setContent(t)}static forEachParent(t,n){let r=new Set,i=t;for(;i&&!r.has(i);)r.add(i),n(i),i=i.getParent()}static forEachChild(t,n){let r=new Set,i=t;for(;i&&!r.has(i);)r.add(i),n(i),i=i.getChild()}constructor(t,n,r){super("ContentNode"),this.child=r||null,this.parent=n||null,this.action=t||null}setParent(t){if(t===this)throw new Error("Cannot set parent to itself");return this.parent=t,this}setChild(t){if(t===this)throw new Error("Cannot set child to itself");return this.child=t,t&&t.parent!==this&&t.remove().setParent(this),this}getChild(){return this.child||null}getParent(){return this.parent||null}addChild(t){return this.setChild(t),this}removeChild(t){return t&&this.child===t?(this.child=null,t.setParent(null)):t||(this.child=null),this}remove(){return this.parent?.removeChild(this),this}hasChild(){return!!this.child}};var Qr={center:"center",left:"left",right:"right"};import{jsx as jl,Fragment as lh}from"react/jsx-runtime";import{useMemo as uh,useRef as $l,useState as zl,useContext as ph}from"react";import{createContext as Wd}from"react";var Yn=Wd({});import{useRef as jd}from"react";function Zn(o){let t=jd(null);return t.current===null&&(t.current=o()),t.current}import{jsx as Ul}from"react/jsx-runtime";import*as Bl from"react";import{useId as Jd,useCallback as Qd,useMemo as Kl}from"react";import{createContext as $d}from"react";var sn=$d(null);import{jsx as qd}from"react/jsx-runtime";import*as ei from"react";import{useId as Xd,useRef as Ol,useContext as Yd,useInsertionEffect as Zd}from"react";import{createContext as zd}from"react";var Jn=zd({transformPagePoint:o=>o,isStatic:!1,reducedMotion:"never"});var wa=class extends ei.Component{getSnapshotBeforeUpdate(t){let n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){let r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function Hl({children:o,isPresent:t}){let n=Xd(),r=Ol(null),i=Ol({width:0,height:0,top:0,left:0}),{nonce:s}=Yd(Jn);return Zd(()=>{let{width:c,height:u,top:p,left:f}=i.current;if(t||!r.current||!c||!u)return;r.current.dataset.motionPopId=n;let a=document.createElement("style");return s&&(a.nonce=s),document.head.appendChild(a),a.sheet&&a.sheet.insertRule(`
|
|
3
|
+
`).trim():""}function Jr(o){return new Promise(t=>setTimeout(t,o))}var Zr=class Zr{constructor(t){this.abortHandler=t;this.events=new re;this.aborted=!1}abort(...t){this.aborted||(this.aborted=!0,this.abortHandler(...t),this.events.emit(Zr.EventTypes["event:skipController.abort"]))}isAborted(){return this.aborted}cancel(){this.aborted=!0}onAbort(t){return this.events.on("event:skipController.abort",t)}};Zr.EventTypes={"event:skipController.abort":"event:skipController.abort"};var K=Zr;function Dl(o,t){let n=0;return function(...r){let i=Date.now();if(!(i-n<t))return n=i,o(...r)}}var Sa=class{constructor(){this.locked=!1;this.listeners=[];this.unlockListeners=[]}lock(){return this.locked=!0,this}unlock(){this.locked=!1;for(let t of this.listeners)t();for(let t of this.unlockListeners)t();return this.listeners=[],this}onUnlock(t){return this.unlockListeners.push(t),t}offUnlock(t){this.unlockListeners=this.unlockListeners.filter(n=>n!==t)}async nextUnlock(){if(this.locked)return new Promise(t=>{this.listeners.push(t)})}isLocked(){return this.locked}},Xn=class{constructor(){this.locks=[]}unlock(t){return t.unlock(),this.off(t),t}register(t){let n=t||new Sa;return this.locks.push(n),n}off(t){this.locks=this.locks.filter(n=>n!==t)}async nextUnlock(){let t=this.locks.map(n=>n.nextUnlock());return Promise.all(t)}isLocked(){return this.locks.some(t=>t.isLocked())}};function Qr(o,t,n={}){return o?t:n}function Rl(o,t){if(t<=0)return o;let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{o(...r)},t)}}var zr=class{constructor(){this.taskToken=null}scheduleTask(t,n){this.taskToken&&this.taskToken.cancel();let r=!1,i=setTimeout(()=>{r||t()},n);return this.taskToken={cancel:()=>{clearTimeout(i),r=!0},isCancelled:()=>r},this.taskToken}cancelTask(){return this.taskToken&&(this.taskToken.cancel(),this.taskToken=null),this}};function Il(o,t){let n=[];for(let r=0;r<Math.max(o.length,t.length);r++)r<o.length&&n.push(o[r]),r<t.length&&n.push(t[r]);return n}async function Ll(o,t){return new Promise((n,r)=>{fetch(o,t).then(i=>i.blob()).then(i=>{let s=new FileReader;s.onload=()=>{n(s.result)},s.readAsDataURL(i)}).catch(r)})}var ir=class{constructor(t,n){this.concurrency=t;this.delay=n;this.tasks=[]}addTask(t){this.tasks.push(t)}async start(){let t=async()=>{if(this.tasks.length===0)return;let n=this.tasks.splice(0,this.concurrency);await Promise.all(n.map(r=>r())),await Jr(this.delay),await t()};await t()}};function rn(o){let t,n=Promise.resolve().then(()=>{t=o()});return()=>{n.then(()=>{t&&t()})}}function _l(o,t){let n={};for(let r in o)t.includes(r)||(n[r]=o[r]);return n}var it=class o{constructor(t={},n={}){this.serializer=t;this.deserializer=n}serialize(t){let n={};for(let r of Object.keys(t))r in this.serializer&&t[r]!==void 0?n[r]=this.serializer[r]?.(t[r]):n[r]=t[r];return n}deserialize(t){let n={};for(let r of Object.keys(t))typeof this.deserializer[r]=="function"&&t[r]!==void 0?n[r]=this.deserializer[r](t[r]):n[r]=t[r];return n}extend(t,n){let r={...this.serializer,...t},i={...this.deserializer,...n};return new o(r,i)}};function Ml(o){return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].includes(o)}var on=class extends b{constructor(n){super();this.tasks=[];n&&this.registerSkipController(n)}addTask(n){return n?(this.tasks.push(n),this):this}abort(){this.current&&this.current.abort(),this.tasks.forEach(([n,r])=>{r&&r.abort()}),super.abort()}resolve(){}run(){return this.current?this:(this.onTaskComplete(),this)}onTaskComplete(){if(this.tasks.length===0){super.resolve();return}let[n,r]=this.tasks.shift(),i=new b(b.nothing,r);this.current=i,this.current.then(()=>this.onTaskComplete()),n(i)}};function Vl(o){return o.constructor.name==="AsyncFunction"||Object.prototype.toString.call(o)==="[object AsyncFunction]"}function ba(o){let t={};for(let n in o)o[n]!==void 0&&(t[n]=o[n]);return t}function Aa(o,t=new WeakSet){if(o===null||typeof o!="object"||Array.isArray(o)||o instanceof Date||o instanceof RegExp||Object.getPrototypeOf(o)!==Object.prototype||t.has(o))return!1;t.add(o);for(let n in o)if(Object.prototype.hasOwnProperty.call(o,n)){let r=o[n];if(r!==null&&typeof r=="object"&&!Aa(r,t)||typeof r=="function"||typeof r=="symbol")return!1}return!0}var qr=class{constructor(t=""){this.prefix=t;this.counter=0}next(){return`${this.prefix?this.prefix+"-":""}${this.counter++}`}};function Nl(o=16){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length;for(let i=0;i<o;i++)t+=n.charAt(Math.floor(Math.random()*r));return t}function Gl(o=16){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",n="";for(let r=0;r<o;r++)n+=t[Math.floor(Math.random()*t.length)];return n}var Fl=()=>()=>{},Xr=class{constructor(t=""){this.prefix=t;this.counter=0}generateId(){return`${this.prefix?this.prefix+"-":""}${this.counter++}`}},Yr=class{constructor(){this.hooks={}}hook(t,n){return this.hooks[t]=this.hooks[t]||[],this.hooks[t].push(n),{cancel:()=>this.unhook(t,n)}}unhook(t,n){this.hooks[t]=this.hooks[t]?.filter(r=>r!==n)||[]}trigger(t,n){let r=this.hooks[t];if(!r)return()=>{};let i=r.map(s=>s(...n));return()=>{i.forEach(s=>s&&s())}}rawTrigger(t,n){let r=this.hooks[t];if(!r)return()=>{};let i=r.map(s=>s(...n()));return()=>{i.forEach(s=>s&&s())}}};var sr=class{constructor(t,n,r){this.callee=t,this.type=n,this.contentNode=r,this.__stack=xa(),this._id=""}executeAction(t){return{type:this.type,node:this.contentNode.getChild()}}getId(){return this._id}setId(t){this._id=t}setContent(t){return this.contentNode.setContent(t),this}setContentNode(t){return this.contentNode=t,this}getFutureActions(t,n){let r=this.contentNode.getChild();return r&&r.action?[r.action]:[]}};sr.ActionTypes={action:"action"};var $=class extends sr{constructor(t,n,r){super(t,n,r),this.callee=t.getSelf(),this.contentNode.action=this}unknownTypeError(){throw new Error("Unknown action type: "+this.type)}resolveAwaitable(t,n){let r=n||new b(i=>i);return(async()=>await t(r.resolve.bind(r),r))(),r}is(t,n){return this instanceof t&&this.type===n}};var Ca=class{constructor(t){this.type=t,this.content=void 0}setContent(t){return this.content=t,this}getContent(){return this.content}},D=class o extends Ca{static create(t){return new o().setContent(t)}static forEachParent(t,n){let r=new Set,i=t;for(;i&&!r.has(i);)r.add(i),n(i),i=i.getParent()}static forEachChild(t,n){let r=new Set,i=t;for(;i&&!r.has(i);)r.add(i),n(i),i=i.getChild()}constructor(t,n,r){super("ContentNode"),this.child=r||null,this.parent=n||null,this.action=t||null}setParent(t){if(t===this)throw new Error("Cannot set parent to itself");return this.parent=t,this}setChild(t){if(t===this)throw new Error("Cannot set child to itself");return this.child=t,t&&t.parent!==this&&t.remove().setParent(this),this}getChild(){return this.child||null}getParent(){return this.parent||null}addChild(t){return this.setChild(t),this}removeChild(t){return t&&this.child===t?(this.child=null,t.setParent(null)):t||(this.child=null),this}remove(){return this.parent?.removeChild(this),this}hasChild(){return!!this.child}};var ei={center:"center",left:"left",right:"right"};import{jsx as jl,Fragment as lh}from"react/jsx-runtime";import{useMemo as uh,useRef as $l,useState as zl,useContext as ph}from"react";import{createContext as Wd}from"react";var Yn=Wd({});import{useRef as jd}from"react";function Zn(o){let t=jd(null);return t.current===null&&(t.current=o()),t.current}import{jsx as Ul}from"react/jsx-runtime";import*as Bl from"react";import{useId as Jd,useCallback as Qd,useMemo as Kl}from"react";import{createContext as $d}from"react";var sn=$d(null);import{jsx as qd}from"react/jsx-runtime";import*as ti from"react";import{useId as Xd,useRef as Ol,useContext as Yd,useInsertionEffect as Zd}from"react";import{createContext as zd}from"react";var Jn=zd({transformPagePoint:o=>o,isStatic:!1,reducedMotion:"never"});var wa=class extends ti.Component{getSnapshotBeforeUpdate(t){let n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){let r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function Hl({children:o,isPresent:t}){let n=Xd(),r=Ol(null),i=Ol({width:0,height:0,top:0,left:0}),{nonce:s}=Yd(Jn);return Zd(()=>{let{width:c,height:u,top:p,left:f}=i.current;if(t||!r.current||!c||!u)return;r.current.dataset.motionPopId=n;let a=document.createElement("style");return s&&(a.nonce=s),document.head.appendChild(a),a.sheet&&a.sheet.insertRule(`
|
|
4
4
|
[data-motion-pop-id="${n}"] {
|
|
5
5
|
position: absolute !important;
|
|
6
6
|
width: ${c}px !important;
|
|
@@ -8,9 +8,9 @@ var Md=Object.create;var ya=Object.defineProperty;var Vd=Object.getOwnPropertyDe
|
|
|
8
8
|
top: ${p}px !important;
|
|
9
9
|
left: ${f}px !important;
|
|
10
10
|
}
|
|
11
|
-
`),()=>{document.head.removeChild(a)}},[t]),qd(wa,{isPresent:t,childRef:r,sizeRef:i,children:ei.cloneElement(o,{ref:r})})}var Wl=({children:o,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:c})=>{let u=Zn(eh),p=Jd(),f=Qd(l=>{u.set(l,!0);for(let m of u.values())if(!m)return;r&&r()},[u,r]),a=Kl(()=>({id:p,initial:t,isPresent:n,custom:i,onExitComplete:f,register:l=>(u.set(l,!1),()=>u.delete(l))}),s?[Math.random(),f]:[n,f]);return Kl(()=>{u.forEach((l,m)=>u.set(m,!1))},[n]),Bl.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),c==="popLayout"&&(o=Ul(Hl,{isPresent:n,children:o})),Ul(sn.Provider,{value:a,children:o})};function eh(){return new Map}import{useContext as th,useId as nh,useEffect as oh,useCallback as rh}from"react";function ti(o=!0){let t=th(sn);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,s=nh();oh(()=>{o&&i(s)},[o]);let c=rh(()=>o&&r&&r(s),[s,r,o]);return!n&&r?[!1,c]:[!0]}import{Children as ih,isValidElement as sh}from"react";var ar=o=>o.key||"";function Pa(o){let t=[];return ih.forEach(o,n=>{sh(n)&&t.push(n)}),t}import{useLayoutEffect as ah,useEffect as ch}from"react";var Qn=typeof window<"u";var ni=Qn?ah:ch;var cr=({children:o,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:c=!1})=>{let[u,p]=ti(c),f=uh(()=>Pa(o),[o]),a=c&&!u?[]:f.map(ar),l=$l(!0),m=$l(f),d=Zn(()=>new Map),[h,g]=zl(f),[y,T]=zl(f);ni(()=>{l.current=!1,m.current=f;for(let C=0;C<y.length;C++){let x=ar(y[C]);a.includes(x)?d.delete(x):d.get(x)!==!0&&d.set(x,!1)}},[y,a.length,a.join("-")]);let v=[];if(f!==h){let C=[...f];for(let x=0;x<y.length;x++){let w=y[x],_=ar(w);a.includes(_)||(C.splice(x,0,w),v.push(w))}s==="wait"&&v.length&&(C=v),T(Pa(C)),g(f);return}let{forceRender:S}=ph(Yn);return jl(lh,{children:y.map(C=>{let x=ar(C),w=c&&!u?!1:f===y||a.includes(x),_=()=>{if(d.has(x))d.set(x,!0);else return;let A=!0;d.forEach(P=>{P||(A=!1)}),A&&(S?.(),T(m.current),c&&p?.(),r&&r())};return jl(Wl,{isPresent:w,initial:!l.current||n?void 0:!1,custom:w?void 0:t,presenceAffectsLayout:i,mode:s,onExitComplete:w?void 0:_,children:C},x)})})};var te=o=>o;var an=te,Ye=te;var eo={skipAnimations:!1,useManualTiming:!1};function ql(o){let t=new Set,n=new Set,r=!1,i=!1,s=new WeakSet,c={delta:0,timestamp:0,isProcessing:!1};function u(f){s.has(f)&&(p.schedule(f),o()),f(c)}let p={schedule:(f,a=!1,l=!1)=>{let d=l&&r?t:n;return a&&s.add(f),d.has(f)||d.add(f),f},cancel:f=>{n.delete(f),s.delete(f)},process:f=>{if(c=f,r){i=!0;return}r=!0,[t,n]=[n,t],t.forEach(u),t.clear(),r=!1,i&&(i=!1,p.process(f))}};return p}var oi=["read","resolveKeyframes","update","preRender","render","postRender"],mh=40;function ri(o,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,c=oi.reduce((T,v)=>(T[v]=ql(s),T),{}),{read:u,resolveKeyframes:p,update:f,preRender:a,render:l,postRender:m}=c,d=()=>{let T=eo.useManualTiming?i.timestamp:performance.now();n=!1,i.delta=r?1e3/60:Math.max(Math.min(T-i.timestamp,mh),1),i.timestamp=T,i.isProcessing=!0,u.process(i),p.process(i),f.process(i),a.process(i),l.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,o(d))},h=()=>{n=!0,r=!0,i.isProcessing||o(d)};return{schedule:oi.reduce((T,v)=>{let S=c[v];return T[v]=(C,x=!1,w=!1)=>(n||h(),S.schedule(C,x,w)),T},{}),cancel:T=>{for(let v=0;v<oi.length;v++)c[oi[v]].cancel(T)},state:i,steps:c}}var{schedule:L,cancel:Ze,state:pe,steps:ii}=ri(typeof requestAnimationFrame<"u"?requestAnimationFrame:te,!0);import{createContext as fh}from"react";var si=fh({strict:!1});var Xl={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},It={};for(let o in Xl)It[o]={isEnabled:t=>Xl[o].some(n=>!!t[n])};function Yl(o){for(let t in o)It[t]={...It[t],...o[t]}}var dh=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function lr(o){return o.startsWith("while")||o.startsWith("drag")&&o!=="draggable"||o.startsWith("layout")||o.startsWith("onTap")||o.startsWith("onPan")||o.startsWith("onLayout")||dh.has(o)}var Zl=o=>!lr(o);function hh(o){o&&(Zl=t=>t.startsWith("on")?!lr(t):o(t))}try{hh(Od("@emotion/is-prop-valid").default)}catch{}function Jl(o,t,n){let r={};for(let i in o)i==="values"&&typeof o.values=="object"||(Zl(i)||n===!0&&lr(i)||!t&&!lr(i)||o.draggable&&i.startsWith("onDrag"))&&(r[i]=o[i]);return r}function Ql(o){if(typeof Proxy>"u")return o;let t=new Map,n=(...r)=>o(...r);return new Proxy(n,{get:(r,i)=>i==="create"?o:(t.has(i)||t.set(i,o(i)),t.get(i))})}import{jsxs as wh,jsx as Ph}from"react/jsx-runtime";import{forwardRef as Eh,useContext as ka}from"react";import{createContext as gh}from"react";var cn=gh({});import{useContext as yh,useMemo as Th}from"react";function Lt(o){return typeof o=="string"||Array.isArray(o)}function ln(o){return o!==null&&typeof o=="object"&&typeof o.start=="function"}var ai=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ur=["initial",...ai];function En(o){return ln(o.animate)||ur.some(t=>Lt(o[t]))}function ci(o){return!!(En(o)||o.variants)}function eu(o,t){if(En(o)){let{initial:n,animate:r}=o;return{initial:n===!1||Lt(n)?n:void 0,animate:Lt(r)?r:void 0}}return o.inherit!==!1?t:{}}function nu(o){let{initial:t,animate:n}=eu(o,yh(cn));return Th(()=>({initial:t,animate:n}),[tu(t),tu(n)])}function tu(o){return Array.isArray(o)?o.join(" "):o}var ou=Symbol.for("motionComponentSymbol");import{useCallback as vh}from"react";function _t(o){return o&&typeof o=="object"&&Object.prototype.hasOwnProperty.call(o,"current")}function ru(o,t,n){return vh(r=>{r&&o.onMount&&o.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):_t(n)&&(n.current=r))},[t])}import{useContext as pr,useRef as Ea,useInsertionEffect as bh,useEffect as Ah}from"react";var to=o=>o.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase();var Sh="framerAppearId",li="data-"+to(Sh);var{schedule:no,cancel:Rx}=ri(queueMicrotask,!1);import{createContext as xh}from"react";var ui=xh({});function iu(o,t,n,r,i){var s,c;let{visualElement:u}=pr(cn),p=pr(si),f=pr(sn),a=pr(Jn).reducedMotion,l=Ea(null);r=r||p.renderer,!l.current&&r&&(l.current=r(o,{visualState:t,parent:u,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:a}));let m=l.current,d=pr(ui);m&&!m.projection&&i&&(m.type==="html"||m.type==="svg")&&Ch(l.current,n,i,d);let h=Ea(!1);bh(()=>{m&&h.current&&m.update(n,f)});let g=n[li],y=Ea(!!g&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,g))&&((c=window.MotionHasOptimisedAnimation)===null||c===void 0?void 0:c.call(window,g)));return ni(()=>{m&&(h.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),no.render(m.render),y.current&&m.animationState&&m.animationState.animateChanges())}),Ah(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{var T;(T=window.MotionHandoffMarkAsComplete)===null||T===void 0||T.call(window,g)}),y.current=!1))}),m}function Ch(o,t,n,r){let{layoutId:i,layout:s,drag:c,dragConstraints:u,layoutScroll:p,layoutRoot:f}=t;o.projection=new n(o.latestValues,t["data-framer-portal-id"]?void 0:su(o.parent)),o.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!c||u&&_t(u),visualElement:o,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,layoutScroll:p,layoutRoot:f})}function su(o){if(o)return o.options.allowProjection!==!1?o.projection:su(o.parent)}function au({preloadedFeatures:o,createVisualElement:t,useRender:n,useVisualState:r,Component:i}){var s,c;o&&Yl(o);function u(f,a){let l,m={...ka(Jn),...f,layoutId:kh(f)},{isStatic:d}=m,h=nu(f),g=r(f,d);if(!d&&Qn){Dh(m,o);let y=Rh(m);l=y.MeasureLayout,h.visualElement=iu(i,g,m,t,y.ProjectionNode)}return wh(cn.Provider,{value:h,children:[l&&h.visualElement?Ph(l,{visualElement:h.visualElement,...m}):null,n(i,f,ru(g,h.visualElement,a),g,d,h.visualElement)]})}u.displayName=`motion.${typeof i=="string"?i:`create(${(c=(s=i.displayName)!==null&&s!==void 0?s:i.name)!==null&&c!==void 0?c:""})`}`;let p=Eh(u);return p[ou]=i,p}function kh({layoutId:o}){let t=ka(Yn).id;return t&&o!==void 0?t+"-"+o:o}function Dh(o,t){let n=ka(si).strict}function Rh(o){let{drag:t,layout:n}=It;if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(o)||n?.isEnabled(o)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}var cu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function oo(o){return typeof o!="string"||o.includes("-")?!1:!!(cu.indexOf(o)>-1||/[A-Z]/u.test(o))}import{useContext as mu}from"react";function lu(o){let t=[{},{}];return o?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ro(o,t,n,r){if(typeof t=="function"){let[i,s]=lu(r);t=t(n!==void 0?n:o.custom,i,s)}if(typeof t=="string"&&(t=o.variants&&o.variants[t]),typeof t=="function"){let[i,s]=lu(r);t=t(n!==void 0?n:o.custom,i,s)}return t}var mr=o=>Array.isArray(o);var uu=o=>!!(o&&typeof o=="object"&&o.mix&&o.toValue),pu=o=>mr(o)?o[o.length-1]||0:o;var z=o=>!!(o&&o.getVelocity);function io(o){let t=z(o)?o.get():o;return uu(t)?t.toValue():t}function Ih({scrapeMotionValuesFromProps:o,createRenderState:t,onUpdate:n},r,i,s){let c={latestValues:Lh(r,i,s,o),renderState:t()};return n&&(c.onMount=u=>n({props:r,current:u,...c}),c.onUpdate=u=>n(u)),c}var pi=o=>(t,n)=>{let r=mu(cn),i=mu(sn),s=()=>Ih(o,t,r,i);return n?s():Zn(s)};function Lh(o,t,n,r){let i={},s=r(o,{});for(let m in s)i[m]=io(s[m]);let{initial:c,animate:u}=o,p=En(o),f=ci(o);t&&f&&!p&&o.inherit!==!1&&(c===void 0&&(c=t.initial),u===void 0&&(u=t.animate));let a=n?n.initial===!1:!1;a=a||c===!1;let l=a?u:c;if(l&&typeof l!="boolean"&&!ln(l)){let m=Array.isArray(l)?l:[l];for(let d=0;d<m.length;d++){let h=ro(o,m[d]);if(h){let{transitionEnd:g,transition:y,...T}=h;for(let v in T){let S=T[v];if(Array.isArray(S)){let C=a?S.length-1:0;S=S[C]}S!==null&&(i[v]=S)}for(let v in g)i[v]=g[v]}}}return i}var St=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],je=new Set(St);var fu=o=>t=>typeof t=="string"&&t.startsWith(o),mi=fu("--"),_h=fu("var(--"),so=o=>_h(o)?Mh.test(o.split("/*")[0].trim()):!1,Mh=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;var fi=(o,t)=>t&&typeof o=="number"?t.transform(o):o;var we=(o,t,n)=>n>t?t:n<o?o:n;var xt={test:o=>typeof o=="number",parse:parseFloat,transform:o=>o},Mt={...xt,transform:o=>we(0,1,o)},fr={...xt,default:1};var dr=o=>({test:t=>typeof t=="string"&&t.endsWith(o)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${o}`}),bt=dr("deg"),He=dr("%"),E=dr("px"),du=dr("vh"),hu=dr("vw"),Da={...He,parse:o=>He.parse(o)/100,transform:o=>He.transform(o*100)};var gu={borderWidth:E,borderTopWidth:E,borderRightWidth:E,borderBottomWidth:E,borderLeftWidth:E,borderRadius:E,radius:E,borderTopLeftRadius:E,borderTopRightRadius:E,borderBottomRightRadius:E,borderBottomLeftRadius:E,width:E,maxWidth:E,height:E,maxHeight:E,top:E,right:E,bottom:E,left:E,padding:E,paddingTop:E,paddingRight:E,paddingBottom:E,paddingLeft:E,margin:E,marginTop:E,marginRight:E,marginBottom:E,marginLeft:E,backgroundPositionX:E,backgroundPositionY:E};var yu={rotate:bt,rotateX:bt,rotateY:bt,rotateZ:bt,scale:fr,scaleX:fr,scaleY:fr,scaleZ:fr,skew:bt,skewX:bt,skewY:bt,distance:E,translateX:E,translateY:E,translateZ:E,x:E,y:E,z:E,perspective:E,transformPerspective:E,opacity:Mt,originX:Da,originY:Da,originZ:E};var Ra={...xt,transform:Math.round};var ao={...gu,...yu,zIndex:Ra,size:E,fillOpacity:Mt,strokeOpacity:Mt,numOctaves:Ra};var Vh={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Nh=St.length;function Tu(o,t,n){let r="",i=!0;for(let s=0;s<Nh;s++){let c=St[s],u=o[c];if(u===void 0)continue;let p=!0;if(typeof u=="number"?p=u===(c.startsWith("scale")?1:0):p=parseFloat(u)===0,!p||n){let f=fi(u,ao[c]);if(!p){i=!1;let a=Vh[c]||c;r+=`${a}(${f}) `}n&&(t[c]=f)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function co(o,t,n){let{style:r,vars:i,transformOrigin:s}=o,c=!1,u=!1;for(let p in t){let f=t[p];if(je.has(p)){c=!0;continue}else if(mi(p)){i[p]=f;continue}else{let a=fi(f,ao[p]);p.startsWith("origin")?(u=!0,s[p]=a):r[p]=a}}if(t.transform||(c||n?r.transform=Tu(t,o.transform,n):r.transform&&(r.transform="none")),u){let{originX:p="50%",originY:f="50%",originZ:a=0}=s;r.transformOrigin=`${p} ${f} ${a}`}}var Gh={offset:"stroke-dashoffset",array:"stroke-dasharray"},Fh={offset:"strokeDashoffset",array:"strokeDasharray"};function vu(o,t,n=1,r=0,i=!0){o.pathLength=1;let s=i?Gh:Fh;o[s.offset]=E.transform(-r);let c=E.transform(t),u=E.transform(n);o[s.array]=`${c} ${u}`}function Su(o,t,n){return typeof o=="string"?o:E.transform(t+n*o)}function xu(o,t,n){let r=Su(t,o.x,o.width),i=Su(n,o.y,o.height);return`${r} ${i}`}function lo(o,{attrX:t,attrY:n,attrScale:r,originX:i,originY:s,pathLength:c,pathSpacing:u=1,pathOffset:p=0,...f},a,l){if(co(o,f,l),a){o.style.viewBox&&(o.attrs.viewBox=o.style.viewBox);return}o.attrs=o.style,o.style={};let{attrs:m,style:d,dimensions:h}=o;m.transform&&(h&&(d.transform=m.transform),delete m.transform),h&&(i!==void 0||s!==void 0||d.transform)&&(d.transformOrigin=xu(h,i!==void 0?i:.5,s!==void 0?s:.5)),t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),r!==void 0&&(m.scale=r),c!==void 0&&vu(m,c,u,p,!1)}var uo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});var di=()=>({...uo(),attrs:{}});var po=o=>typeof o=="string"&&o.toLowerCase()==="svg";function hi(o,{style:t,vars:n},r,i){Object.assign(o.style,t,i&&i.getProjectionStyles(r));for(let s in n)o.style.setProperty(s,n[s])}var gi=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function yi(o,t,n,r){hi(o,t,void 0,r);for(let i in t.attrs)o.setAttribute(gi.has(i)?i:to(i),t.attrs[i])}var mo={};function bu(o){Object.assign(mo,o)}function Ti(o,{layout:t,layoutId:n}){return je.has(o)||o.startsWith("origin")||(t||n!==void 0)&&(!!mo[o]||o==="opacity")}function fo(o,t,n){var r;let{style:i}=o,s={};for(let c in i)(z(i[c])||t.style&&z(t.style[c])||Ti(c,o)||((r=n?.getValue(c))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(s[c]=i[c]);return s}function vi(o,t,n){let r=fo(o,t,n);for(let i in o)if(z(o[i])||z(t[i])){let s=St.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=o[i]}return r}function Oh(o,t){try{t.dimensions=typeof o.getBBox=="function"?o.getBBox():o.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}var Au=["x","y","width","height","cx","cy","r"],Cu={useVisualState:pi({scrapeMotionValuesFromProps:vi,createRenderState:di,onUpdate:({props:o,prevProps:t,current:n,renderState:r,latestValues:i})=>{if(!n)return;let s=!!o.drag;if(!s){for(let u in i)if(je.has(u)){s=!0;break}}if(!s)return;let c=!t;if(t)for(let u=0;u<Au.length;u++){let p=Au[u];o[p]!==t[p]&&(c=!0)}c&&L.read(()=>{Oh(n,r),L.render(()=>{lo(r,i,po(n.tagName),o.transformTemplate),yi(n,r)})})}})};var wu={useVisualState:pi({scrapeMotionValuesFromProps:fo,createRenderState:uo})};import{Fragment as Wh,useMemo as jh,createElement as $h}from"react";import{useMemo as Hh}from"react";function Ia(o,t,n){for(let r in t)!z(t[r])&&!Ti(r,n)&&(o[r]=t[r])}function Uh({transformTemplate:o},t){return Hh(()=>{let n=uo();return co(n,t,o),Object.assign({},n.vars,n.style)},[t])}function Kh(o,t){let n=o.style||{},r={};return Ia(r,n,o),Object.assign(r,Uh(o,t)),r}function Pu(o,t){let n={},r=Kh(o,t);return o.drag&&o.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=o.drag===!0?"none":`pan-${o.drag==="x"?"y":"x"}`),o.tabIndex===void 0&&(o.onTap||o.onTapStart||o.whileTap)&&(n.tabIndex=0),n.style=r,n}import{useMemo as Bh}from"react";function Eu(o,t,n,r){let i=Bh(()=>{let s=di();return lo(s,t,po(r),o.transformTemplate),{...s.attrs,style:{...s.style}}},[t]);if(o.style){let s={};Ia(s,o.style,o),i.style={...s,...i.style}}return i}function ku(o=!1){return(n,r,i,{latestValues:s},c)=>{let p=(oo(n)?Eu:Pu)(r,s,c,n),f=Jl(r,typeof n=="string",o),a=n!==Wh?{...f,...p,ref:i}:{},{children:l}=r,m=jh(()=>z(l)?l.get():l,[l]);return $h(n,{...a,children:m})}}function Du(o,t){return function(r,{forwardMotionProps:i}={forwardMotionProps:!1}){let c={...oo(r)?Cu:wu,preloadedFeatures:o,useRender:ku(i),createVisualElement:t,Component:r};return au(c)}}function La(o,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==o.length)return!1;for(let r=0;r<n;r++)if(t[r]!==o[r])return!1;return!0}function un(o,t,n){let r=o.getProps();return ro(r,t,n!==void 0?n:r.custom,o)}function ho(o,t){return o?o[t]||o.default||o:void 0}var Si=new Set(["width","height","top","left","right","bottom",...St]);var xi;function zh(){xi=void 0}var _e={now:()=>(xi===void 0&&_e.set(pe.isProcessing||eo.useManualTiming?pe.timestamp:performance.now()),xi),set:o=>{xi=o,queueMicrotask(zh)}};function go(o,t){o.indexOf(t)===-1&&o.push(t)}function pn(o,t){let n=o.indexOf(t);n>-1&&o.splice(n,1)}var mn=class{constructor(){this.subscriptions=[]}add(t){return go(this.subscriptions,t),()=>pn(this.subscriptions,t)}notify(t,n,r){let i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let s=0;s<i;s++){let c=this.subscriptions[s];c&&c(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}};function bi(o,t){return t?o*(1e3/t):0}var Ru=30,qh=o=>!isNaN(parseFloat(o)),Iu={current:void 0},_a=class{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,i=!0)=>{let s=_e.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=_e.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=qh(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new mn);let r=this.events[t].add(n);return t==="change"?()=>{r(),L.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(let t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return Iu.current&&Iu.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let t=_e.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Ru)return 0;let n=Math.min(this.updatedAt-this.prevUpdatedAt,Ru);return bi(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Vt(o,t){return new _a(o,t)}function Xh(o,t,n){o.hasValue(t)?o.getValue(t).set(n):o.addValue(t,Vt(n))}function Lu(o,t){let n=un(o,t),{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(let c in s){let u=pu(s[c]);Xh(o,c,u)}}function _u(o){return!!(z(o)&&o.add)}function hr(o,t){let n=o.getValue("willChange");if(_u(n))return n.add(t)}function Ai(o){return o.props[li]}function yo(o){let t;return()=>(t===void 0&&(t=o()),t)}var Mu=yo(()=>window.ScrollTimeline!==void 0);var Ci=class{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t,n){let r=this.animations.map(i=>{if(Mu()&&i.attachTimeline)return i.attachTimeline(t);if(typeof n=="function")return n(i)});return()=>{r.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}};var To=class extends Ci{then(t,n){return Promise.all(this.animations).then(t).catch(n)}};var ye=o=>o*1e3,Me=o=>o/1e3;var wi={current:!1};function fn(o){return typeof o=="function"}function Ma(o,t){o.timeline=t,o.onfinish=null}var gr=o=>Array.isArray(o)&&typeof o[0]=="number";var Vu={linearEasing:void 0};function Nu(o,t){let n=yo(o);return()=>{var r;return(r=Vu[t])!==null&&r!==void 0?r:n()}}var vo=Nu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing");var Je=(o,t,n)=>{let r=t-o;return r===0?1:(n-o)/r};var Pi=(o,t,n=10)=>{let r="",i=Math.max(Math.round(t/n),2);for(let s=0;s<i;s++)r+=o(Je(0,i-1,s))+", ";return`linear(${r.substring(0,r.length-2)})`};function Na(o){return!!(typeof o=="function"&&vo()||!o||typeof o=="string"&&(o in Va||vo())||gr(o)||Array.isArray(o)&&o.every(Na))}var yr=([o,t,n,r])=>`cubic-bezier(${o}, ${t}, ${n}, ${r})`,Va={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:yr([0,.65,.55,1]),circOut:yr([.55,0,1,.45]),backIn:yr([.31,.01,.66,-.59]),backOut:yr([.33,1.53,.69,.99])};function Ga(o,t){if(o)return typeof o=="function"&&vo()?Pi(o,t):gr(o)?yr(o):Array.isArray(o)?o.map(n=>Ga(n,t)||Va.easeOut):Va[o]}var Gu=(o,t,n)=>(((1-3*n+3*t)*o+(3*n-6*t))*o+3*t)*o,Yh=1e-7,Zh=12;function Jh(o,t,n,r,i){let s,c,u=0;do c=t+(n-t)/2,s=Gu(c,r,i)-o,s>0?n=c:t=c;while(Math.abs(s)>Yh&&++u<Zh);return c}function dn(o,t,n,r){if(o===t&&n===r)return te;let i=s=>Jh(s,0,1,o,n);return s=>s===0||s===1?s:Gu(i(s),t,r)}var Ei=o=>t=>t<=.5?o(2*t)/2:(2-o(2*(1-t)))/2;var ki=o=>t=>1-o(1-t);var Fa=dn(.33,1.53,.69,.99),Tr=ki(Fa),Di=Ei(Tr);var Ri=o=>(o*=2)<1?.5*Tr(o):.5*(2-Math.pow(2,-10*(o-1)));var Ii=o=>1-Math.sin(Math.acos(o)),Li=ki(Ii),_i=Ei(Ii);var Mi=o=>/^0[^.\s]+$/u.test(o);function Fu(o){return typeof o=="number"?o===0:o!==null?o==="none"||o==="0"||Mi(o):!0}var hn=o=>Math.round(o*1e5)/1e5;var So=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ou(o){return o==null}var Hu=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;var xo=(o,t)=>n=>!!(typeof n=="string"&&Hu.test(n)&&n.startsWith(o)||t&&!Ou(n)&&Object.prototype.hasOwnProperty.call(n,t)),Vi=(o,t,n)=>r=>{if(typeof r!="string")return r;let[i,s,c,u]=r.match(So);return{[o]:parseFloat(i),[t]:parseFloat(s),[n]:parseFloat(c),alpha:u!==void 0?parseFloat(u):1}};var Qh=o=>we(0,255,o),Oa={...xt,transform:o=>Math.round(Qh(o))},At={test:xo("rgb","red"),parse:Vi("red","green","blue"),transform:({red:o,green:t,blue:n,alpha:r=1})=>"rgba("+Oa.transform(o)+", "+Oa.transform(t)+", "+Oa.transform(n)+", "+hn(Mt.transform(r))+")"};function eg(o){let t="",n="",r="",i="";return o.length>5?(t=o.substring(1,3),n=o.substring(3,5),r=o.substring(5,7),i=o.substring(7,9)):(t=o.substring(1,2),n=o.substring(2,3),r=o.substring(3,4),i=o.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var vr={test:xo("#"),parse:eg,transform:At.transform};var gn={test:xo("hsl","hue"),parse:Vi("hue","saturation","lightness"),transform:({hue:o,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(o)+", "+He.transform(hn(t))+", "+He.transform(hn(n))+", "+hn(Mt.transform(r))+")"};var fe={test:o=>At.test(o)||vr.test(o)||gn.test(o),parse:o=>At.test(o)?At.parse(o):gn.test(o)?gn.parse(o):vr.parse(o),transform:o=>typeof o=="string"?o:o.hasOwnProperty("red")?At.transform(o):gn.transform(o)};var Uu=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tg(o){var t,n;return isNaN(o)&&typeof o=="string"&&(((t=o.match(So))===null||t===void 0?void 0:t.length)||0)+(((n=o.match(Uu))===null||n===void 0?void 0:n.length)||0)>0}var Bu="number",Wu="color",ng="var",og="var(",Ku="${}",rg=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function kn(o){let t=o.toString(),n=[],r={color:[],number:[],var:[]},i=[],s=0,u=t.replace(rg,p=>(fe.test(p)?(r.color.push(s),i.push(Wu),n.push(fe.parse(p))):p.startsWith(og)?(r.var.push(s),i.push(ng),n.push(p)):(r.number.push(s),i.push(Bu),n.push(parseFloat(p))),++s,Ku)).split(Ku);return{values:n,split:u,indexes:r,types:i}}function ju(o){return kn(o).values}function $u(o){let{split:t,types:n}=kn(o),r=t.length;return i=>{let s="";for(let c=0;c<r;c++)if(s+=t[c],i[c]!==void 0){let u=n[c];u===Bu?s+=hn(i[c]):u===Wu?s+=fe.transform(i[c]):s+=i[c]}return s}}var ig=o=>typeof o=="number"?0:o;function sg(o){let t=ju(o);return $u(o)(t.map(ig))}var Ue={test:tg,parse:ju,createTransformer:$u,getAnimatableNone:sg};var ag=new Set(["brightness","contrast","saturate","opacity"]);function cg(o){let[t,n]=o.slice(0,-1).split("(");if(t==="drop-shadow")return o;let[r]=n.match(So)||[];if(!r)return o;let i=n.replace(r,""),s=ag.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+i+")"}var lg=/\b([a-z-]*)\(.*?\)/gu,Sr={...Ue,getAnimatableNone:o=>{let t=o.match(lg);return t?t.map(cg).join(" "):o}};var ug={...ao,color:fe,backgroundColor:fe,outlineColor:fe,fill:fe,stroke:fe,borderColor:fe,borderTopColor:fe,borderRightColor:fe,borderBottomColor:fe,borderLeftColor:fe,filter:Sr,WebkitFilter:Sr},bo=o=>ug[o];function Ni(o,t){let n=bo(o);return n!==Sr&&(n=Ue),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var pg=new Set(["auto","none","0"]);function zu(o,t,n){let r=0,i;for(;r<o.length&&!i;){let s=o[r];typeof s=="string"&&!pg.has(s)&&kn(s).values.length&&(i=o[r]),r++}if(i&&n)for(let s of t)o[s]=Ni(n,i)}var Ha=o=>o===xt||o===E,qu=(o,t)=>parseFloat(o.split(", ")[t]),Xu=(o,t)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;let i=r.match(/^matrix3d\((.+)\)$/u);if(i)return qu(i[1],t);{let s=r.match(/^matrix\((.+)\)$/u);return s?qu(s[1],o):0}},mg=new Set(["x","y","z"]),fg=St.filter(o=>!mg.has(o));function Yu(o){let t=[];return fg.forEach(n=>{let r=o.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}var Dn={width:({x:o},{paddingLeft:t="0",paddingRight:n="0"})=>o.max-o.min-parseFloat(t)-parseFloat(n),height:({y:o},{paddingTop:t="0",paddingBottom:n="0"})=>o.max-o.min-parseFloat(t)-parseFloat(n),top:(o,{top:t})=>parseFloat(t),left:(o,{left:t})=>parseFloat(t),bottom:({y:o},{top:t})=>parseFloat(t)+(o.max-o.min),right:({x:o},{left:t})=>parseFloat(t)+(o.max-o.min),x:Xu(4,13),y:Xu(5,14)};Dn.translateX=Dn.x;Dn.translateY=Dn.y;var Rn=new Set,Ua=!1,Ka=!1;function Zu(){if(Ka){let o=Array.from(Rn).filter(r=>r.needsMeasurement),t=new Set(o.map(r=>r.element)),n=new Map;t.forEach(r=>{let i=Yu(r);i.length&&(n.set(r,i),r.render())}),o.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();let i=n.get(r);i&&i.forEach(([s,c])=>{var u;(u=r.getValue(s))===null||u===void 0||u.set(c)})}),o.forEach(r=>r.measureEndState()),o.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Ka=!1,Ua=!1,Rn.forEach(o=>o.complete()),Rn.clear()}function Ju(){Rn.forEach(o=>{o.readKeyframes(),o.needsMeasurement&&(Ka=!0)})}function Qu(){Ju(),Zu()}var yn=class{constructor(t,n,r,i,s,c=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=s,this.isAsync=c}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Rn.add(this),Ua||(Ua=!0,L.read(Ju),L.resolveKeyframes(Zu))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;for(let s=0;s<t.length;s++)if(t[s]===null)if(s===0){let c=i?.get(),u=t[t.length-1];if(c!==void 0)t[0]=c;else if(r&&n){let p=r.readValue(n,u);p!=null&&(t[0]=p)}t[0]===void 0&&(t[0]=u),i&&c===void 0&&i.set(t[0])}else t[s]=t[s-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Rn.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Rn.delete(this))}resume(){this.isComplete||this.scheduleResolve()}};var Gi=o=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(o);var dg=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function hg(o){let t=dg.exec(o);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var gg=4;function Ba(o,t,n=1){Ye(n<=gg,`Max CSS variable fallback depth detected in property "${o}". This may indicate a circular fallback dependency.`);let[r,i]=hg(o);if(!r)return;let s=window.getComputedStyle(t).getPropertyValue(r);if(s){let c=s.trim();return Gi(c)?parseFloat(c):c}return so(i)?Ba(i,t,n+1):i}var Fi=o=>t=>t.test(o);var ep={test:o=>o==="auto",parse:o=>o};var Wa=[xt,E,He,bt,hu,du,ep],ja=o=>Wa.find(Fi(o));var Ao=class extends yn{constructor(t,n,r,i,s){super(t,n,r,i,s,!0)}readKeyframes(){let{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let f=t[p];if(typeof f=="string"&&(f=f.trim(),so(f))){let a=Ba(f,n.current);a!==void 0&&(t[p]=a),p===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!Si.has(r)||t.length!==2)return;let[i,s]=t,c=ja(i),u=ja(s);if(c!==u)if(Ha(c)&&Ha(u))for(let p=0;p<t.length;p++){let f=t[p];typeof f=="string"&&(t[p]=parseFloat(f))}else this.needsMeasurement=!0}resolveNoneKeyframes(){let{unresolvedKeyframes:t,name:n}=this,r=[];for(let i=0;i<t.length;i++)Fu(t[i])&&r.push(i);r.length&&zu(t,r,n)}measureInitialState(){let{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Dn[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;let i=n[n.length-1];i!==void 0&&t.getValue(r,i).jump(i,!1)}measureEndState(){var t;let{element:n,name:r,unresolvedKeyframes:i}=this;if(!n||!n.current)return;let s=n.getValue(r);s&&s.jump(this.measuredOrigin,!1);let c=i.length-1,u=i[c];i[c]=Dn[r](n.measureViewportBox(),window.getComputedStyle(n.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([p,f])=>{n.getValue(p).set(f)}),this.resolveNoneKeyframes()}};var $a=(o,t)=>t==="zIndex"?!1:!!(typeof o=="number"||Array.isArray(o)||typeof o=="string"&&(Ue.test(o)||o==="0")&&!o.startsWith("url("));function yg(o){let t=o[0];if(o.length===1)return!0;for(let n=0;n<o.length;n++)if(o[n]!==t)return!0}function tp(o,t,n,r){let i=o[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;let s=o[o.length-1],c=$a(i,t),u=$a(s,t);return an(c===u,`You are trying to animate ${t} from "${i}" to "${s}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${s} via the \`style\` property.`),!c||!u?!1:yg(o)||(n==="spring"||fn(n))&&r}var Tg=o=>o!==null;function Tn(o,{repeat:t,repeatType:n="loop"},r){let i=o.filter(Tg),s=t&&n!=="loop"&&t%2===1?0:i.length-1;return!s||r===void 0?i[s]:r}var vg=40,Co=class{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:c="loop",...u}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=_e.now(),this.options={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:s,repeatType:c,...u},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>vg?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&Qu(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=_e.now(),this.hasAttemptedResolve=!0;let{name:r,type:i,velocity:s,delay:c,onComplete:u,onUpdate:p,isGenerator:f}=this.options;if(!f&&!tp(t,r,i,s))if(wi.current||!c){p&&p(Tn(t,this.options,n)),u&&u(),this.resolveFinishedPromise();return}else this.options.duration=0;let a=this.initPlayback(t,n);a!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...a},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}};function wo(o){let t=0,n=50,r=o.next(t);for(;!r.done&&t<2e4;)t+=n,r=o.next(t);return t>=2e4?1/0:t}var G=(o,t,n)=>o+(t-o)*n;function za(o,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+(t-o)*6*n:n<1/2?t:n<2/3?o+(t-o)*(2/3-n)*6:o}function np({hue:o,saturation:t,lightness:n,alpha:r}){o/=360,t/=100,n/=100;let i=0,s=0,c=0;if(!t)i=s=c=n;else{let u=n<.5?n*(1+t):n+t-n*t,p=2*n-u;i=za(p,u,o+1/3),s=za(p,u,o),c=za(p,u,o-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(c*255),alpha:r}}function Po(o,t){return n=>n>0?t:o}var qa=(o,t,n)=>{let r=o*o,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Sg=[vr,At,gn],xg=o=>Sg.find(t=>t.test(o));function op(o){let t=xg(o);if(an(!!t,`'${o}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(o);return t===gn&&(n=np(n)),n}var Xa=(o,t)=>{let n=op(o),r=op(t);if(!n||!r)return Po(o,t);let i={...n};return s=>(i.red=qa(n.red,r.red,s),i.green=qa(n.green,r.green,s),i.blue=qa(n.blue,r.blue,s),i.alpha=G(n.alpha,r.alpha,s),At.transform(i))};var bg=(o,t)=>n=>t(o(n)),Ct=(...o)=>o.reduce(bg);var Oi=new Set(["none","hidden"]);function rp(o,t){return Oi.has(o)?n=>n<=0?o:t:n=>n>=1?t:o}function Ag(o,t){return n=>G(o,t,n)}function Hi(o){return typeof o=="number"?Ag:typeof o=="string"?so(o)?Po:fe.test(o)?Xa:Pg:Array.isArray(o)?ip:typeof o=="object"?fe.test(o)?Xa:Cg:Po}function ip(o,t){let n=[...o],r=n.length,i=o.map((s,c)=>Hi(s)(s,t[c]));return s=>{for(let c=0;c<r;c++)n[c]=i[c](s);return n}}function Cg(o,t){let n={...o,...t},r={};for(let i in n)o[i]!==void 0&&t[i]!==void 0&&(r[i]=Hi(o[i])(o[i],t[i]));return i=>{for(let s in r)n[s]=r[s](i);return n}}function wg(o,t){var n;let r=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){let c=t.types[s],u=o.indexes[c][i[c]],p=(n=o.values[u])!==null&&n!==void 0?n:0;r[s]=p,i[c]++}return r}var Pg=(o,t)=>{let n=Ue.createTransformer(t),r=kn(o),i=kn(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Oi.has(o)&&!i.values.length||Oi.has(t)&&!r.values.length?rp(o,t):Ct(ip(wg(r,i),i.values),n):(an(!0,`Complex values '${o}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Po(o,t))};function Ui(o,t,n){return typeof o=="number"&&typeof t=="number"&&typeof n=="number"?G(o,t,n):Hi(o)(o,t)}var Eg=5;function Ki(o,t,n){let r=Math.max(t-Eg,0);return bi(n-o(r),t-r)}var Q={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};var Ya=.001;function sp({duration:o=Q.duration,bounce:t=Q.bounce,velocity:n=Q.velocity,mass:r=Q.mass}){let i,s;an(o<=ye(Q.maxDuration),"Spring duration must be 10 seconds or less");let c=1-t;c=we(Q.minDamping,Q.maxDamping,c),o=we(Q.minDuration,Q.maxDuration,Me(o)),c<1?(i=f=>{let a=f*c,l=a*o,m=a-n,d=Bi(f,c),h=Math.exp(-l);return Ya-m/d*h},s=f=>{let l=f*c*o,m=l*n+n,d=Math.pow(c,2)*Math.pow(f,2)*o,h=Math.exp(-l),g=Bi(Math.pow(f,2),c);return(-i(f)+Ya>0?-1:1)*((m-d)*h)/g}):(i=f=>{let a=Math.exp(-f*o),l=(f-n)*o+1;return-Ya+a*l},s=f=>{let a=Math.exp(-f*o),l=(n-f)*(o*o);return a*l});let u=5/o,p=Dg(i,s,u);if(o=ye(o),isNaN(p))return{stiffness:Q.stiffness,damping:Q.damping,duration:o};{let f=Math.pow(p,2)*r;return{stiffness:f,damping:c*2*Math.sqrt(r*f),duration:o}}}var kg=12;function Dg(o,t,n){let r=n;for(let i=1;i<kg;i++)r=r-o(r)/t(r);return r}function Bi(o,t){return o*Math.sqrt(1-t*t)}var Rg=["duration","bounce"],Ig=["stiffness","damping","mass"];function ap(o,t){return t.some(n=>o[n]!==void 0)}function Lg(o){let t={velocity:Q.velocity,stiffness:Q.stiffness,damping:Q.damping,mass:Q.mass,isResolvedFromDuration:!1,...o};if(!ap(o,Ig)&&ap(o,Rg))if(o.visualDuration){let n=o.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*we(.05,1,1-(o.bounce||0))*Math.sqrt(i);t={...t,mass:Q.mass,stiffness:i,damping:s}}else{let n=sp(o);t={...t,...n,mass:Q.mass},t.isResolvedFromDuration=!0}return t}function Eo(o=Q.visualDuration,t=Q.bounce){let n=typeof o!="object"?{visualDuration:o,keyframes:[0,1],bounce:t}:o,{restSpeed:r,restDelta:i}=n,s=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],u={done:!1,value:s},{stiffness:p,damping:f,mass:a,duration:l,velocity:m,isResolvedFromDuration:d}=Lg({...n,velocity:-Me(n.velocity||0)}),h=m||0,g=f/(2*Math.sqrt(p*a)),y=c-s,T=Me(Math.sqrt(p/a)),v=Math.abs(y)<5;r||(r=v?Q.restSpeed.granular:Q.restSpeed.default),i||(i=v?Q.restDelta.granular:Q.restDelta.default);let S;if(g<1){let x=Bi(T,g);S=w=>{let _=Math.exp(-g*T*w);return c-_*((h+g*T*y)/x*Math.sin(x*w)+y*Math.cos(x*w))}}else if(g===1)S=x=>c-Math.exp(-T*x)*(y+(h+T*y)*x);else{let x=T*Math.sqrt(g*g-1);S=w=>{let _=Math.exp(-g*T*w),A=Math.min(x*w,300);return c-_*((h+g*T*y)*Math.sinh(A)+x*y*Math.cosh(A))/x}}let C={calculatedDuration:d&&l||null,next:x=>{let w=S(x);if(d)u.done=x>=l;else{let _=0;g<1&&(_=x===0?ye(h):Ki(S,x,w));let A=Math.abs(_)<=r,P=Math.abs(c-w)<=i;u.done=A&&P}return u.value=u.done?c:w,u},toString:()=>{let x=Math.min(wo(C),2e4),w=Pi(_=>C.next(x*_).value,x,30);return x+"ms "+w}};return C}function Ja({keyframes:o,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:c,min:u,max:p,restDelta:f=.5,restSpeed:a}){let l=o[0],m={done:!1,value:l},d=A=>u!==void 0&&A<u||p!==void 0&&A>p,h=A=>u===void 0?p:p===void 0||Math.abs(u-A)<Math.abs(p-A)?u:p,g=n*t,y=l+g,T=c===void 0?y:c(y);T!==y&&(g=T-l);let v=A=>-g*Math.exp(-A/r),S=A=>T+v(A),C=A=>{let P=v(A),V=S(A);m.done=Math.abs(P)<=f,m.value=m.done?T:V},x,w,_=A=>{d(m.value)&&(x=A,w=Eo({keyframes:[m.value,h(m.value)],velocity:Ki(S,A,m.value),damping:i,stiffness:s,restDelta:f,restSpeed:a}))};return _(0),{calculatedDuration:null,next:A=>{let P=!1;return!w&&x===void 0&&(P=!0,C(A),_(A)),x!==void 0&&A>=x?w.next(A-x):(!P&&C(A),m)}}}var cp=dn(.42,0,1,1),lp=dn(0,0,.58,1),Wi=dn(.42,0,.58,1);var ji=o=>Array.isArray(o)&&typeof o[0]!="number";var up={linear:te,easeIn:cp,easeInOut:Wi,easeOut:lp,circIn:Ii,circInOut:_i,circOut:Li,backIn:Tr,backInOut:Di,backOut:Fa,anticipate:Ri},Qa=o=>{if(gr(o)){Ye(o.length===4,"Cubic bezier arrays must contain four numerical values.");let[t,n,r,i]=o;return dn(t,n,r,i)}else if(typeof o=="string")return Ye(up[o]!==void 0,`Invalid easing type '${o}'`),up[o];return o};function _g(o,t,n){let r=[],i=n||Ui,s=o.length-1;for(let c=0;c<s;c++){let u=i(o[c],o[c+1]);if(t){let p=Array.isArray(t)?t[c]||te:t;u=Ct(p,u)}r.push(u)}return r}function pp(o,t,{clamp:n=!0,ease:r,mixer:i}={}){let s=o.length;if(Ye(s===t.length,"Both input and output ranges must be the same length"),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];let c=o[0]===o[1];o[0]>o[s-1]&&(o=[...o].reverse(),t=[...t].reverse());let u=_g(t,r,i),p=u.length,f=a=>{if(c&&a<o[0])return t[0];let l=0;if(p>1)for(;l<o.length-2&&!(a<o[l+1]);l++);let m=Je(o[l],o[l+1],a);return u[l](m)};return n?a=>f(we(o[0],o[s-1],a)):f}function $i(o,t){let n=o[o.length-1];for(let r=1;r<=t;r++){let i=Je(0,t,r);o.push(G(n,1,i))}}function zi(o){let t=[0];return $i(t,o.length-1),t}function mp(o,t){return o.map(n=>n*t)}function Mg(o,t){return o.map(()=>t||Wi).splice(0,o.length-1)}function xr({duration:o=300,keyframes:t,times:n,ease:r="easeInOut"}){let i=ji(r)?r.map(Qa):Qa(r),s={done:!1,value:t[0]},c=mp(n&&n.length===t.length?n:zi(t),o),u=pp(c,t,{ease:Array.isArray(i)?i:Mg(t,i)});return{calculatedDuration:o,next:p=>(s.value=u(p),s.done=p>=o,s)}}var fp=o=>{let t=({timestamp:n})=>o(n);return{start:()=>L.update(t,!0),stop:()=>Ze(t),now:()=>pe.isProcessing?pe.timestamp:_e.now()}};var Vg={decay:Ja,inertia:Ja,tween:xr,keyframes:xr,spring:Eo},Ng=o=>o/100,In=class extends Co{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();let{onStop:p}=this.options;p&&p()};let{name:n,motionValue:r,element:i,keyframes:s}=this.options,c=i?.KeyframeResolver||yn,u=(p,f)=>this.onKeyframesResolved(p,f);this.resolver=new c(s,u,n,r,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){let{type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:c=0}=this.options,u=fn(n)?n:Vg[n]||xr,p,f;u!==xr&&typeof t[0]!="number"&&(p=Ct(Ng,Ui(t[0],t[1])),t=[0,100]);let a=u({...this.options,keyframes:t});s==="mirror"&&(f=u({...this.options,keyframes:[...t].reverse(),velocity:-c})),a.calculatedDuration===null&&(a.calculatedDuration=wo(a));let{calculatedDuration:l}=a,m=l+i,d=m*(r+1)-i;return{generator:a,mirroredGenerator:f,mapPercentToKeyframes:p,calculatedDuration:l,resolvedDuration:m,totalDuration:d}}onPostResolved(){let{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){let{resolved:r}=this;if(!r){let{keyframes:A}=this.options;return{done:!0,value:A[A.length-1]}}let{finalKeyframe:i,generator:s,mirroredGenerator:c,mapPercentToKeyframes:u,keyframes:p,calculatedDuration:f,totalDuration:a,resolvedDuration:l}=r;if(this.startTime===null)return s.next(0);let{delay:m,repeat:d,repeatType:h,repeatDelay:g,onUpdate:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;let T=this.currentTime-m*(this.speed>=0?1:-1),v=this.speed>=0?T<0:T>a;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let S=this.currentTime,C=s;if(d){let A=Math.min(this.currentTime,a)/l,P=Math.floor(A),V=A%1;!V&&A>=1&&(V=1),V===1&&P--,P=Math.min(P,d+1),!!(P%2)&&(h==="reverse"?(V=1-V,g&&(V-=g/l)):h==="mirror"&&(C=c)),S=we(0,1,V)*l}let x=v?{done:!1,value:p[0]}:C.next(S);u&&(x.value=u(x.value));let{done:w}=x;!v&&f!==null&&(w=this.speed>=0?this.currentTime>=a:this.currentTime<=0);let _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&w);return _&&i!==void 0&&(x.value=Tn(p,this.options,i)),y&&y(x.value),_&&this.finish(),x}get duration(){let{resolved:t}=this;return t?Me(t.calculatedDuration):0}get time(){return Me(this.currentTime)}set time(t){t=ye(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){let n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Me(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;let{driver:t=fp,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),n&&n();let i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";let{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}};var dp=new Set(["opacity","clipPath","filter","transform"]);function hp(o,t,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:c="loop",ease:u="easeInOut",times:p}={}){let f={[t]:n};p&&(f.offset=p);let a=Ga(u,i);return Array.isArray(a)&&(f.easing=a),o.animate(f,{delay:r,duration:i,easing:Array.isArray(a)?"linear":a,fill:"both",iterations:s+1,direction:c==="reverse"?"alternate":"normal"})}var gp=yo(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));var qi=10,Gg=2e4;function Fg(o){return fn(o.type)||o.type==="spring"||!Na(o.ease)}function Og(o,t){let n=new In({...t,keyframes:o,repeat:0,delay:0,isGenerator:!0}),r={done:!1,value:o[0]},i=[],s=0;for(;!r.done&&s<Gg;)r=n.sample(s),i.push(r.value),s+=qi;return{times:void 0,keyframes:i,duration:s-qi,ease:"linear"}}var yp={anticipate:Ri,backInOut:Di,circInOut:_i};function Hg(o){return o in yp}var br=class extends Co{constructor(t){super(t);let{name:n,motionValue:r,element:i,keyframes:s}=this.options;this.resolver=new Ao(s,(c,u)=>this.onKeyframesResolved(c,u),n,r,i),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:r=300,times:i,ease:s,type:c,motionValue:u,name:p,startTime:f}=this.options;if(!u.owner||!u.owner.current)return!1;if(typeof s=="string"&&vo()&&Hg(s)&&(s=yp[s]),Fg(this.options)){let{onComplete:l,onUpdate:m,motionValue:d,element:h,...g}=this.options,y=Og(t,g);t=y.keyframes,t.length===1&&(t[1]=t[0]),r=y.duration,i=y.times,s=y.ease,c="keyframes"}let a=hp(u.owner.current,p,t,{...this.options,duration:r,times:i,ease:s});return a.startTime=f??this.calcStartTime(),this.pendingTimeline?(Ma(a,this.pendingTimeline),this.pendingTimeline=void 0):a.onfinish=()=>{let{onComplete:l}=this.options;u.set(Tn(t,this.options,n)),l&&l(),this.cancel(),this.resolveFinishedPromise()},{animation:a,duration:r,times:i,type:c,ease:s,keyframes:t}}get duration(){let{resolved:t}=this;if(!t)return 0;let{duration:n}=t;return Me(n)}get time(){let{resolved:t}=this;if(!t)return 0;let{animation:n}=t;return Me(n.currentTime||0)}set time(t){let{resolved:n}=this;if(!n)return;let{animation:r}=n;r.currentTime=ye(t)}get speed(){let{resolved:t}=this;if(!t)return 1;let{animation:n}=t;return n.playbackRate}set speed(t){let{resolved:n}=this;if(!n)return;let{animation:r}=n;r.playbackRate=t}get state(){let{resolved:t}=this;if(!t)return"idle";let{animation:n}=t;return n.playState}get startTime(){let{resolved:t}=this;if(!t)return null;let{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{let{resolved:n}=this;if(!n)return te;let{animation:r}=n;Ma(r,t)}return te}play(){if(this.isStopped)return;let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();let{resolved:t}=this;if(!t)return;let{animation:n,keyframes:r,duration:i,type:s,ease:c,times:u}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){let{motionValue:f,onUpdate:a,onComplete:l,element:m,...d}=this.options,h=new In({...d,keyframes:r,duration:i,type:s,ease:c,times:u,isGenerator:!0}),g=ye(this.time);f.setWithVelocity(h.sample(g-qi).value,h.sample(g).value,qi)}let{onStop:p}=this.options;p&&p(),this.cancel()}complete(){let{resolved:t}=this;t&&t.animation.finish()}cancel(){let{resolved:t}=this;t&&t.animation.cancel()}static supports(t){let{motionValue:n,name:r,repeatDelay:i,repeatType:s,damping:c,type:u}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;let{onUpdate:p,transformTemplate:f}=n.owner.getProps();return gp()&&r&&dp.has(r)&&!p&&!f&&!i&&s!=="mirror"&&c!==0&&u!=="inertia"}};var Ug={type:"spring",stiffness:500,damping:25,restSpeed:10},Kg=o=>({type:"spring",stiffness:550,damping:o===0?2*Math.sqrt(550):30,restSpeed:10}),Bg={type:"keyframes",duration:.8},Wg={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Tp=(o,{keyframes:t})=>t.length>2?Bg:je.has(o)?o.startsWith("scale")?Kg(t[1]):Ug:Wg;function vp({when:o,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:c,repeatDelay:u,from:p,elapsed:f,...a}){return!!Object.keys(a).length}var ko=(o,t,n,r={},i,s)=>c=>{let u=ho(r,o)||{},p=u.delay||r.delay||0,{elapsed:f=0}=r;f=f-ye(p);let a={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-f,onUpdate:m=>{t.set(m),u.onUpdate&&u.onUpdate(m)},onComplete:()=>{c(),u.onComplete&&u.onComplete()},name:o,motionValue:t,element:s?void 0:i};vp(u)||(a={...a,...Tp(o,a)}),a.duration&&(a.duration=ye(a.duration)),a.repeatDelay&&(a.repeatDelay=ye(a.repeatDelay)),a.from!==void 0&&(a.keyframes[0]=a.from);let l=!1;if((a.type===!1||a.duration===0&&!a.repeatDelay)&&(a.duration=0,a.delay===0&&(l=!0)),(wi.current||eo.skipAnimations)&&(l=!0,a.duration=0,a.delay=0),l&&!s&&t.get()!==void 0){let m=Tn(a.keyframes,u);if(m!==void 0)return L.update(()=>{a.onUpdate(m),a.onComplete()}),new To([])}return!s&&br.supports(a)?new br(a):new In(a)};function jg({protectedKeys:o,needsAnimating:t},n){let r=o.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Do(o,t,{delay:n=0,transitionOverride:r,type:i}={}){var s;let{transition:c=o.getDefaultTransition(),transitionEnd:u,...p}=t;r&&(c=r);let f=[],a=i&&o.animationState&&o.animationState.getState()[i];for(let l in p){let m=o.getValue(l,(s=o.latestValues[l])!==null&&s!==void 0?s:null),d=p[l];if(d===void 0||a&&jg(a,l))continue;let h={delay:n,...ho(c||{},l)},g=!1;if(window.MotionHandoffAnimation){let T=Ai(o);if(T){let v=window.MotionHandoffAnimation(T,l,L);v!==null&&(h.startTime=v,g=!0)}}hr(o,l),m.start(ko(l,m,d,o.shouldReduceMotion&&Si.has(l)?{type:!1}:h,o,g));let y=m.animation;y&&f.push(y)}return u&&Promise.all(f).then(()=>{L.update(()=>{u&&Lu(o,u)})}),f}function Xi(o,t,n={}){var r;let i=un(o,t,n.type==="exit"?(r=o.presenceContext)===null||r===void 0?void 0:r.custom:void 0),{transition:s=o.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);let c=i?()=>Promise.all(Do(o,i,n)):()=>Promise.resolve(),u=o.variantChildren&&o.variantChildren.size?(f=0)=>{let{delayChildren:a=0,staggerChildren:l,staggerDirection:m}=s;return $g(o,t,a+f,l,m,n)}:()=>Promise.resolve(),{when:p}=s;if(p){let[f,a]=p==="beforeChildren"?[c,u]:[u,c];return f().then(()=>a())}else return Promise.all([c(),u(n.delay)])}function $g(o,t,n=0,r=0,i=1,s){let c=[],u=(o.variantChildren.size-1)*r,p=i===1?(f=0)=>f*r:(f=0)=>u-f*r;return Array.from(o.variantChildren).sort(zg).forEach((f,a)=>{f.notify("AnimationStart",t),c.push(Xi(f,t,{...s,delay:n+p(a)}).then(()=>f.notify("AnimationComplete",t)))}),Promise.all(c)}function zg(o,t){return o.sortNodePosition(t)}function Sp(o,t,n={}){o.notify("AnimationStart",t);let r;if(Array.isArray(t)){let i=t.map(s=>Xi(o,s,n));r=Promise.all(i)}else if(typeof t=="string")r=Xi(o,t,n);else{let i=typeof t=="function"?un(o,t,n.custom):t;r=Promise.all(Do(o,i,n))}return r.then(()=>{o.notify("AnimationComplete",t)})}var qg=ur.length;function ec(o){if(!o)return;if(!o.isControllingVariants){let n=o.parent?ec(o.parent)||{}:{};return o.props.initial!==void 0&&(n.initial=o.props.initial),n}let t={};for(let n=0;n<qg;n++){let r=ur[n],i=o.props[r];(Lt(i)||i===!1)&&(t[r]=i)}return t}var Xg=[...ai].reverse(),Yg=ai.length;function Zg(o){return t=>Promise.all(t.map(({animation:n,options:r})=>Sp(o,n,r)))}function bp(o){let t=Zg(o),n=xp(),r=!0,i=p=>(f,a)=>{var l;let m=un(o,a,p==="exit"?(l=o.presenceContext)===null||l===void 0?void 0:l.custom:void 0);if(m){let{transition:d,transitionEnd:h,...g}=m;f={...f,...g,...h}}return f};function s(p){t=p(o)}function c(p){let{props:f}=o,a=ec(o.parent)||{},l=[],m=new Set,d={},h=1/0;for(let y=0;y<Yg;y++){let T=Xg[y],v=n[T],S=f[T]!==void 0?f[T]:a[T],C=Lt(S),x=T===p?v.isActive:null;x===!1&&(h=y);let w=S===a[T]&&S!==f[T]&&C;if(w&&r&&o.manuallyAnimateOnMount&&(w=!1),v.protectedKeys={...d},!v.isActive&&x===null||!S&&!v.prevProp||ln(S)||typeof S=="boolean")continue;let _=Jg(v.prevProp,S),A=_||T===p&&v.isActive&&!w&&C||y>h&&C,P=!1,V=Array.isArray(S)?S:[S],J=V.reduce(i(T),{});x===!1&&(J={});let{prevResolvedValues:I={}}=v,W={...I,...J},se=O=>{A=!0,m.has(O)&&(P=!0,m.delete(O)),v.needsAnimating[O]=!0;let F=o.getValue(O);F&&(F.liveStyle=!1)};for(let O in W){let F=J[O],ae=I[O];if(d.hasOwnProperty(O))continue;let H=!1;mr(F)&&mr(ae)?H=!La(F,ae):H=F!==ae,H?F!=null?se(O):m.add(O):F!==void 0&&m.has(O)?se(O):v.protectedKeys[O]=!0}v.prevProp=S,v.prevResolvedValues=J,v.isActive&&(d={...d,...J}),r&&o.blockInitialAnimation&&(A=!1),A&&(!(w&&_)||P)&&l.push(...V.map(O=>({animation:O,options:{type:T}})))}if(m.size){let y={};m.forEach(T=>{let v=o.getBaseTarget(T),S=o.getValue(T);S&&(S.liveStyle=!0),y[T]=v??null}),l.push({animation:y})}let g=!!l.length;return r&&(f.initial===!1||f.initial===f.animate)&&!o.manuallyAnimateOnMount&&(g=!1),r=!1,g?t(l):Promise.resolve()}function u(p,f){var a;if(n[p].isActive===f)return Promise.resolve();(a=o.variantChildren)===null||a===void 0||a.forEach(m=>{var d;return(d=m.animationState)===null||d===void 0?void 0:d.setActive(p,f)}),n[p].isActive=f;let l=c(p);for(let m in n)n[m].protectedKeys={};return l}return{animateChanges:c,setActive:u,setAnimateFunction:s,getState:()=>n,reset:()=>{n=xp(),r=!0}}}function Jg(o,t){return typeof t=="string"?t!==o:Array.isArray(t)?!La(t,o):!1}function Ln(o=!1){return{isActive:o,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function xp(){return{animate:Ln(!0),whileInView:Ln(),whileHover:Ln(),whileTap:Ln(),whileDrag:Ln(),whileFocus:Ln(),exit:Ln()}}var Te=class{constructor(t){this.isMounted=!1,this.node=t}update(){}};var Yi=class extends Te{constructor(t){super(t),t.animationState||(t.animationState=bp(t))}updateAnimationControlsSubscription(){let{animate:t}=this.node.getProps();ln(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}};var Qg=0,Zi=class extends Te{constructor(){super(...arguments),this.id=Qg++}update(){if(!this.node.presenceContext)return;let{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;let i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>n(this.id))}mount(){let{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}};var Ap={animation:{Feature:Yi},exit:{Feature:Zi}};var it={x:!1,y:!1};function Ji(){return it.x||it.y}function Cp(o){return o==="x"||o==="y"?it[o]?null:(it[o]=!0,()=>{it[o]=!1}):it.x||it.y?null:(it.x=it.y=!0,()=>{it.x=it.y=!1})}var Ro=o=>o.pointerType==="mouse"?typeof o.button!="number"||o.button<=0:o.isPrimary!==!1;function Nt(o,t,n,r={passive:!0}){return o.addEventListener(t,n,r),()=>o.removeEventListener(t,n)}function Gt(o){return{point:{x:o.pageX,y:o.pageY}}}var wp=o=>t=>Ro(t)&&o(t,Gt(t));function vn(o,t,n,r){return Nt(o,t,wp(n),r)}var Pp=(o,t)=>Math.abs(o-t);function Ep(o,t){let n=Pp(o.x,t.x),r=Pp(o.y,t.y);return Math.sqrt(n**2+r**2)}var Io=class{constructor(t,n,{transformPagePoint:r,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let l=nc(this.lastMoveEventInfo,this.history),m=this.startEvent!==null,d=Ep(l.offset,{x:0,y:0})>=3;if(!m&&!d)return;let{point:h}=l,{timestamp:g}=pe;this.history.push({...h,timestamp:g});let{onStart:y,onMove:T}=this.handlers;m||(y&&y(this.lastMoveEvent,l),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,l)},this.handlePointerMove=(l,m)=>{this.lastMoveEvent=l,this.lastMoveEventInfo=tc(m,this.transformPagePoint),L.update(this.updatePoint,!0)},this.handlePointerUp=(l,m)=>{this.end();let{onEnd:d,onSessionEnd:h,resumeAnimation:g}=this.handlers;if(this.dragSnapToOrigin&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let y=nc(l.type==="pointercancel"?this.lastMoveEventInfo:tc(m,this.transformPagePoint),this.history);this.startEvent&&d&&d(l,y),h&&h(l,y)},!Ro(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.contextWindow=i||window;let c=Gt(t),u=tc(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=pe;this.history=[{...p,timestamp:f}];let{onSessionStart:a}=n;a&&a(t,nc(u,this.history)),this.removeListeners=Ct(vn(this.contextWindow,"pointermove",this.handlePointerMove),vn(this.contextWindow,"pointerup",this.handlePointerUp),vn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Ze(this.updatePoint)}};function tc(o,t){return t?{point:t(o.point)}:o}function kp(o,t){return{x:o.x-t.x,y:o.y-t.y}}function nc({point:o},t){return{point:o,delta:kp(o,Dp(t)),offset:kp(o,ey(t)),velocity:ty(t,.1)}}function ey(o){return o[0]}function Dp(o){return o[o.length-1]}function ty(o,t){if(o.length<2)return{x:0,y:0};let n=o.length-1,r=null,i=Dp(o);for(;n>=0&&(r=o[n],!(i.timestamp-r.timestamp>ye(t)));)n--;if(!r)return{x:0,y:0};let s=Me(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};let c={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}var _p=1e-4,ny=1-_p,oy=1+_p,Mp=.01,ry=0-Mp,iy=0+Mp;function Pe(o){return o.max-o.min}function Vp(o,t,n){return Math.abs(o-t)<=n}function Rp(o,t,n,r=.5){o.origin=r,o.originPoint=G(t.min,t.max,o.origin),o.scale=Pe(n)/Pe(t),o.translate=G(n.min,n.max,o.origin)-o.originPoint,(o.scale>=ny&&o.scale<=oy||isNaN(o.scale))&&(o.scale=1),(o.translate>=ry&&o.translate<=iy||isNaN(o.translate))&&(o.translate=0)}function Lo(o,t,n,r){Rp(o.x,t.x,n.x,r?r.originX:void 0),Rp(o.y,t.y,n.y,r?r.originY:void 0)}function Ip(o,t,n){o.min=n.min+t.min,o.max=o.min+Pe(t)}function Np(o,t,n){Ip(o.x,t.x,n.x),Ip(o.y,t.y,n.y)}function Lp(o,t,n){o.min=t.min-n.min,o.max=o.min+Pe(t)}function _o(o,t,n){Lp(o.x,t.x,n.x),Lp(o.y,t.y,n.y)}function Up(o,{min:t,max:n},r){return t!==void 0&&o<t?o=r?G(t,o,r.min):Math.max(o,t):n!==void 0&&o>n&&(o=r?G(n,o,r.max):Math.min(o,n)),o}function Gp(o,t,n){return{min:t!==void 0?o.min+t:void 0,max:n!==void 0?o.max+n-(o.max-o.min):void 0}}function Kp(o,{top:t,left:n,bottom:r,right:i}){return{x:Gp(o.x,n,i),y:Gp(o.y,t,r)}}function Fp(o,t){let n=t.min-o.min,r=t.max-o.max;return t.max-t.min<o.max-o.min&&([n,r]=[r,n]),{min:n,max:r}}function Bp(o,t){return{x:Fp(o.x,t.x),y:Fp(o.y,t.y)}}function Wp(o,t){let n=.5,r=Pe(o),i=Pe(t);return i>r?n=Je(t.min,t.max-r,o.min):r>i&&(n=Je(o.min,o.max-i,t.min)),we(0,1,n)}function jp(o,t){let n={};return t.min!==void 0&&(n.min=t.min-o.min),t.max!==void 0&&(n.max=t.max-o.min),n}var Qi=.35;function $p(o=Qi){return o===!1?o=0:o===!0&&(o=Qi),{x:Op(o,"left","right"),y:Op(o,"top","bottom")}}function Op(o,t,n){return{min:Hp(o,t),max:Hp(o,n)}}function Hp(o,t){return typeof o=="number"?o:o[t]||0}var zp=()=>({translate:0,scale:1,origin:0,originPoint:0}),_n=()=>({x:zp(),y:zp()}),qp=()=>({min:0,max:0}),Y=()=>({x:qp(),y:qp()});function $e(o){return[o("x"),o("y")]}function es({top:o,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:o,max:r}}}function Xp({x:o,y:t}){return{top:t.min,right:o.max,bottom:t.max,left:o.min}}function Yp(o,t){if(!t)return o;let n=t({x:o.left,y:o.top}),r=t({x:o.right,y:o.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function oc(o){return o===void 0||o===1}function ts({scale:o,scaleX:t,scaleY:n}){return!oc(o)||!oc(t)||!oc(n)}function Ft(o){return ts(o)||rc(o)||o.z||o.rotate||o.rotateX||o.rotateY||o.skewX||o.skewY}function rc(o){return Zp(o.x)||Zp(o.y)}function Zp(o){return o&&o!=="0%"}function Ar(o,t,n){let r=o-n,i=t*r;return n+i}function Jp(o,t,n,r,i){return i!==void 0&&(o=Ar(o,i,r)),Ar(o,n,r)+t}function ic(o,t=0,n=1,r,i){o.min=Jp(o.min,t,n,r,i),o.max=Jp(o.max,t,n,r,i)}function sc(o,{x:t,y:n}){ic(o.x,t.translate,t.scale,t.originPoint),ic(o.y,n.translate,n.scale,n.originPoint)}var Qp=.999999999999,em=1.0000000000001;function nm(o,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let s,c;for(let u=0;u<i;u++){s=n[u],c=s.projectionDelta;let{visualElement:p}=s.options;p&&p.props.style&&p.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&Mn(o,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),c&&(t.x*=c.x.scale,t.y*=c.y.scale,sc(o,c)),r&&Ft(s.latestValues)&&Mn(o,s.latestValues))}t.x<em&&t.x>Qp&&(t.x=1),t.y<em&&t.y>Qp&&(t.y=1)}function Sn(o,t){o.min=o.min+t,o.max=o.max+t}function tm(o,t,n,r,i=.5){let s=G(o.min,o.max,i);ic(o,t,n,s,r)}function Mn(o,t){tm(o.x,t.x,t.scaleX,t.scale,t.originX),tm(o.y,t.y,t.scaleY,t.scale,t.originY)}function ac(o,t){return es(Yp(o.getBoundingClientRect(),t))}function om(o,t,n){let r=ac(o,n),{scroll:i}=t;return i&&(Sn(r.x,i.offset.x),Sn(r.y,i.offset.y)),r}var ns=({current:o})=>o?o.ownerDocument.defaultView:null;var sy=new WeakMap,rs=class{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Y(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=a=>{let{dragSnapToOrigin:l}=this.getProps();l?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Gt(a).point)},s=(a,l)=>{let{drag:m,dragPropagation:d,onDragStart:h}=this.getProps();if(m&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Cp(m),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),$e(y=>{let T=this.getAxisMotionValue(y).get()||0;if(He.test(T)){let{projection:v}=this.visualElement;if(v&&v.layout){let S=v.layout.layoutBox[y];S&&(T=Pe(S)*(parseFloat(T)/100))}}this.originPoint[y]=T}),h&&L.postRender(()=>h(a,l)),hr(this.visualElement,"transform");let{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},c=(a,l)=>{let{dragPropagation:m,dragDirectionLock:d,onDirectionLock:h,onDrag:g}=this.getProps();if(!m&&!this.openDragLock)return;let{offset:y}=l;if(d&&this.currentDirection===null){this.currentDirection=ay(y),this.currentDirection!==null&&h&&h(this.currentDirection);return}this.updateAxis("x",l.point,y),this.updateAxis("y",l.point,y),this.visualElement.render(),g&&g(a,l)},u=(a,l)=>this.stop(a,l),p=()=>$e(a=>{var l;return this.getAnimationState(a)==="paused"&&((l=this.getAxisMotionValue(a).animation)===null||l===void 0?void 0:l.play())}),{dragSnapToOrigin:f}=this.getProps();this.panSession=new Io(t,{onSessionStart:i,onStart:s,onMove:c,onSessionEnd:u,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,contextWindow:ns(this.visualElement)})}stop(t,n){let r=this.isDragging;if(this.cancel(),!r)return;let{velocity:i}=n;this.startAnimation(i);let{onDragEnd:s}=this.getProps();s&&L.postRender(()=>s(t,n))}cancel(){this.isDragging=!1;let{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){let{drag:i}=this.getProps();if(!r||!os(t,i,this.currentDirection))return;let s=this.getAxisMotionValue(t),c=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(c=Up(c,this.constraints[t],this.elastic[t])),s.set(c)}resolveConstraints(){var t;let{dragConstraints:n,dragElastic:r}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,s=this.constraints;n&&_t(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Kp(i.layoutBox,n):this.constraints=!1,this.elastic=$p(r),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&$e(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=jp(i.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){let{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!_t(t))return!1;let r=t.current;Ye(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");let{projection:i}=this.visualElement;if(!i||!i.layout)return!1;let s=om(r,i.root,this.visualElement.getTransformPagePoint()),c=Bp(i.layout.layoutBox,s);if(n){let u=n(Xp(c));this.hasMutatedConstraints=!!u,u&&(c=es(u))}return c}startAnimation(t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:c,onDragTransitionEnd:u}=this.getProps(),p=this.constraints||{},f=$e(a=>{if(!os(a,n,this.currentDirection))return;let l=p&&p[a]||{};c&&(l={min:0,max:0});let m=i?200:1e6,d=i?40:1e7,h={type:"inertia",velocity:r?t[a]:0,bounceStiffness:m,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(a,h)});return Promise.all(f).then(u)}startAxisValueAnimation(t,n){let r=this.getAxisMotionValue(t);return hr(this.visualElement,t),r.start(ko(t,r,0,n,this.visualElement,!1))}stopAnimation(){$e(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){$e(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){let n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){$e(n=>{let{drag:r}=this.getProps();if(!os(n,r,this.currentDirection))return;let{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){let{min:c,max:u}=i.layout.layoutBox[n];s.set(t[n]-G(c,u,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!_t(n)||!r||!this.constraints)return;this.stopAnimation();let i={x:0,y:0};$e(c=>{let u=this.getAxisMotionValue(c);if(u&&this.constraints!==!1){let p=u.get();i[c]=Wp({min:p,max:p},this.constraints[c])}});let{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),$e(c=>{if(!os(c,t,null))return;let u=this.getAxisMotionValue(c),{min:p,max:f}=this.constraints[c];u.set(G(p,f,i[c]))})}addListeners(){if(!this.visualElement.current)return;sy.set(this.visualElement,this);let t=this.visualElement.current,n=vn(t,"pointerdown",p=>{let{drag:f,dragListener:a=!0}=this.getProps();f&&a&&this.start(p)}),r=()=>{let{dragConstraints:p}=this.getProps();_t(p)&&p.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),L.read(r);let c=Nt(window,"resize",()=>this.scalePositionWithinConstraints()),u=i.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f})=>{this.isDragging&&f&&($e(a=>{let l=this.getAxisMotionValue(a);l&&(this.originPoint[a]+=p[a].translate,l.set(l.get()+p[a].translate))}),this.visualElement.render())});return()=>{c(),n(),s(),u&&u()}}getProps(){let t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:c=Qi,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:c,dragMomentum:u}}};function os(o,t,n){return(t===!0||t===o)&&(n===null||n===o)}function ay(o,t=10){let n=null;return Math.abs(o.y)>t?n="y":Math.abs(o.x)>t&&(n="x"),n}var is=class extends Te{constructor(t){super(t),this.removeGroupControls=te,this.removeListeners=te,this.controls=new rs(t)}mount(){let{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||te}unmount(){this.removeGroupControls(),this.removeListeners()}};var rm=o=>(t,n)=>{o&&L.postRender(()=>o(t,n))},ss=class extends Te{constructor(){super(...arguments),this.removePointerDownListener=te}onPointerDown(t){this.session=new Io(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ns(this.node)})}createPanHandlers(){let{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:rm(t),onStart:rm(n),onMove:r,onEnd:(s,c)=>{delete this.session,i&&L.postRender(()=>i(s,c))}}}mount(){this.removePointerDownListener=vn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}};import{jsx as cy}from"react/jsx-runtime";import{useContext as am,Component as ly}from"react";var Mo={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function im(o,t){return t.max===t.min?0:o/(t.max-t.min)*100}var Vo={correct:(o,t)=>{if(!t.target)return o;if(typeof o=="string")if(E.test(o))o=parseFloat(o);else return o;let n=im(o,t.target.x),r=im(o,t.target.y);return`${n}% ${r}%`}};var sm={correct:(o,{treeScale:t,projectionDelta:n})=>{let r=o,i=Ue.parse(o);if(i.length>5)return r;let s=Ue.createTransformer(o),c=typeof i[0]!="number"?1:0,u=n.x.scale*t.x,p=n.y.scale*t.y;i[0+c]/=u,i[1+c]/=p;let f=G(u,p,.5);return typeof i[2+c]=="number"&&(i[2+c]/=f),typeof i[3+c]=="number"&&(i[3+c]/=f),s(i)}};var cc=class extends ly{componentDidMount(){let{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=t;bu(uy),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Mo.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){let{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,c=r.projection;return c&&(c.isPresent=s,i||t.layoutDependency!==n||n===void 0?c.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?c.promote():c.relegate()||L.postRender(()=>{let u=c.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),no.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){let{safeToRemove:t}=this.props;t&&t()}render(){return null}};function as(o){let[t,n]=ti(),r=am(Yn);return cy(cc,{...o,layoutGroup:r,switchLayoutGroup:am(ui),isPresent:t,safeToRemove:n})}var uy={borderRadius:{...Vo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Vo,borderTopRightRadius:Vo,borderBottomLeftRadius:Vo,borderBottomRightRadius:Vo,boxShadow:sm};function cs(o,t,n){let r=z(o)?o:Vt(o);return r.start(ko("",r,t,n)),r.animation}function ls(o){return o instanceof SVGElement&&o.tagName!=="svg"}var cm=(o,t)=>o.depth-t.depth;var us=class{constructor(){this.children=[],this.isDirty=!1}add(t){go(this.children,t),this.isDirty=!0}remove(t){pn(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(cm),this.isDirty=!1,this.children.forEach(t)}};function lm(o,t){let n=_e.now(),r=({timestamp:i})=>{let s=i-n;s>=t&&(Ze(r),o(s-t))};return L.read(r,!0),()=>Ze(r)}var fm=["TopLeft","TopRight","BottomLeft","BottomRight"],py=fm.length,um=o=>typeof o=="string"?parseFloat(o):o,pm=o=>typeof o=="number"||E.test(o);function dm(o,t,n,r,i,s){i?(o.opacity=G(0,n.opacity!==void 0?n.opacity:1,my(r)),o.opacityExit=G(t.opacity!==void 0?t.opacity:1,0,fy(r))):s&&(o.opacity=G(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let c=0;c<py;c++){let u=`border${fm[c]}Radius`,p=mm(t,u),f=mm(n,u);if(p===void 0&&f===void 0)continue;p||(p=0),f||(f=0),p===0||f===0||pm(p)===pm(f)?(o[u]=Math.max(G(um(p),um(f),r),0),(He.test(f)||He.test(p))&&(o[u]+="%")):o[u]=f}(t.rotate||n.rotate)&&(o.rotate=G(t.rotate||0,n.rotate||0,r))}function mm(o,t){return o[t]!==void 0?o[t]:o.borderRadius}var my=hm(0,.5,Li),fy=hm(.5,.95,te);function hm(o,t,n){return r=>r<o?0:r>t?1:n(Je(o,t,r))}function gm(o,t){o.min=t.min,o.max=t.max}function Qe(o,t){gm(o.x,t.x),gm(o.y,t.y)}function lc(o,t){o.translate=t.translate,o.scale=t.scale,o.originPoint=t.originPoint,o.origin=t.origin}function ym(o,t,n,r,i){return o-=t,o=Ar(o,1/n,r),i!==void 0&&(o=Ar(o,1/i,r)),o}function dy(o,t=0,n=1,r=.5,i,s=o,c=o){if(He.test(t)&&(t=parseFloat(t),t=G(c.min,c.max,t/100)-c.min),typeof t!="number")return;let u=G(s.min,s.max,r);o===s&&(u-=t),o.min=ym(o.min,t,n,u,i),o.max=ym(o.max,t,n,u,i)}function Tm(o,t,[n,r,i],s,c){dy(o,t[n],t[r],t[i],t.scale,s,c)}var hy=["x","scaleX","originX"],gy=["y","scaleY","originY"];function uc(o,t,n,r){Tm(o.x,t,hy,n?n.x:void 0,r?r.x:void 0),Tm(o.y,t,gy,n?n.y:void 0,r?r.y:void 0)}function vm(o){return o.translate===0&&o.scale===1}function pc(o){return vm(o.x)&&vm(o.y)}function Sm(o,t){return o.min===t.min&&o.max===t.max}function bm(o,t){return Sm(o.x,t.x)&&Sm(o.y,t.y)}function xm(o,t){return Math.round(o.min)===Math.round(t.min)&&Math.round(o.max)===Math.round(t.max)}function mc(o,t){return xm(o.x,t.x)&&xm(o.y,t.y)}function fc(o){return Pe(o.x)/Pe(o.y)}function dc(o,t){return o.translate===t.translate&&o.scale===t.scale&&o.originPoint===t.originPoint}var ps=class{constructor(){this.members=[]}add(t){go(this.members,t),t.scheduleRender()}remove(t){if(pn(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){let n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){let n=this.members.findIndex(i=>t===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){let s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(t,n){let r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);let{crossfade:i}=t.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{let{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}};function Am(o,t,n){let r="",i=o.x.translate/t.x,s=o.y.translate/t.y,c=n?.z||0;if((i||s||c)&&(r=`translate3d(${i}px, ${s}px, ${c}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:f,rotate:a,rotateX:l,rotateY:m,skewX:d,skewY:h}=n;f&&(r=`perspective(${f}px) ${r}`),a&&(r+=`rotate(${a}deg) `),l&&(r+=`rotateX(${l}deg) `),m&&(r+=`rotateY(${m}deg) `),d&&(r+=`skewX(${d}deg) `),h&&(r+=`skewY(${h}deg) `)}let u=o.x.scale*t.x,p=o.y.scale*t.y;return(u!==1||p!==1)&&(r+=`scale(${u}, ${p})`),r||"none"}var Vn={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},Cr=typeof window<"u"&&window.MotionDebug!==void 0,hc=["","X","Y","Z"],yy={visibility:"hidden"},Cm=1e3,Ty=0;function gc(o,t,n,r){let{latestValues:i}=t;i[o]&&(n[o]=i[o],t.setStaticValue(o,0),r&&(r[o]=0))}function Lm(o){if(o.hasCheckedOptimisedAppear=!0,o.root===o)return;let{visualElement:t}=o.options;if(!t)return;let n=Ai(t);if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:i,layoutId:s}=o.options;window.MotionCancelOptimisedAnimation(n,"transform",L,!(i||s))}let{parent:r}=o;r&&!r.hasCheckedOptimisedAppear&&Lm(r)}function ms({attachResizeListener:o,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(c={},u=t?.()){this.id=Ty++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Cr&&(Vn.totalNodes=Vn.resolvedTargetDeltas=Vn.recalculatedProjection=0),this.nodes.forEach(xy),this.nodes.forEach(Py),this.nodes.forEach(Ey),this.nodes.forEach(by),Cr&&window.MotionDebug.record(Vn)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let p=0;p<this.path.length;p++)this.path[p].shouldResetTransform=!0;this.root===this&&(this.nodes=new us)}addEventListener(c,u){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new mn),this.eventHandlers.get(c).add(u)}notifyListeners(c,...u){let p=this.eventHandlers.get(c);p&&p.notify(...u)}hasListeners(c){return this.eventHandlers.has(c)}mount(c,u=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=ls(c),this.instance=c;let{layoutId:p,layout:f,visualElement:a}=this.options;if(a&&!a.current&&a.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),u&&(f||p)&&(this.isLayoutDirty=!0),o){let l,m=()=>this.root.updateBlockedByResize=!1;o(c,()=>{this.root.updateBlockedByResize=!0,l&&l(),l=lm(m,250),Mo.hasAnimatedSinceResize&&(Mo.hasAnimatedSinceResize=!1,this.nodes.forEach(Pm))})}p&&this.root.registerSharedNode(p,this),this.options.animate!==!1&&a&&(p||f)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:m,hasRelativeTargetChanged:d,layout:h})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let g=this.options.transition||a.getDefaultTransition()||Ly,{onLayoutAnimationStart:y,onLayoutAnimationComplete:T}=a.getProps(),v=!this.targetLayout||!mc(this.targetLayout,h)||d,S=!m&&d;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||S||m&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(l,S);let C={...ho(g,"layout"),onPlay:y,onComplete:T};(a.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C)}else m||Pm(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=h})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Ze(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ky),this.animationId++)}getTransformTemplate(){let{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Lm(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){let l=this.path[a];l.shouldResetTransform=!0,l.updateScroll("snapshot"),l.options.layoutRoot&&l.willUpdate(!1)}let{layoutId:u,layout:p}=this.options;if(u===void 0&&!p)return;let f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(wm);return}this.isUpdating||this.nodes.forEach(Cy),this.isUpdating=!1,this.nodes.forEach(wy),this.nodes.forEach(vy),this.nodes.forEach(Sy),this.clearAllSnapshots();let u=_e.now();pe.delta=we(0,1e3/60,u-pe.timestamp),pe.timestamp=u,pe.isProcessing=!0,ii.update.process(pe),ii.preRender.process(pe),ii.render.process(pe),pe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,no.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Ay),this.sharedNodes.forEach(Dy)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,L.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){L.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let p=0;p<this.path.length;p++)this.path[p].updateScroll();let c=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Y(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(u=!1),u){let p=r(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:p,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:p}}}resetTransform(){if(!i)return;let c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!pc(this.projectionDelta),p=this.getTransformTemplate(),f=p?p(this.latestValues,""):void 0,a=f!==this.prevTransformTemplateValue;c&&(u||Ft(this.latestValues)||a)&&(i(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){let u=this.measurePageBox(),p=this.removeElementScroll(u);return c&&(p=this.removeTransform(p)),_y(p),{animationId:this.root.animationId,measuredBox:u,layoutBox:p,latestValues:{},source:this.id}}measurePageBox(){var c;let{visualElement:u}=this.options;if(!u)return Y();let p=u.measureViewportBox();if(!(((c=this.scroll)===null||c===void 0?void 0:c.wasRoot)||this.path.some(My))){let{scroll:a}=this.root;a&&(Sn(p.x,a.offset.x),Sn(p.y,a.offset.y))}return p}removeElementScroll(c){var u;let p=Y();if(Qe(p,c),!((u=this.scroll)===null||u===void 0)&&u.wasRoot)return p;for(let f=0;f<this.path.length;f++){let a=this.path[f],{scroll:l,options:m}=a;a!==this.root&&l&&m.layoutScroll&&(l.wasRoot&&Qe(p,c),Sn(p.x,l.offset.x),Sn(p.y,l.offset.y))}return p}applyTransform(c,u=!1){let p=Y();Qe(p,c);for(let f=0;f<this.path.length;f++){let a=this.path[f];!u&&a.options.layoutScroll&&a.scroll&&a!==a.root&&Mn(p,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),Ft(a.latestValues)&&Mn(p,a.latestValues)}return Ft(this.latestValues)&&Mn(p,this.latestValues),p}removeTransform(c){let u=Y();Qe(u,c);for(let p=0;p<this.path.length;p++){let f=this.path[p];if(!f.instance||!Ft(f.latestValues))continue;ts(f.latestValues)&&f.updateSnapshot();let a=Y(),l=f.measurePageBox();Qe(a,l),uc(u,f.latestValues,f.snapshot?f.snapshot.layoutBox:void 0,a)}return Ft(this.latestValues)&&uc(u,this.latestValues),u}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==pe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){var u;let p=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=p.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=p.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=p.isSharedProjectionDirty);let f=!!this.resumingFrom||this!==p;if(!(c||f&&this.isSharedProjectionDirty||this.isProjectionDirty||!((u=this.parent)===null||u===void 0)&&u.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:l,layoutId:m}=this.options;if(!(!this.layout||!(l||m))){if(this.resolvedRelativeTargetAt=pe.timestamp,!this.targetDelta&&!this.relativeTarget){let d=this.getClosestProjectingParent();d&&d.layout&&this.animationProgress!==1?(this.relativeParent=d,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),_o(this.relativeTargetOrigin,this.layout.layoutBox,d.layout.layoutBox),Qe(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Y(),this.targetWithTransforms=Y()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Np(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Qe(this.target,this.layout.layoutBox),sc(this.target,this.targetDelta)):Qe(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;let d=this.getClosestProjectingParent();d&&!!d.resumingFrom==!!this.resumingFrom&&!d.options.layoutScroll&&d.target&&this.animationProgress!==1?(this.relativeParent=d,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),_o(this.relativeTargetOrigin,this.target,d.target),Qe(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}Cr&&Vn.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||ts(this.parent.latestValues)||rc(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var c;let u=this.getLead(),p=!!this.resumingFrom||this!==u,f=!0;if((this.isProjectionDirty||!((c=this.parent)===null||c===void 0)&&c.isProjectionDirty)&&(f=!1),p&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(f=!1),this.resolvedRelativeTargetAt===pe.timestamp&&(f=!1),f)return;let{layout:a,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(a||l))return;Qe(this.layoutCorrected,this.layout.layoutBox);let m=this.treeScale.x,d=this.treeScale.y;nm(this.layoutCorrected,this.treeScale,this.path,p),u.layout&&!u.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(u.target=u.layout.layoutBox,u.targetWithTransforms=Y());let{target:h}=u;if(!h){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(lc(this.prevProjectionDelta.x,this.projectionDelta.x),lc(this.prevProjectionDelta.y,this.projectionDelta.y)),Lo(this.projectionDelta,this.layoutCorrected,h,this.latestValues),(this.treeScale.x!==m||this.treeScale.y!==d||!dc(this.projectionDelta.x,this.prevProjectionDelta.x)||!dc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",h)),Cr&&Vn.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){var u;if((u=this.options.visualElement)===null||u===void 0||u.scheduleRender(),c){let p=this.getStack();p&&p.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=_n(),this.projectionDelta=_n(),this.projectionDeltaWithTransform=_n()}setAnimationOrigin(c,u=!1){let p=this.snapshot,f=p?p.latestValues:{},a={...this.latestValues},l=_n();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;let m=Y(),d=p?p.source:void 0,h=this.layout?this.layout.source:void 0,g=d!==h,y=this.getStack(),T=!y||y.members.length<=1,v=!!(g&&!T&&this.options.crossfade===!0&&!this.path.some(Iy));this.animationProgress=0;let S;this.mixTargetDelta=C=>{let x=C/1e3;Em(l.x,c.x,x),Em(l.y,c.y,x),this.setTargetDelta(l),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(_o(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Ry(this.relativeTarget,this.relativeTargetOrigin,m,x),S&&bm(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=Y()),Qe(S,this.relativeTarget)),g&&(this.animationValues=a,dm(a,f,this.latestValues,x,v,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=x},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Ze(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=L.update(()=>{Mo.hasAnimatedSinceResize=!0,this.currentAnimation=cs(0,Cm,{...c,onUpdate:u=>{this.mixTargetDelta(u),c.onUpdate&&c.onUpdate(u)},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Cm),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let c=this.getLead(),{targetWithTransforms:u,target:p,layout:f,latestValues:a}=c;if(!(!u||!p||!f)){if(this!==c&&this.layout&&f&&_m(this.options.animationType,this.layout.layoutBox,f.layoutBox)){p=this.target||Y();let l=Pe(this.layout.layoutBox.x);p.x.min=c.target.x.min,p.x.max=p.x.min+l;let m=Pe(this.layout.layoutBox.y);p.y.min=c.target.y.min,p.y.max=p.y.min+m}Qe(u,p),Mn(u,a),Lo(this.projectionDeltaWithTransform,this.layoutCorrected,u,a)}}registerSharedNode(c,u){this.sharedNodes.has(c)||this.sharedNodes.set(c,new ps),this.sharedNodes.get(c).add(u);let f=u.options.initialPromotionConfig;u.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(u):void 0})}isLead(){let c=this.getStack();return c?c.lead===this:!0}getLead(){var c;let{layoutId:u}=this.options;return u?((c=this.getStack())===null||c===void 0?void 0:c.lead)||this:this}getPrevLead(){var c;let{layoutId:u}=this.options;return u?(c=this.getStack())===null||c===void 0?void 0:c.prevLead:void 0}getStack(){let{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:u,preserveFollowOpacity:p}={}){let f=this.getStack();f&&f.promote(this,p),c&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){let c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){let{visualElement:c}=this.options;if(!c)return;let u=!1,{latestValues:p}=c;if((p.z||p.rotate||p.rotateX||p.rotateY||p.rotateZ||p.skewX||p.skewY)&&(u=!0),!u)return;let f={};p.z&&gc("z",c,f,this.animationValues);for(let a=0;a<hc.length;a++)gc(`rotate${hc[a]}`,c,f,this.animationValues),gc(`skew${hc[a]}`,c,f,this.animationValues);c.render();for(let a in f)c.setStaticValue(a,f[a]),this.animationValues&&(this.animationValues[a]=f[a]);c.scheduleRender()}getProjectionStyles(c){var u,p;if(!this.instance||this.isSVG)return;if(!this.isVisible)return yy;let f={visibility:""},a=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,f.opacity="",f.pointerEvents=io(c?.pointerEvents)||"",f.transform=a?a(this.latestValues,""):"none",f;let l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){let g={};return this.options.layoutId&&(g.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,g.pointerEvents=io(c?.pointerEvents)||""),this.hasProjected&&!Ft(this.latestValues)&&(g.transform=a?a({},""):"none",this.hasProjected=!1),g}let m=l.animationValues||l.latestValues;this.applyTransformsToTarget(),f.transform=Am(this.projectionDeltaWithTransform,this.treeScale,m),a&&(f.transform=a(m,f.transform));let{x:d,y:h}=this.projectionDelta;f.transformOrigin=`${d.origin*100}% ${h.origin*100}% 0`,l.animationValues?f.opacity=l===this?(p=(u=m.opacity)!==null&&u!==void 0?u:this.latestValues.opacity)!==null&&p!==void 0?p:1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:f.opacity=l===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(let g in mo){if(m[g]===void 0)continue;let{correct:y,applyTo:T}=mo[g],v=f.transform==="none"?m[g]:y(m[g],l);if(T){let S=T.length;for(let C=0;C<S;C++)f[T[C]]=v}else f[g]=v}return this.options.layoutId&&(f.pointerEvents=l===this?io(c?.pointerEvents)||"":"none"),f}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>{var u;return(u=c.currentAnimation)===null||u===void 0?void 0:u.stop()}),this.root.nodes.forEach(wm),this.root.sharedNodes.clear()}}}function vy(o){o.updateLayout()}function Sy(o){var t;let n=((t=o.resumeFrom)===null||t===void 0?void 0:t.snapshot)||o.snapshot;if(o.isLead()&&o.layout&&n&&o.hasListeners("didUpdate")){let{layoutBox:r,measuredBox:i}=o.layout,{animationType:s}=o.options,c=n.source!==o.layout.source;s==="size"?$e(l=>{let m=c?n.measuredBox[l]:n.layoutBox[l],d=Pe(m);m.min=r[l].min,m.max=m.min+d}):_m(s,n.layoutBox,r)&&$e(l=>{let m=c?n.measuredBox[l]:n.layoutBox[l],d=Pe(r[l]);m.max=m.min+d,o.relativeTarget&&!o.currentAnimation&&(o.isProjectionDirty=!0,o.relativeTarget[l].max=o.relativeTarget[l].min+d)});let u=_n();Lo(u,r,n.layoutBox);let p=_n();c?Lo(p,o.applyTransform(i,!0),n.measuredBox):Lo(p,r,n.layoutBox);let f=!pc(u),a=!1;if(!o.resumeFrom){let l=o.getClosestProjectingParent();if(l&&!l.resumeFrom){let{snapshot:m,layout:d}=l;if(m&&d){let h=Y();_o(h,n.layoutBox,m.layoutBox);let g=Y();_o(g,r,d.layoutBox),mc(h,g)||(a=!0),l.options.layoutRoot&&(o.relativeTarget=g,o.relativeTargetOrigin=h,o.relativeParent=l)}}}o.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:p,layoutDelta:u,hasLayoutChanged:f,hasRelativeTargetChanged:a})}else if(o.isLead()){let{onExitComplete:r}=o.options;r&&r()}o.options.transition=void 0}function xy(o){Cr&&Vn.totalNodes++,o.parent&&(o.isProjecting()||(o.isProjectionDirty=o.parent.isProjectionDirty),o.isSharedProjectionDirty||(o.isSharedProjectionDirty=!!(o.isProjectionDirty||o.parent.isProjectionDirty||o.parent.isSharedProjectionDirty)),o.isTransformDirty||(o.isTransformDirty=o.parent.isTransformDirty))}function by(o){o.isProjectionDirty=o.isSharedProjectionDirty=o.isTransformDirty=!1}function Ay(o){o.clearSnapshot()}function wm(o){o.clearMeasurements()}function Cy(o){o.isLayoutDirty=!1}function wy(o){let{visualElement:t}=o.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),o.resetTransform()}function Pm(o){o.finishAnimation(),o.targetDelta=o.relativeTarget=o.target=void 0,o.isProjectionDirty=!0}function Py(o){o.resolveTargetDelta()}function Ey(o){o.calcProjection()}function ky(o){o.resetSkewAndRotation()}function Dy(o){o.removeLeadSnapshot()}function Em(o,t,n){o.translate=G(t.translate,0,n),o.scale=G(t.scale,1,n),o.origin=t.origin,o.originPoint=t.originPoint}function km(o,t,n,r){o.min=G(t.min,n.min,r),o.max=G(t.max,n.max,r)}function Ry(o,t,n,r){km(o.x,t.x,n.x,r),km(o.y,t.y,n.y,r)}function Iy(o){return o.animationValues&&o.animationValues.opacityExit!==void 0}var Ly={duration:.45,ease:[.4,0,.1,1]},Dm=o=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(o),Rm=Dm("applewebkit/")&&!Dm("chrome/")?Math.round:te;function Im(o){o.min=Rm(o.min),o.max=Rm(o.max)}function _y(o){Im(o.x),Im(o.y)}function _m(o,t,n){return o==="position"||o==="preserve-aspect"&&!Vp(fc(t),fc(n),.2)}function My(o){var t;return o!==o.root&&((t=o.scroll)===null||t===void 0?void 0:t.wasRoot)}var Mm=ms({attachResizeListener:(o,t)=>Nt(o,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0});var yc={current:void 0},fs=ms({measureScroll:o=>({x:o.scrollLeft,y:o.scrollTop}),defaultParent:()=>{if(!yc.current){let o=new Mm({});o.mount(window),o.setOptions({layoutScroll:!0}),yc.current=o}return yc.current},resetTransform:(o,t)=>{o.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:o=>window.getComputedStyle(o).position==="fixed"});var Vm={pan:{Feature:ss},drag:{Feature:is,ProjectionNode:fs,MeasureLayout:as}};function ds(o,t,n){var r;if(o instanceof Element)return[o];if(typeof o=="string"){let i=document;t&&(i=t.current);let s=(r=n?.[o])!==null&&r!==void 0?r:i.querySelectorAll(o);return s?Array.from(s):[]}return Array.from(o)}function hs(o,t){let n=ds(o),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function Nm(o){return t=>{t.pointerType==="touch"||Ji()||o(t)}}function Gm(o,t,n={}){let[r,i,s]=hs(o,n),c=Nm(u=>{let{target:p}=u,f=t(u);if(typeof f!="function"||!p)return;let a=Nm(l=>{f(l),p.removeEventListener("pointerleave",a)});p.addEventListener("pointerleave",a,i)});return r.forEach(u=>{u.addEventListener("pointerenter",c,i)}),s}function Fm(o,t,n){let{props:r}=o;o.animationState&&r.whileHover&&o.animationState.setActive("whileHover",n==="Start");let i="onHover"+n,s=r[i];s&&L.postRender(()=>s(t,Gt(t)))}var gs=class extends Te{mount(){let{current:t}=this.node;t&&(this.unmount=Gm(t,n=>(Fm(this.node,n,"Start"),r=>Fm(this.node,r,"End"))))}unmount(){}};var ys=class extends Te{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ct(Nt(this.node.current,"focus",()=>this.onFocus()),Nt(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};var Tc=(o,t)=>t?o===t?!0:Tc(o,t.parentElement):!1;var Vy=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Om(o){return Vy.has(o.tagName)||o.tabIndex!==-1}var Nn=new WeakSet;function Hm(o){return t=>{t.key==="Enter"&&o(t)}}function vc(o,t){o.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var Um=(o,t)=>{let n=o.currentTarget;if(!n)return;let r=Hm(()=>{if(Nn.has(n))return;vc(n,"down");let i=Hm(()=>{vc(n,"up")}),s=()=>vc(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function Km(o){return Ro(o)&&!Ji()}function Bm(o,t,n={}){let[r,i,s]=hs(o,n),c=u=>{let p=u.currentTarget;if(!Km(u)||Nn.has(p))return;Nn.add(p);let f=t(u),a=(d,h)=>{window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",m),!(!Km(d)||!Nn.has(p))&&(Nn.delete(p),typeof f=="function"&&f(d,{success:h}))},l=d=>{a(d,n.useGlobalTarget||Tc(p,d.target))},m=d=>{a(d,!1)};window.addEventListener("pointerup",l,i),window.addEventListener("pointercancel",m,i)};return r.forEach(u=>{!Om(u)&&u.getAttribute("tabindex")===null&&(u.tabIndex=0),(n.useGlobalTarget?window:u).addEventListener("pointerdown",c,i),u.addEventListener("focus",f=>Um(f,i),i)}),s}function Wm(o,t,n){let{props:r}=o;o.animationState&&r.whileTap&&o.animationState.setActive("whileTap",n==="Start");let i="onTap"+(n==="End"?"":n),s=r[i];s&&L.postRender(()=>s(t,Gt(t)))}var Ts=class extends Te{mount(){let{current:t}=this.node;t&&(this.unmount=Bm(t,n=>(Wm(this.node,n,"Start"),(r,{success:i})=>Wm(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}};var xc=new WeakMap,Sc=new WeakMap,Ny=o=>{let t=xc.get(o.target);t&&t(o)},Gy=o=>{o.forEach(Ny)};function Fy({root:o,...t}){let n=o||document;Sc.has(n)||Sc.set(n,{});let r=Sc.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Gy,{root:o,...t})),r[i]}function jm(o,t,n){let r=Fy(t);return xc.set(o,n),r.observe(o),()=>{xc.delete(o),r.unobserve(o)}}var Oy={some:0,all:1},vs=class extends Te{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=t,c={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:Oy[i]},u=p=>{let{isIntersecting:f}=p;if(this.isInView===f||(this.isInView=f,s&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);let{onViewportEnter:a,onViewportLeave:l}=this.node.getProps(),m=f?a:l;m&&m(p)};return jm(this.node.current,c,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;let{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Hy(t,n))&&this.startObserver()}unmount(){}};function Hy({viewport:o={}},{viewport:t={}}={}){return n=>o[n]!==t[n]}var $m={inView:{Feature:vs},tap:{Feature:Ts},focus:{Feature:ys},hover:{Feature:gs}};var zm={layout:{ProjectionNode:fs,MeasureLayout:as}};import{Fragment as By}from"react";var wr={current:null},Ss={current:!1};function qm(){if(Ss.current=!0,!!Qn)if(window.matchMedia){let o=window.matchMedia("(prefers-reduced-motion)"),t=()=>wr.current=o.matches;o.addListener(t),t()}else wr.current=!1}var Uy=[...Wa,fe,Ue],Xm=o=>Uy.find(Fi(o));var Ot=new WeakMap;function Ym(o,t,n){for(let r in t){let i=t[r],s=n[r];if(z(i))o.addValue(r,i);else if(z(s))o.addValue(r,Vt(i,{owner:o}));else if(s!==i)if(o.hasValue(r)){let c=o.getValue(r);c.liveStyle===!0?c.jump(i):c.hasAnimated||c.set(i)}else{let c=o.getStaticValue(r);o.addValue(r,Vt(c!==void 0?c:i,{owner:o}))}}for(let r in n)t[r]===void 0&&o.removeValue(r);return t}var Zm=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],No=class{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:c},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=yn,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let d=_e.now();this.renderScheduledAt<d&&(this.renderScheduledAt=d,L.render(this.render,!1,!0))};let{latestValues:p,renderState:f,onUpdate:a}=c;this.onUpdate=a,this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=f,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=u,this.blockInitialAnimation=!!s,this.isControllingVariants=En(n),this.isVariantNode=ci(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);let{willChange:l,...m}=this.scrapeMotionValuesFromProps(n,{},this);for(let d in m){let h=m[d];p[d]!==void 0&&z(h)&&h.set(p[d],!1)}}mount(t){this.current=t,Ot.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),Ss.current||qm(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:wr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Ot.delete(this.current),this.projection&&this.projection.unmount(),Ze(this.notifyUpdate),Ze(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(let t in this.events)this.events[t].clear();for(let t in this.features){let n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();let r=je.has(t),i=n.on("change",u=>{this.latestValues[t]=u,this.props.onUpdate&&L.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),s=n.on("renderRequest",this.scheduleRender),c;window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),s(),c&&c(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in It){let n=It[t];if(!n)continue;let{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){let s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Y()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Zm.length;r++){let i=Zm[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);let s="on"+i,c=t[s];c&&(this.propEventSubscriptions[i]=this.on(i,c))}this.prevMotionValues=Ym(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){let n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){let r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);let n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Vt(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){var r;let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(r=this.getBaseTargetFromProps(this.props,t))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(Gi(i)||Mi(i))?i=parseFloat(i):!Xm(i)&&Ue.test(n)&&(i=Ni(t,n)),this.setBaseTarget(t,z(i)?i.get():i)),z(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;let{initial:r}=this.props,i;if(typeof r=="string"||typeof r=="object"){let c=ro(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);c&&(i=c[t])}if(r&&i!==void 0)return i;let s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!z(s)?s:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new mn),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}};var Go=class extends No{constructor(){super(...arguments),this.KeyframeResolver=Ao}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:t}=this.props;z(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}};function Ky(o){return window.getComputedStyle(o)}var Fo=class extends Go{constructor(){super(...arguments),this.type="html",this.renderInstance=hi}readValueFromInstance(t,n){if(je.has(n)){let r=bo(n);return r&&r.default||0}else{let r=Ky(t),i=(mi(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return ac(t,n)}build(t,n,r){co(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return fo(t,n,r)}};var Oo=class extends Go{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Y}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(je.has(n)){let r=bo(n);return r&&r.default||0}return n=gi.has(n)?n:to(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return vi(t,n,r)}build(t,n,r){lo(t,n,this.isSVGTag,r.transformTemplate)}renderInstance(t,n,r,i){yi(t,n,r,i)}mount(t){this.isSVGTag=po(t.tagName),super.mount(t)}};var Jm=(o,t)=>oo(o)?new Oo(t):new Fo(t,{allowProjection:o!==By});var Qm=Du({...Ap,...$m,...Vm,...zm},Jm);var Ht=Ql(Qm);function ef(o,t=100,n){let r=n({...o,keyframes:[0,t]}),i=Math.min(wo(r),2e4);return{type:"keyframes",ease:s=>r.next(i*s).value/t,duration:Me(i)}}var tf=(o,t,n)=>{let r=t-o;return((n-o)%r+r)%r+o};function xs(o,t){return ji(o)?o[tf(0,o.length,t)]:o}function Pr(o){return typeof o=="object"&&!Array.isArray(o)}function bs(o,t,n,r){return typeof o=="string"&&Pr(t)?ds(o,n,r):o instanceof NodeList?Array.from(o):Array.isArray(o)?o:[o]}function nf(o,t,n){return o*(t+1)}function bc(o,t,n,r){var i;return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,o+parseFloat(t)):t==="<"?n:(i=r.get(t))!==null&&i!==void 0?i:o}function Wy(o,t,n){for(let r=0;r<o.length;r++){let i=o[r];i.at>t&&i.at<n&&(pn(o,i),r--)}}function of(o,t,n,r,i,s){Wy(o,i,s);for(let c=0;c<t.length;c++)o.push({value:t[c],at:G(i,s,r[c]),easing:xs(n,c)})}function rf(o,t){for(let n=0;n<o.length;n++)o[n]=o[n]/(t+1)}function sf(o,t){return o.at===t.at?o.value===null?1:t.value===null?-1:0:o.at-t.at}var jy="easeInOut",$y=20;function lf(o,{defaultTransition:t={},...n}={},r,i){let s=t.duration||.3,c=new Map,u=new Map,p={},f=new Map,a=0,l=0,m=0;for(let d=0;d<o.length;d++){let h=o[d];if(typeof h=="string"){f.set(h,l);continue}else if(!Array.isArray(h)){f.set(h.name,bc(l,h.at,a,f));continue}let[g,y,T={}]=h;T.at!==void 0&&(l=bc(l,T.at,a,f));let v=0,S=(C,x,w,_=0,A=0)=>{let P=zy(C),{delay:V=0,times:J=zi(P),type:I="keyframes",repeat:W,repeatType:se,repeatDelay:oe=0,...Fe}=x,{ease:O=t.ease||"easeOut",duration:F}=x,ae=typeof V=="function"?V(_,A):V,H=P.length,j=fn(I)?I:i?.[I];if(H<=2&&j){let vt=100;if(H===2&&Yy(P)){let mt=P[1]-P[0];vt=Math.abs(mt)}let Rt={...Fe};F!==void 0&&(Rt.duration=ye(F));let en=ef(Rt,vt,j);O=en.ease,F=en.duration}F??(F=s);let Ie=l+ae;J.length===1&&J[0]===0&&(J[1]=1);let Le=J.length-P.length;if(Le>0&&$i(J,Le),P.length===1&&P.unshift(null),W){Ye(W<$y,"Repeat count too high, must be less than 20"),F=nf(F,W);let vt=[...P],Rt=[...J];O=Array.isArray(O)?[...O]:[O];let en=[...O];for(let mt=0;mt<W;mt++){P.push(...vt);for(let tn=0;tn<vt.length;tn++)J.push(Rt[tn]+(mt+1)),O.push(tn===0?"linear":xs(en,tn-1))}rf(J,W)}let Oe=Ie+F;of(w,P,O,J,Ie,Oe),v=Math.max(ae+F,v),m=Math.max(Oe,m)};if(z(g)){let C=af(g,u);S(y,T,cf("default",C))}else{let C=bs(g,y,r,p),x=C.length;for(let w=0;w<x;w++){y=y,T=T;let _=C[w],A=af(_,u);for(let P in y)S(y[P],qy(T,P),cf(P,A),w,x)}}a=l,l+=v}return u.forEach((d,h)=>{for(let g in d){let y=d[g];y.sort(sf);let T=[],v=[],S=[];for(let x=0;x<y.length;x++){let{at:w,value:_,easing:A}=y[x];T.push(_),v.push(Je(0,m,w)),S.push(A||"easeOut")}v[0]!==0&&(v.unshift(0),T.unshift(T[0]),S.unshift(jy)),v[v.length-1]!==1&&(v.push(1),T.push(null)),c.has(h)||c.set(h,{keyframes:{},transition:{}});let C=c.get(h);C.keyframes[g]=T,C.transition[g]={...t,duration:m,ease:S,times:v,...n}}}),c}function af(o,t){return!t.has(o)&&t.set(o,{}),t.get(o)}function cf(o,t){return t[o]||(t[o]=[]),t[o]}function zy(o){return Array.isArray(o)?o:[o]}function qy(o,t){return o&&o[t]?{...o,...o[t]}:{...o}}var Xy=o=>typeof o=="number",Yy=o=>o.every(Xy);function Zy(o,t){return o in t}var As=class extends No{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,n){if(Zy(n,t)){let r=t[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(t,n){delete n.output[t]}measureInstanceViewportBox(){return Y()}build(t,n){Object.assign(t.output,n)}renderInstance(t,{output:n}){Object.assign(t,n)}sortInstanceNodePosition(){return 0}};function uf(o){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=ls(o)?new Oo(t):new Fo(t);n.mount(o),Ot.set(o,n)}function pf(o){let t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new As(t);n.mount(o),Ot.set(o,n)}function Jy(o,t){return z(o)||typeof o=="number"||typeof o=="string"&&!Pr(t)}function Cs(o,t,n,r){let i=[];if(Jy(o,t))i.push(cs(o,Pr(t)&&t.default||t,n&&(n.default||n)));else{let s=bs(o,t,r),c=s.length;Ye(!!c,"No valid elements provided.");for(let u=0;u<c;u++){let p=s[u],f=p instanceof Element?uf:pf;Ot.has(p)||f(p);let a=Ot.get(p),l={...n};"delay"in l&&typeof l.delay=="function"&&(l.delay=l.delay(u,c)),i.push(...Do(a,{...t,transition:l},{}))}}return i}function mf(o,t,n){let r=[];return lf(o,t,n,{spring:Eo}).forEach(({keyframes:s,transition:c},u)=>{r.push(...Cs(u,s,c))}),r}function Qy(o){return Array.isArray(o)&&o.some(Array.isArray)}function ff(o){function t(n,r,i){let s=[];Qy(n)?s=mf(n,r,o):s=Cs(n,r,i,o);let c=new To(s);return o&&o.animations.push(c),c}return t}var Er=ff();var kr=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(kr||{}),df={left:"33.33%",center:"50%",right:"66.66%"},st=class st{static isUnknown(t){return t===st.Unknown}static D2PositionToCSS(t,n=!1,r=!1){let i=this.calc(t.y,t.yoffset),s=this.calc(t.x,t.xoffset),c=r?{bottom:i}:{top:i},u=n?{right:s}:{left:s};return this.wrap({...c,...u})}static calc(t,n){return!t||st.isUnknown(t)?"auto":n===void 0||st.isUnknown(n)?`calc(${t} + 0px)`:`calc(${typeof t=="number"?`${t}px`:t} + ${n}px)`}static toCoord2D(t){if(at.isCommonPositionType(t))return ze.fromCommonPosition(t);if(ze.isCoord2DPosition(t))return t;if(Gn.isAlignPosition(t))return ze.fromAlignPosition(t);if(typeof t=="object"&&["x","y","xoffset","yoffset"].some(n=>n in t)){let n=t;return new ze(n)}else throw new Error("Invalid position type")}static orUnknown(t){return st.isUnknown(t)||t===void 0?st.Unknown:t}static mergePosition(t,n){let r=this.toCoord2D(t),i=this.toCoord2D(n);return ze.merge(r,i)}static serializePosition(t){let n=this.toCoord2D(t);return{x:st.isUnknown(n.x)?0:n.x,y:st.isUnknown(n.y)?0:n.y,xoffset:st.isUnknown(n.xoffset)?0:n.xoffset,yoffset:st.isUnknown(n.yoffset)?0:n.yoffset}}static isRawCommonPositionType(t){return Object.values(kr).includes(t)}static isRawCoord2DPosition(t){return typeof t=="object"&&("x"in t||"y"in t||"xoffset"in t||"yoffset"in t)}static isRawAlignPosition(t){return typeof t=="object"&&("xalign"in t||"yalign"in t||"xoffset"in t||"yoffset"in t)}static isRawPosition(t){return this.isRawCommonPositionType(t)||this.isRawCoord2DPosition(t)||this.isRawAlignPosition(t)}static isPosition(t){return t instanceof at||t instanceof ze||t instanceof Gn}static rawPositionToCoord2D(t){if(this.isRawCommonPositionType(t))return ze.fromCommonPosition(new at(t));if(this.isRawCoord2DPosition(t))return new ze(t);if(this.isRawAlignPosition(t))return ze.fromAlignPosition(t);throw new Error("Invalid position type")}static tryParsePosition(t){if(this.isPosition(t))return t;if(this.isRawPosition(t))return this.rawPositionToCoord2D(t);throw new Error("Invalid position type")}static wrap(t){return{left:"auto",top:"auto",right:"auto",bottom:"auto",...t}}};st.Unknown=Symbol("Unknown");var R=st,ws=class ws{static isCommonPositionType(t){return t instanceof ws}constructor(t){this.position=t}toCSS(){return{x:df[this.position],y:"50%",xoffset:0,yoffset:0}}};ws.Positions=kr;var at=ws,ze=class o{static isCoord2DPosition(t){return t instanceof o}static fromCommonPosition(t){return new o({x:df[t.position],y:"50%"})}static fromAlignPosition(t){return new o({x:R.isUnknown(t.xalign)?R.Unknown:`${t.xalign*100}%`,y:R.isUnknown(t.yalign)?R.Unknown:`${t.yalign*100}%`,xoffset:t.xoffset,yoffset:t.yoffset})}static merge(t,n){return new o({x:R.isUnknown(n.x)?t.x:n.x,y:R.isUnknown(n.y)?t.y:n.y,xoffset:R.isUnknown(n.xoffset)?t.xoffset:n.xoffset,yoffset:R.isUnknown(n.yoffset)?t.yoffset:n.yoffset})}constructor(t,n){typeof t=="object"?(this.x=R.orUnknown(t.x),this.y=R.orUnknown(t.y),this.xoffset=R.orUnknown(t.xoffset),this.yoffset=R.orUnknown(t.yoffset)):(this.x=R.orUnknown(t),this.y=R.orUnknown(n),this.xoffset=R.Unknown,this.yoffset=R.Unknown)}toCSS(){return{x:this.x,y:this.y,xoffset:this.xoffset,yoffset:this.yoffset}}},Gn=class o{static isAlignPosition(t){return t instanceof o}constructor(t,n){typeof t=="object"?(this.xalign=R.orUnknown(t.xalign),this.yalign=R.orUnknown(t.yalign),this.xoffset=R.orUnknown(t.xoffset),this.yoffset=R.orUnknown(t.yoffset)):(this.xalign=R.orUnknown(t),this.yalign=R.orUnknown(n),this.xoffset=R.Unknown,this.yoffset=R.Unknown)}toCSS(){return{x:R.isUnknown(this.xalign)?this.xalign:`${this.xalign*100}%`,y:R.isUnknown(this.yalign)?this.yalign:`${this.yalign*100}%`,xoffset:this.xoffset,yoffset:this.yoffset}}};var X=class o{constructor(t,n){this.defaultConfig=t;this.handlers=n||{}}create(t={}){return new Ac(this.mergeWithDefaultConfig(t))}copy(){return new o(U({},this.defaultConfig),this.handlers)}keys(){return Object.keys(this.defaultConfig)}getDefaultConfig(){return this.defaultConfig}mergeWithDefaultConfig(t){return Object.fromEntries(Object.entries(this.defaultConfig).map(([n,r])=>[n,this.mergeValue(n,r,t[n])]))}mergeValue(t,n,r){return this.isPlainObject(r)?U({},r):Array.isArray(n)?Array.isArray(r)&&r.length>0?[...r]:[...n]:r!==void 0?this.applyHandler(t,r):n}isPlainObject(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null&&Object.getPrototypeOf(t)===Object.prototype}applyHandler(t,n){return typeof this.handlers[t]=="function"?this.handlers[t](n):n}},Ac=class o{constructor(t){this.config=t}get(){return this.config}copy(){return new o(U({},this.config))}join(t){let n=_l(this.config,Object.keys(t));return new o(Object.assign(n,t instanceof o?t.get():t))}extract(t){let n={},r={};for(let i of t)n[i]=this.config[i];for(let i in this.config)t.includes(i)||(r[i]=this.config[i]);return[new o(n),new o(r)]}assign(t){return new o(Object.assign({},this.config,t))}};var eT={[Qr.left]:"25.33%",[Qr.center]:"50%",[Qr.right]:"75.66%"},ht=class ht{constructor(t={}){this.state={};this.locked=null;this.frozen=!1;this.state=t}static deserialize(t){return new ht(ht.TransformStateSerializer.deserialize(t))}static mergePosition(t,n){if(!t&&!n)throw new Error("No position found.");return!t||!n?R.toCoord2D(R.tryParsePosition(t||n)):R.mergePosition(R.tryParsePosition(t),R.tryParsePosition(n))}static mergeState(t,n){if("position"in t&&"position"in n){let r=this.mergePosition(t.position,n.position);return{...Object.assign({},t,n),position:r}}return{...Object.assign({},t,n)}}get(){return this.state}freeze(){return this.frozen=!0,this}assign(t,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(t))throw new Error("Trying to write a locked transform state.");return this.state=ht.mergeState(this.state,n),this}lock(){if(this.locked)throw new Error("Transform state is already locked.");return this.locked=Symbol(),this.locked}isLocked(){return!!this.locked}canWrite(t){return this.locked===null||this.locked===t}unlock(t){return this.locked===t&&(this.locked=null),this}toFramesDefinition(t,n){return ba(ce.constructStyle(t,this.state,n))}toStyle(t,n){return ba(ce.constructStyle(t,this.state,n))}serialize(){return ht.TransformStateSerializer.serialize(this.state)}clone(){return new ht(ht.mergeState({},this.state))}overwrite(t,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(t))throw new Error("Trying to write a locked transform state.");return this.state=ht.mergeState(this.state,n),this}forceOverwrite(t){return this.state=t,this}};ht.DefaultTransformState=new X({scale:1,rotation:0,position:new at("center"),opacity:0,alt:""}),ht.TransformStateSerializer=new rt({position:t=>R.toCoord2D(R.tryParsePosition(t))},{position:R.toCoord2D});var Se=ht,ve=class ve{constructor(t,n){this.sequences=[];this.stagedChanges=[];if(Array.isArray(t))this.sequences.push(...t),this.config=Object.assign({},ve.defaultConfig,n||{});else{let[r,i]=[t,n||ve.defaultOptions];this.sequences.push({props:r,options:i||ve.defaultOptions}),this.config=Object.assign({},ve.defaultConfig)}}static isPosition(t){return at.isCommonPositionType(t)||ze.isCoord2DPosition(t)||Gn.isAlignPosition(t)}static immediate(t){return new ve(t,{duration:0,ease:"linear"})}static left(t,n){return new ve({position:at.Positions.Left},{duration:t,ease:n})}static right(t,n){return new ve({position:at.Positions.Right},{duration:t,ease:n})}static center(t,n){return new ve({position:at.Positions.Center},{duration:t,ease:n})}static create(t){return new ve([],t)}static positionToCSS(t,n,r){return t?R.isRawPosition(t)?R.D2PositionToCSS(R.rawPositionToCoord2D(t),r,n):R.D2PositionToCSS(t.toCSS(),r,n):{}}static mergePosition(t,n){if(!t&&!n)throw new Error("No position found.");return!t||!n?R.toCoord2D(R.tryParsePosition(t||n)):R.mergePosition(R.tryParsePosition(t),R.tryParsePosition(n))}static mergeState(t,n){let r=this.mergePosition(t.position,n.position);return{...U(t,n),position:r}}static propToCSSTransform(t,n,{translate:r=[],scale:i=1}={}){if(!t.getLastScene())throw new Error('No scene found in state, make sure you called "scene.activate()" before this method.');let s=n.scale!==void 0?n.scale:1,{invertY:c,invertX:u}=t.getStory().getInversionConfig();return[`translate(${r[0]||(u?"":"-")+"50%"}, ${r[1]||(c?"":"-")+"50%"})`,n.rotation!==void 0&&`rotate(${n.rotation}deg)`,`scale(${s*i})`].filter(Boolean).join(" ")}static constructStyle(t,n,r){let{invertY:i,invertX:s}=t.getStory().getInversionConfig(),{transform:c,scale:u,overwrite:p}=r||{};return{...ve.positionToCSS(n.position,i,s),opacity:n.opacity,color:"fontColor"in n&&n.fontColor?Pn(n.fontColor):void 0,transform:c?c(n):ve.propToCSSTransform(t,n),scale:u?u(n):void 0,...p?p(n):{}}}animate(t,{gameState:n,ref:r,overwrites:i}){if(!r.current)throw new Error("No ref found when animating.");this.commit();let{finalState:s,sequences:c,options:u}=this.constructAnimation({gameState:n,transformState:t,overwrites:i,current:r.current});c.length||n.logger.warn("Transform","No sequences to animate.");let p=t.lock(),f=Er(c,u),a=()=>{t.unlock(p),f.complete()},l=new b().registerSkipController(new K(a)),m=()=>{t.overwrite(p,s.get()).unlock(p),n.logger.debug("Transform","Transform Completed",t.toStyle(n,i)),l.resolve()};return f.then(m,d=>{n.logger.error("Failed to animate transform. "+(d?.toString?.()||""))}),f.play(),n.logger.debug("Transform","Ready to animate transform.",{finalState:s,sequences:c,options:u},this),l}repeat(t){let n=this.copy();return n.config.repeat||(n.config.repeat=1),n.config.repeat*=t,n}getOptions(t){if(!t)return{...ve.defaultOptions};let{duration:n,ease:r,delay:i,at:s}=t;return{duration:this.toSeconds(n,void 0),ease:r,delay:this.toSeconds(i,void 0),at:this.atToSeconds(s)}}constructAnimation({gameState:t,transformState:n,overwrites:r={},current:i}){let s=n.clone(),c=s.lock(),u=this.sequences.map(({props:p,options:f})=>{let a=s.assign(c,p).toFramesDefinition(t,r);return[i,a,this.getOptions(f)]});return{finalState:s.unlock(c).freeze(),sequences:u,options:this.getSequenceOptions()}}getSequenceOptions(){let{repeat:t,repeatDelay:n}=this.config;return{repeat:this.toSeconds(t,void 0),repeatDelay:this.toSeconds(n,void 0)}}copy(){return new ve(this.sequences,this.config)}commit(t){if(!this.stagedChanges.length)return this;let n=this.constructCommit(this.stagedChanges,this.getSequenceOptions());return this.sequences.push({props:n.props,options:{...this.getSequenceOptions(),...t}}),this.stagedChanges=[],this}scale(t){return this.pushChange({key:"scale",props:t})}rotation(t){return this.pushChange({key:"rotation",props:t})}position(t){return this.pushChange({key:"position",props:t})}opacity(t){return this.pushChange({key:"opacity",props:t})}fontColor(t){return this.pushChange({key:"fontColor",props:t})}constructCommit(t,n){let r={props:{},options:n};for(let i of t)r.props[i.key]=i.props;return r}pushChange(t){return this.stagedChanges.push(t),this}toSeconds(t,n){return typeof t>"u"?n:t/1e3}atToSeconds(t){if(typeof t>"u")return t;if(typeof t=="number")return t/1e3;let r=/^([+-])(\d+)$/.exec(t);if(!r)throw new me("Invalid at definition. At definition must be a number or a string in the format of `+n` or `-n`.");let[i,s,c]=r,u=Number(c);if(isNaN(u))throw new me("Invalid number in at definition.");let p=u/1e3;return s==="+"?`+${p}`:`-${p}`}};ve.defaultConfig={sync:!0},ve.defaultOptions={duration:0,ease:"linear"},ve.CommonImagePositionMap=eT;var ce=ve;var e={};var Ps=class{constructor(){this.id=""}setId(t){this.id=t}getId(){return this.id}reset(){}fromData(t){return this}construct(t){for(let n=0;n<t.length;n++){let r=t[n];n!==0&&t[n-1]?.contentNode.setChild(r.contentNode)}return t}};var Es=class{constructor(t){this.config=t;this.watching=null;this.warnings=[]}observe(t){return this.watching=t,this}warn(t,n){return this.warnings.push([t,n]),this.watching?.logger.warn(n),n}getWarnings(){return[...this.warnings]}};var ne=class o{constructor(t,n){this.awaitable=t;this.guard=n;this.children=[];this._onResolved=[];this._onCancelled=[];this._onTimelineRegistered=[];this._ableToAttach=!0;this._status="pending";t.onSettled(()=>{this.resolveStatus()}),rn(()=>{this.preventAttach()})}static proxy(t){let n=new b,r=new b,i=new o(r);return i.onTimelineRegistered(()=>{r.resolve()}).onSettled(()=>{let[s,c]=i.catSettled();t(s,c)}),n.onSkipControllerRegister(s=>{s.onAbort(()=>{i.abort()})}),[n,i]}static any(t){if(t.length===0)throw new M("Cannot create an 'any' timeline with no awaitables.");let n=new b,r=new b,i=new o(r),s=!1;for(let c of t)i.attachChild(c),c.then(u=>{s||(s=!0,n.resolve(u))});return n.onSkipControllerRegister(c=>{c.onAbort(()=>{i.abort()})}),[n,i]}static sequence(t,n){let r=n,i=null,s=new b,c=()=>{if(i){let u;i.onSkipControllerRegister(p=>{u=p.onAbort(()=>{s.abort()})}),i.then(p=>{u?.cancel(),r=p,i=t(p),i?rn(()=>c()):s.resolve(r)})}else s.resolve(r)};return s.registerSkipController(new K(()=>(i&&i.abort(),n))),i=t(n),i?rn(()=>c()):s.resolve(r),s}get status(){return this._status}isSettled(){return this._status!=="pending"}isResolved(){return this._status==="resolved"}isCancelled(){return this._status==="cancelled"}onResolved(t){this._onResolved.push(t)}onCancelled(t){this._onCancelled.push(t)}onSettled(t){this.isSettled()?rn(t):(this.onResolved(t),this.onCancelled(t))}abort(){this.isSettled()||(this.awaitable.abort(),this.setStatus("cancelled",this.emitEvents.bind(this)),this.children.forEach(t=>t.abort()))}attachChild(t){if(!this._ableToAttach)throw new M(`Attaching to this timeline violates the timeline's state.
|
|
11
|
+
`),()=>{document.head.removeChild(a)}},[t]),qd(wa,{isPresent:t,childRef:r,sizeRef:i,children:ti.cloneElement(o,{ref:r})})}var Wl=({children:o,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:c})=>{let u=Zn(eh),p=Jd(),f=Qd(l=>{u.set(l,!0);for(let m of u.values())if(!m)return;r&&r()},[u,r]),a=Kl(()=>({id:p,initial:t,isPresent:n,custom:i,onExitComplete:f,register:l=>(u.set(l,!1),()=>u.delete(l))}),s?[Math.random(),f]:[n,f]);return Kl(()=>{u.forEach((l,m)=>u.set(m,!1))},[n]),Bl.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),c==="popLayout"&&(o=Ul(Hl,{isPresent:n,children:o})),Ul(sn.Provider,{value:a,children:o})};function eh(){return new Map}import{useContext as th,useId as nh,useEffect as oh,useCallback as rh}from"react";function ni(o=!0){let t=th(sn);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,s=nh();oh(()=>{o&&i(s)},[o]);let c=rh(()=>o&&r&&r(s),[s,r,o]);return!n&&r?[!1,c]:[!0]}import{Children as ih,isValidElement as sh}from"react";var ar=o=>o.key||"";function Pa(o){let t=[];return ih.forEach(o,n=>{sh(n)&&t.push(n)}),t}import{useLayoutEffect as ah,useEffect as ch}from"react";var Qn=typeof window<"u";var oi=Qn?ah:ch;var cr=({children:o,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:c=!1})=>{let[u,p]=ni(c),f=uh(()=>Pa(o),[o]),a=c&&!u?[]:f.map(ar),l=$l(!0),m=$l(f),d=Zn(()=>new Map),[h,g]=zl(f),[y,T]=zl(f);oi(()=>{l.current=!1,m.current=f;for(let C=0;C<y.length;C++){let x=ar(y[C]);a.includes(x)?d.delete(x):d.get(x)!==!0&&d.set(x,!1)}},[y,a.length,a.join("-")]);let v=[];if(f!==h){let C=[...f];for(let x=0;x<y.length;x++){let w=y[x],_=ar(w);a.includes(_)||(C.splice(x,0,w),v.push(w))}s==="wait"&&v.length&&(C=v),T(Pa(C)),g(f);return}let{forceRender:S}=ph(Yn);return jl(lh,{children:y.map(C=>{let x=ar(C),w=c&&!u?!1:f===y||a.includes(x),_=()=>{if(d.has(x))d.set(x,!0);else return;let A=!0;d.forEach(P=>{P||(A=!1)}),A&&(S?.(),T(m.current),c&&p?.(),r&&r())};return jl(Wl,{isPresent:w,initial:!l.current||n?void 0:!1,custom:w?void 0:t,presenceAffectsLayout:i,mode:s,onExitComplete:w?void 0:_,children:C},x)})})};var te=o=>o;var an=te,Ze=te;var eo={skipAnimations:!1,useManualTiming:!1};function ql(o){let t=new Set,n=new Set,r=!1,i=!1,s=new WeakSet,c={delta:0,timestamp:0,isProcessing:!1};function u(f){s.has(f)&&(p.schedule(f),o()),f(c)}let p={schedule:(f,a=!1,l=!1)=>{let d=l&&r?t:n;return a&&s.add(f),d.has(f)||d.add(f),f},cancel:f=>{n.delete(f),s.delete(f)},process:f=>{if(c=f,r){i=!0;return}r=!0,[t,n]=[n,t],t.forEach(u),t.clear(),r=!1,i&&(i=!1,p.process(f))}};return p}var ri=["read","resolveKeyframes","update","preRender","render","postRender"],mh=40;function ii(o,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,c=ri.reduce((T,v)=>(T[v]=ql(s),T),{}),{read:u,resolveKeyframes:p,update:f,preRender:a,render:l,postRender:m}=c,d=()=>{let T=eo.useManualTiming?i.timestamp:performance.now();n=!1,i.delta=r?1e3/60:Math.max(Math.min(T-i.timestamp,mh),1),i.timestamp=T,i.isProcessing=!0,u.process(i),p.process(i),f.process(i),a.process(i),l.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,o(d))},h=()=>{n=!0,r=!0,i.isProcessing||o(d)};return{schedule:ri.reduce((T,v)=>{let S=c[v];return T[v]=(C,x=!1,w=!1)=>(n||h(),S.schedule(C,x,w)),T},{}),cancel:T=>{for(let v=0;v<ri.length;v++)c[ri[v]].cancel(T)},state:i,steps:c}}var{schedule:L,cancel:Je,state:pe,steps:si}=ii(typeof requestAnimationFrame<"u"?requestAnimationFrame:te,!0);import{createContext as fh}from"react";var ai=fh({strict:!1});var Xl={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},_t={};for(let o in Xl)_t[o]={isEnabled:t=>Xl[o].some(n=>!!t[n])};function Yl(o){for(let t in o)_t[t]={..._t[t],...o[t]}}var dh=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function lr(o){return o.startsWith("while")||o.startsWith("drag")&&o!=="draggable"||o.startsWith("layout")||o.startsWith("onTap")||o.startsWith("onPan")||o.startsWith("onLayout")||dh.has(o)}var Zl=o=>!lr(o);function hh(o){o&&(Zl=t=>t.startsWith("on")?!lr(t):o(t))}try{hh(Od("@emotion/is-prop-valid").default)}catch{}function Jl(o,t,n){let r={};for(let i in o)i==="values"&&typeof o.values=="object"||(Zl(i)||n===!0&&lr(i)||!t&&!lr(i)||o.draggable&&i.startsWith("onDrag"))&&(r[i]=o[i]);return r}function Ql(o){if(typeof Proxy>"u")return o;let t=new Map,n=(...r)=>o(...r);return new Proxy(n,{get:(r,i)=>i==="create"?o:(t.has(i)||t.set(i,o(i)),t.get(i))})}import{jsxs as wh,jsx as Ph}from"react/jsx-runtime";import{forwardRef as Eh,useContext as ka}from"react";import{createContext as gh}from"react";var cn=gh({});import{useContext as yh,useMemo as Th}from"react";function Mt(o){return typeof o=="string"||Array.isArray(o)}function ln(o){return o!==null&&typeof o=="object"&&typeof o.start=="function"}var ci=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ur=["initial",...ci];function En(o){return ln(o.animate)||ur.some(t=>Mt(o[t]))}function li(o){return!!(En(o)||o.variants)}function eu(o,t){if(En(o)){let{initial:n,animate:r}=o;return{initial:n===!1||Mt(n)?n:void 0,animate:Mt(r)?r:void 0}}return o.inherit!==!1?t:{}}function nu(o){let{initial:t,animate:n}=eu(o,yh(cn));return Th(()=>({initial:t,animate:n}),[tu(t),tu(n)])}function tu(o){return Array.isArray(o)?o.join(" "):o}var ou=Symbol.for("motionComponentSymbol");import{useCallback as vh}from"react";function Vt(o){return o&&typeof o=="object"&&Object.prototype.hasOwnProperty.call(o,"current")}function ru(o,t,n){return vh(r=>{r&&o.onMount&&o.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):Vt(n)&&(n.current=r))},[t])}import{useContext as pr,useRef as Ea,useInsertionEffect as bh,useEffect as Ah}from"react";var to=o=>o.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase();var Sh="framerAppearId",ui="data-"+to(Sh);var{schedule:no,cancel:Ix}=ii(queueMicrotask,!1);import{createContext as xh}from"react";var pi=xh({});function iu(o,t,n,r,i){var s,c;let{visualElement:u}=pr(cn),p=pr(ai),f=pr(sn),a=pr(Jn).reducedMotion,l=Ea(null);r=r||p.renderer,!l.current&&r&&(l.current=r(o,{visualState:t,parent:u,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:a}));let m=l.current,d=pr(pi);m&&!m.projection&&i&&(m.type==="html"||m.type==="svg")&&Ch(l.current,n,i,d);let h=Ea(!1);bh(()=>{m&&h.current&&m.update(n,f)});let g=n[ui],y=Ea(!!g&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,g))&&((c=window.MotionHasOptimisedAnimation)===null||c===void 0?void 0:c.call(window,g)));return oi(()=>{m&&(h.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),no.render(m.render),y.current&&m.animationState&&m.animationState.animateChanges())}),Ah(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{var T;(T=window.MotionHandoffMarkAsComplete)===null||T===void 0||T.call(window,g)}),y.current=!1))}),m}function Ch(o,t,n,r){let{layoutId:i,layout:s,drag:c,dragConstraints:u,layoutScroll:p,layoutRoot:f}=t;o.projection=new n(o.latestValues,t["data-framer-portal-id"]?void 0:su(o.parent)),o.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!c||u&&Vt(u),visualElement:o,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,layoutScroll:p,layoutRoot:f})}function su(o){if(o)return o.options.allowProjection!==!1?o.projection:su(o.parent)}function au({preloadedFeatures:o,createVisualElement:t,useRender:n,useVisualState:r,Component:i}){var s,c;o&&Yl(o);function u(f,a){let l,m={...ka(Jn),...f,layoutId:kh(f)},{isStatic:d}=m,h=nu(f),g=r(f,d);if(!d&&Qn){Dh(m,o);let y=Rh(m);l=y.MeasureLayout,h.visualElement=iu(i,g,m,t,y.ProjectionNode)}return wh(cn.Provider,{value:h,children:[l&&h.visualElement?Ph(l,{visualElement:h.visualElement,...m}):null,n(i,f,ru(g,h.visualElement,a),g,d,h.visualElement)]})}u.displayName=`motion.${typeof i=="string"?i:`create(${(c=(s=i.displayName)!==null&&s!==void 0?s:i.name)!==null&&c!==void 0?c:""})`}`;let p=Eh(u);return p[ou]=i,p}function kh({layoutId:o}){let t=ka(Yn).id;return t&&o!==void 0?t+"-"+o:o}function Dh(o,t){let n=ka(ai).strict}function Rh(o){let{drag:t,layout:n}=_t;if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(o)||n?.isEnabled(o)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}var cu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function oo(o){return typeof o!="string"||o.includes("-")?!1:!!(cu.indexOf(o)>-1||/[A-Z]/u.test(o))}import{useContext as mu}from"react";function lu(o){let t=[{},{}];return o?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ro(o,t,n,r){if(typeof t=="function"){let[i,s]=lu(r);t=t(n!==void 0?n:o.custom,i,s)}if(typeof t=="string"&&(t=o.variants&&o.variants[t]),typeof t=="function"){let[i,s]=lu(r);t=t(n!==void 0?n:o.custom,i,s)}return t}var mr=o=>Array.isArray(o);var uu=o=>!!(o&&typeof o=="object"&&o.mix&&o.toValue),pu=o=>mr(o)?o[o.length-1]||0:o;var z=o=>!!(o&&o.getVelocity);function io(o){let t=z(o)?o.get():o;return uu(t)?t.toValue():t}function Ih({scrapeMotionValuesFromProps:o,createRenderState:t,onUpdate:n},r,i,s){let c={latestValues:Lh(r,i,s,o),renderState:t()};return n&&(c.onMount=u=>n({props:r,current:u,...c}),c.onUpdate=u=>n(u)),c}var mi=o=>(t,n)=>{let r=mu(cn),i=mu(sn),s=()=>Ih(o,t,r,i);return n?s():Zn(s)};function Lh(o,t,n,r){let i={},s=r(o,{});for(let m in s)i[m]=io(s[m]);let{initial:c,animate:u}=o,p=En(o),f=li(o);t&&f&&!p&&o.inherit!==!1&&(c===void 0&&(c=t.initial),u===void 0&&(u=t.animate));let a=n?n.initial===!1:!1;a=a||c===!1;let l=a?u:c;if(l&&typeof l!="boolean"&&!ln(l)){let m=Array.isArray(l)?l:[l];for(let d=0;d<m.length;d++){let h=ro(o,m[d]);if(h){let{transitionEnd:g,transition:y,...T}=h;for(let v in T){let S=T[v];if(Array.isArray(S)){let C=a?S.length-1:0;S=S[C]}S!==null&&(i[v]=S)}for(let v in g)i[v]=g[v]}}}return i}var xt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],je=new Set(xt);var fu=o=>t=>typeof t=="string"&&t.startsWith(o),fi=fu("--"),_h=fu("var(--"),so=o=>_h(o)?Mh.test(o.split("/*")[0].trim()):!1,Mh=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;var di=(o,t)=>t&&typeof o=="number"?t.transform(o):o;var we=(o,t,n)=>n>t?t:n<o?o:n;var bt={test:o=>typeof o=="number",parse:parseFloat,transform:o=>o},Nt={...bt,transform:o=>we(0,1,o)},fr={...bt,default:1};var dr=o=>({test:t=>typeof t=="string"&&t.endsWith(o)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${o}`}),At=dr("deg"),He=dr("%"),E=dr("px"),du=dr("vh"),hu=dr("vw"),Da={...He,parse:o=>He.parse(o)/100,transform:o=>He.transform(o*100)};var gu={borderWidth:E,borderTopWidth:E,borderRightWidth:E,borderBottomWidth:E,borderLeftWidth:E,borderRadius:E,radius:E,borderTopLeftRadius:E,borderTopRightRadius:E,borderBottomRightRadius:E,borderBottomLeftRadius:E,width:E,maxWidth:E,height:E,maxHeight:E,top:E,right:E,bottom:E,left:E,padding:E,paddingTop:E,paddingRight:E,paddingBottom:E,paddingLeft:E,margin:E,marginTop:E,marginRight:E,marginBottom:E,marginLeft:E,backgroundPositionX:E,backgroundPositionY:E};var yu={rotate:At,rotateX:At,rotateY:At,rotateZ:At,scale:fr,scaleX:fr,scaleY:fr,scaleZ:fr,skew:At,skewX:At,skewY:At,distance:E,translateX:E,translateY:E,translateZ:E,x:E,y:E,z:E,perspective:E,transformPerspective:E,opacity:Nt,originX:Da,originY:Da,originZ:E};var Ra={...bt,transform:Math.round};var ao={...gu,...yu,zIndex:Ra,size:E,fillOpacity:Nt,strokeOpacity:Nt,numOctaves:Ra};var Vh={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Nh=xt.length;function Tu(o,t,n){let r="",i=!0;for(let s=0;s<Nh;s++){let c=xt[s],u=o[c];if(u===void 0)continue;let p=!0;if(typeof u=="number"?p=u===(c.startsWith("scale")?1:0):p=parseFloat(u)===0,!p||n){let f=di(u,ao[c]);if(!p){i=!1;let a=Vh[c]||c;r+=`${a}(${f}) `}n&&(t[c]=f)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function co(o,t,n){let{style:r,vars:i,transformOrigin:s}=o,c=!1,u=!1;for(let p in t){let f=t[p];if(je.has(p)){c=!0;continue}else if(fi(p)){i[p]=f;continue}else{let a=di(f,ao[p]);p.startsWith("origin")?(u=!0,s[p]=a):r[p]=a}}if(t.transform||(c||n?r.transform=Tu(t,o.transform,n):r.transform&&(r.transform="none")),u){let{originX:p="50%",originY:f="50%",originZ:a=0}=s;r.transformOrigin=`${p} ${f} ${a}`}}var Gh={offset:"stroke-dashoffset",array:"stroke-dasharray"},Fh={offset:"strokeDashoffset",array:"strokeDasharray"};function vu(o,t,n=1,r=0,i=!0){o.pathLength=1;let s=i?Gh:Fh;o[s.offset]=E.transform(-r);let c=E.transform(t),u=E.transform(n);o[s.array]=`${c} ${u}`}function Su(o,t,n){return typeof o=="string"?o:E.transform(t+n*o)}function xu(o,t,n){let r=Su(t,o.x,o.width),i=Su(n,o.y,o.height);return`${r} ${i}`}function lo(o,{attrX:t,attrY:n,attrScale:r,originX:i,originY:s,pathLength:c,pathSpacing:u=1,pathOffset:p=0,...f},a,l){if(co(o,f,l),a){o.style.viewBox&&(o.attrs.viewBox=o.style.viewBox);return}o.attrs=o.style,o.style={};let{attrs:m,style:d,dimensions:h}=o;m.transform&&(h&&(d.transform=m.transform),delete m.transform),h&&(i!==void 0||s!==void 0||d.transform)&&(d.transformOrigin=xu(h,i!==void 0?i:.5,s!==void 0?s:.5)),t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),r!==void 0&&(m.scale=r),c!==void 0&&vu(m,c,u,p,!1)}var uo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});var hi=()=>({...uo(),attrs:{}});var po=o=>typeof o=="string"&&o.toLowerCase()==="svg";function gi(o,{style:t,vars:n},r,i){Object.assign(o.style,t,i&&i.getProjectionStyles(r));for(let s in n)o.style.setProperty(s,n[s])}var yi=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Ti(o,t,n,r){gi(o,t,void 0,r);for(let i in t.attrs)o.setAttribute(yi.has(i)?i:to(i),t.attrs[i])}var mo={};function bu(o){Object.assign(mo,o)}function vi(o,{layout:t,layoutId:n}){return je.has(o)||o.startsWith("origin")||(t||n!==void 0)&&(!!mo[o]||o==="opacity")}function fo(o,t,n){var r;let{style:i}=o,s={};for(let c in i)(z(i[c])||t.style&&z(t.style[c])||vi(c,o)||((r=n?.getValue(c))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(s[c]=i[c]);return s}function Si(o,t,n){let r=fo(o,t,n);for(let i in o)if(z(o[i])||z(t[i])){let s=xt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=o[i]}return r}function Oh(o,t){try{t.dimensions=typeof o.getBBox=="function"?o.getBBox():o.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}var Au=["x","y","width","height","cx","cy","r"],Cu={useVisualState:mi({scrapeMotionValuesFromProps:Si,createRenderState:hi,onUpdate:({props:o,prevProps:t,current:n,renderState:r,latestValues:i})=>{if(!n)return;let s=!!o.drag;if(!s){for(let u in i)if(je.has(u)){s=!0;break}}if(!s)return;let c=!t;if(t)for(let u=0;u<Au.length;u++){let p=Au[u];o[p]!==t[p]&&(c=!0)}c&&L.read(()=>{Oh(n,r),L.render(()=>{lo(r,i,po(n.tagName),o.transformTemplate),Ti(n,r)})})}})};var wu={useVisualState:mi({scrapeMotionValuesFromProps:fo,createRenderState:uo})};import{Fragment as Wh,useMemo as jh,createElement as $h}from"react";import{useMemo as Hh}from"react";function Ia(o,t,n){for(let r in t)!z(t[r])&&!vi(r,n)&&(o[r]=t[r])}function Uh({transformTemplate:o},t){return Hh(()=>{let n=uo();return co(n,t,o),Object.assign({},n.vars,n.style)},[t])}function Kh(o,t){let n=o.style||{},r={};return Ia(r,n,o),Object.assign(r,Uh(o,t)),r}function Pu(o,t){let n={},r=Kh(o,t);return o.drag&&o.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=o.drag===!0?"none":`pan-${o.drag==="x"?"y":"x"}`),o.tabIndex===void 0&&(o.onTap||o.onTapStart||o.whileTap)&&(n.tabIndex=0),n.style=r,n}import{useMemo as Bh}from"react";function Eu(o,t,n,r){let i=Bh(()=>{let s=hi();return lo(s,t,po(r),o.transformTemplate),{...s.attrs,style:{...s.style}}},[t]);if(o.style){let s={};Ia(s,o.style,o),i.style={...s,...i.style}}return i}function ku(o=!1){return(n,r,i,{latestValues:s},c)=>{let p=(oo(n)?Eu:Pu)(r,s,c,n),f=Jl(r,typeof n=="string",o),a=n!==Wh?{...f,...p,ref:i}:{},{children:l}=r,m=jh(()=>z(l)?l.get():l,[l]);return $h(n,{...a,children:m})}}function Du(o,t){return function(r,{forwardMotionProps:i}={forwardMotionProps:!1}){let c={...oo(r)?Cu:wu,preloadedFeatures:o,useRender:ku(i),createVisualElement:t,Component:r};return au(c)}}function La(o,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==o.length)return!1;for(let r=0;r<n;r++)if(t[r]!==o[r])return!1;return!0}function un(o,t,n){let r=o.getProps();return ro(r,t,n!==void 0?n:r.custom,o)}function ho(o,t){return o?o[t]||o.default||o:void 0}var xi=new Set(["width","height","top","left","right","bottom",...xt]);var bi;function zh(){bi=void 0}var _e={now:()=>(bi===void 0&&_e.set(pe.isProcessing||eo.useManualTiming?pe.timestamp:performance.now()),bi),set:o=>{bi=o,queueMicrotask(zh)}};function go(o,t){o.indexOf(t)===-1&&o.push(t)}function pn(o,t){let n=o.indexOf(t);n>-1&&o.splice(n,1)}var mn=class{constructor(){this.subscriptions=[]}add(t){return go(this.subscriptions,t),()=>pn(this.subscriptions,t)}notify(t,n,r){let i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let s=0;s<i;s++){let c=this.subscriptions[s];c&&c(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}};function Ai(o,t){return t?o*(1e3/t):0}var Ru=30,qh=o=>!isNaN(parseFloat(o)),Iu={current:void 0},_a=class{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,i=!0)=>{let s=_e.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=_e.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=qh(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new mn);let r=this.events[t].add(n);return t==="change"?()=>{r(),L.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(let t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return Iu.current&&Iu.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let t=_e.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Ru)return 0;let n=Math.min(this.updatedAt-this.prevUpdatedAt,Ru);return Ai(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Gt(o,t){return new _a(o,t)}function Xh(o,t,n){o.hasValue(t)?o.getValue(t).set(n):o.addValue(t,Gt(n))}function Lu(o,t){let n=un(o,t),{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(let c in s){let u=pu(s[c]);Xh(o,c,u)}}function _u(o){return!!(z(o)&&o.add)}function hr(o,t){let n=o.getValue("willChange");if(_u(n))return n.add(t)}function Ci(o){return o.props[ui]}function yo(o){let t;return()=>(t===void 0&&(t=o()),t)}var Mu=yo(()=>window.ScrollTimeline!==void 0);var wi=class{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t,n){let r=this.animations.map(i=>{if(Mu()&&i.attachTimeline)return i.attachTimeline(t);if(typeof n=="function")return n(i)});return()=>{r.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}};var To=class extends wi{then(t,n){return Promise.all(this.animations).then(t).catch(n)}};var ye=o=>o*1e3,Me=o=>o/1e3;var Pi={current:!1};function fn(o){return typeof o=="function"}function Ma(o,t){o.timeline=t,o.onfinish=null}var gr=o=>Array.isArray(o)&&typeof o[0]=="number";var Vu={linearEasing:void 0};function Nu(o,t){let n=yo(o);return()=>{var r;return(r=Vu[t])!==null&&r!==void 0?r:n()}}var vo=Nu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing");var Qe=(o,t,n)=>{let r=t-o;return r===0?1:(n-o)/r};var Ei=(o,t,n=10)=>{let r="",i=Math.max(Math.round(t/n),2);for(let s=0;s<i;s++)r+=o(Qe(0,i-1,s))+", ";return`linear(${r.substring(0,r.length-2)})`};function Na(o){return!!(typeof o=="function"&&vo()||!o||typeof o=="string"&&(o in Va||vo())||gr(o)||Array.isArray(o)&&o.every(Na))}var yr=([o,t,n,r])=>`cubic-bezier(${o}, ${t}, ${n}, ${r})`,Va={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:yr([0,.65,.55,1]),circOut:yr([.55,0,1,.45]),backIn:yr([.31,.01,.66,-.59]),backOut:yr([.33,1.53,.69,.99])};function Ga(o,t){if(o)return typeof o=="function"&&vo()?Ei(o,t):gr(o)?yr(o):Array.isArray(o)?o.map(n=>Ga(n,t)||Va.easeOut):Va[o]}var Gu=(o,t,n)=>(((1-3*n+3*t)*o+(3*n-6*t))*o+3*t)*o,Yh=1e-7,Zh=12;function Jh(o,t,n,r,i){let s,c,u=0;do c=t+(n-t)/2,s=Gu(c,r,i)-o,s>0?n=c:t=c;while(Math.abs(s)>Yh&&++u<Zh);return c}function dn(o,t,n,r){if(o===t&&n===r)return te;let i=s=>Jh(s,0,1,o,n);return s=>s===0||s===1?s:Gu(i(s),t,r)}var ki=o=>t=>t<=.5?o(2*t)/2:(2-o(2*(1-t)))/2;var Di=o=>t=>1-o(1-t);var Fa=dn(.33,1.53,.69,.99),Tr=Di(Fa),Ri=ki(Tr);var Ii=o=>(o*=2)<1?.5*Tr(o):.5*(2-Math.pow(2,-10*(o-1)));var Li=o=>1-Math.sin(Math.acos(o)),_i=Di(Li),Mi=ki(Li);var Vi=o=>/^0[^.\s]+$/u.test(o);function Fu(o){return typeof o=="number"?o===0:o!==null?o==="none"||o==="0"||Vi(o):!0}var hn=o=>Math.round(o*1e5)/1e5;var So=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ou(o){return o==null}var Hu=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;var xo=(o,t)=>n=>!!(typeof n=="string"&&Hu.test(n)&&n.startsWith(o)||t&&!Ou(n)&&Object.prototype.hasOwnProperty.call(n,t)),Ni=(o,t,n)=>r=>{if(typeof r!="string")return r;let[i,s,c,u]=r.match(So);return{[o]:parseFloat(i),[t]:parseFloat(s),[n]:parseFloat(c),alpha:u!==void 0?parseFloat(u):1}};var Qh=o=>we(0,255,o),Oa={...bt,transform:o=>Math.round(Qh(o))},Ct={test:xo("rgb","red"),parse:Ni("red","green","blue"),transform:({red:o,green:t,blue:n,alpha:r=1})=>"rgba("+Oa.transform(o)+", "+Oa.transform(t)+", "+Oa.transform(n)+", "+hn(Nt.transform(r))+")"};function eg(o){let t="",n="",r="",i="";return o.length>5?(t=o.substring(1,3),n=o.substring(3,5),r=o.substring(5,7),i=o.substring(7,9)):(t=o.substring(1,2),n=o.substring(2,3),r=o.substring(3,4),i=o.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var vr={test:xo("#"),parse:eg,transform:Ct.transform};var gn={test:xo("hsl","hue"),parse:Ni("hue","saturation","lightness"),transform:({hue:o,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(o)+", "+He.transform(hn(t))+", "+He.transform(hn(n))+", "+hn(Nt.transform(r))+")"};var fe={test:o=>Ct.test(o)||vr.test(o)||gn.test(o),parse:o=>Ct.test(o)?Ct.parse(o):gn.test(o)?gn.parse(o):vr.parse(o),transform:o=>typeof o=="string"?o:o.hasOwnProperty("red")?Ct.transform(o):gn.transform(o)};var Uu=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tg(o){var t,n;return isNaN(o)&&typeof o=="string"&&(((t=o.match(So))===null||t===void 0?void 0:t.length)||0)+(((n=o.match(Uu))===null||n===void 0?void 0:n.length)||0)>0}var Bu="number",Wu="color",ng="var",og="var(",Ku="${}",rg=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function kn(o){let t=o.toString(),n=[],r={color:[],number:[],var:[]},i=[],s=0,u=t.replace(rg,p=>(fe.test(p)?(r.color.push(s),i.push(Wu),n.push(fe.parse(p))):p.startsWith(og)?(r.var.push(s),i.push(ng),n.push(p)):(r.number.push(s),i.push(Bu),n.push(parseFloat(p))),++s,Ku)).split(Ku);return{values:n,split:u,indexes:r,types:i}}function ju(o){return kn(o).values}function $u(o){let{split:t,types:n}=kn(o),r=t.length;return i=>{let s="";for(let c=0;c<r;c++)if(s+=t[c],i[c]!==void 0){let u=n[c];u===Bu?s+=hn(i[c]):u===Wu?s+=fe.transform(i[c]):s+=i[c]}return s}}var ig=o=>typeof o=="number"?0:o;function sg(o){let t=ju(o);return $u(o)(t.map(ig))}var Ue={test:tg,parse:ju,createTransformer:$u,getAnimatableNone:sg};var ag=new Set(["brightness","contrast","saturate","opacity"]);function cg(o){let[t,n]=o.slice(0,-1).split("(");if(t==="drop-shadow")return o;let[r]=n.match(So)||[];if(!r)return o;let i=n.replace(r,""),s=ag.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+i+")"}var lg=/\b([a-z-]*)\(.*?\)/gu,Sr={...Ue,getAnimatableNone:o=>{let t=o.match(lg);return t?t.map(cg).join(" "):o}};var ug={...ao,color:fe,backgroundColor:fe,outlineColor:fe,fill:fe,stroke:fe,borderColor:fe,borderTopColor:fe,borderRightColor:fe,borderBottomColor:fe,borderLeftColor:fe,filter:Sr,WebkitFilter:Sr},bo=o=>ug[o];function Gi(o,t){let n=bo(o);return n!==Sr&&(n=Ue),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var pg=new Set(["auto","none","0"]);function zu(o,t,n){let r=0,i;for(;r<o.length&&!i;){let s=o[r];typeof s=="string"&&!pg.has(s)&&kn(s).values.length&&(i=o[r]),r++}if(i&&n)for(let s of t)o[s]=Gi(n,i)}var Ha=o=>o===bt||o===E,qu=(o,t)=>parseFloat(o.split(", ")[t]),Xu=(o,t)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;let i=r.match(/^matrix3d\((.+)\)$/u);if(i)return qu(i[1],t);{let s=r.match(/^matrix\((.+)\)$/u);return s?qu(s[1],o):0}},mg=new Set(["x","y","z"]),fg=xt.filter(o=>!mg.has(o));function Yu(o){let t=[];return fg.forEach(n=>{let r=o.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}var Dn={width:({x:o},{paddingLeft:t="0",paddingRight:n="0"})=>o.max-o.min-parseFloat(t)-parseFloat(n),height:({y:o},{paddingTop:t="0",paddingBottom:n="0"})=>o.max-o.min-parseFloat(t)-parseFloat(n),top:(o,{top:t})=>parseFloat(t),left:(o,{left:t})=>parseFloat(t),bottom:({y:o},{top:t})=>parseFloat(t)+(o.max-o.min),right:({x:o},{left:t})=>parseFloat(t)+(o.max-o.min),x:Xu(4,13),y:Xu(5,14)};Dn.translateX=Dn.x;Dn.translateY=Dn.y;var Rn=new Set,Ua=!1,Ka=!1;function Zu(){if(Ka){let o=Array.from(Rn).filter(r=>r.needsMeasurement),t=new Set(o.map(r=>r.element)),n=new Map;t.forEach(r=>{let i=Yu(r);i.length&&(n.set(r,i),r.render())}),o.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();let i=n.get(r);i&&i.forEach(([s,c])=>{var u;(u=r.getValue(s))===null||u===void 0||u.set(c)})}),o.forEach(r=>r.measureEndState()),o.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Ka=!1,Ua=!1,Rn.forEach(o=>o.complete()),Rn.clear()}function Ju(){Rn.forEach(o=>{o.readKeyframes(),o.needsMeasurement&&(Ka=!0)})}function Qu(){Ju(),Zu()}var yn=class{constructor(t,n,r,i,s,c=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=s,this.isAsync=c}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Rn.add(this),Ua||(Ua=!0,L.read(Ju),L.resolveKeyframes(Zu))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;for(let s=0;s<t.length;s++)if(t[s]===null)if(s===0){let c=i?.get(),u=t[t.length-1];if(c!==void 0)t[0]=c;else if(r&&n){let p=r.readValue(n,u);p!=null&&(t[0]=p)}t[0]===void 0&&(t[0]=u),i&&c===void 0&&i.set(t[0])}else t[s]=t[s-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Rn.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Rn.delete(this))}resume(){this.isComplete||this.scheduleResolve()}};var Fi=o=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(o);var dg=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function hg(o){let t=dg.exec(o);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var gg=4;function Ba(o,t,n=1){Ze(n<=gg,`Max CSS variable fallback depth detected in property "${o}". This may indicate a circular fallback dependency.`);let[r,i]=hg(o);if(!r)return;let s=window.getComputedStyle(t).getPropertyValue(r);if(s){let c=s.trim();return Fi(c)?parseFloat(c):c}return so(i)?Ba(i,t,n+1):i}var Oi=o=>t=>t.test(o);var ep={test:o=>o==="auto",parse:o=>o};var Wa=[bt,E,He,At,hu,du,ep],ja=o=>Wa.find(Oi(o));var Ao=class extends yn{constructor(t,n,r,i,s){super(t,n,r,i,s,!0)}readKeyframes(){let{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let f=t[p];if(typeof f=="string"&&(f=f.trim(),so(f))){let a=Ba(f,n.current);a!==void 0&&(t[p]=a),p===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!xi.has(r)||t.length!==2)return;let[i,s]=t,c=ja(i),u=ja(s);if(c!==u)if(Ha(c)&&Ha(u))for(let p=0;p<t.length;p++){let f=t[p];typeof f=="string"&&(t[p]=parseFloat(f))}else this.needsMeasurement=!0}resolveNoneKeyframes(){let{unresolvedKeyframes:t,name:n}=this,r=[];for(let i=0;i<t.length;i++)Fu(t[i])&&r.push(i);r.length&&zu(t,r,n)}measureInitialState(){let{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Dn[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;let i=n[n.length-1];i!==void 0&&t.getValue(r,i).jump(i,!1)}measureEndState(){var t;let{element:n,name:r,unresolvedKeyframes:i}=this;if(!n||!n.current)return;let s=n.getValue(r);s&&s.jump(this.measuredOrigin,!1);let c=i.length-1,u=i[c];i[c]=Dn[r](n.measureViewportBox(),window.getComputedStyle(n.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([p,f])=>{n.getValue(p).set(f)}),this.resolveNoneKeyframes()}};var $a=(o,t)=>t==="zIndex"?!1:!!(typeof o=="number"||Array.isArray(o)||typeof o=="string"&&(Ue.test(o)||o==="0")&&!o.startsWith("url("));function yg(o){let t=o[0];if(o.length===1)return!0;for(let n=0;n<o.length;n++)if(o[n]!==t)return!0}function tp(o,t,n,r){let i=o[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;let s=o[o.length-1],c=$a(i,t),u=$a(s,t);return an(c===u,`You are trying to animate ${t} from "${i}" to "${s}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${s} via the \`style\` property.`),!c||!u?!1:yg(o)||(n==="spring"||fn(n))&&r}var Tg=o=>o!==null;function Tn(o,{repeat:t,repeatType:n="loop"},r){let i=o.filter(Tg),s=t&&n!=="loop"&&t%2===1?0:i.length-1;return!s||r===void 0?i[s]:r}var vg=40,Co=class{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:c="loop",...u}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=_e.now(),this.options={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:s,repeatType:c,...u},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>vg?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&Qu(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=_e.now(),this.hasAttemptedResolve=!0;let{name:r,type:i,velocity:s,delay:c,onComplete:u,onUpdate:p,isGenerator:f}=this.options;if(!f&&!tp(t,r,i,s))if(Pi.current||!c){p&&p(Tn(t,this.options,n)),u&&u(),this.resolveFinishedPromise();return}else this.options.duration=0;let a=this.initPlayback(t,n);a!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...a},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}};function wo(o){let t=0,n=50,r=o.next(t);for(;!r.done&&t<2e4;)t+=n,r=o.next(t);return t>=2e4?1/0:t}var G=(o,t,n)=>o+(t-o)*n;function za(o,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+(t-o)*6*n:n<1/2?t:n<2/3?o+(t-o)*(2/3-n)*6:o}function np({hue:o,saturation:t,lightness:n,alpha:r}){o/=360,t/=100,n/=100;let i=0,s=0,c=0;if(!t)i=s=c=n;else{let u=n<.5?n*(1+t):n+t-n*t,p=2*n-u;i=za(p,u,o+1/3),s=za(p,u,o),c=za(p,u,o-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(c*255),alpha:r}}function Po(o,t){return n=>n>0?t:o}var qa=(o,t,n)=>{let r=o*o,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Sg=[vr,Ct,gn],xg=o=>Sg.find(t=>t.test(o));function op(o){let t=xg(o);if(an(!!t,`'${o}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(o);return t===gn&&(n=np(n)),n}var Xa=(o,t)=>{let n=op(o),r=op(t);if(!n||!r)return Po(o,t);let i={...n};return s=>(i.red=qa(n.red,r.red,s),i.green=qa(n.green,r.green,s),i.blue=qa(n.blue,r.blue,s),i.alpha=G(n.alpha,r.alpha,s),Ct.transform(i))};var bg=(o,t)=>n=>t(o(n)),wt=(...o)=>o.reduce(bg);var Hi=new Set(["none","hidden"]);function rp(o,t){return Hi.has(o)?n=>n<=0?o:t:n=>n>=1?t:o}function Ag(o,t){return n=>G(o,t,n)}function Ui(o){return typeof o=="number"?Ag:typeof o=="string"?so(o)?Po:fe.test(o)?Xa:Pg:Array.isArray(o)?ip:typeof o=="object"?fe.test(o)?Xa:Cg:Po}function ip(o,t){let n=[...o],r=n.length,i=o.map((s,c)=>Ui(s)(s,t[c]));return s=>{for(let c=0;c<r;c++)n[c]=i[c](s);return n}}function Cg(o,t){let n={...o,...t},r={};for(let i in n)o[i]!==void 0&&t[i]!==void 0&&(r[i]=Ui(o[i])(o[i],t[i]));return i=>{for(let s in r)n[s]=r[s](i);return n}}function wg(o,t){var n;let r=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){let c=t.types[s],u=o.indexes[c][i[c]],p=(n=o.values[u])!==null&&n!==void 0?n:0;r[s]=p,i[c]++}return r}var Pg=(o,t)=>{let n=Ue.createTransformer(t),r=kn(o),i=kn(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Hi.has(o)&&!i.values.length||Hi.has(t)&&!r.values.length?rp(o,t):wt(ip(wg(r,i),i.values),n):(an(!0,`Complex values '${o}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Po(o,t))};function Ki(o,t,n){return typeof o=="number"&&typeof t=="number"&&typeof n=="number"?G(o,t,n):Ui(o)(o,t)}var Eg=5;function Bi(o,t,n){let r=Math.max(t-Eg,0);return Ai(n-o(r),t-r)}var Q={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};var Ya=.001;function sp({duration:o=Q.duration,bounce:t=Q.bounce,velocity:n=Q.velocity,mass:r=Q.mass}){let i,s;an(o<=ye(Q.maxDuration),"Spring duration must be 10 seconds or less");let c=1-t;c=we(Q.minDamping,Q.maxDamping,c),o=we(Q.minDuration,Q.maxDuration,Me(o)),c<1?(i=f=>{let a=f*c,l=a*o,m=a-n,d=Wi(f,c),h=Math.exp(-l);return Ya-m/d*h},s=f=>{let l=f*c*o,m=l*n+n,d=Math.pow(c,2)*Math.pow(f,2)*o,h=Math.exp(-l),g=Wi(Math.pow(f,2),c);return(-i(f)+Ya>0?-1:1)*((m-d)*h)/g}):(i=f=>{let a=Math.exp(-f*o),l=(f-n)*o+1;return-Ya+a*l},s=f=>{let a=Math.exp(-f*o),l=(n-f)*(o*o);return a*l});let u=5/o,p=Dg(i,s,u);if(o=ye(o),isNaN(p))return{stiffness:Q.stiffness,damping:Q.damping,duration:o};{let f=Math.pow(p,2)*r;return{stiffness:f,damping:c*2*Math.sqrt(r*f),duration:o}}}var kg=12;function Dg(o,t,n){let r=n;for(let i=1;i<kg;i++)r=r-o(r)/t(r);return r}function Wi(o,t){return o*Math.sqrt(1-t*t)}var Rg=["duration","bounce"],Ig=["stiffness","damping","mass"];function ap(o,t){return t.some(n=>o[n]!==void 0)}function Lg(o){let t={velocity:Q.velocity,stiffness:Q.stiffness,damping:Q.damping,mass:Q.mass,isResolvedFromDuration:!1,...o};if(!ap(o,Ig)&&ap(o,Rg))if(o.visualDuration){let n=o.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*we(.05,1,1-(o.bounce||0))*Math.sqrt(i);t={...t,mass:Q.mass,stiffness:i,damping:s}}else{let n=sp(o);t={...t,...n,mass:Q.mass},t.isResolvedFromDuration=!0}return t}function Eo(o=Q.visualDuration,t=Q.bounce){let n=typeof o!="object"?{visualDuration:o,keyframes:[0,1],bounce:t}:o,{restSpeed:r,restDelta:i}=n,s=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],u={done:!1,value:s},{stiffness:p,damping:f,mass:a,duration:l,velocity:m,isResolvedFromDuration:d}=Lg({...n,velocity:-Me(n.velocity||0)}),h=m||0,g=f/(2*Math.sqrt(p*a)),y=c-s,T=Me(Math.sqrt(p/a)),v=Math.abs(y)<5;r||(r=v?Q.restSpeed.granular:Q.restSpeed.default),i||(i=v?Q.restDelta.granular:Q.restDelta.default);let S;if(g<1){let x=Wi(T,g);S=w=>{let _=Math.exp(-g*T*w);return c-_*((h+g*T*y)/x*Math.sin(x*w)+y*Math.cos(x*w))}}else if(g===1)S=x=>c-Math.exp(-T*x)*(y+(h+T*y)*x);else{let x=T*Math.sqrt(g*g-1);S=w=>{let _=Math.exp(-g*T*w),A=Math.min(x*w,300);return c-_*((h+g*T*y)*Math.sinh(A)+x*y*Math.cosh(A))/x}}let C={calculatedDuration:d&&l||null,next:x=>{let w=S(x);if(d)u.done=x>=l;else{let _=0;g<1&&(_=x===0?ye(h):Bi(S,x,w));let A=Math.abs(_)<=r,P=Math.abs(c-w)<=i;u.done=A&&P}return u.value=u.done?c:w,u},toString:()=>{let x=Math.min(wo(C),2e4),w=Ei(_=>C.next(x*_).value,x,30);return x+"ms "+w}};return C}function Ja({keyframes:o,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:c,min:u,max:p,restDelta:f=.5,restSpeed:a}){let l=o[0],m={done:!1,value:l},d=A=>u!==void 0&&A<u||p!==void 0&&A>p,h=A=>u===void 0?p:p===void 0||Math.abs(u-A)<Math.abs(p-A)?u:p,g=n*t,y=l+g,T=c===void 0?y:c(y);T!==y&&(g=T-l);let v=A=>-g*Math.exp(-A/r),S=A=>T+v(A),C=A=>{let P=v(A),V=S(A);m.done=Math.abs(P)<=f,m.value=m.done?T:V},x,w,_=A=>{d(m.value)&&(x=A,w=Eo({keyframes:[m.value,h(m.value)],velocity:Bi(S,A,m.value),damping:i,stiffness:s,restDelta:f,restSpeed:a}))};return _(0),{calculatedDuration:null,next:A=>{let P=!1;return!w&&x===void 0&&(P=!0,C(A),_(A)),x!==void 0&&A>=x?w.next(A-x):(!P&&C(A),m)}}}var cp=dn(.42,0,1,1),lp=dn(0,0,.58,1),ji=dn(.42,0,.58,1);var $i=o=>Array.isArray(o)&&typeof o[0]!="number";var up={linear:te,easeIn:cp,easeInOut:ji,easeOut:lp,circIn:Li,circInOut:Mi,circOut:_i,backIn:Tr,backInOut:Ri,backOut:Fa,anticipate:Ii},Qa=o=>{if(gr(o)){Ze(o.length===4,"Cubic bezier arrays must contain four numerical values.");let[t,n,r,i]=o;return dn(t,n,r,i)}else if(typeof o=="string")return Ze(up[o]!==void 0,`Invalid easing type '${o}'`),up[o];return o};function _g(o,t,n){let r=[],i=n||Ki,s=o.length-1;for(let c=0;c<s;c++){let u=i(o[c],o[c+1]);if(t){let p=Array.isArray(t)?t[c]||te:t;u=wt(p,u)}r.push(u)}return r}function pp(o,t,{clamp:n=!0,ease:r,mixer:i}={}){let s=o.length;if(Ze(s===t.length,"Both input and output ranges must be the same length"),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];let c=o[0]===o[1];o[0]>o[s-1]&&(o=[...o].reverse(),t=[...t].reverse());let u=_g(t,r,i),p=u.length,f=a=>{if(c&&a<o[0])return t[0];let l=0;if(p>1)for(;l<o.length-2&&!(a<o[l+1]);l++);let m=Qe(o[l],o[l+1],a);return u[l](m)};return n?a=>f(we(o[0],o[s-1],a)):f}function zi(o,t){let n=o[o.length-1];for(let r=1;r<=t;r++){let i=Qe(0,t,r);o.push(G(n,1,i))}}function qi(o){let t=[0];return zi(t,o.length-1),t}function mp(o,t){return o.map(n=>n*t)}function Mg(o,t){return o.map(()=>t||ji).splice(0,o.length-1)}function xr({duration:o=300,keyframes:t,times:n,ease:r="easeInOut"}){let i=$i(r)?r.map(Qa):Qa(r),s={done:!1,value:t[0]},c=mp(n&&n.length===t.length?n:qi(t),o),u=pp(c,t,{ease:Array.isArray(i)?i:Mg(t,i)});return{calculatedDuration:o,next:p=>(s.value=u(p),s.done=p>=o,s)}}var fp=o=>{let t=({timestamp:n})=>o(n);return{start:()=>L.update(t,!0),stop:()=>Je(t),now:()=>pe.isProcessing?pe.timestamp:_e.now()}};var Vg={decay:Ja,inertia:Ja,tween:xr,keyframes:xr,spring:Eo},Ng=o=>o/100,In=class extends Co{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();let{onStop:p}=this.options;p&&p()};let{name:n,motionValue:r,element:i,keyframes:s}=this.options,c=i?.KeyframeResolver||yn,u=(p,f)=>this.onKeyframesResolved(p,f);this.resolver=new c(s,u,n,r,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){let{type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:c=0}=this.options,u=fn(n)?n:Vg[n]||xr,p,f;u!==xr&&typeof t[0]!="number"&&(p=wt(Ng,Ki(t[0],t[1])),t=[0,100]);let a=u({...this.options,keyframes:t});s==="mirror"&&(f=u({...this.options,keyframes:[...t].reverse(),velocity:-c})),a.calculatedDuration===null&&(a.calculatedDuration=wo(a));let{calculatedDuration:l}=a,m=l+i,d=m*(r+1)-i;return{generator:a,mirroredGenerator:f,mapPercentToKeyframes:p,calculatedDuration:l,resolvedDuration:m,totalDuration:d}}onPostResolved(){let{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){let{resolved:r}=this;if(!r){let{keyframes:A}=this.options;return{done:!0,value:A[A.length-1]}}let{finalKeyframe:i,generator:s,mirroredGenerator:c,mapPercentToKeyframes:u,keyframes:p,calculatedDuration:f,totalDuration:a,resolvedDuration:l}=r;if(this.startTime===null)return s.next(0);let{delay:m,repeat:d,repeatType:h,repeatDelay:g,onUpdate:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;let T=this.currentTime-m*(this.speed>=0?1:-1),v=this.speed>=0?T<0:T>a;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let S=this.currentTime,C=s;if(d){let A=Math.min(this.currentTime,a)/l,P=Math.floor(A),V=A%1;!V&&A>=1&&(V=1),V===1&&P--,P=Math.min(P,d+1),!!(P%2)&&(h==="reverse"?(V=1-V,g&&(V-=g/l)):h==="mirror"&&(C=c)),S=we(0,1,V)*l}let x=v?{done:!1,value:p[0]}:C.next(S);u&&(x.value=u(x.value));let{done:w}=x;!v&&f!==null&&(w=this.speed>=0?this.currentTime>=a:this.currentTime<=0);let _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&w);return _&&i!==void 0&&(x.value=Tn(p,this.options,i)),y&&y(x.value),_&&this.finish(),x}get duration(){let{resolved:t}=this;return t?Me(t.calculatedDuration):0}get time(){return Me(this.currentTime)}set time(t){t=ye(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){let n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Me(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;let{driver:t=fp,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),n&&n();let i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";let{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}};var dp=new Set(["opacity","clipPath","filter","transform"]);function hp(o,t,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:c="loop",ease:u="easeInOut",times:p}={}){let f={[t]:n};p&&(f.offset=p);let a=Ga(u,i);return Array.isArray(a)&&(f.easing=a),o.animate(f,{delay:r,duration:i,easing:Array.isArray(a)?"linear":a,fill:"both",iterations:s+1,direction:c==="reverse"?"alternate":"normal"})}var gp=yo(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));var Xi=10,Gg=2e4;function Fg(o){return fn(o.type)||o.type==="spring"||!Na(o.ease)}function Og(o,t){let n=new In({...t,keyframes:o,repeat:0,delay:0,isGenerator:!0}),r={done:!1,value:o[0]},i=[],s=0;for(;!r.done&&s<Gg;)r=n.sample(s),i.push(r.value),s+=Xi;return{times:void 0,keyframes:i,duration:s-Xi,ease:"linear"}}var yp={anticipate:Ii,backInOut:Ri,circInOut:Mi};function Hg(o){return o in yp}var br=class extends Co{constructor(t){super(t);let{name:n,motionValue:r,element:i,keyframes:s}=this.options;this.resolver=new Ao(s,(c,u)=>this.onKeyframesResolved(c,u),n,r,i),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:r=300,times:i,ease:s,type:c,motionValue:u,name:p,startTime:f}=this.options;if(!u.owner||!u.owner.current)return!1;if(typeof s=="string"&&vo()&&Hg(s)&&(s=yp[s]),Fg(this.options)){let{onComplete:l,onUpdate:m,motionValue:d,element:h,...g}=this.options,y=Og(t,g);t=y.keyframes,t.length===1&&(t[1]=t[0]),r=y.duration,i=y.times,s=y.ease,c="keyframes"}let a=hp(u.owner.current,p,t,{...this.options,duration:r,times:i,ease:s});return a.startTime=f??this.calcStartTime(),this.pendingTimeline?(Ma(a,this.pendingTimeline),this.pendingTimeline=void 0):a.onfinish=()=>{let{onComplete:l}=this.options;u.set(Tn(t,this.options,n)),l&&l(),this.cancel(),this.resolveFinishedPromise()},{animation:a,duration:r,times:i,type:c,ease:s,keyframes:t}}get duration(){let{resolved:t}=this;if(!t)return 0;let{duration:n}=t;return Me(n)}get time(){let{resolved:t}=this;if(!t)return 0;let{animation:n}=t;return Me(n.currentTime||0)}set time(t){let{resolved:n}=this;if(!n)return;let{animation:r}=n;r.currentTime=ye(t)}get speed(){let{resolved:t}=this;if(!t)return 1;let{animation:n}=t;return n.playbackRate}set speed(t){let{resolved:n}=this;if(!n)return;let{animation:r}=n;r.playbackRate=t}get state(){let{resolved:t}=this;if(!t)return"idle";let{animation:n}=t;return n.playState}get startTime(){let{resolved:t}=this;if(!t)return null;let{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{let{resolved:n}=this;if(!n)return te;let{animation:r}=n;Ma(r,t)}return te}play(){if(this.isStopped)return;let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();let{resolved:t}=this;if(!t)return;let{animation:n,keyframes:r,duration:i,type:s,ease:c,times:u}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){let{motionValue:f,onUpdate:a,onComplete:l,element:m,...d}=this.options,h=new In({...d,keyframes:r,duration:i,type:s,ease:c,times:u,isGenerator:!0}),g=ye(this.time);f.setWithVelocity(h.sample(g-Xi).value,h.sample(g).value,Xi)}let{onStop:p}=this.options;p&&p(),this.cancel()}complete(){let{resolved:t}=this;t&&t.animation.finish()}cancel(){let{resolved:t}=this;t&&t.animation.cancel()}static supports(t){let{motionValue:n,name:r,repeatDelay:i,repeatType:s,damping:c,type:u}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;let{onUpdate:p,transformTemplate:f}=n.owner.getProps();return gp()&&r&&dp.has(r)&&!p&&!f&&!i&&s!=="mirror"&&c!==0&&u!=="inertia"}};var Ug={type:"spring",stiffness:500,damping:25,restSpeed:10},Kg=o=>({type:"spring",stiffness:550,damping:o===0?2*Math.sqrt(550):30,restSpeed:10}),Bg={type:"keyframes",duration:.8},Wg={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Tp=(o,{keyframes:t})=>t.length>2?Bg:je.has(o)?o.startsWith("scale")?Kg(t[1]):Ug:Wg;function vp({when:o,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:c,repeatDelay:u,from:p,elapsed:f,...a}){return!!Object.keys(a).length}var ko=(o,t,n,r={},i,s)=>c=>{let u=ho(r,o)||{},p=u.delay||r.delay||0,{elapsed:f=0}=r;f=f-ye(p);let a={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-f,onUpdate:m=>{t.set(m),u.onUpdate&&u.onUpdate(m)},onComplete:()=>{c(),u.onComplete&&u.onComplete()},name:o,motionValue:t,element:s?void 0:i};vp(u)||(a={...a,...Tp(o,a)}),a.duration&&(a.duration=ye(a.duration)),a.repeatDelay&&(a.repeatDelay=ye(a.repeatDelay)),a.from!==void 0&&(a.keyframes[0]=a.from);let l=!1;if((a.type===!1||a.duration===0&&!a.repeatDelay)&&(a.duration=0,a.delay===0&&(l=!0)),(Pi.current||eo.skipAnimations)&&(l=!0,a.duration=0,a.delay=0),l&&!s&&t.get()!==void 0){let m=Tn(a.keyframes,u);if(m!==void 0)return L.update(()=>{a.onUpdate(m),a.onComplete()}),new To([])}return!s&&br.supports(a)?new br(a):new In(a)};function jg({protectedKeys:o,needsAnimating:t},n){let r=o.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Do(o,t,{delay:n=0,transitionOverride:r,type:i}={}){var s;let{transition:c=o.getDefaultTransition(),transitionEnd:u,...p}=t;r&&(c=r);let f=[],a=i&&o.animationState&&o.animationState.getState()[i];for(let l in p){let m=o.getValue(l,(s=o.latestValues[l])!==null&&s!==void 0?s:null),d=p[l];if(d===void 0||a&&jg(a,l))continue;let h={delay:n,...ho(c||{},l)},g=!1;if(window.MotionHandoffAnimation){let T=Ci(o);if(T){let v=window.MotionHandoffAnimation(T,l,L);v!==null&&(h.startTime=v,g=!0)}}hr(o,l),m.start(ko(l,m,d,o.shouldReduceMotion&&xi.has(l)?{type:!1}:h,o,g));let y=m.animation;y&&f.push(y)}return u&&Promise.all(f).then(()=>{L.update(()=>{u&&Lu(o,u)})}),f}function Yi(o,t,n={}){var r;let i=un(o,t,n.type==="exit"?(r=o.presenceContext)===null||r===void 0?void 0:r.custom:void 0),{transition:s=o.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);let c=i?()=>Promise.all(Do(o,i,n)):()=>Promise.resolve(),u=o.variantChildren&&o.variantChildren.size?(f=0)=>{let{delayChildren:a=0,staggerChildren:l,staggerDirection:m}=s;return $g(o,t,a+f,l,m,n)}:()=>Promise.resolve(),{when:p}=s;if(p){let[f,a]=p==="beforeChildren"?[c,u]:[u,c];return f().then(()=>a())}else return Promise.all([c(),u(n.delay)])}function $g(o,t,n=0,r=0,i=1,s){let c=[],u=(o.variantChildren.size-1)*r,p=i===1?(f=0)=>f*r:(f=0)=>u-f*r;return Array.from(o.variantChildren).sort(zg).forEach((f,a)=>{f.notify("AnimationStart",t),c.push(Yi(f,t,{...s,delay:n+p(a)}).then(()=>f.notify("AnimationComplete",t)))}),Promise.all(c)}function zg(o,t){return o.sortNodePosition(t)}function Sp(o,t,n={}){o.notify("AnimationStart",t);let r;if(Array.isArray(t)){let i=t.map(s=>Yi(o,s,n));r=Promise.all(i)}else if(typeof t=="string")r=Yi(o,t,n);else{let i=typeof t=="function"?un(o,t,n.custom):t;r=Promise.all(Do(o,i,n))}return r.then(()=>{o.notify("AnimationComplete",t)})}var qg=ur.length;function ec(o){if(!o)return;if(!o.isControllingVariants){let n=o.parent?ec(o.parent)||{}:{};return o.props.initial!==void 0&&(n.initial=o.props.initial),n}let t={};for(let n=0;n<qg;n++){let r=ur[n],i=o.props[r];(Mt(i)||i===!1)&&(t[r]=i)}return t}var Xg=[...ci].reverse(),Yg=ci.length;function Zg(o){return t=>Promise.all(t.map(({animation:n,options:r})=>Sp(o,n,r)))}function bp(o){let t=Zg(o),n=xp(),r=!0,i=p=>(f,a)=>{var l;let m=un(o,a,p==="exit"?(l=o.presenceContext)===null||l===void 0?void 0:l.custom:void 0);if(m){let{transition:d,transitionEnd:h,...g}=m;f={...f,...g,...h}}return f};function s(p){t=p(o)}function c(p){let{props:f}=o,a=ec(o.parent)||{},l=[],m=new Set,d={},h=1/0;for(let y=0;y<Yg;y++){let T=Xg[y],v=n[T],S=f[T]!==void 0?f[T]:a[T],C=Mt(S),x=T===p?v.isActive:null;x===!1&&(h=y);let w=S===a[T]&&S!==f[T]&&C;if(w&&r&&o.manuallyAnimateOnMount&&(w=!1),v.protectedKeys={...d},!v.isActive&&x===null||!S&&!v.prevProp||ln(S)||typeof S=="boolean")continue;let _=Jg(v.prevProp,S),A=_||T===p&&v.isActive&&!w&&C||y>h&&C,P=!1,V=Array.isArray(S)?S:[S],J=V.reduce(i(T),{});x===!1&&(J={});let{prevResolvedValues:I={}}=v,W={...I,...J},se=O=>{A=!0,m.has(O)&&(P=!0,m.delete(O)),v.needsAnimating[O]=!0;let F=o.getValue(O);F&&(F.liveStyle=!1)};for(let O in W){let F=J[O],ae=I[O];if(d.hasOwnProperty(O))continue;let H=!1;mr(F)&&mr(ae)?H=!La(F,ae):H=F!==ae,H?F!=null?se(O):m.add(O):F!==void 0&&m.has(O)?se(O):v.protectedKeys[O]=!0}v.prevProp=S,v.prevResolvedValues=J,v.isActive&&(d={...d,...J}),r&&o.blockInitialAnimation&&(A=!1),A&&(!(w&&_)||P)&&l.push(...V.map(O=>({animation:O,options:{type:T}})))}if(m.size){let y={};m.forEach(T=>{let v=o.getBaseTarget(T),S=o.getValue(T);S&&(S.liveStyle=!0),y[T]=v??null}),l.push({animation:y})}let g=!!l.length;return r&&(f.initial===!1||f.initial===f.animate)&&!o.manuallyAnimateOnMount&&(g=!1),r=!1,g?t(l):Promise.resolve()}function u(p,f){var a;if(n[p].isActive===f)return Promise.resolve();(a=o.variantChildren)===null||a===void 0||a.forEach(m=>{var d;return(d=m.animationState)===null||d===void 0?void 0:d.setActive(p,f)}),n[p].isActive=f;let l=c(p);for(let m in n)n[m].protectedKeys={};return l}return{animateChanges:c,setActive:u,setAnimateFunction:s,getState:()=>n,reset:()=>{n=xp(),r=!0}}}function Jg(o,t){return typeof t=="string"?t!==o:Array.isArray(t)?!La(t,o):!1}function Ln(o=!1){return{isActive:o,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function xp(){return{animate:Ln(!0),whileInView:Ln(),whileHover:Ln(),whileTap:Ln(),whileDrag:Ln(),whileFocus:Ln(),exit:Ln()}}var Te=class{constructor(t){this.isMounted=!1,this.node=t}update(){}};var Zi=class extends Te{constructor(t){super(t),t.animationState||(t.animationState=bp(t))}updateAnimationControlsSubscription(){let{animate:t}=this.node.getProps();ln(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}};var Qg=0,Ji=class extends Te{constructor(){super(...arguments),this.id=Qg++}update(){if(!this.node.presenceContext)return;let{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;let i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>n(this.id))}mount(){let{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}};var Ap={animation:{Feature:Zi},exit:{Feature:Ji}};var st={x:!1,y:!1};function Qi(){return st.x||st.y}function Cp(o){return o==="x"||o==="y"?st[o]?null:(st[o]=!0,()=>{st[o]=!1}):st.x||st.y?null:(st.x=st.y=!0,()=>{st.x=st.y=!1})}var Ro=o=>o.pointerType==="mouse"?typeof o.button!="number"||o.button<=0:o.isPrimary!==!1;function Ft(o,t,n,r={passive:!0}){return o.addEventListener(t,n,r),()=>o.removeEventListener(t,n)}function Ot(o){return{point:{x:o.pageX,y:o.pageY}}}var wp=o=>t=>Ro(t)&&o(t,Ot(t));function vn(o,t,n,r){return Ft(o,t,wp(n),r)}var Pp=(o,t)=>Math.abs(o-t);function Ep(o,t){let n=Pp(o.x,t.x),r=Pp(o.y,t.y);return Math.sqrt(n**2+r**2)}var Io=class{constructor(t,n,{transformPagePoint:r,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let l=nc(this.lastMoveEventInfo,this.history),m=this.startEvent!==null,d=Ep(l.offset,{x:0,y:0})>=3;if(!m&&!d)return;let{point:h}=l,{timestamp:g}=pe;this.history.push({...h,timestamp:g});let{onStart:y,onMove:T}=this.handlers;m||(y&&y(this.lastMoveEvent,l),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,l)},this.handlePointerMove=(l,m)=>{this.lastMoveEvent=l,this.lastMoveEventInfo=tc(m,this.transformPagePoint),L.update(this.updatePoint,!0)},this.handlePointerUp=(l,m)=>{this.end();let{onEnd:d,onSessionEnd:h,resumeAnimation:g}=this.handlers;if(this.dragSnapToOrigin&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let y=nc(l.type==="pointercancel"?this.lastMoveEventInfo:tc(m,this.transformPagePoint),this.history);this.startEvent&&d&&d(l,y),h&&h(l,y)},!Ro(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.contextWindow=i||window;let c=Ot(t),u=tc(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=pe;this.history=[{...p,timestamp:f}];let{onSessionStart:a}=n;a&&a(t,nc(u,this.history)),this.removeListeners=wt(vn(this.contextWindow,"pointermove",this.handlePointerMove),vn(this.contextWindow,"pointerup",this.handlePointerUp),vn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Je(this.updatePoint)}};function tc(o,t){return t?{point:t(o.point)}:o}function kp(o,t){return{x:o.x-t.x,y:o.y-t.y}}function nc({point:o},t){return{point:o,delta:kp(o,Dp(t)),offset:kp(o,ey(t)),velocity:ty(t,.1)}}function ey(o){return o[0]}function Dp(o){return o[o.length-1]}function ty(o,t){if(o.length<2)return{x:0,y:0};let n=o.length-1,r=null,i=Dp(o);for(;n>=0&&(r=o[n],!(i.timestamp-r.timestamp>ye(t)));)n--;if(!r)return{x:0,y:0};let s=Me(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};let c={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}var _p=1e-4,ny=1-_p,oy=1+_p,Mp=.01,ry=0-Mp,iy=0+Mp;function Pe(o){return o.max-o.min}function Vp(o,t,n){return Math.abs(o-t)<=n}function Rp(o,t,n,r=.5){o.origin=r,o.originPoint=G(t.min,t.max,o.origin),o.scale=Pe(n)/Pe(t),o.translate=G(n.min,n.max,o.origin)-o.originPoint,(o.scale>=ny&&o.scale<=oy||isNaN(o.scale))&&(o.scale=1),(o.translate>=ry&&o.translate<=iy||isNaN(o.translate))&&(o.translate=0)}function Lo(o,t,n,r){Rp(o.x,t.x,n.x,r?r.originX:void 0),Rp(o.y,t.y,n.y,r?r.originY:void 0)}function Ip(o,t,n){o.min=n.min+t.min,o.max=o.min+Pe(t)}function Np(o,t,n){Ip(o.x,t.x,n.x),Ip(o.y,t.y,n.y)}function Lp(o,t,n){o.min=t.min-n.min,o.max=o.min+Pe(t)}function _o(o,t,n){Lp(o.x,t.x,n.x),Lp(o.y,t.y,n.y)}function Up(o,{min:t,max:n},r){return t!==void 0&&o<t?o=r?G(t,o,r.min):Math.max(o,t):n!==void 0&&o>n&&(o=r?G(n,o,r.max):Math.min(o,n)),o}function Gp(o,t,n){return{min:t!==void 0?o.min+t:void 0,max:n!==void 0?o.max+n-(o.max-o.min):void 0}}function Kp(o,{top:t,left:n,bottom:r,right:i}){return{x:Gp(o.x,n,i),y:Gp(o.y,t,r)}}function Fp(o,t){let n=t.min-o.min,r=t.max-o.max;return t.max-t.min<o.max-o.min&&([n,r]=[r,n]),{min:n,max:r}}function Bp(o,t){return{x:Fp(o.x,t.x),y:Fp(o.y,t.y)}}function Wp(o,t){let n=.5,r=Pe(o),i=Pe(t);return i>r?n=Qe(t.min,t.max-r,o.min):r>i&&(n=Qe(o.min,o.max-i,t.min)),we(0,1,n)}function jp(o,t){let n={};return t.min!==void 0&&(n.min=t.min-o.min),t.max!==void 0&&(n.max=t.max-o.min),n}var es=.35;function $p(o=es){return o===!1?o=0:o===!0&&(o=es),{x:Op(o,"left","right"),y:Op(o,"top","bottom")}}function Op(o,t,n){return{min:Hp(o,t),max:Hp(o,n)}}function Hp(o,t){return typeof o=="number"?o:o[t]||0}var zp=()=>({translate:0,scale:1,origin:0,originPoint:0}),_n=()=>({x:zp(),y:zp()}),qp=()=>({min:0,max:0}),Y=()=>({x:qp(),y:qp()});function $e(o){return[o("x"),o("y")]}function ts({top:o,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:o,max:r}}}function Xp({x:o,y:t}){return{top:t.min,right:o.max,bottom:t.max,left:o.min}}function Yp(o,t){if(!t)return o;let n=t({x:o.left,y:o.top}),r=t({x:o.right,y:o.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function oc(o){return o===void 0||o===1}function ns({scale:o,scaleX:t,scaleY:n}){return!oc(o)||!oc(t)||!oc(n)}function Ht(o){return ns(o)||rc(o)||o.z||o.rotate||o.rotateX||o.rotateY||o.skewX||o.skewY}function rc(o){return Zp(o.x)||Zp(o.y)}function Zp(o){return o&&o!=="0%"}function Ar(o,t,n){let r=o-n,i=t*r;return n+i}function Jp(o,t,n,r,i){return i!==void 0&&(o=Ar(o,i,r)),Ar(o,n,r)+t}function ic(o,t=0,n=1,r,i){o.min=Jp(o.min,t,n,r,i),o.max=Jp(o.max,t,n,r,i)}function sc(o,{x:t,y:n}){ic(o.x,t.translate,t.scale,t.originPoint),ic(o.y,n.translate,n.scale,n.originPoint)}var Qp=.999999999999,em=1.0000000000001;function nm(o,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let s,c;for(let u=0;u<i;u++){s=n[u],c=s.projectionDelta;let{visualElement:p}=s.options;p&&p.props.style&&p.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&Mn(o,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),c&&(t.x*=c.x.scale,t.y*=c.y.scale,sc(o,c)),r&&Ht(s.latestValues)&&Mn(o,s.latestValues))}t.x<em&&t.x>Qp&&(t.x=1),t.y<em&&t.y>Qp&&(t.y=1)}function Sn(o,t){o.min=o.min+t,o.max=o.max+t}function tm(o,t,n,r,i=.5){let s=G(o.min,o.max,i);ic(o,t,n,s,r)}function Mn(o,t){tm(o.x,t.x,t.scaleX,t.scale,t.originX),tm(o.y,t.y,t.scaleY,t.scale,t.originY)}function ac(o,t){return ts(Yp(o.getBoundingClientRect(),t))}function om(o,t,n){let r=ac(o,n),{scroll:i}=t;return i&&(Sn(r.x,i.offset.x),Sn(r.y,i.offset.y)),r}var os=({current:o})=>o?o.ownerDocument.defaultView:null;var sy=new WeakMap,is=class{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Y(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=a=>{let{dragSnapToOrigin:l}=this.getProps();l?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ot(a).point)},s=(a,l)=>{let{drag:m,dragPropagation:d,onDragStart:h}=this.getProps();if(m&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Cp(m),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),$e(y=>{let T=this.getAxisMotionValue(y).get()||0;if(He.test(T)){let{projection:v}=this.visualElement;if(v&&v.layout){let S=v.layout.layoutBox[y];S&&(T=Pe(S)*(parseFloat(T)/100))}}this.originPoint[y]=T}),h&&L.postRender(()=>h(a,l)),hr(this.visualElement,"transform");let{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},c=(a,l)=>{let{dragPropagation:m,dragDirectionLock:d,onDirectionLock:h,onDrag:g}=this.getProps();if(!m&&!this.openDragLock)return;let{offset:y}=l;if(d&&this.currentDirection===null){this.currentDirection=ay(y),this.currentDirection!==null&&h&&h(this.currentDirection);return}this.updateAxis("x",l.point,y),this.updateAxis("y",l.point,y),this.visualElement.render(),g&&g(a,l)},u=(a,l)=>this.stop(a,l),p=()=>$e(a=>{var l;return this.getAnimationState(a)==="paused"&&((l=this.getAxisMotionValue(a).animation)===null||l===void 0?void 0:l.play())}),{dragSnapToOrigin:f}=this.getProps();this.panSession=new Io(t,{onSessionStart:i,onStart:s,onMove:c,onSessionEnd:u,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,contextWindow:os(this.visualElement)})}stop(t,n){let r=this.isDragging;if(this.cancel(),!r)return;let{velocity:i}=n;this.startAnimation(i);let{onDragEnd:s}=this.getProps();s&&L.postRender(()=>s(t,n))}cancel(){this.isDragging=!1;let{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){let{drag:i}=this.getProps();if(!r||!rs(t,i,this.currentDirection))return;let s=this.getAxisMotionValue(t),c=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(c=Up(c,this.constraints[t],this.elastic[t])),s.set(c)}resolveConstraints(){var t;let{dragConstraints:n,dragElastic:r}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,s=this.constraints;n&&Vt(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Kp(i.layoutBox,n):this.constraints=!1,this.elastic=$p(r),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&$e(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=jp(i.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){let{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Vt(t))return!1;let r=t.current;Ze(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");let{projection:i}=this.visualElement;if(!i||!i.layout)return!1;let s=om(r,i.root,this.visualElement.getTransformPagePoint()),c=Bp(i.layout.layoutBox,s);if(n){let u=n(Xp(c));this.hasMutatedConstraints=!!u,u&&(c=ts(u))}return c}startAnimation(t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:c,onDragTransitionEnd:u}=this.getProps(),p=this.constraints||{},f=$e(a=>{if(!rs(a,n,this.currentDirection))return;let l=p&&p[a]||{};c&&(l={min:0,max:0});let m=i?200:1e6,d=i?40:1e7,h={type:"inertia",velocity:r?t[a]:0,bounceStiffness:m,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(a,h)});return Promise.all(f).then(u)}startAxisValueAnimation(t,n){let r=this.getAxisMotionValue(t);return hr(this.visualElement,t),r.start(ko(t,r,0,n,this.visualElement,!1))}stopAnimation(){$e(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){$e(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){let n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){$e(n=>{let{drag:r}=this.getProps();if(!rs(n,r,this.currentDirection))return;let{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){let{min:c,max:u}=i.layout.layoutBox[n];s.set(t[n]-G(c,u,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Vt(n)||!r||!this.constraints)return;this.stopAnimation();let i={x:0,y:0};$e(c=>{let u=this.getAxisMotionValue(c);if(u&&this.constraints!==!1){let p=u.get();i[c]=Wp({min:p,max:p},this.constraints[c])}});let{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),$e(c=>{if(!rs(c,t,null))return;let u=this.getAxisMotionValue(c),{min:p,max:f}=this.constraints[c];u.set(G(p,f,i[c]))})}addListeners(){if(!this.visualElement.current)return;sy.set(this.visualElement,this);let t=this.visualElement.current,n=vn(t,"pointerdown",p=>{let{drag:f,dragListener:a=!0}=this.getProps();f&&a&&this.start(p)}),r=()=>{let{dragConstraints:p}=this.getProps();Vt(p)&&p.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),L.read(r);let c=Ft(window,"resize",()=>this.scalePositionWithinConstraints()),u=i.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f})=>{this.isDragging&&f&&($e(a=>{let l=this.getAxisMotionValue(a);l&&(this.originPoint[a]+=p[a].translate,l.set(l.get()+p[a].translate))}),this.visualElement.render())});return()=>{c(),n(),s(),u&&u()}}getProps(){let t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:c=es,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:c,dragMomentum:u}}};function rs(o,t,n){return(t===!0||t===o)&&(n===null||n===o)}function ay(o,t=10){let n=null;return Math.abs(o.y)>t?n="y":Math.abs(o.x)>t&&(n="x"),n}var ss=class extends Te{constructor(t){super(t),this.removeGroupControls=te,this.removeListeners=te,this.controls=new is(t)}mount(){let{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||te}unmount(){this.removeGroupControls(),this.removeListeners()}};var rm=o=>(t,n)=>{o&&L.postRender(()=>o(t,n))},as=class extends Te{constructor(){super(...arguments),this.removePointerDownListener=te}onPointerDown(t){this.session=new Io(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:os(this.node)})}createPanHandlers(){let{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:rm(t),onStart:rm(n),onMove:r,onEnd:(s,c)=>{delete this.session,i&&L.postRender(()=>i(s,c))}}}mount(){this.removePointerDownListener=vn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}};import{jsx as cy}from"react/jsx-runtime";import{useContext as am,Component as ly}from"react";var Mo={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function im(o,t){return t.max===t.min?0:o/(t.max-t.min)*100}var Vo={correct:(o,t)=>{if(!t.target)return o;if(typeof o=="string")if(E.test(o))o=parseFloat(o);else return o;let n=im(o,t.target.x),r=im(o,t.target.y);return`${n}% ${r}%`}};var sm={correct:(o,{treeScale:t,projectionDelta:n})=>{let r=o,i=Ue.parse(o);if(i.length>5)return r;let s=Ue.createTransformer(o),c=typeof i[0]!="number"?1:0,u=n.x.scale*t.x,p=n.y.scale*t.y;i[0+c]/=u,i[1+c]/=p;let f=G(u,p,.5);return typeof i[2+c]=="number"&&(i[2+c]/=f),typeof i[3+c]=="number"&&(i[3+c]/=f),s(i)}};var cc=class extends ly{componentDidMount(){let{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=t;bu(uy),s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Mo.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){let{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,c=r.projection;return c&&(c.isPresent=s,i||t.layoutDependency!==n||n===void 0?c.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?c.promote():c.relegate()||L.postRender(()=>{let u=c.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),no.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){let{safeToRemove:t}=this.props;t&&t()}render(){return null}};function cs(o){let[t,n]=ni(),r=am(Yn);return cy(cc,{...o,layoutGroup:r,switchLayoutGroup:am(pi),isPresent:t,safeToRemove:n})}var uy={borderRadius:{...Vo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Vo,borderTopRightRadius:Vo,borderBottomLeftRadius:Vo,borderBottomRightRadius:Vo,boxShadow:sm};function ls(o,t,n){let r=z(o)?o:Gt(o);return r.start(ko("",r,t,n)),r.animation}function us(o){return o instanceof SVGElement&&o.tagName!=="svg"}var cm=(o,t)=>o.depth-t.depth;var ps=class{constructor(){this.children=[],this.isDirty=!1}add(t){go(this.children,t),this.isDirty=!0}remove(t){pn(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(cm),this.isDirty=!1,this.children.forEach(t)}};function lm(o,t){let n=_e.now(),r=({timestamp:i})=>{let s=i-n;s>=t&&(Je(r),o(s-t))};return L.read(r,!0),()=>Je(r)}var fm=["TopLeft","TopRight","BottomLeft","BottomRight"],py=fm.length,um=o=>typeof o=="string"?parseFloat(o):o,pm=o=>typeof o=="number"||E.test(o);function dm(o,t,n,r,i,s){i?(o.opacity=G(0,n.opacity!==void 0?n.opacity:1,my(r)),o.opacityExit=G(t.opacity!==void 0?t.opacity:1,0,fy(r))):s&&(o.opacity=G(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let c=0;c<py;c++){let u=`border${fm[c]}Radius`,p=mm(t,u),f=mm(n,u);if(p===void 0&&f===void 0)continue;p||(p=0),f||(f=0),p===0||f===0||pm(p)===pm(f)?(o[u]=Math.max(G(um(p),um(f),r),0),(He.test(f)||He.test(p))&&(o[u]+="%")):o[u]=f}(t.rotate||n.rotate)&&(o.rotate=G(t.rotate||0,n.rotate||0,r))}function mm(o,t){return o[t]!==void 0?o[t]:o.borderRadius}var my=hm(0,.5,_i),fy=hm(.5,.95,te);function hm(o,t,n){return r=>r<o?0:r>t?1:n(Qe(o,t,r))}function gm(o,t){o.min=t.min,o.max=t.max}function et(o,t){gm(o.x,t.x),gm(o.y,t.y)}function lc(o,t){o.translate=t.translate,o.scale=t.scale,o.originPoint=t.originPoint,o.origin=t.origin}function ym(o,t,n,r,i){return o-=t,o=Ar(o,1/n,r),i!==void 0&&(o=Ar(o,1/i,r)),o}function dy(o,t=0,n=1,r=.5,i,s=o,c=o){if(He.test(t)&&(t=parseFloat(t),t=G(c.min,c.max,t/100)-c.min),typeof t!="number")return;let u=G(s.min,s.max,r);o===s&&(u-=t),o.min=ym(o.min,t,n,u,i),o.max=ym(o.max,t,n,u,i)}function Tm(o,t,[n,r,i],s,c){dy(o,t[n],t[r],t[i],t.scale,s,c)}var hy=["x","scaleX","originX"],gy=["y","scaleY","originY"];function uc(o,t,n,r){Tm(o.x,t,hy,n?n.x:void 0,r?r.x:void 0),Tm(o.y,t,gy,n?n.y:void 0,r?r.y:void 0)}function vm(o){return o.translate===0&&o.scale===1}function pc(o){return vm(o.x)&&vm(o.y)}function Sm(o,t){return o.min===t.min&&o.max===t.max}function bm(o,t){return Sm(o.x,t.x)&&Sm(o.y,t.y)}function xm(o,t){return Math.round(o.min)===Math.round(t.min)&&Math.round(o.max)===Math.round(t.max)}function mc(o,t){return xm(o.x,t.x)&&xm(o.y,t.y)}function fc(o){return Pe(o.x)/Pe(o.y)}function dc(o,t){return o.translate===t.translate&&o.scale===t.scale&&o.originPoint===t.originPoint}var ms=class{constructor(){this.members=[]}add(t){go(this.members,t),t.scheduleRender()}remove(t){if(pn(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){let n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){let n=this.members.findIndex(i=>t===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){let s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(t,n){let r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);let{crossfade:i}=t.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{let{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}};function Am(o,t,n){let r="",i=o.x.translate/t.x,s=o.y.translate/t.y,c=n?.z||0;if((i||s||c)&&(r=`translate3d(${i}px, ${s}px, ${c}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:f,rotate:a,rotateX:l,rotateY:m,skewX:d,skewY:h}=n;f&&(r=`perspective(${f}px) ${r}`),a&&(r+=`rotate(${a}deg) `),l&&(r+=`rotateX(${l}deg) `),m&&(r+=`rotateY(${m}deg) `),d&&(r+=`skewX(${d}deg) `),h&&(r+=`skewY(${h}deg) `)}let u=o.x.scale*t.x,p=o.y.scale*t.y;return(u!==1||p!==1)&&(r+=`scale(${u}, ${p})`),r||"none"}var Vn={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},Cr=typeof window<"u"&&window.MotionDebug!==void 0,hc=["","X","Y","Z"],yy={visibility:"hidden"},Cm=1e3,Ty=0;function gc(o,t,n,r){let{latestValues:i}=t;i[o]&&(n[o]=i[o],t.setStaticValue(o,0),r&&(r[o]=0))}function Lm(o){if(o.hasCheckedOptimisedAppear=!0,o.root===o)return;let{visualElement:t}=o.options;if(!t)return;let n=Ci(t);if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:i,layoutId:s}=o.options;window.MotionCancelOptimisedAnimation(n,"transform",L,!(i||s))}let{parent:r}=o;r&&!r.hasCheckedOptimisedAppear&&Lm(r)}function fs({attachResizeListener:o,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(c={},u=t?.()){this.id=Ty++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Cr&&(Vn.totalNodes=Vn.resolvedTargetDeltas=Vn.recalculatedProjection=0),this.nodes.forEach(xy),this.nodes.forEach(Py),this.nodes.forEach(Ey),this.nodes.forEach(by),Cr&&window.MotionDebug.record(Vn)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let p=0;p<this.path.length;p++)this.path[p].shouldResetTransform=!0;this.root===this&&(this.nodes=new ps)}addEventListener(c,u){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new mn),this.eventHandlers.get(c).add(u)}notifyListeners(c,...u){let p=this.eventHandlers.get(c);p&&p.notify(...u)}hasListeners(c){return this.eventHandlers.has(c)}mount(c,u=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=us(c),this.instance=c;let{layoutId:p,layout:f,visualElement:a}=this.options;if(a&&!a.current&&a.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),u&&(f||p)&&(this.isLayoutDirty=!0),o){let l,m=()=>this.root.updateBlockedByResize=!1;o(c,()=>{this.root.updateBlockedByResize=!0,l&&l(),l=lm(m,250),Mo.hasAnimatedSinceResize&&(Mo.hasAnimatedSinceResize=!1,this.nodes.forEach(Pm))})}p&&this.root.registerSharedNode(p,this),this.options.animate!==!1&&a&&(p||f)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:m,hasRelativeTargetChanged:d,layout:h})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let g=this.options.transition||a.getDefaultTransition()||Ly,{onLayoutAnimationStart:y,onLayoutAnimationComplete:T}=a.getProps(),v=!this.targetLayout||!mc(this.targetLayout,h)||d,S=!m&&d;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||S||m&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(l,S);let C={...ho(g,"layout"),onPlay:y,onComplete:T};(a.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C)}else m||Pm(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=h})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Je(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ky),this.animationId++)}getTransformTemplate(){let{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Lm(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){let l=this.path[a];l.shouldResetTransform=!0,l.updateScroll("snapshot"),l.options.layoutRoot&&l.willUpdate(!1)}let{layoutId:u,layout:p}=this.options;if(u===void 0&&!p)return;let f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(wm);return}this.isUpdating||this.nodes.forEach(Cy),this.isUpdating=!1,this.nodes.forEach(wy),this.nodes.forEach(vy),this.nodes.forEach(Sy),this.clearAllSnapshots();let u=_e.now();pe.delta=we(0,1e3/60,u-pe.timestamp),pe.timestamp=u,pe.isProcessing=!0,si.update.process(pe),si.preRender.process(pe),si.render.process(pe),pe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,no.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Ay),this.sharedNodes.forEach(Dy)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,L.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){L.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let p=0;p<this.path.length;p++)this.path[p].updateScroll();let c=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Y(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(u=!1),u){let p=r(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:p,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:p}}}resetTransform(){if(!i)return;let c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!pc(this.projectionDelta),p=this.getTransformTemplate(),f=p?p(this.latestValues,""):void 0,a=f!==this.prevTransformTemplateValue;c&&(u||Ht(this.latestValues)||a)&&(i(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){let u=this.measurePageBox(),p=this.removeElementScroll(u);return c&&(p=this.removeTransform(p)),_y(p),{animationId:this.root.animationId,measuredBox:u,layoutBox:p,latestValues:{},source:this.id}}measurePageBox(){var c;let{visualElement:u}=this.options;if(!u)return Y();let p=u.measureViewportBox();if(!(((c=this.scroll)===null||c===void 0?void 0:c.wasRoot)||this.path.some(My))){let{scroll:a}=this.root;a&&(Sn(p.x,a.offset.x),Sn(p.y,a.offset.y))}return p}removeElementScroll(c){var u;let p=Y();if(et(p,c),!((u=this.scroll)===null||u===void 0)&&u.wasRoot)return p;for(let f=0;f<this.path.length;f++){let a=this.path[f],{scroll:l,options:m}=a;a!==this.root&&l&&m.layoutScroll&&(l.wasRoot&&et(p,c),Sn(p.x,l.offset.x),Sn(p.y,l.offset.y))}return p}applyTransform(c,u=!1){let p=Y();et(p,c);for(let f=0;f<this.path.length;f++){let a=this.path[f];!u&&a.options.layoutScroll&&a.scroll&&a!==a.root&&Mn(p,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),Ht(a.latestValues)&&Mn(p,a.latestValues)}return Ht(this.latestValues)&&Mn(p,this.latestValues),p}removeTransform(c){let u=Y();et(u,c);for(let p=0;p<this.path.length;p++){let f=this.path[p];if(!f.instance||!Ht(f.latestValues))continue;ns(f.latestValues)&&f.updateSnapshot();let a=Y(),l=f.measurePageBox();et(a,l),uc(u,f.latestValues,f.snapshot?f.snapshot.layoutBox:void 0,a)}return Ht(this.latestValues)&&uc(u,this.latestValues),u}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==pe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){var u;let p=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=p.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=p.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=p.isSharedProjectionDirty);let f=!!this.resumingFrom||this!==p;if(!(c||f&&this.isSharedProjectionDirty||this.isProjectionDirty||!((u=this.parent)===null||u===void 0)&&u.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:l,layoutId:m}=this.options;if(!(!this.layout||!(l||m))){if(this.resolvedRelativeTargetAt=pe.timestamp,!this.targetDelta&&!this.relativeTarget){let d=this.getClosestProjectingParent();d&&d.layout&&this.animationProgress!==1?(this.relativeParent=d,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),_o(this.relativeTargetOrigin,this.layout.layoutBox,d.layout.layoutBox),et(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Y(),this.targetWithTransforms=Y()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Np(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):et(this.target,this.layout.layoutBox),sc(this.target,this.targetDelta)):et(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;let d=this.getClosestProjectingParent();d&&!!d.resumingFrom==!!this.resumingFrom&&!d.options.layoutScroll&&d.target&&this.animationProgress!==1?(this.relativeParent=d,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),_o(this.relativeTargetOrigin,this.target,d.target),et(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}Cr&&Vn.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||ns(this.parent.latestValues)||rc(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var c;let u=this.getLead(),p=!!this.resumingFrom||this!==u,f=!0;if((this.isProjectionDirty||!((c=this.parent)===null||c===void 0)&&c.isProjectionDirty)&&(f=!1),p&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(f=!1),this.resolvedRelativeTargetAt===pe.timestamp&&(f=!1),f)return;let{layout:a,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(a||l))return;et(this.layoutCorrected,this.layout.layoutBox);let m=this.treeScale.x,d=this.treeScale.y;nm(this.layoutCorrected,this.treeScale,this.path,p),u.layout&&!u.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(u.target=u.layout.layoutBox,u.targetWithTransforms=Y());let{target:h}=u;if(!h){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(lc(this.prevProjectionDelta.x,this.projectionDelta.x),lc(this.prevProjectionDelta.y,this.projectionDelta.y)),Lo(this.projectionDelta,this.layoutCorrected,h,this.latestValues),(this.treeScale.x!==m||this.treeScale.y!==d||!dc(this.projectionDelta.x,this.prevProjectionDelta.x)||!dc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",h)),Cr&&Vn.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){var u;if((u=this.options.visualElement)===null||u===void 0||u.scheduleRender(),c){let p=this.getStack();p&&p.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=_n(),this.projectionDelta=_n(),this.projectionDeltaWithTransform=_n()}setAnimationOrigin(c,u=!1){let p=this.snapshot,f=p?p.latestValues:{},a={...this.latestValues},l=_n();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;let m=Y(),d=p?p.source:void 0,h=this.layout?this.layout.source:void 0,g=d!==h,y=this.getStack(),T=!y||y.members.length<=1,v=!!(g&&!T&&this.options.crossfade===!0&&!this.path.some(Iy));this.animationProgress=0;let S;this.mixTargetDelta=C=>{let x=C/1e3;Em(l.x,c.x,x),Em(l.y,c.y,x),this.setTargetDelta(l),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(_o(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Ry(this.relativeTarget,this.relativeTargetOrigin,m,x),S&&bm(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=Y()),et(S,this.relativeTarget)),g&&(this.animationValues=a,dm(a,f,this.latestValues,x,v,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=x},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Je(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=L.update(()=>{Mo.hasAnimatedSinceResize=!0,this.currentAnimation=ls(0,Cm,{...c,onUpdate:u=>{this.mixTargetDelta(u),c.onUpdate&&c.onUpdate(u)},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Cm),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let c=this.getLead(),{targetWithTransforms:u,target:p,layout:f,latestValues:a}=c;if(!(!u||!p||!f)){if(this!==c&&this.layout&&f&&_m(this.options.animationType,this.layout.layoutBox,f.layoutBox)){p=this.target||Y();let l=Pe(this.layout.layoutBox.x);p.x.min=c.target.x.min,p.x.max=p.x.min+l;let m=Pe(this.layout.layoutBox.y);p.y.min=c.target.y.min,p.y.max=p.y.min+m}et(u,p),Mn(u,a),Lo(this.projectionDeltaWithTransform,this.layoutCorrected,u,a)}}registerSharedNode(c,u){this.sharedNodes.has(c)||this.sharedNodes.set(c,new ms),this.sharedNodes.get(c).add(u);let f=u.options.initialPromotionConfig;u.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(u):void 0})}isLead(){let c=this.getStack();return c?c.lead===this:!0}getLead(){var c;let{layoutId:u}=this.options;return u?((c=this.getStack())===null||c===void 0?void 0:c.lead)||this:this}getPrevLead(){var c;let{layoutId:u}=this.options;return u?(c=this.getStack())===null||c===void 0?void 0:c.prevLead:void 0}getStack(){let{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:u,preserveFollowOpacity:p}={}){let f=this.getStack();f&&f.promote(this,p),c&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){let c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){let{visualElement:c}=this.options;if(!c)return;let u=!1,{latestValues:p}=c;if((p.z||p.rotate||p.rotateX||p.rotateY||p.rotateZ||p.skewX||p.skewY)&&(u=!0),!u)return;let f={};p.z&&gc("z",c,f,this.animationValues);for(let a=0;a<hc.length;a++)gc(`rotate${hc[a]}`,c,f,this.animationValues),gc(`skew${hc[a]}`,c,f,this.animationValues);c.render();for(let a in f)c.setStaticValue(a,f[a]),this.animationValues&&(this.animationValues[a]=f[a]);c.scheduleRender()}getProjectionStyles(c){var u,p;if(!this.instance||this.isSVG)return;if(!this.isVisible)return yy;let f={visibility:""},a=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,f.opacity="",f.pointerEvents=io(c?.pointerEvents)||"",f.transform=a?a(this.latestValues,""):"none",f;let l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){let g={};return this.options.layoutId&&(g.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,g.pointerEvents=io(c?.pointerEvents)||""),this.hasProjected&&!Ht(this.latestValues)&&(g.transform=a?a({},""):"none",this.hasProjected=!1),g}let m=l.animationValues||l.latestValues;this.applyTransformsToTarget(),f.transform=Am(this.projectionDeltaWithTransform,this.treeScale,m),a&&(f.transform=a(m,f.transform));let{x:d,y:h}=this.projectionDelta;f.transformOrigin=`${d.origin*100}% ${h.origin*100}% 0`,l.animationValues?f.opacity=l===this?(p=(u=m.opacity)!==null&&u!==void 0?u:this.latestValues.opacity)!==null&&p!==void 0?p:1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:f.opacity=l===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(let g in mo){if(m[g]===void 0)continue;let{correct:y,applyTo:T}=mo[g],v=f.transform==="none"?m[g]:y(m[g],l);if(T){let S=T.length;for(let C=0;C<S;C++)f[T[C]]=v}else f[g]=v}return this.options.layoutId&&(f.pointerEvents=l===this?io(c?.pointerEvents)||"":"none"),f}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>{var u;return(u=c.currentAnimation)===null||u===void 0?void 0:u.stop()}),this.root.nodes.forEach(wm),this.root.sharedNodes.clear()}}}function vy(o){o.updateLayout()}function Sy(o){var t;let n=((t=o.resumeFrom)===null||t===void 0?void 0:t.snapshot)||o.snapshot;if(o.isLead()&&o.layout&&n&&o.hasListeners("didUpdate")){let{layoutBox:r,measuredBox:i}=o.layout,{animationType:s}=o.options,c=n.source!==o.layout.source;s==="size"?$e(l=>{let m=c?n.measuredBox[l]:n.layoutBox[l],d=Pe(m);m.min=r[l].min,m.max=m.min+d}):_m(s,n.layoutBox,r)&&$e(l=>{let m=c?n.measuredBox[l]:n.layoutBox[l],d=Pe(r[l]);m.max=m.min+d,o.relativeTarget&&!o.currentAnimation&&(o.isProjectionDirty=!0,o.relativeTarget[l].max=o.relativeTarget[l].min+d)});let u=_n();Lo(u,r,n.layoutBox);let p=_n();c?Lo(p,o.applyTransform(i,!0),n.measuredBox):Lo(p,r,n.layoutBox);let f=!pc(u),a=!1;if(!o.resumeFrom){let l=o.getClosestProjectingParent();if(l&&!l.resumeFrom){let{snapshot:m,layout:d}=l;if(m&&d){let h=Y();_o(h,n.layoutBox,m.layoutBox);let g=Y();_o(g,r,d.layoutBox),mc(h,g)||(a=!0),l.options.layoutRoot&&(o.relativeTarget=g,o.relativeTargetOrigin=h,o.relativeParent=l)}}}o.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:p,layoutDelta:u,hasLayoutChanged:f,hasRelativeTargetChanged:a})}else if(o.isLead()){let{onExitComplete:r}=o.options;r&&r()}o.options.transition=void 0}function xy(o){Cr&&Vn.totalNodes++,o.parent&&(o.isProjecting()||(o.isProjectionDirty=o.parent.isProjectionDirty),o.isSharedProjectionDirty||(o.isSharedProjectionDirty=!!(o.isProjectionDirty||o.parent.isProjectionDirty||o.parent.isSharedProjectionDirty)),o.isTransformDirty||(o.isTransformDirty=o.parent.isTransformDirty))}function by(o){o.isProjectionDirty=o.isSharedProjectionDirty=o.isTransformDirty=!1}function Ay(o){o.clearSnapshot()}function wm(o){o.clearMeasurements()}function Cy(o){o.isLayoutDirty=!1}function wy(o){let{visualElement:t}=o.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),o.resetTransform()}function Pm(o){o.finishAnimation(),o.targetDelta=o.relativeTarget=o.target=void 0,o.isProjectionDirty=!0}function Py(o){o.resolveTargetDelta()}function Ey(o){o.calcProjection()}function ky(o){o.resetSkewAndRotation()}function Dy(o){o.removeLeadSnapshot()}function Em(o,t,n){o.translate=G(t.translate,0,n),o.scale=G(t.scale,1,n),o.origin=t.origin,o.originPoint=t.originPoint}function km(o,t,n,r){o.min=G(t.min,n.min,r),o.max=G(t.max,n.max,r)}function Ry(o,t,n,r){km(o.x,t.x,n.x,r),km(o.y,t.y,n.y,r)}function Iy(o){return o.animationValues&&o.animationValues.opacityExit!==void 0}var Ly={duration:.45,ease:[.4,0,.1,1]},Dm=o=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(o),Rm=Dm("applewebkit/")&&!Dm("chrome/")?Math.round:te;function Im(o){o.min=Rm(o.min),o.max=Rm(o.max)}function _y(o){Im(o.x),Im(o.y)}function _m(o,t,n){return o==="position"||o==="preserve-aspect"&&!Vp(fc(t),fc(n),.2)}function My(o){var t;return o!==o.root&&((t=o.scroll)===null||t===void 0?void 0:t.wasRoot)}var Mm=fs({attachResizeListener:(o,t)=>Ft(o,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0});var yc={current:void 0},ds=fs({measureScroll:o=>({x:o.scrollLeft,y:o.scrollTop}),defaultParent:()=>{if(!yc.current){let o=new Mm({});o.mount(window),o.setOptions({layoutScroll:!0}),yc.current=o}return yc.current},resetTransform:(o,t)=>{o.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:o=>window.getComputedStyle(o).position==="fixed"});var Vm={pan:{Feature:as},drag:{Feature:ss,ProjectionNode:ds,MeasureLayout:cs}};function hs(o,t,n){var r;if(o instanceof Element)return[o];if(typeof o=="string"){let i=document;t&&(i=t.current);let s=(r=n?.[o])!==null&&r!==void 0?r:i.querySelectorAll(o);return s?Array.from(s):[]}return Array.from(o)}function gs(o,t){let n=hs(o),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function Nm(o){return t=>{t.pointerType==="touch"||Qi()||o(t)}}function Gm(o,t,n={}){let[r,i,s]=gs(o,n),c=Nm(u=>{let{target:p}=u,f=t(u);if(typeof f!="function"||!p)return;let a=Nm(l=>{f(l),p.removeEventListener("pointerleave",a)});p.addEventListener("pointerleave",a,i)});return r.forEach(u=>{u.addEventListener("pointerenter",c,i)}),s}function Fm(o,t,n){let{props:r}=o;o.animationState&&r.whileHover&&o.animationState.setActive("whileHover",n==="Start");let i="onHover"+n,s=r[i];s&&L.postRender(()=>s(t,Ot(t)))}var ys=class extends Te{mount(){let{current:t}=this.node;t&&(this.unmount=Gm(t,n=>(Fm(this.node,n,"Start"),r=>Fm(this.node,r,"End"))))}unmount(){}};var Ts=class extends Te{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=wt(Ft(this.node.current,"focus",()=>this.onFocus()),Ft(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};var Tc=(o,t)=>t?o===t?!0:Tc(o,t.parentElement):!1;var Vy=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Om(o){return Vy.has(o.tagName)||o.tabIndex!==-1}var Nn=new WeakSet;function Hm(o){return t=>{t.key==="Enter"&&o(t)}}function vc(o,t){o.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var Um=(o,t)=>{let n=o.currentTarget;if(!n)return;let r=Hm(()=>{if(Nn.has(n))return;vc(n,"down");let i=Hm(()=>{vc(n,"up")}),s=()=>vc(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function Km(o){return Ro(o)&&!Qi()}function Bm(o,t,n={}){let[r,i,s]=gs(o,n),c=u=>{let p=u.currentTarget;if(!Km(u)||Nn.has(p))return;Nn.add(p);let f=t(u),a=(d,h)=>{window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",m),!(!Km(d)||!Nn.has(p))&&(Nn.delete(p),typeof f=="function"&&f(d,{success:h}))},l=d=>{a(d,n.useGlobalTarget||Tc(p,d.target))},m=d=>{a(d,!1)};window.addEventListener("pointerup",l,i),window.addEventListener("pointercancel",m,i)};return r.forEach(u=>{!Om(u)&&u.getAttribute("tabindex")===null&&(u.tabIndex=0),(n.useGlobalTarget?window:u).addEventListener("pointerdown",c,i),u.addEventListener("focus",f=>Um(f,i),i)}),s}function Wm(o,t,n){let{props:r}=o;o.animationState&&r.whileTap&&o.animationState.setActive("whileTap",n==="Start");let i="onTap"+(n==="End"?"":n),s=r[i];s&&L.postRender(()=>s(t,Ot(t)))}var vs=class extends Te{mount(){let{current:t}=this.node;t&&(this.unmount=Bm(t,n=>(Wm(this.node,n,"Start"),(r,{success:i})=>Wm(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}};var xc=new WeakMap,Sc=new WeakMap,Ny=o=>{let t=xc.get(o.target);t&&t(o)},Gy=o=>{o.forEach(Ny)};function Fy({root:o,...t}){let n=o||document;Sc.has(n)||Sc.set(n,{});let r=Sc.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Gy,{root:o,...t})),r[i]}function jm(o,t,n){let r=Fy(t);return xc.set(o,n),r.observe(o),()=>{xc.delete(o),r.unobserve(o)}}var Oy={some:0,all:1},Ss=class extends Te{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=t,c={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:Oy[i]},u=p=>{let{isIntersecting:f}=p;if(this.isInView===f||(this.isInView=f,s&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);let{onViewportEnter:a,onViewportLeave:l}=this.node.getProps(),m=f?a:l;m&&m(p)};return jm(this.node.current,c,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;let{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Hy(t,n))&&this.startObserver()}unmount(){}};function Hy({viewport:o={}},{viewport:t={}}={}){return n=>o[n]!==t[n]}var $m={inView:{Feature:Ss},tap:{Feature:vs},focus:{Feature:Ts},hover:{Feature:ys}};var zm={layout:{ProjectionNode:ds,MeasureLayout:cs}};import{Fragment as By}from"react";var wr={current:null},xs={current:!1};function qm(){if(xs.current=!0,!!Qn)if(window.matchMedia){let o=window.matchMedia("(prefers-reduced-motion)"),t=()=>wr.current=o.matches;o.addListener(t),t()}else wr.current=!1}var Uy=[...Wa,fe,Ue],Xm=o=>Uy.find(Oi(o));var Ut=new WeakMap;function Ym(o,t,n){for(let r in t){let i=t[r],s=n[r];if(z(i))o.addValue(r,i);else if(z(s))o.addValue(r,Gt(i,{owner:o}));else if(s!==i)if(o.hasValue(r)){let c=o.getValue(r);c.liveStyle===!0?c.jump(i):c.hasAnimated||c.set(i)}else{let c=o.getStaticValue(r);o.addValue(r,Gt(c!==void 0?c:i,{owner:o}))}}for(let r in n)t[r]===void 0&&o.removeValue(r);return t}var Zm=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],No=class{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:c},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=yn,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let d=_e.now();this.renderScheduledAt<d&&(this.renderScheduledAt=d,L.render(this.render,!1,!0))};let{latestValues:p,renderState:f,onUpdate:a}=c;this.onUpdate=a,this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=f,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=u,this.blockInitialAnimation=!!s,this.isControllingVariants=En(n),this.isVariantNode=li(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);let{willChange:l,...m}=this.scrapeMotionValuesFromProps(n,{},this);for(let d in m){let h=m[d];p[d]!==void 0&&z(h)&&h.set(p[d],!1)}}mount(t){this.current=t,Ut.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),xs.current||qm(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:wr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Ut.delete(this.current),this.projection&&this.projection.unmount(),Je(this.notifyUpdate),Je(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(let t in this.events)this.events[t].clear();for(let t in this.features){let n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();let r=je.has(t),i=n.on("change",u=>{this.latestValues[t]=u,this.props.onUpdate&&L.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),s=n.on("renderRequest",this.scheduleRender),c;window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),s(),c&&c(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in _t){let n=_t[t];if(!n)continue;let{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){let s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Y()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Zm.length;r++){let i=Zm[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);let s="on"+i,c=t[s];c&&(this.propEventSubscriptions[i]=this.on(i,c))}this.prevMotionValues=Ym(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){let n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){let r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);let n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Gt(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){var r;let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(r=this.getBaseTargetFromProps(this.props,t))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(Fi(i)||Vi(i))?i=parseFloat(i):!Xm(i)&&Ue.test(n)&&(i=Gi(t,n)),this.setBaseTarget(t,z(i)?i.get():i)),z(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;let{initial:r}=this.props,i;if(typeof r=="string"||typeof r=="object"){let c=ro(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);c&&(i=c[t])}if(r&&i!==void 0)return i;let s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!z(s)?s:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new mn),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}};var Go=class extends No{constructor(){super(...arguments),this.KeyframeResolver=Ao}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:t}=this.props;z(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}};function Ky(o){return window.getComputedStyle(o)}var Fo=class extends Go{constructor(){super(...arguments),this.type="html",this.renderInstance=gi}readValueFromInstance(t,n){if(je.has(n)){let r=bo(n);return r&&r.default||0}else{let r=Ky(t),i=(fi(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return ac(t,n)}build(t,n,r){co(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return fo(t,n,r)}};var Oo=class extends Go{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Y}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(je.has(n)){let r=bo(n);return r&&r.default||0}return n=yi.has(n)?n:to(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return Si(t,n,r)}build(t,n,r){lo(t,n,this.isSVGTag,r.transformTemplate)}renderInstance(t,n,r,i){Ti(t,n,r,i)}mount(t){this.isSVGTag=po(t.tagName),super.mount(t)}};var Jm=(o,t)=>oo(o)?new Oo(t):new Fo(t,{allowProjection:o!==By});var Qm=Du({...Ap,...$m,...Vm,...zm},Jm);var Kt=Ql(Qm);function ef(o,t=100,n){let r=n({...o,keyframes:[0,t]}),i=Math.min(wo(r),2e4);return{type:"keyframes",ease:s=>r.next(i*s).value/t,duration:Me(i)}}var tf=(o,t,n)=>{let r=t-o;return((n-o)%r+r)%r+o};function bs(o,t){return $i(o)?o[tf(0,o.length,t)]:o}function Pr(o){return typeof o=="object"&&!Array.isArray(o)}function As(o,t,n,r){return typeof o=="string"&&Pr(t)?hs(o,n,r):o instanceof NodeList?Array.from(o):Array.isArray(o)?o:[o]}function nf(o,t,n){return o*(t+1)}function bc(o,t,n,r){var i;return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,o+parseFloat(t)):t==="<"?n:(i=r.get(t))!==null&&i!==void 0?i:o}function Wy(o,t,n){for(let r=0;r<o.length;r++){let i=o[r];i.at>t&&i.at<n&&(pn(o,i),r--)}}function of(o,t,n,r,i,s){Wy(o,i,s);for(let c=0;c<t.length;c++)o.push({value:t[c],at:G(i,s,r[c]),easing:bs(n,c)})}function rf(o,t){for(let n=0;n<o.length;n++)o[n]=o[n]/(t+1)}function sf(o,t){return o.at===t.at?o.value===null?1:t.value===null?-1:0:o.at-t.at}var jy="easeInOut",$y=20;function lf(o,{defaultTransition:t={},...n}={},r,i){let s=t.duration||.3,c=new Map,u=new Map,p={},f=new Map,a=0,l=0,m=0;for(let d=0;d<o.length;d++){let h=o[d];if(typeof h=="string"){f.set(h,l);continue}else if(!Array.isArray(h)){f.set(h.name,bc(l,h.at,a,f));continue}let[g,y,T={}]=h;T.at!==void 0&&(l=bc(l,T.at,a,f));let v=0,S=(C,x,w,_=0,A=0)=>{let P=zy(C),{delay:V=0,times:J=qi(P),type:I="keyframes",repeat:W,repeatType:se,repeatDelay:oe=0,...Fe}=x,{ease:O=t.ease||"easeOut",duration:F}=x,ae=typeof V=="function"?V(_,A):V,H=P.length,j=fn(I)?I:i?.[I];if(H<=2&&j){let St=100;if(H===2&&Yy(P)){let mt=P[1]-P[0];St=Math.abs(mt)}let Lt={...Fe};F!==void 0&&(Lt.duration=ye(F));let en=ef(Lt,St,j);O=en.ease,F=en.duration}F??(F=s);let Ie=l+ae;J.length===1&&J[0]===0&&(J[1]=1);let Le=J.length-P.length;if(Le>0&&zi(J,Le),P.length===1&&P.unshift(null),W){Ze(W<$y,"Repeat count too high, must be less than 20"),F=nf(F,W);let St=[...P],Lt=[...J];O=Array.isArray(O)?[...O]:[O];let en=[...O];for(let mt=0;mt<W;mt++){P.push(...St);for(let tn=0;tn<St.length;tn++)J.push(Lt[tn]+(mt+1)),O.push(tn===0?"linear":bs(en,tn-1))}rf(J,W)}let Oe=Ie+F;of(w,P,O,J,Ie,Oe),v=Math.max(ae+F,v),m=Math.max(Oe,m)};if(z(g)){let C=af(g,u);S(y,T,cf("default",C))}else{let C=As(g,y,r,p),x=C.length;for(let w=0;w<x;w++){y=y,T=T;let _=C[w],A=af(_,u);for(let P in y)S(y[P],qy(T,P),cf(P,A),w,x)}}a=l,l+=v}return u.forEach((d,h)=>{for(let g in d){let y=d[g];y.sort(sf);let T=[],v=[],S=[];for(let x=0;x<y.length;x++){let{at:w,value:_,easing:A}=y[x];T.push(_),v.push(Qe(0,m,w)),S.push(A||"easeOut")}v[0]!==0&&(v.unshift(0),T.unshift(T[0]),S.unshift(jy)),v[v.length-1]!==1&&(v.push(1),T.push(null)),c.has(h)||c.set(h,{keyframes:{},transition:{}});let C=c.get(h);C.keyframes[g]=T,C.transition[g]={...t,duration:m,ease:S,times:v,...n}}}),c}function af(o,t){return!t.has(o)&&t.set(o,{}),t.get(o)}function cf(o,t){return t[o]||(t[o]=[]),t[o]}function zy(o){return Array.isArray(o)?o:[o]}function qy(o,t){return o&&o[t]?{...o,...o[t]}:{...o}}var Xy=o=>typeof o=="number",Yy=o=>o.every(Xy);function Zy(o,t){return o in t}var Cs=class extends No{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,n){if(Zy(n,t)){let r=t[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(t,n){delete n.output[t]}measureInstanceViewportBox(){return Y()}build(t,n){Object.assign(t.output,n)}renderInstance(t,{output:n}){Object.assign(t,n)}sortInstanceNodePosition(){return 0}};function uf(o){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=us(o)?new Oo(t):new Fo(t);n.mount(o),Ut.set(o,n)}function pf(o){let t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Cs(t);n.mount(o),Ut.set(o,n)}function Jy(o,t){return z(o)||typeof o=="number"||typeof o=="string"&&!Pr(t)}function ws(o,t,n,r){let i=[];if(Jy(o,t))i.push(ls(o,Pr(t)&&t.default||t,n&&(n.default||n)));else{let s=As(o,t,r),c=s.length;Ze(!!c,"No valid elements provided.");for(let u=0;u<c;u++){let p=s[u],f=p instanceof Element?uf:pf;Ut.has(p)||f(p);let a=Ut.get(p),l={...n};"delay"in l&&typeof l.delay=="function"&&(l.delay=l.delay(u,c)),i.push(...Do(a,{...t,transition:l},{}))}}return i}function mf(o,t,n){let r=[];return lf(o,t,n,{spring:Eo}).forEach(({keyframes:s,transition:c},u)=>{r.push(...ws(u,s,c))}),r}function Qy(o){return Array.isArray(o)&&o.some(Array.isArray)}function ff(o){function t(n,r,i){let s=[];Qy(n)?s=mf(n,r,o):s=ws(n,r,i,o);let c=new To(s);return o&&o.animations.push(c),c}return t}var Er=ff();var kr=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(kr||{}),df={left:"33.33%",center:"50%",right:"66.66%"},at=class at{static isUnknown(t){return t===at.Unknown}static D2PositionToCSS(t,n=!1,r=!1){let i=this.calc(t.y,t.yoffset),s=this.calc(t.x,t.xoffset),c=r?{bottom:i}:{top:i},u=n?{right:s}:{left:s};return this.wrap({...c,...u})}static calc(t,n){return!t||at.isUnknown(t)?"auto":n===void 0||at.isUnknown(n)?`calc(${t} + 0px)`:`calc(${typeof t=="number"?`${t}px`:t} + ${n}px)`}static toCoord2D(t){if(ct.isCommonPositionType(t))return ze.fromCommonPosition(t);if(ze.isCoord2DPosition(t))return t;if(Gn.isAlignPosition(t))return ze.fromAlignPosition(t);if(typeof t=="object"&&["x","y","xoffset","yoffset"].some(n=>n in t)){let n=t;return new ze(n)}else throw new Error("Invalid position type")}static orUnknown(t){return at.isUnknown(t)||t===void 0?at.Unknown:t}static mergePosition(t,n){let r=this.toCoord2D(t),i=this.toCoord2D(n);return ze.merge(r,i)}static serializePosition(t){let n=this.toCoord2D(t);return{x:at.isUnknown(n.x)?0:n.x,y:at.isUnknown(n.y)?0:n.y,xoffset:at.isUnknown(n.xoffset)?0:n.xoffset,yoffset:at.isUnknown(n.yoffset)?0:n.yoffset}}static isRawCommonPositionType(t){return Object.values(kr).includes(t)}static isRawCoord2DPosition(t){return typeof t=="object"&&("x"in t||"y"in t||"xoffset"in t||"yoffset"in t)}static isRawAlignPosition(t){return typeof t=="object"&&("xalign"in t||"yalign"in t||"xoffset"in t||"yoffset"in t)}static isRawPosition(t){return this.isRawCommonPositionType(t)||this.isRawCoord2DPosition(t)||this.isRawAlignPosition(t)}static isPosition(t){return t instanceof ct||t instanceof ze||t instanceof Gn}static rawPositionToCoord2D(t){if(this.isRawCommonPositionType(t))return ze.fromCommonPosition(new ct(t));if(this.isRawCoord2DPosition(t))return new ze(t);if(this.isRawAlignPosition(t))return ze.fromAlignPosition(t);throw new Error("Invalid position type")}static tryParsePosition(t){if(this.isPosition(t))return t;if(this.isRawPosition(t))return this.rawPositionToCoord2D(t);throw new Error("Invalid position type")}static wrap(t){return{left:"auto",top:"auto",right:"auto",bottom:"auto",...t}}};at.Unknown=Symbol("Unknown");var R=at,Ps=class Ps{static isCommonPositionType(t){return t instanceof Ps}constructor(t){this.position=t}toCSS(){return{x:df[this.position],y:"50%",xoffset:0,yoffset:0}}};Ps.Positions=kr;var ct=Ps,ze=class o{static isCoord2DPosition(t){return t instanceof o}static fromCommonPosition(t){return new o({x:df[t.position],y:"50%"})}static fromAlignPosition(t){return new o({x:R.isUnknown(t.xalign)?R.Unknown:`${t.xalign*100}%`,y:R.isUnknown(t.yalign)?R.Unknown:`${t.yalign*100}%`,xoffset:t.xoffset,yoffset:t.yoffset})}static merge(t,n){return new o({x:R.isUnknown(n.x)?t.x:n.x,y:R.isUnknown(n.y)?t.y:n.y,xoffset:R.isUnknown(n.xoffset)?t.xoffset:n.xoffset,yoffset:R.isUnknown(n.yoffset)?t.yoffset:n.yoffset})}constructor(t,n){typeof t=="object"?(this.x=R.orUnknown(t.x),this.y=R.orUnknown(t.y),this.xoffset=R.orUnknown(t.xoffset),this.yoffset=R.orUnknown(t.yoffset)):(this.x=R.orUnknown(t),this.y=R.orUnknown(n),this.xoffset=R.Unknown,this.yoffset=R.Unknown)}toCSS(){return{x:this.x,y:this.y,xoffset:this.xoffset,yoffset:this.yoffset}}},Gn=class o{static isAlignPosition(t){return t instanceof o}constructor(t,n){typeof t=="object"?(this.xalign=R.orUnknown(t.xalign),this.yalign=R.orUnknown(t.yalign),this.xoffset=R.orUnknown(t.xoffset),this.yoffset=R.orUnknown(t.yoffset)):(this.xalign=R.orUnknown(t),this.yalign=R.orUnknown(n),this.xoffset=R.Unknown,this.yoffset=R.Unknown)}toCSS(){return{x:R.isUnknown(this.xalign)?this.xalign:`${this.xalign*100}%`,y:R.isUnknown(this.yalign)?this.yalign:`${this.yalign*100}%`,xoffset:this.xoffset,yoffset:this.yoffset}}};var X=class o{constructor(t,n){this.defaultConfig=t;this.handlers=n||{}}create(t={}){return new Ac(this.mergeWithDefaultConfig(t))}copy(){return new o(U({},this.defaultConfig),this.handlers)}keys(){return Object.keys(this.defaultConfig)}getDefaultConfig(){return this.defaultConfig}mergeWithDefaultConfig(t){return Object.fromEntries(Object.entries(this.defaultConfig).map(([n,r])=>[n,this.mergeValue(n,r,t[n])]))}mergeValue(t,n,r){return this.isPlainObject(r)?U({},r):Array.isArray(n)?Array.isArray(r)&&r.length>0?[...r]:[...n]:r!==void 0?this.applyHandler(t,r):n}isPlainObject(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null&&Object.getPrototypeOf(t)===Object.prototype}applyHandler(t,n){return typeof this.handlers[t]=="function"?this.handlers[t](n):n}},Ac=class o{constructor(t){this.config=t}get(){return this.config}copy(){return new o(U({},this.config))}join(t){let n=_l(this.config,Object.keys(t));return new o(Object.assign(n,t instanceof o?t.get():t))}extract(t){let n={},r={};for(let i of t)n[i]=this.config[i];for(let i in this.config)t.includes(i)||(r[i]=this.config[i]);return[new o(n),new o(r)]}assign(t){return new o(Object.assign({},this.config,t))}};var eT={[ei.left]:"25.33%",[ei.center]:"50%",[ei.right]:"75.66%"},ht=class ht{constructor(t={}){this.state={};this.locked=null;this.frozen=!1;this.state=t}static deserialize(t){return new ht(ht.TransformStateSerializer.deserialize(t))}static mergePosition(t,n){if(!t&&!n)throw new Error("No position found.");return!t||!n?R.toCoord2D(R.tryParsePosition(t||n)):R.mergePosition(R.tryParsePosition(t),R.tryParsePosition(n))}static mergeState(t,n){if("position"in t&&"position"in n){let r=this.mergePosition(t.position,n.position);return{...Object.assign({},t,n),position:r}}return{...Object.assign({},t,n)}}get(){return this.state}freeze(){return this.frozen=!0,this}assign(t,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(t))throw new Error("Trying to write a locked transform state.");return this.state=ht.mergeState(this.state,n),this}lock(){if(this.locked)throw new Error("Transform state is already locked.");return this.locked=Symbol(),this.locked}isLocked(){return!!this.locked}canWrite(t){return this.locked===null||this.locked===t}unlock(t){return this.locked===t&&(this.locked=null),this}toFramesDefinition(t,n){return ba(ce.constructStyle(t,this.state,n))}toStyle(t,n){return ba(ce.constructStyle(t,this.state,n))}serialize(){return ht.TransformStateSerializer.serialize(this.state)}clone(){return new ht(ht.mergeState({},this.state))}overwrite(t,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(t))throw new Error("Trying to write a locked transform state.");return this.state=ht.mergeState(this.state,n),this}forceOverwrite(t){return this.state=t,this}};ht.DefaultTransformState=new X({scale:1,rotation:0,position:new ct("center"),opacity:0,alt:""}),ht.TransformStateSerializer=new it({position:t=>R.toCoord2D(R.tryParsePosition(t))},{position:R.toCoord2D});var Se=ht,ve=class ve{constructor(t,n){this.sequences=[];this.stagedChanges=[];if(Array.isArray(t))this.sequences.push(...t),this.config=Object.assign({},ve.defaultConfig,n||{});else{let[r,i]=[t,n||ve.defaultOptions];this.sequences.push({props:r,options:i||ve.defaultOptions}),this.config=Object.assign({},ve.defaultConfig)}}static isPosition(t){return ct.isCommonPositionType(t)||ze.isCoord2DPosition(t)||Gn.isAlignPosition(t)}static immediate(t){return new ve(t,{duration:0,ease:"linear"})}static left(t,n){return new ve({position:ct.Positions.Left},{duration:t,ease:n})}static right(t,n){return new ve({position:ct.Positions.Right},{duration:t,ease:n})}static center(t,n){return new ve({position:ct.Positions.Center},{duration:t,ease:n})}static create(t){return new ve([],t)}static positionToCSS(t,n,r){return t?R.isRawPosition(t)?R.D2PositionToCSS(R.rawPositionToCoord2D(t),r,n):R.D2PositionToCSS(t.toCSS(),r,n):{}}static mergePosition(t,n){if(!t&&!n)throw new Error("No position found.");return!t||!n?R.toCoord2D(R.tryParsePosition(t||n)):R.mergePosition(R.tryParsePosition(t),R.tryParsePosition(n))}static mergeState(t,n){let r=this.mergePosition(t.position,n.position);return{...U(t,n),position:r}}static propToCSSTransform(t,n,{translate:r=[],scale:i=1}={}){if(!t.getLastScene())throw new Error('No scene found in state, make sure you called "scene.activate()" before this method.');let s=n.scale!==void 0?n.scale:1,{invertY:c,invertX:u}=t.getStory().getInversionConfig();return[`translate(${r[0]||(u?"":"-")+"50%"}, ${r[1]||(c?"":"-")+"50%"})`,n.rotation!==void 0&&`rotate(${n.rotation}deg)`,`scale(${s*i})`].filter(Boolean).join(" ")}static constructStyle(t,n,r){let{invertY:i,invertX:s}=t.getStory().getInversionConfig(),{transform:c,scale:u,overwrite:p}=r||{};return{...ve.positionToCSS(n.position,i,s),opacity:n.opacity,color:"fontColor"in n&&n.fontColor?Pn(n.fontColor):void 0,transform:c?c(n):ve.propToCSSTransform(t,n),scale:u?u(n):void 0,...p?p(n):{}}}animate(t,{gameState:n,ref:r,overwrites:i}){if(!r.current)throw new Error("No ref found when animating.");this.commit();let{finalState:s,sequences:c,options:u}=this.constructAnimation({gameState:n,transformState:t,overwrites:i,current:r.current});c.length||n.logger.warn("Transform","No sequences to animate.");let p=t.lock(),f=Er(c,u),a=()=>{t.unlock(p),f.complete()},l=new b().registerSkipController(new K(a)),m=()=>{t.overwrite(p,s.get()).unlock(p),n.logger.debug("Transform","Transform Completed",t.toStyle(n,i)),l.resolve()};return f.then(m,d=>{n.logger.error("Failed to animate transform. "+(d?.toString?.()||""))}),f.play(),n.logger.debug("Transform","Ready to animate transform.",{finalState:s,sequences:c,options:u},this),l}repeat(t){let n=this.copy();return n.config.repeat||(n.config.repeat=1),n.config.repeat*=t,n}getOptions(t){if(!t)return{...ve.defaultOptions};let{duration:n,ease:r,delay:i,at:s}=t;return{duration:this.toSeconds(n,void 0),ease:r,delay:this.toSeconds(i,void 0),at:this.atToSeconds(s)}}constructAnimation({gameState:t,transformState:n,overwrites:r={},current:i}){let s=n.clone(),c=s.lock(),u=this.sequences.map(({props:p,options:f})=>{let a=s.assign(c,p).toFramesDefinition(t,r);return[i,a,this.getOptions(f)]});return{finalState:s.unlock(c).freeze(),sequences:u,options:this.getSequenceOptions()}}getSequenceOptions(){let{repeat:t,repeatDelay:n}=this.config;return{repeat:this.toSeconds(t,void 0),repeatDelay:this.toSeconds(n,void 0)}}copy(){return new ve(this.sequences,this.config)}commit(t){if(!this.stagedChanges.length)return this;let n=this.constructCommit(this.stagedChanges,this.getSequenceOptions());return this.sequences.push({props:n.props,options:{...this.getSequenceOptions(),...t}}),this.stagedChanges=[],this}scale(t){return this.pushChange({key:"scale",props:t})}rotation(t){return this.pushChange({key:"rotation",props:t})}position(t){return this.pushChange({key:"position",props:t})}opacity(t){return this.pushChange({key:"opacity",props:t})}fontColor(t){return this.pushChange({key:"fontColor",props:t})}constructCommit(t,n){let r={props:{},options:n};for(let i of t)r.props[i.key]=i.props;return r}pushChange(t){return this.stagedChanges.push(t),this}toSeconds(t,n){return typeof t>"u"?n:t/1e3}atToSeconds(t){if(typeof t>"u")return t;if(typeof t=="number")return t/1e3;let r=/^([+-])(\d+)$/.exec(t);if(!r)throw new me("Invalid at definition. At definition must be a number or a string in the format of `+n` or `-n`.");let[i,s,c]=r,u=Number(c);if(isNaN(u))throw new me("Invalid number in at definition.");let p=u/1e3;return s==="+"?`+${p}`:`-${p}`}};ve.defaultConfig={sync:!0},ve.defaultOptions={duration:0,ease:"linear"},ve.CommonImagePositionMap=eT;var ce=ve;var e={};var Es=class{constructor(){this.id=""}setId(t){this.id=t}getId(){return this.id}reset(){}fromData(t){return this}construct(t){for(let n=0;n<t.length;n++){let r=t[n];n!==0&&t[n-1]?.contentNode.setChild(r.contentNode)}return t}};var ks=class{constructor(t){this.config=t;this.watching=null;this.warnings=[]}observe(t){return this.watching=t,this}warn(t,n){return this.warnings.push([t,n]),this.watching?.logger.warn(n),n}getWarnings(){return[...this.warnings]}};var ne=class o{constructor(t,n){this.awaitable=t;this.guard=n;this.children=[];this._onResolved=[];this._onCancelled=[];this._onTimelineRegistered=[];this._ableToAttach=!0;this._status="pending";t.onSettled(()=>{this.resolveStatus()}),rn(()=>{this.preventAttach()})}static proxy(t){let n=new b,r=new b,i=new o(r);return i.onTimelineRegistered(()=>{r.resolve()}).onSettled(()=>{let[s,c]=i.catSettled();t(s,c)}),n.onSkipControllerRegister(s=>{s.onAbort(()=>{i.abort()})}),[n,i]}static any(t){if(t.length===0)throw new M("Cannot create an 'any' timeline with no awaitables.");let n=new b,r=new b,i=new o(r),s=!1;for(let c of t)i.attachChild(c),c.then(u=>{s||(s=!0,n.resolve(u))});return n.onSkipControllerRegister(c=>{c.onAbort(()=>{i.abort()})}),[n,i]}static sequence(t,n){let r=n,i=null,s=new b,c=()=>{if(i){let u;i.onSkipControllerRegister(p=>{u=p.onAbort(()=>{s.abort()})}),i.then(p=>{u?.cancel(),r=p,i=t(p),i?rn(()=>c()):s.resolve(r)})}else s.resolve(r)};return s.registerSkipController(new K(()=>(i&&i.abort(),n))),i=t(n),i?rn(()=>c()):s.resolve(r),s}get status(){return this._status}isSettled(){return this._status!=="pending"}isResolved(){return this._status==="resolved"}isCancelled(){return this._status==="cancelled"}onResolved(t){this._onResolved.push(t)}onCancelled(t){this._onCancelled.push(t)}onSettled(t){this.isSettled()?rn(t):(this.onResolved(t),this.onCancelled(t))}abort(){this.isSettled()||(this.awaitable.abort(),this.setStatus("cancelled",this.emitEvents.bind(this)),this.children.forEach(t=>t.abort()))}attachChild(t){if(!this._ableToAttach)throw new M(`Attaching to this timeline violates the timeline's state.
|
|
12
12
|
Timeline attaching is only allowed synchronously after the timeline is created.
|
|
13
|
-
Current _ableToAttach: `+this._ableToAttach);let n=b.isAwaitable(t)?new o(t,this.guard):t;return this.children.push(n),this.guard&&n.setGuard(this.guard),n.onSettled(()=>{this.resolveStatus()}),this}setGuard(t){return this.guard=t,this}catSettled(){return this.children.reduce(([t,n],r)=>(r.isResolved()?t.push(r):r.isCancelled()&&n.push(r),[t,n]),[[],[]])}onTimelineRegistered(t){return this._onTimelineRegistered.push(t),this}resolveStatus(){this.awaitable.solved&&this.children.every(t=>t.isSettled())?this.setStatus("resolved",this.emitEvents.bind(this)):this.awaitable.skipController?.isAborted()&&this.setStatus("cancelled",this.emitEvents.bind(this))}emitEvents(){this.isResolved()?this._onResolved.forEach(t=>t()):this.isCancelled()&&this._onCancelled.forEach(t=>t()),this._onResolved=[],this._onCancelled=[]}setStatus(t,n){if(this.isSettled()){this.guard&&this.guard.warn("unexpectedTimelineStatusChange",`Trying to resolve a settled timeline: ${this._status} -> ${t}`);return}t!==this._status&&n?(this._status=t,n()):this._status=t}preventAttach(){this._ableToAttach=!1,this._onTimelineRegistered.forEach(t=>t())}},ks=class{constructor(t){this.guard=t;this.timelines=[]}attachTimeline(t){this.cleanupSettled();let n=t instanceof ne?t:new ne(t);return this.timelines.push(n),this.guard&&n.setGuard(this.guard),n}abortAll(){for(let t of this.timelines)t.abort();this.cleanupSettled()}cleanupSettled(){this.timelines=this.timelines.filter(t=>!t.isSettled())}};var he=class extends ${executeActionSeries(t,n,r){let i=ne.sequence(u=>{if(!u.node||!u.node.action)return null;let p=u.node.action,f=t.game.getLiveGame().executeActionRaw(t,p);return f?b.isAwaitable(f)?f:b.resolve(f):null},{type:n.type,node:n.contentNode}),s=new ne(i),c=new b;return t.logger.debug("ControlAction","executeActionSeries",n.type,n.contentNode),i.then(u=>{let p=r(u);c.resolve(p)}),i.registerSkipController(new K(()=>{s.abort(),c.abort()})),c.onSkipControllerRegister(u=>{u.onAbort(()=>{s.abort()})}),[c,s]}executeSingleAction(t,n){let r=t.game.getLiveGame().executeAction(t,n);return t.logger.debug("ControlAction","executeSingleAction",n.type,r),b.isAwaitable(r),r}executeAction(t){let n=this.contentNode,[r]=n.getContent();if(this.type===ft.do){let[i,s]=this.executeActionSeries(t,r[0],c=>c);return t.timelines.attachTimeline(s),b.forward(i,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.doAsync){if(r.length>0){let[,i]=this.executeActionSeries(t,r[0],s=>s);t.timelines.attachTimeline(i)}return super.executeAction(t)}else if(this.type===ft.any){if(r.length===0)return b.resolve({type:this.type,node:this.contentNode.getChild()});let[i,s]=ne.any(r.map(c=>this.executeSingleAction(t,c)).filter(c=>b.isAwaitable(c)));return t.timelines.attachTimeline(s),b.forward(i,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.all){let[i,s]=ne.proxy(()=>{i.resolve({type:this.type,node:this.contentNode.getChild()}),t.stage.next()});for(let c of r){let u=this.executeSingleAction(t,c);b.isAwaitable(u)&&s.attachChild(u)}return t.timelines.attachTimeline(s),i}else if(this.type===ft.allAsync){let[,i]=ne.proxy(Fl());for(let s of r){let c=this.executeSingleAction(t,s);b.isAwaitable(c)&&i.attachChild(c)}return t.timelines.attachTimeline(i),super.executeAction(t)}else if(this.type===ft.repeat){let[i,s]=this.contentNode.getContent(),c=ne.sequence(p=>{if(p>=s)return null;let[f,a]=this.executeActionSeries(t,i[0],()=>p+1);return u.attachChild(a),f},0),u=new ne(c);return t.timelines.attachTimeline(u),b.forward(c,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.sleep){let[,i]=this.contentNode.getContent(),s;typeof i=="number"?s=b.delay(i):b.isAwaitable(i)?s=i:s=b.fromPromise(i);let c=new b,u=new ne(s);return t.timelines.attachTimeline(u),s.then(()=>{c.resolve({type:this.type,node:this.contentNode.getChild()}),t.stage.next()}),c.onSkipControllerRegister(p=>{p.onAbort(()=>{u.abort()})}),c}throw new Error("Unknown control action type: "+this.type)}getFutureActions(t,n){if(this.callee.config.allowFutureScene===!1&&n.allowFutureScene===!1)return[...super.getFutureActions(t,n)];let r=this.contentNode.getContent()[0],i=super.getFutureActions(t,n);return[...r,...i]}};he.ActionTypes=ft;var gf=Symbol("_Chained"),yf;yf=gf;var Cc=class Cc{constructor(t){this[yf]=!0;this.__actions=[];this.__self=t}static isChained(t){return t&&t[gf]}static toActions(t){return t.flat(2).map(n=>Cc.isChained(n)?n.fromChained(n):n).flat(3)}push(...t){this.__actions.push(...t)}getActions(){return this.__actions}getSelf(){return this.__self}newChain(){return this.getSelf().chain()}},Ee=Cc,Ho=class extends Ps{chain(t){let n=Ee.isChained(this)?this:this.proxy(this,new Ee(this));if(!t)return n;let r=Array.isArray(t)?t:[t];return n.push(...r),n}proxy(t,n){let r=new Proxy(t,{get:function(i,s){if(s in n)return n[s];let c=i[s];return typeof c=="function"?c.bind(r):c},set:function(i,s,c){return i[s]=c,!0}});return r}combineActions(t,n){let r=n(this.chain().newChain()),i=new he(t.chain(),he.ActionTypes.do,new D().setContent([this.construct(Ee.toActions([r]))]));return this.chain(i)}};var le=class extends Ho{constructor(){super()}toData(){return null}fromChained(t){return t.getActions()}};var Ut=class o extends le{constructor(n={}){super();this.config=n}static do(n){return new o().do(n)}static doAsync(n){return new o().doAsync(n)}static any(n){return new o().any(n)}static all(n){return new o().all(n)}static allAsync(n){return new o().allAsync(n)}static repeat(n,r){return new o().repeat(n,r)}static sleep(n){return new o().sleep(n)}do(n){return this.push(he.ActionTypes.do,n)}doAsync(n){return this.push(he.ActionTypes.doAsync,n)}any(n){return this.push(he.ActionTypes.any,n)}all(n){return this.push(he.ActionTypes.all,n)}allAsync(n){return this.push(he.ActionTypes.allAsync,n)}repeat(n,r){return this.push(he.ActionTypes.repeat,r,n)}sleep(n){return this.push(he.ActionTypes.sleep,[],n)}push(n,r,...i){let s=Ee.toActions(r),c=new he(this.chain(),n,new D().setContent([this.construct(s),...i]));return this.chain(c)}};var ke=class extends ${executeAction(t){if(this.type===Ce.applyTransform){let[n]=this.contentNode.getContent(),r=this.callee;return this.applyTransform(t,r,n)}else if(this.type===Ce.applyTransition){let[n,r]=this.contentNode.getContent(),i=this.callee,s=r?r(n):n;return this.applyTransition(t,i,s)}else if(this.type===Ce.init){let[n,r,i]=this.contentNode.getContent(),s=this.callee;return this.initDisplayable(t,n,s,r||null,i)}throw this.unknownTypeError()}applyTransform(t,n,r,i){let s=new b().registerSkipController(new K(()=>(t.logger.info("Displayable Transition","Skipped"),super.executeAction(t)))),c=t.getExposedStateForce(n),u=n.transformState.clone(),p=c.applyTransform(r,()=>{i?.(),s.resolve(super.executeAction(t)),t.stage.next()}),f=t.timelines.attachTimeline(s).attachChild(p);return t.actionHistory.push(this,a=>{s.isSettled()||s.abort(),n.transformState.forceOverwrite(a.state)},[u],f),s}applyTransition(t,n,r,i){let s=new b().registerSkipController(new K(()=>(t.logger.info("Displayable Transition","Skipped"),super.executeAction(t)))),u=t.getExposedStateForce(n).applyTransition(r,()=>{i?.(),s.resolve(super.executeAction(t)),t.stage.next()}),p=t.timelines.attachTimeline(s).attachChild(u);return t.actionHistory.push(this,void 0,[],p),s}initDisplayable(t,n,r,i,s=!0){if(s!==!1){let p=t.findElementByDisplayable(this.callee,i);p&&t.disposeDisplayable(r,p.scene,i),t.createDisplayable(r,n,i)}t.flush();let c=new b().registerSkipController(new K(()=>super.executeAction(t)));t.getExposedStateAsync(r,p=>{p.initDisplayable(()=>{c.resolve(super.executeAction(t)),t.stage.next()})});let u=t.timelines.attachTimeline(c);return t.actionHistory.push(this,()=>{s!==!1&&t.findElementByDisplayable(r,i)&&t.disposeDisplayable(r,n,i)},[],u),c}};ke.ActionTypes=Ce;var et=class extends ${executeAction(t){if(this.type===nn.play){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.play(this.callee,n),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.stop){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.stop(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.setVolume){let[n,r]=this.contentNode.getContent(),i=this.callee.toData(),s=b.forward(t.audioManager.setVolume(this.callee,n,r),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(s),t.actionHistory.push(this,c=>{c&&this.callee.fromData(c)},[i]),s}else if(this.type===nn.setRate){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.setRate(this.callee,n),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.pause){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.pause(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.resume){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.resume(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}throw super.unknownTypeError()}};et.ActionTypes=nn;var Ve=class Ve extends le{static toSound(t){return t==null?null:typeof t=="string"?new Ve({src:t}):t}constructor(t={}){super();let n=typeof t=="string"?{src:t}:t,r=Ve.DefaultUserConfig.create(n),[i]=r.extract(Ve.DefaultConfig.keys());this.config=i.get(),this.state=this.getInitialState(r),this.userConfig=r}play(t){return this.pushAction(et.ActionTypes.play,[{end:this.state.volume,duration:t||0}])}stop(t){return this.pushAction(et.ActionTypes.stop,[{end:0,duration:t||0}])}setVolume(t,n){return this.pushAction(et.ActionTypes.setVolume,[t,n||0])}setRate(t){return this.pushAction(et.ActionTypes.setRate,[t])}pause(t){return this.pushAction(et.ActionTypes.pause,[{end:0,duration:t||0}])}resume(t){return this.pushAction(et.ActionTypes.resume,[{end:this.state.volume,duration:t||0}])}getSrc(){return this.config.src}toData(){return{state:Ve.StateSerializer.serialize(this.state)}}fromData(t){return this.state=Ve.StateSerializer.deserialize(t.state),this}copy(){return new Ve(this.userConfig.get())}reset(){this.state=this.getInitialState(this.userConfig)}getInitialState(t){return Ve.DefaultState.create({...t.get()}).get()}pushAction(t,n){return this.chain(new et(this.chain(),t,new D().setContent(n)))}};Ve.noSound="data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgA",Ve.DefaultUserConfig=new X({src:Ve.noSound,loop:!1,volume:1,streaming:!1,rate:1,seek:0}),Ve.DefaultConfig=new X({src:Ve.noSound,loop:!1,streaming:!1,seek:0}),Ve.DefaultState=new X({volume:1,rate:1,paused:!1}),Ve.StateSerializer=new rt;var ct=Ve;var Fn=class Fn{constructor(){this.src=[];this.future=[]}static catSrc(t){let n=new Set,r=new Set,i=new Set;return t.forEach(({type:s,src:c})=>{s===Fn.SrcTypes.image?n.add(c):s===Fn.SrcTypes.video?r.add(c):i.add(c)}),{image:Array.from(n),video:Array.from(r),audio:Array.from(i)}}static getSrc(t){return typeof t=="string"?t:t instanceof B?B.getSrcURL(t):t.type==="image"?B.getSrcURL(t.src):t.type==="video"?t.src:t.type==="audio"?t.src.getSrc():""}static getPreloadableSrc(t,n){if(n.is(xe,ge.jumpTo)){let r=n.contentNode.getContent()[0],s=t.getScene(r,!0).state.backgroundImage;if(k.isImageURL(s.config.src))return{type:"image",src:s.config.src,activeType:"once"}}else if(n instanceof ue){let r=n;if(n.is(ue,ot.setSrc)){let i=n.contentNode.getContent()[0];if(k.isImageSrc(i))return{type:"image",src:k.srcToURL(i),activeType:"scene"}}else{if(n.type===ot.initWearable)return{type:"image",src:n.contentNode.getContent()[0],activeType:"scene"};if(n.type===ot.setAppearance){let i=n.contentNode.getContent()[0];if(!r.callee.config.src||typeof r.callee.config.src?.resolve!="function")throw r.callee._invalidSrcHandlerError();if(B.isTagSrc(r.callee)&&i.length===r.callee.config.src.groups.length)return{type:"image",src:B.getSrcFromTags(i,r.callee.config.src.resolve),activeType:"scene"}}}}return null}register(t,n){if(Array.isArray(t))t.forEach(r=>this.register(r));else if(t instanceof ct){if(this.isSrcRegistered(t.getSrc()))return this;this.src.push({type:"audio",src:t})}else if(t instanceof B||k.isStaticImageData(t)){if(t instanceof B){if(!k.isImageURL(t.state.currentSrc))return this;if(this.isSrcRegistered(B.getSrcURL(t)))return this}else if(this.isSrcRegistered(k.srcToURL(t.src)))return this;this.src.push({type:"image",src:k.isStaticImageData(t)?k.srcToURL(t):t.state.currentSrc})}else if(typeof t=="object"){if(this.isSrcRegistered(t.src||""))return this;this.src.push(t)}else if(t==="audio"){if(this.isSrcRegistered(n||""))return this;this.src.push({type:t,src:n instanceof ct?n:new ct({src:n})})}else{if(this.isSrcRegistered(n||""))return this;this.src.push({type:t,src:n})}return this}registerRawSrc(t){return this.isSrcRegistered(t)?this:(this.src.push({type:"image",src:t}),this)}isSrcRegistered(t){if(!t)return!1;let n=t instanceof ct?t.getSrc():t;return this.src.some(r=>r.type===Fn.SrcTypes.audio?n===r.src.getSrc():r.type===Fn.SrcTypes.image?n===B.getSrcURL(r.src):n===r.src)}getSrc(){return[...this.src]}getSrcByType(t){return this.src.filter(n=>n.type===t)}registerFuture(t){return this.future.includes(t)||this.hasFuture(t)?this:(this.future.push(t),this)}hasFuture(t){return this.future.includes(t)}getFutureSrc(){return this.future.map(t=>t.getSrc()).flat(2)}};Fn.SrcTypes={image:"image",video:"video",audio:"audio"};var Ne=Fn;var wt=class extends le{constructor(){super(...arguments);this.srcManager=new Ne}pos(n,r,i){return this.transform(new ce({position:n},{duration:r,ease:i}))}scale(n,r,i){return this.transform(new ce({scale:n},{duration:r,ease:i}))}rotate(n,r,i){return this.transform(new ce({rotation:n},{duration:r,ease:i}))}opacity(n,r,i){return this.transform(new ce({opacity:n},{duration:r,ease:i}))}transform(n){let r=this.chain(),i=new ke(r,Ce.applyTransform,new D().setContent([n.copy()]));return r.chain(i)}show(n){let r=this.chain(),i=n instanceof ce?n.copy():new ce({opacity:1},n),s=new ke(r,Ce.applyTransform,new D().setContent([i]));return r.chain(s)}hide(n){let r=this.chain(),i=n instanceof ce?n.copy():new ce({opacity:0},n),s=new ke(r,Ce.applyTransform,new D().setContent([i]));return r.chain(s)}};var ee=class ee extends wt{static getInitialSrc(t){if(this.isTagDefinition(t.src))return[...t.src.defaults];let n=t.src;return k.isStaticImageData(n)?k.srcToURL(n):k.isColor(n)?n:k.isImageSrc(n)?k.srcToURL(n):ee.DefaultImagePlaceholder}static isTagSrc(t){return!!t.config.src}static isTagDefinition(t){return typeof t=="object"&&t!==null&&!k.isImageSrc(t)&&!k.isColor(t)&&"defaults"in t}static isStaticSrc(t){let n=t.userConfig.get().src;return!this.isTagSrc(t)&&(k.isImageSrc(n)||k.isColor(n))}static getSrcURL(t){return typeof t=="string"?t:ee.isTagSrc(t)?ee.getSrcFromTags(t.state.currentSrc,t.config.src.resolve):ee.isStaticSrc(t)?k.isStaticImageData(t.state.currentSrc)?k.srcToURL(t.state.currentSrc):k.isColor(t.state.currentSrc)?null:t.state.currentSrc:null}static getSrcFromTags(t,n){return n(...t)}static fromSrc(t){return new ee({src:t})}constructor(t={}){super();let n=ee.DefaultUserConfig.create(t),r=this.createImageConfig(n);this.userConfig=n,this.config=r.get(),this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(n),this.checkConfig().registerSrc()}char(t,n){return this.combineActions(new Ut,r=>{if(k.isImageSrc(t)||k.isColor(t)){if(k.isColor(t)&&!this.config.isBackground)throw new Error("Color src is not allowed for non-background image");return r.chain(this._setSrc(r,t,n))}else{let i=new ue(r,ue.ActionTypes.setAppearance,new D().setContent([t,n?.copy()]));return r.chain(i).chain(this._flush())}})}addWearable(t){let n=Array.isArray(t)?t:[t];for(let r of n){if(r===this)throw new me("Cannot add self as a wearable");this.config.wearables.push(r),Object.assign(r.config,{isWearable:!0})}return this}wear(t){return this.addWearable(t)}bindWearable(t){return t.addWearable([this])}asWearableOf(t){return this.bindWearable(t)}useLayer(t){return this.userConfig.get().layer=t||void 0,Object.assign(this.config,{layer:t||void 0}),this}toData(){return{state:ee.StateSerializer.serialize(this.state),transformState:Se.TransformStateSerializer.serialize(this.transformState.get())}}fromData(t){return this.state=ee.StateSerializer.deserialize(t.state),this.transformState=Se.deserialize(t.transformState),this}_applyTransition(t,n){return new ke(this.chain(),Ce.applyTransition,new D().setContent([t,n]))}_init(t,n){return new ke(this.chain(),Ce.init,new D().setContent([t,n||this.config.layer||null]))}_initWearable(t){return new ue(this.chain(),ue.ActionTypes.initWearable,new D().setContent([t]))}_flush(){return new ue(this.chain(),ue.ActionTypes.flush,new D)}reset(){return this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(this.userConfig),this}resolveTags(t,n){if(!ee.isTagSrc(this))throw new Error(`Tag not defined
|
|
13
|
+
Current _ableToAttach: `+this._ableToAttach);let n=b.isAwaitable(t)?new o(t,this.guard):t;return this.children.push(n),this.guard&&n.setGuard(this.guard),n.onSettled(()=>{this.resolveStatus()}),this}setGuard(t){return this.guard=t,this}catSettled(){return this.children.reduce(([t,n],r)=>(r.isResolved()?t.push(r):r.isCancelled()&&n.push(r),[t,n]),[[],[]])}onTimelineRegistered(t){return this._onTimelineRegistered.push(t),this}resolveStatus(){this.awaitable.solved&&this.children.every(t=>t.isSettled())?this.setStatus("resolved",this.emitEvents.bind(this)):this.awaitable.skipController?.isAborted()&&this.setStatus("cancelled",this.emitEvents.bind(this))}emitEvents(){this.isResolved()?this._onResolved.forEach(t=>t()):this.isCancelled()&&this._onCancelled.forEach(t=>t()),this._onResolved=[],this._onCancelled=[]}setStatus(t,n){if(this.isSettled()){this.guard&&this.guard.warn("unexpectedTimelineStatusChange",`Trying to resolve a settled timeline: ${this._status} -> ${t}`);return}t!==this._status&&n?(this._status=t,n()):this._status=t}preventAttach(){this._ableToAttach=!1,this._onTimelineRegistered.forEach(t=>t())}},Ds=class{constructor(t){this.guard=t;this.timelines=[]}attachTimeline(t){this.cleanupSettled();let n=t instanceof ne?t:new ne(t);return this.timelines.push(n),this.guard&&n.setGuard(this.guard),n}abortAll(){for(let t of this.timelines)t.abort();this.cleanupSettled()}cleanupSettled(){this.timelines=this.timelines.filter(t=>!t.isSettled())}};var he=class extends ${executeActionSeries(t,n,r){let i=ne.sequence(u=>{if(!u.node||!u.node.action)return null;let p=u.node.action,f=t.game.getLiveGame().executeActionRaw(t,p);return f?b.isAwaitable(f)?f:b.resolve(f):null},{type:n.type,node:n.contentNode}),s=new ne(i),c=new b;return t.logger.debug("ControlAction","executeActionSeries",n.type,n.contentNode),i.then(u=>{let p=r(u);c.resolve(p)}),i.registerSkipController(new K(()=>{s.abort(),c.abort()})),c.onSkipControllerRegister(u=>{u.onAbort(()=>{s.abort()})}),[c,s]}executeSingleAction(t,n){let r=t.game.getLiveGame().executeAction(t,n);return t.logger.debug("ControlAction","executeSingleAction",n.type,r),b.isAwaitable(r),r}executeAction(t){let n=this.contentNode,[r]=n.getContent();if(this.type===ft.do){let[i,s]=this.executeActionSeries(t,r[0],c=>c);return t.timelines.attachTimeline(s),b.forward(i,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.doAsync){if(r.length>0){let[,i]=this.executeActionSeries(t,r[0],s=>s);t.timelines.attachTimeline(i)}return super.executeAction(t)}else if(this.type===ft.any){if(r.length===0)return b.resolve({type:this.type,node:this.contentNode.getChild()});let[i,s]=ne.any(r.map(c=>this.executeSingleAction(t,c)).filter(c=>b.isAwaitable(c)));return t.timelines.attachTimeline(s),b.forward(i,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.all){let[i,s]=ne.proxy(()=>{i.resolve({type:this.type,node:this.contentNode.getChild()}),t.stage.next()});for(let c of r){let u=this.executeSingleAction(t,c);b.isAwaitable(u)&&s.attachChild(u)}return t.timelines.attachTimeline(s),i}else if(this.type===ft.allAsync){let[,i]=ne.proxy(Fl());for(let s of r){let c=this.executeSingleAction(t,s);b.isAwaitable(c)&&i.attachChild(c)}return t.timelines.attachTimeline(i),super.executeAction(t)}else if(this.type===ft.repeat){let[i,s]=this.contentNode.getContent(),c=ne.sequence(p=>{if(p>=s)return null;let[f,a]=this.executeActionSeries(t,i[0],()=>p+1);return u.attachChild(a),f},0),u=new ne(c);return t.timelines.attachTimeline(u),b.forward(c,{type:this.type,node:this.contentNode.getChild()})}else if(this.type===ft.sleep){let[,i]=this.contentNode.getContent(),s;typeof i=="number"?s=b.delay(i):b.isAwaitable(i)?s=i:s=b.fromPromise(i);let c=new b,u=new ne(s);return t.timelines.attachTimeline(u),s.then(()=>{c.resolve({type:this.type,node:this.contentNode.getChild()}),t.stage.next()}),c.onSkipControllerRegister(p=>{p.onAbort(()=>{u.abort()})}),c}throw new Error("Unknown control action type: "+this.type)}getFutureActions(t,n){if(this.callee.config.allowFutureScene===!1&&n.allowFutureScene===!1)return[...super.getFutureActions(t,n)];let r=this.contentNode.getContent()[0],i=super.getFutureActions(t,n);return[...r,...i]}};he.ActionTypes=ft;var gf=Symbol("_Chained"),yf;yf=gf;var Cc=class Cc{constructor(t){this[yf]=!0;this.__actions=[];this.__self=t}static isChained(t){return t&&t[gf]}static toActions(t){return t.flat(2).map(n=>Cc.isChained(n)?n.fromChained(n):n).flat(3)}push(...t){this.__actions.push(...t)}getActions(){return this.__actions}getSelf(){return this.__self}newChain(){return this.getSelf().chain()}},Ee=Cc,Ho=class extends Es{chain(t){let n=Ee.isChained(this)?this:this.proxy(this,new Ee(this));if(!t)return n;let r=Array.isArray(t)?t:[t];return n.push(...r),n}proxy(t,n){let r=new Proxy(t,{get:function(i,s){if(s in n)return n[s];let c=i[s];return typeof c=="function"?c.bind(r):c},set:function(i,s,c){return i[s]=c,!0}});return r}combineActions(t,n){let r=n(this.chain().newChain()),i=new he(t.chain(),he.ActionTypes.do,new D().setContent([this.construct(Ee.toActions([r]))]));return this.chain(i)}};var le=class extends Ho{constructor(){super()}toData(){return null}fromChained(t){return t.getActions()}};var Bt=class o extends le{constructor(n={}){super();this.config=n}static do(n){return new o().do(n)}static doAsync(n){return new o().doAsync(n)}static any(n){return new o().any(n)}static all(n){return new o().all(n)}static allAsync(n){return new o().allAsync(n)}static repeat(n,r){return new o().repeat(n,r)}static sleep(n){return new o().sleep(n)}do(n){return this.push(he.ActionTypes.do,n)}doAsync(n){return this.push(he.ActionTypes.doAsync,n)}any(n){return this.push(he.ActionTypes.any,n)}all(n){return this.push(he.ActionTypes.all,n)}allAsync(n){return this.push(he.ActionTypes.allAsync,n)}repeat(n,r){return this.push(he.ActionTypes.repeat,r,n)}sleep(n){return this.push(he.ActionTypes.sleep,[],n)}push(n,r,...i){let s=Ee.toActions(r),c=new he(this.chain(),n,new D().setContent([this.construct(s),...i]));return this.chain(c)}};var ke=class extends ${executeAction(t){if(this.type===Ce.applyTransform){let[n]=this.contentNode.getContent(),r=this.callee;return this.applyTransform(t,r,n)}else if(this.type===Ce.applyTransition){let[n,r]=this.contentNode.getContent(),i=this.callee,s=r?r(n):n;return this.applyTransition(t,i,s)}else if(this.type===Ce.init){let[n,r,i]=this.contentNode.getContent(),s=this.callee;return this.initDisplayable(t,n,s,r||null,i)}throw this.unknownTypeError()}applyTransform(t,n,r,i){let s=new b().registerSkipController(new K(()=>(t.logger.info("Displayable Transition","Skipped"),super.executeAction(t)))),c=t.getExposedStateForce(n),u=n.transformState.clone(),p=c.applyTransform(r,()=>{i?.(),s.resolve(super.executeAction(t)),t.stage.next()}),f=t.timelines.attachTimeline(s).attachChild(p);return t.actionHistory.push(this,a=>{s.isSettled()||s.abort(),n.transformState.forceOverwrite(a.state)},[u],f),s}applyTransition(t,n,r,i){let s=new b().registerSkipController(new K(()=>(t.logger.info("Displayable Transition","Skipped"),super.executeAction(t)))),u=t.getExposedStateForce(n).applyTransition(r,()=>{i?.(),s.resolve(super.executeAction(t)),t.stage.next()}),p=t.timelines.attachTimeline(s).attachChild(u);return t.actionHistory.push(this,void 0,[],p),s}initDisplayable(t,n,r,i,s=!0){if(s!==!1){let p=t.findElementByDisplayable(this.callee,i);p&&t.disposeDisplayable(r,p.scene,i),t.createDisplayable(r,n,i)}t.flush();let c=new b().registerSkipController(new K(()=>super.executeAction(t)));t.getExposedStateAsync(r,p=>{p.initDisplayable(()=>{c.resolve(super.executeAction(t)),t.stage.next()})});let u=t.timelines.attachTimeline(c);return t.actionHistory.push(this,()=>{s!==!1&&t.findElementByDisplayable(r,i)&&t.disposeDisplayable(r,n,i)},[],u),c}};ke.ActionTypes=Ce;var tt=class extends ${executeAction(t){if(this.type===nn.play){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.play(this.callee,n),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.stop){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.stop(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.setVolume){let[n,r]=this.contentNode.getContent(),i=this.callee.toData(),s=b.forward(t.audioManager.setVolume(this.callee,n,r),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(s),t.actionHistory.push(this,c=>{c&&this.callee.fromData(c)},[i]),s}else if(this.type===nn.setRate){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.setRate(this.callee,n),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.pause){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.pause(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}else if(this.type===nn.resume){let[n]=this.contentNode.getContent(),r=this.callee.toData(),i=b.forward(t.audioManager.resume(this.callee,n.duration),{type:this.type,node:this.contentNode?.getChild()}).then(()=>t.stage.next());return t.timelines.attachTimeline(i),t.actionHistory.push(this,s=>{s&&this.callee.fromData(s)},[r]),i}throw super.unknownTypeError()}};tt.ActionTypes=nn;var Ve=class Ve extends le{static toSound(t){return t==null?null:typeof t=="string"?new Ve({src:t}):t}constructor(t={}){super();let n=typeof t=="string"?{src:t}:t,r=Ve.DefaultUserConfig.create(n),[i]=r.extract(Ve.DefaultConfig.keys());this.config=i.get(),this.state=this.getInitialState(r),this.userConfig=r}play(t){return this.pushAction(tt.ActionTypes.play,[{end:this.state.volume,duration:t||0}])}stop(t){return this.pushAction(tt.ActionTypes.stop,[{end:0,duration:t||0}])}setVolume(t,n){return this.pushAction(tt.ActionTypes.setVolume,[t,n||0])}setRate(t){return this.pushAction(tt.ActionTypes.setRate,[t])}pause(t){return this.pushAction(tt.ActionTypes.pause,[{end:0,duration:t||0}])}resume(t){return this.pushAction(tt.ActionTypes.resume,[{end:this.state.volume,duration:t||0}])}getSrc(){return this.config.src}toData(){return{state:Ve.StateSerializer.serialize(this.state)}}fromData(t){return this.state=Ve.StateSerializer.deserialize(t.state),this}copy(){return new Ve(this.userConfig.get())}reset(){this.state=this.getInitialState(this.userConfig)}getInitialState(t){return Ve.DefaultState.create({...t.get()}).get()}pushAction(t,n){return this.chain(new tt(this.chain(),t,new D().setContent(n)))}};Ve.noSound="data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgA",Ve.DefaultUserConfig=new X({src:Ve.noSound,loop:!1,volume:1,streaming:!1,rate:1,seek:0}),Ve.DefaultConfig=new X({src:Ve.noSound,loop:!1,streaming:!1,seek:0}),Ve.DefaultState=new X({volume:1,rate:1,paused:!1}),Ve.StateSerializer=new it;var lt=Ve;var Fn=class Fn{constructor(){this.src=[];this.future=[]}static catSrc(t){let n=new Set,r=new Set,i=new Set;return t.forEach(({type:s,src:c})=>{s===Fn.SrcTypes.image?n.add(c):s===Fn.SrcTypes.video?r.add(c):i.add(c)}),{image:Array.from(n),video:Array.from(r),audio:Array.from(i)}}static getSrc(t){return typeof t=="string"?t:t instanceof B?B.getSrcURL(t):t.type==="image"?B.getSrcURL(t.src):t.type==="video"?t.src:t.type==="audio"?t.src.getSrc():""}static getPreloadableSrc(t,n){if(n.is(xe,ge.jumpTo)){let r=n.contentNode.getContent()[0],s=t.getScene(r,!0).state.backgroundImage;if(k.isImageURL(s.config.src))return{type:"image",src:s.config.src,activeType:"once"}}else if(n instanceof ue){let r=n;if(n.is(ue,rt.setSrc)){let i=n.contentNode.getContent()[0];if(k.isImageSrc(i))return{type:"image",src:k.srcToURL(i),activeType:"scene"}}else{if(n.type===rt.initWearable)return{type:"image",src:n.contentNode.getContent()[0],activeType:"scene"};if(n.type===rt.setAppearance){let i=n.contentNode.getContent()[0];if(!r.callee.config.src||typeof r.callee.config.src?.resolve!="function")throw r.callee._invalidSrcHandlerError();if(B.isTagSrc(r.callee)&&i.length===r.callee.config.src.groups.length)return{type:"image",src:B.getSrcFromTags(i,r.callee.config.src.resolve),activeType:"scene"}}}}return null}register(t,n){if(Array.isArray(t))t.forEach(r=>this.register(r));else if(t instanceof lt){if(this.isSrcRegistered(t.getSrc()))return this;this.src.push({type:"audio",src:t})}else if(t instanceof B||k.isStaticImageData(t)){if(t instanceof B){if(!k.isImageURL(t.state.currentSrc))return this;if(this.isSrcRegistered(B.getSrcURL(t)))return this}else if(this.isSrcRegistered(k.srcToURL(t.src)))return this;this.src.push({type:"image",src:k.isStaticImageData(t)?k.srcToURL(t):t.state.currentSrc})}else if(typeof t=="object"){if(this.isSrcRegistered(t.src||""))return this;this.src.push(t)}else if(t==="audio"){if(this.isSrcRegistered(n||""))return this;this.src.push({type:t,src:n instanceof lt?n:new lt({src:n})})}else{if(this.isSrcRegistered(n||""))return this;this.src.push({type:t,src:n})}return this}registerRawSrc(t){return this.isSrcRegistered(t)?this:(this.src.push({type:"image",src:t}),this)}isSrcRegistered(t){if(!t)return!1;let n=t instanceof lt?t.getSrc():t;return this.src.some(r=>r.type===Fn.SrcTypes.audio?n===r.src.getSrc():r.type===Fn.SrcTypes.image?n===B.getSrcURL(r.src):n===r.src)}getSrc(){return[...this.src]}getSrcByType(t){return this.src.filter(n=>n.type===t)}registerFuture(t){return this.future.includes(t)||this.hasFuture(t)?this:(this.future.push(t),this)}hasFuture(t){return this.future.includes(t)}getFutureSrc(){return this.future.map(t=>t.getSrc()).flat(2)}};Fn.SrcTypes={image:"image",video:"video",audio:"audio"};var Ne=Fn;var Pt=class extends le{constructor(){super(...arguments);this.srcManager=new Ne}pos(n,r,i){return this.transform(new ce({position:n},{duration:r,ease:i}))}scale(n,r,i){return this.transform(new ce({scale:n},{duration:r,ease:i}))}rotate(n,r,i){return this.transform(new ce({rotation:n},{duration:r,ease:i}))}opacity(n,r,i){return this.transform(new ce({opacity:n},{duration:r,ease:i}))}transform(n){let r=this.chain(),i=new ke(r,Ce.applyTransform,new D().setContent([n.copy()]));return r.chain(i)}show(n){let r=this.chain(),i=n instanceof ce?n.copy():new ce({opacity:1},n),s=new ke(r,Ce.applyTransform,new D().setContent([i]));return r.chain(s)}hide(n){let r=this.chain(),i=n instanceof ce?n.copy():new ce({opacity:0},n),s=new ke(r,Ce.applyTransform,new D().setContent([i]));return r.chain(s)}};var ee=class ee extends Pt{static getInitialSrc(t){if(this.isTagDefinition(t.src))return[...t.src.defaults];let n=t.src;return k.isStaticImageData(n)?k.srcToURL(n):k.isColor(n)?n:k.isImageSrc(n)?k.srcToURL(n):ee.DefaultImagePlaceholder}static isTagSrc(t){return!!t.config.src}static isTagDefinition(t){return typeof t=="object"&&t!==null&&!k.isImageSrc(t)&&!k.isColor(t)&&"defaults"in t}static isStaticSrc(t){let n=t.userConfig.get().src;return!this.isTagSrc(t)&&(k.isImageSrc(n)||k.isColor(n))}static getSrcURL(t){return typeof t=="string"?t:ee.isTagSrc(t)?ee.getSrcFromTags(t.state.currentSrc,t.config.src.resolve):ee.isStaticSrc(t)?k.isStaticImageData(t.state.currentSrc)?k.srcToURL(t.state.currentSrc):k.isColor(t.state.currentSrc)?null:t.state.currentSrc:null}static getSrcFromTags(t,n){return n(...t)}static fromSrc(t){return new ee({src:t})}constructor(t={}){super();let n=ee.DefaultUserConfig.create(t),r=this.createImageConfig(n);this.userConfig=n,this.config=r.get(),this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(n),this.checkConfig().registerSrc()}char(t,n){return this.combineActions(new Bt,r=>{if(k.isImageSrc(t)||k.isColor(t)){if(k.isColor(t)&&!this.config.isBackground)throw new Error("Color src is not allowed for non-background image");return r.chain(this._setSrc(r,t,n))}else{let i=new ue(r,ue.ActionTypes.setAppearance,new D().setContent([t,n?.copy()]));return r.chain(i).chain(this._flush())}})}addWearable(t){let n=Array.isArray(t)?t:[t];for(let r of n){if(r===this)throw new me("Cannot add self as a wearable");this.config.wearables.push(r),Object.assign(r.config,{isWearable:!0})}return this}wear(t){return this.addWearable(t)}bindWearable(t){return t.addWearable([this])}asWearableOf(t){return this.bindWearable(t)}useLayer(t){return this.userConfig.get().layer=t||void 0,Object.assign(this.config,{layer:t||void 0}),this}toData(){return{state:ee.StateSerializer.serialize(this.state),transformState:Se.TransformStateSerializer.serialize(this.transformState.get())}}fromData(t){return this.state=ee.StateSerializer.deserialize(t.state),this.transformState=Se.deserialize(t.transformState),this}_applyTransition(t,n){return new ke(this.chain(),Ce.applyTransition,new D().setContent([t,n]))}_init(t,n){return new ke(this.chain(),Ce.init,new D().setContent([t,n||this.config.layer||null]))}_initWearable(t){return new ue(this.chain(),ue.ActionTypes.initWearable,new D().setContent([t]))}_flush(){return new ue(this.chain(),ue.ActionTypes.flush,new D)}reset(){return this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(this.userConfig),this}resolveTags(t,n){if(!ee.isTagSrc(this))throw new Error(`Tag not defined
|
|
14
14
|
Tag must be defined in the image config`);let r=this.constructTagMap(this.config.src.groups),i=new Map,s=[];this.config.src.groups.forEach(u=>{i.set(u,null)});let c=u=>{u.forEach(p=>{let f=r.get(p);f&&i.set(f,p)})};return c(t),c(n),this.config.src.groups.forEach(u=>{let p=i.get(u);if(!p)throw new Error(`Invalid Tag Group. Tag group "${u.join(", ")}" is not resolved`);s.push(p)}),s}_mixedSrcError(){throw new me(`Trying to mix src and tags
|
|
15
15
|
To better understand the behavior of the image, you cannot mix static src and tags in the same image. `)}_invalidSrcHandlerError(){throw new Error("Invalid src handler, If you are using tags, config.src must be a function that resolves the src from the tags. If you are using src, config.src must be a string or StaticImageData")}_invalidWearableError(t){throw new Error(`Invalid wearable
|
|
16
16
|
Wearable must be an Image with isWearable set to true
|
|
@@ -20,56 +20,56 @@ Image below violates the rule:
|
|
|
20
20
|
Tag "${s}" is conflicting with another tag
|
|
21
21
|
Error found in config.tag.defaults`);if(!r.has(s))throw new Error(`Tag not found
|
|
22
22
|
Tag "${s}" is not defined in tagDefinitions
|
|
23
|
-
Error found in config.tag.defaults`);r.get(s)?.forEach(c=>i.add(c))}}return this}constructTagMap(t){let n=new Map;for(let r of t)for(let i of r)n.set(i,r);return n}};ee.DefaultImagePlaceholder="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/6Vf9WYAAAAASUVORK5CYII=",ee.StateSerializer=new
|
|
23
|
+
Error found in config.tag.defaults`);r.get(s)?.forEach(c=>i.add(c))}}return this}constructTagMap(t){let n=new Map;for(let r of t)for(let i of r)n.set(i,r);return n}};ee.DefaultImagePlaceholder="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/6Vf9WYAAAAASUVORK5CYII=",ee.StateSerializer=new it,ee.DefaultUserConfig=new X({name:"(anonymous)",autoInit:!0,src:ee.DefaultImagePlaceholder,autoFit:!1,layer:void 0,...Se.DefaultTransformState.getDefaultConfig()},{position:t=>R.tryParsePosition(t)}),ee.DefaultImageConfig=new X({wearables:[],isWearable:!1,name:"(anonymous)",autoInit:!0,src:null,autoFit:!1,layer:void 0,isBackground:!1}),ee.DefaultImageState=new X({currentSrc:ee.DefaultImagePlaceholder});var B=ee;var Rs=class Rs extends ${static resolveTagSrc(t,n){if(!B.isTagSrc(t))throw t._mixedSrcError();let r=t.state.currentSrc,i=t.resolveTags(r,n);return B.getSrcFromTags(i,t.config.src.resolve)}static resolveCurrentSrc(t){if(B.isStaticSrc(t))return k.isImageSrc(t.state.currentSrc)?k.srcToURL(t.state.currentSrc):t.state.currentSrc;if(B.isTagSrc(t))return B.getSrcFromTags(t.state.currentSrc,t.config.src.resolve);throw t._mixedSrcError()}executeAction(t){if(this.type===rt.initWearable){let[n]=this.contentNode.getContent(),r=t.getExposedStateForce(this.callee),i=new b(s=>s);return r.createWearable(n),t.getExposedStateAsync(n,s=>{s.initDisplayable(()=>{i.resolve(super.executeAction(t)),t.stage.next()})}),t.actionHistory.push(this,s=>{r.disposeWearable(s)},[n]),i}else if(this.type===rt.setSrc){let n=this.contentNode.getContent()[0];if(k.isColor(n)&&!this.callee.config.isBackground)throw new me("Color src is not allowed for non-background image");let r=this.callee.state.currentSrc;return this.callee.state.currentSrc=n,t.logger.debug("Image Set Src",n),t.actionHistory.push(this,i=>{this.callee.state.currentSrc=i},[r]),t.stage.update(),super.executeAction(t)}else{if(this.type===rt.flush)return super.executeAction(t);if(this.type===rt.setAppearance){let[n,r]=this.contentNode.getContent();if(!B.isTagSrc(this.callee))throw this.callee._mixedSrcError();let i=this.callee.state.currentSrc,s=this.callee.resolveTags(i,n),c=[...i],u=B.getSrcFromTags(s,this.callee.config.src.resolve),p=()=>{this.callee.state.currentSrc=c};if(t.logger.debug("Image - Set Appearance",s,u),r){let f=new b(m=>m).registerSkipController(new K(()=>super.executeAction(t)));r._setPrevSrc(Rs.resolveCurrentSrc(this.callee))._setTargetSrc(u),t.getExposedStateForce(this.callee).applyTransition(r,()=>{this.callee.state.currentSrc=s,f.resolve(super.executeAction(t)),t.stage.next()});let l=t.timelines.attachTimeline(f);return t.actionHistory.push(this,p,[],l),f}return this.callee.state.currentSrc=s,t.actionHistory.push(this,p),super.executeAction(t)}}throw super.unknownTypeError()}};Rs.ActionTypes=rt;var ue=Rs;var Wt=class Wt extends ${static handleSceneInit(t,n,r,i){return r.isSceneActive(t)?n:(r.registerSrcManager(t.srcManager).addScene(t).flush(),t.local.init(r.getStorable()),r.getExposedStateAsync(t,s=>{Wt.initBackgroundMusic(t,s),i.resolve(n),r.stage.next(),r.logger.debug("Scene Action","Scene init")}),i)}static initBackgroundMusic(t,n){t.state.backgroundMusic&&n.setBackgroundMusic(t.state.backgroundMusic,t.config.backgroundMusicFade)}static createSceneSnapshot(t,n){let r=n.findElementByScene(t);if(!r)throw new me("Scene not found when creating snapshot (scene: "+t.getId()+")");return{state:t.toData(),local:t.local.getNamespace(n.getStorable()).toData(),element:n.createElementSnapshot(r),background:t.background.toData()}}static restoreSceneSnapshot(t,n){let r=t.element.scene,i=n.findElementByScene(r);i&&n.removeElement(i);let s=n.fromElementSnapshot(t.element);n.addElement(s),r.local.getNamespace(n.getStorable()).load(t.local),t.state&&r.fromData(t.state),t.background&&r.background.fromData(t.background)}applyTransition(t,n){let r=new b().registerSkipController(new K(()=>(t.logger.info("Background Transition","Skipped"),super.executeAction(t))));return t.getExposedStateForce(this.callee.background).applyTransition(n,()=>{r.resolve(super.executeAction(t)),t.stage.next()}),t.timelines.attachTimeline(r),r}exit(t){t.offSrcManager(this.callee.srcManager).removeScene(this.callee),this.callee.state.backgroundImage.reset()}executeAction(t){if(this.type===ge.action)return super.executeAction(t);if(this.is(Wt,"scene:init")){let n=new b(i=>i),r=t.timelines.attachTimeline(n);return t.actionHistory.push(this,()=>{this.exit(t)},[],r),Wt.handleSceneInit(this.callee,{type:this.type,node:this.contentNode.getChild()},t,n)}else if(this.type===ge.exit){let n=Wt.createSceneSnapshot(this.callee,t);return t.actionHistory.push(this,r=>{let i=new b(s=>s);t.timelines.attachTimeline(i),Wt.handleSceneInit(this.callee,{type:this.type,node:this.contentNode.getChild()},t,i),Wt.restoreSceneSnapshot(r,t)},[n]),t.getStorable().removeNamespace(this.callee.local.getNamespaceName()),this.exit(t),super.executeAction(t)}else if(this.type===ge.jumpTo){let n=this.contentNode.getContent()[0],r=this.contentNode,i=t.getStory().getScene(n);if(!i)throw this._sceneNotFoundError(this.getSceneName(n));let s=i.getSceneRoot().contentNode;return s&&r.addChild(s),{type:this.type,node:s}}else if(this.type===ge.setBackgroundMusic){let[n,r]=this.contentNode.getContent(),i=this.callee,s=t.getExposedStateForce(i),c=i.state.backgroundMusic;return t.actionHistory.push(this,u=>{u&&s.setBackgroundMusic(u,0)},[c]),s.setBackgroundMusic(n,r||0),super.executeAction(t)}else{if(this.type===ge.preUnmount)return this.callee.events.emit("event:scene.preUnmount"),super.executeAction(t);if(this.type===ge.transitionToScene){let[n,r,i]=this.contentNode.getContent();return n._setPrevSrc(ue.resolveCurrentSrc(this.callee.background)),r?n._setTargetSrc(ue.resolveCurrentSrc(r.background)):i&&n._setTargetSrc(i),this.applyTransition(t,n)}}throw new Error("Unknown scene action type: "+this.type)}getFutureActions(t,n={}){if(this.type===ge.jumpTo&&n.allowFutureScene!==!1){let i=this.contentNode.getContent()[0],s=t.getScene(i,!0);s.isSceneRootConstructed()||s.constructSceneRoot(t);let c=t.getScene(i,!0).getSceneRoot()?.contentNode;return c?.action?[c.action]:[]}let r=this.contentNode.getChild()?.action;return r?[r]:[]}_sceneNotFoundError(t){return new me(`Scene with name ${t} not found
|
|
24
24
|
Make sure you have registered the scene using story.register
|
|
25
25
|
Action: (id: ${this.getId()}) ${this.type}
|
|
26
|
-
At: ${this.__stack}`)}getSceneName(t){return typeof t=="string"?t:t.config.name}};
|
|
26
|
+
At: ${this.__stack}`)}getSceneName(t){return typeof t=="string"?t:t.config.name}};Wt.ActionTypes=ge;var xe=Wt;var Ke=class o{static from(t){return o.isPauseConstructor(t)?new o:t}static wait(t){return new o({duration:t})}static isPause(t){return this.isPauseConstructor(t)||t instanceof o}static isPauseConstructor(t){return t===o}constructor(t={}){this.config=t}};var De=class De{static isWord(t){return t instanceof De}static color(t,n){return De.isWord(t)?t.copy().assign({color:n}):new De(t,{color:n})}static bold(t){return De.isWord(t)?t.copy().assign({bold:!0}):new De(t,{bold:!0})}static italic(t){return De.isWord(t)?t.copy().assign({italic:!0}):new De(t,{italic:!0})}static getText(t){return t.filter(n=>!n.isPause()).map(n=>n.toString()).join("")}constructor(t,n={}){this.text=t,this.config=U(De.defaultConfig,n)}evaluate(t){if(Ke.isPause(this.text))return[this];if(typeof this.text=="function"){let n=this.text(t);return Array.isArray(n)?n.map(r=>De.isWord(r)?r.inherit(this.config).evaluate(t):new De(r,this.config)).flat():De.isWord(n)?n.inherit(this.config).evaluate(t):[new De(n,this.config)]}return[this]}inherit(t){return this.config.color=this.config.color||t.color,this.config.italic=this.config.italic??t.italic,this.config.bold=this.config.bold??t.bold,this.config.cps=this.config.cps??t.cps,this}assign(t){return this.config=U(this.config,t),this}copy(){return new De(this.text,this.config)}isPause(){return Ke.isPause(this.text)}toString(){return typeof this.text=="string"?this.text:""}};De.defaultConfig={},De.defaultColor="#000";var Z=De;var wc=class o{static isHexString(t){return typeof t!="string"?!1:/^#[0-9A-F]{6}$/i.test(t)}static fromHex(t){let n=t.slice(1),r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),s=parseInt(n.slice(4,6),16),c=n.length===8?parseInt(n.slice(6,8),16)/255:1;return new o(r,i,s,c)}constructor(t,n,r,i=1){this.r=t,this.g=n,this.b=r,this.a=i}toString(){return`rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`}toHex(){return"#"+this.r.toString(16)+this.g.toString(16)+this.b.toString(16)}},gt=class gt{static srcToURL(t){return typeof t=="string"?t:t.src}static staticImageDataToSrc(t){return typeof t=="string"?t:t.src}static isStaticImageData(t){return t?.src!==void 0&&typeof t.src=="string"}static isExternalSrc(t){return t.startsWith("http://")||t.startsWith("https://")}static isImageSrc(t){return typeof t=="string"&&!this.isColor(t)||gt.isStaticImageData(t)}static isImageURL(t){return typeof t=="string"&&!this.isColor(t)}static isColor(t){return gt.isHexString(t)||gt.isNamedColor(t)||gt.isRGBAColor(t)}static isNamedColor(t){return Ml(t)}static isRGBAColor(t){return t&&typeof t=="object"&&"r"in t&&"g"in t&&"b"in t}static RGBAColorToHex(t){let n=t.r.toString(16).padStart(2,"0"),r=t.g.toString(16).padStart(2,"0"),i=t.b.toString(16).padStart(2,"0"),s=t.a?Math.round(t.a*255).toString(16).padStart(2,"0"):"";return`#${n}${r}${i}${s}`}static colorToString(t){if(gt.isHexString(t))return t;if(gt.isNamedColor(t))return t;if(gt.isRGBAColor(t))return gt.RGBAColorToHex(t);throw new Error("Unknown color type")}static isHexString(t){return typeof t!="string"?!1:/^#([0-9A-F]{3}|[0-9A-F]{6}|[0-9A-F]{4}|[0-9A-F]{8})$/i.test(t)}static toBackgroundSrc(t){return typeof t=="string"?t:t.src}static isDataURI(t){return t.startsWith("data:")}static offset(t,n,r={invertX:!1,invertY:!1}){let[i,s]=t,[c,u]=n,p=this.calc(i,c),f=this.calc(s,u),a=r.invertX?{right:p}:{left:p},l=r.invertY?{bottom:f}:{top:f};return{left:"auto",right:"auto",top:"auto",bottom:"auto",...a,...l}}static calc(t,n){let r=typeof t=="string"?t:`${t}px`;if(n===void 0)return`calc(${r} + 0px)`;let i=typeof n=="string"?"+":n<0?"-":"+",s=typeof n=="string"?n:`${Math.abs(n)}px`;return`calc(${r} ${i} ${s})`}static formatLength(t){return typeof t=="number"?`${t}px`:t}static toPixel(t){return typeof t=="number"?t:parseFloat(t)}};gt.RGBColor=wc;var k=gt,Pc=class o extends Error{static isUseError(t){return t instanceof o}constructor(t,n,r="UseError"){super(t),this.props=n,this.name=r}},xn=class o extends Pc{static isWarning(t){return t instanceof o}constructor(t,n){super(t,{info:n},"StaticScriptWarning")}},Is=class{constructor(t){this.scene=t}run(t){let n=new Map,r=new Map,i=[],s=new Set,c=this.scene.getAllChildren(t,this.scene.getSceneRoot());if(!c.length)return null;for(i.push(c[0]);i.length;){let u=i.shift();this.checkAction(t,u,{imageStates:n,scenes:r},s);let p=u.contentNode.getChild();p&&p.action&&i.push(p.action)}return n}checkAction(t,n,{imageStates:r,scenes:i},s){if(n instanceof ue)r.has(n.callee)||r.set(n.callee,{isDisposed:!1,usedExternalSrc:!1}),this.checkImage(r.get(n.callee),n);else if(n instanceof xe){let c=n.callee;if(i.has(c.config.name)){if(i.get(c.config.name)!==c){let u=`Scene with name: ${c.config.name} is duplicated
|
|
27
27
|
Scene: ${c.config.name}
|
|
28
28
|
|
|
29
|
-
At: ${n.__stack}`;throw new xn(u)}}else i.set(c.config.name,c);if(n.type===ge.jumpTo){let u=n.contentNode.getContent()[0],p=t.getScene(u,!0);if(s.has(p))return;s.add(p)}}}checkImage(t,n){if(n.type===
|
|
29
|
+
At: ${n.__stack}`;throw new xn(u)}}else i.set(c.config.name,c);if(n.type===ge.jumpTo){let u=n.contentNode.getContent()[0],p=t.getScene(u,!0);if(s.has(p))return;s.add(p)}}}checkImage(t,n){if(n.type===rt.setSrc){let i=n.contentNode.getContent()[0];k.isImageURL(i)&&k.isExternalSrc(i)&&(t.usedExternalSrc=!0)}}},me=class o extends Error{static toMessage(t,n){let r=[];return r.push(...Array.isArray(t)?t:[t]),n&&r.push(...Array.isArray(n)?n.map(o.getActionTrace):[o.getActionTrace(n)]),r.join("")}static getActionTrace(t){return`
|
|
30
30
|
Using action (id: ${t.getId()})
|
|
31
|
-
at: ${t.__stack}`}constructor(t,n){super(o.toMessage(t,n)),this.name="RuntimeScriptError"}},M=class extends Error{constructor(t){super(t),this.name="RuntimeGameError"}},Dr=class extends Error{constructor(t){super(t),this.name="RuntimeInternalError"}};function tT(o,t){return Z.color(o,t)}function nT(o){return Z.bold(o)}function oT(o){return Z.italic(o)}var qe=class qe{static isSentence(t){return t instanceof qe}static toSentence(t){return qe.isSentence(t)?t:new qe(t)}static format(t){let n=[];if(Array.isArray(t))for(let r=0;r<t.length;r++)n.push(this.formatWord(t[r]));else n.push(this.formatWord(t));return n}static formatWord(t){return Z.isWord(t)?t:new Z(t)}static formatStaticWord(t,n){return Array.isArray(t)?t.map(r=>this.formatStaticWord(r,n)).flat(2):[Z.isWord(t)?t:new Z(t,n)]}static isSentencePrompt(t){return Array.isArray(t)?t.every(qe.isSingleWord):qe.isSingleWord(t)}static isSingleWord(t){return typeof t=="string"||Z.isWord(t)||Ke.isPause(t)||typeof t=="function"}constructor(t,n={}){this.text=qe.format(t),this.config=U(qe.defaultConfig,{...n,voice:
|
|
31
|
+
at: ${t.__stack}`}constructor(t,n){super(o.toMessage(t,n)),this.name="RuntimeScriptError"}},M=class extends Error{constructor(t){super(t),this.name="RuntimeGameError"}},Dr=class extends Error{constructor(t){super(t),this.name="RuntimeInternalError"}};function tT(o,t){return Z.color(o,t)}function nT(o){return Z.bold(o)}function oT(o){return Z.italic(o)}var qe=class qe{static isSentence(t){return t instanceof qe}static toSentence(t){return qe.isSentence(t)?t:new qe(t)}static format(t){let n=[];if(Array.isArray(t))for(let r=0;r<t.length;r++)n.push(this.formatWord(t[r]));else n.push(this.formatWord(t));return n}static formatWord(t){return Z.isWord(t)?t:new Z(t)}static formatStaticWord(t,n){return Array.isArray(t)?t.map(r=>this.formatStaticWord(r,n)).flat(2):[Z.isWord(t)?t:new Z(t,n)]}static isSentencePrompt(t){return Array.isArray(t)?t.every(qe.isSingleWord):qe.isSingleWord(t)}static isSingleWord(t){return typeof t=="string"||Z.isWord(t)||Ke.isPause(t)||typeof t=="function"}constructor(t,n={}){this.text=qe.format(t),this.config=U(qe.defaultConfig,{...n,voice:lt.toSound(n.voice)}),this.state=kl(qe.defaultState)}toData(){return null}fromData(t){return this.state=U(this.state,t),this}toString(){return this.text.map(t=>t.text).join("")}setCharacter(t){return this.config.character=t,this}evaluate(t){let n=[];for(let r=0;r<this.text.length;r++){let i=this.text[r].evaluate(t);n.push(...qe.formatStaticWord(i))}return n}copy(){return new qe([...this.text],this.config)}};qe.defaultConfig={pause:!0,voice:null,character:null,voiceId:null},qe.defaultState={};var Re=qe;var Ls=class Ls extends ${static getVoice(t,n){let r=t.getLastScene();if(!r)throw new Error("No scene found when trying to play voice");let{voiceId:i,voice:s}=n.config;return!i&&!s?null:lt.toSound(r.getVoice(i)||s)}executeAction(t){if(this.type===jr.say){let n=new b(p=>p).registerSkipController(new K(()=>{c.cancel()})),r=new ne(n),i=this.contentNode.getContent(),s=Ls.getVoice(t,i);if(s){let p=t.audioManager.play(s);r.attachChild(p)}let c=t.createDialog(this.getId(),i,()=>{if(s){let p=t.audioManager.stop(s);r.attachChild(p)}n.resolve({type:this.type,node:this.contentNode.getChild()})});t.timelines.attachTimeline(r);let{id:u}=t.actionHistory.push(this,()=>{if(s&&t.audioManager.isPlaying(s)){let p=t.audioManager.stop(s);r.attachChild(p)}});return t.gameHistory.push({token:u,action:this,element:{type:"say",text:c.text,voice:s?s.getSrc():null}}),n}else if(this.type===jr.setName){let n=this.callee.state.name;return this.callee.state.name=this.contentNode.getContent()[0],t.actionHistory.push(this,r=>{this.callee.state.name=r},[n]),super.executeAction(t)}throw super.unknownTypeError()}};Ls.ActionTypes=jr;var jt=Ls;var Rr=class Rr extends le{constructor(t,n={}){super(),this.config=U(Rr.defaultConfig,n),this.state={name:t||""}}say(t,n,...r){if(Array.isArray(t)&&t.every(p=>typeof p=="string")&&[n,...r].length>0&&[n,...r].every(p=>Re.isSingleWord(p))){let p=t,f=Re.format([n,...r]),a=new Re(Il(p,f),{character:this}),l=new jt(this.chain(),jt.ActionTypes.say,new D().setContent(a));return this.chain(l)}let i=n||{},s=t,c=Array.isArray(s)?new Re(s,{...i,character:this}):(Re.isSentence(s)?s:new Re(s,{...i,character:this})).copy();c.setCharacter(this);let u=new jt(this.chain(),jt.ActionTypes.say,new D().setContent(c));return this.chain(u)}setName(t){let n=new jt(this.chain(),jt.ActionTypes.setName,new D().setContent([t]));return this.chain(n)}apply(t,n,...r){return this.say.apply(this,[t,n,...r])}};Rr.defaultCharacterColor="#000",Rr.defaultConfig={};var Ec=Rr;var bn=class extends ${executeAction(t){let n=this.callee.evaluate(this.contentNode.getContent(),{gameState:t});return n?.[n.length-1]?.contentNode.addChild(this.contentNode.getChild()),this.contentNode.addChild(n?.[0]?.contentNode||null),{type:this.type,node:this.contentNode.getChild()}}getFutureActions(t,n){return[...this.callee._getFutureActions(),...super.getFutureActions(t,n)]}};bn.ActionTypes=Cl;var Be=class o{static isLambda(t){return t instanceof o&&"handler"in t}static from(t){return o.isLambda(t)?t:new o(t)}constructor(t){this.handler=t}evaluate({gameState:t}){return{value:this.handler(this.getCtx({gameState:t}))}}getCtx({gameState:t}){return{gameState:t,game:t.game,liveGame:t.game.getLiveGame(),storable:t.game.getLiveGame().getStorable()}}},kc=class o extends le{constructor(){super();this.conditions={If:{condition:null,action:null},ElseIf:[],Else:{action:null}}}static getInitialState(){return{If:{condition:null,action:null},ElseIf:[],Else:{action:null}}}static If(n,r){return new o().createIfCondition(n,r)}ElseIf(n,r){if(this.conditions.Else.action)throw new xn(`ELSE condition already set
|
|
32
32
|
You are trying to set an ELSE-IF condition after an ELSE condition`);return this.conditions.ElseIf.push({condition:Be.isLambda(n)?n:new Be(n),action:this.construct(Array.isArray(r)?r:[r])}),this.chain()}Else(n){if(this.conditions.Else.action)throw new xn(`ELSE condition already set
|
|
33
|
-
You are trying to set multiple ELSE conditions for the same condition`);return this.conditions.Else.action=this.construct(Array.isArray(n)?n:[n]),this.chain()}evaluate(n,{gameState:r}){let i={gameState:r};if(n.If.condition?.evaluate(i)?.value)return n.If.action||null;for(let c of n.ElseIf)if(c.condition?.evaluate(i)?.value)return c.action||null;return n.Else.action||null}fromChained(n){return[Reflect.construct(bn,[this,bn.ActionTypes.action,new D().setContent(n.conditions)])]}construct(n,r,i){let s=Ee.toActions(n);for(let c=0;c<s.length;c++){let u=s[c].contentNode,p=s[c+1]?.contentNode;p&&u.setChild(p),c===s.length-1&&r&&u.setChild(r),c===0&&i&&i.setChild(u)}return s}_getFutureActions(){return Ee.toActions([this.conditions.If.action?.[0]||[],...this.conditions.ElseIf.flatMap(n=>n.action?.[0]||[]),this.conditions.Else.action?.[0]||[]])}createIfCondition(n,r){return this.conditions.If.condition=n instanceof Be?n:new Be(n),this.conditions.If.action=this.construct(Array.isArray(r)?r:[r]),this.chain()}};var On=class extends ${executeAction(t){let n=new b().registerSkipController(new K(()=>{s.cancel()})),r=t.timelines.attachTimeline(n),i=this.contentNode.getContent(),s=t.createMenu(i,c=>{let u=t.game.getLiveGame().getCurrentAction()?.contentNode.getChild()||null;u&&c.action[c.action.length-1]?.contentNode.addChild(u),n.resolve({type:this.type,node:c.action[0].contentNode});let{id:p}=t.actionHistory.push(this,void 0,[],r);t.gameHistory.push({token:p,action:this,element:{type:"menu",text:s.prompt,selected:c.evaluated}})});return n}getFutureActions(t,n){let r=this.contentNode.getContent();return[...this.callee._getFutureActions(r.choices),...super.getFutureActions(t,n)]}};On.ActionTypes=Pl;var Hn=class Hn extends le{constructor(n,r={}){super();this.choices=[];this.prompt=Re.isSentence(n)?n:n===null?null:new Re(n),this.config=U(Hn.defaultConfig,r)}static prompt(n,r={}){return new Hn(n,r)}static choose(n,r){return new Hn(null,{}).choose(n,r)}choose(n,r){let i=this.chain();return Re.isSentence(n)&&r?i.choices.push({prompt:Re.toSentence(n),action:Ee.toActions(r)}):(Z.isWord(n)||Array.isArray(n)||typeof n=="string")&&r?i.choices.push({prompt:Re.toSentence(n),action:Ee.toActions(r)}):typeof n=="object"&&"prompt"in n&&"action"in n?i.choices.push({prompt:Re.toSentence(n.prompt),action:Ee.toActions(n.action)}):console.warn("No valid choice added to menu, ",{arg0:n,arg1:r}),i}fromChained(n){return[new On(this.chain(),On.ActionTypes.action,new D().setContent({prompt:this.prompt,choices:n.constructChoices()}))]}_getFutureActions(n){return n.map(r=>r.action[0]||null).filter(r=>r!==null)}constructNodes(n,r,i){for(let s=0;s<n.length;s++){let c=n[s].contentNode,u=n[s+1]?.contentNode;u&&c.setChild(u),s===this.choices.length-1&&r&&c.setChild(r),s===0&&i&&i.setChild(c)}return n}constructChoices(){return this.choices.map(n=>({action:this.constructNodes(n.action),prompt:n.prompt}))}};Hn.defaultConfig={},Hn.targetAction=On;var Dc=Hn;var Uo=class extends Ho{constructor(){super()}fromChained(t){return t.getActions()}forEachChild(t,n,r,i={}){let s=new Set,c=[];for(Array.isArray(n)?c.push(...n):c.push(n);c.length;){let u=c.shift();if(s.has(u))continue;s.add(u),r(u);let p=u.getFutureActions(t,i).filter(f=>!s.has(f));c.push(...p)}}getAllChildren(t,n,r={}){let i=[];return this.forEachChild(t,n,s=>i.push(s),r),i}getAllChildrenMap(t,n){let r=new Map;return this.forEachChild(t,n,i=>r.set(i.getId(),i)),r}getAllElementMap(t,n,r={}){let i=new Map;return this.forEachChild(t,n,s=>i.set(s.callee.getId(),s.callee),r),i}getAllChildrenElements(t,n,r={}){return Array.from(new Set(this.getAllChildren(t,n,r).map(i=>i.callee)))}toData(){return null}constructNodes(t,n){for(let r=0;r<t.length;r++){let i=t[r];r===0&&n?n.setChild(i.contentNode):r>0&&t[r-1].contentNode?.setChild(i.contentNode)}return t.length?t[0].contentNode:null}};var An=class extends ${executeAction(t){if(this.type===$r.setText){let n=this.callee.state.text;return this.callee.state.text=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,r=>{this.callee.state.text=r},[n]),super.executeAction(t)}else if(this.type===$r.setFontSize){let n=this.callee.state.fontSize;return this.callee.state.fontSize=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,r=>{this.callee.state.fontSize=r},[n]),super.executeAction(t)}throw super.unknownTypeError()}};An.ActionTypes=$r;var Ko=(n=>(n[n.Number=0]="Number",n[n.HexColor=1]="HexColor",n))(Ko||{});var
|
|
34
|
-
This should not happen, please report this issue to the developers`);return this._element.state}};var
|
|
33
|
+
You are trying to set multiple ELSE conditions for the same condition`);return this.conditions.Else.action=this.construct(Array.isArray(n)?n:[n]),this.chain()}evaluate(n,{gameState:r}){let i={gameState:r};if(n.If.condition?.evaluate(i)?.value)return n.If.action||null;for(let c of n.ElseIf)if(c.condition?.evaluate(i)?.value)return c.action||null;return n.Else.action||null}fromChained(n){return[Reflect.construct(bn,[this,bn.ActionTypes.action,new D().setContent(n.conditions)])]}construct(n,r,i){let s=Ee.toActions(n);for(let c=0;c<s.length;c++){let u=s[c].contentNode,p=s[c+1]?.contentNode;p&&u.setChild(p),c===s.length-1&&r&&u.setChild(r),c===0&&i&&i.setChild(u)}return s}_getFutureActions(){return Ee.toActions([this.conditions.If.action?.[0]||[],...this.conditions.ElseIf.flatMap(n=>n.action?.[0]||[]),this.conditions.Else.action?.[0]||[]])}createIfCondition(n,r){return this.conditions.If.condition=n instanceof Be?n:new Be(n),this.conditions.If.action=this.construct(Array.isArray(r)?r:[r]),this.chain()}};var On=class extends ${executeAction(t){let n=new b().registerSkipController(new K(()=>{s.cancel()})),r=t.timelines.attachTimeline(n),i=this.contentNode.getContent(),s=t.createMenu(i,c=>{let u=t.game.getLiveGame().getCurrentAction()?.contentNode.getChild()||null;u&&c.action[c.action.length-1]?.contentNode.addChild(u),n.resolve({type:this.type,node:c.action[0].contentNode});let{id:p}=t.actionHistory.push(this,void 0,[],r);t.gameHistory.push({token:p,action:this,element:{type:"menu",text:s.prompt,selected:c.evaluated}})});return n}getFutureActions(t,n){let r=this.contentNode.getContent();return[...this.callee._getFutureActions(r.choices),...super.getFutureActions(t,n)]}};On.ActionTypes=Pl;var Hn=class Hn extends le{constructor(n,r={}){super();this.choices=[];this.prompt=Re.isSentence(n)?n:n===null?null:new Re(n),this.config=U(Hn.defaultConfig,r)}static prompt(n,r={}){return new Hn(n,r)}static choose(n,r){return new Hn(null,{}).choose(n,r)}choose(n,r){let i=this.chain();return Re.isSentence(n)&&r?i.choices.push({prompt:Re.toSentence(n),action:Ee.toActions(r)}):(Z.isWord(n)||Array.isArray(n)||typeof n=="string")&&r?i.choices.push({prompt:Re.toSentence(n),action:Ee.toActions(r)}):typeof n=="object"&&"prompt"in n&&"action"in n?i.choices.push({prompt:Re.toSentence(n.prompt),action:Ee.toActions(n.action)}):console.warn("No valid choice added to menu, ",{arg0:n,arg1:r}),i}fromChained(n){return[new On(this.chain(),On.ActionTypes.action,new D().setContent({prompt:this.prompt,choices:n.constructChoices()}))]}_getFutureActions(n){return n.map(r=>r.action[0]||null).filter(r=>r!==null)}constructNodes(n,r,i){for(let s=0;s<n.length;s++){let c=n[s].contentNode,u=n[s+1]?.contentNode;u&&c.setChild(u),s===this.choices.length-1&&r&&c.setChild(r),s===0&&i&&i.setChild(c)}return n}constructChoices(){return this.choices.map(n=>({action:this.constructNodes(n.action),prompt:n.prompt}))}};Hn.defaultConfig={},Hn.targetAction=On;var Dc=Hn;var Uo=class extends Ho{constructor(){super()}fromChained(t){return t.getActions()}forEachChild(t,n,r,i={}){let s=new Set,c=[];for(Array.isArray(n)?c.push(...n):c.push(n);c.length;){let u=c.shift();if(s.has(u))continue;s.add(u),r(u);let p=u.getFutureActions(t,i).filter(f=>!s.has(f));c.push(...p)}}getAllChildren(t,n,r={}){let i=[];return this.forEachChild(t,n,s=>i.push(s),r),i}getAllChildrenMap(t,n){let r=new Map;return this.forEachChild(t,n,i=>r.set(i.getId(),i)),r}getAllElementMap(t,n,r={}){let i=new Map;return this.forEachChild(t,n,s=>i.set(s.callee.getId(),s.callee),r),i}getAllChildrenElements(t,n,r={}){return Array.from(new Set(this.getAllChildren(t,n,r).map(i=>i.callee)))}toData(){return null}constructNodes(t,n){for(let r=0;r<t.length;r++){let i=t[r];r===0&&n?n.setChild(i.contentNode):r>0&&t[r-1].contentNode?.setChild(i.contentNode)}return t.length?t[0].contentNode:null}};var An=class extends ${executeAction(t){if(this.type===$r.setText){let n=this.callee.state.text;return this.callee.state.text=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,r=>{this.callee.state.text=r},[n]),super.executeAction(t)}else if(this.type===$r.setFontSize){let n=this.callee.state.fontSize;return this.callee.state.fontSize=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,r=>{this.callee.state.fontSize=r},[n]),super.executeAction(t)}throw super.unknownTypeError()}};An.ActionTypes=$r;var Ko=(n=>(n[n.Number=0]="Number",n[n.HexColor=1]="HexColor",n))(Ko||{});var Et=class{requestAnimations(t){let n=t.map(l=>l.start),r=[],i=0,s=[],c=[],u=[];return{onUpdate:l=>(s.push(l),{cancel:()=>{let m=s.indexOf(l);m!==-1&&s.splice(m,1)}}),onComplete:l=>(c.push(l),{cancel:()=>{let m=c.indexOf(l);m!==-1&&c.splice(m,1)}}),onCanceled:l=>(u.push(l),{cancel:()=>{let m=u.indexOf(l);m!==-1&&u.splice(m,1)}}),complete:()=>{i!==t.length&&r.forEach(l=>l.complete())},start:()=>{if(r.length>0)throw new Error("Animation controllers are already started");t.forEach((l,m)=>{r.push(this.requestMotion(l,{onComplete:()=>{n[m]=l.end,s.forEach(d=>d(n)),i++,i===t.length&&c.forEach(d=>d())},onUpdate:d=>{n[m]=d,s.forEach(h=>h(n))}}))})},cancel:()=>{r.forEach(l=>l.cancel()),u.forEach(l=>l())}}}toFinalStyle(t){return t.resolve.map(n=>typeof n=="function"?n(...t.animations.map(r=>r.end)):n.resolver(...t.animations.map(r=>r.end)))}asPrev(t){return{resolver:t,key:"current"}}asTarget(t){return{resolver:t,key:"target"}}requestMotion(t,n){return Er(t.start,t.end,{duration:t.duration/1e3,onUpdate:r=>{n.onUpdate&&n.onUpdate(r)},onComplete:()=>{n.onComplete&&n.onComplete()},ease:t.ease})}};Et.AnimationType=Ko;var Ir=class extends Et{_setElement(t){return this._element=t,this}getTextState(){if(this._element===void 0)throw new M(`Trying to access text state, but element is not set
|
|
34
|
+
This should not happen, please report this issue to the developers`);return this._element.state}};var _s=class o extends Ir{constructor(n,r,i){super();this.textSize=n;this.duration=r;this.easing=i}createTask(){return{animations:[{type:0,start:this.getTextState().fontSize,end:this.textSize,duration:this.duration,ease:this.easing}],resolve:[this.asTarget(n=>({style:{fontSize:`${n}px`}}))]}}copy(){return new o(this.textSize,this.duration,this.easing)}};var Xe=class Xe extends Pt{constructor(t,n={}){super();let r=typeof t=="string"?{...n,text:t}:t,i=Xe.DefaultUserConfig.create(r),s=Xe.DefaultTextConfig.create(i.get());this.userConfig=i,this.config=s.get(),this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(i)}setText(t){let n=this.chain(),r=new An(n,An.ActionTypes.setText,new D().setContent([t]));return n.chain(r)}setFontColor(t,n=0,r){return this.transform(new ce({fontColor:t},{duration:n,ease:r}))}setFontSize(t,n=0,r){return this.combineActions(new Bt,i=>{if(n){let c=new _s(t,n,r);i.chain(this._applyTransition(i,c))}let s=new An(i,An.ActionTypes.setFontSize,new D().setContent([t]));return i.chain(s)})}useLayer(t){return this.userConfig.get().layer=t,Object.assign(this.config,{layer:t}),this}toData(){return{state:Xe.StateSerializer.serialize(this.state),transformState:this.transformState.serialize()}}fromData(t){return this.state=Xe.StateSerializer.deserialize(t.state),this.transformState=Se.deserialize(t.transformState),this}_init(t){return new ke(this.chain(),Ce.init,new D().setContent([t||null,this.config.layer||null]))}reset(){this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(this.userConfig)}getInitialTransformState(t){let[n]=t.extract(Xe.DefaultTextTransformState.keys());return new Se(Xe.DefaultTextTransformState.create(n.get()).get())}_applyTransition(t,n){return new ke(t,Ce.applyTransition,new D().setContent([n,r=>r._setElement(this)]))}getInitialState(){return Xe.DefaultTextState.create({fontSize:this.userConfig.get().fontSize,text:this.userConfig.get().text}).get()}};Xe.DefaultUserConfig=new X({alignX:"center",alignY:"center",className:"",fontSize:16,fontColor:"#000000",text:""}),Xe.DefaultTextConfig=new X({alignX:"center",alignY:"center",className:"",layer:void 0}),Xe.DefaultTextState=new X({fontSize:16,display:!1,text:""}),Xe.DefaultTextTransformState=new X({fontColor:"#000000",...Se.DefaultTransformState.getDefaultConfig()}),Xe.StateSerializer=new it;var Un=Xe;var Lr=class Lr extends ${executeAction(t){let n=this;if(n.is(Lr,"persistent:set")){let[r,i]=n.contentNode.getContent(),s=t.getStorable().getNamespace(n.callee.getNamespaceName()),c=s.get(r);if(typeof i=="function"){let u=s.get(r);s.set(r,i(u))}else s.set(r,i);return t.actionHistory.push(this,u=>{s.set(r,u)},[c]),super.executeAction(t)}else if(n.is(Lr,"persistent:assign")){let[r]=n.contentNode.getContent(),i=t.getStorable().getNamespace(n.callee.getNamespaceName()),s={};return Object.keys(r).forEach(c=>{s[c]=i.get(c),i.set(c,r[c])}),t.actionHistory.push(this,c=>{Object.keys(c).forEach(u=>{i.set(u,c[u])})},[s]),super.executeAction(t)}throw this.unknownTypeError()}};Lr.ActionTypes=or;var Ms=Lr;var $t=class o{static isSerializable(t){return["number","string","boolean"].includes(typeof t)||t instanceof Date||t==null?!0:Array.isArray(t)?t.every(o.isSerializable):typeof t=="object"?Object.getPrototypeOf(t)===Object.prototype&&Object.values(t).every(o.isSerializable):!1}constructor(t,n,r){this.name=t,this.key=r||t,this.content=U({},n),this.defaultContent=n}set(t,n){return o.isSerializable(n)?(this.content[t]=n,this):(console.warn(`Value "${n}" in key "${String(t)}" is not serializable, and will not be set
|
|
35
35
|
at namespace "${this.name}"`),this.content[t]=n,this)}get(t){return this.content[t]}equals(t,n){return this.content[t]===n}assign(t){return Object.entries(t).forEach(([n,r])=>{this.set(n,r)}),this}reset(){return this.content=U({},this.defaultContent),this}toData(){return this.serialize()}load(t){if(!t){console.warn("No data to load");return}this.content=t}serialize(){let t={};return Object.entries(this.content).forEach(([n,r])=>{t[n]=this.wrap(r)}),t}deserialize(t){if(!t){console.warn("No data to load");return}Object.entries(t).forEach(([n,r])=>{this.content[n]=this.unwrap(r)})}toTypeName(t){return t instanceof Date?"date":"any"}wrap(t){let n={any:i=>({type:"any",data:i}),date:i=>({type:"date",data:i.toString()})},r=this.toTypeName(t);return n[r](t)}unwrap(t){return{any:r=>r.data,date:r=>new Date(r.data)}[t.type](t)}},_r=class{constructor(){this.namespaces={}}addNamespace(t){if(!this.namespaces[t.key])return this.namespaces[t.key]=t,this}getNamespace(t){if(!this.namespaces[t])throw new M(`Namespace ${t} is not initialized, did you forget to register it?
|
|
36
|
-
Use \`story.registerPersistent\` to register a persistent namespace`);return this.namespaces[t]}setNamespace(t,n){return this.namespaces[t]=n,this}hasNamespace(t){return!!this.namespaces[t]}removeNamespace(t){return delete this.namespaces[t],this}getNamespaces(){return this.namespaces}keys(){return Object.keys(this.namespaces)}values(){return Object.values(this.namespaces)}entries(){return Object.entries(this.namespaces)}toData(){return this.entries().reduce((t,[n,r])=>(t[n]=r.toData(),t),{})}load(t){if(!t){console.warn("No data to load");return}Object.entries(t).forEach(([n,r])=>{this.namespaces[n]?this.namespaces[n].load(r):this.namespaces[n]=new
|
|
36
|
+
Use \`story.registerPersistent\` to register a persistent namespace`);return this.namespaces[t]}setNamespace(t,n){return this.namespaces[t]=n,this}hasNamespace(t){return!!this.namespaces[t]}removeNamespace(t){return delete this.namespaces[t],this}getNamespaces(){return this.namespaces}keys(){return Object.keys(this.namespaces)}values(){return Object.values(this.namespaces)}entries(){return Object.entries(this.namespaces)}toData(){return this.entries().reduce((t,[n,r])=>(t[n]=r.toData(),t),{})}load(t){if(!t){console.warn("No data to load");return}Object.entries(t).forEach(([n,r])=>{this.namespaces[n]?this.namespaces[n].load(r):this.namespaces[n]=new $t(n,r)})}clear(){return this.namespaces={},this}};var Ns=class Ns extends le{constructor(t,n){super(),this.namespace=this.prefix(t),this.defaultContent=n}init(t){t.hasNamespace(this.namespace)||t.addNamespace(new $t(this.namespace,this.defaultContent))}getNamespace(t){return t.getNamespace(this.namespace)}set(t,n){return this.chain(this.createAction(or.set,[t,n]))}assign(t){return this.chain(this.createAction(or.assign,[t]))}equals(t,n){return new Be(({storable:r})=>r.getNamespace(this.namespace).equals(t,n))}notEquals(t,n){return new Be(({storable:r})=>!r.getNamespace(this.namespace).equals(t,n))}isTrue(t){return new Be(({storable:n})=>n.getNamespace(this.namespace).equals(t,!0))}isFalse(t){return new Be(({storable:n})=>n.getNamespace(this.namespace).equals(t,!1))}isNotNull(t){return new Be(({storable:n})=>{let r=n.getNamespace(this.namespace).get(t);return r!=null})}toWord(t){return new Z(({storable:n})=>[String(n.getNamespace(this.namespace).get(t))])}get(t){return this.toWord(t)}conditional(t,n,r){return new Z(i=>Be.from(t).evaluate(i).value?n:r)}evaluate(t,n){return new Be(({storable:r})=>n(r.getNamespace(this.namespace).get(t)))}getNamespaceName(){return this.namespace}prefix(t,n=Ns.NamespacePrefix){return n+":"+String(t)}createAction(t,n){return new Ms(this.chain(),t,D.create(n))}};Ns.NamespacePrefix="persistent";var Bo=Ns,Gs=class Gs extends Bo{constructor(t){super(t,{}),this.namespace=this.prefix(t,Gs.LocalNamespacePrefix)}init(t){t.removeNamespace(this.namespace).addNamespace(new $t(this.namespace,this.defaultContent))}};Gs.LocalNamespacePrefix="local";var Vs=Gs;var Mr=class extends ${executeAction(t){if(this.type===rr.action)return super.executeAction(t);throw super.unknownTypeError()}};Mr.ActionTypes=rr;var zt=class zt extends Pt{constructor(t,n={}){super();let r=zt.DefaultUserConfig.create(n),i=zt.DefaultConfig.create({...r.get(),name:t});this.userConfig=r,this.config=i.get(),this.state=this.getInitialState(),this.transformState=this.getInitialTransformState()}include(t){return(Array.isArray(t)?t:[t]).forEach(r=>{r.useLayer(this)}),this}copy(){return new zt(this.config.name,this.userConfig.get())}setName(t){return this.config.name=t,this}_init(t){return[new Mr(this.chain(),rr.action,new D),new ke(this.chain(),Ce.init,new D().setContent([t,null,!1]))]}getInitialState(){return zt.DefaultState.create({zIndex:this.config.zIndex}).get()}getInitialTransformState(){let[t]=this.userConfig.extract(Se.DefaultTransformState.keys());return new Se(Se.DefaultTransformState.create(t.get()).get())}};zt.DefaultUserConfig=new X({zIndex:0,...Se.DefaultTransformState.getDefaultConfig(),opacity:1}),zt.DefaultConfig=new X({name:"(anonymous)",zIndex:0}),zt.DefaultState=new X({displayables:[],zIndex:0});var Wo=zt;var We=class We extends Uo{constructor(n,r){super();this.srcManager=new Ne;this.events=new re;this.actions=[];this._futureActions_=[];let i=We.DefaultSceneConfig.getDefaultConfig().defaultBackgroundLayer.copy().setName("[[Background Layer of "+n+"]]"),s=We.DefaultSceneConfig.getDefaultConfig().defaultDisplayableLayer.copy().setName("[[Displayable Layer of "+n+"]]"),c=We.DefaultUserConfig.create(r),u=We.DefaultSceneConfig.create({...c.get(),name:n,layers:[...c.get().layers,i,s],defaultBackgroundLayer:i,defaultDisplayableLayer:s});this.userConfig=c,this.config=u.get(),this.state=this.getInitialState(),this.localPersistent=new Vs(n)}static isScene(n){return n instanceof We}static getScene(n,r){return typeof r=="string"?n.getScene(r):r}static getStateSerializer(n){return new it({backgroundImage:r=>r.toData(),backgroundMusic:r=>r?.toData()||null},{backgroundImage:r=>n.state.backgroundImage.fromData(r),backgroundMusic:r=>n.state.backgroundMusic&&r?n.state.backgroundMusic.fromData(r):null})}get __futureActions__(){return this._futureActions_}get local(){return this.localPersistent}get background(){return this.state.backgroundImage}get backgroundLayer(){return this.config.defaultBackgroundLayer}get displayableLayer(){return this.config.defaultDisplayableLayer}setBackground(n,r){let i=this.chain();return i.chain(this.state.backgroundImage._setSrc(i,n,r))}jumpTo(n,r={}){return this.combineActions(new Bt({allowFutureScene:!1}),i=>{let c=U({unloadScene:!0},r instanceof Et?{transition:r}:r);return i.chain(new xe(i,"scene:preUnmount",new D().setContent([]))).chain(this._initScene(n))._transitionToScene(c.transition,n.state.backgroundImage.state.currentSrc),c.unloadScene&&i.chain(this._exit()),i})._jumpTo(n)}setBackgroundMusic(n,r){return this.chain(new xe(this.chain(),ge.setBackgroundMusic,new D().setContent([n,r])))}action(n){return this.actions=n,this}preloadImage(n){if(!k.isImageSrc(n))throw new Error("Invalid image source: "+n);return(Array.isArray(n)?n:[n]).forEach(i=>{this.srcManager.register({type:"image",src:i})}),this}toData(){return{state:We.getStateSerializer(this).serialize(this.state)}}fromData(n){return this.state=We.getStateSerializer(this).deserialize(n.state),this}constructSceneRoot(n){this.sceneRoot=new xe(this.chain(),"scene:action",new D);let r=this.actions,s=(Array.isArray(r)?r.flat(2):r(this).flat(2)).map(h=>Ee.isChained(h)?h.fromChained(h):h).flat(2),c=[],u=[];this.getAllChildrenElements(n,s,{allowFutureScene:!1}).forEach(h=>{Ee.isChained(h)||(h instanceof B?c.push(h):h instanceof Un&&u.push(h))});let p=[],f=[],a=new Map;c.forEach(h=>{h.config.isWearable?f.push(h):h.config.autoInit&&p.push(h);for(let g of h.config.wearables){if(a.get(g)&&a.get(g)!==h)throw new Error(`Wearable image cannot be used multiple times
|
|
37
37
|
Maybe you bind the same wearable image to multiple parent images
|
|
38
38
|
Parent Conflict (src: `+a.get(g)?.state.currentSrc+`)
|
|
39
|
-
Current Parent (src: `+h.state.currentSrc+")");a.set(g,h)}});let l=[...this._initScene(this),...p.map(h=>h._init(this)),...f.map(h=>{if(!a.has(h))throw new Error("Wearable image must have a parent image");return a.get(h)._initWearable(h)}),...u.map(h=>h._init()),...s],m=super.constructNodes(l),d=new D(this.sceneRoot,void 0,m||void 0).setContent(this);return m?.setParent(d),this.sceneRoot?.setContentNode(d),this._futureActions_=l,this}isSceneRootConstructed(){return!!this.sceneRoot}registerSrc(n,r=new Set){if(!this.sceneRoot)return;let i=new Set,s=new Set,c=[this.sceneRoot],u=new Set;for(;c.length;){let p=c.shift();if(!i.has(p)){if(i.add(p),p instanceof xe){let f=p.callee;if(k.isImageSrc(f.state.backgroundImage.state.currentSrc)&&this.srcManager.register({type:"image",src:k.srcToURL(f.state.backgroundImage.state.currentSrc)}),p.type===ge.jumpTo){let a=p,l=We.getScene(n,a.contentNode.getContent()[0]);if(!l)throw p._sceneNotFoundError(p.getSceneName(a.contentNode.getContent()[0]));let m=Ne.getPreloadableSrc(n,p);if(m&&this.srcManager.register(m),s.has(a)||r.has(l))continue;s.add(a),u.add(l),r.add(l)}}else if(p instanceof ue){let f=Ne.getPreloadableSrc(n,p);f&&this.srcManager.register(f)}else if(p instanceof
|
|
39
|
+
Current Parent (src: `+h.state.currentSrc+")");a.set(g,h)}});let l=[...this._initScene(this),...p.map(h=>h._init(this)),...f.map(h=>{if(!a.has(h))throw new Error("Wearable image must have a parent image");return a.get(h)._initWearable(h)}),...u.map(h=>h._init()),...s],m=super.constructNodes(l),d=new D(this.sceneRoot,void 0,m||void 0).setContent(this);return m?.setParent(d),this.sceneRoot?.setContentNode(d),this._futureActions_=l,this}isSceneRootConstructed(){return!!this.sceneRoot}registerSrc(n,r=new Set){if(!this.sceneRoot)return;let i=new Set,s=new Set,c=[this.sceneRoot],u=new Set;for(;c.length;){let p=c.shift();if(!i.has(p)){if(i.add(p),p instanceof xe){let f=p.callee;if(k.isImageSrc(f.state.backgroundImage.state.currentSrc)&&this.srcManager.register({type:"image",src:k.srcToURL(f.state.backgroundImage.state.currentSrc)}),p.type===ge.jumpTo){let a=p,l=We.getScene(n,a.contentNode.getContent()[0]);if(!l)throw p._sceneNotFoundError(p.getSceneName(a.contentNode.getContent()[0]));let m=Ne.getPreloadableSrc(n,p);if(m&&this.srcManager.register(m),s.has(a)||r.has(l))continue;s.add(a),u.add(l),r.add(l)}}else if(p instanceof ue){let f=Ne.getPreloadableSrc(n,p);f&&this.srcManager.register(f)}else if(p instanceof tt)this.srcManager.register(p.callee);else if(p instanceof he){let a=p.getFutureActions(n,{allowFutureScene:!0});c.push(...a)}else p instanceof ke&&this.srcManager.register(p.callee.srcManager.getSrc());c.push(...p.getFutureActions(n,{allowFutureScene:!0}))}}u.forEach(p=>{p.registerSrc(n,r),this.srcManager.registerFuture(p.srcManager)})}assignActionId(n){this.getAllChildren(n,this.sceneRoot||[],{allowFutureScene:!0}).forEach((i,s)=>{i.setId(`a-${s}`)})}assignElementId(n){this.getAllChildrenElements(n,this.sceneRoot||[]).forEach((i,s)=>{i.setId(`e-${s}`)})}getVoice(n){if(!n)return null;let r=this.config.voices;return r?typeof r=="function"?r(n):r[n]||null:null}getSceneRoot(){if(!this.sceneRoot)throw new Error("Scene root is not constructed");return this.sceneRoot}reset(){this.state.backgroundImage.reset(),this.state.backgroundMusic?.reset(),this.state=this.getInitialState()}getInitialState(){return We.DefaultSceneState.create().assign({backgroundImage:this.state?.backgroundImage?this.state.backgroundImage.reset():new B({src:this.userConfig.get().background,opacity:1,autoFit:!0,name:`[[Background Image of ${this.config.name}]]`,layer:this.config.defaultBackgroundLayer})._setIsBackground(!0)}).get()}_jumpTo(n){return this.chain(new xe(this.chain(),"scene:jumpTo",new D().setContent([n])))}_exit(){return new xe(this.chain(),"scene:exit",new D().setContent([]))}_transitionToScene(n,r){let i=this.chain();if(n&&r){let s=this.state.backgroundImage.char(r,n);i.chain(s.getActions())}return i}_init(n){return new xe(this.chain(),"scene:init",new D().setContent([n]))}_initScene(n){return[n._init(n),...n.config.layers.flatMap(r=>r._init(n)),...n._initBackground(n,n.config.defaultBackgroundLayer)]}_initBackground(n,r){return[n.state.backgroundImage._init(n,r)]}};We.EventTypes={"event:scene.remove":"event:scene.remove","event:scene.load":"event:scene.load","event:scene.unload":"event:scene.unload","event:scene.mount":"event:scene.mount","event:scene.unmount":"event:scene.unmount","event:scene.preUnmount":"event:scene.preUnmount","event:scene.imageLoaded":"event:scene.imageLoaded"},We.DefaultUserConfig=new X({backgroundMusic:null,backgroundMusicFade:0,voices:void 0,background:"#fff",layers:[]}),We.DefaultSceneConfig=new X({name:"",backgroundMusicFade:0,voices:null,layers:[],defaultBackgroundLayer:new Wo("[[Background Layer]]",{zIndex:-1}),defaultDisplayableLayer:new Wo("[[Displayable Layer]]",{zIndex:0})}),We.DefaultSceneState=new X({backgroundImage:new B,backgroundMusic:null});var yt=We;var jo=class extends ${executeAction(t){let n=this.contentNode.getContent().execute({gameState:t});return n&&t.actionHistory.push(this,()=>{n()},[]),super.executeAction(t)}};jo.ActionTypes=wl;var ut=class o extends le{static getCtx({gameState:t}){return{gameState:t,game:t.game,liveGame:t.game.getLiveGame(),storable:t.game.getLiveGame().getStorable()}}constructor(t){return super(),this.handler=t,this.chain()}execute({gameState:t}){return this.handler(o.getCtx({gameState:t}))}fromChained(t){return[new jo(this.chain(),jo.ActionTypes.action,new D().setContent(t))]}};var qt=class qt extends Uo{constructor(n,r=qt.defaultConfig){super();this.entryScene=null;this.scenes=new Map;this.persistent=[];this.services=new Map;this.name=n,this.config=U(qt.defaultConfig,r)}static empty(){return new qt("empty").entry(new yt("empty"))}entry(n){return this.entryScene=n,this}registerScene(n,r){let i=typeof n=="string"?n:n.config.name,s=typeof n=="string"?r:n;if(this.scenes.has(i)&&this.scenes.get(i)!==s)throw new Error(`Scene with name ${i} already exists when registering scene`);return this.scenes.set(i,s),this}registerPersistent(n){return this.persistent.push(n),this}createPersistent(n,r){let i=new Bo(n,r);return this.registerPersistent(i),i}registerService(n,r){return this.services.set(n,r),this}getService(n){let r=this.services.get(n);if(!r)throw new xn(`Trying to access service ${n} before it's registered, please use "story.registerService" to register the service`);return r}serializeServices(){let n={};return this.services.forEach((r,i)=>{if(!r.serialize||typeof r.serialize!="function")return;let s=r.serialize();if(s!==null){{if(s instanceof Promise)throw new me(`Service ${i} serialize method should not return a promise`);if(!Aa(s))throw new me(`Service ${i} serialize method should return a pure object.
|
|
40
40
|
A pure object should:
|
|
41
41
|
1. be an object literal
|
|
42
42
|
2. not have any prototype
|
|
43
43
|
3. no circular reference
|
|
44
44
|
4. sub objects should also be pure objects or serializable data
|
|
45
45
|
Return null if nothing needs to be saved. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description
|
|
46
|
-
Returned value ${s} violates the above rules`)}n[i]=s}}),n}deserializeServices(n){this.services.forEach((r,i)=>{!r.deserialize||typeof r.deserialize!="function"||n[i]&&r.deserialize(n[i])})}getScene(n,r=!1,i){if(yt.isScene(n))return n;let s=this.scenes.get(n)||null;if(!s&&r)throw Reflect.construct(i||me,[`Scene with name ${n} not found`]);return s}constructStory(){let n=this.entryScene;if(!n)throw new Error("Story must have an entry scene");return this.constructSceneRoots(n),n.registerSrc(this),n.assignActionId(this),n.assignElementId(this),this.runStaticCheck(n),this}getAllElementStates(){return this.getAllChildrenElements(this,this.entryScene?.getSceneRoot()||[]).map(r=>({id:r.getId(),data:r.toData()})).filter(r=>!!r.data)}constructSceneRoots(n){let r=new Set,i=[],s=0;for(n.constructSceneRoot(this),i.push(n.getSceneRoot());i.length;){if(s++,s
|
|
47
|
-
Use video.show() to add the video to the game`);let r=this.callee,i=new b,s=t.getExposedStateAsync(r,async c=>{t.logger.debug("Video Component state exposed",c),await n(c),i.resolve(super.executeAction(t)),t.stage.next()});return i.registerSkipController(new K(s.cancel)),i}changeState(t,n){return this.changeStateBase(t,n)}changeStateAsync(t,n){return this.changeStateBase(t,n)}};
|
|
46
|
+
Returned value ${s} violates the above rules`)}n[i]=s}}),n}deserializeServices(n){this.services.forEach((r,i)=>{!r.deserialize||typeof r.deserialize!="function"||n[i]&&r.deserialize(n[i])})}getScene(n,r=!1,i){if(yt.isScene(n))return n;let s=this.scenes.get(n)||null;if(!s&&r)throw Reflect.construct(i||me,[`Scene with name ${n} not found`]);return s}constructStory(){let n=this.entryScene;if(!n)throw new Error("Story must have an entry scene");return this.constructSceneRoots(n),n.registerSrc(this),n.assignActionId(this),n.assignElementId(this),this.runStaticCheck(n),this}getAllElementStates(){return this.getAllChildrenElements(this,this.entryScene?.getSceneRoot()||[]).map(r=>({id:r.getId(),data:r.toData()})).filter(r=>!!r.data)}constructSceneRoots(n){let r=new Set,i=[],s=0;for(n.constructSceneRoot(this),i.push(n.getSceneRoot());i.length;){if(s++,s>qt.MAX_DEPTH)throw new Error(`Max depth reached while constructing scene roots (max depth: ${qt.MAX_DEPTH})`);let c=i.shift();if(yt.isScene(c.callee)){if(r.has(c.callee))continue;c.callee.isSceneRootConstructed()||c.callee.constructSceneRoot(this),r.add(c.callee)}let u=c.getFutureActions(this,{allowFutureScene:!0});i.push(...u)}return this}initPersistent(n){return this.persistent.forEach(r=>{r.init(n)}),this}getInversionConfig(){let{origin:n}=this.config;return{invertY:n==="bottom left"||n==="bottom right",invertX:n==="bottom right"||n==="top right"}}runStaticCheck(n){return new Is(n).run(this)}};qt.defaultConfig={origin:"bottom left"},qt.MAX_DEPTH=1e4;var Vr=qt;var Fs=class extends ${executeAction(t){let[n,r]=this.contentNode.getContent(),i=this.callee.triggerAction(ut.getCtx({gameState:t}),n,r);return b.isAwaitable(i)?b.forward(i,{type:this.type,node:this.contentNode?.getChild()}):super.executeAction(t)}};var Rc=class extends le{constructor(){super(...arguments);this._handlers={}}on(n,r){return this._registerActionHandler(n,r),this}trigger(n,...r){let i=this.chain();return i.chain(this._createAction(i,n,r))}triggerAction(n,r,i){let s=this._handlers[r];if(!s){n.gameState.logger.warn(`(in User-Defined Service) Trying to trigger action ${r} before it's registered, please use "service.on" to register the action`);return}if(Vl(s)){let c=[],u=new b().registerSkipController(new K(()=>{for(let f of c)f?.()}));return s({...n,onAbort:f=>{c.push(f)}},...i).then(()=>u.resolve()),u}s({...n,onAbort:()=>{}},...i)}_registerActionHandler(n,r){this._handlers[n]=r}_createAction(n,r,i){return new Fs(n,"service:action",new D().setContent([r,i]))}},Ic=class extends Rc{},Lc=class extends Ic{};var kt=class kt extends ${executeAction(t){let n=this,r=this.callee;if(n.is(kt,"video:play"))return this.changeStateAsync(t,i=>i.play());if(n.is(kt,"video:pause"))return this.changeState(t,i=>i.pause());if(n.is(kt,"video:stop"))return this.changeState(t,i=>i.stop());if(n.is(kt,"video:seek"))return this.changeState(t,i=>i.seek(n.contentNode.getContent()[0]));if(n.is(kt,"video:show")){let i=r.state.display;return t.isVideoAdded(r)||(t.addVideo(r),t.stage.update()),r.state.display=!0,t.actionHistory.push(n,s=>{r.state.display=s},[i]),this.changeState(t,s=>s.show())}else if(n.is(kt,"video:hide")){let i=r.state.display;return this.changeState(t,s=>{r.state.display=!1,t.actionHistory.push(n,c=>{r.state.display=c},[i]),s.hide(),t.removeVideo(r),t.stage.update()})}else if(n.is(kt,"video:resume"))return this.changeState(t,i=>i.resume());throw this.unknownTypeError()}changeStateBase(t,n){if(!t.isVideoAdded(this.callee))throw new M(`Video is being used before it is added to the game
|
|
47
|
+
Use video.show() to add the video to the game`);let r=this.callee,i=new b,s=t.getExposedStateAsync(r,async c=>{t.logger.debug("Video Component state exposed",c),await n(c),i.resolve(super.executeAction(t)),t.stage.next()});return i.registerSkipController(new K(s.cancel)),i}changeState(t,n){return this.changeStateBase(t,n)}changeStateAsync(t,n){return this.changeStateBase(t,n)}};kt.ActionTypes=qn;var Os=kt;var $o=class $o extends le{constructor(t){super();let n=$o.DefaultVideoConfig.create(t);if(this.config=n.get(),this.state=this.getInitialState(),!this.config.src)throw new me("Video must have a src")}show(){return this.chain(this.createAction(qn.show,[]))}hide(){return this.chain(this.createAction(qn.hide,[]))}play(){return this.chain(this.createAction(qn.play,[]))}toData(){return{state:{display:this.state.display}}}fromData(t){let{state:n}=t;return this.state={display:n.display},this}reset(){return this.state=this.getInitialState(),this}getInitialState(){return $o.DefaultVideoState.create().get()}createAction(t,n){return new Os(this.chain(),t,D.create(n))}};$o.DefaultVideoConfig=new X({src:"",muted:!1}),$o.DefaultVideoState=new X({display:!1});var _c=$o;var Of=Bd(Tf());var Us=class{constructor(t,n){this.game=t,this.prefix=n}log(t,...n){this.isEnabled("log")&&console.log(...this.colorLog("gray",t,...n))}info(t,...n){this.isEnabled("info")&&console.info(...this._log(t,...n))}warn(t,...n){this.isEnabled("warn")&&console.warn(...this._log(t,...n))}error(t,...n){this.isEnabled("error")&&console.error(...this._log(t,...n))}debug(t,...n){this.isEnabled("debug")&&console.debug(...this.colorLog("gray",t,...n))}trace(t,...n){this.isEnabled("trace")&&console.trace(this._log(t,...n))}weakWarn(t,...n){this.isEnabled("warn")&&console.log(...this.colorLog("yellow",t,...n))}weakError(t,...n){this.isEnabled("error")&&console.log(...this.colorLog("red",t,...n))}verbose(t,...n){this.isEnabled("verbose")&&console.log(...this.colorLog("gray",t,...n))}group(t,n=!1){let r=this._log(t).join(" ");return this.isEnabled("info")&&(n?console.groupCollapsed(r):console.group(r)),{end:()=>{this.isEnabled("info")&&console.groupEnd()}}}isEnabled(t){return typeof this.game.config.app.logger=="boolean"?this.game.config.app.logger:this.game.config.app.logger[t]}_log(t,...n){return n.length===0?[this.prefix||"",t]:[`${this.prefix||""} [${t}]`,...n]}colorLog(t,n,...r){if(r.length===0)return[`%c${this.prefix||""} ${n}`,`color: ${t}`];let i=[],s=[],c=[];return this.prefix?(i.push(`%c${this.prefix} [${n}]`),s.push(`color: ${t}`)):(i.push(`%c[${n}]`),s.push(`color: ${t}`)),r.forEach(u=>{typeof u=="string"?(i.push(`%c${u}`),s.push(`color: ${t}`)):(i.push("%O"),c.push(u),s.push(""))}),[i.join(" ")].concat(s,c)}};var Ks=class{constructor(t){this.gameState=t;this.state=new Map;this.tasks=new Map}play(t,n={end:1,duration:0}){this.state.has(t)&&this.abortTask(this.getState(t).group);let{group:r,token:i,onPlayTask:s,onEndTask:c}=this.initSound(t);return this.state.set(t,{group:r,token:i}),this.pushTask(r,new on().addTask(s).addTask(this.fadeTo(r,i,{...n,start:0})).addTask(this.createTask(u=>{t.state.volume=n.end,t.state.paused=!1,u()})).addTask(c).run())}stop(t,n=0){let r=this.getState(t);return this.abortTask(r.group),n===0?(r.group.stop(r.token),b.resolve(void 0)):this.pushTask(r.group,new on().addTask(this.fadeTo(r.group,r.token,{start:t.state.volume,end:0,duration:n})).addTask(this.createTask(i=>{r.group.volume(t.state.volume,r.token),i()})).addTask(this.stopSound(r.group,r.token)).run())}setVolume(t,n,r=0){let i=this.getState(t);return this.abortTask(i.group),r===0?(i.group.volume(n,i.token),b.resolve(void 0)):this.pushTask(i.group,new on().addTask(this.fadeTo(i.group,i.token,{start:t.state.volume,end:n,duration:r})).addTask(this.createTask(s=>{t.state.volume=n,s()})).run())}pause(t,n=0){let r=this.getState(t);return this.abortTask(r.group),n===0?(r.group.pause(r.token),b.resolve(void 0)):this.pushTask(r.group,new on().addTask(this.fadeTo(r.group,r.token,{start:t.state.volume,end:0,duration:n})).addTask(this.pauseSound(r.group,r.token)).addTask(this.createTask(i=>{r.group.volume(t.state.volume,r.token),t.state.paused=!0,i()})).run())}resume(t,n=0){let r=this.getState(t);return this.abortTask(r.group),n===0?(r.group.play(r.token),b.resolve(void 0)):this.pushTask(r.group,new on().addTask(this.fadeTo(r.group,r.token,{start:0,end:t.state.volume,duration:n})).addTask(this.resumeSound(r.group,r.token)).addTask(this.createTask(i=>{t.state.paused=!1,i()})).run())}setRate(t,n){let r=this.getState(t);return this.abortTask(r.group),r.group.rate(n,r.token),t.state.rate=n,b.resolve(void 0)}getPosition(t){let n=this.getState(t);return n.group.seek(n.token)}isPlaying(t){if(!this.isManaged(t))return!1;let n=this.getState(t);return n.group.playing(n.token)}toData(){return{sounds:[...this.state.entries()].map(([t,n])=>[t.getId(),{isPlaying:n.group.playing(n.token),position:n.group.seek(n.token)}])}}fromData(t,n){return t.sounds.forEach(([r,i])=>{let s=n.get(r);if(!s)throw new M(`Sound not found (id: "${r}")
|
|
48
48
|
NarraLeaf cannot find the element with the id from the saved game`);this.soundFromData(s,i)}),this}soundFromData(t,n){let r=this.getState(t);r.group.playing(r.token)&&r.group.stop(r.token);let i=this.initSound(t);this.state.set(t,i),i.group.seek(n.position,i.token),t.state.paused?i.group.pause(i.token):n.isPlaying||i.group.stop(i.token)}isManaged(t){return this.state.has(t)}reset(){this.state.forEach(t=>{t.group.stop(t.token)}),this.state.clear(),this.tasks.forEach(t=>{t.awaitable.abort()}),this.tasks.clear()}initSound(t){if(this.state.has(t))return this.state.get(t);let n=this,[r,i]=this.wrapTask(),[s,c]=this.wrapTask(),u=Reflect.construct(this.gameState.getHowl(),[this.getHowlConfig(t,{onend(){s.resolve()},onplay(){r.resolve()},onloaderror(f,a){let l=a,m={1:"The fetching process for the media resource was aborted by the user agent at the user's request.",2:"A network error of some description caused the user agent to stop fetching the media resource, after the resource was established to be usable.",3:"An error of some description occurred while decoding the media resource, after the resource was established to be usable.",4:"The media resource indicated by the src attribute or assigned media provider object was not suitable."};n.gameState.logger.error("AudioManager",`Failed to load sound (src: "${t.config.src}")
|
|
49
49
|
${m[l]}
|
|
50
|
-
For more information, see https://github.com/goldfire/howler.js?tab=readme-ov-file#onloaderror-function`)}})]),p=u.play();return this.state.set(t,{group:u,token:p}),u.seek(t.config.seek,p).volume(t.state.volume,p).rate(t.state.rate,p),t.state.paused&&u.pause(p),{group:u,token:p,onPlayTask:i,onEndTask:c}}pushTask(t,n){return this.tasks.set(t,{awaitable:n}),n}getState(t){if(!this.state.has(t))throw new M(`Sound not initialized (src: "${t.config.src}")`);return this.state.get(t)}abortTask(t){let n=this.tasks.get(t);n&&(n.awaitable.abort(),this.tasks.delete(t))}fadeTo(t,n,r){let i,s,c=r.start??t.volume(),u=r.end??t.volume(),p=r.duration,f=new K(()=>{t.volume(u,n),i()});return[l=>{t.volume(c,n),t.fade(c,u,p,n),i=()=>{l.isSolved()||(s&&(s(),s=void 0),l.resolve())},s=this.gameState.schedule(()=>{s=void 0,i()},p)},f]}stopSound(t,n){return[()=>{t.stop(n)}]}pauseSound(t,n){return[()=>{t.pause(n)}]}resumeSound(t,n){return[()=>{t.play(n)}]}getHowlConfig(t,n={}){return{src:t.config.src,volume:t.state.volume,loop:t.config.loop,rate:t.state.rate,html5:t.config.streaming,...n}}createTask(t){return[n=>{t(n.resolve.bind(n))}]}wrapTask(){let t=new b;return[t,[n=>{t.isSolved()?n.resolve():t.then(()=>{n.resolve()})}]]}};var Hc={};Ud(Hc,{getFontEmbedCSS:()=>KT,toBlob:()=>UT,toCanvas:()=>Fr,toJpeg:()=>HT,toPixelData:()=>FT,toPng:()=>OT,toSvg:()=>Ff});function vf(o,t){if(o.match(/^[a-z]+:\/\//i))return o;if(o.match(/^\/\//))return window.location.protocol+o;if(o.match(/^[a-z]+:/i))return o;let n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=o,i.href}var Sf=(()=>{let o=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(o+=1,`u${t()}${o}`)})();function Tt(o){let t=[];for(let n=0,r=o.length;n<r;n++)t.push(o[n]);return t}var zo=null;function Bs(o={}){return zo||(o.includeStyleProperties?(zo=o.includeStyleProperties,zo):(zo=Tt(window.getComputedStyle(document.documentElement)),zo))}function Ks(o,t){let r=(o.ownerDocument.defaultView||window).getComputedStyle(o).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function rT(o){let t=Ks(o,"border-left-width"),n=Ks(o,"border-right-width");return o.clientWidth+t+n}function iT(o){let t=Ks(o,"border-top-width"),n=Ks(o,"border-bottom-width");return o.clientHeight+t+n}function Ws(o,t={}){let n=t.width||rT(o),r=t.height||iT(o);return{width:n,height:r}}function xf(){let o,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(o=parseInt(n,10),Number.isNaN(o)&&(o=1)),o||window.devicePixelRatio||1}var tt=16384;function bf(o){(o.width>tt||o.height>tt)&&(o.width>tt&&o.height>tt?o.width>o.height?(o.height*=tt/o.width,o.width=tt):(o.width*=tt/o.height,o.height=tt):o.width>tt?(o.height*=tt/o.width,o.width=tt):(o.width*=tt/o.height,o.height=tt))}function Af(o,t={}){return o.toBlob?new Promise(n=>{o.toBlob(n,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(n=>{let r=window.atob(o.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),i=r.length,s=new Uint8Array(i);for(let c=0;c<i;c+=1)s[c]=r.charCodeAt(c);n(new Blob([s],{type:t.type?t.type:"image/png"}))})}function qo(o){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=o})}async function sT(o){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(o)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Cf(o,t,n){let r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(o),sT(i)}var Ge=(o,t)=>{if(o instanceof t)return!0;let n=Object.getPrototypeOf(o);return n===null?!1:n.constructor.name===t.name||Ge(n,t)};function aT(o){let t=o.getPropertyValue("content");return`${o.cssText} content: '${t.replace(/'|"/g,"")}';`}function cT(o,t){return Bs(t).map(n=>{let r=o.getPropertyValue(n),i=o.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function lT(o,t,n,r){let i=`.${o}:${t}`,s=n.cssText?aT(n):cT(n,r);return document.createTextNode(`${i}{${s}}`)}function wf(o,t,n,r){let i=window.getComputedStyle(o,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;let c=Sf();try{t.className=`${t.className} ${c}`}catch{return}let u=document.createElement("style");u.appendChild(lT(c,n,i,r)),t.appendChild(u)}function Pf(o,t,n){wf(o,t,":before",n),wf(o,t,":after",n)}var Ef="application/font-woff",kf="image/jpeg",uT={woff:Ef,woff2:Ef,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:kf,jpeg:kf,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function pT(o){let t=/\.([^./]*?)$/g.exec(o);return t?t[1]:""}function Xo(o){let t=pT(o).toLowerCase();return uT[t]||""}function mT(o){return o.split(/,/)[1]}function Nr(o){return o.search(/^(data:)/)!==-1}function Vc(o,t){return`data:${t};base64,${o}`}async function Nc(o,t,n){let r=await fetch(o,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((s,c)=>{let u=new FileReader;u.onerror=c,u.onloadend=()=>{try{s(n({res:r,result:u.result}))}catch(p){c(p)}},u.readAsDataURL(i)})}var Mc={};function fT(o,t,n){let r=o.replace(/\?.*/,"");return n&&(r=o),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Yo(o,t,n){let r=fT(o,t,n.includeQueryParams);if(Mc[r]!=null)return Mc[r];n.cacheBust&&(o+=(/\?/.test(o)?"&":"?")+new Date().getTime());let i;try{let s=await Nc(o,n.fetchRequestInit,({res:c,result:u})=>(t||(t=c.headers.get("Content-Type")||""),mT(u)));i=Vc(s,t)}catch(s){i=n.imagePlaceholder||"";let c=`Failed to fetch resource: ${o}`;s&&(c=typeof s=="string"?s:s.message),c&&console.warn(c)}return Mc[r]=i,i}async function dT(o){let t=o.toDataURL();return t==="data:,"?o.cloneNode(!1):qo(t)}async function hT(o,t){if(o.currentSrc){let s=document.createElement("canvas"),c=s.getContext("2d");s.width=o.clientWidth,s.height=o.clientHeight,c?.drawImage(o,0,0,s.width,s.height);let u=s.toDataURL();return qo(u)}let n=o.poster,r=Xo(n),i=await Yo(n,r,t);return qo(i)}async function gT(o,t){var n;try{if(!((n=o?.contentDocument)===null||n===void 0)&&n.body)return await Gr(o.contentDocument.body,t,!0)}catch{}return o.cloneNode(!1)}async function yT(o,t){return Ge(o,HTMLCanvasElement)?dT(o):Ge(o,HTMLVideoElement)?hT(o,t):Ge(o,HTMLIFrameElement)?gT(o,t):o.cloneNode(Df(o))}var TT=o=>o.tagName!=null&&o.tagName.toUpperCase()==="SLOT",Df=o=>o.tagName!=null&&o.tagName.toUpperCase()==="SVG";async function vT(o,t,n){var r,i;if(Df(t))return t;let s=[];return TT(o)&&o.assignedNodes?s=Tt(o.assignedNodes()):Ge(o,HTMLIFrameElement)&&(!((r=o.contentDocument)===null||r===void 0)&&r.body)?s=Tt(o.contentDocument.body.childNodes):s=Tt(((i=o.shadowRoot)!==null&&i!==void 0?i:o).childNodes),s.length===0||Ge(o,HTMLVideoElement)||await s.reduce((c,u)=>c.then(()=>Gr(u,n)).then(p=>{p&&t.appendChild(p)}),Promise.resolve()),t}function ST(o,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(o);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Bs(n).forEach(s=>{let c=i.getPropertyValue(s);s==="font-size"&&c.endsWith("px")&&(c=`${Math.floor(parseFloat(c.substring(0,c.length-2)))-.1}px`),Ge(o,HTMLIFrameElement)&&s==="display"&&c==="inline"&&(c="block"),s==="d"&&t.getAttribute("d")&&(c=`path(${t.getAttribute("d")})`),r.setProperty(s,c,i.getPropertyPriority(s))})}function xT(o,t){Ge(o,HTMLTextAreaElement)&&(t.innerHTML=o.value),Ge(o,HTMLInputElement)&&t.setAttribute("value",o.value)}function bT(o,t){if(Ge(o,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(i=>o.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function AT(o,t,n){return Ge(t,Element)&&(ST(o,t,n),Pf(o,t,n),xT(o,t),bT(o,t)),t}async function CT(o,t){let n=o.querySelectorAll?o.querySelectorAll("use"):[];if(n.length===0)return o;let r={};for(let s=0;s<n.length;s++){let u=n[s].getAttribute("xlink:href");if(u){let p=o.querySelector(u),f=document.querySelector(u);!p&&f&&!r[u]&&(r[u]=await Gr(f,t,!0))}}let i=Object.values(r);if(i.length){let s="http://www.w3.org/1999/xhtml",c=document.createElementNS(s,"svg");c.setAttribute("xmlns",s),c.style.position="absolute",c.style.width="0",c.style.height="0",c.style.overflow="hidden",c.style.display="none";let u=document.createElementNS(s,"defs");c.appendChild(u);for(let p=0;p<i.length;p++)u.appendChild(i[p]);o.appendChild(c)}return o}async function Gr(o,t,n){return!n&&t.filter&&!t.filter(o)?null:Promise.resolve(o).then(r=>yT(r,t)).then(r=>vT(o,r,t)).then(r=>AT(o,r,t)).then(r=>CT(r,t))}var Rf=/url\((['"]?)([^'"]+?)\1\)/g,wT=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,PT=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ET(o){let t=o.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function kT(o){let t=[];return o.replace(Rf,(n,r,i)=>(t.push(i),n)),t.filter(n=>!Nr(n))}async function DT(o,t,n,r,i){try{let s=n?vf(t,n):t,c=Xo(t),u;if(i){let p=await i(s);u=Vc(p,c)}else u=await Yo(s,c,r);return o.replace(ET(t),`$1${u}$3`)}catch{}return o}function RT(o,{preferredFontFormat:t}){return t?o.replace(PT,n=>{for(;;){let[r,,i]=wT.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):o}function Gc(o){return o.search(Rf)!==-1}async function js(o,t,n){if(!Gc(o))return o;let r=RT(o,n);return kT(r).reduce((s,c)=>s.then(u=>DT(u,c,t,n)),Promise.resolve(r))}async function Zo(o,t,n){var r;let i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(o);if(i){let s=await js(i,null,n);return t.style.setProperty(o,s,t.style.getPropertyPriority(o)),!0}return!1}async function IT(o,t){await Zo("background",o,t)||await Zo("background-image",o,t),await Zo("mask",o,t)||await Zo("-webkit-mask",o,t)||await Zo("mask-image",o,t)||await Zo("-webkit-mask-image",o,t)}async function LT(o,t){let n=Ge(o,HTMLImageElement);if(!(n&&!Nr(o.src))&&!(Ge(o,SVGImageElement)&&!Nr(o.href.baseVal)))return;let r=n?o.src:o.href.baseVal,i=await Yo(r,Xo(r),t);await new Promise((s,c)=>{o.onload=s,o.onerror=t.onImageErrorHandler?(...p)=>{try{s(t.onImageErrorHandler(...p))}catch(f){c(f)}}:c;let u=o;u.decode&&(u.decode=s),u.loading==="lazy"&&(u.loading="eager"),n?(o.srcset="",o.src=i):o.href.baseVal=i})}async function _T(o,t){let r=Tt(o.childNodes).map(i=>Fc(i,t));await Promise.all(r).then(()=>o)}async function Fc(o,t){Ge(o,Element)&&(await IT(o,t),await LT(o,t),await _T(o,t))}function If(o,t){let{style:n}=o;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),o}var Lf={};async function _f(o){let t=Lf[o];if(t!=null)return t;let r=await(await fetch(o)).text();return t={url:o,cssText:r},Lf[o]=t,t}async function Mf(o,t){let n=o.cssText,r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async c=>{let u=c.replace(r,"$1");return u.startsWith("https://")||(u=new URL(u,o.url).href),Nc(u,t.fetchRequestInit,({result:p})=>(n=n.replace(c,`url(${p})`),[c,p]))});return Promise.all(s).then(()=>n)}function Vf(o){if(o==null)return[];let t=[],n=/(\/\*[\s\S]*?\*\/)/gi,r=o.replace(n,""),i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let p=i.exec(r);if(p===null)break;t.push(p[0])}r=r.replace(i,"");let s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,c="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",u=new RegExp(c,"gi");for(;;){let p=s.exec(r);if(p===null){if(p=u.exec(r),p===null)break;s.lastIndex=u.lastIndex}else u.lastIndex=s.lastIndex;t.push(p[0])}return t}async function MT(o,t){let n=[],r=[];return o.forEach(i=>{if("cssRules"in i)try{Tt(i.cssRules||[]).forEach((s,c)=>{if(s.type===CSSRule.IMPORT_RULE){let u=c+1,p=s.href,f=_f(p).then(a=>Mf(a,t)).then(a=>Vf(a).forEach(l=>{try{i.insertRule(l,l.startsWith("@import")?u+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:l,error:m})}})).catch(a=>{console.error("Error loading remote css",a.toString())});r.push(f)}})}catch(s){let c=o.find(u=>u.href==null)||document.styleSheets[0];i.href!=null&&r.push(_f(i.href).then(u=>Mf(u,t)).then(u=>Vf(u).forEach(p=>{c.insertRule(p,c.cssRules.length)})).catch(u=>{console.error("Error loading remote stylesheet",u)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(o.forEach(i=>{if("cssRules"in i)try{Tt(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function VT(o){return o.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Gc(t.style.getPropertyValue("src")))}async function NT(o,t){if(o.ownerDocument==null)throw new Error("Provided element is not within a Document");let n=Tt(o.ownerDocument.styleSheets),r=await MT(n,t);return VT(r)}function Nf(o){return o.trim().replace(/["']/g,"")}function GT(o){let t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(Nf(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(o),t}async function Oc(o,t){let n=await NT(o,t),r=GT(o);return(await Promise.all(n.filter(s=>r.has(Nf(s.style.fontFamily))).map(s=>{let c=s.parentStyleSheet?s.parentStyleSheet.href:null;return js(s.cssText,c,t)}))).join(`
|
|
51
|
-
`)}async function Gf(o,t){let n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Oc(o,t);if(n){let r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r)}}async function Ff(o,t={}){let{width:n,height:r}=Ws(o,t),i=await Gr(o,t,!0);return await Gf(i,t),await Fc(i,t),If(i,t),await Cf(i,n,r)}async function Fr(o,t={}){let{width:n,height:r}=Ws(o,t),i=await Ff(o,t),s=await qo(i),c=document.createElement("canvas"),u=c.getContext("2d"),p=t.pixelRatio||xf(),f=t.canvasWidth||n,a=t.canvasHeight||r;return c.width=f*p,c.height=a*p,t.skipAutoScale||bf(c),c.style.width=`${f}`,c.style.height=`${a}`,t.backgroundColor&&(u.fillStyle=t.backgroundColor,u.fillRect(0,0,c.width,c.height)),u.drawImage(s,0,0,c.width,c.height),c}async function FT(o,t={}){let{width:n,height:r}=Ws(o,t);return(await Fr(o,t)).getContext("2d").getImageData(0,0,n,r).data}async function OT(o,t={}){return(await Fr(o,t)).toDataURL()}async function HT(o,t={}){return(await Fr(o,t)).toDataURL("image/jpeg",t.quality||1)}async function UT(o,t={}){let n=await Fr(o,t);return await Af(n)}async function KT(o,t={}){return Oc(o,t)}var $s=class{constructor(t,n){this.gameState=t;this.notifications=n;this.events=new re}addNotification(t){this.notifications.push(t),this.flush()}removeNotification(t){this.notifications=this.notifications.filter(n=>n!==t),this.flush()}clearNotifications(){this.notifications=[],this.flush()}consume(t){let n=new b,r=new ne(n);return n.registerSkipController(new K(()=>{this.removeNotification(t)})),this.addNotification(t),this.gameState.schedule(()=>{n.resolve(),this.removeNotification(t)},t.duration),this.gameState.timelines.attachTimeline(r),n}onFlush(t){return this.events.on("event:notifications.flush",t)}toArray(){return[...this.notifications]}flush(){this.events.emit("event:notifications.flush")}};var zs=class{constructor(t=100){this.history=[];this.hooks={onUndo:[],onHistoryLimit:[]};this.maxHistorySize=t}push(t,n,r,i){let s=Nl(6);if(this.history.push({action:t,id:s,args:r,undo:n,timeline:i}),this.history.length>this.maxHistorySize){let c=this.history.splice(0,this.history.length-this.maxHistorySize);this.hooks.onHistoryLimit.forEach(u=>u(c))}return{id:s}}undoUntil(t){let n=-1;for(let i=this.history.length-1;i>=0;i--)if(this.history[i].id===t){n=i;break}if(n===-1)return null;let r=[];for(let i=this.history.length-1;i>=n;i--)this.history[i].timeline&&!this.history[i].timeline.isSettled&&this.history[i].timeline.abort(),this.history[i].undo?.(...this.history[i].args||[]),r.push(this.history[i]);return this.history.splice(n),this.hooks.onUndo.forEach(i=>i(r)),r[r.length-1]?.action||null}undo(){let t=this.history.pop();return t?(t.timeline&&!t.timeline.isSettled&&t.timeline.abort(),t.undo?.(...t.args),this.hooks.onUndo.forEach(n=>n([t])),t.action):null}onUndo(t){return this.hooks.onUndo.push(t),{cancel:()=>this.offUndo(t)}}offUndo(t){this.hooks.onUndo=this.hooks.onUndo.filter(n=>n!==t)}getHistory(){return this.history}onHistoryLimit(t){return this.hooks.onHistoryLimit.push(t),{cancel:()=>this.offHistoryLimit(t)}}offHistoryLimit(t){this.hooks.onHistoryLimit=this.hooks.onHistoryLimit.filter(n=>n!==t)}reset(){this.history=[]}};var qs=class{constructor(t){this.history=[];this.actionHistoryMgr=t,this.actionHistoryMgr.onUndo(n=>{this.crossFilter(n)}),this.actionHistoryMgr.onHistoryLimit(n=>{this.crossFilter(n)})}push(t){return this.history.push(t),this}getHistory(){return this.history}reset(){this.history=[]}crossFilter(t){let n=new Set(t.map(r=>r.id));this.history=this.history.filter(r=>!n.has(r.token))}};var Or=class Or{constructor(t,n){this.state={sounds:[],videos:[],srcManagers:[],elements:[]};this.currentHandling=null;this.playerCurrent=null;this.mainContentNode=null;this.exposedState=new Map;this.htmlToImage=Hc;this.stage=n,this.game=t,this.events=new re,this.logger=new Hs(t,"NarraLeaf-React"),this.audioManager=new Us(this),this.guard=new Es(t.config.app.guard).observe(this),this.timelines=new ks(this.guard),this.notificationMgr=new $s(this,[]),this.idManager=new Xr,this.actionHistory=new zs,this.gameHistory=new qs(this.actionHistory)}addVideo(t){return this.state.videos.push(t),this}removeVideo(t){let n=this.state.videos.indexOf(t);return n===-1?(this.logger.weakWarn("Video not found when removing",t.getId()),this):(this.state.videos.splice(n,1),this)}isVideoAdded(t){return this.state.videos.includes(t)}getVideos(){return this.state.videos}findElementByScene(t){return this.state.elements.find(n=>n.scene===t)||null}findElementByDisplayable(t,n=null){return this.state.elements.find(r=>{if(n)return r.layers.get(n)?.includes(t)||!1;for(let i of r.layers.values())if(i.includes(t))return!0;return!1})||null}removeElement(t){let n=this.state.elements.indexOf(t);return n===-1?(this.logger.weakWarn("Element not found when removing",t.scene.getId()),this):(this.state.elements.splice(n,1),this)}addElement(t){return this.state.elements.push(t),this}addScene(t){return this.sceneExists(t)?this:(this.state.elements.unshift({scene:t,texts:[],menus:[],layers:new Map(t.config.layers.map(n=>[n,[]]))}),this)}flush(){return this.stage.update(),this}popScene(){let t=this.state.elements.pop();return t?(this.removeElements(t.scene),this):this}removeScene(t){return this.removeElements(t),this}getSceneElements(){return this.state.elements}getLastScene(){return this.state.elements[this.state.elements.length-1]?.scene||null}sceneExists(t){return t?this.state.elements.some(n=>n.scene===t):!!this.getLastScene()}isSceneActive(t){for(let{scene:n}of this.state.elements)if(n===t)return!0;return!1}wait(t){return new Promise(n=>setTimeout(n,t))}schedule(t,n){let r=setTimeout(()=>{t({retry:()=>{this.schedule(t,0)}})},n);return()=>clearTimeout(r)}notify(t){this.notificationMgr.addNotification(t)}handle(t){if(this.currentHandling===t)return this;switch(this.currentHandling=t,t.type){case"condition:action":break}return this}createDialog(t,n,r,i){let s=this.findElementByScene(this.getLastSceneIfNot(i))?.texts;if(!s)throw this.sceneNotFound();let c=n.evaluate(lt.getCtx({gameState:this}));this.game.getLiveGame().events.emit(Cn.EventTypes["event:character.prompt"],{character:n.config.character,sentence:n,text:Z.getText(c)});let u=this.createWaitableAction({character:n.config.character,sentence:n,id:t,words:c},()=>{s.splice(s.indexOf(u),1),r&&r()});return s.push(u),{cancel:()=>{let p=s.indexOf(u);p!==-1&&s.splice(p,1)},text:Z.getText(c)}}createMenu(t,n,r){if(!t.choices.length)throw new Error("Menu must have at least one choice");let i=this.findElementByScene(this.getLastSceneIfNot(r))?.menus;if(!i)throw this.sceneNotFound();let s=t.prompt?.evaluate(lt.getCtx({gameState:this}))||null,c=this.createWaitableAction({...t,words:s},u=>{i.splice(i.indexOf(c),1),n&&n(u),this.game.getLiveGame().events.emit(Cn.EventTypes["event:menu.choose"],{sentence:u.prompt,text:u.evaluated})});return i.push(c),{cancel:()=>{let u=i.indexOf(c);u!==-1&&i.splice(u,1)},prompt:s?Z.getText(s):null}}createDisplayable(t,n=null,r=null){let i=this.getLastSceneIfNot(n),s=this.findElementByScene(i);if(!s)throw this.sceneNotFound();let c=s.layers.get(r||i.config.defaultDisplayableLayer);if(!c)throw this.layerNotFound();return c.push(t),this}disposeDisplayable(t,n=null,r=null){let i=this.getLastSceneIfNot(n),s=this.findElementByScene(i)?.layers.get(r||i.config.defaultDisplayableLayer);if(!s)throw this.layerNotFound();let c=s.indexOf(t);if(c===-1)throw new M(`Displayables not found when disposing. (disposing: ${t.getId()})`);return s.splice(c,1),this}forceReset(){this.state.elements.forEach(({scene:t})=>{this.offSrcManager(t.srcManager),this.removeScene(t),t.events.clear()}),this.state.elements=[],this.state.srcManagers=[],this.state.videos=[],this.audioManager.reset(),this.timelines.abortAll(),this.gameHistory.reset(),this.actionHistory.reset()}getHowl(){return Of.Howl}registerSrcManager(t){return this.state.srcManagers.push(t),this}offSrcManager(t){return this.state.srcManagers=this.state.srcManagers.filter(n=>n!==t),this}getStorable(){return this.game.getLiveGame().getStorable()}getSceneByName(t){return this.game.getLiveGame().story?.getScene(t)||null}getStory(){if(!this.game.getLiveGame().story)throw new M("Story not loaded");return this.game.getLiveGame().story}setInterval(t,n){return setInterval(t,n)}clearInterval(t){clearInterval(t)}setTimeout(t,n){return setTimeout(t,n)}clearTimeout(t){clearTimeout(t)}forceAnimation(){let[t,n]=ne.proxy(b.nothing),r=[];return Array.from(this.exposedState.keys()).forEach(i=>{i instanceof wt&&r.push(i)}),r.forEach(i=>{let c=this.getExposedStateForce(i).applyTransform(ce.immediate({}),()=>{});n.attachChild(c)}),this.timelines.attachTimeline(n),t}mountState(t,n){if(this.exposedState.has(t))throw new Dr("State already mounted");if(!t)throw new Dr("Invalid state key");return this.exposedState.set(t,n),this.events.emit(Or.EventTypes["event.state.onExpose"],t,n),{unMount:()=>{this.unMountState(t)}}}unMountState(t){return this.exposedState.has(t)||this.guard.warn("invalidExposedStateUnmounting","State not found when unmounting"),this.exposedState.delete(t),this}initVideo(t){return this.state.videos.push(t),this}isStateMounted(t){return this.exposedState.has(t)}getExposedState(t){return this.exposedState.get(t)||null}getExposedStateForce(t){let n=this.getExposedState(t);if(!n)throw new M("State not found, key: "+t);return n}getExposedStateAsync(t,n){let r=this.getExposedState(t);if(r)return{cancel:this.schedule(()=>{n(r)},0)};{let i=this.events.on(Or.EventTypes["event.state.onExpose"],(s,c)=>{s===t&&(n(c),i.cancel())});return i}}dispose(){this.forceReset()}toData(){return{scenes:this.state.elements.map(t=>({sceneId:t.scene.getId(),elements:{layers:Object.fromEntries(Array.from(t.layers.entries()).map(([n,r])=>[n.getId(),r.map(i=>i.getId())]))}})),audio:this.audioManager.toData(),videos:this.state.videos.map(t=>[t.getId(),t.toData()])}}loadData(t,n){if(this.state.elements=[],!this.game.getLiveGame().story)throw new Error("No story loaded");let{scenes:i,audio:s,videos:c}=t;i.forEach(({sceneId:u,elements:p})=>{this.logger.debug("Loading scene: "+u);let f=n.get(u);if(!f)throw new M("Scene not found, id: "+u+`
|
|
50
|
+
For more information, see https://github.com/goldfire/howler.js?tab=readme-ov-file#onloaderror-function`)}})]),p=u.play();return this.state.set(t,{group:u,token:p}),u.seek(t.config.seek,p).volume(t.state.volume,p).rate(t.state.rate,p),t.state.paused&&u.pause(p),{group:u,token:p,onPlayTask:i,onEndTask:c}}pushTask(t,n){return this.tasks.set(t,{awaitable:n}),n}getState(t){if(!this.state.has(t))throw new M(`Sound not initialized (src: "${t.config.src}")`);return this.state.get(t)}abortTask(t){let n=this.tasks.get(t);n&&(n.awaitable.abort(),this.tasks.delete(t))}fadeTo(t,n,r){let i,s,c=r.start??t.volume(),u=r.end??t.volume(),p=r.duration,f=new K(()=>{t.volume(u,n),i()});return[l=>{t.volume(c,n),t.fade(c,u,p,n),i=()=>{l.isSolved()||(s&&(s(),s=void 0),l.resolve())},s=this.gameState.schedule(()=>{s=void 0,i()},p)},f]}stopSound(t,n){return[()=>{t.stop(n)}]}pauseSound(t,n){return[()=>{t.pause(n)}]}resumeSound(t,n){return[()=>{t.play(n)}]}getHowlConfig(t,n={}){return{src:t.config.src,volume:t.state.volume,loop:t.config.loop,rate:t.state.rate,html5:t.config.streaming,...n}}createTask(t){return[n=>{t(n.resolve.bind(n))}]}wrapTask(){let t=new b;return[t,[n=>{t.isSolved()?n.resolve():t.then(()=>{n.resolve()})}]]}};var Hc={};Ud(Hc,{getFontEmbedCSS:()=>KT,toBlob:()=>UT,toCanvas:()=>Fr,toJpeg:()=>HT,toPixelData:()=>FT,toPng:()=>OT,toSvg:()=>Ff});function vf(o,t){if(o.match(/^[a-z]+:\/\//i))return o;if(o.match(/^\/\//))return window.location.protocol+o;if(o.match(/^[a-z]+:/i))return o;let n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=o,i.href}var Sf=(()=>{let o=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(o+=1,`u${t()}${o}`)})();function Tt(o){let t=[];for(let n=0,r=o.length;n<r;n++)t.push(o[n]);return t}var zo=null;function Ws(o={}){return zo||(o.includeStyleProperties?(zo=o.includeStyleProperties,zo):(zo=Tt(window.getComputedStyle(document.documentElement)),zo))}function Bs(o,t){let r=(o.ownerDocument.defaultView||window).getComputedStyle(o).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function rT(o){let t=Bs(o,"border-left-width"),n=Bs(o,"border-right-width");return o.clientWidth+t+n}function iT(o){let t=Bs(o,"border-top-width"),n=Bs(o,"border-bottom-width");return o.clientHeight+t+n}function js(o,t={}){let n=t.width||rT(o),r=t.height||iT(o);return{width:n,height:r}}function xf(){let o,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(o=parseInt(n,10),Number.isNaN(o)&&(o=1)),o||window.devicePixelRatio||1}var nt=16384;function bf(o){(o.width>nt||o.height>nt)&&(o.width>nt&&o.height>nt?o.width>o.height?(o.height*=nt/o.width,o.width=nt):(o.width*=nt/o.height,o.height=nt):o.width>nt?(o.height*=nt/o.width,o.width=nt):(o.width*=nt/o.height,o.height=nt))}function Af(o,t={}){return o.toBlob?new Promise(n=>{o.toBlob(n,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(n=>{let r=window.atob(o.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),i=r.length,s=new Uint8Array(i);for(let c=0;c<i;c+=1)s[c]=r.charCodeAt(c);n(new Blob([s],{type:t.type?t.type:"image/png"}))})}function qo(o){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=o})}async function sT(o){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(o)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Cf(o,t,n){let r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(o),sT(i)}var Ge=(o,t)=>{if(o instanceof t)return!0;let n=Object.getPrototypeOf(o);return n===null?!1:n.constructor.name===t.name||Ge(n,t)};function aT(o){let t=o.getPropertyValue("content");return`${o.cssText} content: '${t.replace(/'|"/g,"")}';`}function cT(o,t){return Ws(t).map(n=>{let r=o.getPropertyValue(n),i=o.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function lT(o,t,n,r){let i=`.${o}:${t}`,s=n.cssText?aT(n):cT(n,r);return document.createTextNode(`${i}{${s}}`)}function wf(o,t,n,r){let i=window.getComputedStyle(o,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;let c=Sf();try{t.className=`${t.className} ${c}`}catch{return}let u=document.createElement("style");u.appendChild(lT(c,n,i,r)),t.appendChild(u)}function Pf(o,t,n){wf(o,t,":before",n),wf(o,t,":after",n)}var Ef="application/font-woff",kf="image/jpeg",uT={woff:Ef,woff2:Ef,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:kf,jpeg:kf,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function pT(o){let t=/\.([^./]*?)$/g.exec(o);return t?t[1]:""}function Xo(o){let t=pT(o).toLowerCase();return uT[t]||""}function mT(o){return o.split(/,/)[1]}function Nr(o){return o.search(/^(data:)/)!==-1}function Vc(o,t){return`data:${t};base64,${o}`}async function Nc(o,t,n){let r=await fetch(o,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((s,c)=>{let u=new FileReader;u.onerror=c,u.onloadend=()=>{try{s(n({res:r,result:u.result}))}catch(p){c(p)}},u.readAsDataURL(i)})}var Mc={};function fT(o,t,n){let r=o.replace(/\?.*/,"");return n&&(r=o),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Yo(o,t,n){let r=fT(o,t,n.includeQueryParams);if(Mc[r]!=null)return Mc[r];n.cacheBust&&(o+=(/\?/.test(o)?"&":"?")+new Date().getTime());let i;try{let s=await Nc(o,n.fetchRequestInit,({res:c,result:u})=>(t||(t=c.headers.get("Content-Type")||""),mT(u)));i=Vc(s,t)}catch(s){i=n.imagePlaceholder||"";let c=`Failed to fetch resource: ${o}`;s&&(c=typeof s=="string"?s:s.message),c&&console.warn(c)}return Mc[r]=i,i}async function dT(o){let t=o.toDataURL();return t==="data:,"?o.cloneNode(!1):qo(t)}async function hT(o,t){if(o.currentSrc){let s=document.createElement("canvas"),c=s.getContext("2d");s.width=o.clientWidth,s.height=o.clientHeight,c?.drawImage(o,0,0,s.width,s.height);let u=s.toDataURL();return qo(u)}let n=o.poster,r=Xo(n),i=await Yo(n,r,t);return qo(i)}async function gT(o,t){var n;try{if(!((n=o?.contentDocument)===null||n===void 0)&&n.body)return await Gr(o.contentDocument.body,t,!0)}catch{}return o.cloneNode(!1)}async function yT(o,t){return Ge(o,HTMLCanvasElement)?dT(o):Ge(o,HTMLVideoElement)?hT(o,t):Ge(o,HTMLIFrameElement)?gT(o,t):o.cloneNode(Df(o))}var TT=o=>o.tagName!=null&&o.tagName.toUpperCase()==="SLOT",Df=o=>o.tagName!=null&&o.tagName.toUpperCase()==="SVG";async function vT(o,t,n){var r,i;if(Df(t))return t;let s=[];return TT(o)&&o.assignedNodes?s=Tt(o.assignedNodes()):Ge(o,HTMLIFrameElement)&&(!((r=o.contentDocument)===null||r===void 0)&&r.body)?s=Tt(o.contentDocument.body.childNodes):s=Tt(((i=o.shadowRoot)!==null&&i!==void 0?i:o).childNodes),s.length===0||Ge(o,HTMLVideoElement)||await s.reduce((c,u)=>c.then(()=>Gr(u,n)).then(p=>{p&&t.appendChild(p)}),Promise.resolve()),t}function ST(o,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(o);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Ws(n).forEach(s=>{let c=i.getPropertyValue(s);s==="font-size"&&c.endsWith("px")&&(c=`${Math.floor(parseFloat(c.substring(0,c.length-2)))-.1}px`),Ge(o,HTMLIFrameElement)&&s==="display"&&c==="inline"&&(c="block"),s==="d"&&t.getAttribute("d")&&(c=`path(${t.getAttribute("d")})`),r.setProperty(s,c,i.getPropertyPriority(s))})}function xT(o,t){Ge(o,HTMLTextAreaElement)&&(t.innerHTML=o.value),Ge(o,HTMLInputElement)&&t.setAttribute("value",o.value)}function bT(o,t){if(Ge(o,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(i=>o.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function AT(o,t,n){return Ge(t,Element)&&(ST(o,t,n),Pf(o,t,n),xT(o,t),bT(o,t)),t}async function CT(o,t){let n=o.querySelectorAll?o.querySelectorAll("use"):[];if(n.length===0)return o;let r={};for(let s=0;s<n.length;s++){let u=n[s].getAttribute("xlink:href");if(u){let p=o.querySelector(u),f=document.querySelector(u);!p&&f&&!r[u]&&(r[u]=await Gr(f,t,!0))}}let i=Object.values(r);if(i.length){let s="http://www.w3.org/1999/xhtml",c=document.createElementNS(s,"svg");c.setAttribute("xmlns",s),c.style.position="absolute",c.style.width="0",c.style.height="0",c.style.overflow="hidden",c.style.display="none";let u=document.createElementNS(s,"defs");c.appendChild(u);for(let p=0;p<i.length;p++)u.appendChild(i[p]);o.appendChild(c)}return o}async function Gr(o,t,n){return!n&&t.filter&&!t.filter(o)?null:Promise.resolve(o).then(r=>yT(r,t)).then(r=>vT(o,r,t)).then(r=>AT(o,r,t)).then(r=>CT(r,t))}var Rf=/url\((['"]?)([^'"]+?)\1\)/g,wT=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,PT=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ET(o){let t=o.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function kT(o){let t=[];return o.replace(Rf,(n,r,i)=>(t.push(i),n)),t.filter(n=>!Nr(n))}async function DT(o,t,n,r,i){try{let s=n?vf(t,n):t,c=Xo(t),u;if(i){let p=await i(s);u=Vc(p,c)}else u=await Yo(s,c,r);return o.replace(ET(t),`$1${u}$3`)}catch{}return o}function RT(o,{preferredFontFormat:t}){return t?o.replace(PT,n=>{for(;;){let[r,,i]=wT.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):o}function Gc(o){return o.search(Rf)!==-1}async function $s(o,t,n){if(!Gc(o))return o;let r=RT(o,n);return kT(r).reduce((s,c)=>s.then(u=>DT(u,c,t,n)),Promise.resolve(r))}async function Zo(o,t,n){var r;let i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(o);if(i){let s=await $s(i,null,n);return t.style.setProperty(o,s,t.style.getPropertyPriority(o)),!0}return!1}async function IT(o,t){await Zo("background",o,t)||await Zo("background-image",o,t),await Zo("mask",o,t)||await Zo("-webkit-mask",o,t)||await Zo("mask-image",o,t)||await Zo("-webkit-mask-image",o,t)}async function LT(o,t){let n=Ge(o,HTMLImageElement);if(!(n&&!Nr(o.src))&&!(Ge(o,SVGImageElement)&&!Nr(o.href.baseVal)))return;let r=n?o.src:o.href.baseVal,i=await Yo(r,Xo(r),t);await new Promise((s,c)=>{o.onload=s,o.onerror=t.onImageErrorHandler?(...p)=>{try{s(t.onImageErrorHandler(...p))}catch(f){c(f)}}:c;let u=o;u.decode&&(u.decode=s),u.loading==="lazy"&&(u.loading="eager"),n?(o.srcset="",o.src=i):o.href.baseVal=i})}async function _T(o,t){let r=Tt(o.childNodes).map(i=>Fc(i,t));await Promise.all(r).then(()=>o)}async function Fc(o,t){Ge(o,Element)&&(await IT(o,t),await LT(o,t),await _T(o,t))}function If(o,t){let{style:n}=o;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),o}var Lf={};async function _f(o){let t=Lf[o];if(t!=null)return t;let r=await(await fetch(o)).text();return t={url:o,cssText:r},Lf[o]=t,t}async function Mf(o,t){let n=o.cssText,r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async c=>{let u=c.replace(r,"$1");return u.startsWith("https://")||(u=new URL(u,o.url).href),Nc(u,t.fetchRequestInit,({result:p})=>(n=n.replace(c,`url(${p})`),[c,p]))});return Promise.all(s).then(()=>n)}function Vf(o){if(o==null)return[];let t=[],n=/(\/\*[\s\S]*?\*\/)/gi,r=o.replace(n,""),i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let p=i.exec(r);if(p===null)break;t.push(p[0])}r=r.replace(i,"");let s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,c="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",u=new RegExp(c,"gi");for(;;){let p=s.exec(r);if(p===null){if(p=u.exec(r),p===null)break;s.lastIndex=u.lastIndex}else u.lastIndex=s.lastIndex;t.push(p[0])}return t}async function MT(o,t){let n=[],r=[];return o.forEach(i=>{if("cssRules"in i)try{Tt(i.cssRules||[]).forEach((s,c)=>{if(s.type===CSSRule.IMPORT_RULE){let u=c+1,p=s.href,f=_f(p).then(a=>Mf(a,t)).then(a=>Vf(a).forEach(l=>{try{i.insertRule(l,l.startsWith("@import")?u+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:l,error:m})}})).catch(a=>{console.error("Error loading remote css",a.toString())});r.push(f)}})}catch(s){let c=o.find(u=>u.href==null)||document.styleSheets[0];i.href!=null&&r.push(_f(i.href).then(u=>Mf(u,t)).then(u=>Vf(u).forEach(p=>{c.insertRule(p,c.cssRules.length)})).catch(u=>{console.error("Error loading remote stylesheet",u)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(o.forEach(i=>{if("cssRules"in i)try{Tt(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function VT(o){return o.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Gc(t.style.getPropertyValue("src")))}async function NT(o,t){if(o.ownerDocument==null)throw new Error("Provided element is not within a Document");let n=Tt(o.ownerDocument.styleSheets),r=await MT(n,t);return VT(r)}function Nf(o){return o.trim().replace(/["']/g,"")}function GT(o){let t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(Nf(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(o),t}async function Oc(o,t){let n=await NT(o,t),r=GT(o);return(await Promise.all(n.filter(s=>r.has(Nf(s.style.fontFamily))).map(s=>{let c=s.parentStyleSheet?s.parentStyleSheet.href:null;return $s(s.cssText,c,t)}))).join(`
|
|
51
|
+
`)}async function Gf(o,t){let n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Oc(o,t);if(n){let r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r)}}async function Ff(o,t={}){let{width:n,height:r}=js(o,t),i=await Gr(o,t,!0);return await Gf(i,t),await Fc(i,t),If(i,t),await Cf(i,n,r)}async function Fr(o,t={}){let{width:n,height:r}=js(o,t),i=await Ff(o,t),s=await qo(i),c=document.createElement("canvas"),u=c.getContext("2d"),p=t.pixelRatio||xf(),f=t.canvasWidth||n,a=t.canvasHeight||r;return c.width=f*p,c.height=a*p,t.skipAutoScale||bf(c),c.style.width=`${f}`,c.style.height=`${a}`,t.backgroundColor&&(u.fillStyle=t.backgroundColor,u.fillRect(0,0,c.width,c.height)),u.drawImage(s,0,0,c.width,c.height),c}async function FT(o,t={}){let{width:n,height:r}=js(o,t);return(await Fr(o,t)).getContext("2d").getImageData(0,0,n,r).data}async function OT(o,t={}){return(await Fr(o,t)).toDataURL()}async function HT(o,t={}){return(await Fr(o,t)).toDataURL("image/jpeg",t.quality||1)}async function UT(o,t={}){let n=await Fr(o,t);return await Af(n)}async function KT(o,t={}){return Oc(o,t)}var zs=class{constructor(t,n){this.gameState=t;this.notifications=n;this.events=new re}addNotification(t){this.notifications.push(t),this.flush()}removeNotification(t){this.notifications=this.notifications.filter(n=>n!==t),this.flush()}clearNotifications(){this.notifications=[],this.flush()}consume(t){let n=new b,r=new ne(n);return n.registerSkipController(new K(()=>{this.removeNotification(t)})),this.addNotification(t),this.gameState.schedule(()=>{n.resolve(),this.removeNotification(t)},t.duration),this.gameState.timelines.attachTimeline(r),n}onFlush(t){return this.events.on("event:notifications.flush",t)}toArray(){return[...this.notifications]}flush(){this.events.emit("event:notifications.flush")}};var qs=class{constructor(t=100){this.history=[];this.hooks={onUndo:[],onHistoryLimit:[]};this.maxHistorySize=t}push(t,n,r,i){let s=Nl(6);if(this.history.push({action:t,id:s,args:r,undo:n,timeline:i}),this.history.length>this.maxHistorySize){let c=this.history.splice(0,this.history.length-this.maxHistorySize);this.hooks.onHistoryLimit.forEach(u=>u(c))}return{id:s}}undoUntil(t){let n=-1;for(let i=this.history.length-1;i>=0;i--)if(this.history[i].id===t){n=i;break}if(n===-1)return null;let r=[];for(let i=this.history.length-1;i>=n;i--)this.history[i].timeline&&!this.history[i].timeline.isSettled&&this.history[i].timeline.abort(),this.history[i].undo?.(...this.history[i].args||[]),r.push(this.history[i]);return this.history.splice(n),this.hooks.onUndo.forEach(i=>i(r)),r[r.length-1]?.action||null}undo(){let t=this.history.pop();return t?(t.timeline&&!t.timeline.isSettled&&t.timeline.abort(),t.undo?.(...t.args),this.hooks.onUndo.forEach(n=>n([t])),t.action):null}onUndo(t){return this.hooks.onUndo.push(t),{cancel:()=>this.offUndo(t)}}offUndo(t){this.hooks.onUndo=this.hooks.onUndo.filter(n=>n!==t)}getHistory(){return this.history}onHistoryLimit(t){return this.hooks.onHistoryLimit.push(t),{cancel:()=>this.offHistoryLimit(t)}}offHistoryLimit(t){this.hooks.onHistoryLimit=this.hooks.onHistoryLimit.filter(n=>n!==t)}reset(){this.history=[]}};var Xs=class{constructor(t){this.history=[];this.actionHistoryMgr=t,this.actionHistoryMgr.onUndo(n=>{this.crossFilter(n)}),this.actionHistoryMgr.onHistoryLimit(n=>{this.crossFilter(n)})}push(t){return this.history.push(t),this}getHistory(){return this.history}reset(){this.history=[]}crossFilter(t){let n=new Set(t.map(r=>r.id));this.history=this.history.filter(r=>!n.has(r.token))}};var Or=class Or{constructor(t,n){this.state={sounds:[],videos:[],srcManagers:[],elements:[]};this.currentHandling=null;this.playerCurrent=null;this.mainContentNode=null;this.exposedState=new Map;this.preloadingScene=null;this.htmlToImage=Hc;this.stage=n,this.game=t,this.events=new re,this.logger=new Us(t,"NarraLeaf-React"),this.audioManager=new Ks(this),this.guard=new ks(t.config.app.guard).observe(this),this.timelines=new Ds(this.guard),this.notificationMgr=new zs(this,[]),this.idManager=new Xr,this.actionHistory=new qs,this.gameHistory=new Xs(this.actionHistory)}addVideo(t){return this.state.videos.push(t),this}removeVideo(t){let n=this.state.videos.indexOf(t);return n===-1?(this.logger.weakWarn("Video not found when removing",t.getId()),this):(this.state.videos.splice(n,1),this)}isVideoAdded(t){return this.state.videos.includes(t)}getVideos(){return this.state.videos}findElementByScene(t){return this.state.elements.find(n=>n.scene===t)||null}findElementByDisplayable(t,n=null){return this.state.elements.find(r=>{if(n)return r.layers.get(n)?.includes(t)||!1;for(let i of r.layers.values())if(i.includes(t))return!0;return!1})||null}removeElement(t){let n=this.state.elements.indexOf(t);return n===-1?(this.logger.weakWarn("Element not found when removing",t.scene.getId()),this):(this.state.elements.splice(n,1),this)}preloadScene(t){return this.preloadingScene=t,this}getPreloadingScene(){return this.preloadingScene}addElement(t){return this.state.elements.push(t),this}addScene(t){return this.sceneExists(t)?this:(this.state.elements.unshift({scene:t,texts:[],menus:[],layers:new Map(t.config.layers.map(n=>[n,[]]))}),this)}flush(){return this.stage.update(),this}popScene(){let t=this.state.elements.pop();return t?(this.removeElements(t.scene),this):this}removeScene(t){return this.removeElements(t),this}getSceneElements(){return this.state.elements}getLastScene(){return this.state.elements[this.state.elements.length-1]?.scene||null}sceneExists(t){return t?this.state.elements.some(n=>n.scene===t):!!this.getLastScene()}isSceneActive(t){for(let{scene:n}of this.state.elements)if(n===t)return!0;return!1}wait(t){return new Promise(n=>setTimeout(n,t))}schedule(t,n){let r=setTimeout(()=>{t({retry:()=>{this.schedule(t,0)}})},n);return()=>clearTimeout(r)}notify(t){this.notificationMgr.addNotification(t)}handle(t){if(this.currentHandling===t)return this;switch(this.currentHandling=t,t.type){case"condition:action":break}return this}createDialog(t,n,r,i){let s=this.findElementByScene(this.getLastSceneIfNot(i))?.texts;if(!s)throw this.sceneNotFound();let c=n.evaluate(ut.getCtx({gameState:this}));this.game.getLiveGame().events.emit(Cn.EventTypes["event:character.prompt"],{character:n.config.character,sentence:n,text:Z.getText(c)});let u=this.createWaitableAction({character:n.config.character,sentence:n,id:t,words:c},()=>{s.splice(s.indexOf(u),1),r&&r()});return s.push(u),{cancel:()=>{let p=s.indexOf(u);p!==-1&&s.splice(p,1)},text:Z.getText(c)}}createMenu(t,n,r){if(!t.choices.length)throw new Error("Menu must have at least one choice");let i=this.findElementByScene(this.getLastSceneIfNot(r))?.menus;if(!i)throw this.sceneNotFound();let s=t.prompt?.evaluate(ut.getCtx({gameState:this}))||null,c=this.createWaitableAction({...t,words:s},u=>{i.splice(i.indexOf(c),1),n&&n(u),this.game.getLiveGame().events.emit(Cn.EventTypes["event:menu.choose"],{sentence:u.prompt,text:u.evaluated})});return i.push(c),{cancel:()=>{let u=i.indexOf(c);u!==-1&&i.splice(u,1)},prompt:s?Z.getText(s):null}}createDisplayable(t,n=null,r=null){let i=this.getLastSceneIfNot(n),s=this.findElementByScene(i);if(!s)throw this.sceneNotFound();let c=s.layers.get(r||i.config.defaultDisplayableLayer);if(!c)throw this.layerNotFound();return c.push(t),this}disposeDisplayable(t,n=null,r=null){let i=this.getLastSceneIfNot(n),s=this.findElementByScene(i)?.layers.get(r||i.config.defaultDisplayableLayer);if(!s)throw this.layerNotFound();let c=s.indexOf(t);if(c===-1)throw new M(`Displayables not found when disposing. (disposing: ${t.getId()})`);return s.splice(c,1),this}forceReset(){this.state.elements.forEach(({scene:t})=>{this.offSrcManager(t.srcManager),this.removeScene(t),t.events.clear()}),this.state.elements=[],this.state.srcManagers=[],this.state.videos=[],this.audioManager.reset(),this.timelines.abortAll(),this.gameHistory.reset(),this.actionHistory.reset()}getHowl(){return Of.Howl}registerSrcManager(t){return this.state.srcManagers.push(t),this}offSrcManager(t){return this.state.srcManagers=this.state.srcManagers.filter(n=>n!==t),this}getStorable(){return this.game.getLiveGame().getStorable()}getSceneByName(t){return this.game.getLiveGame().story?.getScene(t)||null}getStory(){if(!this.game.getLiveGame().story)throw new M("Story not loaded");return this.game.getLiveGame().story}setInterval(t,n){return setInterval(t,n)}clearInterval(t){clearInterval(t)}setTimeout(t,n){return setTimeout(t,n)}clearTimeout(t){clearTimeout(t)}forceAnimation(){let[t,n]=ne.proxy(b.nothing),r=[];return Array.from(this.exposedState.keys()).forEach(i=>{i instanceof Pt&&r.push(i)}),r.forEach(i=>{let c=this.getExposedStateForce(i).applyTransform(ce.immediate({}),()=>{});n.attachChild(c)}),this.timelines.attachTimeline(n),t}mountState(t,n){if(this.exposedState.has(t))throw new Dr("State already mounted");if(!t)throw new Dr("Invalid state key");return this.exposedState.set(t,n),this.events.emit(Or.EventTypes["event.state.onExpose"],t,n),{unMount:()=>{this.unMountState(t)}}}unMountState(t){return this.exposedState.has(t)||this.guard.warn("invalidExposedStateUnmounting","State not found when unmounting"),this.exposedState.delete(t),this}initVideo(t){return this.state.videos.push(t),this}isStateMounted(t){return this.exposedState.has(t)}getExposedState(t){return this.exposedState.get(t)||null}getExposedStateForce(t){let n=this.getExposedState(t);if(!n)throw new M("State not found, key: "+t);return n}getExposedStateAsync(t,n){let r=this.getExposedState(t);if(r)return{cancel:this.schedule(()=>{n(r)},0)};{let i=this.events.on(Or.EventTypes["event.state.onExpose"],(s,c)=>{s===t&&(n(c),i.cancel())});return i}}dispose(){this.forceReset()}toData(){return{scenes:this.state.elements.map(t=>({sceneId:t.scene.getId(),elements:{layers:Object.fromEntries(Array.from(t.layers.entries()).map(([n,r])=>[n.getId(),r.map(i=>i.getId())]))}})),audio:this.audioManager.toData(),videos:this.state.videos.map(t=>[t.getId(),t.toData()])}}loadData(t,n){if(this.state.elements=[],!this.game.getLiveGame().story)throw new Error("No story loaded");let{scenes:i,audio:s,videos:c}=t;i.forEach(({sceneId:u,elements:p})=>{this.logger.debug("Loading scene: "+u);let f=n.get(u);if(!f)throw new M("Scene not found, id: "+u+`
|
|
52
52
|
NarraLeaf cannot find the element with the id from the saved game`);let a={scene:f,layers:this.constructLayerMap(p.layers,n),menus:[],texts:[]};this.state.elements.push(a),this.registerSrcManager(f.srcManager),this.getExposedStateAsync(f,l=>{xe.initBackgroundMusic(f,l)})}),this.audioManager.fromData(s,n),this.state.videos=c.map(([u,p])=>{let f=n.get(u);if(!f)throw new M("Video not found, id: "+u+`
|
|
53
53
|
NarraLeaf cannot find the element with the id from the saved game`);return f.fromData(p),f})}getLastSceneIfNot(t){let n=t||this.getLastScene();if(!n||!this.sceneExists(n))throw new M('Scene not found, please call "scene.activate()" first.');return n}createElementSnapshot(t){return{scene:t.scene,layers:new Map(Array.from(t.layers.entries()).map(([n,r])=>[n,r.map(i=>[i,i.toData()])]))}}fromElementSnapshot(t){return{scene:t.scene,layers:new Map(Array.from(t.layers.entries()).map(([n,r])=>[n,r.map(([i,s])=>(i.fromData(s),i))])),texts:[],menus:[]}}removeElements(t){let n=this.state.elements.findIndex(r=>r.scene===t);return n===-1?(this.logger.weakWarn("Scene not found when removing elements",t.getId()),this):(this.resetLayers(this.state.elements[n].layers),this.state.elements.splice(n,1),this)}resetLayers(t){t.forEach(n=>{n.forEach(r=>{r.reset()})})}createWaitableAction(t,n){return{action:t,onClick:i=>{n&&n(i)}}}sceneNotFound(){return new M("Scene not found, target scene may not be activated. This is an internal error, please report this to the developer.")}layerNotFound(){return new M("Layer not found, target layer may not be activated. You may forget to add the layer to the scene config")}constructLayerMap(t,n){return new Map(Object.entries(t).map(([r,i])=>{let s=n.get(r);if(!s)throw new M("Layer not found, id: "+r+`
|
|
54
54
|
NarraLeaf cannot find the element with the id from the saved game`);return[s,i.map(c=>{if(!n.has(c))throw new M("Displayable not found, id: "+c+`
|
|
55
55
|
NarraLeaf cannot find the element with the id from the saved game
|
|
56
|
-
This may be caused by the damage of the saved game file or the change of the story file`);return n.get(c)})]}))}};Or.EventTypes={"event:state.end":"event:state.end","event:state.player.skip":"event:state.player.skip","event:state.player.requestFlush":"event:state.player.requestFlush","event.state.onExpose":"event.state.onExpose","event:state.onRender":"event:state.onRender"};var ie=Or;var
|
|
56
|
+
This may be caused by the damage of the saved game file or the change of the story file`);return n.get(c)})]}))}};Or.EventTypes={"event:state.end":"event:state.end","event:state.player.skip":"event:state.player.skip","event:state.player.requestFlush":"event:state.player.requestFlush","event.state.onExpose":"event.state.onExpose","event:state.onRender":"event:state.onRender"};var ie=Or;var Xt=class Xt{constructor(t){this.gameLock=new Xn;this.events=new re;this.story=null;this.currentSavedGame=null;this.lockedAwaiting=null;this.gameState=void 0;this._lockedCount=0;this.currentAction=null;this.game=t,this.storable=new _r,this.initNamespaces()}initNamespaces(){return this.storable.clear().addNamespace(new $t(Xt.GameSpacesKey.game,Xt.DefaultNamespaces.game)),this.story&&this.story.initPersistent(this.storable),this}getStorable(){return this.storable}loadStory(t){return this.story=t.constructStory(),this}serialize(){this.assertGameState();let t=this.gameState,n=this.story;if(!n)throw new Error("No story loaded");if(!this.currentSavedGame)throw new Error("Failed when trying to serialize the game: The game has not started");let r=this.storable.toData(),i=t.toData(),s=this.getCurrentAction()?.getId()||null,c=n.getAllElementStates();return{name:this.currentSavedGame.name,meta:{created:this.currentSavedGame.meta.created,updated:Date.now(),id:this.currentSavedGame.meta.id},game:{store:r,stage:i,currentAction:s,elementStates:c,services:n.serializeServices()}}}deserialize(t){this.assertGameState();let n=this.gameState,r=this.story;if(!r)throw new Error("No story loaded");this.reset({gameState:n}),n.stage.forceRemount();let i=new Map,s=new Map,{game:{store:c,stage:u,elementStates:p,currentAction:f,services:a}}=t;if(r.forEachChild(r,r.entryScene?.getSceneRoot()||[],l=>{i.set(l.getId(),l),s.set(l.callee.getId(),l.callee)},{allowFutureScene:!0}),this.storable.clear().load(c),p.forEach(({id:l,data:m})=>{n.logger.debug("restore element",l);let d=s.get(l);if(!d)throw new Error("Element not found, id: "+l+`
|
|
57
57
|
NarraLeaf cannot find the element with the id from the saved game`);d.reset(),d.fromData(m)}),this.currentSavedGame=t,n.loadData(u,s),f){let l=i.get(f);if(!l)throw new Error("Action not found, id: "+f+`
|
|
58
|
-
NarraLeaf cannot find the action with the id from the saved game`);this.currentAction=l}r.deserializeServices(a),n.stage.forceUpdate(),n.events.once(ie.EventTypes["event:state.onRender"],()=>{n.schedule(()=>{n.stage.next()},0)})}getHistory(){return this.assertGameState(),this.gameState.gameHistory.getHistory()}undo(t){this.assertGameState(),this.lockedAwaiting&&(this.lockedAwaiting.abort(),this.lockedAwaiting=null);let n=this.currentAction;t?n=this.gameState.actionHistory.undoUntil(t):n=this.gameState.actionHistory.undo(),n?this.currentAction=n:this.gameState.logger.warn("LiveGame.undo","No action found"),this.gameState.logger.info("LiveGame.undo","Undo until",t,"currentAction",this.currentAction,"action",n),this.gameState.stage.forceUpdate(),this.gameState.stage.next(),this.gameState.schedule(()=>{this.gameState&&this.gameState.forceAnimation()},0)}dispose(){this.events.clear(),this.gameState?.dispose()}notify(t,n=3e3){this.assertGameState();let r=this.gameState.idManager.generateId();this.gameState.notificationMgr.consume({id:r,message:t,duration:n})}assertScreenshot(){this.assertGameState(),this.assertPlayerElement()}capturePng(){return this.assertScreenshot(),this.gameState.htmlToImage.toPng(this.gameState.mainContentNode,this.getScreenshotOptions())}captureJpeg(){return this.assertScreenshot(),this.gameState.htmlToImage.toJpeg(this.gameState.mainContentNode,this.getScreenshotOptions())}captureSvg(){return this.assertScreenshot(),this.gameState.htmlToImage.toSvg(this.gameState.mainContentNode,this.getScreenshotOptions())}capturePngBlob(){return this.assertScreenshot(),this.assertGameState(),this.assertPlayerElement(),this.gameState.htmlToImage.toBlob(this.gameState.mainContentNode,this.getScreenshotOptions())}onCharacterPrompt(t){return this.events.on(
|
|
59
|
-
Please refresh the page`);return this.lockedAwaiting}let r=this.lockedAwaiting.result;return this.currentAction=r?.node?.action||null,this.lockedAwaiting=null,this.currentAction||t.events.emit(ie.EventTypes["event:state.end"]),t.logger.debug("next action (lockedAwaiting)",r),r||null}if(!this.currentAction)return t.logger.weakWarn("LiveGame","No current action"),null;let n=this.currentAction.executeAction(t);return b.isAwaitable(n)?(this.lockedAwaiting=n,n):(t.logger.debug("next action",n),this._lockedCount=0,this.currentAction=n.node?.action||null,n)}isPlaying(){return!!this.currentAction}abortAwaiting(){if(this.lockedAwaiting){let t=this.lockedAwaiting.abort();this.currentAction=t?.node?.action||null,this.lockedAwaiting=null}}executeAction(t,n){let r=n.executeAction(t);return b.isAwaitable(r)?r:r?.node?.action||null}executeActionRaw(t,n){return n.executeAction(t)}setGameState(t){return this.gameState=t,this}getGameState(){return this.gameState}getAllPredictableActions(t,n,r){let i=n?.contentNode||null,s=[],c=[],u=new Set;for(;(i||c.length)&&!(r&&s.length>=r);){if(i||(i=c.pop().contentNode),[bn].some(p=>i?.action&&i.action instanceof p)){i=null;continue}if(i.action&&i.action.is(xe,ge.jumpTo)){let[p]=i.action.contentNode.getContent(),f=t.getScene(p);if(!f)throw i.action._sceneNotFoundError(i.action.getSceneName(p));if(u.has(f)){i=null;continue}u.add(f),i=f.getSceneRoot()?.contentNode||null;continue}else if(i.action&&i.action.is(he,ft.do)){let[p]=i.action.contentNode.getContent();i.getChild()?.action&&c.push(i.getChild().action),i=p[0]?.contentNode||null}i.action&&s.push(i.action),i=i.getChild()}return s}getNewSavedGame(){return{name:"",meta:{created:Date.now(),updated:Date.now(),id:Gl()},game:{store:{},stage:{scenes:[],audio:{sounds:[]},videos:[]},elementStates:[],currentAction:this.story?.entryScene?.getSceneRoot().getId()||null,services:{}}}}assertGameState(){if(!this.gameState)throw new M("No game state found, make sure you call this method in effect hooks or event handlers")}assertPlayerElement(){if(this.assertGameState(),!this.gameState.playerCurrent)throw new M("Player Element Not Mounted")}};zt.DefaultNamespaces={game:{}},zt.GameSpacesKey={game:"game"},zt.EventTypes={"event:character.prompt":"event:character.prompt","event:menu.choose":"event:menu.choose"};var Cn=zt;var Hr=class Hr{constructor(t){this.settings=t;this.events=new re;this.events.setMaxListeners(64)}setPreference(t,n){this.settings[t]=n,this.events.emit(Hr.EventTypes["event:game.preference.change"],t,n)}getPreference(t){return this.settings[t]}getPreferences(){return this.settings}onPreferenceChange(t,n){return this.events.on(Hr.EventTypes["event:game.preference.change"],(r,i)=>{typeof t=="string"?t===r&&n&&n(i):t(r,i)})}importPreferences(t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.setPreference(n,t[n])}exportPreferences(){let t={};for(let n in this.settings)Object.prototype.hasOwnProperty.call(this.settings,n)&&(t[n]=this.settings[n]);return t}togglePreference(t){this.setPreference(t,!this.getPreference(t))}};Hr.EventTypes={"event:game.preference.change":"event:game.preference.change"};var Xs=Hr;function Hf(o){var t,n,r="";if(typeof o=="string"||typeof o=="number")r+=o;else if(typeof o=="object")if(Array.isArray(o)){var i=o.length;for(t=0;t<i;t++)o[t]&&(n=Hf(o[t]))&&(r&&(r+=" "),r+=n)}else for(n in o)o[n]&&(r&&(r+=" "),r+=n);return r}function BT(){for(var o,t,n=0,r="",i=arguments.length;n<i;n++)(o=arguments[n])&&(t=Hf(o))&&(r&&(r+=" "),r+=t);return r}var q=BT;import{flushSync as Ad}from"react-dom";import Bf,{useEffect as YT,useRef as ZT,useState as Wf}from"react";import Kf from"react";import WT,{createContext as jT,useContext as $T,useEffect as zT,useReducer as qT,useState as XT}from"react";var qt=class qt{constructor(){this.state={width:0,height:0,minWidth:800,minHeight:450,paused:!1,scale:0};this.events=new re().setMaxListeners(1/0);this.lockers=[];this.updater=null}update(t,n,r){this.state.width=t,this.state.height=n,this.state.scale=r,this.events.emit(qt.EventTypes["event:aspectRatio.update"],t,n)}updateMin(t,n){this.state.minWidth=t,this.state.minHeight=n}lock(){let t=Symbol();return this.lockers.push(t),t}unlock(t){if(t&&!this.lockers.includes(t))throw new Error("Locker not found");return this.lockers=this.lockers.filter(n=>n!==t),this.triggerUpdate(),null}isLocked(){return!!this.lockers.length}getStyle(){return{width:`${this.state.width}px`,height:`${this.state.height}px`}}setUpdate(t){this.updater=t}pause(){this.state.paused=!0,this.events.emit(qt.EventTypes["event:aspectRatio.pause"])}resume(){this.state.paused=!1,this.events.emit(qt.EventTypes["event:aspectRatio.resume"])}onUpdate(t){return this.events.on(qt.EventTypes["event:aspectRatio.update"],t).cancel}requestUpdate(){this.events.emit(qt.EventTypes["event:aspectRatio.requestUpdate"])}onRequestedUpdate(t){return this.events.on(qt.EventTypes["event:aspectRatio.requestUpdate"],t).cancel}triggerUpdate(){this.updater&&this.updater()}};qt.EventTypes={"event:aspectRatio.update":"event:aspectRatio.update","event:aspectRatio.pause":"event:aspectRatio.pause","event:aspectRatio.resume":"event:aspectRatio.resume","event:aspectRatio.requestUpdate":"event:aspectRatio.requestUpdate"};var Uc=qt,Kc=jT(null);function Uf({children:o}){"use client";let[t]=XT(()=>new Uc);return WT.createElement(Kc,{value:{ratio:t}},o)}function be(){let o=$T(Kc),[,t]=qT(r=>r+1,0);if(!Kc||!o)throw new Error("useRatio must be used within a RatioProvider");let{ratio:n}=o;return zT(()=>n.onUpdate(()=>{t()}),[]),o}function kt({children:o,className:t,props:n,style:r,ref:i}){let{ratio:s}=be(),c=s.getStyle();return Kf.createElement("div",{className:q("inset-0",t),style:{width:"100%",height:"100%",minWidth:`${s.state.minWidth}px`,minHeight:`${s.state.minHeight}px`}},Kf.createElement("div",{style:{...c,position:"relative",...n?.style||{},...r||{}},...n||{},ref:i},o))}function Bc({src:o,width:t,height:n}){let[r,i]=Wf({x:0,y:0}),[s,c]=Wf(!1),u=ZT(null),{ratio:p}=be();return YT(()=>{let f=a=>{if(u.current){let l=u.current.getBoundingClientRect(),m=a.clientX-l.left,d=a.clientY-l.top;i({x:m,y:d}),s||c(!0)}};return window.addEventListener("mousemove",f),()=>{window.removeEventListener("mousemove",f)}},[s]),Bf.createElement(kt,{ref:u,className:"overflow-hidden absolute"},Bf.createElement("img",{src:o,style:{position:"absolute",left:r.x,top:r.y,width:t,height:n,pointerEvents:"none",zIndex:1001,display:s?"block":"none",cursor:"none",transform:`scale(${p.state.scale})`},alt:""}))}var Kn=class Kn{constructor(){this.preloaded=[];this.events=new re}add(t){let n=this.getSrc(t);return n&&this.has(n)?this:(this.preloaded.push(t),this.events.emit(Kn.EventTypes["event:preloaded.add"],t),this.events.emit(Kn.EventTypes["event:preloaded.change"]),this)}get(t){return this.preloaded.find(n=>this.getSrc(n)===t)}has(t){return Array.isArray(t)?t.every(n=>this.has(n)):this.preloaded.some(n=>this.getSrc(n)===t)}remove(t){if(Array.isArray(t)){let r=t.map(i=>this.getSrc(i));return this.preloaded=this.preloaded.filter(i=>!r.includes(this.getSrc(i))),this}let n=this.getSrc(t);return this.preloaded=this.preloaded.filter(r=>this.getSrc(r)!==n),this.events.emit(Kn.EventTypes["event:preloaded.remove"],t),this.events.emit(Kn.EventTypes["event:preloaded.change"]),this}clear(){return this.preloaded=[],this}getSrc(t){return Ne.getSrc(t)}};Kn.EventTypes={"event:preloaded.add":"event:preloaded.add","event:preloaded.remove":"event:preloaded.remove","event:preloaded.change":"event:preloaded.change","event:preloaded.mount":"event:preloaded.mount","event:preloaded.ready":"event:preloaded.ready","event:preloaded.unmount":"event:preloaded.unmount"};var nt=Kn;import qf,{useEffect as Xf,useState as nv}from"react";import jf,{useContext as JT,useState as QT}from"react";var $f=jf.createContext(null);function zf({children:o,game:t}){"use client";let n=new de({}),[r]=QT(t||n);return jf.createElement($f,{value:r},o)}function N(){let o=JT($f);if(!o)throw new Error("useGame must be used within a GameProvider");return o}import{useEffect as ev,useState as tv}from"react";function ut(o){let[t,n]=tv(0);ev(()=>{r()},o??[]);function r(){n(i=>i+1)}return[r,t]}function Wc({children:o,className:t,gameState:n}){let[r,i]=nv({}),{ratio:s}=be(),c=N(),[u]=ut(),p=c.config.minWidth,f=c.config.minHeight;return Xf(()=>{n.logger.debug("AspectRatio","mount, using interval",c.config.ratioUpdateInterval);let a=()=>{if(s.isLocked()){n.logger.weakWarn("Ratio is locked, skipping update");return}let h=document.getElementById(c.config.contentContainerId);if(h){let g=h.clientWidth,y=h.clientHeight,T=c.config.aspectRatio,v,S;g/y>T?(v=y*T,S=y):(v=g,S=g/T),v<p&&(v=p),S<f&&(S=f),i({width:`${v}px`,height:`${S}px`,margin:"auto",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",display:"flex",alignItems:"center",justifyContent:"center"});let C=v/c.config.width;s.update(v,S,C),s.updateMin(p,f),u()}};s.setUpdate(a);let m=Rl(()=>{a()},c.config.ratioUpdateInterval);m(),window.addEventListener("resize",m);let d=s.onRequestedUpdate(m);return()=>{window.removeEventListener("resize",m),d()}},[s,c.config.ratioUpdateInterval]),Xf(()=>n.events.on(ie.EventTypes["event:state.player.requestFlush"],u).cancel,[n]),qf.createElement("div",{id:c.config.contentContainerId,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},qf.createElement("div",{className:q(t),style:r},o))}import Yf from"react";import Xt from"react";function jc({error:o,errorInfo:t}){let n=N();return n.config.onError&&n.config.onError(o),n.config.app.debug?Xt.createElement("div",{className:"text-left"},Xt.createElement("h1",null,"NarraLeaf-React cannot initialize the player correctly. (development mode)"),Xt.createElement("p",{className:"text-red-700"},"Message: ",o.message),Xt.createElement("pre",null,"Error Stack: ",o?.stack),Xt.createElement("pre",null,"Component Stack: ",t?.componentStack),Xt.createElement("pre",null,"Digest: ",t?.digest)):Xt.createElement("div",{className:"bg-white w-full h-full"},Xt.createElement("h1",null,"NarraLeaf-React crashed due to an unknown error."),Xt.createElement("p",null,"Please contact the game developer for further assistance."))}var Ys=class extends Yf.Component{constructor(){super(...arguments);this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n,errorInfo:null}}componentDidCatch(n,r){this.setState({error:n,errorInfo:r}),console.error(n,r)}render(){return this.state.hasError?Yf.createElement(jc,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}};import $c,{createContext as ov,useContext as rv,useState as Zf}from"react";var Zs=class o{constructor(t){this.game=t;this.src=new Map;this.preloadTasks=new Map;this.game.addSideEffect(()=>{this.abortAll(),this.src.clear()})}static getImage(t,n,r){return Ll(t,{...r,signal:n})}has(t){return this.src.has(t)}add(t,n){return this.src.set(t,n),this}remove(t){return this.src.delete(t),this}get(t){return this.src.get(t)}clear(){return this.src.clear(),this}size(){return this.src.size}isPreloading(t){return this.preloadTasks.has(t)}preload(t,n){if(this.src.has(n)||this.preloadTasks.has(n)){let l={abort:()=>{},onFinished:()=>l,onErrored:()=>l};return l}let r=n,i={};this.game.hooks.rawTrigger("preloadImage",()=>[r,(l,m)=>{r=l,i={...i,...m}}]);let s=new AbortController,c=s.signal,u=[],f={promise:o.getImage(r,c,i).then(l=>{this.preloadTasks.delete(n),l&&this.add(n,l)}).catch(l=>{t.logger.error("ImageCacheManager",`Failed to preload image: ${n}`,`Reason: ${l}`),u.forEach(m=>m(l))}),controller:s};this.preloadTasks.set(n,f);let a={abort:()=>{s.abort(),this.preloadTasks.delete(n)},onFinished:l=>(f.promise.then(l),a),onErrored:l=>(u.push(l),a)};return a}abortAll(){this.preloadTasks.forEach(t=>{t.controller.abort()}),this.preloadTasks.clear()}abort(t){let n=this.preloadTasks.get(t);n&&(n.controller.abort(),this.preloadTasks.delete(t))}preloadedSrc(){return Array.from(this.src.values())}filter(t){for(let n of this.src.keys())t.includes(n)||this.src.delete(n);return this}};var zc=ov(null);function Jf({children:o}){let t=N(),[n]=Zf(()=>new nt),[r]=Zf(()=>new Zs(t));return $c.createElement($c.Fragment,null,$c.createElement(zc,{value:{preloaded:n,cacheManager:r}},o))}function Jo(){if(!zc)throw new Error("usePreloaded must be used within a PreloadedProvider");return rv(zc)}import{useEffect as qc,useRef as iv}from"react";function Qf({state:o}){let{preloaded:t,cacheManager:n}=Jo(),r=N(),i=iv(new Set),s="Preload",c=o.getLastScene(),u=r.getLiveGame().getCurrentAction(),p=r.getLiveGame().story;function f(){o.logger.debug(s,"Preload unmounted"),t.events.emit(nt.EventTypes["event:preloaded.unmount"])}return qc(()=>{if(typeof fetch>"u")return t.events.emit(nt.EventTypes["event:preloaded.ready"]),o.logger.warn(s,"Fetch is not supported in this environment, skipping preload"),f;if(!r.config.preloadAllImages)return t.events.emit(nt.EventTypes["event:preloaded.ready"]),o.logger.debug(s,"Preload all images is disabled, skipping preload"),f;if(r.config.forceClearCache&&(n.clear(),o.logger.weakWarn(s,"Cache cleared")),!p||!c)return o.logger.weakWarn(s,"Story/Scene not found, skipping preload"),f;let a=performance.now(),l=Ne.catSrc([...c.srcManager?.src||[],...c.srcManager?.getFutureSrc()||[]]),m=new ir(r.config.preloadConcurrency,r.config.preloadDelay),d=[],h=o.logger.group(s,!0),g=[];o.logger.debug(s,"preloading:",l,c);for(let y of l.image){let T=Ne.getSrc(y);if(T){if(d.push(T),n.has(T)||n.isPreloading(T)||g.includes(T)){o.logger.debug(s,`Image already loaded (${l.image.indexOf(y)+1}/${l.image.length})`,T),g.push(T);continue}g.push(T),m.addTask(()=>new Promise(v=>{n.preload(o,T).onFinished(()=>{o.logger.debug(s,`Image loaded (${l.image.indexOf(y)+1}/${l.image.length})`,T),v()}).onErrored(()=>{o.logger.weakError(s,`Failed to preload image (${l.image.indexOf(y)+1}/${l.image.length})`,T),v()})}))}}return h.end(),m.start().then(()=>{o.logger.info(s,"Image preload",`loaded ${n.size()} images in ${performance.now()-a}ms`),r.config.waitForPreload&&t.events.emit(nt.EventTypes["event:preloaded.ready"]),n.filter(d)}),r.config.waitForPreload||t.events.emit(nt.EventTypes["event:preloaded.ready"]),t.events.emit(nt.EventTypes["event:preloaded.mount"]),f},[c,p]),qc(()=>{i.current.clear()},[c]),qc(()=>{if(typeof fetch>"u"||r.config.preloadAllImages)return;if(!p){o.logger.weakWarn(s,"Story not found, skipping preload");return}let a=performance.now(),l=r.getLiveGame().getAllPredictableActions(p,u,r.config.maxPreloadActions).map(T=>Ne.getPreloadableSrc(p,T)).filter(function(T){return T!==null});l.filter(function(T){return T?.activeType==="scene"}).forEach(T=>{i.current.has(T)||i.current.add(T)});let d=Ne.catSrc([...i.current,...l]),h=new ir(r.config.preloadConcurrency,r.config.preloadDelay),g=[],y=o.logger.group(s);o.logger.debug(s,"preloading:",d);for(let T of d.image){let v=Ne.getSrc(T);if(v){if(g.push(v),n.has(v)||n.isPreloading(v)){o.logger.debug(s,`Image already loaded (${d.image.indexOf(T)+1}/${d.image.length})`,v);continue}h.addTask(()=>new Promise(S=>{n.preload(o,v).onFinished(()=>{o.logger.debug(s,`Image loaded (${d.image.indexOf(T)+1}/${d.image.length})`,v),S()}).onErrored(()=>{o.logger.weakError(s,`Failed to preload image (${d.image.indexOf(T)+1}/${d.image.length})`,v),S()})}))}}y.end(),h.start().then(()=>{o.logger.info(s,"Image preload (quick reload)",`loaded ${n.size()} images in ${performance.now()-a}ms`),n.filter(g)})},[u,p]),null}import Ae,{useEffect as ma,useReducer as Cd,useState as Sl}from"react";import Qo,{useEffect as cv}from"react";import ed from"react";import Js from"react";function Qs({children:o,className:t,style:n}){let{ratio:r}=be(),i=N();return Js.createElement(kt,{className:q("absolute pointer-events-none w-full h-full"),style:{transform:`scale(${r.state.scale})`,transformOrigin:"left top",width:i.config.width,height:i.config.height,pointerEvents:"none"}},Js.createElement("div",{className:"absolute inset-0 pointer-events-auto"},Js.createElement("div",{className:"inset-0"},Js.createElement("div",{className:q(t),style:n},o))))}function Xc({id:o,children:t,className:n,style:r,...i}){return ed.createElement(Ht.div,{className:q("w-full h-full"),key:o,...i},ed.createElement(Qs,{className:n,style:r},t))}import Yc,{createContext as sv,useContext as td,useState as av}from"react";var Zc=class{constructor(t,n){this.events=new re;this.current=null;this.history=[];this.historyIndex=-1;this.game=t,n&&(this.current=n,this.history.push(n),this.historyIndex=0)}getCurrentId(){return this.current}push(t){return this.historyIndex<this.history.length-1&&(this.history=this.history.slice(0,this.historyIndex+1)),this.history.push(t),this.history.length>this.game.config.maxRouterHistory&&(this.history.shift(),this.historyIndex--),this.historyIndex++,this.current=t,this.emitOnChange(),this}back(){return this.historyIndex>0?(this.historyIndex--,this.current=this.history[this.historyIndex],this.emitOnChange()):(this.current=null,this.emitOnChange()),this}forward(){return this.historyIndex<this.history.length-1&&(this.historyIndex++,this.current=this.history[this.historyIndex],this.emitOnChange()),this}clear(){return this.current=null,this.history=[],this.historyIndex=-1,this.emitOnChange(),this}cleanHistory(){return this.history=this.current?[this.current]:[],this.historyIndex=this.current?0:-1,this}isActive(){return this.current!==null}emitOnChange(){this.events.emit("event:router.onChange")}},Jc=sv(null);function nd({children:o}){"use client";let t=N(),[n]=av(()=>new Zc(t));return Yc.createElement(Yc.Fragment,null,Yc.createElement(Jc,{value:{router:n}},o))}function Ur(){if(!td(Jc))throw new Error("usePreloaded must be used within a PreloadedProvider");return td(Jc).router}import Qc from"react";function el({children:o,className:t,style:n}){return Qc.createElement(Qc.Fragment,null,Qc.createElement(Qs,{style:n,className:t},o))}function od({children:o}){let[t]=ut(),n=Ur(),r=N();if(cv(()=>{if(n)return n.events.on("event:router.onChange",t).cancel},[]),!n)return null;let i=Qo.Children.toArray([...r.config.stage?[r.config.stage]:[],...o?[o]:[]]),s=Xc,u=i.filter(function(l){return Qo.isValidElement(l)&&l.type===s}).find(l=>l.props.id===n.getCurrentId()),p=el,f=i.find(function(l){return Qo.isValidElement(l)&&l.type===p});return Qo.createElement(Qo.Fragment,null,f,Qo.createElement(cr,null,u))}import jn,{useEffect as hl,useRef as _v}from"react";import ea,{useEffect as uv}from"react";import tl,{useEffect as Kr,useRef as rd,useState as nl}from"react";function er({element:o,state:t,skipTransform:n,skipTransition:r,overwriteDefinition:i,onTransform:s,transitionsProps:c=[],propOverwrite:u}){let[p,f]=nl(null),[a,l]=nl(null),m=tl.useRef(null),[d]=nl(()=>new qr("displayable.refGroup")),h=rd(d.next()),g=rd(V()),T=N().getLiveGame().getGameState(),v=typeof c=="function"?c(p):c,[S]=ut([a,p,g]);Kr(()=>T.events.depends([T.events.on(ie.EventTypes["event:state.player.skip"],P)]).cancel,[a,p,g]),Kr(()=>{if(!p)return;if(g.current.some(([oe])=>!oe.current))throw new M("Displayable: Trying to access transition groups before they are mounted");let{controller:I,task:W}=p;return I.onUpdate(oe=>{g.current.forEach(([Fe],O)=>{let F=W.resolve[O],ae=typeof F=="function"?F:F.resolver;if(!ae)throw new M(`Displayable: Trying to resolve element props but found no resolver. (reading: transitionTask.task.resolve[${O}])`);let H=ae(...oe),j=U(v[O]||v[v.length-1]||{},H);x(Fe,u?u(j):j)})}).cancel},[p]),Kr(()=>{if(!g.current||!g.current.length)throw new M("Displayable: Transition group refs are not initialized correctly");if(g.current.some(([I])=>!I.current))throw new M("Displayable: Trying to access transition groups before they are mounted");g.current.forEach(([I],W)=>{if(!I.current)throw new M("Displayable: Trying to assign properties to unmounted element");x(I,v[W]||v[v.length-1]||{})})},[p]),Kr(()=>{if(!m.current)throw new Error(`Scope not ready. Using element: ${o.constructor.name}`)},[]),Kr(()=>{let I=t.toStyle(T,i);Object.assign(m.current.style,I),T.logger.debug("Displayable","Initial style applied",m.current,I)},[]);function C(I){T.logger.debug("Displayable","Transform applied",t.toStyle(T,i),m.current),S(),s?.(I)}function x(I,W){if(!I.current)throw new M("Displayable: Trying to assign properties to unmounted element");let se=I.current,oe={},Fe={};Object.keys(W).forEach(F=>{let ae=F;ae==="style"&&W.style?Object.assign(oe,W.style):W[ae]!==void 0&&ae!=="key"&&(Fe[ae]=W[ae])}),Object.keys(oe).length>0&&Object.assign(se.style,oe);let O=u?u(Fe):Fe;for(let[F,ae]of Object.entries(O))se.getAttribute(F)!==ae&&se.setAttribute(F,ae)}function w(I,W){a&&(a.abort(),l(null));let se=I.animate(t,{gameState:T,ref:m,overwrites:i}),oe=new ne(se);return T.timelines.attachTimeline(oe),se.onSkipControllerRegister(Fe=>{Fe.onAbort(()=>{oe.abort()})}),l(se),se.then(()=>{l(null),C(I),W()}),oe}function _(I,W){p&&p.controller.complete();let se=I.createTask(T),oe=I.requestAnimations(se.animations),Fe=new b().registerSkipController(new K(oe.cancel)),O=new ne(Fe);Fe.skipController.onAbort(()=>{oe.cancel()}),oe.onCanceled(()=>{O.abort()}),T.timelines.attachTimeline(O),f({task:se,controller:oe,transition:I,resolve:W});let F;if(g.current=se.resolve.map(ae=>{let H=tl.createRef(),j=typeof ae=="function"?void 0:ae.key;if(!j)return[H,d.next()];if(j==="target")return F=d.next(),[H,F];if(j==="current")return[H,h.current];throw new M("Displayable: Invalid key type")}),!F)throw new M("Displayable: No target key found");return h.current=F,oe.start(),oe.onComplete(()=>{J(),f(null),W(),Fe.resolve()}),O}function A(I){return T.logger.debug("initDisplayable",o),w(ce.immediate(t.get()),I)}function P(){n&&a&&(a.abort(),l(null),T.logger.debug("transform skipped")),r&&p&&(p.controller.complete(),T.logger.debug("transition skipped"))}function V(){return[[tl.createRef(),h.current]]}function J(){g.current.forEach(([I])=>{I.current=null}),g.current=V()}return{transformRef:m,transitionRefs:g.current,isTransforming:!!a,transitionTask:p,initDisplayable:A,applyTransform:w,applyTransition:_,deps:[a,p,g]}}import{useEffect as lv}from"react";function wn(o,t,n=[]){let i=N().getLiveGame().getGameState();return lv(()=>{let s=typeof t=="function"?t():t;return i.mountState(o,s).unMount},[...n]),[]}function id({state:o,layer:t,children:n}){let{transformRef:r,transitionRefs:i,initDisplayable:s,applyTransition:c,applyTransform:u,deps:p}=er({element:t,state:t.transformState,skipTransform:o.game.config.allowSkipLayersTransform,skipTransition:!1,transitionsProps:[{style:{width:"100%",height:"100%",transformOrigin:"center"}}]});return wn(t,{initDisplayable:s,applyTransition:c,applyTransform:u},[...p]),uv(()=>(o.logger.debug("Layer","Layer mounted",t.getId()),()=>{o.logger.debug("Layer","Layer unmounted",t.getId())}),[]),ea.createElement(ea.Fragment,null,ea.createElement(Ht.div,{layout:!0,className:"absolute w-full h-full",ref:r,"data-element-type":"layer","data-layer-id":t.getId(),key:`layer-${t.getId()}`},i.map(([f,a])=>ea.createElement("div",{className:"relative w-full h-full",ref:f,key:a},n))))}import ra from"react";import na from"react";import pt,{useState as sd}from"react";function ta({children:o,border:t="solid",color:n="red",tag:r,borderWidth:i=1,as:s="div",ref:c,...u}){let p=N(),[f,a]=sd(!1);if(!p.config.app.inspector)return pt.createElement(s,{...u,ref:c},o);let l={...u,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{...u.style||{},outline:`${i}px ${t} ${n}`,zIndex:f?1e3:"auto"}};return pt.createElement(s,{...l,ref:c},r&&f&&pt.createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black text-sm"},r),o)}function pv({border:o="solid",color:t="red",tag:n,borderWidth:r=1,as:i="img",...s}){let c=N(),[u,p]=sd(!1);if(!c.config.app.inspector)return pt.createElement(i,{...s});let f={...s,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{...s.style||{},outline:`${o} ${r}px ${t}`,zIndex:u?1e3:"auto"}};return pt.createElement("div",null,pt.createElement(i,{...f}),n&&u&&pt.createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black"},n))}function mv(o){return pt.createElement(ta,{...o,as:"div"})}function fv(o){return pt.createElement(ta,{...o,as:"span"})}function dv(o){return pt.createElement(pv,{...o,as:"img"})}function hv(o){return pt.createElement(ta,{...o,as:"button"})}function gv(o){return pt.createElement(ta,{...o,as:Ht.div,ref:o.ref,layout:o.layout})}var yv={Div:mv,Span:fv,Button:hv,Img:dv,mDiv:gv},Bn=yv;function ol({state:o,text:t}){let{ratio:n}=be(),[r]=ut(),{transformRef:i,transitionRefs:s,initDisplayable:c,applyTransform:u,applyTransition:p,deps:f,isTransforming:a}=er({element:t,state:t.transformState,skipTransform:o.game.config.allowSkipTextTransform,skipTransition:o.game.config.allowSkipTextTransition,overwriteDefinition:{overwrite:l=>({width:"fit-content",transform:ce.propToCSSTransform(o,l,{translate:[t.config.alignX==="left"?"0%":t.config.alignX==="right"?"-100%":void 0,t.config.alignY==="top"?"100%":t.config.alignY==="bottom"?"0%":void 0]})})},transitionsProps:[{style:{width:"fit-content",whiteSpace:"nowrap",transform:`scale(${n.state.scale})`,transformOrigin:`${t.config.alignX} ${t.config.alignY}`,fontSize:`${t.state.fontSize}px`}}]});return wn(t,{initDisplayable:c,applyTransform:u,applyTransition:p,flush:r},[...f]),na.createElement(Bn.Div,{"data-element-type":"text"},na.createElement(Bn.mDiv,{tag:"text.container",color:"green",border:"dashed",layout:a,ref:i,className:"absolute"},s.map(([l,m])=>na.createElement("span",{key:m,ref:l,className:t.config.className},na.createElement("span",null,t.state.text)))))}import tr,{useRef as cd,useState as ld}from"react";import rl,{useEffect as ad,useRef as Tv}from"react";function il({ref:o,onSizeChanged:t,onLoad:n,autoFit:r=!1}){let i=Tv(null),{ratio:s}=be(),[c,u]=rl.useState(()=>s.state.width),[p,f]=rl.useState(()=>s.state.height),a=N();ad(()=>(l(),s.onUpdate(l)),[o]),ad(()=>{let d=new MutationObserver(h=>{h.forEach(g=>{g.type==="attributes"&&g.attributeName==="src"&&i.current&&l()})});return i.current&&d.observe(i.current,{attributes:!0}),()=>{d.disconnect()}},[]);function l(){let d=o||i;if(d.current&&d.current.naturalWidth)if(d.current.naturalWidth*d.current.naturalHeight===1){let h=s.state.width,g=s.state.height,y=`${h} / ${g}`;u(h),f(g),d.current.style.aspectRatio=y,t&&t(h,g)}else{let h=r?a.config.width/d.current.naturalWidth:1,g=d.current.naturalWidth*s.state.scale*h,y=d.current.naturalHeight*s.state.scale*h;u(g),f(y),t&&t(g,y)}}function m(){l(),n&&n()}return rl.createElement("img",{ref:o||i,onLoad:m,width:c,height:p,alt:"image"})}function oa({image:o,state:t}){let[n]=ld(()=>new re),[r,i]=ld([]),{cacheManager:s}=Jo(),c=cd([]),u=cd(null),{transformRef:p,transitionRefs:f,isTransforming:a,initDisplayable:l,applyTransition:m,applyTransform:d,deps:h}=er({element:o,state:o.transformState,skipTransform:t.game.config.allowSkipImageTransform,skipTransition:t.game.config.allowSkipImageTransition,transitionsProps:T=>{let v=T?T.transition._getCurrentSrc():o.state.currentSrc;return[{style:{position:"absolute",transformOrigin:"center",backgroundColor:k.isColor(v)?k.colorToString(v):void 0,transform:"none",top:"auto",left:"auto",right:"auto",bottom:"auto"},src:k.isImageSrc(v)?k.srcToURL(v):B.DefaultImagePlaceholder},{style:{position:"absolute",transformOrigin:"center",transform:"translate(-50%, -50%)",top:"50%",left:"50%",right:"auto",bottom:"auto",maxWidth:"none",maxHeight:"none"}}]},propOverwrite:T=>T.src?(!k.isDataURI(T.src)&&!s.has(T.src)&&!s.isPreloading(T.src)&&!c.current.includes(T.src)&&(t.game.getLiveGame().getGameState()?.logger.warn("Image",`Image not preloaded: "${T.src}".
|
|
58
|
+
NarraLeaf cannot find the action with the id from the saved game`);this.currentAction=l}r.deserializeServices(a),n.stage.forceUpdate(),n.events.once(ie.EventTypes["event:state.onRender"],()=>{n.schedule(()=>{n.stage.next()},0)})}getHistory(){return this.assertGameState(),this.gameState.gameHistory.getHistory()}undo(t){this.assertGameState(),this.lockedAwaiting&&(this.lockedAwaiting.abort(),this.lockedAwaiting=null);let n=this.currentAction;t?n=this.gameState.actionHistory.undoUntil(t):n=this.gameState.actionHistory.undo(),n?this.currentAction=n:this.gameState.logger.warn("LiveGame.undo","No action found"),this.gameState.logger.info("LiveGame.undo","Undo until",t,"currentAction",this.currentAction,"action",n),this.gameState.stage.forceUpdate(),this.gameState.stage.next(),this.gameState.schedule(()=>{this.gameState&&this.gameState.forceAnimation()},0)}dispose(){this.events.clear(),this.gameState?.dispose()}notify(t,n=3e3){this.assertGameState();let r=this.gameState.idManager.generateId();this.gameState.notificationMgr.consume({id:r,message:t,duration:n})}assertScreenshot(){this.assertGameState(),this.assertPlayerElement()}capturePng(){return this.assertScreenshot(),this.gameState.htmlToImage.toPng(this.gameState.mainContentNode,this.getScreenshotOptions())}captureJpeg(){return this.assertScreenshot(),this.gameState.htmlToImage.toJpeg(this.gameState.mainContentNode,this.getScreenshotOptions())}captureSvg(){return this.assertScreenshot(),this.gameState.htmlToImage.toSvg(this.gameState.mainContentNode,this.getScreenshotOptions())}capturePngBlob(){return this.assertScreenshot(),this.assertGameState(),this.assertPlayerElement(),this.gameState.htmlToImage.toBlob(this.gameState.mainContentNode,this.getScreenshotOptions())}onCharacterPrompt(t){return this.events.on(Xt.EventTypes["event:character.prompt"],t)}onMenuChoose(t){return this.events.on(Xt.EventTypes["event:menu.choose"],t)}newGame(){this.assertGameState();let t=this.gameState,n=t.logger.group("LiveGame (newGame)",!0);this.reset({gameState:t}),this.initNamespaces();let r=this.getNewSavedGame();r.name="NewGame-"+Date.now(),this.currentSavedGame=r,this.currentAction=this.story?.entryScene?.getSceneRoot()||null;let i=this.story?.getAllElementMap(this.story,this.story?.entryScene?.getSceneRoot()||[]);return i?i.forEach(s=>{t.logger.debug("reset element",s),s.reset()}):t.logger.warn("No elements found"),t.stage.forceUpdate(),t.stage.next(),n.end(),this}requestFullScreen(t){this.assertGameState();let n="LiveGame.requestFullScreen";try{let r=this.gameState.playerCurrent;if(!r){this.gameState.logger.warn(n,"No player element found");return}if(r.requestFullscreen)return r.requestFullscreen(t);this.gameState.logger.warn(n,"Fullscreen is not supported")}catch(r){this.gameState.logger.error(n,r)}}exitFullScreen(){this.assertGameState();let t="LiveGame.exitFullScreen";try{if(document.exitFullscreen)return document.exitFullscreen();this.gameState.logger.warn(t,"Fullscreen is not supported")}catch(n){this.gameState.logger.error(t,n)}}getScreenshotOptions(){return{quality:this.game.config.screenshotQuality}}onPlayerEvent(t,n,r){this.assertPlayerElement();let i=this.gameState.playerCurrent;return i?(i.addEventListener(t,n,r),{cancel:()=>i.removeEventListener(t,n,r)}):(this.gameState.logger.warn("LiveGame.onEvent","No player element found"),{cancel:()=>{}})}reset({gameState:t}){this.lockedAwaiting&&this.lockedAwaiting.abort(),this.currentAction=null,this.lockedAwaiting=null,this.currentSavedGame=null,t.forceReset()}getCurrentAction(){return this.currentAction}setCurrentAction(t){return this.currentAction=t,this}next(t){if(this.gameLock.isLocked())return this.gameLock;if(!this.story)throw new Error("No story loaded");if(this.lockedAwaiting){if(!this.lockedAwaiting.isSettled()){if(this._lockedCount++,this._lockedCount>1e3)throw new Error(`LiveGame locked: dead cycle detected
|
|
59
|
+
Please refresh the page`);return this.lockedAwaiting}let r=this.lockedAwaiting.result;return this.currentAction=r?.node?.action||null,this.lockedAwaiting=null,this.currentAction||t.events.emit(ie.EventTypes["event:state.end"]),this._lockedCount=0,t.logger.debug("next action (lockedAwaiting)",r),r||null}if(!this.currentAction)return t.logger.weakWarn("LiveGame","No current action"),null;let n=this.currentAction.executeAction(t);return b.isAwaitable(n)?(this.lockedAwaiting=n,this._lockedCount=0,n):(t.logger.debug("next action",n),this._lockedCount=0,this.currentAction=n.node?.action||null,n)}isPlaying(){return!!this.currentAction}abortAwaiting(){if(this.lockedAwaiting){let t=this.lockedAwaiting.abort();this.currentAction=t?.node?.action||null,this.lockedAwaiting=null}}executeAction(t,n){let r=n.executeAction(t);return b.isAwaitable(r)?r:r?.node?.action||null}executeActionRaw(t,n){return n.executeAction(t)}setGameState(t){return this.gameState=t,this}getGameState(){return this.gameState}getAllPredictableActions(t,n,r){let i=n?.contentNode||null,s=[],c=[],u=new Set;for(;(i||c.length)&&!(r&&s.length>=r);){if(i||(i=c.pop().contentNode),[bn].some(p=>i?.action&&i.action instanceof p)){i=null;continue}if(i.action&&i.action.is(xe,ge.jumpTo)){let[p]=i.action.contentNode.getContent(),f=t.getScene(p);if(!f)throw i.action._sceneNotFoundError(i.action.getSceneName(p));if(u.has(f)){i=null;continue}u.add(f),i=f.getSceneRoot()?.contentNode||null;continue}else if(i.action&&i.action.is(he,ft.do)){let[p]=i.action.contentNode.getContent();i.getChild()?.action&&c.push(i.getChild().action),i=p[0]?.contentNode||null}i.action&&s.push(i.action),i=i.getChild()}return s}getNewSavedGame(){return{name:"",meta:{created:Date.now(),updated:Date.now(),id:Gl()},game:{store:{},stage:{scenes:[],audio:{sounds:[]},videos:[]},elementStates:[],currentAction:this.story?.entryScene?.getSceneRoot().getId()||null,services:{}}}}assertGameState(){if(!this.gameState)throw new M("No game state found, make sure you call this method in effect hooks or event handlers")}assertPlayerElement(){if(this.assertGameState(),!this.gameState.playerCurrent)throw new M("Player Element Not Mounted")}};Xt.DefaultNamespaces={game:{}},Xt.GameSpacesKey={game:"game"},Xt.EventTypes={"event:character.prompt":"event:character.prompt","event:menu.choose":"event:menu.choose"};var Cn=Xt;var Hr=class Hr{constructor(t){this.settings=t;this.events=new re;this.events.setMaxListeners(64)}setPreference(t,n){this.settings[t]=n,this.events.emit(Hr.EventTypes["event:game.preference.change"],t,n)}getPreference(t){return this.settings[t]}getPreferences(){return this.settings}onPreferenceChange(t,n){return this.events.on(Hr.EventTypes["event:game.preference.change"],(r,i)=>{typeof t=="string"?t===r&&n&&n(i):t(r,i)})}importPreferences(t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.setPreference(n,t[n])}exportPreferences(){let t={};for(let n in this.settings)Object.prototype.hasOwnProperty.call(this.settings,n)&&(t[n]=this.settings[n]);return t}togglePreference(t){this.setPreference(t,!this.getPreference(t))}};Hr.EventTypes={"event:game.preference.change":"event:game.preference.change"};var Ys=Hr;function Hf(o){var t,n,r="";if(typeof o=="string"||typeof o=="number")r+=o;else if(typeof o=="object")if(Array.isArray(o)){var i=o.length;for(t=0;t<i;t++)o[t]&&(n=Hf(o[t]))&&(r&&(r+=" "),r+=n)}else for(n in o)o[n]&&(r&&(r+=" "),r+=n);return r}function BT(){for(var o,t,n=0,r="",i=arguments.length;n<i;n++)(o=arguments[n])&&(t=Hf(o))&&(r&&(r+=" "),r+=t);return r}var q=BT;import{flushSync as Ad}from"react-dom";import Bf,{useEffect as YT,useRef as ZT,useState as Wf}from"react";import Kf from"react";import WT,{createContext as jT,useContext as $T,useEffect as zT,useReducer as qT,useState as XT}from"react";var Yt=class Yt{constructor(){this.state={width:0,height:0,minWidth:800,minHeight:450,paused:!1,scale:0};this.events=new re().setMaxListeners(1/0);this.lockers=[];this.updater=null}update(t,n,r){this.state.width=t,this.state.height=n,this.state.scale=r,this.events.emit(Yt.EventTypes["event:aspectRatio.update"],t,n)}updateMin(t,n){this.state.minWidth=t,this.state.minHeight=n}lock(){let t=Symbol();return this.lockers.push(t),t}unlock(t){if(t&&!this.lockers.includes(t))throw new Error("Locker not found");return this.lockers=this.lockers.filter(n=>n!==t),this.triggerUpdate(),null}isLocked(){return!!this.lockers.length}getStyle(){return{width:`${this.state.width}px`,height:`${this.state.height}px`}}setUpdate(t){this.updater=t}pause(){this.state.paused=!0,this.events.emit(Yt.EventTypes["event:aspectRatio.pause"])}resume(){this.state.paused=!1,this.events.emit(Yt.EventTypes["event:aspectRatio.resume"])}onUpdate(t){return this.events.on(Yt.EventTypes["event:aspectRatio.update"],t).cancel}requestUpdate(){this.events.emit(Yt.EventTypes["event:aspectRatio.requestUpdate"])}onRequestedUpdate(t){return this.events.on(Yt.EventTypes["event:aspectRatio.requestUpdate"],t).cancel}triggerUpdate(){this.updater&&this.updater()}};Yt.EventTypes={"event:aspectRatio.update":"event:aspectRatio.update","event:aspectRatio.pause":"event:aspectRatio.pause","event:aspectRatio.resume":"event:aspectRatio.resume","event:aspectRatio.requestUpdate":"event:aspectRatio.requestUpdate"};var Uc=Yt,Kc=jT(null);function Uf({children:o}){"use client";let[t]=XT(()=>new Uc);return WT.createElement(Kc,{value:{ratio:t}},o)}function be(){let o=$T(Kc),[,t]=qT(r=>r+1,0);if(!Kc||!o)throw new Error("useRatio must be used within a RatioProvider");let{ratio:n}=o;return zT(()=>n.onUpdate(()=>{t()}),[]),o}function Dt({children:o,className:t,style:n,ref:r,...i}){let{ratio:s}=be(),c=s.getStyle();return Kf.createElement("div",{className:q("inset-0",t),style:{width:"100%",height:"100%",minWidth:`${s.state.minWidth}px`,minHeight:`${s.state.minHeight}px`},...i},Kf.createElement("div",{style:{...c,position:"relative",...n||{}},...i||{},ref:r},o))}function Bc({src:o,width:t,height:n}){let[r,i]=Wf({x:0,y:0}),[s,c]=Wf(!1),u=ZT(null),{ratio:p}=be();return YT(()=>{let f=a=>{if(u.current){let l=u.current.getBoundingClientRect(),m=a.clientX-l.left,d=a.clientY-l.top;i({x:m,y:d}),s||c(!0)}};return window.addEventListener("mousemove",f),()=>{window.removeEventListener("mousemove",f)}},[s]),Bf.createElement(Dt,{ref:u,className:"overflow-hidden absolute"},Bf.createElement("img",{src:o,style:{position:"absolute",left:r.x,top:r.y,width:t,height:n,pointerEvents:"none",zIndex:1001,display:s?"block":"none",cursor:"none",transform:`scale(${p.state.scale})`},alt:""}))}var Kn=class Kn{constructor(){this.preloaded=[];this.events=new re}add(t){let n=this.getSrc(t);return n&&this.has(n)?this:(this.preloaded.push(t),this.events.emit(Kn.EventTypes["event:preloaded.add"],t),this.events.emit(Kn.EventTypes["event:preloaded.change"]),this)}get(t){return this.preloaded.find(n=>this.getSrc(n)===t)}has(t){return Array.isArray(t)?t.every(n=>this.has(n)):this.preloaded.some(n=>this.getSrc(n)===t)}remove(t){if(Array.isArray(t)){let r=t.map(i=>this.getSrc(i));return this.preloaded=this.preloaded.filter(i=>!r.includes(this.getSrc(i))),this}let n=this.getSrc(t);return this.preloaded=this.preloaded.filter(r=>this.getSrc(r)!==n),this.events.emit(Kn.EventTypes["event:preloaded.remove"],t),this.events.emit(Kn.EventTypes["event:preloaded.change"]),this}clear(){return this.preloaded=[],this}getSrc(t){return Ne.getSrc(t)}};Kn.EventTypes={"event:preloaded.add":"event:preloaded.add","event:preloaded.remove":"event:preloaded.remove","event:preloaded.change":"event:preloaded.change","event:preloaded.mount":"event:preloaded.mount","event:preloaded.ready":"event:preloaded.ready","event:preloaded.unmount":"event:preloaded.unmount"};var ot=Kn;import qf,{useEffect as Xf,useState as nv}from"react";import jf,{useContext as JT,useState as QT}from"react";var $f=jf.createContext(null);function zf({children:o,game:t}){"use client";let n=new de({}),[r]=QT(t||n);return jf.createElement($f,{value:r},o)}function N(){let o=JT($f);if(!o)throw new Error("useGame must be used within a GameProvider");return o}import{useEffect as ev,useState as tv}from"react";function Ye(o){let[t,n]=tv(0);ev(()=>{r()},o??[]);function r(){n(i=>i+1)}return[r,t]}function Wc({children:o,className:t,gameState:n}){let[r,i]=nv({}),{ratio:s}=be(),c=N(),[u]=Ye(),p=c.config.minWidth,f=c.config.minHeight;return Xf(()=>{n.logger.debug("AspectRatio","mount, using interval",c.config.ratioUpdateInterval);let a=()=>{if(s.isLocked()){n.logger.weakWarn("Ratio is locked, skipping update");return}let h=document.getElementById(c.config.contentContainerId);if(h){let g=h.clientWidth,y=h.clientHeight,T=c.config.aspectRatio,v,S;g/y>T?(v=y*T,S=y):(v=g,S=g/T),v<p&&(v=p),S<f&&(S=f),i({width:`${v}px`,height:`${S}px`,margin:"auto",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",display:"flex",alignItems:"center",justifyContent:"center"});let C=v/c.config.width;s.update(v,S,C),s.updateMin(p,f),u()}};s.setUpdate(a);let m=Rl(()=>{a()},c.config.ratioUpdateInterval);m(),window.addEventListener("resize",m);let d=s.onRequestedUpdate(m);return()=>{window.removeEventListener("resize",m),d()}},[s,c.config.ratioUpdateInterval]),Xf(()=>n.events.on(ie.EventTypes["event:state.player.requestFlush"],u).cancel,[n]),qf.createElement("div",{id:c.config.contentContainerId,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},qf.createElement("div",{className:q(t),style:r},o))}import Yf from"react";import Zt from"react";function jc({error:o,errorInfo:t}){let n=N();return n.config.onError&&n.config.onError(o),n.config.app.debug?Zt.createElement("div",{className:"text-left"},Zt.createElement("h1",null,"NarraLeaf-React cannot initialize the player correctly. (development mode)"),Zt.createElement("p",{className:"text-red-700"},"Message: ",o.message),Zt.createElement("pre",null,"Error Stack: ",o?.stack),Zt.createElement("pre",null,"Component Stack: ",t?.componentStack),Zt.createElement("pre",null,"Digest: ",t?.digest)):Zt.createElement("div",{className:"bg-white w-full h-full"},Zt.createElement("h1",null,"NarraLeaf-React crashed due to an unknown error."),Zt.createElement("p",null,"Please contact the game developer for further assistance."))}var Zs=class extends Yf.Component{constructor(){super(...arguments);this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n,errorInfo:null}}componentDidCatch(n,r){this.setState({error:n,errorInfo:r}),console.error(n,r)}render(){return this.state.hasError?Yf.createElement(jc,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}};import $c,{createContext as ov,useContext as rv,useState as Zf}from"react";var Js=class o{constructor(t){this.game=t;this.src=new Map;this.preloadTasks=new Map;this.game.addSideEffect(()=>{this.abortAll(),this.src.clear()})}static getImage(t,n,r){return Ll(t,{...r,signal:n})}has(t){return this.src.has(t)}add(t,n){return this.src.set(t,n),this}remove(t){return this.src.delete(t),this}get(t){return this.src.get(t)}clear(){return this.src.clear(),this}size(){return this.src.size}isPreloading(t){return this.preloadTasks.has(t)}preload(t,n){if(this.src.has(n)||this.preloadTasks.has(n)){let l={abort:()=>{},onFinished:()=>l,onErrored:()=>l};return l}let r=n,i={};this.game.hooks.rawTrigger("preloadImage",()=>[r,(l,m)=>{r=l,i={...i,...m}}]);let s=new AbortController,c=s.signal,u=[],f={promise:o.getImage(r,c,i).then(l=>{this.preloadTasks.delete(n),l&&this.add(n,l)}).catch(l=>{t.logger.error("ImageCacheManager",`Failed to preload image: ${n}`,`Reason: ${l}`),u.forEach(m=>m(l))}),controller:s};this.preloadTasks.set(n,f);let a={abort:()=>{s.abort(),this.preloadTasks.delete(n)},onFinished:l=>(f.promise.then(l),a),onErrored:l=>(u.push(l),a)};return a}abortAll(){this.preloadTasks.forEach(t=>{t.controller.abort()}),this.preloadTasks.clear()}abort(t){let n=this.preloadTasks.get(t);n&&(n.controller.abort(),this.preloadTasks.delete(t))}preloadedSrc(){return Array.from(this.src.values())}filter(t){for(let n of this.src.keys())t.includes(n)||this.src.delete(n);return this}};var zc=ov(null);function Jf({children:o}){let t=N(),[n]=Zf(()=>new ot),[r]=Zf(()=>new Js(t));return $c.createElement($c.Fragment,null,$c.createElement(zc,{value:{preloaded:n,cacheManager:r}},o))}function Jo(){if(!zc)throw new Error("usePreloaded must be used within a PreloadedProvider");return rv(zc)}import{useEffect as qc,useRef as iv}from"react";function Qf({state:o}){let{preloaded:t,cacheManager:n}=Jo(),r=N(),i=iv(new Set),s="Preload",c=o.getLastScene()||o.getPreloadingScene(),u=r.getLiveGame().getCurrentAction(),p=r.getLiveGame().story;function f(){o.logger.debug(s,"Preload unmounted"),t.events.emit(ot.EventTypes["event:preloaded.unmount"])}return qc(()=>{if(typeof fetch>"u")return t.events.emit(ot.EventTypes["event:preloaded.ready"]),o.logger.warn(s,"Fetch is not supported in this environment, skipping preload"),f;if(!r.config.preloadAllImages)return t.events.emit(ot.EventTypes["event:preloaded.ready"]),o.logger.debug(s,"Preload all images is disabled, skipping preload"),f;if(r.config.forceClearCache&&(n.clear(),o.logger.weakWarn(s,"Cache cleared")),!p||!c)return o.logger.weakWarn(s,"Story/Scene not found, skipping preload"),f;let a=performance.now(),l=Ne.catSrc([...c.srcManager?.src||[],...c.srcManager?.getFutureSrc()||[]]),m=new ir(r.config.preloadConcurrency,r.config.preloadDelay),d=[],h=o.logger.group(s,!0),g=[];o.logger.debug(s,"preloading:",l,c);for(let y of l.image){let T=Ne.getSrc(y);if(T){if(d.push(T),n.has(T)||n.isPreloading(T)||g.includes(T)){o.logger.debug(s,`Image already loaded (${l.image.indexOf(y)+1}/${l.image.length})`,T),g.push(T);continue}g.push(T),m.addTask(()=>new Promise(v=>{n.preload(o,T).onFinished(()=>{o.logger.debug(s,`Image loaded (${l.image.indexOf(y)+1}/${l.image.length})`,T),v()}).onErrored(()=>{o.logger.weakError(s,`Failed to preload image (${l.image.indexOf(y)+1}/${l.image.length})`,T),v()})}))}}return h.end(),m.start().then(()=>{o.logger.info(s,"Image preload",`loaded ${n.size()} images in ${performance.now()-a}ms`),r.config.waitForPreload&&t.events.emit(ot.EventTypes["event:preloaded.ready"]),n.filter(d)}),r.config.waitForPreload||t.events.emit(ot.EventTypes["event:preloaded.ready"]),t.events.emit(ot.EventTypes["event:preloaded.mount"]),f},[c,p]),qc(()=>{i.current.clear()},[c]),qc(()=>{if(typeof fetch>"u"||r.config.preloadAllImages)return;if(!p){o.logger.weakWarn(s,"Story not found, skipping preload");return}let a=performance.now(),l=r.getLiveGame().getAllPredictableActions(p,u,r.config.maxPreloadActions).map(T=>Ne.getPreloadableSrc(p,T)).filter(function(T){return T!==null});l.filter(function(T){return T?.activeType==="scene"}).forEach(T=>{i.current.has(T)||i.current.add(T)});let d=Ne.catSrc([...i.current,...l]),h=new ir(r.config.preloadConcurrency,r.config.preloadDelay),g=[],y=o.logger.group(s);o.logger.debug(s,"preloading:",d);for(let T of d.image){let v=Ne.getSrc(T);if(v){if(g.push(v),n.has(v)||n.isPreloading(v)){o.logger.debug(s,`Image already loaded (${d.image.indexOf(T)+1}/${d.image.length})`,v);continue}h.addTask(()=>new Promise(S=>{n.preload(o,v).onFinished(()=>{o.logger.debug(s,`Image loaded (${d.image.indexOf(T)+1}/${d.image.length})`,v),S()}).onErrored(()=>{o.logger.weakError(s,`Failed to preload image (${d.image.indexOf(T)+1}/${d.image.length})`,v),S()})}))}}y.end(),h.start().then(()=>{o.logger.info(s,"Image preload (quick reload)",`loaded ${n.size()} images in ${performance.now()-a}ms`),n.filter(g)})},[u,p]),null}import Ae,{useEffect as fa,useReducer as Cd,useState as Sl}from"react";import Qo,{useEffect as cv}from"react";import ed from"react";import Qs from"react";function ea({children:o,className:t,style:n,...r}){let{ratio:i}=be(),s=N();return Qs.createElement(Dt,{className:q("absolute pointer-events-none w-full h-full"),style:{transform:`scale(${i.state.scale})`,transformOrigin:"left top",width:s.config.width,height:s.config.height,pointerEvents:"none"},"data-element-type":"full",...r},Qs.createElement("div",{className:"absolute inset-0 w-full h-full"},Qs.createElement("div",{className:"inset-0 w-full h-full"},Qs.createElement("div",{className:q("pointer-events-auto-rest",t),style:n},o))))}function Xc({id:o,children:t,className:n,style:r,...i}){return ed.createElement(Kt.div,{className:q("w-full h-full"),key:o,...i},ed.createElement(ea,{className:n,style:r},t))}import Yc,{createContext as sv,useContext as td,useState as av}from"react";var Zc=class{constructor(t,n){this.events=new re;this.current=null;this.history=[];this.historyIndex=-1;this.game=t,n&&(this.current=n,this.history.push(n),this.historyIndex=0)}getCurrentId(){return this.current}push(t){return this.historyIndex<this.history.length-1&&(this.history=this.history.slice(0,this.historyIndex+1)),this.history.push(t),this.history.length>this.game.config.maxRouterHistory&&(this.history.shift(),this.historyIndex--),this.historyIndex++,this.current=t,this.emitOnChange(),this}back(){return this.historyIndex>0?(this.historyIndex--,this.current=this.history[this.historyIndex],this.emitOnChange()):(this.current=null,this.emitOnChange()),this}forward(){return this.historyIndex<this.history.length-1&&(this.historyIndex++,this.current=this.history[this.historyIndex],this.emitOnChange()),this}clear(){return this.current=null,this.history=[],this.historyIndex=-1,this.emitOnChange(),this}cleanHistory(){return this.history=this.current?[this.current]:[],this.historyIndex=this.current?0:-1,this}isActive(){return this.current!==null}emitOnChange(){this.events.emit("event:router.onChange")}},Jc=sv(null);function nd({children:o}){"use client";let t=N(),[n]=av(()=>new Zc(t));return Yc.createElement(Yc.Fragment,null,Yc.createElement(Jc,{value:{router:n}},o))}function Ur(){if(!td(Jc))throw new Error("usePreloaded must be used within a PreloadedProvider");return td(Jc).router}import Qc from"react";function el({children:o,className:t,style:n}){return Qc.createElement(Qc.Fragment,null,Qc.createElement(ea,{style:n,className:t,"data-element-type":"stage","data-code-source":"Stage.tsx"},o))}function od({children:o}){let[t]=Ye(),n=Ur(),r=N();if(cv(()=>{if(n)return n.events.on("event:router.onChange",t).cancel},[]),!n)return null;let i=Qo.Children.toArray([...r.config.stage?[r.config.stage]:[],...o?[o]:[]]),s=Xc,u=i.filter(function(l){return Qo.isValidElement(l)&&l.type===s}).find(l=>l.props.id===n.getCurrentId()),p=el,f=i.find(function(l){return Qo.isValidElement(l)&&l.type===p});return Qo.createElement(Qo.Fragment,null,f,Qo.createElement(cr,{mode:"wait"},u))}import jn,{useEffect as hl,useRef as _v}from"react";import ta,{useEffect as uv}from"react";import tl,{useEffect as Kr,useRef as rd,useState as nl}from"react";function er({element:o,state:t,skipTransform:n,skipTransition:r,overwriteDefinition:i,onTransform:s,transitionsProps:c=[],propOverwrite:u}){let[p,f]=nl(null),[a,l]=nl(null),m=tl.useRef(null),[d]=nl(()=>new qr("displayable.refGroup")),h=rd(d.next()),g=rd(V()),T=N().getLiveGame().getGameState(),v=typeof c=="function"?c(p):c,[S]=Ye([a,p,g]);Kr(()=>T.events.depends([T.events.on(ie.EventTypes["event:state.player.skip"],P)]).cancel,[a,p,g]),Kr(()=>{if(!p)return;if(g.current.some(([oe])=>!oe.current))throw new M("Displayable: Trying to access transition groups before they are mounted");let{controller:I,task:W}=p;return I.onUpdate(oe=>{g.current.forEach(([Fe],O)=>{let F=W.resolve[O],ae=typeof F=="function"?F:F.resolver;if(!ae)throw new M(`Displayable: Trying to resolve element props but found no resolver. (reading: transitionTask.task.resolve[${O}])`);let H=ae(...oe),j=U(v[O]||v[v.length-1]||{},H);x(Fe,u?u(j):j)})}).cancel},[p]),Kr(()=>{if(!g.current||!g.current.length)throw new M("Displayable: Transition group refs are not initialized correctly");if(g.current.some(([I])=>!I.current))throw new M("Displayable: Trying to access transition groups before they are mounted");g.current.forEach(([I],W)=>{if(!I.current)throw new M("Displayable: Trying to assign properties to unmounted element");x(I,v[W]||v[v.length-1]||{})})},[p]),Kr(()=>{if(!m.current)throw new Error(`Scope not ready. Using element: ${o.constructor.name}`)},[]),Kr(()=>{let I=t.toStyle(T,i);Object.assign(m.current.style,I),T.logger.debug("Displayable","Initial style applied",m.current,I)},[]);function C(I){T.logger.debug("Displayable","Transform applied",t.toStyle(T,i),m.current),S(),s?.(I)}function x(I,W){if(!I.current)throw new M("Displayable: Trying to assign properties to unmounted element");let se=I.current,oe={},Fe={};Object.keys(W).forEach(F=>{let ae=F;ae==="style"&&W.style?Object.assign(oe,W.style):W[ae]!==void 0&&ae!=="key"&&(Fe[ae]=W[ae])}),Object.keys(oe).length>0&&Object.assign(se.style,oe);let O=u?u(Fe):Fe;for(let[F,ae]of Object.entries(O))se.getAttribute(F)!==ae&&se.setAttribute(F,ae)}function w(I,W){a&&(a.abort(),l(null));let se=I.animate(t,{gameState:T,ref:m,overwrites:i}),oe=new ne(se);return T.timelines.attachTimeline(oe),se.onSkipControllerRegister(Fe=>{Fe.onAbort(()=>{oe.abort()})}),l(se),se.then(()=>{l(null),C(I),W()}),oe}function _(I,W){p&&p.controller.complete();let se=I.createTask(T),oe=I.requestAnimations(se.animations),Fe=new b().registerSkipController(new K(oe.cancel)),O=new ne(Fe);Fe.skipController.onAbort(()=>{oe.cancel()}),oe.onCanceled(()=>{O.abort()}),T.timelines.attachTimeline(O),f({task:se,controller:oe,transition:I,resolve:W});let F;if(g.current=se.resolve.map(ae=>{let H=tl.createRef(),j=typeof ae=="function"?void 0:ae.key;if(!j)return[H,d.next()];if(j==="target")return F=d.next(),[H,F];if(j==="current")return[H,h.current];throw new M("Displayable: Invalid key type")}),!F)throw new M("Displayable: No target key found");return h.current=F,oe.start(),oe.onComplete(()=>{J(),f(null),W(),Fe.resolve()}),O}function A(I){return T.logger.debug("initDisplayable",o),w(ce.immediate(t.get()),I)}function P(){n&&a&&(a.abort(),l(null),T.logger.debug("transform skipped")),r&&p&&(p.controller.complete(),T.logger.debug("transition skipped"))}function V(){return[[tl.createRef(),h.current]]}function J(){g.current.forEach(([I])=>{I.current=null}),g.current=V()}return{transformRef:m,transitionRefs:g.current,isTransforming:!!a,transitionTask:p,initDisplayable:A,applyTransform:w,applyTransition:_,deps:[a,p,g]}}import{useEffect as lv}from"react";function wn(o,t,n=[]){let i=N().getLiveGame().getGameState();return lv(()=>{let s=typeof t=="function"?t():t;return i.mountState(o,s).unMount},[...n]),[]}function id({state:o,layer:t,children:n}){let{transformRef:r,transitionRefs:i,initDisplayable:s,applyTransition:c,applyTransform:u,deps:p}=er({element:t,state:t.transformState,skipTransform:o.game.config.allowSkipLayersTransform,skipTransition:!1,transitionsProps:[{style:{width:"100%",height:"100%",transformOrigin:"center"}}]});return wn(t,{initDisplayable:s,applyTransition:c,applyTransform:u},[...p]),uv(()=>(o.logger.debug("Layer","Layer mounted",t.getId()),()=>{o.logger.debug("Layer","Layer unmounted",t.getId())}),[]),ta.createElement(ta.Fragment,null,ta.createElement(Kt.div,{layout:!0,className:"absolute w-full h-full",ref:r,"data-element-type":"layer","data-layer-id":t.getId(),key:`layer-${t.getId()}`},i.map(([f,a])=>ta.createElement("div",{className:"relative w-full h-full",ref:f,key:a},n))))}import ia from"react";import oa from"react";import pt,{useState as sd}from"react";function na({children:o,border:t="solid",color:n="red",tag:r,borderWidth:i=1,as:s="div",ref:c,...u}){let p=N(),[f,a]=sd(!1);if(!p.config.app.inspector)return pt.createElement(s,{...u,ref:c},o);let l={...u,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{...u.style||{},outline:`${i}px ${t} ${n}`,zIndex:f?1e3:"auto"}};return pt.createElement(s,{...l,ref:c},r&&f&&pt.createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black text-sm"},r),o)}function pv({border:o="solid",color:t="red",tag:n,borderWidth:r=1,as:i="img",...s}){let c=N(),[u,p]=sd(!1);if(!c.config.app.inspector)return pt.createElement(i,{...s});let f={...s,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{...s.style||{},outline:`${o} ${r}px ${t}`,zIndex:u?1e3:"auto"}};return pt.createElement("div",null,pt.createElement(i,{...f}),n&&u&&pt.createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black"},n))}function mv(o){return pt.createElement(na,{...o,as:"div"})}function fv(o){return pt.createElement(na,{...o,as:"span"})}function dv(o){return pt.createElement(pv,{...o,as:"img"})}function hv(o){return pt.createElement(na,{...o,as:"button"})}function gv(o){return pt.createElement(na,{...o,as:Kt.div,ref:o.ref,layout:o.layout})}var yv={Div:mv,Span:fv,Button:hv,Img:dv,mDiv:gv},Bn=yv;function ol({state:o,text:t}){let{ratio:n}=be(),[r]=Ye(),{transformRef:i,transitionRefs:s,initDisplayable:c,applyTransform:u,applyTransition:p,deps:f,isTransforming:a}=er({element:t,state:t.transformState,skipTransform:o.game.config.allowSkipTextTransform,skipTransition:o.game.config.allowSkipTextTransition,overwriteDefinition:{overwrite:l=>({width:"fit-content",transform:ce.propToCSSTransform(o,l,{translate:[t.config.alignX==="left"?"0%":t.config.alignX==="right"?"-100%":void 0,t.config.alignY==="top"?"100%":t.config.alignY==="bottom"?"0%":void 0]})})},transitionsProps:[{style:{width:"fit-content",whiteSpace:"nowrap",transform:`scale(${n.state.scale})`,transformOrigin:`${t.config.alignX} ${t.config.alignY}`,fontSize:`${t.state.fontSize}px`}}]});return wn(t,{initDisplayable:c,applyTransform:u,applyTransition:p,flush:r},[...f]),oa.createElement(Bn.Div,{"data-element-type":"text"},oa.createElement(Bn.mDiv,{tag:"text.container",color:"green",border:"dashed",layout:a,ref:i,className:"absolute"},s.map(([l,m])=>oa.createElement("span",{key:m,ref:l,className:t.config.className},oa.createElement("span",null,t.state.text)))))}import tr,{useRef as cd,useState as ld}from"react";import rl,{useEffect as ad,useRef as Tv}from"react";function il({ref:o,onSizeChanged:t,onLoad:n,autoFit:r=!1}){let i=Tv(null),{ratio:s}=be(),[c,u]=rl.useState(()=>s.state.width),[p,f]=rl.useState(()=>s.state.height),a=N();ad(()=>(l(),s.onUpdate(l)),[o]),ad(()=>{let d=new MutationObserver(h=>{h.forEach(g=>{g.type==="attributes"&&g.attributeName==="src"&&i.current&&l()})});return i.current&&d.observe(i.current,{attributes:!0}),()=>{d.disconnect()}},[]);function l(){let d=o||i;if(d.current&&d.current.naturalWidth)if(d.current.naturalWidth*d.current.naturalHeight===1){let h=s.state.width,g=s.state.height,y=`${h} / ${g}`;u(h),f(g),d.current.style.aspectRatio=y,t&&t(h,g)}else{let h=r?a.config.width/d.current.naturalWidth:1,g=d.current.naturalWidth*s.state.scale*h,y=d.current.naturalHeight*s.state.scale*h;u(g),f(y),t&&t(g,y)}}function m(){l(),n&&n()}return rl.createElement("img",{ref:o||i,onLoad:m,width:c,height:p,alt:""})}function ra({image:o,state:t}){let[n]=ld(()=>new re),[r,i]=ld([]),{cacheManager:s}=Jo(),c=cd([]),u=cd(null),{transformRef:p,transitionRefs:f,isTransforming:a,initDisplayable:l,applyTransition:m,applyTransform:d,deps:h}=er({element:o,state:o.transformState,skipTransform:t.game.config.allowSkipImageTransform,skipTransition:t.game.config.allowSkipImageTransition,transitionsProps:T=>{let v=T?T.transition._getCurrentSrc():o.state.currentSrc;return[{style:{position:"absolute",transformOrigin:"center",backgroundColor:k.isColor(v)?k.colorToString(v):void 0,transform:"none",top:"auto",left:"auto",right:"auto",bottom:"auto"},src:k.isImageSrc(v)?k.srcToURL(v):B.DefaultImagePlaceholder},{style:{position:"absolute",transformOrigin:"center",transform:"translate(-50%, -50%)",top:"50%",left:"50%",right:"auto",bottom:"auto",maxWidth:"none",maxHeight:"none"}}]},propOverwrite:T=>T.src?(!k.isDataURI(T.src)&&!s.has(T.src)&&!s.isPreloading(T.src)&&!c.current.includes(T.src)&&(t.game.getLiveGame().getGameState()?.logger.warn("Image",`Image not preloaded: "${T.src}".
|
|
60
60
|
This may be caused by complicated image action behavior that cannot be predicted.
|
|
61
|
-
To fix this issue, you can manually register the image using scene.preloadImage(YourImageSrc). `),c.current.push(T.src)),{...T,src:s.get(T.src)||T.src}):T});wn(o,{createWearable:T=>{i(v=>[...v,T])},disposeWearable:T=>{i(v=>v.filter(S=>S.getId()!==T.getId()))},initDisplayable:l,applyTransform:d,applyTransition:m,events:n},[...h]);function g(T,v){u.current&&(n.emit("event:image.onLoad"),Object.assign(u.current.style,{width:`${T}px`,height:`${v}px`}))}function y(){n.emit("event:image.onLoad")}return tr.createElement(
|
|
61
|
+
To fix this issue, you can manually register the image using scene.preloadImage(YourImageSrc). `),c.current.push(T.src)),{...T,src:s.get(T.src)||T.src}):T});wn(o,{createWearable:T=>{i(v=>[...v,T])},disposeWearable:T=>{i(v=>v.filter(S=>S.getId()!==T.getId()))},initDisplayable:l,applyTransform:d,applyTransition:m,events:n},[...h]);function g(T,v){u.current&&(n.emit("event:image.onLoad"),Object.assign(u.current.style,{width:`${T}px`,height:`${v}px`}))}function y(){n.emit("event:image.onLoad")}return tr.createElement(Kt.div,{layout:a,ref:p,className:"absolute w-max h-max","data-element-type":"image"},tr.createElement("div",{className:"relative h-full w-full",ref:u,"data-image-id":o.getId()},f.map(([T,v],S)=>tr.createElement(il,{key:v,ref:T,autoFit:o.config.autoFit,onSizeChanged:S===0?g:void 0,onLoad:S===0?y:void 0})),tr.createElement("div",{className:q("w-full h-full top-0 left-0 absolute")},r.map(T=>tr.createElement("div",{className:q("w-full h-full relative"),key:"wearable-"+T.getId()},tr.createElement(ra,{image:T,state:t}))))))}function sl({state:o,displayable:t}){return ia.createElement(ia.Fragment,null,t.map(n=>{if(n instanceof Un)return ia.createElement(ol,{state:o,text:n,key:"text-"+n.getId()});if(n instanceof B)return ia.createElement(ra,{state:o,image:n,key:"image-"+n.getId()});throw new Error("Unsupported displayable type: "+(n?.constructor?.name||n))}))}import It,{useMemo as Rv,useCallback as ml,useRef as Iv}from"react";import sa from"react";var al=sa.createContext(null);function ud(){let o=sa.useContext(al);if(!o)throw new Error("useUIMenuContext must be used within a UIMenuContext");return o}var cl=sa.createContext(null);function pd(){let o=sa.useContext(cl);if(!o)throw new Error("useUIListContext must be used within a UIListContext");return o}import md from"react";function aa({className:o,children:t,...n}){let{ratio:r}=be();return md.createElement("div",{style:{transform:`scale(${r.state.scale})`,transformOrigin:"left top"},className:q("w-full h-full")},md.createElement("div",{className:q("z-20",o),...n},t))}import la,{useEffect as Pv,useLayoutEffect as Ev,useRef as kv,useState as Dv}from"react";import Wn,{useEffect as ul,useRef as Av,useState as Cv}from"react";import fd from"react";var ll=fd.createContext(null);function Jt(){let o=fd.useContext(ll);if(!o)throw new Error("useDialogContext must be used within a DialogContext");return o}import ca,{useEffect as vv,useLayoutEffect as Sv,useMemo as xv,useState as bv}from"react";var Rt=class Rt{constructor(t){this.events=new re;this._forceSkipped=!1;this._idle=!1;this.config=t,this._state="pending",this.autoForwardScheduler=new zr,this._count=0}get state(){return this._state}get deps(){return[this._count]}isIdle(){return this._idle}setIdle(t){this._idle=t}requestComplete(){this.state==="ended"?this.events.emit(Rt.Events.complete):this.events.emit(Rt.Events.requestComplete)}forceSkip(){this.state==="ended"?this.emitComplete():(this._forceSkipped=!0,this.events.emit(Rt.Events.forceSkip))}dispatchComplete(){if(this.state==="ended")return;let t=this.config.gameState.game.preference;return this._state="ended",t.getPreference(de.Preferences.autoForward)&&this.scheduleAutoForward(),this.emitComplete(),this}emitComplete(){return this.events.emit(Rt.Events.complete),this.emitFlush(),this}isEnded(){return this.state==="ended"}setPause(t){this.isEnded()||(t?this._state="paused":this._state="pending")}isForceSkipped(){return this._forceSkipped}tryScheduleAutoForward(){this.isEnded()&&this.scheduleAutoForward()}cancelAutoForward(){this.autoForwardScheduler.cancelTask()}emitFlush(){return this._count++,this.events.emit(Rt.Events.onFlush),this}onFlush(t){return this.events.on(Rt.Events.onFlush,t)}scheduleAutoForward(){let t=this.config.gameState.game.preference;!t.getPreference(de.Preferences.autoForward)||this.state!=="ended"||this.autoForwardScheduler.cancelTask().scheduleTask(()=>{this.events.emit(Rt.Events.complete)},this.config.gameState.game.config.autoForwardDelay/t.getPreference(de.Preferences.gameSpeed))}};Rt.Events={requestComplete:"event:dialog.requestComplete",complete:"event:dialog.complete",forceSkip:"event:dialog.forceSkip",onFlush:"event:dialog.onFlush"};var vt=Rt;function Br({action:o,onFinished:t,useTypeEffect:n=!0,gameState:r}){let i=xv(()=>o.sentence?.evaluate(ut.getCtx({gameState:r})),[o.sentence,r]),[s]=bv(()=>new vt({useTypeEffect:n,action:o,evaluatedWords:i||[],gameState:r})),c=r.game.config.dialog;return Sv(()=>s.events.depends([s.events.on(vt.Events.complete,()=>{r.logger.log("NarraLeaf-React: Say","Complete",s.isIdle()),s.isIdle()?t?.(!1):s.setIdle(!0)})]).cancel,[]),vv(()=>r.events.on(ie.EventTypes["event:state.player.skip"],()=>{s.isIdle()?t?.(!0):s.forceSkip()}).cancel,[s]),ca.createElement(ca.Fragment,null,ca.createElement(ll,{value:s,key:o.id},ca.createElement(c,null)))}function*dd(o){let t=[...o];for(let n=0;n<t.length;n++){let r=t[n];if(Ke.isPause(r.text)){yield Ke.from(r.text);continue}for(let i=0;i<r.text.length;i++){let s=r.text[i];s===`
|
|
62
62
|
`?yield`
|
|
63
|
-
`:yield{text:s,config:r.config,tag:n,tag2:i,cps:r.config.cps}}}}function hd({defaultColor:o,className:t,style:n,dialog:r,...i}){let s=N(),c=s.getLiveGame().getGameState(),u=Av(null),[p,f]=Cv(()=>r&&!r.config.useTypeEffect?d(r.config.evaluatedWords):[]),[a,l]=
|
|
63
|
+
`:yield{text:s,config:r.config,tag:n,tag2:i,cps:r.config.cps}}}}function hd({defaultColor:o,className:t,style:n,dialog:r,...i}){let s=N(),c=s.getLiveGame().getGameState(),u=Av(null),[p,f]=Cv(()=>r&&!r.config.useTypeEffect?d(r.config.evaluatedWords):[]),[a,l]=Ye();if(!r)throw new Error("Dialog state is required");ul(()=>{if(!(!r.config.action.sentence||u.current)){if(c.logger.info("Initializing the sentence",r,u.current),!r.config.useTypeEffect){r.dispatchComplete();return}f([]),u.current=m(),a(),u.current.onComplete(()=>{r.dispatchComplete()})}},[r]),ul(()=>r.events.depends([r.events.on(vt.Events.requestComplete,()=>{u.current?.interact()}),r.events.on(vt.Events.forceSkip,()=>{r.isEnded()||u.current?.forceSkip()})]).cancel,[r,l]),ul(()=>s.preference.events.depends([s.preference.onPreferenceChange(de.Preferences.gameSpeed,()=>{u.current?.update()}),s.preference.onPreferenceChange(de.Preferences.autoForward,()=>{u.current?.update()})]).cancel,[]);function m(){let v=new b,S=new ne(v).setGuard(c.guard),C=new Set,x=new Set,w=new Set,_=dd(r.config.evaluatedWords),A=null,P=[],V=[],J=()=>{P.forEach(H=>H()),P.length=0},I=()=>{if(V.length!==0)return{done:!1,value:V.shift()};let{done:H,value:j}=_.next();return{done:H,value:j}},W=H=>{let j=Ie=>{H(Ie),x.delete(j)};return x.add(j),{cancel:()=>{x.delete(j)}}},se=H=>{f(j=>{let Ie=j[j.length-1];return Ie&&Ie!==`
|
|
64
64
|
`&&H!==`
|
|
65
|
-
`&&Ie.tag===H.tag?[...j.slice(0,-1),{...H,text:Ie.text+H.text,config:H.config}]:[...j,H]})},oe=(H=!1)=>{
|
|
66
|
-
`?f(Oe=>[...Oe,Le]):typeof Le=="object"&&"text"in Le&&!C.has(Le)&&(C.add(Le),se(Le))}A&&!A.isSettled()?A.abort():(w.forEach(Ie=>Ie()),v.resolve())};return c.schedule(async H=>{let j=!1,Ie=!1;for(;!j;){let{done:Le,value:Oe}=I();if(Le){j=Ie=!0;break}let
|
|
67
|
-
`&&C.has(Oe))continue;C.add(Oe),se(Oe);let
|
|
68
|
-
`?Wn.createElement("br",{key:S}):Wn.createElement(Bn.Span,{tag:`say.word.${S}`,key:S,style:{...y(v),...
|
|
69
|
-
at Video.tsx: useEffect`),f=()=>{u||!c||(u=!0,o.mountState(t,{show:()=>{if(!n.current)throw p();r()},hide:()=>{if(!n.current)throw p();i()},play:()=>{if(!n.current)throw p();let l=n.current;return l.currentTime=0,new Promise(m=>{o.schedule(({retry:d})=>{if(l.readyState<3){let T=()=>{l.removeEventListener("loadeddata",T),d()};l.addEventListener("loadeddata",T);return}let h=()=>{y(),m()},g=()=>{y(),m()},y=()=>{l.removeEventListener("ended",h),l.removeEventListener("stopped",g)};l.addEventListener("ended",h),l.addEventListener("stopped",g),a.push(y),l.play().catch(T=>{o.logger.error("Failed to play video: "+T),y(),m()})},10)})},pause:()=>{if(!n.current)throw p();n.current.pause()},resume:()=>{if(!n.current)throw p();return n.current.play()},stop:()=>{if(!n.current)throw p();n.current.pause(),n.current.dispatchEvent(new Event("stopped"))},seek:l=>{if(!n.current)throw p();n.current.currentTime=l}}))},a=[];return c.addEventListener("canplay",f),()=>{u=!1,c.removeEventListener("canplay",f),a.forEach(l=>l()),c.currentTime>0&&c.pause(),o.isStateMounted(t)&&o.unMountState(t)}},[o,t]);function s(){n.current&&(n.current.pause(),n.current.currentTime=0,n.current.dispatchEvent(new Event("stopped")))}return Nv.createElement("video",{ref:n,src:t.config.src,preload:"auto",muted:t.config.muted,playsInline:!0,width:"100%",height:"100%",onContextMenu:c=>c.preventDefault()})}function Fv(o,t){return o.handle(t)}function wd({story:o=Vr.empty(),width:t,height:n,className:r,onReady:i,onEnd:s,children:c,active:u=!0}){let[,p]=Cd(P=>P+1,0),[f,a]=Sl(0),l=N(),[m,d]=Cd(Fv,new ie(l,{update:p,forceUpdate:()=>{m.logger.weakWarn("Player","force update"),Ad(()=>{p()})},forceRemount:()=>{m.logger.weakWarn("Player","force remount"),Ad(()=>{a(P=>P+1),p()})},next:w,dispatch:P=>d(P)})),h=Ae.createRef(),g=Ae.createRef(),[y,T]=Sl(!1),v=Ae.useRef(!1),{preloaded:S}=Jo(),[C,x]=Sl(!1);function w(){let P=!1;for(;!P;){let V=l.getLiveGame().next(m);if(!V)break;if(b.isAwaitable(V)){V.then(()=>{m.stage.next()}),P=!0;break}if(V instanceof Xn){V.nextUnlock().then(()=>{w()}),P=!0;break}d(V)}m.stage.update()}
|
|
70
|
-
at Say.tsx: onElementClick`);return}let u=p=>{n.config.nextKey.includes(p.key)&&r.requestComplete()};return window.addEventListener("keyup",u),()=>{window.removeEventListener("keyup",u)}},[r]),Ed(()=>{let u=n.preference.onPreferenceChange(de.Preferences.autoForward,p=>{p&&r.isEnded()?r.tryScheduleAutoForward():r.cancelAutoForward()});return()=>{u.cancel()}},[r]),$n.createElement("div",{"data-element-type":"dialog",className:"w-full h-full"},$n.createElement("div",{className:q("absolute bottom-0 w-full h-full",!s&&"invisible pointer-events-auto"),onClick:c,style:{...
|
|
71
|
-
@layer properties{@supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}.pointer-events-auto{pointer-events:auto}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.static{position:static}.z-20{z-index:20}.container{width:100%}.block{display:block}.contents{display:contents}.flex{display:flex}.hidden{display:none}.inline-block{display:inline-block}.h-\\[80px\\]{height:80px}.h-full{height:100%}.h-max{height:-moz-max-content;height:max-content}.w-1\\/2{width:50%}.w-\\[100px\\]{width:100px}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-full{min-width:100%}.flex-grow{flex-grow:1}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.resize{resize:both}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.text-center{text-align:center}.text-left{text-align:left}.align-bottom{vertical-align:bottom}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.italic{font-style:italic}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.invert{--tw-invert:invert(100%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.__narraleaf_content-player *{-webkit-user-select:none;-moz-user-select:none;user-select:none}.__narraleaf_content-player img{pointer-events:none;-webkit-user-drag:none;-webkit-user-select:none}.__narraleaf_content-player .pointer-disabled{pointer-events:none}.__narraleaf_content-player .pointer-disabled>:not(.pointer-disabled),.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}\r
|
|
72
|
-
`,document.head.appendChild(o)}export{Gn as Align,Ec as Character,
|
|
65
|
+
`&&Ie.tag===H.tag?[...j.slice(0,-1),{...H,text:Ie.text+H.text,config:H.config}]:[...j,H]})},oe=(H=!1)=>{let j=!1;for(;!j;){let{done:Ie,value:Le}=I();if(Ie){j=!0;break}if(Ke.isPause(Le)){if(H)continue;j=!0,V.push(Le);break}else Le===`
|
|
66
|
+
`?f(Oe=>[...Oe,Le]):typeof Le=="object"&&"text"in Le&&!C.has(Le)&&(C.add(Le),se(Le))}A&&!A.isSettled()?A.abort():(w.forEach(Ie=>Ie()),v.resolve())};return c.schedule(async H=>{let j=!1,Ie=!1;for(;!j;){let{done:Le,value:Oe}=I();if(Le){j=Ie=!0;break}let St=new b;if(c.timelines.attachTimeline(St),St.registerSkipController(new K(()=>{J(),j=!0,H.retry()})),St.onSettled(()=>{J()}),A=St,Ke.isPause(Oe)){let Lt=Ke.from(Oe),en=s.preference.getPreference(de.Preferences.gameSpeed);if(Lt.config.duration){let mt=Lt.config.duration/en;await Jr(mt)}else{let mt=s.preference.getPreference(de.Preferences.autoForward),tn=b.race([b.create(Id=>{let Ld=W(_d=>{_d(),Id.resolve()});P.push(()=>Ld.cancel())}),...mt?[b.delay(s.config.autoForwardDefaultPause/en)]:[]]);c.timelines.attachTimeline(tn),await b.wait(tn)}}else{if(Oe!==`
|
|
67
|
+
`&&C.has(Oe))continue;C.add(Oe),se(Oe);let Lt=s.preference.getPreference(de.Preferences.gameSpeed),mt=1e3/((typeof Oe=="object"&&"cps"in Oe&&Oe.cps!==void 0?Oe.cps:s.config.cps)*Lt);await Jr(mt)}}Ie&&(w.forEach(Le=>Le()),v.resolve())},0),{getToken:()=>v,interact:()=>{let H=!1;x.forEach(j=>j(()=>H=!0)),!H&&oe()},update:()=>{A&&A.abort()},forceSkip:()=>{oe(!0)},timeline:S,onComplete:H=>(w.add(H),{cancel:()=>{w.delete(H)}})}}function d(v){let S=dd(v),C=[];for(let x of S)Ke.isPause(x)||C.push(x);return C}let h=r.config.action.sentence;if(!h)return null;let g={fontWeight:h.config.bold?s.config.fontWeightBold:s.config.fontWeight,fontSize:h.config.fontSize??s.config.fontSize,color:Pn(h.config.color??s.config.defaultTextColor),fontFamily:h.config.fontFamily??s.config.fontFamily,fontStyle:h.config.italic?"italic":void 0},y=v=>({fontWeight:v.config.bold||h.config.bold?s.config.fontWeightBold:s.config.fontWeight,fontSize:v.config.fontSize??h.config.fontSize??s.config.fontSize,color:Pn(v.config.color??h.config.color??o??s.config.defaultTextColor),fontFamily:v.config.fontFamily??h.config.fontFamily??s.config.fontFamily,fontStyle:v.config.italic??h.config.italic?"italic":void 0}),T=(v,S)=>v===`
|
|
68
|
+
`?Wn.createElement("br",{key:S}):Wn.createElement(Bn.Span,{tag:`say.word.${S}`,key:S,style:{...y(v),...Qr(s.config.app.debug,{outline:"1px dashed red"})},className:q("inline-block break-all",v.config.className)},v.config.ruby?Wn.createElement("ruby",{className:"align-bottom inline-block"},Wn.createElement("rt",{className:"block text-center"},v.config.ruby),v.text):v.text);return Wn.createElement("div",{...i,className:q("whitespace-pre-wrap",t),style:{...n,...g}},p.map(T))}function gd(o){return Wn.createElement(hd,{...o,key:o.dialog?.config.action.id})}function pl(o){let t=Jt();return Wn.createElement(hd,{...o,dialog:t,key:t.config.action.id})}var wv=pl;function ua({className:o,style:t,bindKey:n}){let r=kv(null),{register:i,unregister:s,getIndex:c}=pd(),[u,p]=Dv(-1),{choose:f,evaluated:a,gameState:l}=ud(),m=u===-1?null:a[u];Ev(()=>{if(!r.current)return;let h=r;i(h);let g=c(h);return p(g),r.current.dataset.index=g.toString(),()=>s(h)},[i,s,c]),Pv(()=>{if(!n)return;let h=g=>{g.key.toLowerCase()===n.toLowerCase()&&!g.ctrlKey&&!g.metaKey&&(g.preventDefault(),g.stopPropagation(),d())};return window.addEventListener("keydown",h,!0),()=>{window.removeEventListener("keydown",h,!0)}},[n]);function d(){if(u===-1||!a[u])return;let h=a[u];f({...h,evaluated:Z.getText(h.words||[])})}return la.createElement(la.Fragment,null,la.createElement("button",{className:q(o),style:t,onClick:d,ref:r},m&&la.createElement(gd,{dialog:new vt({useTypeEffect:!1,action:{sentence:m.prompt,words:m.words,character:null},gameState:l,evaluatedWords:m.words})})))}function fl({prompt:o,choices:t,afterChoose:n,state:r,words:i}){let s=N(),c=Iv([]),u=ml(d=>(c.current.push(d),c.current.indexOf(d)),[]),p=ml(d=>{let h=c.current.indexOf(d);h!==-1&&c.current.splice(h,1)},[]),f=ml(d=>c.current.indexOf(d),[]),a=s.config.menu,l=Rv(()=>t.map(d=>({...d,words:d.prompt.evaluate(ut.getCtx({gameState:r}))})),[]);function m(d){n(d)}return It.createElement(It.Fragment,null,It.createElement(al,{value:{evaluated:l,choose:m,gameState:r}},It.createElement(cl,{value:{register:u,unregister:p,getIndex:f}},It.createElement(Dt,{className:"absolute"},o&&It.createElement(Br,{gameState:r,action:{sentence:o,words:i,character:null},useTypeEffect:!1})),It.createElement(Bn.Div,{color:"green",border:"dashed",className:q("absolute"),style:{width:`${s.config.width}px`,height:`${s.config.height}px`}},It.createElement(a,{items:l.map((d,h)=>h)})))))}function yd({items:o}){return It.createElement(aa,{className:"absolute flex flex-col items-center justify-center min-w-full w-full h-full"},o.map(t=>It.createElement(ua,{key:t,className:"bg-white text-black p-2 mt-2 w-1/2"})))}import Wr,{useEffect as Lv}from"react";import pa from"react";function ma({children:o,...t}){let n=cr;return pa.createElement(pa.Fragment,null,pa.createElement("div",{...t},pa.createElement(n,null,o)))}function dl({gameState:o}){let[t]=Ye(),n=o.notificationMgr;Lv(()=>n.onFlush(()=>{t()}).cancel,[]);let r=o.game.config.notification;return Wr.createElement("div",{className:"absolute top-0 left-0 w-full h-full pointer-events-none","data-element-type":"notification"},Wr.createElement(r,{notifications:n.toArray()}))}function Td({notifications:o}){return Wr.createElement(ma,{className:"absolute top-0 left-0 w-full h-full"},o.map(({id:t,message:n})=>Wr.createElement("div",{key:t,className:"absolute top-0 left-0 w-[100px] h-[80px]"},Wr.createElement("span",{className:"text-white text-2xl font-bold"},n))))}function gl({state:o,className:t,elements:n}){let{scene:r,layers:i,texts:s,menus:c}=n,u=_v(!1);return hl(()=>r.events.depends([r.events.on(yt.EventTypes["event:scene.preUnmount"],()=>{if(r.state.backgroundMusic)return o.audioManager.stop(r.state.backgroundMusic).then(()=>{r.state.backgroundMusic=null})})]).cancel,[]),hl(()=>(r.events.emit(yt.EventTypes["event:scene.mount"]),o.logger.debug("Scene","Scene mounted",r.getId()),()=>{r.events.emit(yt.EventTypes["event:scene.unmount"]),o.logger.debug("Scene","Scene unmounted",r.getId())}),[]),wn(r,{setBackgroundMusic(p,f){return new Promise(a=>{r.state.backgroundMusic&&o.audioManager.stop(r.state.backgroundMusic,f).then(()=>{r.state.backgroundMusic=null,p&&o.audioManager.play(p,{end:p.state.volume,duration:f}).then(a)})})}}),hl(()=>{o.events.emit(ie.EventTypes["event:state.onRender"])},[]),jn.createElement("div",{className:q(t,"w-full h-full absolute")},[...i.entries()].sort(([p],[f])=>p.config.zIndex-f.config.zIndex).map(([p,f])=>jn.createElement(id,{state:o,layer:p,key:p.getId()},jn.createElement(sl,{state:o,displayable:f}))),s.map(({action:p,onClick:f})=>jn.createElement(Br,{gameState:o,key:"say-"+p.id,action:p,onFinished:a=>{a!==void 0&&(u.current=a),f(),o.stage.next(),setTimeout(()=>{u.current=!1},0)},useTypeEffect:!u.current})),c.map(({action:p,onClick:f},a)=>jn.createElement("div",{key:"menu-"+a,"data-element-type":"menu"},jn.createElement(fl,{state:o,prompt:p.prompt,choices:p.choices,afterChoose:l=>{f(l),o.stage.next()},words:p.words}))),jn.createElement(dl,{gameState:o}))}import vd,{useEffect as Mv}from"react";function Sd({state:o}){let t=N(),n=Ur();return Mv(()=>{if(!t.getLiveGame().gameState.playerCurrent){o.logger.warn("KeyEventAnnouncer","Failed to listen to playerElement events");return}let i=Dl(s=>{t.config.skipKey.includes(s.key)&&t.preference.getPreference(de.Preferences.skip)&&(!n||!n.isActive())&&(o.logger.verbose("KeyEventAnnouncer","Emitted event: state.player.skip"),o.events.emit(ie.EventTypes["event:state.player.skip"]))},t.config.skipInterval);return t.getLiveGame().onPlayerEvent("keydown",i).cancel},[n]),vd.createElement(vd.Fragment,null)}import{useEffect as Vv}from"react";function yl({ref:o}){let{ratio:t}=be();return Vv(()=>{let n=o.current;if(!n)return;let r=new ResizeObserver(()=>{t.requestUpdate()});return r.observe(n),()=>{r.disconnect()}},[o.current]),null}import Nv from"react";import{useEffect as Tl,useRef as Gv}from"react";import{useCallback as xd}from"react";function bd(o){let t=xd(()=>{if(!o.current)return;let r=o.current;r.style.opacity="1",r.style.pointerEvents="auto",r.style.visibility="visible"},[o]),n=xd(()=>{if(!o.current)return;let r=o.current;r.style.opacity="0",r.style.pointerEvents="none",r.style.visibility="hidden"},[o]);return{show:t,hide:n}}function vl({gameState:o,video:t}){let n=Gv(null),{show:r,hide:i}=bd(n);Tl(()=>o.events.depends([o.events.on(ie.EventTypes["event:state.player.skip"],()=>{o.game.config.allowSkipVideo&&(s(),o.logger.log("NarraLeaf-React: Video","Skipped"))})]).cancel,[]),Tl(()=>{i(),t.state.display&&r()},[]),Tl(()=>{if(!n.current)return;let c=n.current,u=!1,p=()=>new M(`Failed to add event listener, ref is not available
|
|
69
|
+
at Video.tsx: useEffect`),f=()=>{u||!c||(u=!0,o.mountState(t,{show:()=>{if(!n.current)throw p();r()},hide:()=>{if(!n.current)throw p();i()},play:()=>{if(!n.current)throw p();let l=n.current;return l.currentTime=0,new Promise(m=>{o.schedule(({retry:d})=>{if(l.readyState<3){let T=()=>{l.removeEventListener("loadeddata",T),d()};l.addEventListener("loadeddata",T);return}let h=()=>{y(),m()},g=()=>{y(),m()},y=()=>{l.removeEventListener("ended",h),l.removeEventListener("stopped",g)};l.addEventListener("ended",h),l.addEventListener("stopped",g),a.push(y),l.play().catch(T=>{o.logger.error("Failed to play video: "+T),y(),m()})},10)})},pause:()=>{if(!n.current)throw p();n.current.pause()},resume:()=>{if(!n.current)throw p();return n.current.play()},stop:()=>{if(!n.current)throw p();n.current.pause(),n.current.dispatchEvent(new Event("stopped"))},seek:l=>{if(!n.current)throw p();n.current.currentTime=l}}))},a=[];return c.addEventListener("canplay",f),()=>{u=!1,c.removeEventListener("canplay",f),a.forEach(l=>l()),c.currentTime>0&&c.pause(),o.isStateMounted(t)&&o.unMountState(t)}},[o,t]);function s(){n.current&&(n.current.pause(),n.current.currentTime=0,n.current.dispatchEvent(new Event("stopped")))}return Nv.createElement("video",{ref:n,src:t.config.src,preload:"auto",muted:t.config.muted,playsInline:!0,width:"100%",height:"100%",onContextMenu:c=>c.preventDefault()})}function Fv(o,t){return o.handle(t)}function wd({story:o=Vr.empty(),width:t,height:n,className:r,onReady:i,onEnd:s,children:c,active:u=!0}){let[,p]=Cd(P=>P+1,0),[f,a]=Sl(0),l=N(),[m,d]=Cd(Fv,new ie(l,{update:p,forceUpdate:()=>{m.logger.weakWarn("Player","force update"),Ad(()=>{p()})},forceRemount:()=>{m.logger.weakWarn("Player","force remount"),Ad(()=>{a(P=>P+1),p()})},next:w,dispatch:P=>d(P)})),h=Ae.createRef(),g=Ae.createRef(),[y,T]=Sl(!1),v=Ae.useRef(!1),{preloaded:S}=Jo(),[C,x]=Sl(!1);function w(){let P=!1;for(;!P;){let V=l.getLiveGame().next(m);if(!V)break;if(b.isAwaitable(V)){V.then(()=>{m.stage.next()}),P=!0;break}if(V instanceof Xn){V.nextUnlock().then(()=>{w()}),P=!0;break}d(V)}m.stage.update()}fa(()=>(l.getLiveGame().setGameState(m),o&&!l.getLiveGame().isPlaying()&&l.getLiveGame().loadStory(o),m.playerCurrent=h.current,m.mainContentNode=g.current,()=>{l.getLiveGame().setGameState(void 0),m.playerCurrent=null}),[l,o]),fa(()=>rn(()=>{T(!0);let P=m.getLastScene(),V=[];P?V.push(P.events.once("event:scene.mount",()=>{m.stage.next()}).cancel):m.stage.next();let J=m.events.on(ie.EventTypes["event:state.end"],()=>{s&&s({game:l,gameState:m,liveGame:l.getLiveGame(),storable:l.getLiveGame().getStorable()})});return m.stage.update(),()=>{P&&V.forEach(I=>I()),J.cancel()}}),[]),fa(()=>rn(()=>{y&&i&&!v.current&&(v.current=!0,m.stage.forceUpdate(),l.hooks.trigger("init",[]),i({game:l,gameState:m,liveGame:l.getLiveGame(),storable:l.getLiveGame().getStorable()}))}),[y]),fa(()=>S.events.depends([S.events.on(ot.EventTypes["event:preloaded.ready"],()=>{x(!0),m.stage.update(),o&&w()})]).cancel,[]);let _=t||l.config.width,A=n||l.config.height;return Ae.createElement(Zs,null,Ae.createElement("div",{style:{width:typeof _=="number"?`${_}px`:_,height:typeof A=="number"?`${A}px`:A},className:q(r,"__narraleaf_content-player"),ref:h,tabIndex:0},Ae.createElement(Wc,{className:q("flex-grow overflow-auto"),gameState:m},Ae.createElement(yl,{ref:h}),Ae.createElement(Dt,{className:"absolute",ref:g,style:{cursor:m.game.config.cursor?"none":"auto",overflow:m.game.config.showOverflow?"visible":"hidden"}},l.config.cursor&&Ae.createElement(Bc,{src:l.config.cursor,width:l.config.cursorWidth,height:l.config.cursorHeight}),Ae.createElement(Ov,{show:C&&u,key:f},Ae.createElement(Sd,{state:m}),m.getSceneElements().map(P=>Ae.createElement(gl,{key:"scene-"+P.scene.getId(),state:m,elements:P})),m.getVideos().map((P,V)=>Ae.createElement("div",{className:"w-full h-full absolute",key:"video-"+V,"data-element-type":"video"},Ae.createElement(vl,{gameState:m,video:P})))),Ae.createElement(Qf,{state:m}),Ae.createElement(od,null,c)))))}function Ov({children:o,show:t}){return Ae.createElement(Ae.Fragment,null,t?o:null)}import nr from"react";function Pd({children:o,game:t}){return nr.createElement(nr.Fragment,null,nr.createElement(Uf,null,nr.createElement(zf,{game:t},nr.createElement(Jf,null,nr.createElement(nd,null,o)))))}var Hv=(s=>(s.image="narraleaf:image",s.text="narraleaf:text",s.layer="narraleaf:layer",s.scene="narraleaf:scene",s.video="narraleaf:video",s))(Hv||{});import Uv,{useEffect as Kv}from"react";function xl(o){let t=N(),[n,r]=Uv.useState(t.preference.getPreference(o)),i=s=>{t.preference.setPreference(o,s),r(s)};return Kv(()=>t.preference.onPreferenceChange(o,r).cancel,[]),[n,i]}import da from"react";function ha({...o}){let{config:t}=Jt(),n=N();return da.createElement(da.Fragment,null,da.createElement("div",{...o},da.createElement("span",{style:{color:Pn(t.action.character?.config.color||n.config.defaultNametagColor)}},t.action.character?.state.name)))}import{useEffect as Bv}from"react";function Wv(){let o=Jt(),[t]=Ye(o.deps),n=Z.getText(o.config.evaluatedWords);return Bv(()=>o.events.on(vt.Events.onFlush,()=>{t()}).cancel,[o]),{done:o.isEnded(),text:n}}import $n,{useEffect as Ed}from"react";function $v({children:o,...t}){let n=N(),r=Jt(),{ratio:i}=be(),[s]=xl(de.Preferences.showDialog);function c(){r.requestComplete()}return Ed(()=>{if(!window){console.warn(`Failed to add event listener, window is not available
|
|
70
|
+
at Say.tsx: onElementClick`);return}let u=p=>{n.config.nextKey.includes(p.key)&&r.requestComplete()};return window.addEventListener("keyup",u),()=>{window.removeEventListener("keyup",u)}},[r]),Ed(()=>{let u=n.preference.onPreferenceChange(de.Preferences.autoForward,p=>{p&&r.isEnded()?r.tryScheduleAutoForward():r.cancelAutoForward()});return()=>{u.cancel()}},[r]),$n.createElement("div",{"data-element-type":"dialog",className:"w-full h-full"},$n.createElement("div",{className:q("absolute bottom-0 w-full h-full",!s&&"invisible pointer-events-auto"),onClick:c,style:{...Qr(n.config.useAspectScale,{maxWidth:n.config.dialogWidth,maxHeight:n.config.dialogHeight,transform:`scale(${i.state.scale})`,transformOrigin:"bottom left",width:n.config.width,height:n.config.height})}},$n.createElement("div",{...t},o)))}function kd({children:o,...t}){let n=Jt();return!n.config.action.sentence||!n.config.action.words?null:$n.createElement($v,{...t},o)}var jv=kd;function Dd(){return $n.createElement(kd,null,$n.createElement(ha,null),$n.createElement(pl,null))}var ga={say:Dd,menu:yd,notification:Td};var ya=class{constructor(t){this.game=t;this.plugins=[];this.registerAll()}use(t){return this.plugins.push(t),this}register(t){t.register(this.game)}registerAll(){this.plugins.forEach(t=>t.register(this.game))}unregisterAll(){this.plugins.forEach(t=>t.unregister(this.game))}has(t){return this.plugins.some(n=>n.name===t.name)}};var Rd=(t=>(t.game="game",t))(Rd||{}),Qt=class Qt{constructor(t){this.hooks=new Yr;this.liveGame=null;this.sideEffect=[];this.preference=new Ys(Qt.DefaultPreference);this.config=U(Qt.DefaultConfig,t),this.plugins=new ya(this)}configure(t){return this.config=U(this.config,t),this.getLiveGame().getGameState()?.events.emit(ie.EventTypes["event:state.player.requestFlush"]),this}use(t){return this.plugins.has(t)||this.plugins.use(t).register(t),this}getLiveGame(){if(!this.liveGame){let t=this.createLiveGame();return this.liveGame=t,t}return this.liveGame}dispose(){this.plugins.unregisterAll(),this.liveGame?.dispose(),this.sideEffect.forEach(t=>t())}addSideEffect(t){this.sideEffect.push(t)}createLiveGame(){return new Cn(this)}};Qt.defaultSettings={volume:1},Qt.DefaultPreference={autoForward:!1,skip:!0,showDialog:!0,gameSpeed:1},Qt.Preferences={autoForward:"autoForward",skip:"skip",showDialog:"showDialog",gameSpeed:"gameSpeed"},Qt.DefaultConfig={app:{debug:!1,logger:{log:!1,info:!1,warn:!0,error:!0,debug:!1,trace:!1,verbose:!1},inspector:!1,guard:{invalidExposedStateUnmounting:!0,unexpectedTimelineStatusChange:!0}},contentContainerId:"__narraleaf_content",aspectRatio:16/9,minWidth:800,minHeight:450,width:1920,height:1080,skipKey:["Control"],skipInterval:100,ratioUpdateInterval:50,preloadDelay:100,preloadConcurrency:5,waitForPreload:!0,preloadAllImages:!0,forceClearCache:!1,maxPreloadActions:10,cursor:null,cursorHeight:30,cursorWidth:30,showOverflow:!1,maxRouterHistory:10,screenshotQuality:1,nextKey:[" "],cps:10,useAspectScale:!0,autoForwardDelay:3*1e3,autoForwardDefaultPause:1e3,allowSkipImageTransform:!0,allowSkipImageTransition:!0,allowSkipBackgroundTransform:!0,allowSkipBackgroundTransition:!1,allowSkipTextTransform:!0,allowSkipTextTransition:!0,allowSkipLayersTransform:!0,allowSkipVideo:!1,dialogWidth:1920,dialogHeight:1080*.2,defaultTextColor:"#000",defaultNametagColor:"#000",notification:ga.notification,menu:ga.menu,dialog:ga.say,onError:t=>{console.error(t)},fontSize:16,fontWeight:400,fontWeightBold:700,fontFamily:"sans-serif",stage:null,defaultMenuChoiceColor:"#000"},Qt.GameSettingsNamespace=Rd;var de=Qt;var zn=class extends Et{_setPrevSrc(t){return this._prevSrc=t,this}_setTargetSrc(t){return this._targetSrc=t,this}_setCurrentSrc(t){return this._currentSrc=t,this}_getPrevSrc(){return this._prevSrc}_getTargetSrc(){return this._targetSrc}_getCurrentSrc(){return this._currentSrc}requestAnimations(t){let n=super.requestAnimations(t);return n.onComplete(()=>{this._setCurrentSrc(this._getTargetSrc())}),n}asPrev(t){return super.asPrev((...n)=>U(t(...n),this._srcToProps(this._prevSrc)))}asTarget(t){return super.asTarget((...n)=>U(t(...n),this._srcToProps(this._targetSrc)))}_srcToProps(t){if(k.isColor(t))return{src:B.DefaultImagePlaceholder,style:{backgroundColor:k.isRGBAColor(t)?k.RGBAColorToHex(t):t}};if(k.isImageSrc(t))return{src:k.srcToURL(t)};throw new me("Image transition src cannot be identified, using: "+t)}};var bl=class o extends zn{constructor(n,r){super();this.duration=n;this.easing=r}createTask(){return{animations:[{type:0,start:0,end:1,duration:this.duration,ease:this.easing}],resolve:[this.asPrev(n=>({style:{opacity:1-n}})),this.asTarget(n=>({style:{opacity:n}}))]}}copy(){return new o(this.duration,this.easing)}};var Al=class o extends zn{constructor(n,r=[0,0],i){super();this.duration=n;this.startPos=r;this.easing=i}createTask(n){return{animations:[{type:0,start:0,end:1,duration:this.duration,ease:this.easing},{type:0,start:this.startPos[0],end:0,duration:this.duration,ease:this.easing},{type:0,start:this.startPos[1],end:0,duration:this.duration,ease:this.easing}],resolve:[this.asPrev(()=>({})),this.asTarget((r,i,s)=>({style:{opacity:r,...k.offset(["50%","50%"],[i,s],n.getStory().getInversionConfig()),transform:"translate(-50%, 50%)"}}))]}}copy(){return new o(this.duration,this.startPos,this.easing)}};if(typeof document<"u"){let o=document.createElement("style");o.textContent=`/*! tailwindcss v4.1.5 | MIT License | https://tailwindcss.com */
|
|
71
|
+
@layer properties{@supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}.pointer-events-auto{pointer-events:auto}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.static{position:static}.z-20{z-index:20}.container{width:100%}.block{display:block}.contents{display:contents}.flex{display:flex}.hidden{display:none}.inline-block{display:inline-block}.h-\\[80px\\]{height:80px}.h-full{height:100%}.h-max{height:-moz-max-content;height:max-content}.w-1\\/2{width:50%}.w-\\[100px\\]{width:100px}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-full{min-width:100%}.flex-grow{flex-grow:1}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.resize{resize:both}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.text-center{text-align:center}.text-left{text-align:left}.align-bottom{vertical-align:bottom}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.italic{font-style:italic}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.invert{--tw-invert:invert(100%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.__narraleaf_content-player *{-webkit-user-select:none;-moz-user-select:none;user-select:none}.__narraleaf_content-player img{pointer-events:none;-webkit-user-drag:none;-webkit-user-select:none}.__narraleaf_content-player .pointer-disabled{pointer-events:none}.__narraleaf_content-player .pointer-disabled>:not(.pointer-disabled),.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.bg-cover{background-size:cover}.bg-center{background-position:50%}.pointer-events-auto-rest *{pointer-events:auto}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}\r
|
|
72
|
+
`,document.head.appendChild(o)}export{Gn as Align,Ec as Character,ct as CommonPosition,kr as CommonPositionType,kc as Condition,Bt as Control,ze as Coord2D,jv as Dialog,bl as Dissolve,Hv as ExposedStateType,Al as FadeIn,de as Game,aa as GameMenu,Pd as GameProviders,ie as GameState,B as Image,zn as ImageTransition,Dt as Isolated,ua as Item,Be as Lambda,Wo as Layer,Cn as LiveGame,Dc as Menu,$t as Namespace,ha as Nametag,ma as Notifications,Xc as Page,Ke as Pause,Bo as Persistent,wd as Player,yt as Scene,ut as Script,Re as Sentence,Lc as Service,lt as Sound,el as Stage,_r as Storable,Vr as Story,Un as Text,Ir as TextTransition,wv as Texts,ce as Transform,Et as Transition,_c as Video,Z as Word,nT as b,tT as c,oT as i,Wv as useDialog,N as useGame,xl as usePreference,Ur as useRouter};
|
|
73
73
|
/*! Bundled license information:
|
|
74
74
|
|
|
75
75
|
howler/dist/howler.js:
|