narraleaf-react 0.4.0 → 0.4.2

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/main.js CHANGED
@@ -1,31 +1,96 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],e):"object"==typeof exports?exports.NarraleafReact=e(require("react"),require("react-dom")):t.NarraleafReact=e(t.React,t.ReactDOM)}(this,((t,e)=>(()=>{var n={587:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(601),o=n.n(r),i=n(314),a=n.n(i)()(o());a.push([t.id,"*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}/*\n! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n7. Disable tap highlights on iOS\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font-family by default.\n2. Use the user's configured `mono` font-feature-settings by default.\n3. Use the user's configured `mono` font-variation-settings by default.\n4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-feature-settings: normal; /* 2 */\n font-variation-settings: normal; /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\ninput:where([type='button']),\ninput:where([type='reset']),\ninput:where([type='submit']) {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nReset default styling for dialogs.\n*/\ndialog {\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden]:where(:not([hidden=\"until-found\"])) {\n display: none;\n}\n.\\!container {\n width: 100% !important;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 640px) {\n\n .\\!container {\n max-width: 640px !important;\n }\n\n .container {\n max-width: 640px;\n }\n}\n@media (min-width: 768px) {\n\n .\\!container {\n max-width: 768px !important;\n }\n\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n\n .\\!container {\n max-width: 1024px !important;\n }\n\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n\n .\\!container {\n max-width: 1280px !important;\n }\n\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n\n .\\!container {\n max-width: 1536px !important;\n }\n\n .container {\n max-width: 1536px;\n }\n}\n.pointer-events-none {\n pointer-events: none;\n}\n.pointer-events-auto {\n pointer-events: auto;\n}\n.\\!visible {\n visibility: visible !important;\n}\n.visible {\n visibility: visible;\n}\n.invisible {\n visibility: hidden;\n}\n.static {\n position: static;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.inset-0 {\n inset: 0px;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-20 {\n z-index: 20;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.block {\n display: block;\n}\n.inline-block {\n display: inline-block;\n}\n.flex {\n display: flex;\n}\n.hidden {\n display: none;\n}\n.h-\\[80px\\] {\n height: 80px;\n}\n.h-full {\n height: 100%;\n}\n.h-max {\n height: -moz-max-content;\n height: max-content;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-\\[100px\\] {\n width: 100px;\n}\n.w-\\[calc\\(100\\%-40px\\)\\] {\n width: calc(100% - 40px);\n}\n.w-full {\n width: 100%;\n}\n.w-max {\n width: -moz-max-content;\n width: max-content;\n}\n.min-w-full {\n min-width: 100%;\n}\n.flex-grow {\n flex-grow: 1;\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.resize {\n resize: both;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.whitespace-pre {\n white-space: pre;\n}\n.whitespace-pre-wrap {\n white-space: pre-wrap;\n}\n.border {\n border-width: 1px;\n}\n.border-2 {\n border-width: 2px;\n}\n.border-black {\n --tw-border-opacity: 1;\n border-color: rgb(0 0 0 / var(--tw-border-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.p-2 {\n padding: 0.5rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.align-bottom {\n vertical-align: bottom;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.italic {\n font-style: italic;\n}\n.text-black {\n --tw-text-opacity: 1;\n color: rgb(0 0 0 / var(--tw-text-opacity, 1));\n}\n.text-red-700 {\n --tw-text-opacity: 1;\n color: rgb(185 28 28 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.outline {\n outline-style: solid;\n}\n.invert {\n --tw-invert: invert(100%);\n 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);\n}\n.filter {\n 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);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n\n.__narraleaf_content-player * {\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n.__narraleaf_content-player img {\n pointer-events: none;\n -webkit-user-drag: none;\n -webkit-user-select: none;\n}\n\n.__narraleaf_content-player .pointer-disabled {\n pointer-events: none;\n}\n\n.__narraleaf_content-player .pointer-disabled > :not(.pointer-disabled) {\n pointer-events: auto;\n }\n",""]);const s=a},314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,r,o,i){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(r)for(var s=0;s<this.length;s++){var u=this[s][0];null!=u&&(a[u]=!0)}for(var c=0;c<t.length;c++){var l=[].concat(t[c]);r&&a[l[0]]||(void 0!==i&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=i),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),e.push(l))}},e}},601:t=>{"use strict";t.exports=function(t){return t[1]}},196:(t,e,n)=>{var r;
2
- /*!
3
- * howler.js v2.2.4
4
- * howlerjs.com
5
- *
6
- * (c) 2013-2020, James Simpson of GoldFire Studios
7
- * goldfirestudios.com
8
- *
9
- * MIT License
10
- */!function(){"use strict";var o=function(){this.init()};o.prototype={init:function(){var t=this||i;return t._counter=1e3,t._html5AudioPool=[],t.html5PoolSize=10,t._codecs={},t._howls=[],t._muted=!1,t._volume=1,t._canPlayEvent="canplaythrough",t._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,t.masterGain=null,t.noAudio=!1,t.usingWebAudio=!0,t.autoSuspend=!0,t.ctx=null,t.autoUnlock=!0,t._setup(),t},volume:function(t){var e=this||i;if(t=parseFloat(t),e.ctx||p(),void 0!==t&&t>=0&&t<=1){if(e._volume=t,e._muted)return e;e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t,i.ctx.currentTime);for(var n=0;n<e._howls.length;n++)if(!e._howls[n]._webAudio)for(var r=e._howls[n]._getSoundIds(),o=0;o<r.length;o++){var a=e._howls[n]._soundById(r[o]);a&&a._node&&(a._node.volume=a._volume*t)}return e}return e._volume},mute:function(t){var e=this||i;e.ctx||p(),e._muted=t,e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t?0:e._volume,i.ctx.currentTime);for(var n=0;n<e._howls.length;n++)if(!e._howls[n]._webAudio)for(var r=e._howls[n]._getSoundIds(),o=0;o<r.length;o++){var a=e._howls[n]._soundById(r[o]);a&&a._node&&(a._node.muted=!!t||a._muted)}return e},stop:function(){for(var t=this||i,e=0;e<t._howls.length;e++)t._howls[e].stop();return t},unload:function(){for(var t=this||i,e=t._howls.length-1;e>=0;e--)t._howls[e].unload();return t.usingWebAudio&&t.ctx&&void 0!==t.ctx.close&&(t.ctx.close(),t.ctx=null,p()),t},codecs:function(t){return(this||i)._codecs[t.replace(/^x-/,"")]},_setup:function(){var t=this||i;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(t){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||i,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(e){return t}if(!e||"function"!=typeof e.canPlayType)return t;var n=e.canPlayType("audio/mpeg;").replace(/^no$/,""),r=t._navigator?t._navigator.userAgent:"",o=r.match(/OPR\/(\d+)/g),a=o&&parseInt(o[0].split("/")[1],10)<33,s=-1!==r.indexOf("Safari")&&-1===r.indexOf("Chrome"),u=r.match(/Version\/(.*?) /),c=s&&u&&parseInt(u[1],10)<15;return t._codecs={mp3:!(a||!n&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!n,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(c||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(c||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var t=this||i;if(!t._audioUnlocked&&t.ctx){t._audioUnlocked=!1,t.autoUnlock=!1,t._mobileUnloaded||44100===t.ctx.sampleRate||(t._mobileUnloaded=!0,t.unload()),t._scratchBuffer=t.ctx.createBuffer(1,1,22050);var e=function(n){for(;t._html5AudioPool.length<t.html5PoolSize;)try{var r=new Audio;r._unlocked=!0,t._releaseHtml5Audio(r)}catch(n){t.noAudio=!0;break}for(var o=0;o<t._howls.length;o++)if(!t._howls[o]._webAudio)for(var i=t._howls[o]._getSoundIds(),a=0;a<i.length;a++){var s=t._howls[o]._soundById(i[a]);s&&s._node&&!s._node._unlocked&&(s._node._unlocked=!0,s._node.load())}t._autoResume();var u=t.ctx.createBufferSource();u.buffer=t._scratchBuffer,u.connect(t.ctx.destination),void 0===u.start?u.noteOn(0):u.start(0),"function"==typeof t.ctx.resume&&t.ctx.resume(),u.onended=function(){u.disconnect(0),t._audioUnlocked=!0,document.removeEventListener("touchstart",e,!0),document.removeEventListener("touchend",e,!0),document.removeEventListener("click",e,!0),document.removeEventListener("keydown",e,!0);for(var n=0;n<t._howls.length;n++)t._howls[n]._emit("unlock")}};return document.addEventListener("touchstart",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("click",e,!0),document.addEventListener("keydown",e,!0),t}},_obtainHtml5Audio:function(){var t=this||i;if(t._html5AudioPool.length)return t._html5AudioPool.pop();var e=(new Audio).play();return e&&"undefined"!=typeof Promise&&(e instanceof Promise||"function"==typeof e.then)&&e.catch((function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")})),new Audio},_releaseHtml5Audio:function(t){var e=this||i;return t._unlocked&&e._html5AudioPool.push(t),e},_autoSuspend:function(){var t=this;if(t.autoSuspend&&t.ctx&&void 0!==t.ctx.suspend&&i.usingWebAudio){for(var e=0;e<t._howls.length;e++)if(t._howls[e]._webAudio)for(var n=0;n<t._howls[e]._sounds.length;n++)if(!t._howls[e]._sounds[n]._paused)return t;return t._suspendTimer&&clearTimeout(t._suspendTimer),t._suspendTimer=setTimeout((function(){if(t.autoSuspend){t._suspendTimer=null,t.state="suspending";var e=function(){t.state="suspended",t._resumeAfterSuspend&&(delete t._resumeAfterSuspend,t._autoResume())};t.ctx.suspend().then(e,e)}}),3e4),t}},_autoResume:function(){var t=this;if(t.ctx&&void 0!==t.ctx.resume&&i.usingWebAudio)return"running"===t.state&&"interrupted"!==t.ctx.state&&t._suspendTimer?(clearTimeout(t._suspendTimer),t._suspendTimer=null):"suspended"===t.state||"running"===t.state&&"interrupted"===t.ctx.state?(t.ctx.resume().then((function(){t.state="running";for(var e=0;e<t._howls.length;e++)t._howls[e]._emit("resume")})),t._suspendTimer&&(clearTimeout(t._suspendTimer),t._suspendTimer=null)):"suspending"===t.state&&(t._resumeAfterSuspend=!0),t}};var i=new o,a=function(t){t.src&&0!==t.src.length?this.init(t):console.error("An array of source files must be passed with any new Howl.")};a.prototype={init:function(t){var e=this;return i.ctx||p(),e._autoplay=t.autoplay||!1,e._format="string"!=typeof t.format?t.format:[t.format],e._html5=t.html5||!1,e._muted=t.mute||!1,e._loop=t.loop||!1,e._pool=t.pool||5,e._preload="boolean"!=typeof t.preload&&"metadata"!==t.preload||t.preload,e._rate=t.rate||1,e._sprite=t.sprite||{},e._src="string"!=typeof t.src?t.src:[t.src],e._volume=void 0!==t.volume?t.volume:1,e._xhr={method:t.xhr&&t.xhr.method?t.xhr.method:"GET",headers:t.xhr&&t.xhr.headers?t.xhr.headers:null,withCredentials:!(!t.xhr||!t.xhr.withCredentials)&&t.xhr.withCredentials},e._duration=0,e._state="unloaded",e._sounds=[],e._endTimers={},e._queue=[],e._playLock=!1,e._onend=t.onend?[{fn:t.onend}]:[],e._onfade=t.onfade?[{fn:t.onfade}]:[],e._onload=t.onload?[{fn:t.onload}]:[],e._onloaderror=t.onloaderror?[{fn:t.onloaderror}]:[],e._onplayerror=t.onplayerror?[{fn:t.onplayerror}]:[],e._onpause=t.onpause?[{fn:t.onpause}]:[],e._onplay=t.onplay?[{fn:t.onplay}]:[],e._onstop=t.onstop?[{fn:t.onstop}]:[],e._onmute=t.onmute?[{fn:t.onmute}]:[],e._onvolume=t.onvolume?[{fn:t.onvolume}]:[],e._onrate=t.onrate?[{fn:t.onrate}]:[],e._onseek=t.onseek?[{fn:t.onseek}]:[],e._onunlock=t.onunlock?[{fn:t.onunlock}]:[],e._onresume=[],e._webAudio=i.usingWebAudio&&!e._html5,void 0!==i.ctx&&i.ctx&&i.autoUnlock&&i._unlockAudio(),i._howls.push(e),e._autoplay&&e._queue.push({event:"play",action:function(){e.play()}}),e._preload&&"none"!==e._preload&&e.load(),e},load:function(){var t=this,e=null;if(i.noAudio)t._emit("loaderror",null,"No audio support.");else{"string"==typeof t._src&&(t._src=[t._src]);for(var n=0;n<t._src.length;n++){var r,o;if(t._format&&t._format[n])r=t._format[n];else{if("string"!=typeof(o=t._src[n])){t._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}(r=/^data:audio\/([^;,]+);/i.exec(o))||(r=/\.([^.]+)$/.exec(o.split("?",1)[0])),r&&(r=r[1].toLowerCase())}if(r||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),r&&i.codecs(r)){e=t._src[n];break}}if(e)return t._src=e,t._state="loading","https:"===window.location.protocol&&"http:"===e.slice(0,5)&&(t._html5=!0,t._webAudio=!1),new s(t),t._webAudio&&c(t),t;t._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(t,e){var n=this,r=null;if("number"==typeof t)r=t,t=null;else{if("string"==typeof t&&"loaded"===n._state&&!n._sprite[t])return null;if(void 0===t&&(t="__default",!n._playLock)){for(var o=0,a=0;a<n._sounds.length;a++)n._sounds[a]._paused&&!n._sounds[a]._ended&&(o++,r=n._sounds[a]._id);1===o?t=null:r=null}}var s=r?n._soundById(r):n._inactiveSound();if(!s)return null;if(r&&!t&&(t=s._sprite||"__default"),"loaded"!==n._state){s._sprite=t,s._ended=!1;var u=s._id;return n._queue.push({event:"play",action:function(){n.play(u)}}),u}if(r&&!s._paused)return e||n._loadQueue("play"),s._id;n._webAudio&&i._autoResume();var c=Math.max(0,s._seek>0?s._seek:n._sprite[t][0]/1e3),l=Math.max(0,(n._sprite[t][0]+n._sprite[t][1])/1e3-c),f=1e3*l/Math.abs(s._rate),h=n._sprite[t][0]/1e3,p=(n._sprite[t][0]+n._sprite[t][1])/1e3;s._sprite=t,s._ended=!1;var d=function(){s._paused=!1,s._seek=c,s._start=h,s._stop=p,s._loop=!(!s._loop&&!n._sprite[t][2])};if(!(c>=p)){var y=s._node;if(n._webAudio){var m=function(){n._playLock=!1,d(),n._refreshBuffer(s);var t=s._muted||n._muted?0:s._volume;y.gain.setValueAtTime(t,i.ctx.currentTime),s._playStart=i.ctx.currentTime,void 0===y.bufferSource.start?s._loop?y.bufferSource.noteGrainOn(0,c,86400):y.bufferSource.noteGrainOn(0,c,l):s._loop?y.bufferSource.start(0,c,86400):y.bufferSource.start(0,c,l),f!==1/0&&(n._endTimers[s._id]=setTimeout(n._ended.bind(n,s),f)),e||setTimeout((function(){n._emit("play",s._id),n._loadQueue()}),0)};"running"===i.state&&"interrupted"!==i.ctx.state?m():(n._playLock=!0,n.once("resume",m),n._clearTimer(s._id))}else{var v=function(){y.currentTime=c,y.muted=s._muted||n._muted||i._muted||y.muted,y.volume=s._volume*i.volume(),y.playbackRate=s._rate;try{var r=y.play();if(r&&"undefined"!=typeof Promise&&(r instanceof Promise||"function"==typeof r.then)?(n._playLock=!0,d(),r.then((function(){n._playLock=!1,y._unlocked=!0,e?n._loadQueue():n._emit("play",s._id)})).catch((function(){n._playLock=!1,n._emit("playerror",s._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."),s._ended=!0,s._paused=!0}))):e||(n._playLock=!1,d(),n._emit("play",s._id)),y.playbackRate=s._rate,y.paused)return void n._emit("playerror",s._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.");"__default"!==t||s._loop?n._endTimers[s._id]=setTimeout(n._ended.bind(n,s),f):(n._endTimers[s._id]=function(){n._ended(s),y.removeEventListener("ended",n._endTimers[s._id],!1)},y.addEventListener("ended",n._endTimers[s._id],!1))}catch(t){n._emit("playerror",s._id,t)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===y.src&&(y.src=n._src,y.load());var g=window&&window.ejecta||!y.readyState&&i._navigator.isCocoonJS;if(y.readyState>=3||g)v();else{n._playLock=!0,n._state="loading";var b=function(){n._state="loaded",v(),y.removeEventListener(i._canPlayEvent,b,!1)};y.addEventListener(i._canPlayEvent,b,!1),n._clearTimer(s._id)}}return s._id}n._ended(s)},pause:function(t){var e=this;if("loaded"!==e._state||e._playLock)return e._queue.push({event:"pause",action:function(){e.pause(t)}}),e;for(var n=e._getSoundIds(t),r=0;r<n.length;r++){e._clearTimer(n[r]);var o=e._soundById(n[r]);if(o&&!o._paused&&(o._seek=e.seek(n[r]),o._rateSeek=0,o._paused=!0,e._stopFade(n[r]),o._node))if(e._webAudio){if(!o._node.bufferSource)continue;void 0===o._node.bufferSource.stop?o._node.bufferSource.noteOff(0):o._node.bufferSource.stop(0),e._cleanBuffer(o._node)}else isNaN(o._node.duration)&&o._node.duration!==1/0||o._node.pause();arguments[1]||e._emit("pause",o?o._id:null)}return e},stop:function(t,e){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"stop",action:function(){n.stop(t)}}),n;for(var r=n._getSoundIds(t),o=0;o<r.length;o++){n._clearTimer(r[o]);var i=n._soundById(r[o]);i&&(i._seek=i._start||0,i._rateSeek=0,i._paused=!0,i._ended=!0,n._stopFade(r[o]),i._node&&(n._webAudio?i._node.bufferSource&&(void 0===i._node.bufferSource.stop?i._node.bufferSource.noteOff(0):i._node.bufferSource.stop(0),n._cleanBuffer(i._node)):isNaN(i._node.duration)&&i._node.duration!==1/0||(i._node.currentTime=i._start||0,i._node.pause(),i._node.duration===1/0&&n._clearSound(i._node))),e||n._emit("stop",i._id))}return n},mute:function(t,e){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"mute",action:function(){n.mute(t,e)}}),n;if(void 0===e){if("boolean"!=typeof t)return n._muted;n._muted=t}for(var r=n._getSoundIds(e),o=0;o<r.length;o++){var a=n._soundById(r[o]);a&&(a._muted=t,a._interval&&n._stopFade(a._id),n._webAudio&&a._node?a._node.gain.setValueAtTime(t?0:a._volume,i.ctx.currentTime):a._node&&(a._node.muted=!!i._muted||t),n._emit("mute",a._id))}return n},volume:function(){var t,e,n,r=this,o=arguments;if(0===o.length)return r._volume;if(1===o.length||2===o.length&&void 0===o[1]?r._getSoundIds().indexOf(o[0])>=0?e=parseInt(o[0],10):t=parseFloat(o[0]):o.length>=2&&(t=parseFloat(o[0]),e=parseInt(o[1],10)),!(void 0!==t&&t>=0&&t<=1))return(n=e?r._soundById(e):r._sounds[0])?n._volume:0;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,o)}}),r;void 0===e&&(r._volume=t),e=r._getSoundIds(e);for(var a=0;a<e.length;a++)(n=r._soundById(e[a]))&&(n._volume=t,o[2]||r._stopFade(e[a]),r._webAudio&&n._node&&!n._muted?n._node.gain.setValueAtTime(t,i.ctx.currentTime):n._node&&!n._muted&&(n._node.volume=t*i.volume()),r._emit("volume",n._id));return r},fade:function(t,e,n,r){var o=this;if("loaded"!==o._state||o._playLock)return o._queue.push({event:"fade",action:function(){o.fade(t,e,n,r)}}),o;t=Math.min(Math.max(0,parseFloat(t)),1),e=Math.min(Math.max(0,parseFloat(e)),1),n=parseFloat(n),o.volume(t,r);for(var a=o._getSoundIds(r),s=0;s<a.length;s++){var u=o._soundById(a[s]);if(u){if(r||o._stopFade(a[s]),o._webAudio&&!u._muted){var c=i.ctx.currentTime,l=c+n/1e3;u._volume=t,u._node.gain.setValueAtTime(t,c),u._node.gain.linearRampToValueAtTime(e,l)}o._startFadeInterval(u,t,e,n,a[s],void 0===r)}}return o},_startFadeInterval:function(t,e,n,r,o,i){var a=this,s=e,u=n-e,c=Math.abs(u/.01),l=Math.max(4,c>0?r/c:r),f=Date.now();t._fadeTo=n,t._interval=setInterval((function(){var o=(Date.now()-f)/r;f=Date.now(),s+=u*o,s=Math.round(100*s)/100,s=u<0?Math.max(n,s):Math.min(n,s),a._webAudio?t._volume=s:a.volume(s,t._id,!0),i&&(a._volume=s),(n<e&&s<=n||n>e&&s>=n)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,a.volume(n,t._id),a._emit("fade",t._id))}),l)},_stopFade:function(t){var e=this,n=e._soundById(t);return n&&n._interval&&(e._webAudio&&n._node.gain.cancelScheduledValues(i.ctx.currentTime),clearInterval(n._interval),n._interval=null,e.volume(n._fadeTo,t),n._fadeTo=null,e._emit("fade",t)),e},loop:function(){var t,e,n,r=this,o=arguments;if(0===o.length)return r._loop;if(1===o.length){if("boolean"!=typeof o[0])return!!(n=r._soundById(parseInt(o[0],10)))&&n._loop;t=o[0],r._loop=t}else 2===o.length&&(t=o[0],e=parseInt(o[1],10));for(var i=r._getSoundIds(e),a=0;a<i.length;a++)(n=r._soundById(i[a]))&&(n._loop=t,r._webAudio&&n._node&&n._node.bufferSource&&(n._node.bufferSource.loop=t,t&&(n._node.bufferSource.loopStart=n._start||0,n._node.bufferSource.loopEnd=n._stop,r.playing(i[a])&&(r.pause(i[a],!0),r.play(i[a],!0)))));return r},rate:function(){var t,e,n,r=this,o=arguments;if(0===o.length)e=r._sounds[0]._id;else if(1===o.length){r._getSoundIds().indexOf(o[0])>=0?e=parseInt(o[0],10):t=parseFloat(o[0])}else 2===o.length&&(t=parseFloat(o[0]),e=parseInt(o[1],10));if("number"!=typeof t)return(n=r._soundById(e))?n._rate:r._rate;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,o)}}),r;void 0===e&&(r._rate=t),e=r._getSoundIds(e);for(var a=0;a<e.length;a++)if(n=r._soundById(e[a])){r.playing(e[a])&&(n._rateSeek=r.seek(e[a]),n._playStart=r._webAudio?i.ctx.currentTime:n._playStart),n._rate=t,r._webAudio&&n._node&&n._node.bufferSource?n._node.bufferSource.playbackRate.setValueAtTime(t,i.ctx.currentTime):n._node&&(n._node.playbackRate=t);var s=r.seek(e[a]),u=1e3*((r._sprite[n._sprite][0]+r._sprite[n._sprite][1])/1e3-s)/Math.abs(n._rate);!r._endTimers[e[a]]&&n._paused||(r._clearTimer(e[a]),r._endTimers[e[a]]=setTimeout(r._ended.bind(r,n),u)),r._emit("rate",n._id)}return r},seek:function(){var t,e,n=this,r=arguments;if(0===r.length)n._sounds.length&&(e=n._sounds[0]._id);else if(1===r.length){n._getSoundIds().indexOf(r[0])>=0?e=parseInt(r[0],10):n._sounds.length&&(e=n._sounds[0]._id,t=parseFloat(r[0]))}else 2===r.length&&(t=parseFloat(r[0]),e=parseInt(r[1],10));if(void 0===e)return 0;if("number"==typeof t&&("loaded"!==n._state||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,r)}}),n;var o=n._soundById(e);if(o){if(!("number"==typeof t&&t>=0)){if(n._webAudio){var a=n.playing(e)?i.ctx.currentTime-o._playStart:0,s=o._rateSeek?o._rateSeek-o._seek:0;return o._seek+(s+a*Math.abs(o._rate))}return o._node.currentTime}var u=n.playing(e);u&&n.pause(e,!0),o._seek=t,o._ended=!1,n._clearTimer(e),n._webAudio||!o._node||isNaN(o._node.duration)||(o._node.currentTime=t);var c=function(){u&&n.play(e,!0),n._emit("seek",e)};if(u&&!n._webAudio){var l=function(){n._playLock?setTimeout(l,0):c()};setTimeout(l,0)}else c()}return n},playing:function(t){var e=this;if("number"==typeof t){var n=e._soundById(t);return!!n&&!n._paused}for(var r=0;r<e._sounds.length;r++)if(!e._sounds[r]._paused)return!0;return!1},duration:function(t){var e=this,n=e._duration,r=e._soundById(t);return r&&(n=e._sprite[r._sprite][1]/1e3),n},state:function(){return this._state},unload:function(){for(var t=this,e=t._sounds,n=0;n<e.length;n++)e[n]._paused||t.stop(e[n]._id),t._webAudio||(t._clearSound(e[n]._node),e[n]._node.removeEventListener("error",e[n]._errorFn,!1),e[n]._node.removeEventListener(i._canPlayEvent,e[n]._loadFn,!1),e[n]._node.removeEventListener("ended",e[n]._endFn,!1),i._releaseHtml5Audio(e[n]._node)),delete e[n]._node,t._clearTimer(e[n]._id);var r=i._howls.indexOf(t);r>=0&&i._howls.splice(r,1);var o=!0;for(n=0;n<i._howls.length;n++)if(i._howls[n]._src===t._src||t._src.indexOf(i._howls[n]._src)>=0){o=!1;break}return u&&o&&delete u[t._src],i.noAudio=!1,t._state="unloaded",t._sounds=[],t=null,null},on:function(t,e,n,r){var o=this["_on"+t];return"function"==typeof e&&o.push(r?{id:n,fn:e,once:r}:{id:n,fn:e}),this},off:function(t,e,n){var r=this,o=r["_on"+t],i=0;if("number"==typeof e&&(n=e,e=null),e||n)for(i=0;i<o.length;i++){var a=n===o[i].id;if(e===o[i].fn&&a||!e&&a){o.splice(i,1);break}}else if(t)r["_on"+t]=[];else{var s=Object.keys(r);for(i=0;i<s.length;i++)0===s[i].indexOf("_on")&&Array.isArray(r[s[i]])&&(r[s[i]]=[])}return r},once:function(t,e,n){return this.on(t,e,n,1),this},_emit:function(t,e,n){for(var r=this,o=r["_on"+t],i=o.length-1;i>=0;i--)o[i].id&&o[i].id!==e&&"load"!==t||(setTimeout(function(t){t.call(this,e,n)}.bind(r,o[i].fn),0),o[i].once&&r.off(t,o[i].fn,o[i].id));return r._loadQueue(t),r},_loadQueue:function(t){var e=this;if(e._queue.length>0){var n=e._queue[0];n.event===t&&(e._queue.shift(),e._loadQueue()),t||n.action()}return e},_ended:function(t){var e=this,n=t._sprite;if(!e._webAudio&&t._node&&!t._node.paused&&!t._node.ended&&t._node.currentTime<t._stop)return setTimeout(e._ended.bind(e,t),100),e;var r=!(!t._loop&&!e._sprite[n][2]);if(e._emit("end",t._id),!e._webAudio&&r&&e.stop(t._id,!0).play(t._id),e._webAudio&&r){e._emit("play",t._id),t._seek=t._start||0,t._rateSeek=0,t._playStart=i.ctx.currentTime;var o=1e3*(t._stop-t._start)/Math.abs(t._rate);e._endTimers[t._id]=setTimeout(e._ended.bind(e,t),o)}return e._webAudio&&!r&&(t._paused=!0,t._ended=!0,t._seek=t._start||0,t._rateSeek=0,e._clearTimer(t._id),e._cleanBuffer(t._node),i._autoSuspend()),e._webAudio||r||e.stop(t._id,!0),e},_clearTimer:function(t){var e=this;if(e._endTimers[t]){if("function"!=typeof e._endTimers[t])clearTimeout(e._endTimers[t]);else{var n=e._soundById(t);n&&n._node&&n._node.removeEventListener("ended",e._endTimers[t],!1)}delete e._endTimers[t]}return e},_soundById:function(t){for(var e=this,n=0;n<e._sounds.length;n++)if(t===e._sounds[n]._id)return e._sounds[n];return null},_inactiveSound:function(){var t=this;t._drain();for(var e=0;e<t._sounds.length;e++)if(t._sounds[e]._ended)return t._sounds[e].reset();return new s(t)},_drain:function(){var t=this,e=t._pool,n=0,r=0;if(!(t._sounds.length<e)){for(r=0;r<t._sounds.length;r++)t._sounds[r]._ended&&n++;for(r=t._sounds.length-1;r>=0;r--){if(n<=e)return;t._sounds[r]._ended&&(t._webAudio&&t._sounds[r]._node&&t._sounds[r]._node.disconnect(0),t._sounds.splice(r,1),n--)}}},_getSoundIds:function(t){if(void 0===t){for(var e=[],n=0;n<this._sounds.length;n++)e.push(this._sounds[n]._id);return e}return[t]},_refreshBuffer:function(t){return t._node.bufferSource=i.ctx.createBufferSource(),t._node.bufferSource.buffer=u[this._src],t._panner?t._node.bufferSource.connect(t._panner):t._node.bufferSource.connect(t._node),t._node.bufferSource.loop=t._loop,t._loop&&(t._node.bufferSource.loopStart=t._start||0,t._node.bufferSource.loopEnd=t._stop||0),t._node.bufferSource.playbackRate.setValueAtTime(t._rate,i.ctx.currentTime),this},_cleanBuffer:function(t){var e=i._navigator&&i._navigator.vendor.indexOf("Apple")>=0;if(!t.bufferSource)return this;if(i._scratchBuffer&&t.bufferSource&&(t.bufferSource.onended=null,t.bufferSource.disconnect(0),e))try{t.bufferSource.buffer=i._scratchBuffer}catch(t){}return t.bufferSource=null,this},_clearSound:function(t){/MSIE |Trident\//.test(i._navigator&&i._navigator.userAgent)||(t.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(t){this._parent=t,this.init()};s.prototype={init:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++i._counter,e._sounds.push(t),t.create(),t},create:function(){var t=this,e=t._parent,n=i._muted||t._muted||t._parent._muted?0:t._volume;return e._webAudio?(t._node=void 0===i.ctx.createGain?i.ctx.createGainNode():i.ctx.createGain(),t._node.gain.setValueAtTime(n,i.ctx.currentTime),t._node.paused=!0,t._node.connect(i.masterGain)):i.noAudio||(t._node=i._obtainHtml5Audio(),t._errorFn=t._errorListener.bind(t),t._node.addEventListener("error",t._errorFn,!1),t._loadFn=t._loadListener.bind(t),t._node.addEventListener(i._canPlayEvent,t._loadFn,!1),t._endFn=t._endListener.bind(t),t._node.addEventListener("ended",t._endFn,!1),t._node.src=e._src,t._node.preload=!0===e._preload?"auto":e._preload,t._node.volume=n*i.volume(),t._node.load()),t},reset:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._rateSeek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++i._counter,t},_errorListener:function(){var t=this;t._parent._emit("loaderror",t._id,t._node.error?t._node.error.code:0),t._node.removeEventListener("error",t._errorFn,!1)},_loadListener:function(){var t=this,e=t._parent;e._duration=Math.ceil(10*t._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),t._node.removeEventListener(i._canPlayEvent,t._loadFn,!1)},_endListener:function(){var t=this,e=t._parent;e._duration===1/0&&(e._duration=Math.ceil(10*t._node.duration)/10,e._sprite.__default[1]===1/0&&(e._sprite.__default[1]=1e3*e._duration),e._ended(t)),t._node.removeEventListener("ended",t._endFn,!1)}};var u={},c=function(t){var e=t._src;if(u[e])return t._duration=u[e].duration,void h(t);if(/^data:[^;]+;base64,/.test(e)){for(var n=atob(e.split(",")[1]),r=new Uint8Array(n.length),o=0;o<n.length;++o)r[o]=n.charCodeAt(o);f(r.buffer,t)}else{var i=new XMLHttpRequest;i.open(t._xhr.method,e,!0),i.withCredentials=t._xhr.withCredentials,i.responseType="arraybuffer",t._xhr.headers&&Object.keys(t._xhr.headers).forEach((function(e){i.setRequestHeader(e,t._xhr.headers[e])})),i.onload=function(){var e=(i.status+"")[0];"0"===e||"2"===e||"3"===e?f(i.response,t):t._emit("loaderror",null,"Failed loading audio file with status: "+i.status+".")},i.onerror=function(){t._webAudio&&(t._html5=!0,t._webAudio=!1,t._sounds=[],delete u[e],t.load())},l(i)}},l=function(t){try{t.send()}catch(e){t.onerror()}},f=function(t,e){var n=function(){e._emit("loaderror",null,"Decoding audio data failed.")},r=function(t){t&&e._sounds.length>0?(u[e._src]=t,h(e,t)):n()};"undefined"!=typeof Promise&&1===i.ctx.decodeAudioData.length?i.ctx.decodeAudioData(t).then(r).catch(n):i.ctx.decodeAudioData(t,r,n)},h=function(t,e){e&&!t._duration&&(t._duration=e.duration),0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue())},p=function(){if(i.usingWebAudio){try{"undefined"!=typeof AudioContext?i.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?i.ctx=new webkitAudioContext:i.usingWebAudio=!1}catch(t){i.usingWebAudio=!1}i.ctx||(i.usingWebAudio=!1);var t=/iP(hone|od|ad)/.test(i._navigator&&i._navigator.platform),e=i._navigator&&i._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),n=e?parseInt(e[1],10):null;if(t&&n&&n<9){var r=/safari/.test(i._navigator&&i._navigator.userAgent.toLowerCase());i._navigator&&!r&&(i.usingWebAudio=!1)}i.usingWebAudio&&(i.masterGain=void 0===i.ctx.createGain?i.ctx.createGainNode():i.ctx.createGain(),i.masterGain.gain.setValueAtTime(i._muted?0:i._volume,i.ctx.currentTime),i.masterGain.connect(i.ctx.destination)),i._setup()}};void 0===(r=function(){return{Howler:i,Howl:a}}.apply(e,[]))||(t.exports=r),e.Howler=i,e.Howl=a,void 0!==n.g?(n.g.HowlerGlobal=o,n.g.Howler=i,n.g.Howl=a,n.g.Sound=s):"undefined"!=typeof window&&(window.HowlerGlobal=o,window.Howler=i,window.Howl=a,window.Sound=s)}(),
11
- /*!
12
- * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
13
- *
14
- * howler.js v2.2.4
15
- * howlerjs.com
16
- *
17
- * (c) 2013-2020, James Simpson of GoldFire Studios
18
- * goldfirestudios.com
19
- *
20
- * MIT License
21
- */
22
- function(){"use strict";var t;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var n=e._howls.length-1;n>=0;n--)e._howls[n].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,n){var r=this;return r.ctx&&r.ctx.listener?(e="number"!=typeof e?r._pos[1]:e,n="number"!=typeof n?r._pos[2]:n,"number"!=typeof t?r._pos:(r._pos=[t,e,n],void 0!==r.ctx.listener.positionX?(r.ctx.listener.positionX.setTargetAtTime(r._pos[0],Howler.ctx.currentTime,.1),r.ctx.listener.positionY.setTargetAtTime(r._pos[1],Howler.ctx.currentTime,.1),r.ctx.listener.positionZ.setTargetAtTime(r._pos[2],Howler.ctx.currentTime,.1)):r.ctx.listener.setPosition(r._pos[0],r._pos[1],r._pos[2]),r)):r},HowlerGlobal.prototype.orientation=function(t,e,n,r,o,i){var a=this;if(!a.ctx||!a.ctx.listener)return a;var s=a._orientation;return e="number"!=typeof e?s[1]:e,n="number"!=typeof n?s[2]:n,r="number"!=typeof r?s[3]:r,o="number"!=typeof o?s[4]:o,i="number"!=typeof i?s[5]:i,"number"!=typeof t?s:(a._orientation=[t,e,n,r,o,i],void 0!==a.ctx.listener.forwardX?(a.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(i,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(t,e,n,r,o,i),a)},Howl.prototype.init=(t=Howl.prototype.init,function(e){var n=this;return n._orientation=e.orientation||[1,0,0],n._stereo=e.stereo||null,n._pos=e.pos||null,n._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},n._onstereo=e.onstereo?[{fn:e.onstereo}]:[],n._onpos=e.onpos?[{fn:e.onpos}]:[],n._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}),Howl.prototype.stereo=function(t,n){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"stereo",action:function(){r.stereo(t,n)}}),r;var o=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===n){if("number"!=typeof t)return r._stereo;r._stereo=t,r._pos=[t,0,0]}for(var i=r._getSoundIds(n),a=0;a<i.length;a++){var s=r._soundById(i[a]);if(s){if("number"!=typeof t)return s._stereo;s._stereo=t,s._pos=[t,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",s._panner&&s._panner.pan||e(s,o),"spatial"===o?void 0!==s._panner.positionX?(s._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(t,0,0):s._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",s._id)}}return r},Howl.prototype.pos=function(t,n,r,o){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"pos",action:function(){i.pos(t,n,r,o)}}),i;if(n="number"!=typeof n?0:n,r="number"!=typeof r?-.5:r,void 0===o){if("number"!=typeof t)return i._pos;i._pos=[t,n,r]}for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var u=i._soundById(a[s]);if(u){if("number"!=typeof t)return u._pos;u._pos=[t,n,r],u._node&&(u._panner&&!u._panner.pan||e(u,"spatial"),void 0!==u._panner.positionX?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(n,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):u._panner.setPosition(t,n,r)),i._emit("pos",u._id)}}return i},Howl.prototype.orientation=function(t,n,r,o){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"orientation",action:function(){i.orientation(t,n,r,o)}}),i;if(n="number"!=typeof n?i._orientation[1]:n,r="number"!=typeof r?i._orientation[2]:r,void 0===o){if("number"!=typeof t)return i._orientation;i._orientation=[t,n,r]}for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var u=i._soundById(a[s]);if(u){if("number"!=typeof t)return u._orientation;u._orientation=[t,n,r],u._node&&(u._panner||(u._pos||(u._pos=i._pos||[0,0,-.5]),e(u,"spatial")),void 0!==u._panner.orientationX?(u._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(n,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):u._panner.setOrientation(t,n,r)),i._emit("orientation",u._id)}}return i},Howl.prototype.pannerAttr=function(){var t,n,r,o=this,i=arguments;if(!o._webAudio)return o;if(0===i.length)return o._pannerAttr;if(1===i.length){if("object"!=typeof i[0])return(r=o._soundById(parseInt(i[0],10)))?r._pannerAttr:o._pannerAttr;t=i[0],void 0===n&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),o._pannerAttr={coneInnerAngle:void 0!==t.pannerAttr.coneInnerAngle?t.pannerAttr.coneInnerAngle:o._coneInnerAngle,coneOuterAngle:void 0!==t.pannerAttr.coneOuterAngle?t.pannerAttr.coneOuterAngle:o._coneOuterAngle,coneOuterGain:void 0!==t.pannerAttr.coneOuterGain?t.pannerAttr.coneOuterGain:o._coneOuterGain,distanceModel:void 0!==t.pannerAttr.distanceModel?t.pannerAttr.distanceModel:o._distanceModel,maxDistance:void 0!==t.pannerAttr.maxDistance?t.pannerAttr.maxDistance:o._maxDistance,refDistance:void 0!==t.pannerAttr.refDistance?t.pannerAttr.refDistance:o._refDistance,rolloffFactor:void 0!==t.pannerAttr.rolloffFactor?t.pannerAttr.rolloffFactor:o._rolloffFactor,panningModel:void 0!==t.pannerAttr.panningModel?t.pannerAttr.panningModel:o._panningModel})}else 2===i.length&&(t=i[0],n=parseInt(i[1],10));for(var a=o._getSoundIds(n),s=0;s<a.length;s++)if(r=o._soundById(a[s])){var u=r._pannerAttr;u={coneInnerAngle:void 0!==t.coneInnerAngle?t.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:void 0!==t.coneOuterAngle?t.coneOuterAngle:u.coneOuterAngle,coneOuterGain:void 0!==t.coneOuterGain?t.coneOuterGain:u.coneOuterGain,distanceModel:void 0!==t.distanceModel?t.distanceModel:u.distanceModel,maxDistance:void 0!==t.maxDistance?t.maxDistance:u.maxDistance,refDistance:void 0!==t.refDistance?t.refDistance:u.refDistance,rolloffFactor:void 0!==t.rolloffFactor?t.rolloffFactor:u.rolloffFactor,panningModel:void 0!==t.panningModel?t.panningModel:u.panningModel};var c=r._panner;c||(r._pos||(r._pos=o._pos||[0,0,-.5]),e(r,"spatial"),c=r._panner),c.coneInnerAngle=u.coneInnerAngle,c.coneOuterAngle=u.coneOuterAngle,c.coneOuterGain=u.coneOuterGain,c.distanceModel=u.distanceModel,c.maxDistance=u.maxDistance,c.refDistance=u.refDistance,c.rolloffFactor=u.rolloffFactor,c.panningModel=u.panningModel}return o},Sound.prototype.init=function(t){return function(){var e=this,n=e._parent;e._orientation=n._orientation,e._stereo=n._stereo,e._pos=n._pos,e._pannerAttr=n._pannerAttr,t.call(this),e._stereo?n.stereo(e._stereo):e._pos&&n.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,n=e._parent;return e._orientation=n._orientation,e._stereo=n._stereo,e._pos=n._pos,e._pannerAttr=n._pannerAttr,e._stereo?n.stereo(e._stereo):e._pos?n.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,n._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var e=function(t,e){"spatial"===(e=e||"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,void 0!==t._panner.positionX?(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]),void 0!==t._panner.orientationX?(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)}}()},698:(t,e)=>{"use strict";
23
- /**
24
- * @license React
25
- * react-jsx-runtime.production.js
26
- *
27
- * Copyright (c) Meta Platforms, Inc. and affiliates.
28
- *
29
- * This source code is licensed under the MIT license found in the
30
- * LICENSE file in the root directory of this source tree.
31
- */var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(t,e,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==e.key&&(o=""+e.key),"key"in e)for(var i in r={},e)"key"!==i&&(r[i]=e[i]);else r=e;return e=r.ref,{$$typeof:n,type:t,key:o,ref:void 0!==e?e:null,props:r}}e.Fragment=r,e.jsx=o,e.jsxs=o},848:(t,e,n)=>{"use strict";t.exports=n(698)},72:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var i={},a=[],s=0;s<t.length;s++){var u=t[s],c=r.base?u[0]+r.base:u[0],l=i[c]||0,f="".concat(c," ").concat(l);i[c]=l+1;var h=n(f),p={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var d=o(p,r);r.byIndex=s,e.splice(s,0,{identifier:f,updater:d,references:1})}a.push(f)}return a}function o(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var a=0;a<i.length;a++){var s=n(i[a]);e[s].references--}for(var u=r(t,o),c=0;c<i.length;c++){var l=n(i[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}i=u}}},659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},56:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},12:e=>{"use strict";e.exports=t},33:t=>{"use strict";t.exports=e}},r={};function o(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={id:t,exports:{}};return n[t](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nc=void 0;var i={};return(()=>{"use strict";o.r(i),o.d(i,{Align:()=>na,Character:()=>kl,CommonPosition:()=>ta,CommonPositionType:()=>Hi,Condition:()=>ql,Control:()=>Vs,Coord2D:()=>ea,Dialog:()=>fS,Dissolve:()=>qx,ExposedStateType:()=>Dk,FadeIn:()=>e_,Game:()=>IS,GameMenu:()=>jw,GameProviders:()=>jx,GameState:()=>bm,Image:()=>qu,ImageTransition:()=>Bx,Isolated:()=>mw,Item:()=>qw,Lambda:()=>Wl,Layer:()=>hp,LiveGame:()=>Am,Menu:()=>pf,Namespace:()=>Rh,Nametag:()=>oS,Notifications:()=>nS,Page:()=>_w,Pause:()=>xc,Persistent:()=>$h,Player:()=>Ox,Scene:()=>_p,Script:()=>Gp,Sentence:()=>ol,Service:()=>xd,Sound:()=>wu,Stage:()=>Sw,Storable:()=>Dh,Story:()=>Jp,Text:()=>ph,TextTransition:()=>Xf,Texts:()=>Hw,Transform:()=>Ta,Transition:()=>Vf,Video:()=>zd,Word:()=>Oc,b:()=>Zc,c:()=>Kc,i:()=>Qc,useGame:()=>qm,usePreference:()=>bw,useRouter:()=>Bk});var t={};o.r(t),o.d(t,{getFontEmbedCSS:()=>qy,toBlob:()=>Wy,toCanvas:()=>zy,toJpeg:()=>$y,toPixelData:()=>Gy,toPng:()=>Hy,toSvg:()=>Vy});var e={action:"displayable:action",applyTransform:"displayable:applyTransform",applyTransition:"displayable:applyTransition",init:"displayable:init"},n={say:"character:say",action:"character:action",setName:"character:setName"},r={action:"scene:action",init:"scene:init",exit:"scene:exit",jumpTo:"scene:jumpTo",setBackgroundMusic:"scene:setBackgroundMusic",preUnmount:"scene:preUnmount",transitionToScene:"scene:transitionToScene"},a={action:"image:action",setSrc:"image:setSrc",flush:"image:flush",initWearable:"image:initWearable",setAppearance:"image:setAppearance"},s={action:"sound:action",play:"sound:play",stop:"sound:stop",setVolume:"sound:setVolume",setRate:"sound:setRate",pause:"sound:pause",resume:"sound:resume"},u={action:"control:action",do:"control:do",doAsync:"control:doAsync",any:"control:any",all:"control:all",allAsync:"control:allAsync",repeat:"control:repeat",sleep:"control:sleep"},c={action:"text:action",setText:"text:setText",setFontSize:"text:setFontSize"},l={action:"persistent:action",set:"persistent:set",assign:"persistent:assign"},f={action:"layer:action"},h={action:"video:action",show:"video:show",hide:"video:hide",play:"video:play",pause:"video:pause",resume:"video:resume",stop:"video:stop",seek:"video:seek"};function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||O(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e,n){return e=g(e),function(t,e){if(e&&("object"==j(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(e,n||[],g(t).constructor):e.apply(t,n))}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function m(t,e,n,r){var o=v(g(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},v.apply(null,arguments)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function w(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */w=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),s=new I(r||[]);return o(a,"_invoke",{value:O(t,n,s)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",m={};function v(){}function g(){}function b(){}var S={};c(S,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(R([])));x&&x!==n&&r.call(x,a)&&(S=x);var _=b.prototype=v.prototype=Object.create(S);function A(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==j(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,n,r){var o=h;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var u=E(s,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var c=f(e,n,r);if("normal"===c.type){if(o=r.done?y:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=y,r.method="throw",r.arg=c.arg)}}}function E(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,E(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=f(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(j(e)+" is not iterable")}return g.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},A(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new T(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},A(_),c(_,u,"Generator"),c(_,a,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return s.type="throw",s.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;C(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function S(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=O(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function k(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function x(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,A(r.key),r)}}function _(t,e,n){return e&&x(t.prototype,e),n&&x(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){var e=function(t,e){if("object"!=j(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=j(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==j(e)?e:e+""}function T(t){return function(t){if(Array.isArray(t))return E(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||O(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t,e){if(t){if("string"==typeof t)return E(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function j(t){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},j(t)}var P,C,I=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))};(C=P||(P={}))[C.string=0]="string",C[C.number=1]="number",C[C.boolean=2]="boolean",C[C.object=3]="object",C[C.array=4]="array",C[C.function=5]="function",C[C.symbol=6]="symbol",C[C[void 0]=7]="undefined",C[C.null=8]="null",C[C.date=9]="date",C[C.regexp=10]="regexp",C[C.other=11]="other";var R=function(t){return"string"==typeof t?P.string:"number"==typeof t?P.number:"boolean"==typeof t?P.boolean:"object"===j(t)?Array.isArray(t)?P.array:null===t?P.null:t instanceof Date?P.date:t instanceof RegExp?P.regexp:P.object:"function"==typeof t?P.function:"symbol"===j(t)?P.symbol:void 0===t?P.undefined:P.other};function D(t,e){var n,r,o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i={};for(var a in t)o(t,a)&&(i[a]=(n=t[a],r=e[a],R(n)===P.object&&R(r)===P.object?n.constructor!==Object||r.constructor!==Object?r||n:D(n,r):Array.isArray(n)&&Array.isArray(r)?r&&r.length>0?T(r):T(n):void 0===n&&Array.isArray(r)?T(r):void 0===r?Array.isArray(n)?T(n):n:Array.isArray(r)?T(r):r));for(var s in e)o(e,s)&&!o(i,s)&&("object"===j(e[s])&&null!==e[s]?e[s].constructor===Object?i[s]=D({},e[s]):Array.isArray(e[s])?i[s]=T(e[s]):i[s]=e[s]:i[s]=e[s]);for(var u=arguments.length,c=new Array(u>2?u-2:0),l=2;l<u;l++)c[l-2]=arguments[l];if(c.length){var f=c[0],h=c.slice(1);return D.apply(void 0,[i,f].concat(T(h)))}return i}R.DataTypes=P;var L=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t){return t},n=arguments.length>1?arguments[1]:void 0;k(this,t),this.solved=!1,this.aborted=!1,this.listeners=[],this.onRegisterSkipController=[],this.receiver=e,this.skipController=n,this.__stack=B()}return _(t,[{key:"registerSkipController",value:function(t){this.skipController=t;var e,n=S(this.onRegisterSkipController);try{for(n.s();!(e=n.n()).done;){(0,e.value)(t)}}catch(t){n.e(t)}finally{n.f()}return this}},{key:"resolve",value:function(t){if(!this.solved){this.result=this.receiver(t),this.solved=!0,this.skipController&&this.skipController.cancel();var e,n=S(this.listeners);try{for(n.s();!(e=n.n()).done;){(0,e.value)(this.result)}}catch(t){n.e(t)}finally{n.f()}}}},{key:"then",value:function(t){return this.solved?t(this.result):this.listeners.push(t),this}},{key:"onSettled",value:function(t){return this.solved?t():(this.listeners.push(t),this.onSkipControllerRegister((function(e){e.onAbort((function(){t()}))}))),this}},{key:"onSkipControllerRegister",value:function(t){return this.skipController?t(this.skipController):this.onRegisterSkipController.push(t),this}},{key:"abort",value:function(){return this.aborted=!0,this.skipController?this.skipController.abort():this.result}},{key:"isSolved",value:function(){return this.solved&&!this.aborted}},{key:"isAborted",value:function(){return this.aborted}},{key:"isSettled",value:function(){return this.solved||this.aborted}}],[{key:"isAwaitable",value:function(e){return e instanceof t}},{key:"fromPromise",value:function(e){var n=new t;return e.then((function(t){return n.resolve(t)})),n}},{key:"resolve",value:function(e){var n=new t;return n.resolve(e),n}},{key:"delay",value:function(e){var n=new t;return setTimeout((function(){return n.resolve()}),e),n}},{key:"forward",value:function(e,n,r){var o,i,a=(new t).registerSkipController(r||new z((function(){return n})));e.then((function(){return a.resolve(n)}));var s=null===(o=e.skipController)||void 0===o?void 0:o.onAbort((function(){var t;null===(t=a.skipController)||void 0===t||t.abort(),null==s||s.cancel(),null==u||u.cancel()})),u=null===(i=a.skipController)||void 0===i?void 0:i.onAbort((function(){var t;null===(t=e.skipController)||void 0===t||t.abort(),null==s||s.cancel(),null==u||u.cancel()}));return a}}])}();function M(t){var e=new WeakSet;return function t(n){if(null===n||"object"!==j(n))return n;if(!e.has(n)){if(e.add(n),Array.isArray(n)){var r,o=[],i=S(n);try{for(i.s();!(r=i.n()).done;){var a=r.value;o.push(t(a))}}catch(t){i.e(t)}finally{i.f()}return o}var s={};for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(s[u]=t(n[u]));return s}}(t)}function N(t){return"string"==typeof t?t:"#".concat((t.r||0).toString(16).padStart(2,"0")).concat((t.g||0).toString(16).padStart(2,"0")).concat((t.b||0).toString(16).padStart(2,"0")).concat(void 0===t.a?"":t.a.toString(16).padStart(2,"0"))}L.nothing=function(t){return t};var F=function(){return _((function t(){k(this,t),this.events={},this.maxListeners=10}),[{key:"on",value:function(t,e){var n=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(e),this.events[t].length>this.maxListeners&&console.warn("NarraLeaf-React: Event ".concat(t," has more than ").concat(this.maxListeners," listeners (total: ").concat(this.events[t].length,"), this may cause performance issues.")),this.emit("event:EventDispatcher.register",t,e),{type:t,listener:e,cancel:function(){n.off(t,e)}}}},{key:"depends",value:function(t){return{cancel:function(){t.forEach((function(t){return t.cancel()}))}}}},{key:"off",value:function(t,e){this.events[t]&&(this.events[t]=this.events[t].filter((function(t){return t!==e})))}},{key:"emit",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.events[t]&&this.events[t].forEach((function(t){t.apply(void 0,n)}))}},{key:"once",value:function(t,e){var n=this,r=function(){e.apply(void 0,arguments),n.off(t,r)};return this.on(t,r)}},{key:"any",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return I(this,void 0,void 0,w().mark((function e(){var r=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.events[t]||(this.events[t]=[]),!(this.events[t].length>0)){e.next=5;break}return e.next=4,Promise.all(this.events[t].map((function(t){return t.apply(void 0,n)})));case 4:return e.abrupt("return");case 5:return e.abrupt("return",new Promise((function(e){var o="event:EventDispatcher.register",i=r.on(o,(function(a,s){if(a===t){r.off(o,i);var u=null==s?void 0:s.apply(void 0,n);null!==u&&"object"===j(u)&&u.then?u.then(e):e(u)}})).listener})));case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setMaxListeners",value:function(t){return this.maxListeners=t,this}},{key:"clear",value:function(){this.events={}}}])}();function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=(new Error).stack;return e?e.split("\n").slice(t+1).join("\n").trim():""}function U(t){return new Promise((function(e){return setTimeout(e,t)}))}function V(t,e){if(t===e)return!0;if("object"!==j(t)||"object"!==j(e)||null===t||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var o=0,i=n;o<i.length;o++){var a=i[o];if(!r.includes(a)||!V(t[a],e[a]))return!1}return!0}var z=function(){function t(e){k(this,t),this.abortHandler=e,this.events=new F,this.aborted=!1}return _(t,[{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.abortHandler.apply(this,arguments),this.events.emit(t.EventTypes["event:skipController.abort"]))}},{key:"isAborted",value:function(){return this.aborted}},{key:"cancel",value:function(){this.aborted=!0}},{key:"onAbort",value:function(t){return this.events.on("event:skipController.abort",t)}}])}();z.EventTypes={"event:skipController.abort":"event:skipController.abort"};var G=function(){return _((function t(){k(this,t),this.locked=!1,this.listeners=[],this.unlockListeners=[]}),[{key:"lock",value:function(){return this.locked=!0,this}},{key:"unlock",value:function(){this.locked=!1;var t,e=S(this.listeners);try{for(e.s();!(t=e.n()).done;){(0,t.value)()}}catch(t){e.e(t)}finally{e.f()}var n,r=S(this.unlockListeners);try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(t){r.e(t)}finally{r.f()}return this.listeners=[],this}},{key:"onUnlock",value:function(t){return this.unlockListeners.push(t),t}},{key:"offUnlock",value:function(t){this.unlockListeners=this.unlockListeners.filter((function(e){return e!==t}))}},{key:"nextUnlock",value:function(){return I(this,void 0,void 0,w().mark((function t(){var e=this;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.locked){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",new Promise((function(t){e.listeners.push(t)})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"isLocked",value:function(){return this.locked}}])}(),H=function(){return _((function t(){k(this,t),this.locks=[]}),[{key:"unlock",value:function(t){return t.unlock(),this.off(t),t}},{key:"register",value:function(t){var e=t||new G;return this.locks.push(e),e}},{key:"off",value:function(t){this.locks=this.locks.filter((function(e){return e!==t}))}},{key:"nextUnlock",value:function(){return I(this,void 0,void 0,w().mark((function t(){var e;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.locks.map((function(t){return t.nextUnlock()})),t.abrupt("return",Promise.all(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"isLocked",value:function(){return this.locks.some((function(t){return t.isLocked()}))}}])}();function $(t,e){return t?e:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}}var W=function(){return _((function t(){k(this,t),this.taskToken=null}),[{key:"scheduleTask",value:function(t,e){this.taskToken&&this.taskToken.cancel();var n=!1,r=setTimeout((function(){n||t()}),e);return this.taskToken={cancel:function(){clearTimeout(r),n=!0},isCancelled:function(){return n}},this.taskToken}},{key:"cancelTask",value:function(){return this.taskToken&&(this.taskToken.cancel(),this.taskToken=null),this}}])}();var q=function(){return _((function t(e,n){k(this,t),this.concurrency=e,this.delay=n,this.tasks=[]}),[{key:"addTask",value:function(t){this.tasks.push(t)}},{key:"start",value:function(){return I(this,void 0,void 0,w().mark((function t(){var e,n=this;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){return I(n,void 0,void 0,w().mark((function t(){var n;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==this.tasks.length){t.next=2;break}return t.abrupt("return");case 2:return n=this.tasks.splice(0,this.concurrency),t.next=5,Promise.all(n.map((function(t){return t()})));case 5:return t.next=7,U(this.delay);case 7:return t.next=9,e();case 9:case"end":return t.stop()}}),t,this)})))},t.next=3,e();case 3:case"end":return t.stop()}}),t)})))}}])}();function Y(t){var e,n=Promise.resolve().then((function(){e=t()}));return function(){n.then((function(){e&&e()}))}}var X=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k(this,t),this.serializer=e,this.deserializer=n}return _(t,[{key:"serialize",value:function(t){for(var e,n,r={},o=0,i=Object.keys(t);o<i.length;o++){var a=i[o];a in this.serializer&&void 0!==t[a]?r[a]=null===(n=(e=this.serializer)[a])||void 0===n?void 0:n.call(e,t[a]):r[a]=t[a]}return r}},{key:"deserialize",value:function(t){for(var e={},n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];"function"==typeof this.deserializer[o]&&void 0!==t[o]?e[o]=this.deserializer[o](t[o]):e[o]=t[o]}return e}},{key:"extend",value:function(e,n){return new t(Object.assign(Object.assign({},this.serializer),e),Object.assign(Object.assign({},this.deserializer),n))}}])}();var K=function(t){function e(t){var n;return k(this,e),(n=d(this,e)).tasks=[],t&&n.registerSkipController(t),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(e,t),_(e,[{key:"addTask",value:function(t){return t?(this.tasks.push(t),this):this}},{key:"abort",value:function(){this.current&&this.current.abort(),this.tasks.forEach((function(t){var e=p(t,2),n=(e[0],e[1]);n&&n.abort()})),m(e,"abort",this,3)([])}},{key:"resolve",value:function(){}},{key:"run",value:function(){return this.current||this.onTaskComplete(),this}},{key:"onTaskComplete",value:function(){var t=this;if(0!==this.tasks.length){var n=p(this.tasks.shift(),2),r=n[0],o=n[1],i=new L(L.nothing,o);this.current=i,this.current.then((function(){return t.onTaskComplete()})),r(i)}else m(e,"resolve",this,3)([])}}])}(L);function Z(t){var e={};for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}function Q(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakSet;if(null===t||"object"!==j(t))return!1;if(Array.isArray(t)||t instanceof Date||t instanceof RegExp)return!1;if(Object.getPrototypeOf(t)!==Object.prototype)return!1;if(e.has(t))return!1;for(var n in e.add(t),t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];if(null!==r&&"object"===j(r)&&!Q(r,e))return!1;if("function"==typeof r||"symbol"===j(r))return!1}return!0}var J=function(){return _((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";k(this,t),this.prefix=e,this.counter=0}),[{key:"next",value:function(){return"".concat(this.prefix?this.prefix+"-":"").concat(this.counter++)}}])}();function tt(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",n="",r=0;r<t;r++)n+=e[Math.floor(62*Math.random())];return n}var et=function(){return _((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";k(this,t),this.prefix=e,this.counter=0}),[{key:"generateId",value:function(){return"".concat(this.prefix?this.prefix+"-":"").concat(this.counter++)}}])}(),nt=function(){return _((function t(){k(this,t),this.hooks={}}),[{key:"hook",value:function(t,e){var n=this;return this.hooks[t]=this.hooks[t]||[],this.hooks[t].push(e),{cancel:function(){return n.unhook(t,e)}}}},{key:"unhook",value:function(t,e){var n;this.hooks[t]=(null===(n=this.hooks[t])||void 0===n?void 0:n.filter((function(t){return t!==e})))||[]}},{key:"trigger",value:function(t,e){var n=this.hooks[t];if(!n)return function(){};var r=n.map((function(t){return t.apply(void 0,T(e))}));return function(){r.forEach((function(t){return t&&t()}))}}},{key:"rawTrigger",value:function(t,e){var n=this.hooks[t];if(!n)return function(){};var r=n.map((function(t){return t.apply(void 0,T(e()))}));return function(){r.forEach((function(t){return t&&t()}))}}}])}();function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function ot(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,it(r.key),r)}}function it(t){var e=function(t,e){if("object"!=rt(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==rt(e)?e:e+""}var at=function(){return t=function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.callee=e,this.type=n,this.contentNode=r,this.__stack=B(),this._id=""},(e=[{key:"executeAction",value:function(t){return{type:this.type,node:this.contentNode.getChild()}}},{key:"getId",value:function(){return this._id}},{key:"setId",value:function(t){this._id=t}},{key:"setContent",value:function(t){return this.contentNode.setContent(t),this}},{key:"setContentNode",value:function(t){return this.contentNode=t,this}},{key:"getFutureActions",value:function(t,e){var n=this.contentNode.getChild();return n&&n.action?[n.action]:[]}}])&&ot(t.prototype,e),n&&ot(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function ut(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ut=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),s=new P(r||[]);return o(a,"_invoke",{value:T(t,n,s)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};c(w,a,(function(){return this}));var S=Object.getPrototypeOf,k=S&&S(S(C([])));k&&k!==n&&r.call(k,a)&&(w=k);var x=b.prototype=v.prototype=Object.create(w);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==st(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function T(e,n,r){var o=h;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var u=O(s,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var c=f(e,n,r);if("normal"===c.type){if(o=r.done?y:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=y,r.method="throw",r.arg=c.arg)}}}function O(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,O(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=f(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function C(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(st(e)+" is not iterable")}return g.prototype=b,o(x,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(x),t},e.awrap=function(t){return{__await:t}},_(A.prototype),c(A.prototype,s,(function(){return this})),e.AsyncIterator=A,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new A(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(x),c(x,u,"Generator"),c(x,a,(function(){return this})),c(x,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return s.type="throw",s.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function ct(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,lt(r.key),r)}}function lt(t){var e=function(t,e){if("object"!=st(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=st(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==st(e)?e:e+""}function ft(t,e,n){return e=pt(e),function(t,e){if(e&&("object"==st(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ht()?Reflect.construct(e,n||[],pt(t).constructor):e.apply(t,n))}function ht(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ht=function(){return!!t})()}function pt(t){return pt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pt(t)}function dt(t,e){return dt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},dt(t,e)}at.ActionTypes={action:"action"};var yt,mt,vt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},gt=function(t){function e(t,n,r){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(o=ft(this,e,[t,n,r])).callee=t.getSelf(),o.contentNode.action=o,o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&dt(t,e)}(e,t),n=e,(r=[{key:"unknownTypeError",value:function(){throw new Error("Unknown action type: "+this.type)}},{key:"resolveAwaitable",value:function(t,e){var n=this,r=e||new L((function(t){return t}));return vt(n,void 0,void 0,ut().mark((function e(){return ut().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t(r.resolve.bind(r),r);case 2:case"end":return e.stop()}}),e)}))),r}},{key:"is",value:function(t,e){return this instanceof t&&this.type===e}}])&&ct(n.prototype,r),o&&ct(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(at);function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e,n){return e=kt(e),function(t,e){if(e&&("object"==bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,St()?Reflect.construct(e,n||[],kt(t).constructor):e.apply(t,n))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=function(){return!!t})()}function kt(t){return kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},kt(t)}function xt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_t(t,e)}function _t(t,e){return _t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_t(t,e)}function At(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Tt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Et(r.key),r)}}function Ot(t,e,n){return e&&Tt(t.prototype,e),n&&Tt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Et(t){var e=function(t,e){if("object"!=bt(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=bt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==bt(e)?e:e+""}(mt=yt||(yt={})).TreeNode="TreeNode",mt.ContentNode="ContentNode";var jt=function(t){function e(t,n,r){var o;return At(this,e),(o=wt(this,e,[yt.ContentNode])).child=r||null,o.parent=n||null,o.action=t||null,o}return xt(e,t),Ot(e,[{key:"setParent",value:function(t){if(t===this)throw new Error("Cannot set parent to itself");return this.parent=t,this}},{key:"setChild",value:function(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}},{key:"getChild",value:function(){return this.child||null}},{key:"getParent",value:function(){return this.parent||null}},{key:"addChild",value:function(t){return this.setChild(t),this}},{key:"removeChild",value:function(t){return t&&this.child===t?(this.child=null,t.setParent(null)):t||(this.child=null),this}},{key:"remove",value:function(){var t;return null===(t=this.parent)||void 0===t||t.removeChild(this),this}},{key:"hasChild",value:function(){return!!this.child}}],[{key:"create",value:function(t){return(new e).setContent(t)}},{key:"forEachParent",value:function(t,e){for(var n=new Set,r=t;r&&!n.has(r);)n.add(r),e(r),r=r.getParent()}},{key:"forEachChild",value:function(t,e){for(var n=new Set,r=t;r&&!n.has(r);)n.add(r),e(r),r=r.getChild()}}])}(function(){return Ot((function t(e){At(this,t),this.type=e,this.content=void 0}),[{key:"setContent",value:function(t){return this.content=t,this}},{key:"getContent",value:function(){return this.content}}])}()),Pt="center",Ct="left",It="right";function Rt(t){let e;return()=>(void 0===e&&(e=t()),e)}const Dt=Rt((()=>void 0!==window.ScrollTimeline));class Lt{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,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const n=this.animations.map((n=>Dt()&&n.attachTimeline?n.attachTimeline(t):"function"==typeof e?e(n):void 0));return()=>{n.forEach(((t,e)=>{t&&t(),this.animations[e].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 e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach((e=>e[t]()))}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Mt extends Lt{then(t,e){return Promise.all(this.animations).then(t).catch(e)}}const Nt=t=>1e3*t,Ft=t=>t/1e3,Bt=2e4;function Ut(t){let e=0;let n=t.next(e);for(;!n.done&&e<Bt;)e+=50,n=t.next(e);return e>=Bt?1/0:e}const Vt=(t,e,n)=>{const r=e-t;return 0===r?1:(n-t)/r},zt=(t,e,n=10)=>{let r="";const o=Math.max(Math.round(e/n),2);for(let e=0;e<o;e++)r+=t(Vt(0,o-1,e))+", ";return`linear(${r.substring(0,r.length-2)})`},Gt=(t,e,n)=>n>e?e:n<t?t:n;function Ht(t,e){return e?t*(1e3/e):0}function $t(t,e,n){const r=Math.max(e-5,0);return Ht(n-t(r),e-r)}const Wt=100,qt=10,Yt=1,Xt=0,Kt=800,Zt=.3,Qt=.3,Jt={granular:.01,default:2},te={granular:.005,default:.5},ee=.01,ne=10,re=.05,oe=1,ie=t=>t;let ae=ie,se=ie;const ue=.001;function ce({duration:t=Kt,bounce:e=Zt,velocity:n=Xt,mass:r=Yt}){let o,i;ae(t<=Nt(ne),"Spring duration must be 10 seconds or less");let a=1-e;a=Gt(re,oe,a),t=Gt(ee,ne,Ft(t)),a<1?(o=e=>{const r=e*a,o=r*t,i=r-n,s=fe(e,a),u=Math.exp(-o);return ue-i/s*u},i=e=>{const r=e*a*t,i=r*n+n,s=Math.pow(a,2)*Math.pow(e,2)*t,u=Math.exp(-r),c=fe(Math.pow(e,2),a);return(-o(e)+ue>0?-1:1)*((i-s)*u)/c}):(o=e=>Math.exp(-e*t)*((e-n)*t+1)-.001,i=e=>Math.exp(-e*t)*(t*t*(n-e)));const s=function(t,e,n){let r=n;for(let n=1;n<le;n++)r-=t(r)/e(r);return r}(o,i,5/t);if(t=Nt(t),isNaN(s))return{stiffness:Wt,damping:qt,duration:t};{const e=Math.pow(s,2)*r;return{stiffness:e,damping:2*a*Math.sqrt(r*e),duration:t}}}const le=12;function fe(t,e){return t*Math.sqrt(1-e*e)}const he=["duration","bounce"],pe=["stiffness","damping","mass"];function de(t,e){return e.some((e=>void 0!==t[e]))}function ye(t=Qt,e=Zt){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:o}=n;const i=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],s={done:!1,value:i},{stiffness:u,damping:c,mass:l,duration:f,velocity:h,isResolvedFromDuration:p}=function(t){let e={velocity:Xt,stiffness:Wt,damping:qt,mass:Yt,isResolvedFromDuration:!1,...t};if(!de(t,pe)&&de(t,he))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(1.2*n),o=r*r,i=2*Gt(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:Yt,stiffness:o,damping:i}}else{const n=ce(t);e={...e,...n,mass:Yt},e.isResolvedFromDuration=!0}return e}({...n,velocity:-Ft(n.velocity||0)}),d=h||0,y=c/(2*Math.sqrt(u*l)),m=a-i,v=Ft(Math.sqrt(u/l)),g=Math.abs(m)<5;let b;if(r||(r=g?Jt.granular:Jt.default),o||(o=g?te.granular:te.default),y<1){const t=fe(v,y);b=e=>{const n=Math.exp(-y*v*e);return a-n*((d+y*v*m)/t*Math.sin(t*e)+m*Math.cos(t*e))}}else if(1===y)b=t=>a-Math.exp(-v*t)*(m+(d+v*m)*t);else{const t=v*Math.sqrt(y*y-1);b=e=>{const n=Math.exp(-y*v*e),r=Math.min(t*e,300);return a-n*((d+y*v*m)*Math.sinh(r)+t*m*Math.cosh(r))/t}}const w={calculatedDuration:p&&f||null,next:t=>{const e=b(t);if(p)s.done=t>=f;else{let n=0;y<1&&(n=0===t?Nt(d):$t(b,t,e));const i=Math.abs(n)<=r,u=Math.abs(a-e)<=o;s.done=i&&u}return s.value=s.done?a:e,s},toString:()=>{const t=Math.min(Ut(w),Bt),e=zt((e=>w.next(t*e).value),t,30);return t+"ms "+e}};return w}function me(t,e=100,n){const r=n({...t,keyframes:[0,e]}),o=Math.min(Ut(r),Bt);return{type:"keyframes",ease:t=>r.next(o*t).value/e,duration:Ft(o)}}function ve(t){return"function"==typeof t}const ge=t=>Array.isArray(t)&&"number"!=typeof t[0];function be(t,e){return ge(t)?t[((t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t})(0,t.length,e)]:t}const we=(t,e,n)=>t+(e-t)*n;function Se(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const o=Vt(0,e,r);t.push(we(n,1,o))}}function ke(t){const e=[0];return Se(e,t.length-1),e}const xe=t=>Boolean(t&&t.getVelocity);function _e(t,e,n){var r;if(t instanceof Element)return[t];if("string"==typeof t){let o=document;e&&(o=e.current);const i=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:o.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}function Ae(t){return"object"==typeof t&&!Array.isArray(t)}function Te(t,e,n,r){return"string"==typeof t&&Ae(e)?_e(t,n,r):t instanceof NodeList?Array.from(t):Array.isArray(t)?t:[t]}function Oe(t,e,n){return t*(e+1)}function Ee(t,e,n,r){var o;return"number"==typeof e?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(o=r.get(e))&&void 0!==o?o:t}function je(t,e){-1===t.indexOf(e)&&t.push(e)}function Pe(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}function Ce(t,e,n,r,o,i){!function(t,e,n){for(let r=0;r<t.length;r++){const o=t[r];o.at>e&&o.at<n&&(Pe(t,o),r--)}}(t,o,i);for(let a=0;a<e.length;a++)t.push({value:e[a],at:we(o,i,r[a]),easing:be(n,a)})}function Ie(t,e){for(let n=0;n<t.length;n++)t[n]=t[n]/(e+1)}function Re(t,e){return t.at===e.at?null===t.value?1:null===e.value?-1:0:t.at-e.at}function De(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function Le(t,e){return e[t]||(e[t]=[]),e[t]}function Me(t){return Array.isArray(t)?t:[t]}function Ne(t,e){return t&&t[e]?{...t,...t[e]}:{...t}}const Fe=t=>"number"==typeof t,Be=t=>t.every(Fe),Ue=new WeakMap;function Ve(t,e){return t?t[e]||t.default||t:void 0}const ze=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ge=new Set(ze),He=new Set(["width","height","top","left","right","bottom",...ze]),$e=t=>Array.isArray(t),We=!1,qe=!1;const Ye=["read","resolveKeyframes","update","preRender","render","postRender"];function Xe(t,e){let n=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,a=Ye.reduce(((t,e)=>(t[e]=function(t){let e=new Set,n=new Set,r=!1,o=!1;const i=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function s(e){i.has(e)&&(u.schedule(e),t()),e(a)}const u={schedule:(t,o=!1,a=!1)=>{const s=a&&r?e:n;return o&&i.add(t),s.has(t)||s.add(t),t},cancel:t=>{n.delete(t),i.delete(t)},process:t=>{a=t,r?o=!0:(r=!0,[e,n]=[n,e],e.forEach(s),e.clear(),r=!1,o&&(o=!1,u.process(t)))}};return u}(i),t)),{}),{read:s,resolveKeyframes:u,update:c,preRender:l,render:f,postRender:h}=a,p=()=>{const i=qe?o.timestamp:performance.now();n=!1,o.delta=r?1e3/60:Math.max(Math.min(i-o.timestamp,40),1),o.timestamp=i,o.isProcessing=!0,s.process(o),u.process(o),c.process(o),l.process(o),f.process(o),h.process(o),o.isProcessing=!1,n&&e&&(r=!1,t(p))};return{schedule:Ye.reduce(((e,i)=>{const s=a[i];return e[i]=(e,i=!1,a=!1)=>(n||(n=!0,r=!0,o.isProcessing||t(p)),s.schedule(e,i,a)),e}),{}),cancel:t=>{for(let e=0;e<Ye.length;e++)a[Ye[e]].cancel(t)},state:o,steps:a}}const{schedule:Ke,cancel:Ze,state:Qe,steps:Je}=Xe("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:ie,!0);let tn;function en(){tn=void 0}const nn={now:()=>(void 0===tn&&nn.set(Qe.isProcessing||qe?Qe.timestamp:performance.now()),tn),set:t=>{tn=t,queueMicrotask(en)}};class rn{constructor(){this.subscriptions=[]}add(t){return je(this.subscriptions,t),()=>Pe(this.subscriptions,t)}notify(t,e,n){const r=this.subscriptions.length;if(r)if(1===r)this.subscriptions[0](t,e,n);else for(let o=0;o<r;o++){const r=this.subscriptions[o];r&&r(t,e,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const on={current:void 0};class an{constructor(t,e={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const n=nn.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),e&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=nn.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){this.events[t]||(this.events[t]=new rn);const n=this.events[t].add(e);return"change"===t?()=>{n(),Ke.read((()=>{this.events.change.getSize()||this.stop()}))}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,n){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return on.current&&on.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=nn.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return Ht(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise((e=>{this.hasAnimated=!0,this.animation=t(e),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 sn(t,e){return new an(t,e)}function un(t){const e=[{},{}];return null==t||t.values.forEach(((t,n)=>{e[0][n]=t.get(),e[1][n]=t.getVelocity()})),e}function cn(t,e,n,r){if("function"==typeof e){const[o,i]=un(r);e=e(void 0!==n?n:t.custom,o,i)}if("string"==typeof e&&(e=t.variants&&t.variants[e]),"function"==typeof e){const[o,i]=un(r);e=e(void 0!==n?n:t.custom,o,i)}return e}function ln(t,e,n){const r=t.getProps();return cn(r,e,void 0!==n?n:r.custom,t)}function fn(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,sn(n))}function hn(t,e){const n=t.getValue("willChange");if(r=n,Boolean(xe(r)&&r.add))return n.add(e);var r}const pn=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),dn="data-"+pn("framerAppearId");function yn(t){return t.props[dn]}const mn=!1;function vn(t,e){t.timeline=e,t.onfinish=null}const gn=t=>Array.isArray(t)&&"number"==typeof t[0],bn={linearEasing:void 0};function wn(t,e){const n=Rt(t);return()=>{var t;return null!==(t=bn[e])&&void 0!==t?t:n()}}const Sn=wn((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing");function kn(t){return Boolean("function"==typeof t&&Sn()||!t||"string"==typeof t&&(t in _n||Sn())||gn(t)||Array.isArray(t)&&t.every(kn))}const xn=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,_n={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xn([0,.65,.55,1]),circOut:xn([.55,0,1,.45]),backIn:xn([.31,.01,.66,-.59]),backOut:xn([.33,1.53,.69,.99])};function An(t,e){return t?"function"==typeof t&&Sn()?zt(t,e):gn(t)?xn(t):Array.isArray(t)?t.map((t=>An(t,e)||_n.easeOut)):_n[t]:void 0}const Tn=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function On(t,e,n,r){if(t===e&&n===r)return ie;const o=e=>function(t,e,n,r,o){let i,a,s=0;do{a=e+(n-e)/2,i=Tn(a,r,o)-t,i>0?n=a:e=a}while(Math.abs(i)>1e-7&&++s<12);return a}(e,0,1,t,n);return t=>0===t||1===t?t:Tn(o(t),e,r)}const En=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,jn=t=>e=>1-t(1-e),Pn=On(.33,1.53,.69,.99),Cn=jn(Pn),In=En(Cn),Rn=t=>(t*=2)<1?.5*Cn(t):.5*(2-Math.pow(2,-10*(t-1))),Dn=t=>1-Math.sin(Math.acos(t)),Ln=jn(Dn),Mn=En(Dn),Nn=t=>/^0[^.\s]+$/u.test(t);const Fn={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},Bn={...Fn,transform:t=>Gt(0,1,t)},Un={...Fn,default:1},Vn=t=>Math.round(1e5*t)/1e5,zn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Gn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Hn=(t,e)=>n=>Boolean("string"==typeof n&&Gn.test(n)&&n.startsWith(t)||e&&!function(t){return null==t}(n)&&Object.prototype.hasOwnProperty.call(n,e)),$n=(t,e,n)=>r=>{if("string"!=typeof r)return r;const[o,i,a,s]=r.match(zn);return{[t]:parseFloat(o),[e]:parseFloat(i),[n]:parseFloat(a),alpha:void 0!==s?parseFloat(s):1}},Wn={...Fn,transform:t=>Math.round((t=>Gt(0,255,t))(t))},qn={test:Hn("rgb","red"),parse:$n("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Wn.transform(t)+", "+Wn.transform(e)+", "+Wn.transform(n)+", "+Vn(Bn.transform(r))+")"};const Yn={test:Hn("#"),parse:function(t){let e="",n="",r="",o="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),o=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),o=t.substring(4,5),e+=e,n+=n,r+=r,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}},transform:qn.transform},Xn=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),Kn=Xn("deg"),Zn=Xn("%"),Qn=Xn("px"),Jn=Xn("vh"),tr=Xn("vw"),er={...Zn,parse:t=>Zn.parse(t)/100,transform:t=>Zn.transform(100*t)},nr={test:Hn("hsl","hue"),parse:$n("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+Zn.transform(Vn(e))+", "+Zn.transform(Vn(n))+", "+Vn(Bn.transform(r))+")"},rr={test:t=>qn.test(t)||Yn.test(t)||nr.test(t),parse:t=>qn.test(t)?qn.parse(t):nr.test(t)?nr.parse(t):Yn.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?qn.transform(t):nr.transform(t)},or=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const ir="number",ar="color",sr=/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 ur(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},o=[];let i=0;const a=e.replace(sr,(t=>(rr.test(t)?(r.color.push(i),o.push(ar),n.push(rr.parse(t))):t.startsWith("var(")?(r.var.push(i),o.push("var"),n.push(t)):(r.number.push(i),o.push(ir),n.push(parseFloat(t))),++i,"${}"))).split("${}");return{values:n,split:a,indexes:r,types:o}}function cr(t){return ur(t).values}function lr(t){const{split:e,types:n}=ur(t),r=e.length;return t=>{let o="";for(let i=0;i<r;i++)if(o+=e[i],void 0!==t[i]){const e=n[i];o+=e===ir?Vn(t[i]):e===ar?rr.transform(t[i]):t[i]}return o}}const fr=t=>"number"==typeof t?0:t;const hr={test:function(t){var e,n;return isNaN(t)&&"string"==typeof t&&((null===(e=t.match(zn))||void 0===e?void 0:e.length)||0)+((null===(n=t.match(or))||void 0===n?void 0:n.length)||0)>0},parse:cr,createTransformer:lr,getAnimatableNone:function(t){const e=cr(t);return lr(t)(e.map(fr))}},pr=new Set(["brightness","contrast","saturate","opacity"]);function dr(t){const[e,n]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[r]=n.match(zn)||[];if(!r)return t;const o=n.replace(r,"");let i=pr.has(e)?1:0;return r!==n&&(i*=100),e+"("+i+o+")"}const yr=/\b([a-z-]*)\(.*?\)/gu,mr={...hr,getAnimatableNone:t=>{const e=t.match(yr);return e?e.map(dr).join(" "):t}},vr={borderWidth:Qn,borderTopWidth:Qn,borderRightWidth:Qn,borderBottomWidth:Qn,borderLeftWidth:Qn,borderRadius:Qn,radius:Qn,borderTopLeftRadius:Qn,borderTopRightRadius:Qn,borderBottomRightRadius:Qn,borderBottomLeftRadius:Qn,width:Qn,maxWidth:Qn,height:Qn,maxHeight:Qn,top:Qn,right:Qn,bottom:Qn,left:Qn,padding:Qn,paddingTop:Qn,paddingRight:Qn,paddingBottom:Qn,paddingLeft:Qn,margin:Qn,marginTop:Qn,marginRight:Qn,marginBottom:Qn,marginLeft:Qn,backgroundPositionX:Qn,backgroundPositionY:Qn},gr={rotate:Kn,rotateX:Kn,rotateY:Kn,rotateZ:Kn,scale:Un,scaleX:Un,scaleY:Un,scaleZ:Un,skew:Kn,skewX:Kn,skewY:Kn,distance:Qn,translateX:Qn,translateY:Qn,translateZ:Qn,x:Qn,y:Qn,z:Qn,perspective:Qn,transformPerspective:Qn,opacity:Bn,originX:er,originY:er,originZ:Qn},br={...Fn,transform:Math.round},wr={...vr,...gr,zIndex:br,size:Qn,fillOpacity:Bn,strokeOpacity:Bn,numOctaves:br},Sr={...wr,color:rr,backgroundColor:rr,outlineColor:rr,fill:rr,stroke:rr,borderColor:rr,borderTopColor:rr,borderRightColor:rr,borderBottomColor:rr,borderLeftColor:rr,filter:mr,WebkitFilter:mr},kr=t=>Sr[t];function xr(t,e){let n=kr(t);return n!==mr&&(n=hr),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const _r=new Set(["auto","none","0"]);const Ar=t=>t===Fn||t===Qn,Tr=(t,e)=>parseFloat(t.split(", ")[e]),Or=(t,e)=>(n,{transform:r})=>{if("none"===r||!r)return 0;const o=r.match(/^matrix3d\((.+)\)$/u);if(o)return Tr(o[1],e);{const e=r.match(/^matrix\((.+)\)$/u);return e?Tr(e[1],t):0}},Er=new Set(["x","y","z"]),jr=ze.filter((t=>!Er.has(t)));const Pr={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:Or(4,13),y:Or(5,14)};Pr.translateX=Pr.x,Pr.translateY=Pr.y;const Cr=new Set;let Ir=!1,Rr=!1;function Dr(){if(Rr){const t=Array.from(Cr).filter((t=>t.needsMeasurement)),e=new Set(t.map((t=>t.element))),n=new Map;e.forEach((t=>{const e=function(t){const e=[];return jr.forEach((n=>{const r=t.getValue(n);void 0!==r&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))})),e}(t);e.length&&(n.set(t,e),t.render())})),t.forEach((t=>t.measureInitialState())),e.forEach((t=>{t.render();const e=n.get(t);e&&e.forEach((([e,n])=>{var r;null===(r=t.getValue(e))||void 0===r||r.set(n)}))})),t.forEach((t=>t.measureEndState())),t.forEach((t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)}))}Rr=!1,Ir=!1,Cr.forEach((t=>t.complete())),Cr.clear()}function Lr(){Cr.forEach((t=>{t.readKeyframes(),t.needsMeasurement&&(Rr=!0)}))}class Mr{constructor(t,e,n,r,o,i=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=n,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Cr.add(this),Ir||(Ir=!0,Ke.read(Lr),Ke.resolveKeyframes(Dr))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:n,motionValue:r}=this;for(let o=0;o<t.length;o++)if(null===t[o])if(0===o){const o=null==r?void 0:r.get(),i=t[t.length-1];if(void 0!==o)t[0]=o;else if(n&&e){const r=n.readValue(e,i);null!=r&&(t[0]=r)}void 0===t[0]&&(t[0]=i),r&&void 0===o&&r.set(t[0])}else t[o]=t[o-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Cr.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Cr.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Nr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),Fr=t=>e=>"string"==typeof e&&e.startsWith(t),Br=Fr("--"),Ur=Fr("var(--"),Vr=t=>!!Ur(t)&&zr.test(t.split("/*")[0].trim()),zr=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Gr=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Hr(t,e,n=1){se(n<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);const[r,o]=function(t){const e=Gr.exec(t);if(!e)return[,];const[,n,r,o]=e;return[`--${null!=n?n:r}`,o]}(t);if(!r)return;const i=window.getComputedStyle(e).getPropertyValue(r);if(i){const t=i.trim();return Nr(t)?parseFloat(t):t}return Vr(o)?Hr(o,e,n+1):o}const $r=t=>e=>e.test(t),Wr=[Fn,Qn,Zn,Kn,tr,Jn,{test:t=>"auto"===t,parse:t=>t}],qr=t=>Wr.find($r(t));class Yr extends Mr{constructor(t,e,n,r,o){super(t,e,n,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:n}=this;if(!e||!e.current)return;super.readKeyframes();for(let n=0;n<t.length;n++){let r=t[n];if("string"==typeof r&&(r=r.trim(),Vr(r))){const o=Hr(r,e.current);void 0!==o&&(t[n]=o),n===t.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!He.has(n)||2!==t.length)return;const[r,o]=t,i=qr(r),a=qr(o);if(i!==a)if(Ar(i)&&Ar(a))for(let e=0;e<t.length;e++){const n=t[e];"string"==typeof n&&(t[e]=parseFloat(n))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,n=[];for(let e=0;e<t.length;e++)("number"==typeof(r=t[e])?0===r:null===r||"none"===r||"0"===r||Nn(r))&&n.push(e);var r;n.length&&function(t,e,n){let r,o=0;for(;o<t.length&&!r;){const e=t[o];"string"==typeof e&&!_r.has(e)&&ur(e).values.length&&(r=t[o]),o++}if(r&&n)for(const o of e)t[o]=xr(n,r)}(t,n,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:n}=this;if(!t||!t.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Pr[n](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const r=e[e.length-1];void 0!==r&&t.getValue(n,r).jump(r,!1)}measureEndState(){var t;const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const o=e.getValue(n);o&&o.jump(this.measuredOrigin,!1);const i=r.length-1,a=r[i];r[i]=Pr[n](e.measureViewportBox(),window.getComputedStyle(e.current)),null!==a&&void 0===this.finalKeyframe&&(this.finalKeyframe=a),(null===(t=this.removedTransforms)||void 0===t?void 0:t.length)&&this.removedTransforms.forEach((([t,n])=>{e.getValue(t).set(n)})),this.resolveNoneKeyframes()}}const Xr=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!hr.test(t)&&"0"!==t||t.startsWith("url(")));const Kr=t=>null!==t;function Zr(t,{repeat:e,repeatType:n="loop"},r){const o=t.filter(Kr),i=e&&"loop"!==n&&e%2==1?0:o.length-1;return i&&void 0!==r?r:o[i]}class Qr{constructor({autoplay:t=!0,delay:e=0,type:n="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",...a}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=nn.now(),this.options={autoplay:t,delay:e,type:n,repeat:r,repeatDelay:o,repeatType:i,...a},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt}get resolved(){return this._resolved||this.hasAttemptedResolve||(Lr(),Dr()),this._resolved}onKeyframesResolved(t,e){this.resolvedAt=nn.now(),this.hasAttemptedResolve=!0;const{name:n,type:r,velocity:o,delay:i,onComplete:a,onUpdate:s,isGenerator:u}=this.options;if(!u&&!function(t,e,n,r){const o=t[0];if(null===o)return!1;if("display"===e||"visibility"===e)return!0;const i=t[t.length-1],a=Xr(o,e),s=Xr(i,e);return ae(a===s,`You are trying to animate ${e} from "${o}" to "${i}". ${o} is not an animatable value - to enable this animation set ${o} to a value animatable to ${i} via the \`style\` property.`),!(!a||!s)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}(t)||("spring"===n||ve(n))&&r)}(t,n,r,o)){if(mn||!i)return s&&s(Zr(t,this.options,e)),a&&a(),void this.resolveFinishedPromise();this.options.duration=0}const c=this.initPlayback(t,e);!1!==c&&(this._resolved={keyframes:t,finalKeyframe:e,...c},this.onPostResolved())}onPostResolved(){}then(t,e){return this.currentFinishedPromise.then(t,e)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise((t=>{this.resolveFinishedPromise=t}))}}function Jr(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function to(t,e){return n=>n>0?e:t}const eo=(t,e,n)=>{const r=t*t,o=n*(e*e-r)+r;return o<0?0:Math.sqrt(o)},no=[Yn,qn,nr];function ro(t){const e=(n=t,no.find((t=>t.test(n))));var n;if(ae(Boolean(e),`'${t}' is not an animatable color. Use the equivalent color code instead.`),!Boolean(e))return!1;let r=e.parse(t);return e===nr&&(r=function({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,n/=100;let o=0,i=0,a=0;if(e/=100){const r=n<.5?n*(1+e):n+e-n*e,s=2*n-r;o=Jr(s,r,t+1/3),i=Jr(s,r,t),a=Jr(s,r,t-1/3)}else o=i=a=n;return{red:Math.round(255*o),green:Math.round(255*i),blue:Math.round(255*a),alpha:r}}(r)),r}const oo=(t,e)=>{const n=ro(t),r=ro(e);if(!n||!r)return to(t,e);const o={...n};return t=>(o.red=eo(n.red,r.red,t),o.green=eo(n.green,r.green,t),o.blue=eo(n.blue,r.blue,t),o.alpha=we(n.alpha,r.alpha,t),qn.transform(o))},io=(t,e)=>n=>e(t(n)),ao=(...t)=>t.reduce(io),so=new Set(["none","hidden"]);function uo(t,e){return n=>we(t,e,n)}function co(t){return"number"==typeof t?uo:"string"==typeof t?Vr(t)?to:rr.test(t)?oo:ho:Array.isArray(t)?lo:"object"==typeof t?rr.test(t)?oo:fo:to}function lo(t,e){const n=[...t],r=n.length,o=t.map(((t,n)=>co(t)(t,e[n])));return t=>{for(let e=0;e<r;e++)n[e]=o[e](t);return n}}function fo(t,e){const n={...t,...e},r={};for(const o in n)void 0!==t[o]&&void 0!==e[o]&&(r[o]=co(t[o])(t[o],e[o]));return t=>{for(const e in r)n[e]=r[e](t);return n}}const ho=(t,e)=>{const n=hr.createTransformer(e),r=ur(t),o=ur(e);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?so.has(t)&&!o.values.length||so.has(e)&&!r.values.length?function(t,e){return so.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}(t,e):ao(lo(function(t,e){var n;const r=[],o={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const a=e.types[i],s=t.indexes[a][o[a]],u=null!==(n=t.values[s])&&void 0!==n?n:0;r[i]=u,o[a]++}return r}(r,o),o.values),n):(ae(!0,`Complex values '${t}' and '${e}' 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.`),to(t,e))};function po(t,e,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof n)return we(t,e,n);return co(t)(t,e)}function yo({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:i=500,modifyTarget:a,min:s,max:u,restDelta:c=.5,restSpeed:l}){const f=t[0],h={done:!1,value:f},p=t=>void 0===s?u:void 0===u||Math.abs(s-t)<Math.abs(u-t)?s:u;let d=n*e;const y=f+d,m=void 0===a?y:a(y);m!==y&&(d=m-f);const v=t=>-d*Math.exp(-t/r),g=t=>m+v(t),b=t=>{const e=v(t),n=g(t);h.done=Math.abs(e)<=c,h.value=h.done?m:n};let w,S;const k=t=>{var e;(e=h.value,void 0!==s&&e<s||void 0!==u&&e>u)&&(w=t,S=ye({keyframes:[h.value,p(h.value)],velocity:$t(g,t,h.value),damping:o,stiffness:i,restDelta:c,restSpeed:l}))};return k(0),{calculatedDuration:null,next:t=>{let e=!1;return S||void 0!==w||(e=!0,b(t),k(t)),void 0!==w&&t>=w?S.next(t-w):(!e&&b(t),h)}}}const mo=On(.42,0,1,1),vo=On(0,0,.58,1),go=On(.42,0,.58,1),bo={linear:ie,easeIn:mo,easeInOut:go,easeOut:vo,circIn:Dn,circInOut:Mn,circOut:Ln,backIn:Cn,backInOut:In,backOut:Pn,anticipate:Rn},wo=t=>{if(gn(t)){se(4===t.length,"Cubic bezier arrays must contain four numerical values.");const[e,n,r,o]=t;return On(e,n,r,o)}return"string"==typeof t?(se(void 0!==bo[t],`Invalid easing type '${t}'`),bo[t]):t};function So(t,e,{clamp:n=!0,ease:r,mixer:o}={}){const i=t.length;if(se(i===e.length,"Both input and output ranges must be the same length"),1===i)return()=>e[0];if(2===i&&e[0]===e[1])return()=>e[1];const a=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const s=function(t,e,n){const r=[],o=n||po,i=t.length-1;for(let n=0;n<i;n++){let i=o(t[n],t[n+1]);if(e){const t=Array.isArray(e)?e[n]||ie:e;i=ao(t,i)}r.push(i)}return r}(e,r,o),u=s.length,c=n=>{if(a&&n<t[0])return e[0];let r=0;if(u>1)for(;r<t.length-2&&!(n<t[r+1]);r++);const o=Vt(t[r],t[r+1],n);return s[r](o)};return n?e=>c(Gt(t[0],t[i-1],e)):c}function ko({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const o=ge(r)?r.map(wo):wo(r),i={done:!1,value:e[0]},a=function(t,e){return t.map((t=>t*e))}(n&&n.length===e.length?n:ke(e),t),s=So(a,e,{ease:Array.isArray(o)?o:(u=e,c=o,u.map((()=>c||go)).splice(0,u.length-1))});var u,c;return{calculatedDuration:t,next:e=>(i.value=s(e),i.done=e>=t,i)}}const xo=t=>{const e=({timestamp:e})=>t(e);return{start:()=>Ke.update(e,!0),stop:()=>Ze(e),now:()=>Qe.isProcessing?Qe.timestamp:nn.now()}},_o={decay:yo,inertia:yo,tween:ko,keyframes:ko,spring:ye},Ao=t=>t/100;class To extends Qr{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,"idle"===this.state)return;this.teardown();const{onStop:t}=this.options;t&&t()};const{name:e,motionValue:n,element:r,keyframes:o}=this.options,i=(null==r?void 0:r.KeyframeResolver)||Mr;this.resolver=new i(o,((t,e)=>this.onKeyframesResolved(t,e)),e,n,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:e="keyframes",repeat:n=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=this.options,a=ve(e)?e:_o[e]||ko;let s,u;a!==ko&&"number"!=typeof t[0]&&(s=ao(Ao,po(t[0],t[1])),t=[0,100]);const c=a({...this.options,keyframes:t});"mirror"===o&&(u=a({...this.options,keyframes:[...t].reverse(),velocity:-i})),null===c.calculatedDuration&&(c.calculatedDuration=Ut(c));const{calculatedDuration:l}=c,f=l+r;return{generator:c,mirroredGenerator:u,mapPercentToKeyframes:s,calculatedDuration:l,resolvedDuration:f,totalDuration:f*(n+1)-r}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),"paused"!==this.pendingPlayState&&t?this.state=this.pendingPlayState:this.pause()}tick(t,e=!1){const{resolved:n}=this;if(!n){const{keyframes:t}=this.options;return{done:!0,value:t[t.length-1]}}const{finalKeyframe:r,generator:o,mirroredGenerator:i,mapPercentToKeyframes:a,keyframes:s,calculatedDuration:u,totalDuration:c,resolvedDuration:l}=n;if(null===this.startTime)return o.next(0);const{delay:f,repeat:h,repeatType:p,repeatDelay:d,onUpdate:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-c/this.speed,this.startTime)),e?this.currentTime=t:null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const m=this.currentTime-f*(this.speed>=0?1:-1),v=this.speed>=0?m<0:m>c;this.currentTime=Math.max(m,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=c);let g=this.currentTime,b=o;if(h){const t=Math.min(this.currentTime,c)/l;let e=Math.floor(t),n=t%1;!n&&t>=1&&(n=1),1===n&&e--,e=Math.min(e,h+1);Boolean(e%2)&&("reverse"===p?(n=1-n,d&&(n-=d/l)):"mirror"===p&&(b=i)),g=Gt(0,1,n)*l}const w=v?{done:!1,value:s[0]}:b.next(g);a&&(w.value=a(w.value));let{done:S}=w;v||null===u||(S=this.speed>=0?this.currentTime>=c:this.currentTime<=0);const k=null===this.holdTime&&("finished"===this.state||"running"===this.state&&S);return k&&void 0!==r&&(w.value=Zr(s,this.options,r)),y&&y(w.value),k&&this.finish(),w}get duration(){const{resolved:t}=this;return t?Ft(t.calculatedDuration):0}get time(){return Ft(this.currentTime)}set time(t){t=Nt(t),this.currentTime=t,null!==this.holdTime||0===this.speed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=Ft(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved)return void(this.pendingPlayState="running");if(this.isStopped)return;const{driver:t=xo,onPlay:e,startTime:n}=this.options;this.driver||(this.driver=t((t=>this.tick(t)))),e&&e();const r=this.driver.now();null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime?"finished"===this.state&&(this.startTime=r):this.startTime=null!=n?n:this.calcStartTime(),"finished"===this.state&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;this._resolved?(this.state="paused",this.holdTime=null!==(t=this.currentTime)&&void 0!==t?t:0):this.pendingPlayState="paused"}complete(){"running"!==this.state&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){null!==this.cancelTime&&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)}}const Oo=new Set(["opacity","clipPath","filter","transform"]);function Eo(t,e,n,{delay:r=0,duration:o=300,repeat:i=0,repeatType:a="loop",ease:s="easeInOut",times:u}={}){const c={[e]:n};u&&(c.offset=u);const l=An(s,o);return Array.isArray(l)&&(c.easing=l),t.animate(c,{delay:r,duration:o,easing:Array.isArray(l)?"linear":l,fill:"both",iterations:i+1,direction:"reverse"===a?"alternate":"normal"})}const jo=Rt((()=>Object.hasOwnProperty.call(Element.prototype,"animate")));const Po={anticipate:Rn,backInOut:In,circInOut:Mn};class Co extends Qr{constructor(t){super(t);const{name:e,motionValue:n,element:r,keyframes:o}=this.options;this.resolver=new Yr(o,((t,e)=>this.onKeyframesResolved(t,e)),e,n,r),this.resolver.scheduleResolve()}initPlayback(t,e){let{duration:n=300,times:r,ease:o,type:i,motionValue:a,name:s,startTime:u}=this.options;if(!a.owner||!a.owner.current)return!1;var c;if("string"==typeof o&&Sn()&&o in Po&&(o=Po[o]),ve((c=this.options).type)||"spring"===c.type||!kn(c.ease)){const{onComplete:e,onUpdate:a,motionValue:s,element:u,...c}=this.options,l=function(t,e){const n=new To({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:t[0]};const o=[];let i=0;for(;!r.done&&i<2e4;)r=n.sample(i),o.push(r.value),i+=10;return{times:void 0,keyframes:o,duration:i-10,ease:"linear"}}(t,c);1===(t=l.keyframes).length&&(t[1]=t[0]),n=l.duration,r=l.times,o=l.ease,i="keyframes"}const l=Eo(a.owner.current,s,t,{...this.options,duration:n,times:r,ease:o});return l.startTime=null!=u?u:this.calcStartTime(),this.pendingTimeline?(vn(l,this.pendingTimeline),this.pendingTimeline=void 0):l.onfinish=()=>{const{onComplete:n}=this.options;a.set(Zr(t,this.options,e)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:l,duration:n,times:r,type:i,ease:o,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:e}=t;return Ft(e)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:e}=t;return Ft(e.currentTime||0)}set time(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.currentTime=Nt(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:e}=t;return e.playbackRate}set speed(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:e}=t;return e.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:e}=t;return e.startTime}attachTimeline(t){if(this._resolved){const{resolved:e}=this;if(!e)return ie;const{animation:n}=e;vn(n,t)}else this.pendingTimeline=t;return ie}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:e}=t;"finished"===e.playState&&this.updateFinishedPromise(),e.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:e}=t;e.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:e,keyframes:n,duration:r,type:o,ease:i,times:a}=t;if("idle"===e.playState||"finished"===e.playState)return;if(this.time){const{motionValue:t,onUpdate:e,onComplete:s,element:u,...c}=this.options,l=new To({...c,keyframes:n,duration:r,type:o,ease:i,times:a,isGenerator:!0}),f=Nt(this.time);t.setWithVelocity(l.sample(f-10).value,l.sample(f).value,10)}const{onStop:s}=this.options;s&&s(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:o,damping:i,type:a}=t;if(!(e&&e.owner&&e.owner.current instanceof HTMLElement))return!1;const{onUpdate:s,transformTemplate:u}=e.owner.getProps();return jo()&&n&&Oo.has(n)&&!s&&!u&&!r&&"mirror"!==o&&0!==i&&"inertia"!==a}}const Io={type:"spring",stiffness:500,damping:25,restSpeed:10},Ro={type:"keyframes",duration:.8},Do={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lo=(t,{keyframes:e})=>e.length>2?Ro:Ge.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:Io:Do;const Mo=(t,e,n,r={},o,i)=>a=>{const s=Ve(r,t)||{},u=s.delay||r.delay||0;let{elapsed:c=0}=r;c-=Nt(u);let l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...s,delay:-c,onUpdate:t=>{e.set(t),s.onUpdate&&s.onUpdate(t)},onComplete:()=>{a(),s.onComplete&&s.onComplete()},name:t,motionValue:e,element:i?void 0:o};(function({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:o,repeat:i,repeatType:a,repeatDelay:s,from:u,elapsed:c,...l}){return!!Object.keys(l).length})(s)||(l={...l,...Lo(t,l)}),l.duration&&(l.duration=Nt(l.duration)),l.repeatDelay&&(l.repeatDelay=Nt(l.repeatDelay)),void 0!==l.from&&(l.keyframes[0]=l.from);let f=!1;if((!1===l.type||0===l.duration&&!l.repeatDelay)&&(l.duration=0,0===l.delay&&(f=!0)),(mn||We)&&(f=!0,l.duration=0,l.delay=0),f&&!i&&void 0!==e.get()){const t=Zr(l.keyframes,s);if(void 0!==t)return Ke.update((()=>{l.onUpdate(t),l.onComplete()})),new Mt([])}return!i&&Co.supports(l)?new Co(l):new To(l)};function No({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&!0!==e[n];return e[n]=!1,r}function Fo(t,e,{delay:n=0,transitionOverride:r,type:o}={}){var i;let{transition:a=t.getDefaultTransition(),transitionEnd:s,...u}=e;r&&(a=r);const c=[],l=o&&t.animationState&&t.animationState.getState()[o];for(const e in u){const r=t.getValue(e,null!==(i=t.latestValues[e])&&void 0!==i?i:null),o=u[e];if(void 0===o||l&&No(l,e))continue;const s={delay:n,...Ve(a||{},e)};let f=!1;if(window.MotionHandoffAnimation){const n=yn(t);if(n){const t=window.MotionHandoffAnimation(n,e,Ke);null!==t&&(s.startTime=t,f=!0)}}hn(t,e),r.start(Mo(e,r,o,t.shouldReduceMotion&&He.has(e)?{type:!1}:s,t,f));const h=r.animation;h&&c.push(h)}return s&&Promise.all(c).then((()=>{Ke.update((()=>{s&&function(t,e){const n=ln(t,e);let{transitionEnd:r={},transition:o={},...i}=n||{};i={...i,...r};for(const e in i)fn(t,e,(a=i[e],$e(a)?a[a.length-1]||0:a));var a}(t,s)}))})),c}function Bo(t){return t instanceof SVGElement&&"svg"!==t.tagName}const Uo=()=>({x:{min:0,max:0},y:{min:0,max:0}}),Vo={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"]},zo={};for(const t in Vo)zo[t]={isEnabled:e=>Vo[t].some((t=>!!e[t]))};const Go="undefined"!=typeof window,Ho={current:null},$o={current:!1};const Wo=[...Wr,rr,hr];function qo(t){return null!==t&&"object"==typeof t&&"function"==typeof t.start}function Yo(t){return"string"==typeof t||Array.isArray(t)}const Xo=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ko=["initial",...Xo];function Zo(t){return qo(t.animate)||Ko.some((e=>Yo(t[e])))}function Qo(t){return Boolean(Zo(t)||t.variants)}const Jo=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class ti{scrapeMotionValuesFromProps(t,e,n){return{}}constructor({parent:t,props:e,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Mr,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=()=>{const t=nn.now();this.renderScheduledAt<t&&(this.renderScheduledAt=t,Ke.render(this.render,!1,!0))};const{latestValues:s,renderState:u,onUpdate:c}=i;this.onUpdate=c,this.latestValues=s,this.baseTarget={...s},this.initialValues=e.initial?{...s}:{},this.renderState=u,this.parent=t,this.props=e,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=Boolean(o),this.isControllingVariants=Zo(e),this.isVariantNode=Qo(e),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(t&&t.current);const{willChange:l,...f}=this.scrapeMotionValuesFromProps(e,{},this);for(const t in f){const e=f[t];void 0!==s[t]&&xe(e)&&e.set(s[t],!1)}}mount(t){this.current=t,Ue.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(((t,e)=>this.bindToMotionValue(e,t))),$o.current||function(){if($o.current=!0,Go)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Ho.current=t.matches;t.addListener(e),e()}else Ho.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Ho.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Ue.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(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}bindToMotionValue(t,e){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const n=Ge.has(t),r=e.on("change",(e=>{this.latestValues[t]=e,this.props.onUpdate&&Ke.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)})),o=e.on("renderRequest",this.scheduleRender);let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,e)),this.valueSubscriptions.set(t,(()=>{r(),o(),i&&i(),e.owner&&e.stop()}))}sortNodePosition(t){return this.current&&this.sortInstanceNodePosition&&this.type===t.type?this.sortInstanceNodePosition(this.current,t.current):0}updateFeatures(){let t="animation";for(t in zo){const e=zo[t];if(!e)continue;const{isEnabled:n,Feature:r}=e;if(!this.features[t]&&r&&n(this.props)&&(this.features[t]=new r(this)),this.features[t]){const e=this.features[t];e.isMounted?e.update():(e.mount(),e.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,e){this.latestValues[t]=e}update(t,e){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=e;for(let e=0;e<Jo.length;e++){const n=Jo[e];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);const r=t["on"+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=function(t,e,n){for(const r in e){const o=e[r],i=n[r];if(xe(o))t.addValue(r,o);else if(xe(i))t.addValue(r,sn(o,{owner:t}));else if(i!==o)if(t.hasValue(r)){const e=t.getValue(r);!0===e.liveStyle?e.jump(o):e.hasAnimated||e.set(o)}else{const e=t.getStaticValue(r);t.addValue(r,sn(void 0!==e?e:o,{owner:t}))}}for(const r in n)void 0===e[r]&&t.removeValue(r);return e}(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){const e=this.getClosestVariantNode();if(e)return e.variantChildren&&e.variantChildren.add(t),()=>e.variantChildren.delete(t)}addValue(t,e){const n=this.values.get(t);e!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,e),this.values.set(t,e),this.latestValues[t]=e.get())}removeValue(t){this.values.delete(t);const e=this.valueSubscriptions.get(t);e&&(e(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,e){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return void 0===n&&void 0!==e&&(n=sn(null===e?void 0:e,{owner:this}),this.addValue(t,n)),n}readValue(t,e){var n;let r=void 0===this.latestValues[t]&&this.current?null!==(n=this.getBaseTargetFromProps(this.props,t))&&void 0!==n?n:this.readValueFromInstance(this.current,t,this.options):this.latestValues[t];var o;return null!=r&&("string"==typeof r&&(Nr(r)||Nn(r))?r=parseFloat(r):(o=r,!Wo.find($r(o))&&hr.test(e)&&(r=xr(t,e))),this.setBaseTarget(t,xe(r)?r.get():r)),xe(r)?r.get():r}setBaseTarget(t,e){this.baseTarget[t]=e}getBaseTarget(t){var e;const{initial:n}=this.props;let r;if("string"==typeof n||"object"==typeof n){const o=cn(this.props,n,null===(e=this.presenceContext)||void 0===e?void 0:e.custom);o&&(r=o[t])}if(n&&void 0!==r)return r;const o=this.getBaseTargetFromProps(this.props,t);return void 0===o||xe(o)?void 0!==this.initialValues[t]&&void 0===r?void 0:this.baseTarget[t]:o}on(t,e){return this.events[t]||(this.events[t]=new rn),this.events[t].add(e)}notify(t,...e){this.events[t]&&this.events[t].notify(...e)}}class ei extends ti{constructor(){super(...arguments),this.KeyframeResolver=Yr}sortInstanceNodePosition(t,e){return 2&t.compareDocumentPosition(e)?1:-1}getBaseTargetFromProps(t,e){return t.style?t.style[e]:void 0}removeValueFromRenderState(t,{vars:e,style:n}){delete e[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;xe(t)&&(this.childSubscription=t.on("change",(t=>{this.current&&(this.current.textContent=`${t}`)})))}}const ni=(t,e)=>e&&"number"==typeof t?e.transform(t):t,ri={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},oi=ze.length;function ii(t,e,n){const{style:r,vars:o,transformOrigin:i}=t;let a=!1,s=!1;for(const t in e){const n=e[t];if(Ge.has(t))a=!0;else if(Br(t))o[t]=n;else{const e=ni(n,wr[t]);t.startsWith("origin")?(s=!0,i[t]=e):r[t]=e}}if(e.transform||(a||n?r.transform=function(t,e,n){let r="",o=!0;for(let i=0;i<oi;i++){const a=ze[i],s=t[a];if(void 0===s)continue;let u=!0;if(u="number"==typeof s?s===(a.startsWith("scale")?1:0):0===parseFloat(s),!u||n){const t=ni(s,wr[a]);u||(o=!1,r+=`${ri[a]||a}(${t}) `),n&&(e[a]=t)}}return r=r.trim(),n?r=n(e,o?"":r):o&&(r="none"),r}(e,t.transform,n):r.transform&&(r.transform="none")),s){const{originX:t="50%",originY:e="50%",originZ:n=0}=i;r.transformOrigin=`${t} ${e} ${n}`}}const ai={offset:"stroke-dashoffset",array:"stroke-dasharray"},si={offset:"strokeDashoffset",array:"strokeDasharray"};function ui(t,e,n){return"string"==typeof t?t:Qn.transform(e+n*t)}function ci(t,{attrX:e,attrY:n,attrScale:r,originX:o,originY:i,pathLength:a,pathSpacing:s=1,pathOffset:u=0,...c},l,f){if(ii(t,c,f),l)return void(t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox));t.attrs=t.style,t.style={};const{attrs:h,style:p,dimensions:d}=t;h.transform&&(d&&(p.transform=h.transform),delete h.transform),d&&(void 0!==o||void 0!==i||p.transform)&&(p.transformOrigin=function(t,e,n){return`${ui(e,t.x,t.width)} ${ui(n,t.y,t.height)}`}(d,void 0!==o?o:.5,void 0!==i?i:.5)),void 0!==e&&(h.x=e),void 0!==n&&(h.y=n),void 0!==r&&(h.scale=r),void 0!==a&&function(t,e,n=1,r=0,o=!0){t.pathLength=1;const i=o?ai:si;t[i.offset]=Qn.transform(-r);const a=Qn.transform(e),s=Qn.transform(n);t[i.array]=`${a} ${s}`}(h,a,s,u,!1)}const li=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"]),fi=t=>"string"==typeof t&&"svg"===t.toLowerCase();function hi(t,{style:e,vars:n},r,o){Object.assign(t.style,e,o&&o.getProjectionStyles(r));for(const e in n)t.style.setProperty(e,n[e])}function pi(t,e,n,r){hi(t,e,void 0,r);for(const n in e.attrs)t.setAttribute(li.has(n)?n:pn(n),e.attrs[n])}const di={};function yi(t,{layout:e,layoutId:n}){return Ge.has(t)||t.startsWith("origin")||(e||void 0!==n)&&(!!di[t]||"opacity"===t)}function mi(t,e,n){var r;const{style:o}=t,i={};for(const a in o)(xe(o[a])||e.style&&xe(e.style[a])||yi(a,t)||void 0!==(null===(r=null==n?void 0:n.getValue(a))||void 0===r?void 0:r.liveStyle))&&(i[a]=o[a]);return i}function vi(t,e,n){const r=mi(t,e,n);for(const n in t)if(xe(t[n])||xe(e[n])){r[-1!==ze.indexOf(n)?"attr"+n.charAt(0).toUpperCase()+n.substring(1):n]=t[n]}return r}class gi extends ei{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Uo}getBaseTargetFromProps(t,e){return t[e]}readValueFromInstance(t,e){if(Ge.has(e)){const t=kr(e);return t&&t.default||0}return e=li.has(e)?e:pn(e),t.getAttribute(e)}scrapeMotionValuesFromProps(t,e,n){return vi(t,e,n)}build(t,e,n){ci(t,e,this.isSVGTag,n.transformTemplate)}renderInstance(t,e,n,r){pi(t,e,0,r)}mount(t){this.isSVGTag=fi(t.tagName),super.mount(t)}}function bi({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function wi(t){return void 0===t||1===t}function Si({scale:t,scaleX:e,scaleY:n}){return!wi(t)||!wi(e)||!wi(n)}function ki(t){return Si(t)||xi(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xi(t){return _i(t.x)||_i(t.y)}function _i(t){return t&&"0%"!==t}function Ai(t,e,n){return n+e*(t-n)}function Ti(t,e,n,r,o){return void 0!==o&&(t=Ai(t,o,r)),Ai(t,n,r)+e}function Oi(t,e=0,n=1,r,o){t.min=Ti(t.min,e,n,r,o),t.max=Ti(t.max,e,n,r,o)}function Ei(t,{x:e,y:n}){Oi(t.x,e.translate,e.scale,e.originPoint),Oi(t.y,n.translate,n.scale,n.originPoint)}const ji=.999999999999,Pi=1.0000000000001;function Ci(t,e){t.min=t.min+e,t.max=t.max+e}function Ii(t,e,n,r,o=.5){Oi(t,e,n,we(t.min,t.max,o),r)}function Ri(t,e){Ii(t.x,e.x,e.scaleX,e.scale,e.originX),Ii(t.y,e.y,e.scaleY,e.scale,e.originY)}function Di(t,e){return bi(function(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}(t.getBoundingClientRect(),e))}class Li extends ei{constructor(){super(...arguments),this.type="html",this.renderInstance=hi}readValueFromInstance(t,e){if(Ge.has(e)){const t=kr(e);return t&&t.default||0}{const r=(n=t,window.getComputedStyle(n)),o=(Br(e)?r.getPropertyValue(e):r[e])||0;return"string"==typeof o?o.trim():o}var n}measureInstanceViewportBox(t,{transformPagePoint:e}){return Di(t,e)}build(t,e,n){ii(t,e,n.transformTemplate)}scrapeMotionValuesFromProps(t,e,n){return mi(t,e,n)}}class Mi extends ti{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,e){if(function(t,e){return t in e}(e,t)){const n=t[e];if("string"==typeof n||"number"==typeof n)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(t,e){delete e.output[t]}measureInstanceViewportBox(){return{x:{min:0,max:0},y:{min:0,max:0}}}build(t,e){Object.assign(t.output,e)}renderInstance(t,{output:e}){Object.assign(t,e)}sortInstanceNodePosition(){return 0}}function Ni(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=Bo(t)?new gi(e):new Li(e);n.mount(t),Ue.set(t,n)}function Fi(t){const e=new Mi({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});e.mount(t),Ue.set(t,e)}function Bi(t,e,n){const r=xe(t)?t:sn(t);return r.start(Mo("",r,e,n)),r.animation}function Ui(t,e,n,r){const o=[];if(function(t,e){return xe(t)||"number"==typeof t||"string"==typeof t&&!Ae(e)}(t,e))o.push(Bi(t,Ae(e)&&e.default||e,n&&n.default||n));else{const i=Te(t,e,r),a=i.length;se(Boolean(a),"No valid elements provided.");for(let t=0;t<a;t++){const r=i[t],s=r instanceof Element?Ni:Fi;Ue.has(r)||s(r);const u=Ue.get(r),c={...n};"delay"in c&&"function"==typeof c.delay&&(c.delay=c.delay(t,a)),o.push(...Fo(u,{...e,transition:c},{}))}}return o}function Vi(t,e,n){const r=[],o=function(t,{defaultTransition:e={},...n}={},r,o){const i=e.duration||.3,a=new Map,s=new Map,u={},c=new Map;let l=0,f=0,h=0;for(let n=0;n<t.length;n++){const a=t[n];if("string"==typeof a){c.set(a,f);continue}if(!Array.isArray(a)){c.set(a.name,Ee(f,a.at,l,c));continue}let[p,d,y={}]=a;void 0!==y.at&&(f=Ee(f,y.at,l,c));let m=0;const v=(t,n,r,a=0,s=0)=>{const u=Me(t),{delay:c=0,times:l=ke(u),type:p="keyframes",repeat:d,repeatType:y,repeatDelay:v=0,...g}=n;let{ease:b=e.ease||"easeOut",duration:w}=n;const S="function"==typeof c?c(a,s):c,k=u.length,x=ve(p)?p:null==o?void 0:o[p];if(k<=2&&x){let t=100;if(2===k&&Be(u)){const e=u[1]-u[0];t=Math.abs(e)}const e={...g};void 0!==w&&(e.duration=Nt(w));const n=me(e,t,x);b=n.ease,w=n.duration}null!=w||(w=i);const _=f+S;1===l.length&&0===l[0]&&(l[1]=1);const A=l.length-u.length;if(A>0&&Se(l,A),1===u.length&&u.unshift(null),d){se(d<20,"Repeat count too high, must be less than 20"),w=Oe(w,d);const t=[...u],e=[...l];b=Array.isArray(b)?[...b]:[b];const n=[...b];for(let r=0;r<d;r++){u.push(...t);for(let o=0;o<t.length;o++)l.push(e[o]+(r+1)),b.push(0===o?"linear":be(n,o-1))}Ie(l,d)}const T=_+w;Ce(r,u,b,l,_,T),m=Math.max(S+w,m),h=Math.max(T,h)};if(xe(p))v(d,y,Le("default",De(p,s)));else{const t=Te(p,d,r,u),e=t.length;for(let n=0;n<e;n++){const r=De(t[n],s);for(const t in d)v(d[t],Ne(y,t),Le(t,r),n,e)}}l=f,f+=m}return s.forEach(((t,r)=>{for(const o in t){const i=t[o];i.sort(Re);const s=[],u=[],c=[];for(let t=0;t<i.length;t++){const{at:e,value:n,easing:r}=i[t];s.push(n),u.push(Vt(0,h,e)),c.push(r||"easeOut")}0!==u[0]&&(u.unshift(0),s.unshift(s[0]),c.unshift("easeInOut")),1!==u[u.length-1]&&(u.push(1),s.push(null)),a.has(r)||a.set(r,{keyframes:{},transition:{}});const l=a.get(r);l.keyframes[o]=s,l.transition[o]={...e,duration:h,ease:c,times:u,...n}}})),a}(t,e,n,{spring:ye});return o.forEach((({keyframes:t,transition:e},n)=>{r.push(...Ui(n,t,e))})),r}const zi=function(t,e,n){let r=[];var o;o=t,r=Array.isArray(o)&&o.some(Array.isArray)?Vi(t,e,Gi):Ui(t,e,n,Gi);const i=new Mt(r);return Gi&&Gi.animations.push(i),i};var Gi,Hi,$i;function Wi(t){return Wi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wi(t)}function qi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Yi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Zi(r.key),r)}}function Xi(t,e,n){return e&&Yi(t.prototype,e),n&&Yi(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ki(t,e,n){return(e=Zi(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zi(t){var e=function(t,e){if("object"!=Wi(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Wi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Wi(e)?e:e+""}($i=Hi||(Hi={})).Left="left",$i.Center="center",$i.Right="right";var Qi=Ki(Ki(Ki({},Hi.Left,"33.33%"),Hi.Center,"50%"),Hi.Right,"66.66%"),Ji=function(){function t(){qi(this,t)}return Xi(t,null,[{key:"isUnknown",value:function(e){return e===t.Unknown}},{key:"D2PositionToCSS",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.calc(t.y,t.yoffset),o=this.calc(t.x,t.xoffset),i=n?{bottom:r}:{top:r},a=e?{right:o}:{left:o};return this.wrap(Object.assign(Object.assign({},i),a))}},{key:"calc",value:function(e,n){if(!e||t.isUnknown(e))return"auto";if(void 0===n||t.isUnknown(n))return"calc(".concat(e," + 0px)");var r="number"==typeof e?"".concat(e,"px"):e;return"calc(".concat(r," + ").concat(n,"px)")}},{key:"toCoord2D",value:function(t){if(ta.isCommonPositionType(t))return ea.fromCommonPosition(t);if(ea.isCoord2DPosition(t))return t;if(na.isAlignPosition(t))return ea.fromAlignPosition(t);if("object"===Wi(t)&&["x","y","xoffset","yoffset"].some((function(e){return e in t})))return new ea(t);throw new Error("Invalid position type")}},{key:"orUnknown",value:function(e){return t.isUnknown(e)||void 0===e?t.Unknown:e}},{key:"mergePosition",value:function(t,e){var n=this.toCoord2D(t),r=this.toCoord2D(e);return ea.merge(n,r)}},{key:"serializePosition",value:function(e){var n=this.toCoord2D(e);return{x:t.isUnknown(n.x)?0:n.x,y:t.isUnknown(n.y)?0:n.y,xoffset:t.isUnknown(n.xoffset)?0:n.xoffset,yoffset:t.isUnknown(n.yoffset)?0:n.yoffset}}},{key:"isRawCommonPositionType",value:function(t){return Object.values(Hi).includes(t)}},{key:"isRawCoord2DPosition",value:function(t){return"object"===Wi(t)&&("x"in t||"y"in t||"xoffset"in t||"yoffset"in t)}},{key:"isRawAlignPosition",value:function(t){return"object"===Wi(t)&&("xalign"in t||"yalign"in t||"xoffset"in t||"yoffset"in t)}},{key:"isRawPosition",value:function(t){return this.isRawCommonPositionType(t)||this.isRawCoord2DPosition(t)||this.isRawAlignPosition(t)}},{key:"isPosition",value:function(t){return t instanceof ta||t instanceof ea||t instanceof na}},{key:"rawPositionToCoord2D",value:function(t){if(this.isRawCommonPositionType(t))return ea.fromCommonPosition(new ta(t));if(this.isRawCoord2DPosition(t))return new ea(t);if(this.isRawAlignPosition(t))return ea.fromAlignPosition(t);throw new Error("Invalid position type")}},{key:"tryParsePosition",value:function(t){if(this.isPosition(t))return t;if(this.isRawPosition(t))return this.rawPositionToCoord2D(t);throw new Error("Invalid position type")}},{key:"wrap",value:function(t){return Object.assign({left:"auto",top:"auto",right:"auto",bottom:"auto"},t)}}])}();Ji.Unknown=Symbol("Unknown");var ta=function(){function t(e){qi(this,t),this.position=e}return Xi(t,[{key:"toCSS",value:function(){return{x:Qi[this.position],y:"50%",xoffset:0,yoffset:0}}}],[{key:"isCommonPositionType",value:function(e){return e instanceof t}}])}();ta.Positions=Hi;var ea=function(){function t(e,n){qi(this,t),"object"===Wi(e)?(this.x=Ji.orUnknown(e.x),this.y=Ji.orUnknown(e.y),this.xoffset=Ji.orUnknown(e.xoffset),this.yoffset=Ji.orUnknown(e.yoffset)):(this.x=Ji.orUnknown(e),this.y=Ji.orUnknown(n),this.xoffset=Ji.Unknown,this.yoffset=Ji.Unknown)}return Xi(t,[{key:"toCSS",value:function(){return{x:this.x,y:this.y,xoffset:this.xoffset,yoffset:this.yoffset}}}],[{key:"isCoord2DPosition",value:function(e){return e instanceof t}},{key:"fromCommonPosition",value:function(e){return new t({x:Qi[e.position],y:"50%"})}},{key:"fromAlignPosition",value:function(e){return new t({x:Ji.isUnknown(e.xalign)?Ji.Unknown:"".concat(100*e.xalign,"%"),y:Ji.isUnknown(e.yalign)?Ji.Unknown:"".concat(100*e.yalign,"%"),xoffset:e.xoffset,yoffset:e.yoffset})}},{key:"merge",value:function(e,n){return new t({x:Ji.isUnknown(n.x)?e.x:n.x,y:Ji.isUnknown(n.y)?e.y:n.y,xoffset:Ji.isUnknown(n.xoffset)?e.xoffset:n.xoffset,yoffset:Ji.isUnknown(n.yoffset)?e.yoffset:n.yoffset})}}])}(),na=function(){function t(e,n){qi(this,t),"object"===Wi(e)?(this.xalign=Ji.orUnknown(e.xalign),this.yalign=Ji.orUnknown(e.yalign),this.xoffset=Ji.orUnknown(e.xoffset),this.yoffset=Ji.orUnknown(e.yoffset)):(this.xalign=Ji.orUnknown(e),this.yalign=Ji.orUnknown(n),this.xoffset=Ji.Unknown,this.yoffset=Ji.Unknown)}return Xi(t,[{key:"toCSS",value:function(){return{x:Ji.isUnknown(this.xalign)?this.xalign:"".concat(100*this.xalign,"%"),y:Ji.isUnknown(this.yalign)?this.yalign:"".concat(100*this.yalign,"%"),xoffset:this.xoffset,yoffset:this.yoffset}}}],[{key:"isAlignPosition",value:function(e){return e instanceof t}}])}();function ra(t){return ra="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ra(t)}function oa(t){return function(t){if(Array.isArray(t))return sa(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||aa(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ia(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||aa(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function aa(t,e){if(t){if("string"==typeof t)return sa(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sa(t,e):void 0}}function sa(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ua(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ca(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,fa(r.key),r)}}function la(t,e,n){return e&&ca(t.prototype,e),n&&ca(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function fa(t){var e=function(t,e){if("object"!=ra(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=ra(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ra(e)?e:e+""}var ha=function(){function t(e,n){ua(this,t),this.defaultConfig=e,this.handlers=n||{}}return la(t,[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new pa(this.mergeWithDefaultConfig(t))}},{key:"copy",value:function(){return new t(D({},this.defaultConfig),this.handlers)}},{key:"keys",value:function(){return Object.keys(this.defaultConfig)}},{key:"getDefaultConfig",value:function(){return this.defaultConfig}},{key:"mergeWithDefaultConfig",value:function(t){var e=this;return Object.fromEntries(Object.entries(this.defaultConfig).map((function(n){var r=ia(n,2),o=r[0],i=r[1];return[o,e.mergeValue(o,i,t[o])]})))}},{key:"mergeValue",value:function(t,e,n){return this.isPlainObject(n)?D({},n):Array.isArray(e)?Array.isArray(n)&&n.length>0?oa(n):oa(e):void 0!==n?this.applyHandler(t,n):e}},{key:"isPlainObject",value:function(t){return"object"===ra(t)&&!Array.isArray(t)&&null!==t&&Object.getPrototypeOf(t)===Object.prototype}},{key:"applyHandler",value:function(t,e){return"function"==typeof this.handlers[t]?this.handlers[t](e):e}}])}(),pa=function(){function t(e){ua(this,t),this.config=e}return la(t,[{key:"get",value:function(){return this.config}},{key:"copy",value:function(){return new t(D({},this.config))}},{key:"join",value:function(e){var n=function(t,e){var n={};for(var r in t)e.includes(r)||(n[r]=t[r]);return n}(this.config,Object.keys(e));return new t(Object.assign(n,e instanceof t?e.get():e))}},{key:"extract",value:function(e){var n,r={},o={},i=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=aa(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;r[a]=this.config[a]}}catch(t){i.e(t)}finally{i.f()}for(var s in this.config)e.includes(s)||(o[s]=this.config[s]);return[new t(r),new t(o)]}},{key:"assign",value:function(e){return new t(Object.assign({},this.config,e))}}])}();function da(t){return da="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},da(t)}function ya(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||va(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ma(t){return function(t){if(Array.isArray(t))return ga(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||va(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function va(t,e){if(t){if("string"==typeof t)return ga(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ga(t,e):void 0}}function ga(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ba(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function wa(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,xa(r.key),r)}}function Sa(t,e,n){return e&&wa(t.prototype,e),n&&wa(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function ka(t,e,n){return(e=xa(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xa(t){var e=function(t,e){if("object"!=da(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=da(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==da(e)?e:e+""}var _a=ka(ka(ka({},Ct,"25.33%"),Pt,"50%"),It,"75.66%"),Aa=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ba(this,t),this.state={},this.locked=null,this.frozen=!1,this.state=e}return Sa(t,[{key:"get",value:function(){return this.state}},{key:"freeze",value:function(){return this.frozen=!0,this}},{key:"assign",value:function(e,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(e))throw new Error("Trying to write a locked transform state.");return this.state=t.mergeState(this.state,n),this}},{key:"lock",value:function(){if(this.locked)throw new Error("Transform state is already locked.");return this.locked=Symbol(),this.locked}},{key:"isLocked",value:function(){return!!this.locked}},{key:"canWrite",value:function(t){return null===this.locked||this.locked===t}},{key:"unlock",value:function(t){return this.locked===t&&(this.locked=null),this}},{key:"toFramesDefinition",value:function(t,e){return Z(Ta.constructStyle(t,this.state,e))}},{key:"toStyle",value:function(t,e){return Z(Ta.constructStyle(t,this.state,e))}},{key:"serialize",value:function(){return t.TransformStateSerializer.serialize(this.state)}},{key:"clone",value:function(){return new t(t.mergeState({},this.state))}},{key:"overwrite",value:function(e,n){if(this.frozen)throw new Error("Trying to write a frozen transform state.");if(!this.canWrite(e))throw new Error("Trying to write a locked transform state.");return this.state=t.mergeState(this.state,n),this}},{key:"forceOverwrite",value:function(t){return this.state=t,this}}],[{key:"deserialize",value:function(e){return new t(t.TransformStateSerializer.deserialize(e))}},{key:"mergePosition",value:function(t,e){if(!t&&!e)throw new Error("No position found.");return t&&e?Ji.mergePosition(Ji.tryParsePosition(t),Ji.tryParsePosition(e)):Ji.toCoord2D(Ji.tryParsePosition(t||e))}},{key:"mergeState",value:function(t,e){if("position"in t&&"position"in e){var n=this.mergePosition(t.position,e.position);return Object.assign(Object.assign({},Object.assign({},t,e)),{position:n})}return Object.assign({},Object.assign({},t,e))}}])}();Aa.DefaultTransformState=new ha({scale:1,rotation:0,position:new ta(Hi.Center),opacity:0,alt:""}),Aa.TransformStateSerializer=new X({position:function(t){return Ji.toCoord2D(Ji.tryParsePosition(t))}},{position:Ji.toCoord2D});var Ta=function(){function t(e,n){if(ba(this,t),this.sequences=[],this.stagedChanges=[],Array.isArray(e)){var r;(r=this.sequences).push.apply(r,ma(e)),this.config=Object.assign({},t.defaultConfig,n||{})}else{var o=e,i=n||t.defaultOptions;this.sequences.push({props:o,options:i||t.defaultOptions}),this.config=Object.assign({},t.defaultConfig)}}return Sa(t,[{key:"animate",value:function(t,e){var n=e.gameState,r=e.ref,o=e.overwrites;if(!r.current)throw new Error("No ref found when animating.");this.commit();var i=this.constructAnimation({gameState:n,transformState:t,overwrites:o,current:r.current}),a=i.finalState,s=i.sequences,u=i.options;s.length||n.logger.warn("Transform","No sequences to animate.");var c=t.lock(),l=zi(s,u),f=(new L).registerSkipController(new z((function(){t.unlock(c),l.complete()})));return l.then((function(){t.overwrite(c,a.get()).unlock(c),n.logger.debug("Transform","Transform Completed",t.toStyle(n,o)),f.resolve()}),(function(t){var e;n.logger.error("Failed to animate transform. "+((null===(e=null==t?void 0:t.toString)||void 0===e?void 0:e.call(t))||""))})),l.play(),n.logger.debug("Transform","Ready to animate transform.",{finalState:a,sequences:s,options:u},this),f}},{key:"repeat",value:function(t){var e=this.copy();return e.config.repeat||(e.config.repeat=1),e.config.repeat*=t,e}},{key:"getOptions",value:function(e){if(!e)return Object.assign({},t.defaultOptions);var n=e.duration,r=e.ease,o=e.delay,i=e.at;return{duration:this.toSeconds(n,void 0),ease:r,delay:this.toSeconds(o,void 0),at:this.atToSeconds(i)}}},{key:"constructAnimation",value:function(t){var e=this,n=t.gameState,r=t.transformState,o=t.overwrites,i=void 0===o?{}:o,a=t.current,s=r.clone(),u=s.lock(),c=this.sequences.map((function(t){var r=t.props,o=t.options,c=s.assign(u,r).toFramesDefinition(n,i);return[a,c,e.getOptions(o)]}));return{finalState:s.unlock(u).freeze(),sequences:c,options:this.getSequenceOptions()}}},{key:"getSequenceOptions",value:function(){var t=this.config,e=t.repeat,n=t.repeatDelay;return{repeat:this.toSeconds(e,void 0),repeatDelay:this.toSeconds(n,void 0)}}},{key:"copy",value:function(){return new t(this.sequences,this.config)}},{key:"commit",value:function(t){if(!this.stagedChanges.length)return this;var e=this.constructCommit(this.stagedChanges,this.getSequenceOptions());return this.sequences.push({props:e.props,options:Object.assign(Object.assign({},this.getSequenceOptions()),t)}),this.stagedChanges=[],this}},{key:"scale",value:function(t){return this.pushChange({key:"scale",props:t})}},{key:"rotation",value:function(t){return this.pushChange({key:"rotation",props:t})}},{key:"position",value:function(t){return this.pushChange({key:"position",props:t})}},{key:"opacity",value:function(t){return this.pushChange({key:"opacity",props:t})}},{key:"fontColor",value:function(t){return this.pushChange({key:"fontColor",props:t})}},{key:"constructCommit",value:function(t,e){var n,r={props:{},options:e},o=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=va(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;r.props[i.key]=i.props}}catch(t){o.e(t)}finally{o.f()}return r}},{key:"pushChange",value:function(t){return this.stagedChanges.push(t),this}},{key:"toSeconds",value:function(t,e){return void 0===t?e:t/1e3}},{key:"atToSeconds",value:function(t){if(void 0===t)return t;if("number"==typeof t)return t/1e3;var e=/^([+-])(\d+)$/.exec(t);if(!e)throw new qc("Invalid at definition. At definition must be a number or a string in the format of `+n` or `-n`.");var n=ya(e,3),r=(n[0],n[1]),o=n[2],i=Number(o);if(isNaN(i))throw new qc("Invalid number in at definition.");var a=i/1e3;return"+"===r?"+".concat(a):"-".concat(a)}}],[{key:"isPosition",value:function(t){return ta.isCommonPositionType(t)||ea.isCoord2DPosition(t)||na.isAlignPosition(t)}},{key:"immediate",value:function(e){return new t(e,{duration:0,ease:"linear"})}},{key:"left",value:function(e,n){return new t({position:ta.Positions.Left},{duration:e,ease:n})}},{key:"right",value:function(e,n){return new t({position:ta.Positions.Right},{duration:e,ease:n})}},{key:"center",value:function(e,n){return new t({position:ta.Positions.Center},{duration:e,ease:n})}},{key:"create",value:function(e){return new t([],e)}},{key:"positionToCSS",value:function(t,e,n){return t?Ji.isRawPosition(t)?Ji.D2PositionToCSS(Ji.rawPositionToCoord2D(t),n,e):Ji.D2PositionToCSS(t.toCSS(),n,e):{}}},{key:"mergePosition",value:function(t,e){if(!t&&!e)throw new Error("No position found.");return t&&e?Ji.mergePosition(Ji.tryParsePosition(t),Ji.tryParsePosition(e)):Ji.toCoord2D(Ji.tryParsePosition(t||e))}},{key:"mergeState",value:function(t,e){var n=this.mergePosition(t.position,e.position);return Object.assign(Object.assign({},D(t,e)),{position:n})}},{key:"propToCSSTransform",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.translate,o=void 0===r?[]:r,i=n.scale,a=void 0===i?1:i;if(!t.getLastScene())throw new Error('No scene found in state, make sure you called "scene.activate()" before this method.');var s=void 0!==e.scale?e.scale:1,u=t.getStory().getInversionConfig(),c=u.invertY,l=u.invertX;return["translate(".concat(o[0]||(l?"":"-")+"50%",", ").concat(o[1]||(c?"":"-")+"50%",")"),void 0!==e.rotation&&"rotate(".concat(e.rotation,"deg)"),"scale(".concat(s*a,")")].filter(Boolean).join(" ")}},{key:"constructStyle",value:function(e,n,r){var o=e.getStory().getInversionConfig(),i=o.invertY,a=o.invertX,s=r||{},u=s.transform,c=s.scale,l=s.overwrite;return Object.assign(Object.assign(Object.assign({},t.positionToCSS(n.position,i,a)),{opacity:n.opacity,color:"fontColor"in n&&n.fontColor?N(n.fontColor):void 0,transform:u?u(n):t.propToCSSTransform(e,n),scale:c?c(n):void 0}),l?l(n):{})}}])}();function Oa(t){return Oa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oa(t)}function Ea(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ja(r.key),r)}}function ja(t){var e=function(t,e){if("object"!=Oa(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Oa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Oa(e)?e:e+""}Ta.defaultConfig={sync:!0},Ta.defaultOptions={duration:0,ease:"linear"},Ta.CommonImagePositionMap=_a;var Pa,Ca,Ia=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=""},(e=[{key:"setId",value:function(t){this.id=t}},{key:"getId",value:function(){return this.id}},{key:"reset",value:function(){}},{key:"fromData",value:function(t){return this}},{key:"construct",value:function(t){for(var e,n=0;n<t.length;n++){var r=t[n];0!==n&&(null===(e=t[n-1])||void 0===e||e.contentNode.setChild(r.contentNode))}return t}}])&&Ea(t.prototype,e),n&&Ea(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function Ra(t){return Ra="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ra(t)}function Da(t){return function(t){if(Array.isArray(t))return La(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return La(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?La(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function La(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ma(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Na(r.key),r)}}function Na(t){var e=function(t,e){if("object"!=Ra(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ra(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ra(e)?e:e+""}(Ca=Pa||(Pa={})).invalidExposedStateUnmounting="invalidExposedStateUnmounting",Ca.unexpectedTimelineStatusChange="unexpectedTimelineStatusChange";var Fa=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.watching=null,this.warnings=[]},(e=[{key:"observe",value:function(t){return this.watching=t,this}},{key:"warn",value:function(t,e){var n;return this.warnings.push([t,e]),null===(n=this.watching)||void 0===n||n.logger.warn(e),e}},{key:"getWarnings",value:function(){return Da(this.warnings)}}])&&Ma(t.prototype,e),n&&Ma(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function Ba(t){return Ba="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ba(t)}function Ua(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=za(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Va(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||za(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function za(t,e){if(t){if("string"==typeof t)return Ga(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ga(t,e):void 0}}function Ga(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ha(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,qa(r.key),r)}}function Wa(t,e,n){return e&&$a(t.prototype,e),n&&$a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function qa(t){var e=function(t,e){if("object"!=Ba(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ba(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ba(e)?e:e+""}var Ya=function(){function t(e,n){var r=this;Ha(this,t),this.awaitable=e,this.guard=n,this.children=[],this._onResolved=[],this._onCancelled=[],this._onTimelineRegistered=[],this._ableToAttach=!0,this._status="pending",e.onSettled((function(){r.resolveStatus()})),Y((function(){r.preventAttach()}))}return Wa(t,[{key:"status",get:function(){return this._status}},{key:"isSettled",value:function(){return"pending"!==this._status}},{key:"isResolved",value:function(){return"resolved"===this._status}},{key:"isCancelled",value:function(){return"cancelled"===this._status}},{key:"onResolved",value:function(t){this._onResolved.push(t)}},{key:"onCancelled",value:function(t){this._onCancelled.push(t)}},{key:"onSettled",value:function(t){this.isSettled()?Y(t):(this.onResolved(t),this.onCancelled(t))}},{key:"abort",value:function(){this.isSettled()||(this.awaitable.abort(),this.setStatus("cancelled",this.emitEvents.bind(this)),this.children.forEach((function(t){return t.abort()})))}},{key:"attachChild",value:function(e){var n=this;if(!this._ableToAttach)throw new Yc("Attaching to this timeline violates the timeline's state. \nTimeline attaching is only allowed synchronously after the timeline is created. \nCurrent _ableToAttach: "+this._ableToAttach);var r=L.isAwaitable(e)?new t(e,this.guard):e;return this.children.push(r),this.guard&&r.setGuard(this.guard),r.onSettled((function(){n.resolveStatus()})),this}},{key:"setGuard",value:function(t){return this.guard=t,this}},{key:"catSettled",value:function(){return this.children.reduce((function(t,e){var n=Va(t,2),r=n[0],o=n[1];return e.isResolved()?r.push(e):e.isCancelled()&&o.push(e),[r,o]}),[[],[]])}},{key:"onTimelineRegistered",value:function(t){return this._onTimelineRegistered.push(t),this}},{key:"resolveStatus",value:function(){var t;this.awaitable.solved&&this.children.every((function(t){return t.isSettled()}))?this.setStatus("resolved",this.emitEvents.bind(this)):(null===(t=this.awaitable.skipController)||void 0===t?void 0:t.isAborted())&&this.setStatus("cancelled",this.emitEvents.bind(this))}},{key:"emitEvents",value:function(){this.isResolved()?this._onResolved.forEach((function(t){return t()})):this.isCancelled()&&this._onCancelled.forEach((function(t){return t()})),this._onResolved=[],this._onCancelled=[]}},{key:"setStatus",value:function(t,e){this.isSettled()?this.guard&&this.guard.warn(Pa.unexpectedTimelineStatusChange,"Trying to resolve a settled timeline: ".concat(this._status," -> ").concat(t)):t!==this._status&&e?(this._status=t,e()):this._status=t}},{key:"preventAttach",value:function(){this._ableToAttach=!1,this._onTimelineRegistered.forEach((function(t){return t()}))}}],[{key:"proxy",value:function(e){var n=new L,r=new L,o=new t(r);return o.onTimelineRegistered((function(){r.resolve()})).onSettled((function(){var t=Va(o.catSettled(),2),n=t[0],r=t[1];e(n,r)})),n.onSkipControllerRegister((function(t){t.onAbort((function(){o.abort()}))})),[n,o]}},{key:"any",value:function(e){if(0===e.length)throw new Yc("Cannot create an 'any' timeline with no awaitables.");var n,r=new L,o=new t(new L),i=!1,a=Ua(e);try{for(a.s();!(n=a.n()).done;){var s=n.value;o.attachChild(s),s.then((function(t){i||(i=!0,r.resolve(t))}))}}catch(t){a.e(t)}finally{a.f()}return r.onSkipControllerRegister((function(t){t.onAbort((function(){o.abort()}))})),[r,o]}},{key:"sequence",value:function(t,e){var n=e,r=null,o=new L,i=function(){var e;r?(r.onSkipControllerRegister((function(t){e=t.onAbort((function(){o.abort()}))})),r.then((function(a){null==e||e.cancel(),n=a,(r=t(a))?Y((function(){return i()})):o.resolve(n)}))):o.resolve(n)};return o.registerSkipController(new z((function(){return r&&r.abort(),e}))),(r=t(e))?Y((function(){return i()})):o.resolve(n),o}}])}(),Xa=function(){return Wa((function t(e){Ha(this,t),this.guard=e,this.timelines=[]}),[{key:"attachTimeline",value:function(t){this.cleanupSettled();var e=t instanceof Ya?t:new Ya(t);return this.timelines.push(e),this.guard&&e.setGuard(this.guard),e}},{key:"abortAll",value:function(){var t,e=Ua(this.timelines);try{for(e.s();!(t=e.n()).done;){t.value.abort()}}catch(t){e.e(t)}finally{e.f()}this.cleanupSettled()}},{key:"cleanupSettled",value:function(){this.timelines=this.timelines.filter((function(t){return!t.isSettled()}))}}])}();function Ka(t){return Ka="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ka(t)}function Za(t){return function(t){if(Array.isArray(t))return es(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ts(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qa(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ts(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Ja(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||ts(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ts(t,e){if(t){if("string"==typeof t)return es(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?es(t,e):void 0}}function es(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ns(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,rs(r.key),r)}}function rs(t){var e=function(t,e){if("object"!=Ka(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ka(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ka(e)?e:e+""}function os(t,e,n){return e=us(e),function(t,e){if(e&&("object"==Ka(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,is()?Reflect.construct(e,n||[],us(t).constructor):e.apply(t,n))}function is(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(is=function(){return!!t})()}function as(t,e,n,r){var o=ss(us(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function ss(){return ss="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=us(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},ss.apply(null,arguments)}function us(t){return us=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},us(t)}function cs(t,e){return cs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},cs(t,e)}var ls,fs=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),os(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&cs(t,e)}(e,t),n=e,(r=[{key:"executeActionSeries",value:function(t,e,n){var r=Ya.sequence((function(e){if(!e.node||!e.node.action)return null;var n=e.node.action,r=t.game.getLiveGame().executeActionRaw(t,n);return r?L.isAwaitable(r)?r:L.resolve(r):null}),{type:e.type,node:e.contentNode}),o=new Ya(r),i=new L;return t.logger.debug("ControlAction","executeActionSeries",e.type,e.contentNode),r.then((function(t){var e=n(t);i.resolve(e)})),r.registerSkipController(new z((function(){o.abort(),i.abort()}))),i.onSkipControllerRegister((function(t){t.onAbort((function(){o.abort()}))})),[i,o]}},{key:"executeSingleAction",value:function(t,e){var n=t.game.getLiveGame().executeAction(t,e);return t.logger.debug("ControlAction","executeSingleAction",e.type,n),L.isAwaitable(n),n}},{key:"executeAction",value:function(t){var n=this,r=Ja(this.contentNode.getContent(),1)[0];if(this.type===u.do){var o=this.executeActionSeries(t,r[0],(function(t){return t})),i=Ja(o,2),a=i[0],s=i[1];return t.timelines.attachTimeline(s),L.forward(a,{type:this.type,node:this.contentNode.getChild()})}if(this.type===u.doAsync){if(r.length>0){var c=this.executeActionSeries(t,r[0],(function(t){return t})),l=Ja(c,2)[1];t.timelines.attachTimeline(l)}return as(e,"executeAction",this,3)([t])}if(this.type===u.any){if(0===r.length)return L.resolve({type:this.type,node:this.contentNode.getChild()});var f=Ja(Ya.any(r.map((function(e){return n.executeSingleAction(t,e)})).filter((function(t){return L.isAwaitable(t)}))),2),h=f[0],p=f[1];return t.timelines.attachTimeline(p),L.forward(h,{type:this.type,node:this.contentNode.getChild()})}if(this.type===u.all){var d,y=Ja(Ya.proxy((function(){m.resolve({type:n.type,node:n.contentNode.getChild()}),t.stage.next()})),2),m=y[0],v=y[1],g=Qa(r);try{for(g.s();!(d=g.n()).done;){var b=d.value,w=this.executeSingleAction(t,b);L.isAwaitable(w)&&v.attachChild(w)}}catch(t){g.e(t)}finally{g.f()}return t.timelines.attachTimeline(v),m}if(this.type===u.allAsync){var S,k=Ja(Ya.proxy((function(){})),2)[1],x=Qa(r);try{for(x.s();!(S=x.n()).done;){var _=S.value,A=this.executeSingleAction(t,_);L.isAwaitable(A)&&k.attachChild(A)}}catch(t){x.e(t)}finally{x.f()}return t.timelines.attachTimeline(k),as(e,"executeAction",this,3)([t])}if(this.type===u.repeat){var T=Ja(this.contentNode.getContent(),2),O=T[0],E=T[1],j=Ya.sequence((function(e){if(e>=E)return null;var r=Ja(n.executeActionSeries(t,O[0],(function(){return e+1})),2),o=r[0],i=r[1];return P.attachChild(i),o}),0),P=new Ya(j);return t.timelines.attachTimeline(P),L.forward(j,{type:this.type,node:this.contentNode.getChild()})}if(this.type===u.sleep){var C,I=Ja(this.contentNode.getContent(),2)[1];C="number"==typeof I?L.delay(I):L.isAwaitable(I)?I:L.fromPromise(I);var R=new L,D=new Ya(C);return t.timelines.attachTimeline(D),C.then((function(){R.resolve({type:n.type,node:n.contentNode.getChild()}),t.stage.next()})),R.onSkipControllerRegister((function(t){t.onAbort((function(){D.abort()}))})),R}throw new Error("Unknown control action type: "+this.type)}},{key:"getFutureActions",value:function(t,n){if(!1===this.callee.config.allowFutureScene&&!1===n.allowFutureScene)return Za(as(e,"getFutureActions",this,3)([t,n]));var r=this.contentNode.getContent()[0],o=as(e,"getFutureActions",this,3)([t,n]);return[].concat(Za(r),Za(o))}}])&&ns(n.prototype,r),o&&ns(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function hs(t){return hs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hs(t)}function ps(t){return function(t){if(Array.isArray(t))return ds(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ds(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ds(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ds(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ys(t,e,n){return e=vs(e),function(t,e){if(e&&("object"==hs(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ms()?Reflect.construct(e,n||[],vs(t).constructor):e.apply(t,n))}function ms(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ms=function(){return!!t})()}function vs(t){return vs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vs(t)}function gs(t,e){return gs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},gs(t,e)}function bs(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ws(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ks(r.key),r)}}function Ss(t,e,n){return e&&ws(t.prototype,e),n&&ws(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function ks(t){var e=function(t,e){if("object"!=hs(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=hs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==hs(e)?e:e+""}fs.ActionTypes=u;var xs=Symbol("_Chained"),_s=function(){function t(e){bs(this,t),this[ls]=!0,this.__actions=[],this.__self=e}return Ss(t,[{key:"push",value:function(){var t;(t=this.__actions).push.apply(t,arguments)}},{key:"getActions",value:function(){return this.__actions}},{key:"getSelf",value:function(){return this.__self}},{key:"newChain",value:function(){return this.getSelf().chain()}}],[{key:"isChained",value:function(t){return t&&t[xs]}},{key:"toActions",value:function(e){return e.flat(2).map((function(e){return t.isChained(e)?e.fromChained(e):e})).flat(3)}}])}();ls=xs;var As=function(t){function e(){return bs(this,e),ys(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&gs(t,e)}(e,t),Ss(e,[{key:"chain",value:function(t){var e=_s.isChained(this)?this:this.proxy(this,new _s(this));if(!t)return e;var n=Array.isArray(t)?t:[t];return e.push.apply(e,ps(n)),e}},{key:"proxy",value:function(t,e){var n=new Proxy(t,{get:function(t,r){if(r in e)return e[r];var o=t[r];return"function"==typeof o?o.bind(n):o},set:function(t,e,n){return t[e]=n,!0}});return n}},{key:"combineActions",value:function(t,e){var n=e(this.chain().newChain()),r=new fs(t.chain(),fs.ActionTypes.do,(new jt).setContent([this.construct(_s.toActions([n]))]));return this.chain(r)}}])}(Ia);function Ts(t){return Ts="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ts(t)}function Os(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Es(r.key),r)}}function Es(t){var e=function(t,e){if("object"!=Ts(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ts(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ts(e)?e:e+""}function js(t,e,n){return e=Cs(e),function(t,e){if(e&&("object"==Ts(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ps()?Reflect.construct(e,n||[],Cs(t).constructor):e.apply(t,n))}function Ps(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ps=function(){return!!t})()}function Cs(t){return Cs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cs(t)}function Is(t,e){return Is=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Is(t,e)}var Rs=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),js(this,e)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Is(t,e)}(e,t),n=e,(r=[{key:"toData",value:function(){return null}},{key:"fromChained",value:function(t){return t.getActions()}}])&&Os(n.prototype,r),o&&Os(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(As);function Ds(t){return Ds="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ds(t)}function Ls(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ms(r.key),r)}}function Ms(t){var e=function(t,e){if("object"!=Ds(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ds(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ds(e)?e:e+""}function Ns(t,e,n){return e=Bs(e),function(t,e){if(e&&("object"==Ds(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Fs()?Reflect.construct(e,n||[],Bs(t).constructor):e.apply(t,n))}function Fs(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Fs=function(){return!!t})()}function Bs(t){return Bs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bs(t)}function Us(t,e){return Us=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Us(t,e)}var Vs=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=Ns(this,e)).config=n,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Us(t,e)}(e,t),n=e,r=[{key:"do",value:function(t){return this.push(fs.ActionTypes.do,t)}},{key:"doAsync",value:function(t){return this.push(fs.ActionTypes.doAsync,t)}},{key:"any",value:function(t){return this.push(fs.ActionTypes.any,t)}},{key:"all",value:function(t){return this.push(fs.ActionTypes.all,t)}},{key:"allAsync",value:function(t){return this.push(fs.ActionTypes.allAsync,t)}},{key:"repeat",value:function(t,e){return this.push(fs.ActionTypes.repeat,e,t)}},{key:"sleep",value:function(t){return this.push(fs.ActionTypes.sleep,[],t)}},{key:"push",value:function(t,e){for(var n=_s.toActions(e),r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var a=new fs(this.chain(),t,(new jt).setContent([this.construct(n)].concat(o)));return this.chain(a)}}],o=[{key:"do",value:function(t){return(new e).do(t)}},{key:"doAsync",value:function(t){return(new e).doAsync(t)}},{key:"any",value:function(t){return(new e).any(t)}},{key:"all",value:function(t){return(new e).all(t)}},{key:"allAsync",value:function(t){return(new e).allAsync(t)}},{key:"repeat",value:function(t,n){return(new e).repeat(t,n)}},{key:"sleep",value:function(t){return(new e).sleep(t)}}],r&&Ls(n.prototype,r),o&&Ls(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);function zs(t){return zs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zs(t)}function Gs(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Hs(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hs(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hs(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function $s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ws(r.key),r)}}function Ws(t){var e=function(t,e){if("object"!=zs(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=zs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==zs(e)?e:e+""}function qs(t,e,n){return e=Zs(e),function(t,e){if(e&&("object"==zs(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ys()?Reflect.construct(e,n||[],Zs(t).constructor):e.apply(t,n))}function Ys(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ys=function(){return!!t})()}function Xs(t,e,n,r){var o=Ks(Zs(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Ks(){return Ks="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Zs(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Ks.apply(null,arguments)}function Zs(t){return Zs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zs(t)}function Qs(t,e){return Qs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qs(t,e)}var Js=function(t){function n(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),qs(this,n,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Qs(t,e)}(n,t),r=n,o=[{key:"executeAction",value:function(t){if(this.type===e.applyTransform){var n=Gs(this.contentNode.getContent(),1)[0],r=this.callee;return this.applyTransform(t,r,n)}if(this.type===e.applyTransition){var o=Gs(this.contentNode.getContent(),2),i=o[0],a=o[1],s=this.callee,u=a?a(i):i;return this.applyTransition(t,s,u)}if(this.type===e.init){var c=Gs(this.contentNode.getContent(),3),l=c[0],f=c[1],h=c[2],p=this.callee;return this.initDisplayable(t,l,p,f||null,h)}throw this.unknownTypeError()}},{key:"applyTransform",value:function(t,e,r,o){var i=this,a=(new L).registerSkipController(new z((function(){return t.logger.info("Displayable Transition","Skipped"),Xs(n,"executeAction",i,3)([t])}))),s=t.getExposedStateForce(e),u=e.transformState.clone(),c=s.applyTransform(r,(function(){null==o||o(),a.resolve(Xs(n,"executeAction",i,3)([t])),t.stage.next()})),l=t.timelines.attachTimeline(a).attachChild(c);return t.actionHistory.push(this,(function(t){a.isSettled()||a.abort(),e.transformState.forceOverwrite(t.state)}),[u],l),a}},{key:"applyTransition",value:function(t,e,r,o){var i=this,a=(new L).registerSkipController(new z((function(){return t.logger.info("Displayable Transition","Skipped"),Xs(n,"executeAction",i,3)([t])}))),s=t.getExposedStateForce(e).applyTransition(r,(function(){null==o||o(),a.resolve(Xs(n,"executeAction",i,3)([t])),t.stage.next()})),u=t.timelines.attachTimeline(a).attachChild(s);return t.actionHistory.push(this,void 0,[],u),a}},{key:"initDisplayable",value:function(t,e,r,o){var i=this,a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(!1!==a){var s=t.findElementByDisplayable(this.callee,o);s&&t.disposeDisplayable(r,s.scene,o),t.createDisplayable(r,e,o)}t.flush();var u=(new L).registerSkipController(new z((function(){return Xs(n,"executeAction",i,3)([t])})));t.getExposedStateAsync(r,(function(e){e.initDisplayable((function(){u.resolve(Xs(n,"executeAction",i,3)([t])),t.stage.next()}))}));var c=t.timelines.attachTimeline(u);return t.actionHistory.push(this,(function(){!1!==a&&t.findElementByDisplayable(r,o)&&t.disposeDisplayable(r,e,o)}),[],c),u}}],o&&$s(r.prototype,o),i&&$s(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(gt);function tu(t){return tu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tu(t)}function eu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ru(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ou(r.key),r)}}function ou(t){var e=function(t,e){if("object"!=tu(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=tu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==tu(e)?e:e+""}function iu(t,e,n){return e=uu(e),function(t,e){if(e&&("object"==tu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,au()?Reflect.construct(e,n||[],uu(t).constructor):e.apply(t,n))}function au(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(au=function(){return!!t})()}function su(){return su="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=uu(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},su.apply(null,arguments)}function uu(t){return uu=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},uu(t)}function cu(t,e){return cu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},cu(t,e)}Js.ActionTypes=e;var lu=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),iu(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&cu(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var n,r,o,i,a,u,c,l,f,h,p,d=this;if(this.type===s.play){var y=eu(this.contentNode.getContent(),1)[0],m=this.callee.toData(),v=L.forward(t.audioManager.play(this.callee,y),{type:this.type,node:null===(n=this.contentNode)||void 0===n?void 0:n.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(v),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[m]),v}if(this.type===s.stop){var g=eu(this.contentNode.getContent(),1)[0],b=this.callee.toData(),w=L.forward(t.audioManager.stop(this.callee,g.duration),{type:this.type,node:null===(r=this.contentNode)||void 0===r?void 0:r.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(w),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[b]),w}if(this.type===s.setVolume){var S=eu(this.contentNode.getContent(),2),k=S[0],x=S[1],_=this.callee.toData(),A=L.forward(t.audioManager.setVolume(this.callee,k,x),{type:this.type,node:null===(o=this.contentNode)||void 0===o?void 0:o.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(A),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[_]),A}if(this.type===s.setRate){var T=eu(this.contentNode.getContent(),1)[0],O=this.callee.toData(),E=L.forward(t.audioManager.setRate(this.callee,T),{type:this.type,node:null===(i=this.contentNode)||void 0===i?void 0:i.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(E),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[O]),E}if(this.type===s.pause){var j=eu(this.contentNode.getContent(),1)[0],P=this.callee.toData(),C=L.forward(t.audioManager.pause(this.callee,j.duration),{type:this.type,node:null===(a=this.contentNode)||void 0===a?void 0:a.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(C),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[P]),C}if(this.type===s.resume){var I=eu(this.contentNode.getContent(),1)[0],R=this.callee.toData(),D=L.forward(t.audioManager.resume(this.callee,I.duration),{type:this.type,node:null===(u=this.contentNode)||void 0===u?void 0:u.getChild()}).then((function(){return t.stage.next()}));return t.timelines.attachTimeline(D),t.actionHistory.push(this,(function(t){t&&d.callee.fromData(t)}),[R]),D}throw(c=e,l="unknownTypeError",f=this,p=su(uu(1&(h=3)?c.prototype:c),l,f),2&h&&"function"==typeof p?function(t){return p.apply(f,t)}:p)([])}}],r&&ru(n.prototype,r),o&&ru(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function fu(t){return fu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fu(t)}function hu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return pu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function du(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,yu(r.key),r)}}function yu(t){var e=function(t,e){if("object"!=fu(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=fu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==fu(e)?e:e+""}function mu(t,e,n){return e=gu(e),function(t,e){if(e&&("object"==fu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,vu()?Reflect.construct(e,n||[],gu(t).constructor):e.apply(t,n))}function vu(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(vu=function(){return!!t})()}function gu(t){return gu=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},gu(t)}function bu(t,e){return bu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},bu(t,e)}lu.ActionTypes=s;var wu=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=mu(this,e);var r="string"==typeof n?{src:n}:n,o=e.DefaultUserConfig.create(r),i=hu(o.extract(e.DefaultConfig.keys()),1)[0];return t.config=i.get(),t.state=t.getInitialState(o),t.userConfig=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&bu(t,e)}(e,t),n=e,o=[{key:"toSound",value:function(t){return null==t?null:"string"==typeof t?new e({src:t}):t}}],(r=[{key:"play",value:function(t){return this.pushAction(lu.ActionTypes.play,[{end:this.state.volume,duration:t||0}])}},{key:"stop",value:function(t){return this.pushAction(lu.ActionTypes.stop,[{end:0,duration:t||0}])}},{key:"setVolume",value:function(t,e){return this.pushAction(lu.ActionTypes.setVolume,[t,e||0])}},{key:"setRate",value:function(t){return this.pushAction(lu.ActionTypes.setRate,[t])}},{key:"pause",value:function(t){return this.pushAction(lu.ActionTypes.pause,[{end:0,duration:t||0}])}},{key:"resume",value:function(t){return this.pushAction(lu.ActionTypes.resume,[{end:this.state.volume,duration:t||0}])}},{key:"getSrc",value:function(){return this.config.src}},{key:"toData",value:function(){return{state:e.StateSerializer.serialize(this.state)}}},{key:"fromData",value:function(t){return this.state=e.StateSerializer.deserialize(t.state),this}},{key:"copy",value:function(){return new e(this.userConfig.get())}},{key:"reset",value:function(){this.state=this.getInitialState(this.userConfig)}},{key:"getInitialState",value:function(t){return e.DefaultState.create(Object.assign({},t.get())).get()}},{key:"pushAction",value:function(t,e){return this.chain(new lu(this.chain(),t,(new jt).setContent(e)))}}])&&du(n.prototype,r),o&&du(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);function Su(t){return function(t){if(Array.isArray(t))return ku(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ku(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ku(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ku(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function xu(t){return xu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xu(t)}function _u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Au(r.key),r)}}function Au(t){var e=function(t,e){if("object"!=xu(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=xu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==xu(e)?e:e+""}wu.noSound="data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgA",wu.DefaultUserConfig=new ha({src:wu.noSound,loop:!1,volume:1,streaming:!1,rate:1,seek:0}),wu.DefaultConfig=new ha({src:wu.noSound,loop:!1,streaming:!1,seek:0}),wu.DefaultState=new ha({volume:1,rate:1,paused:!1}),wu.StateSerializer=new X;var Tu=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.src=[],this.future=[]}return e=t,o=[{key:"catSrc",value:function(e){var n=new Set,r=new Set,o=new Set;return e.forEach((function(e){var i=e.type,a=e.src;i===t.SrcTypes.image?n.add(a):i===t.SrcTypes.video?r.add(a):o.add(a)})),{image:Array.from(n),video:Array.from(r),audio:Array.from(o)}}},{key:"getSrc",value:function(t){return"string"==typeof t?t:t instanceof qu?qu.getSrcURL(t):"image"===t.type?qu.getSrcURL(t.src):"video"===t.type?t.src:"audio"===t.type?t.src.getSrc():""}},{key:"getPreloadableSrc",value:function(t,e){var n;if(e.is(bc,r.jumpTo)){var o=e.contentNode.getContent()[0],i=t.getScene(o,!0).state.backgroundImage;if(Hc.isImageURL(i.config.src))return{type:"image",src:i.config.src,activeType:"once"}}else if(e instanceof sc){var s=e;if(e.is(sc,a.setSrc)){var u=e.contentNode.getContent()[0];if(Hc.isImageSrc(u))return{type:"image",src:Hc.srcToURL(u),activeType:"scene"}}else{if(e.type===a.initWearable)return{type:"image",src:e.contentNode.getContent()[0],activeType:"scene"};if(e.type===a.setAppearance){var c=e.contentNode.getContent()[0];if(!s.callee.config.src||"function"!=typeof(null===(n=s.callee.config.src)||void 0===n?void 0:n.resolve))throw s.callee._invalidSrcHandlerError();if(qu.isTagSrc(s.callee)&&c.length===s.callee.config.src.groups.length)return{type:"image",src:qu.getSrcFromTags(c,s.callee.config.src.resolve),activeType:"scene"}}}}return null}}],(n=[{key:"register",value:function(t,e){var n=this;if(Array.isArray(t))t.forEach((function(t){return n.register(t)}));else if(t instanceof wu){if(this.isSrcRegistered(t.getSrc()))return this;this.src.push({type:"audio",src:t})}else if(t instanceof qu||Hc.isStaticImageData(t)){if(t instanceof qu){if(!Hc.isImageURL(t.state.currentSrc))return this;if(this.isSrcRegistered(qu.getSrcURL(t)))return this}else if(this.isSrcRegistered(Hc.srcToURL(t.src)))return this;this.src.push({type:"image",src:Hc.isStaticImageData(t)?Hc.srcToURL(t):t.state.currentSrc})}else if("object"===xu(t)){if(this.isSrcRegistered(t.src||""))return this;this.src.push(t)}else if("audio"===t){if(this.isSrcRegistered(e||""))return this;this.src.push({type:t,src:e instanceof wu?e:new wu({src:e})})}else{if(this.isSrcRegistered(e||""))return this;this.src.push({type:t,src:e})}return this}},{key:"registerRawSrc",value:function(t){return this.isSrcRegistered(t)||this.src.push({type:"image",src:t}),this}},{key:"isSrcRegistered",value:function(e){if(!e)return!1;var n=e instanceof wu?e.getSrc():e;return this.src.some((function(e){return e.type===t.SrcTypes.audio?n===e.src.getSrc():e.type===t.SrcTypes.image?n===qu.getSrcURL(e.src):n===e.src}))}},{key:"getSrc",value:function(){return Su(this.src)}},{key:"getSrcByType",value:function(t){return this.src.filter((function(e){return e.type===t}))}},{key:"registerFuture",value:function(t){return this.future.includes(t)||this.hasFuture(t)||this.future.push(t),this}},{key:"hasFuture",value:function(t){return this.future.includes(t)}},{key:"getFutureSrc",value:function(){return this.future.map((function(t){return t.getSrc()})).flat(2)}}])&&_u(e.prototype,n),o&&_u(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}();function Ou(t){return Ou="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ou(t)}function Eu(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ju(r.key),r)}}function ju(t){var e=function(t,e){if("object"!=Ou(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ou(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ou(e)?e:e+""}function Pu(t,e,n){return e=Iu(e),function(t,e){if(e&&("object"==Ou(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Cu()?Reflect.construct(e,n||[],Iu(t).constructor):e.apply(t,n))}function Cu(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Cu=function(){return!!t})()}function Iu(t){return Iu=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Iu(t)}function Ru(t,e){return Ru=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ru(t,e)}Tu.SrcTypes={image:"image",video:"video",audio:"audio"};var Du=function(t){function n(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),(t=Pu(this,n,arguments)).srcManager=new Tu,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ru(t,e)}(n,t),r=n,(o=[{key:"pos",value:function(t,e,n){return this.transform(new Ta({position:t},{duration:e,ease:n}))}},{key:"scale",value:function(t,e,n){return this.transform(new Ta({scale:t},{duration:e,ease:n}))}},{key:"rotate",value:function(t,e,n){return this.transform(new Ta({rotation:t},{duration:e,ease:n}))}},{key:"opacity",value:function(t,e,n){return this.transform(new Ta({opacity:t},{duration:e,ease:n}))}},{key:"transform",value:function(t){var n=this.chain(),r=new Js(n,e.applyTransform,(new jt).setContent([t.copy()]));return n.chain(r)}},{key:"show",value:function(t){var n=this.chain(),r=t instanceof Ta?t.copy():new Ta({opacity:1},t),o=new Js(n,e.applyTransform,(new jt).setContent([r]));return n.chain(o)}},{key:"hide",value:function(t){var n=this.chain(),r=t instanceof Ta?t.copy():new Ta({opacity:0},t),o=new Js(n,e.applyTransform,(new jt).setContent([r]));return n.chain(o)}}])&&Eu(r.prototype,o),i&&Eu(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(Rs);function Lu(t){return Lu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lu(t)}function Mu(t){return function(t){if(Array.isArray(t))return Uu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Bu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Bu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fu(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Bu(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Bu(t,e){if(t){if("string"==typeof t)return Uu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Uu(t,e):void 0}}function Uu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Vu(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zu(r.key),r)}}function zu(t){var e=function(t,e){if("object"!=Lu(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Lu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Lu(e)?e:e+""}function Gu(t,e,n){return e=$u(e),function(t,e){if(e&&("object"==Lu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Hu()?Reflect.construct(e,n||[],$u(t).constructor):e.apply(t,n))}function Hu(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Hu=function(){return!!t})()}function $u(t){return $u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$u(t)}function Wu(t,e){return Wu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wu(t,e)}var qu=function(t){function n(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),t=Gu(this,n);var r=n.DefaultUserConfig.create(e),o=t.createImageConfig(r);return t.userConfig=r,t.config=o.get(),t.state=t.getInitialState(),t.transformState=t.getInitialTransformState(r),t.checkConfig().registerSrc(),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wu(t,e)}(n,t),r=n,o=[{key:"char",value:function(t,e){var n=this;return this.combineActions(new Vs,(function(r){if(Hc.isImageSrc(t)||Hc.isColor(t)){if(Hc.isColor(t)&&!n.config.isBackground)throw new Error("Color src is not allowed for non-background image");return r.chain(n._setSrc(r,t,e))}var o=new sc(r,sc.ActionTypes.setAppearance,(new jt).setContent([t,null==e?void 0:e.copy()]));return r.chain(o).chain(n._flush())}))}},{key:"addWearable",value:function(t){var e,n=Fu(Array.isArray(t)?t:[t]);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r===this)throw new qc("Cannot add self as a wearable");this.config.wearables.push(r),Object.assign(r.config,{isWearable:!0})}}catch(t){n.e(t)}finally{n.f()}return this}},{key:"wear",value:function(t){return this.addWearable(t)}},{key:"bindWearable",value:function(t){return t.addWearable([this])}},{key:"asWearableOf",value:function(t){return this.bindWearable(t)}},{key:"useLayer",value:function(t){return this.userConfig.get().layer=t||void 0,Object.assign(this.config,{layer:t||void 0}),this}},{key:"toData",value:function(){return{state:n.StateSerializer.serialize(this.state),transformState:Aa.TransformStateSerializer.serialize(this.transformState.get())}}},{key:"fromData",value:function(t){return this.state=n.StateSerializer.deserialize(t.state),this.transformState=Aa.deserialize(t.transformState),this}},{key:"_applyTransition",value:function(t,n){return new Js(this.chain(),e.applyTransition,(new jt).setContent([t,n]))}},{key:"_init",value:function(t,n){return new Js(this.chain(),e.init,(new jt).setContent([t,n||this.config.layer||null]))}},{key:"_initWearable",value:function(t){return new sc(this.chain(),sc.ActionTypes.initWearable,(new jt).setContent([t]))}},{key:"_flush",value:function(){return new sc(this.chain(),sc.ActionTypes.flush,new jt)}},{key:"reset",value:function(){return this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(this.userConfig),this}},{key:"resolveTags",value:function(t,e){if(!n.isTagSrc(this))throw new Error("Tag not defined\nTag must be defined in the image config");var r=this.constructTagMap(this.config.src.groups),o=new Map,i=[];this.config.src.groups.forEach((function(t){o.set(t,null)}));var a=function(t){t.forEach((function(t){var e=r.get(t);e&&o.set(e,t)}))};return a(t),a(e),this.config.src.groups.forEach((function(t){var e=o.get(t);if(!e)throw new Error('Invalid Tag Group. Tag group "'.concat(t.join(", "),'" is not resolved'));i.push(e)})),i}},{key:"_mixedSrcError",value:function(){throw new qc("Trying to mix src and tags \nTo better understand the behavior of the image, you cannot mix static src and tags in the same image. ")}},{key:"_invalidSrcHandlerError",value:function(){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")}},{key:"_invalidWearableError",value:function(t){throw new Error("Invalid wearable\nWearable must be an Image with isWearable set to true\nIt seems like you are trying to add a non-wearable image to wearables\nImage below violates the rule:\n"+t)}},{key:"_invalidTagGroupDefinitionError",value:function(){throw new Error("Invalid tag group definition. Tags in groups must be unique and not conflicting with each other.")}},{key:"_setSrc",value:function(t,e,n){var r=this;return n&&t.chain(this._applyTransition(n.copy(),(function(t){return t._setPrevSrc(sc.resolveCurrentSrc(r))._setTargetSrc(e)}))),new sc(t,sc.ActionTypes.setSrc,(new jt).setContent([e]))}},{key:"_setIsBackground",value:function(t){return Object.assign(this.config,{isBackground:t}),this}},{key:"registerSrc",value:function(){return n.isTagSrc(this)?this.srcManager.registerRawSrc(n.getSrcFromTags(this.config.src.defaults,this.config.src.resolve)):Hc.isImageSrc(this.state.currentSrc)&&this.srcManager.registerRawSrc(Hc.srcToURL(this.state.currentSrc)),this}},{key:"createImageConfig",value:function(t){var e=t.get();return n.DefaultImageConfig.create(Object.assign(Object.assign({},e),{src:n.isTagDefinition(e.src)?e.src:null}))}},{key:"getInitialState",value:function(){return n.DefaultImageState.create().assign({currentSrc:n.getInitialSrc(this.userConfig.get())}).get()}},{key:"getInitialTransformState",value:function(t){var e=Nu(t.extract(Aa.DefaultTransformState.keys()),1)[0];return new Aa(Aa.DefaultTransformState.create(e.get()).get())}},{key:"checkConfig",value:function(){var t,e,r=Fu(this.config.wearables);try{for(r.s();!(e=r.n()).done;){var o=e.value;if(!o.config.isWearable)throw this._invalidWearableError(JSON.stringify(o.config))}}catch(t){r.e(t)}finally{r.f()}if(n.isTagSrc(this)){var i,a=this.config.src,s=new Set,u=Fu(a.groups);try{for(u.s();!(i=u.n()).done;){var c,l=Fu(i.value);try{for(l.s();!(c=l.n()).done;){var f=c.value;if(s.has(f))throw this._invalidTagGroupDefinitionError();s.add(f)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){u.e(t)}finally{u.f()}var h,p=this.constructTagMap(a.groups),d=new Set,y=Fu(a.defaults);try{for(y.s();!(h=y.n()).done;){var m=h.value;if(d.has(m))throw new Error('Tag conflict\nTag "'.concat(m,'" is conflicting with another tag\nError found in config.tag.defaults'));if(!p.has(m))throw new Error('Tag not found\nTag "'.concat(m,'" is not defined in tagDefinitions\nError found in config.tag.defaults'));null===(t=p.get(m))||void 0===t||t.forEach((function(t){return d.add(t)}))}}catch(t){y.e(t)}finally{y.f()}}return this}},{key:"constructTagMap",value:function(t){var e,n=new Map,r=Fu(t);try{for(r.s();!(e=r.n()).done;){var o,i=e.value,a=Fu(i);try{for(a.s();!(o=a.n()).done;){var s=o.value;n.set(s,i)}}catch(t){a.e(t)}finally{a.f()}}}catch(t){r.e(t)}finally{r.f()}return n}}],i=[{key:"getInitialSrc",value:function(t){if(this.isTagDefinition(t.src))return Mu(t.src.defaults);var e=t.src;return Hc.isStaticImageData(e)?Hc.srcToURL(e):Hc.isColor(e)?e:Hc.isImageSrc(e)?Hc.srcToURL(e):n.DefaultImagePlaceholder}},{key:"isTagSrc",value:function(t){return!!t.config.src}},{key:"isTagDefinition",value:function(t){return"object"===Lu(t)&&null!==t&&!Hc.isImageSrc(t)&&!Hc.isColor(t)&&"defaults"in t}},{key:"isStaticSrc",value:function(t){var e=t.userConfig.get().src;return!this.isTagSrc(t)&&(Hc.isImageSrc(e)||Hc.isColor(e))}},{key:"getSrcURL",value:function(t){return"string"==typeof t?t:n.isTagSrc(t)?n.getSrcFromTags(t.state.currentSrc,t.config.src.resolve):n.isStaticSrc(t)?Hc.isStaticImageData(t.state.currentSrc)?Hc.srcToURL(t.state.currentSrc):Hc.isColor(t.state.currentSrc)?null:t.state.currentSrc:null}},{key:"getSrcFromTags",value:function(t,e){return e.apply(void 0,Mu(t))}},{key:"fromSrc",value:function(t){return new n({src:t})}}],o&&Vu(r.prototype,o),i&&Vu(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(Du);function Yu(t){return Yu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yu(t)}function Xu(t){return function(t){if(Array.isArray(t))return Qu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Zu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ku(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Zu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zu(t,e){if(t){if("string"==typeof t)return Qu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qu(t,e):void 0}}function Qu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ju(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,tc(r.key),r)}}function tc(t){var e=function(t,e){if("object"!=Yu(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Yu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Yu(e)?e:e+""}function ec(t,e,n){return e=ic(e),function(t,e){if(e&&("object"==Yu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,nc()?Reflect.construct(e,n||[],ic(t).constructor):e.apply(t,n))}function nc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(nc=function(){return!!t})()}function rc(t,e,n,r){var o=oc(ic(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function oc(){return oc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ic(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},oc.apply(null,arguments)}function ic(t){return ic=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ic(t)}function ac(t,e){return ac=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ac(t,e)}qu.DefaultImagePlaceholder="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/6Vf9WYAAAAASUVORK5CYII=",qu.StateSerializer=new X,qu.DefaultUserConfig=new ha(Object.assign({name:"(anonymous)",autoInit:!0,src:qu.DefaultImagePlaceholder,autoFit:!1,layer:void 0},Aa.DefaultTransformState.getDefaultConfig()),{position:function(t){return Ji.tryParsePosition(t)}}),qu.DefaultImageConfig=new ha({wearables:[],isWearable:!1,name:"(anonymous)",autoInit:!0,src:null,autoFit:!1,layer:void 0,isBackground:!1}),qu.DefaultImageState=new ha({currentSrc:qu.DefaultImagePlaceholder});var sc=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ec(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ac(t,e)}(e,t),n=e,o=[{key:"resolveTagSrc",value:function(t,e){if(!qu.isTagSrc(t))throw t._mixedSrcError();var n=t.state.currentSrc,r=t.resolveTags(n,e);return qu.getSrcFromTags(r,t.config.src.resolve)}},{key:"resolveCurrentSrc",value:function(t){if(qu.isStaticSrc(t))return Hc.isImageSrc(t.state.currentSrc)?Hc.srcToURL(t.state.currentSrc):t.state.currentSrc;if(qu.isTagSrc(t))return qu.getSrcFromTags(t.state.currentSrc,t.config.src.resolve);throw t._mixedSrcError()}}],(r=[{key:"executeAction",value:function(t){var n=this;if(this.type===a.initWearable){var r=Ku(this.contentNode.getContent(),1)[0],o=t.getExposedStateForce(this.callee),i=new L((function(t){return t}));return o.createWearable(r),t.getExposedStateAsync(r,(function(r){r.initDisplayable((function(){i.resolve(rc(e,"executeAction",n,3)([t])),t.stage.next()}))})),t.actionHistory.push(this,(function(t){o.disposeWearable(t)}),[r]),i}if(this.type===a.setSrc){var s=this.contentNode.getContent()[0];if(Hc.isColor(s)&&!this.callee.config.isBackground)throw new qc("Color src is not allowed for non-background image");var u=this.callee.state.currentSrc;return this.callee.state.currentSrc=s,t.logger.debug("Image Set Src",s),t.actionHistory.push(this,(function(t){n.callee.state.currentSrc=t}),[u]),t.stage.update(),rc(e,"executeAction",this,3)([t])}if(this.type===a.flush)return rc(e,"executeAction",this,3)([t]);if(this.type===a.setAppearance){var c=Ku(this.contentNode.getContent(),2),l=c[0],f=c[1];if(!qu.isTagSrc(this.callee))throw this.callee._mixedSrcError();var h=this.callee.state.currentSrc,p=this.callee.resolveTags(h,l),d=Xu(h),y=qu.getSrcFromTags(p,this.callee.config.src.resolve),m=function(){n.callee.state.currentSrc=d};if(t.logger.debug("Image - Set Appearance",p,y),f){var v=new L((function(t){return t})).registerSkipController(new z((function(){return rc(e,"executeAction",n,3)([t])})));f._setPrevSrc(e.resolveCurrentSrc(this.callee))._setTargetSrc(y),t.getExposedStateForce(this.callee).applyTransition(f,(function(){n.callee.state.currentSrc=p,v.resolve(rc(e,"executeAction",n,3)([t])),t.stage.next()}));var g=t.timelines.attachTimeline(v);return t.actionHistory.push(this,m,[],g),v}return this.callee.state.currentSrc=p,t.actionHistory.push(this,m),rc(e,"executeAction",this,3)([t])}throw rc(e,"unknownTypeError",this,3)([])}}])&&Ju(n.prototype,r),o&&Ju(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function uc(t){return uc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uc(t)}function cc(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return lc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?lc(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function fc(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,hc(r.key),r)}}function hc(t){var e=function(t,e){if("object"!=uc(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=uc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==uc(e)?e:e+""}function pc(t,e,n){return e=vc(e),function(t,e){if(e&&("object"==uc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,dc()?Reflect.construct(e,n||[],vc(t).constructor):e.apply(t,n))}function dc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(dc=function(){return!!t})()}function yc(t,e,n,r){var o=mc(vc(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function mc(){return mc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=vc(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},mc.apply(null,arguments)}function vc(t){return vc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vc(t)}function gc(t,e){return gc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},gc(t,e)}sc.ActionTypes=a;var bc=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),pc(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&gc(t,e)}(e,t),n=e,o=[{key:"applyTransition",value:function(t,n){var r=this,o=(new L).registerSkipController(new z((function(){return t.logger.info("Background Transition","Skipped"),yc(e,"executeAction",r,3)([t])})));return t.getExposedStateForce(this.callee.background).applyTransition(n,(function(){o.resolve(yc(e,"executeAction",r,3)([t])),t.stage.next()})),t.timelines.attachTimeline(o),o}},{key:"exit",value:function(t){t.offSrcManager(this.callee.srcManager).removeScene(this.callee),this.callee.state.backgroundImage.reset()}},{key:"executeAction",value:function(t){var n=this;if(this.type===r.action)return yc(e,"executeAction",this,3)([t]);if(this.is(e,"scene:init")){var o=new L((function(t){return t})),i=t.timelines.attachTimeline(o);return t.actionHistory.push(this,(function(){n.exit(t)}),[],i),e.handleSceneInit(this.callee,{type:this.type,node:this.contentNode.getChild()},t,o)}if(this.type===r.exit){var a=e.createSceneSnapshot(this.callee,t);return t.actionHistory.push(this,(function(r){var o=new L((function(t){return t}));t.timelines.attachTimeline(o),e.handleSceneInit(n.callee,{type:n.type,node:n.contentNode.getChild()},t,o),e.restoreSceneSnapshot(r,t)}),[a]),t.getStorable().removeNamespace(this.callee.local.getNamespaceName()),this.exit(t),yc(e,"executeAction",this,3)([t])}if(this.type===r.jumpTo){var s=this.contentNode.getContent()[0],u=this.contentNode,c=t.getStory().getScene(s);if(!c)throw this._sceneNotFoundError(this.getSceneName(s));var l=c.getSceneRoot().contentNode;return l&&u.addChild(l),{type:this.type,node:l}}if(this.type===r.setBackgroundMusic){var f=cc(this.contentNode.getContent(),2),h=f[0],p=f[1],d=this.callee,y=t.getExposedStateForce(d),m=d.state.backgroundMusic;return t.actionHistory.push(this,(function(t){t&&y.setBackgroundMusic(t,0)}),[m]),y.setBackgroundMusic(h,p||0),yc(e,"executeAction",this,3)([t])}if(this.type===r.preUnmount)return this.callee.events.emit("event:scene.preUnmount"),yc(e,"executeAction",this,3)([t]);if(this.type===r.transitionToScene){var v=cc(this.contentNode.getContent(),3),g=v[0],b=v[1],w=v[2];return g._setPrevSrc(sc.resolveCurrentSrc(this.callee.background)),b?g._setTargetSrc(sc.resolveCurrentSrc(b.background)):w&&g._setTargetSrc(w),this.applyTransition(t,g)}throw new Error("Unknown scene action type: "+this.type)}},{key:"getFutureActions",value:function(t){var e,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.type===r.jumpTo&&!1!==o.allowFutureScene){var i=this.contentNode.getContent()[0],a=t.getScene(i,!0);a.isSceneRootConstructed()||a.constructSceneRoot(t);var s=null===(e=t.getScene(i,!0).getSceneRoot())||void 0===e?void 0:e.contentNode;return(null==s?void 0:s.action)?[s.action]:[]}var u=null===(n=this.contentNode.getChild())||void 0===n?void 0:n.action;return u?[u]:[]}},{key:"_sceneNotFoundError",value:function(t){return new qc("Scene with name ".concat(t," not found")+"\nMake sure you have registered the scene using story.register"+"\nAction: (id: ".concat(this.getId(),") ").concat(this.type)+"\nAt: ".concat(this.__stack))}},{key:"getSceneName",value:function(t){return"string"==typeof t?t:t.config.name}}],i=[{key:"handleSceneInit",value:function(t,n,r,o){return r.isSceneActive(t)?n:(r.registerSrcManager(t.srcManager).addScene(t).flush(),t.local.init(r.getStorable()),r.getExposedStateAsync(t,(function(i){e.initBackgroundMusic(t,i),o.resolve(n),r.stage.next(),r.logger.debug("Scene Action","Scene init")})),o)}},{key:"initBackgroundMusic",value:function(t,e){t.state.backgroundMusic&&e.setBackgroundMusic(t.state.backgroundMusic,t.config.backgroundMusicFade)}},{key:"createSceneSnapshot",value:function(t,e){var n=e.findElementByScene(t);if(!n)throw new qc("Scene not found when creating snapshot (scene: "+t.getId()+")");return{state:t.toData(),local:t.local.getNamespace(e.getStorable()).toData(),element:e.createElementSnapshot(n),background:t.background.toData()}}},{key:"restoreSceneSnapshot",value:function(t,e){var n=t.element.scene,r=e.findElementByScene(n);r&&e.removeElement(r);var o=e.fromElementSnapshot(t.element);e.addElement(o),n.local.getNamespace(e.getStorable()).load(t.local),t.state&&n.fromData(t.state),t.background&&n.background.fromData(t.background)}}],o&&fc(n.prototype,o),i&&fc(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,i}(gt);function wc(t){return wc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wc(t)}function Sc(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,kc(r.key),r)}}function kc(t){var e=function(t,e){if("object"!=wc(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=wc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wc(e)?e:e+""}bc.ActionTypes=r;var xc=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e}return e=t,r=[{key:"from",value:function(e){return t.isPauseConstructor(e)?new t:e}},{key:"wait",value:function(e){return new t({duration:e})}},{key:"isPause",value:function(e){return this.isPauseConstructor(e)||e instanceof t}},{key:"isPauseConstructor",value:function(e){return e===t}}],(n=null)&&Sc(e.prototype,n),r&&Sc(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function _c(t){return _c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_c(t)}function Ac(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Tc(r.key),r)}}function Tc(t){var e=function(t,e){if("object"!=_c(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=_c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_c(e)?e:e+""}var Oc=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.text=e,this.config=D(t.defaultConfig,n)}return e=t,r=[{key:"isWord",value:function(e){return e instanceof t}},{key:"color",value:function(e,n){return t.isWord(e)?e.copy().inherit({color:n}):new t(e,{color:n})}},{key:"bold",value:function(e){return t.isWord(e)?e.copy().inherit({bold:!0}):new t(e,{bold:!0})}},{key:"italic",value:function(e){return t.isWord(e)?e.copy().inherit({italic:!0}):new t(e,{italic:!0})}},{key:"getText",value:function(t){return t.filter((function(t){return!t.isPause()})).map((function(t){return t.toString()})).join("")}}],(n=[{key:"evaluate",value:function(e){var n=this;if(xc.isPause(this.text))return[this];if("function"==typeof this.text){var r=this.text(e);return Array.isArray(r)?r.map((function(r){return t.isWord(r)?r.inherit(n.config).evaluate(e):new t(r,n.config)})).flat():t.isWord(r)?r.inherit(this.config).evaluate(e):[new t(r,this.config)]}return[this]}},{key:"inherit",value:function(t){var e,n,r;return this.config.color=this.config.color||t.color,this.config.italic=null!==(e=this.config.italic)&&void 0!==e?e:t.italic,this.config.bold=null!==(n=this.config.bold)&&void 0!==n?n:t.bold,this.config.cps=null!==(r=this.config.cps)&&void 0!==r?r:t.cps,this}},{key:"copy",value:function(){return new t(this.text,this.config)}},{key:"isPause",value:function(){return xc.isPause(this.text)}},{key:"toString",value:function(){return"string"==typeof this.text?this.text:""}}])&&Ac(e.prototype,n),r&&Ac(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Ec(t){return function(t){if(Array.isArray(t))return Nc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Mc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jc(t,e,n){return e=Dc(e),function(t,e){if(e&&("object"==Fc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ic()?Reflect.construct(e,n||[],Dc(t).constructor):e.apply(t,n))}function Pc(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rc(t,e)}function Cc(t){var e="function"==typeof Map?new Map:void 0;return Cc=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(Ic())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var o=new(t.bind.apply(t,r));return n&&Rc(o,n.prototype),o}(t,arguments,Dc(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Rc(n,t)},Cc(t)}function Ic(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ic=function(){return!!t})()}function Rc(t,e){return Rc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rc(t,e)}function Dc(t){return Dc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Dc(t)}function Lc(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Mc(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mc(t,e){if(t){if("string"==typeof t)return Nc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nc(t,e):void 0}}function Nc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Fc(t){return Fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fc(t)}function Bc(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Uc(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zc(r.key),r)}}function Vc(t,e,n){return e&&Uc(t.prototype,e),n&&Uc(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function zc(t){var e=function(t,e){if("object"!=Fc(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Fc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Fc(e)?e:e+""}Oc.defaultConfig={},Oc.defaultColor="#000";var Gc=function(){function t(e,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Bc(this,t),this.r=e,this.g=n,this.b=r,this.a=o}return Vc(t,[{key:"toString",value:function(){return"rgba(".concat(this.r,", ").concat(this.g,", ").concat(this.b,", ").concat(this.a,")")}},{key:"toHex",value:function(){return"#"+this.r.toString(16)+this.g.toString(16)+this.b.toString(16)}}],[{key:"isHexString",value:function(t){return"string"==typeof t&&/^#[0-9A-F]{6}$/i.test(t)}},{key:"fromHex",value:function(e){var n=e.slice(1);return new t(parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),8===n.length?parseInt(n.slice(6,8),16)/255:1)}}])}(),Hc=function(){function t(){Bc(this,t)}return Vc(t,null,[{key:"srcToURL",value:function(t){return"string"==typeof t?t:t.src}},{key:"staticImageDataToSrc",value:function(t){return"string"==typeof t?t:t.src}},{key:"isStaticImageData",value:function(t){return void 0!==(null==t?void 0:t.src)&&"string"==typeof t.src}},{key:"isExternalSrc",value:function(t){return t.startsWith("http://")||t.startsWith("https://")}},{key:"isImageSrc",value:function(e){return"string"==typeof e&&!this.isColor(e)||t.isStaticImageData(e)}},{key:"isImageURL",value:function(t){return"string"==typeof t&&!this.isColor(t)}},{key:"isColor",value:function(e){return t.isHexString(e)||t.isNamedColor(e)||t.isRGBAColor(e)}},{key:"isNamedColor",value:function(t){return function(t){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(t)}(t)}},{key:"isRGBAColor",value:function(t){return t&&"object"===Fc(t)&&"r"in t&&"g"in t&&"b"in t}},{key:"RGBAColorToHex",value:function(t){var e=t.r.toString(16).padStart(2,"0"),n=t.g.toString(16).padStart(2,"0"),r=t.b.toString(16).padStart(2,"0"),o=t.a?Math.round(255*t.a).toString(16).padStart(2,"0"):"";return"#".concat(e).concat(n).concat(r).concat(o)}},{key:"colorToString",value:function(e){if(t.isHexString(e))return e;if(t.isNamedColor(e))return e;if(t.isRGBAColor(e))return t.RGBAColorToHex(e);throw new Error("Unknown color type")}},{key:"isHexString",value:function(t){return"string"==typeof t&&/^#([0-9A-F]{3}|[0-9A-F]{6}|[0-9A-F]{4}|[0-9A-F]{8})$/i.test(t)}},{key:"toBackgroundSrc",value:function(t){return"string"==typeof t?t:t.src}},{key:"isDataURI",value:function(t){return t.startsWith("data:")}},{key:"offset",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{invertX:!1,invertY:!1},r=Lc(t,2),o=r[0],i=r[1],a=Lc(e,2),s=a[0],u=a[1],c=this.calc(o,s),l=this.calc(i,u),f=n.invertX?{right:c}:{left:c},h=n.invertY?{bottom:l}:{top:l};return Object.assign(Object.assign({left:"auto",right:"auto",top:"auto",bottom:"auto"},f),h)}},{key:"calc",value:function(t,e){var n="string"==typeof t?t:"".concat(t,"px");if(void 0===e)return"calc(".concat(n," + 0px)");var r="string"==typeof e?"+":e<0?"-":"+",o="string"==typeof e?e:"".concat(Math.abs(e),"px");return"calc(".concat(n," ").concat(r," ").concat(o,")")}},{key:"formatLength",value:function(t){return"number"==typeof t?"".concat(t,"px"):t}},{key:"toPixel",value:function(t){return"number"==typeof t?t:parseFloat(t)}}])}();Hc.RGBColor=Gc;var $c=function(t){function e(t,n){return Bc(this,e),jc(this,e,[t,{info:n},"StaticScriptWarning"])}return Pc(e,t),Vc(e,null,[{key:"isWarning",value:function(t){return t instanceof e}}])}(function(t){function e(t,n){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"UseError";return Bc(this,e),(r=jc(this,e,[t])).props=n,r.name=o,r}return Pc(e,t),Vc(e,null,[{key:"isUseError",value:function(t){return t instanceof e}}])}(Cc(Error))),Wc=function(){return Vc((function t(e){Bc(this,t),this.scene=e}),[{key:"run",value:function(t){var e=new Map,n=new Map,r=[],o=new Set,i=this.scene.getAllChildren(t,this.scene.getSceneRoot());if(!i.length)return null;for(r.push(i[0]);r.length;){var a=r.shift();this.checkAction(t,a,{imageStates:e,scenes:n},o);var s=a.contentNode.getChild();s&&s.action&&r.push(s.action)}return e}},{key:"checkAction",value:function(t,e,n,o){var i=n.imageStates,a=n.scenes;if(e instanceof sc)i.has(e.callee)||i.set(e.callee,{isDisposed:!1,usedExternalSrc:!1}),this.checkImage(i.get(e.callee),e);else if(e instanceof bc){var s=e.callee;if(a.has(s.config.name)){if(a.get(s.config.name)!==s){var u="Scene with name: ".concat(s.config.name," is duplicated\nScene: ").concat(s.config.name,"\n\nAt: ").concat(e.__stack);throw new $c(u)}}else a.set(s.config.name,s);if(e.type===r.jumpTo){var c=e.contentNode.getContent()[0],l=t.getScene(c,!0);if(o.has(l))return;o.add(l)}}}},{key:"checkImage",value:function(t,e){if(e.type===a.setSrc){var n=e.contentNode.getContent()[0];Hc.isImageURL(n)&&Hc.isExternalSrc(n)&&(t.usedExternalSrc=!0)}}}])}(),qc=function(t){function e(t,n){var r;return Bc(this,e),(r=jc(this,e,[e.toMessage(t,n)])).name="RuntimeScriptError",r}return Pc(e,t),Vc(e,null,[{key:"toMessage",value:function(t,n){var r=[];return r.push.apply(r,Ec(Array.isArray(t)?t:[t])),n&&r.push.apply(r,Ec(Array.isArray(n)?n.map(e.getActionTrace):[e.getActionTrace(n)])),r.join("")}},{key:"getActionTrace",value:function(t){return"\nUsing action (id: ".concat(t.getId(),")")+"\n at: ".concat(t.__stack)}}])}(Cc(Error)),Yc=function(t){function e(t){var n;return Bc(this,e),(n=jc(this,e,[t])).name="RuntimeGameError",n}return Pc(e,t),Vc(e)}(Cc(Error)),Xc=function(t){function e(t){var n;return Bc(this,e),(n=jc(this,e,[t])).name="RuntimeInternalError",n}return Pc(e,t),Vc(e)}(Cc(Error));function Kc(t,e){return Oc.color(t,e)}function Zc(t){return Oc.bold(t)}function Qc(t){return Oc.italic(t)}function Jc(t){return Jc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jc(t)}function tl(t){return function(t){if(Array.isArray(t))return el(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return el(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?el(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function el(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function nl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,rl(r.key),r)}}function rl(t){var e=function(t,e){if("object"!=Jc(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Jc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Jc(e)?e:e+""}var ol=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.text=t.format(e),this.config=D(t.defaultConfig,Object.assign(Object.assign({},n),{voice:wu.toSound(n.voice)})),this.state=M(t.defaultState)}return e=t,r=[{key:"isSentence",value:function(e){return e instanceof t}},{key:"toSentence",value:function(e){return t.isSentence(e)?e:new t(e)}},{key:"format",value:function(t){var e=[];if(Array.isArray(t))for(var n=0;n<t.length;n++)e.push(this.formatWord(t[n]));else e.push(this.formatWord(t));return e}},{key:"formatWord",value:function(t){return Oc.isWord(t)?t:new Oc(t)}},{key:"formatStaticWord",value:function(t,e){var n=this;return Array.isArray(t)?t.map((function(t){return n.formatStaticWord(t,e)})).flat(2):[Oc.isWord(t)?t:new Oc(t,e)]}},{key:"isSentencePrompt",value:function(e){return Array.isArray(e)?e.every(t.isSingleWord):t.isSingleWord(e)}},{key:"isSingleWord",value:function(t){return"string"==typeof t||Oc.isWord(t)||xc.isPause(t)||"function"==typeof t}}],(n=[{key:"toData",value:function(){return V(this.state,t.defaultState)?null:{state:M(this.state)}}},{key:"fromData",value:function(t){return this.state=D(this.state,t),this}},{key:"toString",value:function(){return this.text.map((function(t){return t.text})).join("")}},{key:"setCharacter",value:function(t){return this.config.character=t,this}},{key:"evaluate",value:function(e){for(var n=[],r=0;r<this.text.length;r++){var o=this.text[r].evaluate(e);n.push.apply(n,tl(t.formatStaticWord(o)))}return n}},{key:"copy",value:function(){return new t(tl(this.text),this.config)}}])&&nl(e.prototype,n),r&&nl(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function il(t){return il="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},il(t)}function al(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,sl(r.key),r)}}function sl(t){var e=function(t,e){if("object"!=il(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=il(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==il(e)?e:e+""}function ul(t,e,n){return e=hl(e),function(t,e){if(e&&("object"==il(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,cl()?Reflect.construct(e,n||[],hl(t).constructor):e.apply(t,n))}function cl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(cl=function(){return!!t})()}function ll(t,e,n,r){var o=fl(hl(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function fl(){return fl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=hl(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},fl.apply(null,arguments)}function hl(t){return hl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},hl(t)}function pl(t,e){return pl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},pl(t,e)}ol.defaultConfig={pause:!0,voice:null,character:null,voiceId:null},ol.defaultState={display:!0};var dl=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ul(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&pl(t,e)}(e,t),r=e,i=[{key:"getVoice",value:function(t,e){var n=t.getLastScene();if(!n)throw new Error("No scene found when trying to play voice");var r=e.config,o=r.voiceId,i=r.voice;return o||i?wu.toSound(n.getVoice(o)||i):null}}],(o=[{key:"executeAction",value:function(t){var r=this;if(this.type===n.say){var o=new L((function(t){return t})).registerSkipController(new z((function(){c.cancel()}))),i=new Ya(o),a=this.contentNode.getContent(),s=e.getVoice(t,a);if(s){var u=t.audioManager.play(s);i.attachChild(u)}var c=t.createDialog(this.getId(),a,(function(){if(s){var e=t.audioManager.stop(s);i.attachChild(e)}o.resolve({type:r.type,node:r.contentNode.getChild()})}));t.timelines.attachTimeline(i);var l=t.actionHistory.push(this,(function(){if(s&&t.audioManager.isPlaying(s)){var e=t.audioManager.stop(s);i.attachChild(e)}})).id;return t.gameHistory.push({token:l,action:this,element:{type:"say",text:c.text,voice:s?s.getSrc():null}}),o}if(this.type===n.setName){var f=this.callee.state.name;return this.callee.state.name=this.contentNode.getContent()[0],t.actionHistory.push(this,(function(t){r.callee.state.name=t}),[f]),ll(e,"executeAction",this,3)([t])}throw ll(e,"unknownTypeError",this,3)([])}}])&&al(r.prototype,o),i&&al(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(gt);function yl(t){return yl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yl(t)}function ml(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,vl(r.key),r)}}function vl(t){var e=function(t,e){if("object"!=yl(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=yl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==yl(e)?e:e+""}function gl(t,e,n){return e=wl(e),function(t,e){if(e&&("object"==yl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,bl()?Reflect.construct(e,n||[],wl(t).constructor):e.apply(t,n))}function bl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(bl=function(){return!!t})()}function wl(t){return wl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wl(t)}function Sl(t,e){return Sl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Sl(t,e)}dl.ActionTypes=n;var kl=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=gl(this,e)).config=D(e.defaultConfig,r),n.state={name:t||""},n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Sl(t,e)}(e,t),n=e,r=[{key:"say",value:function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];if(Array.isArray(t)&&t.every((function(t){return"string"==typeof t}))&&[e].concat(r).length>0&&[e].concat(r).every((function(t){return ol.isSingleWord(t)}))){var i=t,a=ol.format([e].concat(r)),s=new ol(function(t,e){for(var n=[],r=0;r<Math.max(t.length,e.length);r++)r<t.length&&n.push(t[r]),r<e.length&&n.push(e[r]);return n}(i,a),{character:this}),u=new dl(this.chain(),dl.ActionTypes.say,(new jt).setContent(s));return this.chain(u)}var c=e||{},l=t,f=Array.isArray(l)?new ol(l,Object.assign(Object.assign({},c),{character:this})):(ol.isSentence(l)?l:new ol(l,Object.assign(Object.assign({},c),{character:this}))).copy();f.setCharacter(this);var h=new dl(this.chain(),dl.ActionTypes.say,(new jt).setContent(f));return this.chain(h)}},{key:"setName",value:function(t){var e=new dl(this.chain(),dl.ActionTypes.setName,(new jt).setContent([t]));return this.chain(e)}},{key:"apply",value:function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return this.say.apply(this,[t,e].concat(r))}}],r&&ml(n.prototype,r),o&&ml(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);function xl(t){return xl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xl(t)}function _l(t){return function(t){if(Array.isArray(t))return Al(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Al(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Al(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Al(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Tl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ol(r.key),r)}}function Ol(t){var e=function(t,e){if("object"!=xl(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=xl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==xl(e)?e:e+""}function El(t,e,n){return e=Cl(e),function(t,e){if(e&&("object"==xl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,jl()?Reflect.construct(e,n||[],Cl(t).constructor):e.apply(t,n))}function jl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jl=function(){return!!t})()}function Pl(){return Pl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Cl(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Pl.apply(null,arguments)}function Cl(t){return Cl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cl(t)}function Il(t,e){return Il=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Il(t,e)}kl.defaultCharacterColor="#000",kl.defaultConfig={};var Rl=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),El(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Il(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var e,n,r=this.callee.evaluate(this.contentNode.getContent(),{gameState:t});return null===(e=null==r?void 0:r[r.length-1])||void 0===e||e.contentNode.addChild(this.contentNode.getChild()),this.contentNode.addChild((null===(n=null==r?void 0:r[0])||void 0===n?void 0:n.contentNode)||null),{type:this.type,node:this.contentNode.getChild()}}},{key:"getFutureActions",value:function(t,n){return[].concat(_l(this.callee._getFutureActions()),_l((r=e,o="getFutureActions",i=this,s=Pl(Cl(1&(a=3)?r.prototype:r),o,i),2&a&&"function"==typeof s?function(t){return s.apply(i,t)}:s)([t,n])));var r,o,i,a,s}}],r&&Tl(n.prototype,r),o&&Tl(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function Dl(t){return Dl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dl(t)}function Ll(t){return function(t){if(Array.isArray(t))return Nl(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ml(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ml(t,e){if(t){if("string"==typeof t)return Nl(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nl(t,e):void 0}}function Nl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Fl(t,e,n){return e=Ul(e),function(t,e){if(e&&("object"==Dl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Bl()?Reflect.construct(e,n||[],Ul(t).constructor):e.apply(t,n))}function Bl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Bl=function(){return!!t})()}function Ul(t){return Ul=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ul(t)}function Vl(t,e){return Vl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Vl(t,e)}function zl(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Gl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,$l(r.key),r)}}function Hl(t,e,n){return e&&Gl(t.prototype,e),n&&Gl(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function $l(t){var e=function(t,e){if("object"!=Dl(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Dl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Dl(e)?e:e+""}Rl.ActionTypes={action:"condition:action"};var Wl=function(){function t(e){zl(this,t),this.handler=e}return Hl(t,[{key:"evaluate",value:function(t){var e=t.gameState;return{value:this.handler(this.getCtx({gameState:e}))}}},{key:"getCtx",value:function(t){var e=t.gameState;return{gameState:e,game:e.game,liveGame:e.game.getLiveGame(),storable:e.game.getLiveGame().getStorable()}}}],[{key:"isLambda",value:function(e){return e instanceof t&&"handler"in e}},{key:"from",value:function(e){return t.isLambda(e)?e:new t(e)}}])}(),ql=function(t){function e(){var t;return zl(this,e),(t=Fl(this,e)).conditions={If:{condition:null,action:null},ElseIf:[],Else:{action:null}},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vl(t,e)}(e,t),Hl(e,[{key:"ElseIf",value:function(t,e){if(this.conditions.Else.action)throw new $c("ELSE condition already set\nYou are trying to set an ELSE-IF condition after an ELSE condition");return this.conditions.ElseIf.push({condition:Wl.isLambda(t)?t:new Wl(t),action:this.construct(Array.isArray(e)?e:[e])}),this.chain()}},{key:"Else",value:function(t){if(this.conditions.Else.action)throw new $c("ELSE condition already set\nYou are trying to set multiple ELSE conditions for the same condition");return this.conditions.Else.action=this.construct(Array.isArray(t)?t:[t]),this.chain()}},{key:"evaluate",value:function(t,e){var n,r,o={gameState:e.gameState},i=null===(n=t.If.condition)||void 0===n?void 0:n.evaluate(o);if(null==i?void 0:i.value)return t.If.action||null;var a,s=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Ml(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(t.ElseIf);try{for(s.s();!(a=s.n()).done;){var u=a.value,c=null===(r=u.condition)||void 0===r?void 0:r.evaluate(o);if(null==c?void 0:c.value)return u.action||null}}catch(t){s.e(t)}finally{s.f()}return t.Else.action||null}},{key:"fromChained",value:function(t){return[Reflect.construct(Rl,[this,Rl.ActionTypes.action,(new jt).setContent(t.conditions)])]}},{key:"construct",value:function(t,e,n){for(var r,o=_s.toActions(t),i=0;i<o.length;i++){var a=o[i].contentNode,s=null===(r=o[i+1])||void 0===r?void 0:r.contentNode;s&&a.setChild(s),i===o.length-1&&e&&a.setChild(e),0===i&&n&&n.setChild(a)}return o}},{key:"_getFutureActions",value:function(){var t,e;return _s.toActions([(null===(t=this.conditions.If.action)||void 0===t?void 0:t[0])||[]].concat(Ll(this.conditions.ElseIf.flatMap((function(t){var e;return(null===(e=t.action)||void 0===e?void 0:e[0])||[]}))),[(null===(e=this.conditions.Else.action)||void 0===e?void 0:e[0])||[]]))}},{key:"createIfCondition",value:function(t,e){return this.conditions.If.condition=t instanceof Wl?t:new Wl(t),this.conditions.If.action=this.construct(Array.isArray(e)?e:[e]),this.chain()}}],[{key:"getInitialState",value:function(){return{If:{condition:null,action:null},ElseIf:[],Else:{action:null}}}},{key:"If",value:function(t,n){return(new e).createIfCondition(t,n)}}])}(Rs);function Yl(t){return Yl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yl(t)}function Xl(t){return function(t){if(Array.isArray(t))return Kl(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Kl(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Kl(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Zl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ql(r.key),r)}}function Ql(t){var e=function(t,e){if("object"!=Yl(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Yl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Yl(e)?e:e+""}function Jl(t,e,n){return e=nf(e),function(t,e){if(e&&("object"==Yl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,tf()?Reflect.construct(e,n||[],nf(t).constructor):e.apply(t,n))}function tf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tf=function(){return!!t})()}function ef(){return ef="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=nf(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},ef.apply(null,arguments)}function nf(t){return nf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nf(t)}function rf(t,e){return rf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rf(t,e)}var of=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Jl(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&rf(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var e=this,n=(new L).registerSkipController(new z((function(){i.cancel()}))),r=t.timelines.attachTimeline(n),o=this.contentNode.getContent(),i=t.createMenu(o,(function(o){var a,s,u=(null===(a=t.game.getLiveGame().getCurrentAction())||void 0===a?void 0:a.contentNode.getChild())||null;u&&(null===(s=o.action[o.action.length-1])||void 0===s||s.contentNode.addChild(u)),n.resolve({type:e.type,node:o.action[0].contentNode});var c=t.actionHistory.push(e,void 0,[],r).id;t.gameHistory.push({token:c,action:e,element:{type:"menu",text:i.prompt,selected:o.evaluated}})}));return n}},{key:"getFutureActions",value:function(t,n){var r,o,i,a,s,u=this.contentNode.getContent();return[].concat(Xl(this.callee._getFutureActions(u.choices)),Xl((r=e,o="getFutureActions",i=this,s=ef(nf(1&(a=3)?r.prototype:r),o,i),2&a&&"function"==typeof s?function(t){return s.apply(i,t)}:s)([t,n])))}}],r&&Zl(n.prototype,r),o&&Zl(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function af(t){return af="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},af(t)}function sf(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,uf(r.key),r)}}function uf(t){var e=function(t,e){if("object"!=af(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=af(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==af(e)?e:e+""}function cf(t,e,n){return e=ff(e),function(t,e){if(e&&("object"==af(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,lf()?Reflect.construct(e,n||[],ff(t).constructor):e.apply(t,n))}function lf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(lf=function(){return!!t})()}function ff(t){return ff=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ff(t)}function hf(t,e){return hf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},hf(t,e)}of.ActionTypes={action:"menu:action"};var pf=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=cf(this,e)).choices=[],n.prompt=ol.isSentence(t)?t:new ol(t),n.config=D(e.defaultConfig,r),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&hf(t,e)}(e,t),n=e,o=[{key:"prompt",value:function(t){return new e(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}}],(r=[{key:"choose",value:function(t,e){var n=this.chain();return ol.isSentence(t)&&e||(Oc.isWord(t)||Array.isArray(t)||"string"==typeof t)&&e?n.choices.push({prompt:ol.toSentence(t),action:_s.toActions(e)}):"object"===af(t)&&"prompt"in t&&"action"in t?n.choices.push({prompt:ol.toSentence(t.prompt),action:_s.toActions(t.action)}):console.warn("No valid choice added to menu, ",{arg0:t,arg1:e}),n}},{key:"fromChained",value:function(t){return[new of(this.chain(),of.ActionTypes.action,(new jt).setContent({prompt:this.prompt,choices:t.constructChoices()}))]}},{key:"_getFutureActions",value:function(t){return t.map((function(t){return t.action[0]||null})).filter((function(t){return null!==t}))}},{key:"constructNodes",value:function(t,e,n){for(var r,o=0;o<t.length;o++){var i=t[o].contentNode,a=null===(r=t[o+1])||void 0===r?void 0:r.contentNode;a&&i.setChild(a),o===this.choices.length-1&&e&&i.setChild(e),0===o&&n&&n.setChild(i)}return t}},{key:"constructChoices",value:function(){var t=this;return this.choices.map((function(e){return{action:t.constructNodes(e.action),prompt:e.prompt}}))}}])&&sf(n.prototype,r),o&&sf(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);function df(t){return df="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},df(t)}function yf(t){return function(t){if(Array.isArray(t))return mf(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return mf(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mf(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function vf(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,gf(r.key),r)}}function gf(t){var e=function(t,e){if("object"!=df(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=df(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==df(e)?e:e+""}function bf(t,e,n){return e=Sf(e),function(t,e){if(e&&("object"==df(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wf()?Reflect.construct(e,n||[],Sf(t).constructor):e.apply(t,n))}function wf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wf=function(){return!!t})()}function Sf(t){return Sf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Sf(t)}function kf(t,e){return kf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},kf(t,e)}pf.defaultConfig={},pf.targetAction=of;var xf=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),bf(this,e)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kf(t,e)}(e,t),n=e,r=[{key:"fromChained",value:function(t){return t.getActions()}},{key:"forEachChild",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=new Set,i=[];for(Array.isArray(e)?i.push.apply(i,yf(e)):i.push(e);i.length;){var a=i.shift();if(!o.has(a)){o.add(a),n(a);var s=a.getFutureActions(t,r).filter((function(t){return!o.has(t)}));i.push.apply(i,yf(s))}}}},{key:"getAllChildren",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[];return this.forEachChild(t,e,(function(t){return r.push(t)}),n),r}},{key:"getAllChildrenMap",value:function(t,e){var n=new Map;return this.forEachChild(t,e,(function(t){return n.set(t.getId(),t)})),n}},{key:"getAllElementMap",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new Map;return this.forEachChild(t,e,(function(t){return r.set(t.callee.getId(),t.callee)}),n),r}},{key:"getAllChildrenElements",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Array.from(new Set(this.getAllChildren(t,e,n).map((function(t){return t.callee}))))}},{key:"toData",value:function(){return null}},{key:"constructNodes",value:function(t,e){for(var n,r=0;r<t.length;r++){var o=t[r];0===r&&e?e.setChild(o.contentNode):r>0&&(null===(n=t[r-1].contentNode)||void 0===n||n.setChild(o.contentNode))}return t.length?t[0].contentNode:null}}],r&&vf(n.prototype,r),o&&vf(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(As);function _f(t){return _f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_f(t)}function Af(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Tf(r.key),r)}}function Tf(t){var e=function(t,e){if("object"!=_f(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=_f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_f(e)?e:e+""}function Of(t,e,n){return e=Cf(e),function(t,e){if(e&&("object"==_f(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Ef()?Reflect.construct(e,n||[],Cf(t).constructor):e.apply(t,n))}function Ef(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ef=function(){return!!t})()}function jf(t,e,n,r){var o=Pf(Cf(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Pf(){return Pf="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Cf(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Pf.apply(null,arguments)}function Cf(t){return Cf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cf(t)}function If(t,e){return If=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},If(t,e)}var Rf,Df,Lf=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Of(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&If(t,e)}(e,t),n=e,(r=[{key:"executeAction",value:function(t){var n=this;if(this.type===c.setText){var r=this.callee.state.text;return this.callee.state.text=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,(function(t){n.callee.state.text=t}),[r]),jf(e,"executeAction",this,3)([t])}if(this.type===c.setFontSize){var o=this.callee.state.fontSize;return this.callee.state.fontSize=this.contentNode.getContent()[0],t.getExposedStateForce(this.callee).flush(),t.actionHistory.push(this,(function(t){n.callee.state.fontSize=t}),[o]),jf(e,"executeAction",this,3)([t])}throw jf(e,"unknownTypeError",this,3)([])}}])&&Af(n.prototype,r),o&&Af(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function Mf(t){return Mf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mf(t)}function Nf(t){return function(t){if(Array.isArray(t))return Ff(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ff(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ff(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ff(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Bf(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Uf(r.key),r)}}function Uf(t){var e=function(t,e){if("object"!=Mf(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Mf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Mf(e)?e:e+""}Lf.ActionTypes=c,(Df=Rf||(Rf={}))[Df.Number=0]="Number",Df[Df.HexColor=1]="HexColor";var Vf=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},(e=[{key:"requestAnimations",value:function(t){var e=this,n=t.map((function(t){return t.start})),r=[],o=0,i=[],a=[],s=[];return{onUpdate:function(t){return i.push(t),{cancel:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},onComplete:function(t){return a.push(t),{cancel:function(){var e=a.indexOf(t);-1!==e&&a.splice(e,1)}}},onCanceled:function(t){return s.push(t),{cancel:function(){var e=s.indexOf(t);-1!==e&&s.splice(e,1)}}},complete:function(){o!==t.length&&r.forEach((function(t){return t.complete()}))},start:function(){if(r.length>0)throw new Error("Animation controllers are already started");t.forEach((function(s,u){r.push(e.requestMotion(s,{onComplete:function(){n[u]=s.end,i.forEach((function(t){return t(n)})),++o===t.length&&a.forEach((function(t){return t()}))},onUpdate:function(t){n[u]=t,i.forEach((function(t){return t(n)}))}}))}))},cancel:function(){r.forEach((function(t){return t.cancel()})),s.forEach((function(t){return t()}))}}}},{key:"toFinalStyle",value:function(t){return t.resolve.map((function(e){return"function"==typeof e?e.apply(void 0,Nf(t.animations.map((function(t){return t.end})))):e.resolver.apply(e,Nf(t.animations.map((function(t){return t.end}))))}))}},{key:"asPrev",value:function(t){return{resolver:t,key:"current"}}},{key:"asTarget",value:function(t){return{resolver:t,key:"target"}}},{key:"requestMotion",value:function(t,e){return zi(t.start,t.end,{duration:t.duration/1e3,onUpdate:function(t){e.onUpdate&&e.onUpdate(t)},onComplete:function(){e.onComplete&&e.onComplete()},ease:t.ease})}}])&&Bf(t.prototype,e),n&&Bf(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function zf(t){return zf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zf(t)}function Gf(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Hf(r.key),r)}}function Hf(t){var e=function(t,e){if("object"!=zf(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=zf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==zf(e)?e:e+""}function $f(t,e,n){return e=qf(e),function(t,e){if(e&&("object"==zf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Wf()?Reflect.construct(e,n||[],qf(t).constructor):e.apply(t,n))}function Wf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Wf=function(){return!!t})()}function qf(t){return qf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},qf(t)}function Yf(t,e){return Yf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yf(t,e)}Vf.AnimationType=Rf;var Xf=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),$f(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yf(t,e)}(e,t),n=e,(r=[{key:"_setElement",value:function(t){return this._element=t,this}},{key:"getTextState",value:function(){if(void 0===this._element)throw new Yc("Trying to access text state, but element is not set\nThis should not happen, please report this issue to the developers");return this._element.state}}])&&Gf(n.prototype,r),o&&Gf(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Vf);function Kf(t){return Kf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kf(t)}function Zf(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Qf(r.key),r)}}function Qf(t){var e=function(t,e){if("object"!=Kf(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Kf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Kf(e)?e:e+""}function Jf(t,e,n){return e=eh(e),function(t,e){if(e&&("object"==Kf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,th()?Reflect.construct(e,n||[],eh(t).constructor):e.apply(t,n))}function th(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(th=function(){return!!t})()}function eh(t){return eh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},eh(t)}function nh(t,e){return nh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},nh(t,e)}var rh=function(t){function e(t,n,r){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(o=Jf(this,e)).textSize=t,o.duration=n,o.easing=r,o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&nh(t,e)}(e,t),n=e,(r=[{key:"createTask",value:function(){return{animations:[{type:Rf.Number,start:this.getTextState().fontSize,end:this.textSize,duration:this.duration,ease:this.easing}],resolve:[this.asTarget((function(t){return{style:{fontSize:"".concat(t,"px")}}}))]}}},{key:"copy",value:function(){return new e(this.textSize,this.duration,this.easing)}}])&&Zf(n.prototype,r),o&&Zf(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Xf);function oh(t){return oh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oh(t)}function ih(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ah(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ah(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ah(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function sh(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,uh(r.key),r)}}function uh(t){var e=function(t,e){if("object"!=oh(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=oh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==oh(e)?e:e+""}function ch(t,e,n){return e=fh(e),function(t,e){if(e&&("object"==oh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,lh()?Reflect.construct(e,n||[],fh(t).constructor):e.apply(t,n))}function lh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(lh=function(){return!!t})()}function fh(t){return fh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},fh(t)}function hh(t,e){return hh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},hh(t,e)}var ph=function(t){function n(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),e=ch(this,n);var o="string"==typeof t?Object.assign(Object.assign({},r),{text:t}):t,i=n.DefaultUserConfig.create(o),a=n.DefaultTextConfig.create(i.get());return e.userConfig=i,e.config=a.get(),e.state=e.getInitialState(),e.transformState=e.getInitialTransformState(i),e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&hh(t,e)}(n,t),r=n,o=[{key:"setText",value:function(t){var e=this.chain(),n=new Lf(e,Lf.ActionTypes.setText,(new jt).setContent([t]));return e.chain(n)}},{key:"setFontColor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;return this.transform(new Ta({fontColor:t},{duration:e,ease:n}))}},{key:"setFontSize",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;return this.combineActions(new Vs,(function(o){if(n){var i=new rh(t,n,r);o.chain(e._applyTransition(o,i))}var a=new Lf(o,Lf.ActionTypes.setFontSize,(new jt).setContent([t]));return o.chain(a)}))}},{key:"useLayer",value:function(t){return this.userConfig.get().layer=t,Object.assign(this.config,{layer:t}),this}},{key:"toData",value:function(){return{state:n.StateSerializer.serialize(this.state),transformState:this.transformState.serialize()}}},{key:"fromData",value:function(t){return this.state=n.StateSerializer.deserialize(t.state),this.transformState=Aa.deserialize(t.transformState),this}},{key:"_init",value:function(t){return new Js(this.chain(),e.init,(new jt).setContent([t||null,this.config.layer||null]))}},{key:"reset",value:function(){this.state=this.getInitialState(),this.transformState=this.getInitialTransformState(this.userConfig)}},{key:"getInitialTransformState",value:function(t){var e=ih(t.extract(n.DefaultTextTransformState.keys()),1)[0];return new Aa(n.DefaultTextTransformState.create(e.get()).get())}},{key:"_applyTransition",value:function(t,n){var r=this;return new Js(t,e.applyTransition,(new jt).setContent([n,function(t){return t._setElement(r)}]))}},{key:"getInitialState",value:function(){return n.DefaultTextState.create({fontSize:this.userConfig.get().fontSize,text:this.userConfig.get().text}).get()}}],o&&sh(r.prototype,o),i&&sh(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(Du);function dh(t){return dh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dh(t)}function yh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return mh(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mh(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function vh(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,gh(r.key),r)}}function gh(t){var e=function(t,e){if("object"!=dh(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=dh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==dh(e)?e:e+""}function bh(t,e,n){return e=xh(e),function(t,e){if(e&&("object"==dh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wh()?Reflect.construct(e,n||[],xh(t).constructor):e.apply(t,n))}function wh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wh=function(){return!!t})()}function Sh(t,e,n,r){var o=kh(xh(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function kh(){return kh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=xh(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},kh.apply(null,arguments)}function xh(t){return xh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xh(t)}function _h(t,e){return _h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_h(t,e)}ph.DefaultUserConfig=new ha({alignX:"center",alignY:"center",className:"",fontSize:16,fontColor:"#000000",text:""}),ph.DefaultTextConfig=new ha({alignX:"center",alignY:"center",className:"",layer:void 0}),ph.DefaultTextState=new ha({fontSize:16,display:!1,text:""}),ph.DefaultTextTransformState=new ha(Object.assign({fontColor:"#000000"},Aa.DefaultTransformState.getDefaultConfig())),ph.StateSerializer=new X;var Ah=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),bh(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_h(t,e)}(e,t),n=e,(r=[{key:"executeAction",value:function(t){var n=this;if(n.is(e,"persistent:set")){var r=yh(n.contentNode.getContent(),2),o=r[0],i=r[1],a=t.getStorable().getNamespace(n.callee.getNamespaceName()),s=a.get(o);if("function"==typeof i){var u=a.get(o);a.set(o,i(u))}else a.set(o,i);return t.actionHistory.push(this,(function(t){a.set(o,t)}),[s]),Sh(e,"executeAction",this,3)([t])}if(n.is(e,"persistent:assign")){var c=yh(n.contentNode.getContent(),1)[0],l=t.getStorable().getNamespace(n.callee.getNamespaceName()),f={};return Object.keys(c).forEach((function(t){f[t]=l.get(t),l.set(t,c[t])})),t.actionHistory.push(this,(function(t){Object.keys(t).forEach((function(e){l.set(e,t[e])}))}),[f]),Sh(e,"executeAction",this,3)([t])}throw this.unknownTypeError()}}])&&vh(n.prototype,r),o&&vh(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function Th(t){return Th="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Th(t)}function Oh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Eh(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Eh(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Eh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function jh(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ph(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ih(r.key),r)}}function Ch(t,e,n){return e&&Ph(t.prototype,e),n&&Ph(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ih(t){var e=function(t,e){if("object"!=Th(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Th(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Th(e)?e:e+""}Ah.ActionTypes=l;var Rh=function(){function t(e,n,r){jh(this,t),this.name=e,this.key=r||e,this.content=D({},n),this.defaultContent=n}return Ch(t,[{key:"set",value:function(e,n){return t.isSerializable(n)?(this.content[e]=n,this):(console.warn('Value "'.concat(n,'" in key "').concat(String(e),'" is not serializable, and will not be set\n at namespace "').concat(this.name,'"')),this.content[e]=n,this)}},{key:"get",value:function(t){return this.content[t]}},{key:"equals",value:function(t,e){return this.content[t]===e}},{key:"assign",value:function(t){var e=this;return Object.entries(t).forEach((function(t){var n=Oh(t,2),r=n[0],o=n[1];e.set(r,o)})),this}},{key:"reset",value:function(){return this.content=D({},this.defaultContent),this}},{key:"toData",value:function(){return this.serialize()}},{key:"load",value:function(t){t?this.content=t:console.warn("No data to load")}},{key:"serialize",value:function(){var t=this,e={};return Object.entries(this.content).forEach((function(n){var r=Oh(n,2),o=r[0],i=r[1];e[o]=t.wrap(i)})),e}},{key:"deserialize",value:function(t){var e=this;t?Object.entries(t).forEach((function(t){var n=Oh(t,2),r=n[0],o=n[1];e.content[r]=e.unwrap(o)})):console.warn("No data to load")}},{key:"toTypeName",value:function(t){return t instanceof Date?"date":"any"}},{key:"wrap",value:function(t){return{any:function(t){return{type:"any",data:t}},date:function(t){return{type:"date",data:t.toString()}}}[this.toTypeName(t)](t)}},{key:"unwrap",value:function(t){var e={any:function(t){return t.data},date:function(t){return new Date(t.data)}};return e[t.type](t)}}],[{key:"isSerializable",value:function(e){return!!["number","string","boolean"].includes(Th(e))||(e instanceof Date||(null==e||(Array.isArray(e)?e.every(t.isSerializable):"object"===Th(e)&&(Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(t.isSerializable)))))}}])}(),Dh=function(){return Ch((function t(){jh(this,t),this.namespaces={}}),[{key:"addNamespace",value:function(t){if(!this.namespaces[t.key])return this.namespaces[t.key]=t,this}},{key:"getNamespace",value:function(t){if(!this.namespaces[t])throw new Yc("Namespace ".concat(t," is not initialized, did you forget to register it?")+"\nUse `story.registerPersistent` to register a persistent namespace");return this.namespaces[t]}},{key:"setNamespace",value:function(t,e){return this.namespaces[t]=e,this}},{key:"hasNamespace",value:function(t){return!!this.namespaces[t]}},{key:"removeNamespace",value:function(t){return delete this.namespaces[t],this}},{key:"getNamespaces",value:function(){return this.namespaces}},{key:"keys",value:function(){return Object.keys(this.namespaces)}},{key:"values",value:function(){return Object.values(this.namespaces)}},{key:"entries",value:function(){return Object.entries(this.namespaces)}},{key:"toData",value:function(){return this.entries().reduce((function(t,e){var n=Oh(e,2),r=n[0],o=n[1];return t[r]=o.toData(),t}),{})}},{key:"load",value:function(t){var e=this;t?Object.entries(t).forEach((function(t){var n=Oh(t,2),r=n[0],o=n[1];e.namespaces[r]?e.namespaces[r].load(o):e.namespaces[r]=new Rh(r,o)})):console.warn("No data to load")}},{key:"clear",value:function(){return this.namespaces={},this}}])}();function Lh(t){return Lh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lh(t)}function Mh(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Nh(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Bh(r.key),r)}}function Fh(t,e,n){return e&&Nh(t.prototype,e),n&&Nh(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Bh(t){var e=function(t,e){if("object"!=Lh(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Lh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Lh(e)?e:e+""}function Uh(t,e,n){return e=zh(e),function(t,e){if(e&&("object"==Lh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Vh()?Reflect.construct(e,n||[],zh(t).constructor):e.apply(t,n))}function Vh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Vh=function(){return!!t})()}function zh(t){return zh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},zh(t)}function Gh(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Hh(t,e)}function Hh(t,e){return Hh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hh(t,e)}var $h=function(t){function e(t,n){var r;return Mh(this,e),(r=Uh(this,e)).namespace=r.prefix(t),r.defaultContent=n,r}return Gh(e,t),Fh(e,[{key:"init",value:function(t){t.hasNamespace(this.namespace)||t.addNamespace(new Rh(this.namespace,this.defaultContent))}},{key:"getNamespace",value:function(t){return t.getNamespace(this.namespace)}},{key:"set",value:function(t,e){return this.chain(this.createAction(l.set,[t,e]))}},{key:"assign",value:function(t){return this.chain(this.createAction(l.assign,[t]))}},{key:"equals",value:function(t,e){var n=this;return new Wl((function(r){return r.storable.getNamespace(n.namespace).equals(t,e)}))}},{key:"notEquals",value:function(t,e){var n=this;return new Wl((function(r){return!r.storable.getNamespace(n.namespace).equals(t,e)}))}},{key:"isTrue",value:function(t){var e=this;return new Wl((function(n){return n.storable.getNamespace(e.namespace).equals(t,!0)}))}},{key:"isFalse",value:function(t){var e=this;return new Wl((function(n){return n.storable.getNamespace(e.namespace).equals(t,!1)}))}},{key:"isNotNull",value:function(t){var e=this;return new Wl((function(n){var r=n.storable.getNamespace(e.namespace).get(t);return null!=r}))}},{key:"toWord",value:function(t){var e=this;return new Oc((function(n){var r=n.storable;return[String(r.getNamespace(e.namespace).get(t))]}))}},{key:"get",value:function(t){return this.toWord(t)}},{key:"conditional",value:function(t,e,n){return new Oc((function(r){return Wl.from(t).evaluate(r).value?e:n}))}},{key:"evaluate",value:function(t,e){var n=this;return new Wl((function(r){var o=r.storable;return e(o.getNamespace(n.namespace).get(t))}))}},{key:"getNamespaceName",value:function(){return this.namespace}},{key:"prefix",value:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.NamespacePrefix)+":"+String(t)}},{key:"createAction",value:function(t,e){return new Ah(this.chain(),t,jt.create(e))}}])}(Rs);$h.NamespacePrefix="persistent";var Wh=function(t){function e(t){var n;return Mh(this,e),(n=Uh(this,e,[t,{}])).namespace=n.prefix(t,e.LocalNamespacePrefix),n}return Gh(e,t),Fh(e,[{key:"init",value:function(t){t.removeNamespace(this.namespace).addNamespace(new Rh(this.namespace,this.defaultContent))}}])}($h);function qh(t){return qh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qh(t)}function Yh(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Xh(r.key),r)}}function Xh(t){var e=function(t,e){if("object"!=qh(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=qh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==qh(e)?e:e+""}function Kh(t,e,n){return e=tp(e),function(t,e){if(e&&("object"==qh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Zh()?Reflect.construct(e,n||[],tp(t).constructor):e.apply(t,n))}function Zh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Zh=function(){return!!t})()}function Qh(t,e,n,r){var o=Jh(tp(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Jh(){return Jh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=tp(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Jh.apply(null,arguments)}function tp(t){return tp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},tp(t)}function ep(t,e){return ep=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ep(t,e)}Wh.LocalNamespacePrefix="local";var np=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Kh(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ep(t,e)}(e,t),n=e,(r=[{key:"executeAction",value:function(t){if(this.type===f.action)return Qh(e,"executeAction",this,3)([t]);throw Qh(e,"unknownTypeError",this,3)([])}}])&&Yh(n.prototype,r),o&&Yh(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function rp(t){return rp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rp(t)}function op(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ip(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ip(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ip(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ap(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,sp(r.key),r)}}function sp(t){var e=function(t,e){if("object"!=rp(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=rp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==rp(e)?e:e+""}function up(t,e,n){return e=lp(e),function(t,e){if(e&&("object"==rp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,cp()?Reflect.construct(e,n||[],lp(t).constructor):e.apply(t,n))}function cp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(cp=function(){return!!t})()}function lp(t){return lp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},lp(t)}function fp(t,e){return fp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},fp(t,e)}np.ActionTypes=f;var hp=function(t){function n(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),e=up(this,n);var o=n.DefaultUserConfig.create(r),i=n.DefaultConfig.create(Object.assign(Object.assign({},o.get()),{name:t}));return e.userConfig=o,e.config=i.get(),e.state=e.getInitialState(),e.transformState=e.getInitialTransformState(),e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&fp(t,e)}(n,t),r=n,(o=[{key:"include",value:function(t){var e=this;return(Array.isArray(t)?t:[t]).forEach((function(t){t.useLayer(e)})),this}},{key:"copy",value:function(){return new n(this.config.name,this.userConfig.get())}},{key:"setName",value:function(t){return this.config.name=t,this}},{key:"_init",value:function(t){return[new np(this.chain(),f.action,new jt),new Js(this.chain(),e.init,(new jt).setContent([t,null,!1]))]}},{key:"getInitialState",value:function(){return n.DefaultState.create({zIndex:this.config.zIndex}).get()}},{key:"getInitialTransformState",value:function(){var t=op(this.userConfig.extract(Aa.DefaultTransformState.keys()),1)[0];return new Aa(Aa.DefaultTransformState.create(t.get()).get())}}])&&ap(r.prototype,o),i&&ap(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,o,i}(Du);function pp(t){return pp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pp(t)}function dp(t){return function(t){if(Array.isArray(t))return mp(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||yp(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yp(t,e){if(t){if("string"==typeof t)return mp(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mp(t,e):void 0}}function mp(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function vp(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,gp(r.key),r)}}function gp(t){var e=function(t,e){if("object"!=pp(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=pp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==pp(e)?e:e+""}function bp(t,e,n){return e=kp(e),function(t,e){if(e&&("object"==pp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wp()?Reflect.construct(e,n||[],kp(t).constructor):e.apply(t,n))}function wp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wp=function(){return!!t})()}function Sp(){return Sp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=kp(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Sp.apply(null,arguments)}function kp(t){return kp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},kp(t)}function xp(t,e){return xp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},xp(t,e)}hp.DefaultUserConfig=new ha(Object.assign(Object.assign({zIndex:0},Aa.DefaultTransformState.getDefaultConfig()),{opacity:1})),hp.DefaultConfig=new ha({name:"(anonymous)",zIndex:0}),hp.DefaultState=new ha({displayables:[],zIndex:0});var _p=function(t){function e(t,n){var r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=bp(this,e)).srcManager=new Tu,r.events=new F,r.actions=[],r._futureActions_=[];var o=e.DefaultSceneConfig.getDefaultConfig().defaultBackgroundLayer.copy().setName("[[Background Layer of "+t+"]]"),i=e.DefaultSceneConfig.getDefaultConfig().defaultDisplayableLayer.copy().setName("[[Displayable Layer of "+t+"]]"),a=e.DefaultUserConfig.create(n),s=e.DefaultSceneConfig.create(Object.assign(Object.assign({},a.get()),{name:t,layers:[].concat(dp(a.get().layers),[o,i]),defaultBackgroundLayer:o,defaultDisplayableLayer:i}));return r.userConfig=a,r.config=s.get(),r.state=r.getInitialState(),r.localPersistent=new Wh(t),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&xp(t,e)}(e,t),n=e,o=[{key:"__futureActions__",get:function(){return this._futureActions_}},{key:"local",get:function(){return this.localPersistent}},{key:"background",get:function(){return this.state.backgroundImage}},{key:"backgroundLayer",get:function(){return this.config.defaultBackgroundLayer}},{key:"displayableLayer",get:function(){return this.config.defaultDisplayableLayer}},{key:"setBackground",value:function(t,e){var n=this.chain();return n.chain(this.state.backgroundImage._setSrc(n,t,e))}},{key:"jumpTo",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.combineActions(new Vs({allowFutureScene:!1}),(function(r){var o=D({unloadScene:!0},n instanceof Vf?{transition:n}:n);return r.chain(new bc(r,"scene:preUnmount",(new jt).setContent([]))).chain(e._initScene(t))._transitionToScene(o.transition,t.state.backgroundImage.state.currentSrc),o.unloadScene&&r.chain(e._exit()),r}))._jumpTo(t)}},{key:"setBackgroundMusic",value:function(t,e){return this.chain(new bc(this.chain(),r.setBackgroundMusic,(new jt).setContent([t,e])))}},{key:"action",value:function(t){return this.actions=t,this}},{key:"preloadImage",value:function(t){var e=this;if(!Hc.isImageSrc(t))throw new Error("Invalid image source: "+t);return(Array.isArray(t)?t:[t]).forEach((function(t){e.srcManager.register({type:"image",src:t})})),this}},{key:"toData",value:function(){return{state:e.getStateSerializer(this).serialize(this.state)}}},{key:"fromData",value:function(t){return this.state=e.getStateSerializer(this).deserialize(t.state),this}},{key:"constructSceneRoot",value:function(t){var n,r=this;this.sceneRoot=new bc(this.chain(),"scene:action",new jt);var o=this.actions,i=(Array.isArray(o)?o.flat(2):o(this).flat(2)).map((function(t){return _s.isChained(t)?t.fromChained(t):t})).flat(2),a=[],s=[];this.getAllChildrenElements(t,i,{allowFutureScene:!1}).forEach((function(t){_s.isChained(t)||(t instanceof qu?a.push(t):t instanceof ph&&s.push(t))}));var u=[],c=[],l=new Map;a.forEach((function(t){var e;t.config.isWearable?c.push(t):t.config.autoInit&&u.push(t);var n,r=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=yp(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(t.config.wearables);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(l.get(o)&&l.get(o)!==t)throw new Error("Wearable image cannot be used multiple times\nMaybe you bind the same wearable image to multiple parent images\nParent Conflict (src: "+(null===(e=l.get(o))||void 0===e?void 0:e.state.currentSrc)+")\nCurrent Parent (src: "+t.state.currentSrc+")");l.set(o,t)}}catch(t){r.e(t)}finally{r.f()}}));var f,h,p,d,y,m=[].concat(dp(this._initScene(this)),dp(u.map((function(t){return t._init(r)}))),dp(c.map((function(t){if(!l.has(t))throw new Error("Wearable image must have a parent image");return l.get(t)._initWearable(t)}))),dp(s.map((function(t){return t._init()}))),dp(i)),v=(f=e,h="constructNodes",p=this,y=Sp(kp(1&(d=3)?f.prototype:f),h,p),2&d&&"function"==typeof y?function(t){return y.apply(p,t)}:y)([m]),g=new jt(this.sceneRoot,void 0,v||void 0).setContent(this);return null==v||v.setParent(g),null===(n=this.sceneRoot)||void 0===n||n.setContentNode(g),this._futureActions_=m,this}},{key:"isSceneRootConstructed",value:function(){return!!this.sceneRoot}},{key:"registerSrc",value:function(t){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(this.sceneRoot){for(var i=new Set,a=new Set,s=[this.sceneRoot],u=new Set;s.length;){var c=s.shift();if(!i.has(c)){if(i.add(c),c instanceof bc){var l=c.callee;if(Hc.isImageSrc(l.state.backgroundImage.state.currentSrc)&&this.srcManager.register({type:"image",src:Hc.srcToURL(l.state.backgroundImage.state.currentSrc)}),c.type===r.jumpTo){var f=c,h=e.getScene(t,f.contentNode.getContent()[0]);if(!h)throw c._sceneNotFoundError(c.getSceneName(f.contentNode.getContent()[0]));var p=Tu.getPreloadableSrc(t,c);if(p&&this.srcManager.register(p),a.has(f)||o.has(h))continue;a.add(f),u.add(h),o.add(h)}}else if(c instanceof sc){var d=Tu.getPreloadableSrc(t,c);d&&this.srcManager.register(d)}else if(c instanceof lu)this.srcManager.register(c.callee);else if(c instanceof fs){var y=c.getFutureActions(t,{allowFutureScene:!0});s.push.apply(s,dp(y))}else c instanceof Js&&this.srcManager.register(c.callee.srcManager.getSrc());s.push.apply(s,dp(c.getFutureActions(t,{allowFutureScene:!0})))}}u.forEach((function(e){e.registerSrc(t,o),n.srcManager.registerFuture(e.srcManager)}))}}},{key:"assignActionId",value:function(t){this.getAllChildren(t,this.sceneRoot||[],{allowFutureScene:!0}).forEach((function(t,e){t.setId("a-".concat(e))}))}},{key:"assignElementId",value:function(t){this.getAllChildrenElements(t,this.sceneRoot||[]).forEach((function(t,e){t.setId("e-".concat(e))}))}},{key:"getVoice",value:function(t){if(!t)return null;var e=this.config.voices;return e?"function"==typeof e?e(t):e[t]||null:null}},{key:"getSceneRoot",value:function(){if(!this.sceneRoot)throw new Error("Scene root is not constructed");return this.sceneRoot}},{key:"reset",value:function(){var t;this.state.backgroundImage.reset(),null===(t=this.state.backgroundMusic)||void 0===t||t.reset(),this.state=this.getInitialState()}},{key:"getInitialState",value:function(){var t;return e.DefaultSceneState.create().assign({backgroundImage:(null===(t=this.state)||void 0===t?void 0:t.backgroundImage)?this.state.backgroundImage.reset():new qu({src:this.userConfig.get().background,opacity:1,autoFit:!0,name:"[[Background Image of ".concat(this.config.name,"]]"),layer:this.config.defaultBackgroundLayer})._setIsBackground(!0)}).get()}},{key:"_jumpTo",value:function(t){return this.chain(new bc(this.chain(),"scene:jumpTo",(new jt).setContent([t])))}},{key:"_exit",value:function(){return new bc(this.chain(),"scene:exit",(new jt).setContent([]))}},{key:"_transitionToScene",value:function(t,e){var n=this.chain();if(t&&e){var r=this.state.backgroundImage.char(e,t);n.chain(r.getActions())}return n}},{key:"_init",value:function(t){return new bc(this.chain(),"scene:init",(new jt).setContent([t]))}},{key:"_initScene",value:function(t){return[t._init(t)].concat(dp(t.config.layers.flatMap((function(e){return e._init(t)}))),dp(t._initBackground(t,t.config.defaultBackgroundLayer)))}},{key:"_initBackground",value:function(t,e){return[t.state.backgroundImage._init(t,e)]}}],i=[{key:"isScene",value:function(t){return t instanceof e}},{key:"getScene",value:function(t,e){return"string"==typeof e?t.getScene(e):e}},{key:"getStateSerializer",value:function(t){return new X({backgroundImage:function(t){return t.toData()},backgroundMusic:function(t){return(null==t?void 0:t.toData())||null}},{backgroundImage:function(e){return t.state.backgroundImage.fromData(e)},backgroundMusic:function(e){return t.state.backgroundMusic&&e?t.state.backgroundMusic.fromData(e):null}})}}],o&&vp(n.prototype,o),i&&vp(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,i}(xf);function Ap(t){return Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(t)}function Tp(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Op(r.key),r)}}function Op(t){var e=function(t,e){if("object"!=Ap(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ap(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ap(e)?e:e+""}function Ep(t,e,n){return e=Cp(e),function(t,e){if(e&&("object"==Ap(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,jp()?Reflect.construct(e,n||[],Cp(t).constructor):e.apply(t,n))}function jp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jp=function(){return!!t})()}function Pp(){return Pp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Cp(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Pp.apply(null,arguments)}function Cp(t){return Cp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cp(t)}function Ip(t,e){return Ip=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ip(t,e)}_p.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"},_p.DefaultUserConfig=new ha({backgroundMusic:null,backgroundMusicFade:0,voices:void 0,background:"#fff",layers:[]}),_p.DefaultSceneConfig=new ha({name:"",backgroundMusicFade:0,voices:null,layers:[],defaultBackgroundLayer:new hp("[[Background Layer]]",{zIndex:-1}),defaultDisplayableLayer:new hp("[[Displayable Layer]]",{zIndex:0})}),_p.DefaultSceneState=new ha({backgroundImage:new qu,backgroundMusic:null});var Rp=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ep(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ip(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var n,r,o,i,a,s=this.contentNode.getContent().execute({gameState:t});return s&&t.actionHistory.push(this,(function(){s()}),[]),(n=e,r="executeAction",o=this,a=Pp(Cp(1&(i=3)?n.prototype:n),r,o),2&i&&"function"==typeof a?function(t){return a.apply(o,t)}:a)([t])}}],r&&Tp(n.prototype,r),o&&Tp(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function Dp(t){return Dp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dp(t)}function Lp(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Mp(r.key),r)}}function Mp(t){var e=function(t,e){if("object"!=Dp(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Dp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Dp(e)?e:e+""}function Np(t,e){if(e&&("object"==Dp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Fp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Fp=function(){return!!t})()}function Bp(t){return Bp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bp(t)}function Up(t,e){return Up=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Up(t,e)}Rp.ActionTypes={action:"script:action"};var Vp,zp,Gp=function(t){function e(t){var n,r,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),r=this,o=Bp(o=e),(n=Np(r,Fp()?Reflect.construct(o,i||[],Bp(r).constructor):o.apply(r,i))).handler=t,Np(n,n.chain())}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Up(t,e)}(e,t),n=e,o=[{key:"getCtx",value:function(t){var e=t.gameState;return{gameState:e,game:e.game,liveGame:e.game.getLiveGame(),storable:e.game.getLiveGame().getStorable()}}}],(r=[{key:"execute",value:function(t){var n=t.gameState;return this.handler(e.getCtx({gameState:n}))}},{key:"fromChained",value:function(t){return[new Rp(this.chain(),Rp.ActionTypes.action,(new jt).setContent(t))]}}])&&Lp(n.prototype,r),o&&Lp(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);function Hp(t){return Hp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hp(t)}function $p(t){return function(t){if(Array.isArray(t))return Wp(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wp(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wp(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wp(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qp(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Yp(r.key),r)}}function Yp(t){var e=function(t,e){if("object"!=Hp(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Hp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Hp(e)?e:e+""}function Xp(t,e,n){return e=Zp(e),function(t,e){if(e&&("object"==Hp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Kp()?Reflect.construct(e,n||[],Zp(t).constructor):e.apply(t,n))}function Kp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Kp=function(){return!!t})()}function Zp(t){return Zp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zp(t)}function Qp(t,e){return Qp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qp(t,e)}(zp=Vp||(Vp={})).topLeft="top left",zp.topRight="top right",zp.bottomLeft="bottom left",zp.bottomRight="bottom right";var Jp=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.defaultConfig;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=Xp(this,e)).entryScene=null,n.scenes=new Map,n.persistent=[],n.services=new Map,n.name=t,n.config=D(e.defaultConfig,r),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Qp(t,e)}(e,t),n=e,r=[{key:"entry",value:function(t){return this.entryScene=t,this}},{key:"registerScene",value:function(t,e){var n="string"==typeof t?t:t.config.name,r="string"==typeof t?e:t;if(this.scenes.has(n)&&this.scenes.get(n)!==r)throw new Error("Scene with name ".concat(n," already exists when registering scene"));return this.scenes.set(n,r),this}},{key:"registerPersistent",value:function(t){return this.persistent.push(t),this}},{key:"createPersistent",value:function(t,e){var n=new $h(t,e);return this.registerPersistent(n),n}},{key:"registerService",value:function(t,e){return this.services.set(t,e),this}},{key:"getService",value:function(t){var e=this.services.get(t);if(!e)throw new $c("Trying to access service ".concat(t,' before it\'s registered, please use "story.registerService" to register the service'));return e}},{key:"serializeServices",value:function(){var t={};return this.services.forEach((function(e,n){if(e.serialize&&"function"==typeof e.serialize){var r=e.serialize();if(null!==r){if(r instanceof Promise)throw new qc("Service ".concat(n," serialize method should not return a promise"));if(!Q(r))throw new qc("Service ".concat(n," serialize method should return a pure object. \n")+"A pure object should:\n1. be an object literal\n2. not have any prototype\n3. no circular reference\n4. sub objects should also be pure objects or serializable data\nReturn 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\n"+"Returned value ".concat(r," violates the above rules"));t[n]=r}}})),t}},{key:"deserializeServices",value:function(t){this.services.forEach((function(e,n){e.deserialize&&"function"==typeof e.deserialize&&t[n]&&e.deserialize(t[n])}))}},{key:"getScene",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0;if(_p.isScene(t))return t;var r=this.scenes.get(t)||null;if(!r&&e){var o=n||qc;throw Reflect.construct(o,["Scene with name ".concat(t," not found")])}return r}},{key:"constructStory",value:function(){var t=this.entryScene;if(!t)throw new Error("Story must have an entry scene");return this.constructSceneRoots(t),t.registerSrc(this),t.assignActionId(this),t.assignElementId(this),this.runStaticCheck(t),this}},{key:"getAllElementStates",value:function(){var t;return this.getAllChildrenElements(this,(null===(t=this.entryScene)||void 0===t?void 0:t.getSceneRoot())||[]).map((function(t){return{id:t.getId(),data:t.toData()}})).filter((function(t){return!!t.data}))}},{key:"constructSceneRoots",value:function(t){var n=new Set,r=[],o=0;for(t.constructSceneRoot(this),r.push(t.getSceneRoot());r.length;){if(++o>e.MAX_DEPTH)throw new Error("Max depth reached while constructing scene roots (max depth: ".concat(e.MAX_DEPTH,")"));var i=r.shift();if(_p.isScene(i.callee)){if(n.has(i.callee))continue;i.callee.isSceneRootConstructed()||i.callee.constructSceneRoot(this),n.add(i.callee)}var a=i.getFutureActions(this,{allowFutureScene:!0});r.push.apply(r,$p(a))}return this}},{key:"initPersistent",value:function(t){return this.persistent.forEach((function(e){e.init(t)})),this}},{key:"getInversionConfig",value:function(){var t=this.config.origin;return{invertY:t===Vp.bottomLeft||t===Vp.bottomRight,invertX:t===Vp.bottomRight||t===Vp.topRight}}},{key:"runStaticCheck",value:function(t){return new Wc(t).run(this)}}],o=[{key:"empty",value:function(){return new e("empty").entry(new _p("empty"))}}],r&&qp(n.prototype,r),o&&qp(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(xf);function td(t){return td="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},td(t)}function ed(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nd(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nd(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function rd(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,od(r.key),r)}}function od(t){var e=function(t,e){if("object"!=td(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=td(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==td(e)?e:e+""}function id(t,e,n){return e=ud(e),function(t,e){if(e&&("object"==td(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ad()?Reflect.construct(e,n||[],ud(t).constructor):e.apply(t,n))}function ad(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ad=function(){return!!t})()}function sd(){return sd="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ud(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},sd.apply(null,arguments)}function ud(t){return ud=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ud(t)}function cd(t,e){return cd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},cd(t,e)}Jp.defaultConfig={origin:Vp.bottomLeft},Jp.MAX_DEPTH=1e4;var ld=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),id(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&cd(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var n,r,o,i,a,s,u=ed(this.contentNode.getContent(),2),c=u[0],l=u[1],f=this.callee.triggerAction(Gp.getCtx({gameState:t}),c,l);return L.isAwaitable(f)?L.forward(f,{type:this.type,node:null===(n=this.contentNode)||void 0===n?void 0:n.getChild()}):(r=e,o="executeAction",i=this,s=sd(ud(1&(a=3)?r.prototype:r),o,i),2&a&&"function"==typeof s?function(t){return s.apply(i,t)}:s)([t])}}],r&&rd(n.prototype,r),o&&rd(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function fd(t){return fd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fd(t)}function hd(t){return function(t){if(Array.isArray(t))return pd(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return pd(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pd(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function dd(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function yd(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,vd(r.key),r)}}function md(t,e,n){return e&&yd(t.prototype,e),n&&yd(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function vd(t){var e=function(t,e){if("object"!=fd(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=fd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==fd(e)?e:e+""}function gd(t,e,n){return e=wd(e),function(t,e){if(e&&("object"==fd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,bd()?Reflect.construct(e,n||[],wd(t).constructor):e.apply(t,n))}function bd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(bd=function(){return!!t})()}function wd(t){return wd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wd(t)}function Sd(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kd(t,e)}function kd(t,e){return kd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},kd(t,e)}var xd=function(t){function e(){return dd(this,e),gd(this,e,arguments)}return Sd(e,t),md(e)}(function(t){function e(){return dd(this,e),gd(this,e,arguments)}return Sd(e,t),md(e)}(function(t){function e(){var t;return dd(this,e),(t=gd(this,e,arguments))._handlers={},t}return Sd(e,t),md(e,[{key:"on",value:function(t,e){return this._registerActionHandler(t,e),this}},{key:"trigger",value:function(t){for(var e=this.chain(),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.chain(this._createAction(e,t,r))}},{key:"triggerAction",value:function(t,e,n){var r=this._handlers[e];if(r){if("AsyncFunction"===(a=r).constructor.name||"[object AsyncFunction]"===Object.prototype.toString.call(a)){var o=[],i=(new L).registerSkipController(new z((function(){for(var t=0,e=o;t<e.length;t++){var n=e[t];null==n||n()}})));return r.apply(void 0,[Object.assign(Object.assign({},t),{onAbort:function(t){o.push(t)}})].concat(hd(n))).then((function(){return i.resolve()})),i}var a;r.apply(void 0,[Object.assign(Object.assign({},t),{onAbort:function(){}})].concat(hd(n)))}else t.gameState.logger.warn("(in User-Defined Service) Trying to trigger action ".concat(e,' before it\'s registered, please use "service.on" to register the action'))}},{key:"_registerActionHandler",value:function(t,e){this._handlers[t]=e}},{key:"_createAction",value:function(t,e,n){return new ld(t,"service:action",(new jt).setContent([e,n]))}}])}(Rs)));function _d(t){return _d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_d(t)}function Ad(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ad=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),s=new P(r||[]);return o(a,"_invoke",{value:T(t,n,s)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};c(w,a,(function(){return this}));var S=Object.getPrototypeOf,k=S&&S(S(C([])));k&&k!==n&&r.call(k,a)&&(w=k);var x=b.prototype=v.prototype=Object.create(w);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==_d(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function T(e,n,r){var o=h;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var u=O(s,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var c=f(e,n,r);if("normal"===c.type){if(o=r.done?y:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=y,r.method="throw",r.arg=c.arg)}}}function O(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,O(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=f(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function C(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(_d(e)+" is not iterable")}return g.prototype=b,o(x,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(x),t},e.awrap=function(t){return{__await:t}},_(A.prototype),c(A.prototype,s,(function(){return this})),e.AsyncIterator=A,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new A(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(x),c(x,u,"Generator"),c(x,a,(function(){return this})),c(x,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return s.type="throw",s.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function Td(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Od(r.key),r)}}function Od(t){var e=function(t,e){if("object"!=_d(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=_d(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_d(e)?e:e+""}function Ed(t,e,n){return e=Cd(e),function(t,e){if(e&&("object"==_d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,jd()?Reflect.construct(e,n||[],Cd(t).constructor):e.apply(t,n))}function jd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jd=function(){return!!t})()}function Pd(){return Pd="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Cd(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Pd.apply(null,arguments)}function Cd(t){return Cd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cd(t)}function Id(t,e){return Id=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Id(t,e)}var Rd=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},Dd=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ed(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Id(t,e)}(e,t),n=e,r=[{key:"executeAction",value:function(t){var n=this,r=this.callee;if(n.is(e,"video:play"))return this.changeStateAsync(t,(function(t){return t.play()}));if(n.is(e,"video:pause"))return this.changeState(t,(function(t){return t.pause()}));if(n.is(e,"video:stop"))return this.changeState(t,(function(t){return t.stop()}));if(n.is(e,"video:seek"))return this.changeState(t,(function(t){return t.seek(n.contentNode.getContent()[0])}));if(n.is(e,"video:show")){var o=r.state.display;return t.isVideoAdded(r)||(t.addVideo(r),t.stage.update()),r.state.display=!0,t.actionHistory.push(n,(function(t){r.state.display=t}),[o]),this.changeState(t,(function(t){return t.show()}))}if(n.is(e,"video:hide")){var i=r.state.display;return this.changeState(t,(function(e){r.state.display=!1,t.actionHistory.push(n,(function(t){r.state.display=t}),[i]),e.hide(),t.removeVideo(r),t.stage.update()}))}if(n.is(e,"video:resume"))return this.changeState(t,(function(t){return t.resume()}));throw this.unknownTypeError()}},{key:"changeStateBase",value:function(t,n){var r=this,o=Object.create(null,{executeAction:{get:function(){return t=e,n="executeAction",o=r,a=Pd(Cd(1&(i=1)?t.prototype:t),n,o),2&i&&"function"==typeof a?function(t){return a.apply(o,t)}:a;var t,n,o,i,a}}});if(!t.isVideoAdded(this.callee))throw new Yc("Video is being used before it is added to the game\nUse video.show() to add the video to the game");var i=this.callee,a=new L,s=t.getExposedStateAsync(i,(function(e){return Rd(r,void 0,void 0,Ad().mark((function r(){return Ad().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t.logger.debug("Video Component state exposed",e),r.next=3,n(e);case 3:a.resolve(o.executeAction.call(this,t)),t.stage.next();case 5:case"end":return r.stop()}}),r,this)})))}));return a.registerSkipController(new z(s.cancel)),a}},{key:"changeState",value:function(t,e){return this.changeStateBase(t,e)}},{key:"changeStateAsync",value:function(t,e){return this.changeStateBase(t,e)}}],r&&Td(n.prototype,r),o&&Td(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(gt);function Ld(t){return Ld="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ld(t)}function Md(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Nd(r.key),r)}}function Nd(t){var e=function(t,e){if("object"!=Ld(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ld(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ld(e)?e:e+""}function Fd(t,e,n){return e=Ud(e),function(t,e){if(e&&("object"==Ld(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Bd()?Reflect.construct(e,n||[],Ud(t).constructor):e.apply(t,n))}function Bd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Bd=function(){return!!t})()}function Ud(t){return Ud=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ud(t)}function Vd(t,e){return Vd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Vd(t,e)}Dd.ActionTypes=h;var zd=function(t){function e(t){var n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=Fd(this,e);var r=e.DefaultVideoConfig.create(t);if(n.config=r.get(),n.state=n.getInitialState(),!n.config.src)throw new qc("Video must have a src");return n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Vd(t,e)}(e,t),n=e,(r=[{key:"show",value:function(){return this.chain(this.createAction(h.show,[]))}},{key:"hide",value:function(){return this.chain(this.createAction(h.hide,[]))}},{key:"play",value:function(){return this.chain(this.createAction(h.play,[]))}},{key:"toData",value:function(){return{state:{display:this.state.display}}}},{key:"fromData",value:function(t){var e=t.state;return this.state={display:e.display},this}},{key:"reset",value:function(){return this.state=this.getInitialState(),this}},{key:"getInitialState",value:function(){return e.DefaultVideoState.create().get()}},{key:"createAction",value:function(t,e){return new Dd(this.chain(),t,jt.create(e))}}])&&Md(n.prototype,r),o&&Md(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rs);zd.DefaultVideoConfig=new ha({src:"",muted:!1}),zd.DefaultVideoState=new ha({display:!1});var Gd=o(196);function Hd(t){return Hd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hd(t)}function $d(t){return function(t){if(Array.isArray(t))return Wd(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wd(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wd(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qd(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Yd(r.key),r)}}function Yd(t){var e=function(t,e){if("object"!=Hd(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Hd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Hd(e)?e:e+""}var Xd=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.game=e,this.prefix=n},e=[{key:"log",value:function(t){if(this.isEnabled("log")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).log.apply(e,$d(this.colorLog.apply(this,["gray",t].concat(r))))}}},{key:"info",value:function(t){if(this.isEnabled("info")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).info.apply(e,$d(this._log.apply(this,[t].concat(r))))}}},{key:"warn",value:function(t){if(this.isEnabled("warn")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).warn.apply(e,$d(this._log.apply(this,[t].concat(r))))}}},{key:"error",value:function(t){if(this.isEnabled("error")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).error.apply(e,$d(this._log.apply(this,[t].concat(r))))}}},{key:"debug",value:function(t){if(this.isEnabled("debug")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).debug.apply(e,$d(this.colorLog.apply(this,["gray",t].concat(r))))}}},{key:"trace",value:function(t){if(this.isEnabled("trace")){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];console.trace(this._log.apply(this,[t].concat(n)))}}},{key:"weakWarn",value:function(t){if(this.isEnabled("warn")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).log.apply(e,$d(this.colorLog.apply(this,["yellow",t].concat(r))))}}},{key:"weakError",value:function(t){if(this.isEnabled("error")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).log.apply(e,$d(this.colorLog.apply(this,["red",t].concat(r))))}}},{key:"verbose",value:function(t){if(this.isEnabled("verbose")){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).log.apply(e,$d(this.colorLog.apply(this,["gray",t].concat(r))))}}},{key:"group",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this._log(t).join(" ");return this.isEnabled("info")&&(n?console.groupCollapsed(r):console.group(r)),{end:function(){e.isEnabled("info")&&console.groupEnd()}}}},{key:"isEnabled",value:function(t){return"boolean"==typeof this.game.config.app.logger?this.game.config.app.logger:this.game.config.app.logger[t]}},{key:"_log",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return 0===n.length?[this.prefix||"",t]:["".concat(this.prefix||""," [").concat(t,"]")].concat(n)}},{key:"colorLog",value:function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];if(0===r.length)return["%c".concat(this.prefix||""," ").concat(e),"color: ".concat(t)];var i=[],a=[],s=[];return this.prefix?(i.push("%c".concat(this.prefix," [").concat(e,"]")),a.push("color: ".concat(t))):(i.push("%c[".concat(e,"]")),a.push("color: ".concat(t))),r.forEach((function(e){"string"==typeof e?(i.push("%c".concat(e)),a.push("color: ".concat(t))):(i.push("%O"),s.push(e),a.push(""))})),[i.join(" ")].concat(a,s)}}],e&&qd(t.prototype,e),n&&qd(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function Kd(t){return Kd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kd(t)}function Zd(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Jd(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qd(t){return function(t){if(Array.isArray(t))return ty(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Jd(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jd(t,e){if(t){if("string"==typeof t)return ty(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ty(t,e):void 0}}function ty(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ey(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ny(r.key),r)}}function ny(t){var e=function(t,e){if("object"!=Kd(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Kd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Kd(e)?e:e+""}var ry=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gameState=e,this.state=new Map,this.tasks=new Map},e=[{key:"play",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{end:1,duration:0};this.state.has(t)&&this.abortTask(this.getState(t).group);var n=this.initSound(t),r=n.group,o=n.token,i=n.onPlayTask,a=n.onEndTask;return this.state.set(t,{group:r,token:o}),this.pushTask(r,(new K).addTask(i).addTask(this.fadeTo(r,o,Object.assign(Object.assign({},e),{start:0}))).addTask(this.createTask((function(n){t.state.volume=e.end,t.state.paused=!1,n()}))).addTask(a).run())}},{key:"stop",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.getState(t);return this.abortTask(n.group),0===e?(n.group.stop(n.token),L.resolve(void 0)):this.pushTask(n.group,(new K).addTask(this.fadeTo(n.group,n.token,{start:t.state.volume,end:0,duration:e})).addTask(this.createTask((function(e){n.group.volume(t.state.volume,n.token),e()}))).addTask(this.stopSound(n.group,n.token)).run())}},{key:"setVolume",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=this.getState(t);return this.abortTask(r.group),0===n?(r.group.volume(e,r.token),L.resolve(void 0)):this.pushTask(r.group,(new K).addTask(this.fadeTo(r.group,r.token,{start:t.state.volume,end:e,duration:n})).addTask(this.createTask((function(n){t.state.volume=e,n()}))).run())}},{key:"pause",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.getState(t);return this.abortTask(n.group),0===e?(n.group.pause(n.token),L.resolve(void 0)):this.pushTask(n.group,(new K).addTask(this.fadeTo(n.group,n.token,{start:t.state.volume,end:0,duration:e})).addTask(this.pauseSound(n.group,n.token)).addTask(this.createTask((function(e){n.group.volume(t.state.volume,n.token),t.state.paused=!0,e()}))).run())}},{key:"resume",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.getState(t);return this.abortTask(n.group),0===e?(n.group.play(n.token),L.resolve(void 0)):this.pushTask(n.group,(new K).addTask(this.fadeTo(n.group,n.token,{start:0,end:t.state.volume,duration:e})).addTask(this.resumeSound(n.group,n.token)).addTask(this.createTask((function(e){t.state.paused=!1,e()}))).run())}},{key:"setRate",value:function(t,e){var n=this.getState(t);return this.abortTask(n.group),n.group.rate(e,n.token),t.state.rate=e,L.resolve(void 0)}},{key:"getPosition",value:function(t){var e=this.getState(t);return e.group.seek(e.token)}},{key:"isPlaying",value:function(t){if(!this.isManaged(t))return!1;var e=this.getState(t);return e.group.playing(e.token)}},{key:"toData",value:function(){return{sounds:Qd(this.state.entries()).map((function(t){var e=Zd(t,2),n=e[0],r=e[1];return[n.getId(),{isPlaying:r.group.playing(r.token),position:r.group.seek(r.token)}]}))}}},{key:"fromData",value:function(t,e){var n=this;return t.sounds.forEach((function(t){var r=Zd(t,2),o=r[0],i=r[1],a=e.get(o);if(!a)throw new Yc('Sound not found (id: "'.concat(o,'")')+"\nNarraLeaf cannot find the element with the id from the saved game");n.soundFromData(a,i)})),this}},{key:"soundFromData",value:function(t,e){var n=this.getState(t);n.group.playing(n.token)&&n.group.stop(n.token);var r=this.initSound(t);this.state.set(t,r),r.group.seek(e.position,r.token),t.state.paused?r.group.pause(r.token):e.isPlaying||r.group.stop(r.token)}},{key:"isManaged",value:function(t){return this.state.has(t)}},{key:"reset",value:function(){this.state.forEach((function(t){t.group.stop(t.token)})),this.state.clear(),this.tasks.forEach((function(t){t.awaitable.abort()})),this.tasks.clear()}},{key:"initSound",value:function(t){if(this.state.has(t))return this.state.get(t);var e=this,n=Zd(this.wrapTask(),2),r=n[0],o=n[1],i=Zd(this.wrapTask(),2),a=i[0],s=i[1],u=Reflect.construct(this.gameState.getHowl(),[this.getHowlConfig(t,{onend:function(){a.resolve()},onplay:function(){r.resolve()},onloaderror:function(n,r){var o=r;e.gameState.logger.error("AudioManager",'Failed to load sound (src: "'.concat(t.config.src,'")')+" \n".concat({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."}[o])+" \nFor more information, see https://github.com/goldfire/howler.js?tab=readme-ov-file#onloaderror-function")}})]),c=u.play();return this.state.set(t,{group:u,token:c}),u.seek(t.config.seek,c).volume(t.state.volume,c).rate(t.state.rate,c),t.state.paused&&u.pause(c),{group:u,token:c,onPlayTask:o,onEndTask:s}}},{key:"pushTask",value:function(t,e){return this.tasks.set(t,{awaitable:e}),e}},{key:"getState",value:function(t){if(!this.state.has(t))throw new Yc('Sound not initialized (src: "'.concat(t.config.src,'")'));return this.state.get(t)}},{key:"abortTask",value:function(t){var e=this.tasks.get(t);e&&(e.awaitable.abort(),this.tasks.delete(t))}},{key:"fadeTo",value:function(t,e,n){var r,o,i,a,s=this,u=null!==(r=n.start)&&void 0!==r?r:t.volume(),c=null!==(o=n.end)&&void 0!==o?o:t.volume(),l=n.duration;return[function(n){t.volume(u,e),t.fade(u,c,l,e),i=function(){n.isSolved()||(a&&(a(),a=void 0),n.resolve())},a=s.gameState.schedule((function(){a=void 0,i()}),l)},new z((function(){t.volume(c,e),i()}))]}},{key:"stopSound",value:function(t,e){return[function(){t.stop(e)}]}},{key:"pauseSound",value:function(t,e){return[function(){t.pause(e)}]}},{key:"resumeSound",value:function(t,e){return[function(){t.play(e)}]}},{key:"getHowlConfig",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.assign({src:t.config.src,volume:t.state.volume,loop:t.config.loop,rate:t.state.rate,html5:t.config.streaming},e)}},{key:"createTask",value:function(t){return[function(e){t(e.resolve.bind(e))}]}},{key:"wrapTask",value:function(){var t=new L;return[t,[function(e){t.isSolved()?e.resolve():t.then((function(){e.resolve()}))}]]}}],e&&ey(t.prototype,e),n&&ey(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();const oy=(()=>{let t=0;return()=>(t+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${t}`)})();function iy(t){const e=[];for(let n=0,r=t.length;n<r;n++)e.push(t[n]);return e}function ay(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function sy(t,e={}){return{width:e.width||function(t){const e=ay(t,"border-left-width"),n=ay(t,"border-right-width");return t.clientWidth+e+n}(t),height:e.height||function(t){const e=ay(t,"border-top-width"),n=ay(t,"border-bottom-width");return t.clientHeight+e+n}(t)}}const uy=16384;function cy(t){return new Promise(((e,n)=>{const r=new Image;r.decode=()=>e(r),r.onload=()=>e(r),r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=t}))}async function ly(t,e,n){const r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg"),i=document.createElementNS(r,"foreignObject");return o.setAttribute("width",`${e}`),o.setAttribute("height",`${n}`),o.setAttribute("viewBox",`0 0 ${e} ${n}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),o.appendChild(i),i.appendChild(t),async function(t){return Promise.resolve().then((()=>(new XMLSerializer).serializeToString(t))).then(encodeURIComponent).then((t=>`data:image/svg+xml;charset=utf-8,${t}`))}(o)}const fy=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===e.name||fy(n,e))};function hy(t,e,n){const r=`.${t}:${e}`,o=n.cssText?function(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}(n):function(t){return iy(t).map((e=>`${e}: ${t.getPropertyValue(e)}${t.getPropertyPriority(e)?" !important":""};`)).join(" ")}(n);return document.createTextNode(`${r}{${o}}`)}function py(t,e,n){const r=window.getComputedStyle(t,n),o=r.getPropertyValue("content");if(""===o||"none"===o)return;const i=oy();try{e.className=`${e.className} ${i}`}catch(t){return}const a=document.createElement("style");a.appendChild(hy(i,n,r)),e.appendChild(a)}const dy="application/font-woff",yy="image/jpeg",my={woff:dy,woff2:dy,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:yy,jpeg:yy,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function vy(t){const e=function(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return my[e]||""}function gy(t){return-1!==t.search(/^(data:)/)}function by(t,e){return`data:${e};base64,${t}`}async function wy(t,e,n){const r=await fetch(t,e);if(404===r.status)throw new Error(`Resource "${r.url}" not found`);const o=await r.blob();return new Promise(((t,e)=>{const i=new FileReader;i.onerror=e,i.onloadend=()=>{try{t(n({res:r,result:i.result}))}catch(t){e(t)}},i.readAsDataURL(o)}))}const Sy={};async function ky(t,e,n){const r=function(t,e,n){let r=t.replace(/\?.*/,"");return n&&(r=t),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),e?`[${e}]${r}`:r}(t,e,n.includeQueryParams);if(null!=Sy[r])return Sy[r];let o;n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());try{const r=await wy(t,n.fetchRequestInit,(({res:t,result:n})=>(e||(e=t.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n))));o=by(r,e)}catch(e){o=n.imagePlaceholder||"";let r=`Failed to fetch resource: ${t}`;e&&(r="string"==typeof e?e:e.message),r&&console.warn(r)}return Sy[r]=o,o}async function xy(t,e){return fy(t,HTMLCanvasElement)?async function(t){const e=t.toDataURL();return"data:,"===e?t.cloneNode(!1):cy(e)}(t):fy(t,HTMLVideoElement)?async function(t,e){if(t.currentSrc){const e=document.createElement("canvas"),n=e.getContext("2d");return e.width=t.clientWidth,e.height=t.clientHeight,null==n||n.drawImage(t,0,0,e.width,e.height),cy(e.toDataURL())}const n=t.poster,r=vy(n);return cy(await ky(n,r,e))}(t,e):fy(t,HTMLIFrameElement)?async function(t){var e;try{if(null===(e=null==t?void 0:t.contentDocument)||void 0===e?void 0:e.body)return await Ty(t.contentDocument.body,{},!0)}catch(t){}return t.cloneNode(!1)}(t):t.cloneNode(!1)}const _y=t=>null!=t.tagName&&"SLOT"===t.tagName.toUpperCase();function Ay(t,e){return fy(e,Element)&&(function(t,e){const n=e.style;if(!n)return;const r=window.getComputedStyle(t);r.cssText?(n.cssText=r.cssText,n.transformOrigin=r.transformOrigin):iy(r).forEach((o=>{let i=r.getPropertyValue(o);if("font-size"===o&&i.endsWith("px")){const t=Math.floor(parseFloat(i.substring(0,i.length-2)))-.1;i=`${t}px`}fy(t,HTMLIFrameElement)&&"display"===o&&"inline"===i&&(i="block"),"d"===o&&e.getAttribute("d")&&(i=`path(${e.getAttribute("d")})`),n.setProperty(o,i,r.getPropertyPriority(o))}))}(t,e),function(t,e){py(t,e,":before"),py(t,e,":after")}(t,e),function(t,e){fy(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),fy(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,e),function(t,e){if(fy(t,HTMLSelectElement)){const n=e,r=Array.from(n.children).find((e=>t.value===e.getAttribute("value")));r&&r.setAttribute("selected","")}}(t,e)),e}async function Ty(t,e,n){return n||!e.filter||e.filter(t)?Promise.resolve(t).then((t=>xy(t,e))).then((n=>async function(t,e,n){var r,o;let i=[];return i=_y(t)&&t.assignedNodes?iy(t.assignedNodes()):fy(t,HTMLIFrameElement)&&(null===(r=t.contentDocument)||void 0===r?void 0:r.body)?iy(t.contentDocument.body.childNodes):iy((null!==(o=t.shadowRoot)&&void 0!==o?o:t).childNodes),0===i.length||fy(t,HTMLVideoElement)||await i.reduce(((t,r)=>t.then((()=>Ty(r,n))).then((t=>{t&&e.appendChild(t)}))),Promise.resolve()),e}(t,n,e))).then((e=>Ay(t,e))).then((t=>async function(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;const r={};for(let o=0;o<n.length;o++){const i=n[o].getAttribute("xlink:href");if(i){const n=t.querySelector(i),o=document.querySelector(i);n||!o||r[i]||(r[i]=await Ty(o,e,!0))}}const o=Object.values(r);if(o.length){const e="http://www.w3.org/1999/xhtml",n=document.createElementNS(e,"svg");n.setAttribute("xmlns",e),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";const r=document.createElementNS(e,"defs");n.appendChild(r);for(let t=0;t<o.length;t++)r.appendChild(o[t]);t.appendChild(n)}return t}(t,e))):null}const Oy=/url\((['"]?)([^'"]+?)\1\)/g,Ey=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jy=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;async function Py(t,e,n,r,o){try{const i=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),e&&(r.href=e),o.href=t,o.href}(e,n):e,a=vy(e);let s;if(o){s=by(await o(i),a)}else s=await ky(i,a,r);return t.replace(function(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}(e),`$1${s}$3`)}catch(t){}return t}function Cy(t){return-1!==t.search(Oy)}async function Iy(t,e,n){if(!Cy(t))return t;const r=function(t,{preferredFontFormat:e}){return e?t.replace(jy,(t=>{for(;;){const[n,,r]=Ey.exec(t)||[];if(!r)return"";if(r===e)return`src: ${n};`}})):t}(t,n),o=function(t){const e=[];return t.replace(Oy,((t,n,r)=>(e.push(r),t))),e.filter((t=>!gy(t)))}(r);return o.reduce(((t,r)=>t.then((t=>Py(t,r,e,n)))),Promise.resolve(r))}async function Ry(t,e,n){var r;const o=null===(r=e.style)||void 0===r?void 0:r.getPropertyValue(t);if(o){const r=await Iy(o,null,n);return e.style.setProperty(t,r,e.style.getPropertyPriority(t)),!0}return!1}async function Dy(t,e){fy(t,Element)&&(await async function(t,e){await Ry("background",t,e)||await Ry("background-image",t,e),await Ry("mask",t,e)||await Ry("mask-image",t,e)}(t,e),await async function(t,e){const n=fy(t,HTMLImageElement);if((!n||gy(t.src))&&(!fy(t,SVGImageElement)||gy(t.href.baseVal)))return;const r=n?t.src:t.href.baseVal,o=await ky(r,vy(r),e);await new Promise(((e,r)=>{t.onload=e,t.onerror=r;const i=t;i.decode&&(i.decode=e),"lazy"===i.loading&&(i.loading="eager"),n?(t.srcset="",t.src=o):t.href.baseVal=o}))}(t,e),await async function(t,e){const n=iy(t.childNodes).map((t=>Dy(t,e)));await Promise.all(n).then((()=>t))}(t,e))}const Ly={};async function My(t){let e=Ly[t];if(null!=e)return e;const n=await fetch(t);return e={url:t,cssText:await n.text()},Ly[t]=e,e}async function Ny(t,e){let n=t.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map((async o=>{let i=o.replace(r,"$1");return i.startsWith("https://")||(i=new URL(i,t.url).href),wy(i,e.fetchRequestInit,(({result:t})=>(n=n.replace(o,`url(${t})`),[o,t])))}));return Promise.all(o).then((()=>n))}function Fy(t){if(null==t)return[];const e=[];let n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const t=r.exec(n);if(null===t)break;e.push(t[0])}n=n.replace(r,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=o.exec(n);if(null===t){if(t=i.exec(n),null===t)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;e.push(t[0])}return e}async function By(t,e){if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");const n=iy(t.ownerDocument.styleSheets),r=await async function(t,e){const n=[],r=[];return t.forEach((n=>{if("cssRules"in n)try{iy(n.cssRules||[]).forEach(((t,o)=>{if(t.type===CSSRule.IMPORT_RULE){let i=o+1;const a=My(t.href).then((t=>Ny(t,e))).then((t=>Fy(t).forEach((t=>{try{n.insertRule(t,t.startsWith("@import")?i+=1:n.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}})))).catch((t=>{console.error("Error loading remote css",t.toString())}));r.push(a)}}))}catch(o){const i=t.find((t=>null==t.href))||document.styleSheets[0];null!=n.href&&r.push(My(n.href).then((t=>Ny(t,e))).then((t=>Fy(t).forEach((t=>{i.insertRule(t,n.cssRules.length)})))).catch((t=>{console.error("Error loading remote stylesheet",t)}))),console.error("Error inlining remote css file",o)}})),Promise.all(r).then((()=>(t.forEach((t=>{if("cssRules"in t)try{iy(t.cssRules||[]).forEach((t=>{n.push(t)}))}catch(e){console.error(`Error while reading CSS rules from ${t.href}`,e)}})),n)))}(n,e);return function(t){return t.filter((t=>t.type===CSSRule.FONT_FACE_RULE)).filter((t=>Cy(t.style.getPropertyValue("src"))))}(r)}async function Uy(t,e){const n=await By(t,e);return(await Promise.all(n.map((t=>{const n=t.parentStyleSheet?t.parentStyleSheet.href:null;return Iy(t.cssText,n,e)})))).join("\n")}async function Vy(t,e={}){const{width:n,height:r}=sy(t,e),o=await Ty(t,e,!0);await async function(t,e){const n=null!=e.fontEmbedCSS?e.fontEmbedCSS:e.skipFonts?null:await Uy(t,e);if(n){const e=document.createElement("style"),r=document.createTextNode(n);e.appendChild(r),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}}(o,e),await Dy(o,e),function(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const r=e.style;null!=r&&Object.keys(r).forEach((t=>{n[t]=r[t]}))}(o,e);return await ly(o,n,r)}async function zy(t,e={}){const{width:n,height:r}=sy(t,e),o=await Vy(t,e),i=await cy(o),a=document.createElement("canvas"),s=a.getContext("2d"),u=e.pixelRatio||function(){let t,e;try{e=process}catch(t){}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),c=e.canvasWidth||n,l=e.canvasHeight||r;return a.width=c*u,a.height=l*u,e.skipAutoScale||function(t){(t.width>uy||t.height>uy)&&(t.width>uy&&t.height>uy?t.width>t.height?(t.height*=uy/t.width,t.width=uy):(t.width*=uy/t.height,t.height=uy):t.width>uy?(t.height*=uy/t.width,t.width=uy):(t.width*=uy/t.height,t.height=uy))}(a),a.style.width=`${c}`,a.style.height=`${l}`,e.backgroundColor&&(s.fillStyle=e.backgroundColor,s.fillRect(0,0,a.width,a.height)),s.drawImage(i,0,0,a.width,a.height),a}async function Gy(t,e={}){const{width:n,height:r}=sy(t,e);return(await zy(t,e)).getContext("2d").getImageData(0,0,n,r).data}async function Hy(t,e={}){return(await zy(t,e)).toDataURL()}async function $y(t,e={}){return(await zy(t,e)).toDataURL("image/jpeg",e.quality||1)}async function Wy(t,e={}){const n=await zy(t,e),r=await function(t,e={}){return t.toBlob?new Promise((n=>{t.toBlob(n,e.type?e.type:"image/png",e.quality?e.quality:1)})):new Promise((n=>{const r=window.atob(t.toDataURL(e.type?e.type:void 0,e.quality?e.quality:void 0).split(",")[1]),o=r.length,i=new Uint8Array(o);for(let t=0;t<o;t+=1)i[t]=r.charCodeAt(t);n(new Blob([i],{type:e.type?e.type:"image/png"}))}))}(n);return r}async function qy(t,e={}){return Uy(t,e)}function Yy(t){return Yy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yy(t)}function Xy(t){return function(t){if(Array.isArray(t))return Ky(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ky(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ky(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ky(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Zy(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Qy(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,tm(r.key),r)}}function Jy(t,e,n){return e&&Qy(t.prototype,e),n&&Qy(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function tm(t){var e=function(t,e){if("object"!=Yy(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Yy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Yy(e)?e:e+""}var em=function(){return Jy((function t(e,n){Zy(this,t),this.gameState=e,this.notifications=n,this.events=new F}),[{key:"addNotification",value:function(t){this.notifications.push(t),this.flush()}},{key:"removeNotification",value:function(t){this.notifications=this.notifications.filter((function(e){return e!==t})),this.flush()}},{key:"clearNotifications",value:function(){this.notifications=[],this.flush()}},{key:"consume",value:function(t){var e=this,n=new L,r=new Ya(n);return n.registerSkipController(new z((function(){e.removeNotification(t)}))),this.addNotification(t),this.gameState.schedule((function(){n.resolve(),e.removeNotification(t)}),t.duration),this.gameState.timelines.attachTimeline(r),n}},{key:"onFlush",value:function(t){return this.events.on("event:notifications.flush",t)}},{key:"toArray",value:function(){return Xy(this.notifications)}},{key:"flush",value:function(){this.events.emit("event:notifications.flush")}}])}();function nm(t){return nm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nm(t)}function rm(t){return function(t){if(Array.isArray(t))return om(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return om(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?om(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function om(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function im(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,am(r.key),r)}}function am(t){var e=function(t,e){if("object"!=nm(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=nm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==nm(e)?e:e+""}var sm=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.history=[],this.hooks={onUndo:[],onHistoryLimit:[]},this.maxHistorySize=e},e=[{key:"push",value:function(t,e,n,r){var o=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;r<t;r++)e+=n.charAt(Math.floor(62*Math.random()));return e}(6);if(this.history.push({action:t,id:o,args:n,undo:e,timeline:r}),this.history.length>this.maxHistorySize){var i=this.history.splice(0,this.history.length-this.maxHistorySize);this.hooks.onHistoryLimit.forEach((function(t){return t(i)}))}return{id:o}}},{key:"undoUntil",value:function(t){for(var e,n,r,o=-1,i=this.history.length-1;i>=0;i--)if(this.history[i].id===t){o=i;break}if(-1===o)return null;for(var a=[],s=this.history.length-1;s>=o;s--){var u;this.history[s].timeline&&!this.history[s].timeline.isSettled&&this.history[s].timeline.abort(),null===(n=(e=this.history[s]).undo)||void 0===n||(u=n).call.apply(u,[e].concat(rm(this.history[s].args||[]))),a.push(this.history[s])}return this.history.splice(o),this.hooks.onUndo.forEach((function(t){return t(a)})),(null===(r=a[a.length-1])||void 0===r?void 0:r.action)||null}},{key:"undo",value:function(){var t,e,n=this.history.pop();return n?(n.timeline&&!n.timeline.isSettled&&n.timeline.abort(),null===(t=n.undo)||void 0===t||(e=t).call.apply(e,[n].concat(rm(n.args))),this.hooks.onUndo.forEach((function(t){return t([n])})),n.action):null}},{key:"onUndo",value:function(t){var e=this;return this.hooks.onUndo.push(t),{cancel:function(){return e.offUndo(t)}}}},{key:"offUndo",value:function(t){this.hooks.onUndo=this.hooks.onUndo.filter((function(e){return e!==t}))}},{key:"getHistory",value:function(){return this.history}},{key:"onHistoryLimit",value:function(t){var e=this;return this.hooks.onHistoryLimit.push(t),{cancel:function(){return e.offHistoryLimit(t)}}}},{key:"offHistoryLimit",value:function(t){this.hooks.onHistoryLimit=this.hooks.onHistoryLimit.filter((function(e){return e!==t}))}},{key:"reset",value:function(){this.history=[]}}],e&&im(t.prototype,e),n&&im(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function um(t){return um="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},um(t)}function cm(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,lm(r.key),r)}}function lm(t){var e=function(t,e){if("object"!=um(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=um(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==um(e)?e:e+""}var fm=function(){return t=function t(e){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.history=[],this.actionHistoryMgr=e,this.actionHistoryMgr.onUndo((function(t){n.crossFilter(t)})),this.actionHistoryMgr.onHistoryLimit((function(t){n.crossFilter(t)}))},(e=[{key:"push",value:function(t){return this.history.push(t),this}},{key:"getHistory",value:function(){return this.history}},{key:"reset",value:function(){this.history=[]}},{key:"crossFilter",value:function(t){var e=new Set(t.map((function(t){return t.id})));this.history=this.history.filter((function(t){return!e.has(t.token)}))}}])&&cm(t.prototype,e),n&&cm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function hm(t){return hm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hm(t)}function pm(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||ym(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dm(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ym(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function ym(t,e){if(t){if("string"==typeof t)return mm(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mm(t,e):void 0}}function mm(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function vm(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,gm(r.key),r)}}function gm(t){var e=function(t,e){if("object"!=hm(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=hm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==hm(e)?e:e+""}var bm=function(){function e(n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.state={sounds:[],videos:[],srcManagers:[],elements:[]},this.currentHandling=null,this.playerCurrent=null,this.mainContentNode=null,this.exposedState=new Map,this.htmlToImage=t,this.stage=r,this.game=n,this.events=new F,this.logger=new Xd(n,"NarraLeaf-React"),this.audioManager=new ry(this),this.guard=new Fa(n.config.app.guard).observe(this),this.timelines=new Xa(this.guard),this.notificationMgr=new em(this,[]),this.idManager=new et,this.actionHistory=new sm,this.gameHistory=new fm(this.actionHistory)}return n=e,r=[{key:"addVideo",value:function(t){return this.state.videos.push(t),this}},{key:"removeVideo",value:function(t){var e=this.state.videos.indexOf(t);return-1===e?(this.logger.weakWarn("Video not found when removing",t.getId()),this):(this.state.videos.splice(e,1),this)}},{key:"isVideoAdded",value:function(t){return this.state.videos.includes(t)}},{key:"getVideos",value:function(){return this.state.videos}},{key:"findElementByScene",value:function(t){return this.state.elements.find((function(e){return e.scene===t}))||null}},{key:"findElementByDisplayable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.state.elements.find((function(n){var r;if(e)return(null===(r=n.layers.get(e))||void 0===r?void 0:r.includes(t))||!1;var o,i=dm(n.layers.values());try{for(i.s();!(o=i.n()).done;)if(o.value.includes(t))return!0}catch(t){i.e(t)}finally{i.f()}return!1}))||null}},{key:"removeElement",value:function(t){var e=this.state.elements.indexOf(t);return-1===e?(this.logger.weakWarn("Element not found when removing",t.scene.getId()),this):(this.state.elements.splice(e,1),this)}},{key:"addElement",value:function(t){return this.state.elements.push(t),this}},{key:"addScene",value:function(t){return this.sceneExists(t)||this.state.elements.unshift({scene:t,texts:[],menus:[],layers:new Map(t.config.layers.map((function(t){return[t,[]]})))}),this}},{key:"flush",value:function(){return this.stage.update(),this}},{key:"popScene",value:function(){var t=this.state.elements.pop();return t?(this.removeElements(t.scene),this):this}},{key:"removeScene",value:function(t){return this.removeElements(t),this}},{key:"getSceneElements",value:function(){return this.state.elements}},{key:"getLastScene",value:function(){var t;return(null===(t=this.state.elements[this.state.elements.length-1])||void 0===t?void 0:t.scene)||null}},{key:"sceneExists",value:function(t){return t?this.state.elements.some((function(e){return e.scene===t})):!!this.getLastScene()}},{key:"isSceneActive",value:function(t){var e,n=dm(this.state.elements);try{for(n.s();!(e=n.n()).done;)if(e.value.scene===t)return!0}catch(t){n.e(t)}finally{n.f()}return!1}},{key:"wait",value:function(t){return new Promise((function(e){return setTimeout(e,t)}))}},{key:"schedule",value:function(t,e){var n=this,r=setTimeout((function(){t({retry:function(){n.schedule(t,0)}})}),e);return function(){return clearTimeout(r)}}},{key:"notify",value:function(t){this.notificationMgr.addNotification(t)}},{key:"handle",value:function(t){return this.currentHandling===t||(this.currentHandling=t,t.type),this}},{key:"createDialog",value:function(t,e,n,r){var o,i=null===(o=this.findElementByScene(this.getLastSceneIfNot(r)))||void 0===o?void 0:o.texts;if(!i)throw this.sceneNotFound();var a=e.evaluate(Gp.getCtx({gameState:this}));this.game.getLiveGame().events.emit(Am.EventTypes["event:character.prompt"],{character:e.config.character,sentence:e,text:Oc.getText(a)});var s=this.createWaitableAction({character:e.config.character,sentence:e,id:t,words:a},(function(){i.splice(i.indexOf(s),1),n&&n()}));return i.push(s),{cancel:function(){var t=i.indexOf(s);-1!==t&&i.splice(t,1)},text:Oc.getText(a)}}},{key:"createMenu",value:function(t,e,n){var r,o=this;if(!t.choices.length)throw new Error("Menu must have at least one choice");var i=null===(r=this.findElementByScene(this.getLastSceneIfNot(n)))||void 0===r?void 0:r.menus;if(!i)throw this.sceneNotFound();var a=t.prompt.evaluate(Gp.getCtx({gameState:this})),s=this.createWaitableAction(Object.assign(Object.assign({},t),{words:a}),(function(t){i.splice(i.indexOf(s),1),e&&e(t),o.game.getLiveGame().events.emit(Am.EventTypes["event:menu.choose"],{sentence:t.prompt,text:t.evaluated})}));return i.push(s),{cancel:function(){var t=i.indexOf(s);-1!==t&&i.splice(t,1)},prompt:Oc.getText(a)}}},{key:"createDisplayable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=this.getLastSceneIfNot(e),o=this.findElementByScene(r);if(!o)throw this.sceneNotFound();var i=o.layers.get(n||r.config.defaultDisplayableLayer);if(!i)throw this.layerNotFound();return i.push(t),this}},{key:"disposeDisplayable",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=this.getLastSceneIfNot(n),i=null===(e=this.findElementByScene(o))||void 0===e?void 0:e.layers.get(r||o.config.defaultDisplayableLayer);if(!i)throw this.layerNotFound();var a=i.indexOf(t);if(-1===a)throw new Yc("Displayables not found when disposing. (disposing: ".concat(t.getId(),")"));return i.splice(a,1),this}},{key:"forceReset",value:function(){var t=this;this.state.elements.forEach((function(e){var n=e.scene;t.offSrcManager(n.srcManager),t.removeScene(n),n.events.clear()})),this.state.elements=[],this.state.srcManagers=[],this.state.videos=[],this.audioManager.reset(),this.timelines.abortAll(),this.gameHistory.reset(),this.actionHistory.reset()}},{key:"getHowl",value:function(){return Gd.Howl}},{key:"registerSrcManager",value:function(t){return this.state.srcManagers.push(t),this}},{key:"offSrcManager",value:function(t){return this.state.srcManagers=this.state.srcManagers.filter((function(e){return e!==t})),this}},{key:"getStorable",value:function(){return this.game.getLiveGame().getStorable()}},{key:"getSceneByName",value:function(t){var e;return(null===(e=this.game.getLiveGame().story)||void 0===e?void 0:e.getScene(t))||null}},{key:"getStory",value:function(){if(!this.game.getLiveGame().story)throw new Yc("Story not loaded");return this.game.getLiveGame().story}},{key:"setInterval",value:function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return setInterval(t,e)}))},{key:"clearInterval",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){clearInterval(t)}))},{key:"setTimeout",value:function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return setTimeout(t,e)}))},{key:"clearTimeout",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){clearTimeout(t)}))},{key:"forceAnimation",value:function(){var t=this,e=pm(Ya.proxy(L.nothing),2),n=e[0],r=e[1],o=[];return Array.from(this.exposedState.keys()).forEach((function(t){t instanceof Du&&o.push(t)})),o.forEach((function(e){var n=t.getExposedStateForce(e).applyTransform(Ta.immediate({}),(function(){}));r.attachChild(n)})),this.timelines.attachTimeline(r),n}},{key:"mountState",value:function(t,n){var r=this;if(this.exposedState.has(t))throw new Xc("State already mounted");if(!t)throw new Xc("Invalid state key");return this.exposedState.set(t,n),this.events.emit(e.EventTypes["event.state.onExpose"],t,n),{unMount:function(){r.unMountState(t)}}}},{key:"unMountState",value:function(t){return this.exposedState.has(t)||this.guard.warn(Pa.invalidExposedStateUnmounting,"State not found when unmounting"),this.exposedState.delete(t),this}},{key:"initVideo",value:function(t){return this.state.videos.push(t),this}},{key:"isStateMounted",value:function(t){return this.exposedState.has(t)}},{key:"getExposedState",value:function(t){return this.exposedState.get(t)||null}},{key:"getExposedStateForce",value:function(t){var e=this.getExposedState(t);if(!e)throw new Yc("State not found, key: "+t);return e}},{key:"getExposedStateAsync",value:function(t,n){var r=this.getExposedState(t);if(r)return{cancel:this.schedule((function(){n(r)}),0)};var o=this.events.on(e.EventTypes["event.state.onExpose"],(function(e,r){e===t&&(n(r),o.cancel())}));return o}},{key:"dispose",value:function(){this.forceReset()}},{key:"toData",value:function(){return{scenes:this.state.elements.map((function(t){return{sceneId:t.scene.getId(),elements:{layers:Object.fromEntries(Array.from(t.layers.entries()).map((function(t){var e=pm(t,2),n=e[0],r=e[1];return[n.getId(),r.map((function(t){return t.getId()}))]})))}}})),audio:this.audioManager.toData(),videos:this.state.videos.map((function(t){return[t.getId(),t.toData()]}))}}},{key:"loadData",value:function(t,e){var n=this;if(this.state.elements=[],!this.game.getLiveGame().story)throw new Error("No story loaded");var r=t.scenes,o=t.audio,i=t.videos;r.forEach((function(t){var r=t.sceneId,o=t.elements;n.logger.debug("Loading scene: "+r);var i=e.get(r);if(!i)throw new Yc("Scene not found, id: "+r+"\nNarraLeaf cannot find the element with the id from the saved game");var a={scene:i,layers:n.constructLayerMap(o.layers,e),menus:[],texts:[]};n.state.elements.push(a),n.registerSrcManager(i.srcManager),n.getExposedStateAsync(i,(function(t){bc.initBackgroundMusic(i,t)}))})),this.audioManager.fromData(o,e),this.state.videos=i.map((function(t){var n=pm(t,2),r=n[0],o=n[1],i=e.get(r);if(!i)throw new Yc("Video not found, id: "+r+"\nNarraLeaf cannot find the element with the id from the saved game");return i.fromData(o),i}))}},{key:"getLastSceneIfNot",value:function(t){var e=t||this.getLastScene();if(!e||!this.sceneExists(e))throw new Yc('Scene not found, please call "scene.activate()" first.');return e}},{key:"createElementSnapshot",value:function(t){return{scene:t.scene,layers:new Map(Array.from(t.layers.entries()).map((function(t){var e=pm(t,2);return[e[0],e[1].map((function(t){return[t,t.toData()]}))]})))}}},{key:"fromElementSnapshot",value:function(t){return{scene:t.scene,layers:new Map(Array.from(t.layers.entries()).map((function(t){var e=pm(t,2);return[e[0],e[1].map((function(t){var e=pm(t,2),n=e[0],r=e[1];return n.fromData(r),n}))]}))),texts:[],menus:[]}}},{key:"removeElements",value:function(t){var e=this.state.elements.findIndex((function(e){return e.scene===t}));return-1===e?(this.logger.weakWarn("Scene not found when removing elements",t.getId()),this):(this.resetLayers(this.state.elements[e].layers),this.state.elements.splice(e,1),this)}},{key:"resetLayers",value:function(t){t.forEach((function(t){t.forEach((function(t){t.reset()}))}))}},{key:"createWaitableAction",value:function(t,e){return{action:t,onClick:function(t){e&&e(t)}}}},{key:"sceneNotFound",value:function(){return new Yc("Scene not found, target scene may not be activated. This is an internal error, please report this to the developer.")}},{key:"layerNotFound",value:function(){return new Yc("Layer not found, target layer may not be activated. You may forget to add the layer to the scene config")}},{key:"constructLayerMap",value:function(t,e){return new Map(Object.entries(t).map((function(t){var n=pm(t,2),r=n[0],o=n[1],i=e.get(r);if(!i)throw new Yc("Layer not found, id: "+r+"\nNarraLeaf cannot find the element with the id from the saved game");return[i,o.map((function(t){if(!e.has(t))throw new Yc("Displayable not found, id: "+t+"\nNarraLeaf cannot find the element with the id from the saved game\nThis may be caused by the damage of the saved game file or the change of the story file");return e.get(t)}))]})))}}],r&&vm(n.prototype,r),o&&vm(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}();function wm(t){return wm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wm(t)}function Sm(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return km(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?km(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function km(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function xm(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,_m(r.key),r)}}function _m(t){var e=function(t,e){if("object"!=wm(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=wm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wm(e)?e:e+""}bm.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 Am=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gameLock=new H,this.events=new F,this.story=null,this.currentSavedGame=null,this.lockedAwaiting=null,this.gameState=void 0,this._lockedCount=0,this.currentAction=null,this.game=e,this.storable=new Dh,this.initNamespaces()}return e=t,n=[{key:"initNamespaces",value:function(){return this.storable.clear().addNamespace(new Rh(t.GameSpacesKey.game,t.DefaultNamespaces.game)),this.story&&this.story.initPersistent(this.storable),this}},{key:"getStorable",value:function(){return this.storable}},{key:"loadStory",value:function(t){return this.story=t.constructStory(),this}},{key:"serialize",value:function(){var t;this.assertGameState();var e=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");var r=this.storable.toData(),o=e.toData(),i=(null===(t=this.getCurrentAction())||void 0===t?void 0:t.getId())||null,a=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:o,currentAction:i,elementStates:a,services:n.serializeServices()}}}},{key:"deserialize",value:function(t){var e;this.assertGameState();var n=this.gameState,r=this.story;if(!r)throw new Error("No story loaded");this.reset({gameState:n}),n.stage.forceRemount();var o=new Map,i=new Map,a=t.game,s=a.store,u=a.stage,c=a.elementStates,l=a.currentAction,f=a.services;if(r.forEachChild(r,(null===(e=r.entryScene)||void 0===e?void 0:e.getSceneRoot())||[],(function(t){o.set(t.getId(),t),i.set(t.callee.getId(),t.callee)}),{allowFutureScene:!0}),this.storable.clear().load(s),c.forEach((function(t){var e=t.id,r=t.data;n.logger.debug("restore element",e);var o=i.get(e);if(!o)throw new Error("Element not found, id: "+e+"\nNarraLeaf cannot find the element with the id from the saved game");o.reset(),o.fromData(r)})),this.currentSavedGame=t,n.loadData(u,i),l){var h=o.get(l);if(!h)throw new Error("Action not found, id: "+l+"\nNarraLeaf cannot find the action with the id from the saved game");this.currentAction=h}r.deserializeServices(f),n.stage.forceUpdate(),n.events.once(bm.EventTypes["event:state.onRender"],(function(){n.schedule((function(){n.stage.next()}),0)}))}},{key:"getHistory",value:function(){return this.assertGameState(),this.gameState.gameHistory.getHistory()}},{key:"undo",value:function(t){var e=this;this.assertGameState(),this.lockedAwaiting&&(this.lockedAwaiting.abort(),this.lockedAwaiting=null);var n=this.currentAction;(n=t?this.gameState.actionHistory.undoUntil(t):this.gameState.actionHistory.undo())?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((function(){e.gameState&&e.gameState.forceAnimation()}),0)}},{key:"dispose",value:function(){var t;this.events.clear(),null===(t=this.gameState)||void 0===t||t.dispose()}},{key:"notify",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;this.assertGameState();var n=this.gameState.idManager.generateId();this.gameState.notificationMgr.consume({id:n,message:t,duration:e})}},{key:"assertScreenshot",value:function(){this.assertGameState(),this.assertPlayerElement()}},{key:"capturePng",value:function(){return this.assertScreenshot(),this.gameState.htmlToImage.toPng(this.gameState.mainContentNode)}},{key:"captureJpeg",value:function(){return this.assertScreenshot(),this.gameState.htmlToImage.toJpeg(this.gameState.mainContentNode)}},{key:"captureSvg",value:function(){return this.assertScreenshot(),this.gameState.htmlToImage.toSvg(this.gameState.mainContentNode)}},{key:"capturePngBlob",value:function(){return this.assertScreenshot(),this.assertGameState(),this.assertPlayerElement(),this.gameState.htmlToImage.toBlob(this.gameState.mainContentNode)}},{key:"onCharacterPrompt",value:function(e){return this.events.on(t.EventTypes["event:character.prompt"],e)}},{key:"onMenuChoose",value:function(e){return this.events.on(t.EventTypes["event:menu.choose"],e)}},{key:"newGame",value:function(){var t,e,n,r,o;this.assertGameState();var i=this.gameState,a=i.logger.group("LiveGame (newGame)",!0);this.reset({gameState:i}),this.initNamespaces();var s=this.getNewSavedGame();s.name="NewGame-"+Date.now(),this.currentSavedGame=s,this.currentAction=(null===(e=null===(t=this.story)||void 0===t?void 0:t.entryScene)||void 0===e?void 0:e.getSceneRoot())||null;var u=null===(n=this.story)||void 0===n?void 0:n.getAllElementMap(this.story,(null===(o=null===(r=this.story)||void 0===r?void 0:r.entryScene)||void 0===o?void 0:o.getSceneRoot())||[]);return u?u.forEach((function(t){i.logger.debug("reset element",t),t.reset()})):i.logger.warn("No elements found"),i.stage.forceUpdate(),i.stage.next(),a.end(),this}},{key:"requestFullScreen",value:function(t){this.assertGameState();var e="LiveGame.requestFullScreen";try{var n=this.gameState.playerCurrent;if(!n)return void this.gameState.logger.warn(e,"No player element found");if(n.requestFullscreen)return n.requestFullscreen(t);this.gameState.logger.warn(e,"Fullscreen is not supported")}catch(t){this.gameState.logger.error(e,t)}}},{key:"exitFullScreen",value:function(){this.assertGameState();var t="LiveGame.exitFullScreen";try{if(document.exitFullscreen)return document.exitFullscreen();this.gameState.logger.warn(t,"Fullscreen is not supported")}catch(e){this.gameState.logger.error(t,e)}}},{key:"onPlayerEvent",value:function(t,e,n){this.assertPlayerElement();var r=this.gameState.playerCurrent;return r?(r.addEventListener(t,e,n),{cancel:function(){return r.removeEventListener(t,e,n)}}):(this.gameState.logger.warn("LiveGame.onEvent","No player element found"),{cancel:function(){}})}},{key:"reset",value:function(t){var e=t.gameState;this.lockedAwaiting&&this.lockedAwaiting.abort(),this.currentAction=null,this.lockedAwaiting=null,this.currentSavedGame=null,e.forceReset()}},{key:"getCurrentAction",value:function(){return this.currentAction}},{key:"setCurrentAction",value:function(t){return this.currentAction=t,this}},{key:"next",value:function(t){var e,n;if(this.gameLock.isLocked())return this.gameLock;if(!this.story)throw new Error("No story loaded");if(this.lockedAwaiting){if(!this.lockedAwaiting.solved){if(this._lockedCount++,this._lockedCount>1e3)throw new Error("LiveGame locked: dead cycle detected\nPlease refresh the page");return this.lockedAwaiting}var r=this.lockedAwaiting.result;return this.currentAction=(null===(e=null==r?void 0:r.node)||void 0===e?void 0:e.action)||null,this.lockedAwaiting=null,this.currentAction||t.events.emit(bm.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;var o=this.currentAction.executeAction(t);return L.isAwaitable(o)?(this.lockedAwaiting=o,o):(t.logger.debug("next action",o),this._lockedCount=0,this.currentAction=(null===(n=o.node)||void 0===n?void 0:n.action)||null,o)}},{key:"isPlaying",value:function(){return!!this.currentAction}},{key:"abortAwaiting",value:function(){var t;if(this.lockedAwaiting){var e=this.lockedAwaiting.abort();this.currentAction=(null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.action)||null,this.lockedAwaiting=null}}},{key:"executeAction",value:function(t,e){var n,r=e.executeAction(t);return L.isAwaitable(r)?r:(null===(n=null==r?void 0:r.node)||void 0===n?void 0:n.action)||null}},{key:"executeActionRaw",value:function(t,e){return e.executeAction(t)}},{key:"setGameState",value:function(t){return this.gameState=t,this}},{key:"getGameState",value:function(){return this.gameState}},{key:"getAllPredictableActions",value:function(t,e,n){for(var o,i,a,s=(null==e?void 0:e.contentNode)||null,c=[],l=[],f=new Set;(s||l.length)&&!(n&&c.length>=n);)if(s||(s=l.pop().contentNode),[Rl].some((function(t){return(null==s?void 0:s.action)&&s.action instanceof t})))s=null;else if(s.action&&s.action.is(bc,r.jumpTo)){var h=Sm(s.action.contentNode.getContent(),1)[0],p=t.getScene(h);if(!p)throw s.action._sceneNotFoundError(s.action.getSceneName(h));if(f.has(p)){s=null;continue}f.add(p),s=(null===(o=p.getSceneRoot())||void 0===o?void 0:o.contentNode)||null}else{if(s.action&&s.action.is(fs,u.do)){var d=Sm(s.action.contentNode.getContent(),1)[0];(null===(i=s.getChild())||void 0===i?void 0:i.action)&&l.push(s.getChild().action),s=(null===(a=d[0])||void 0===a?void 0:a.contentNode)||null}s.action&&c.push(s.action),s=s.getChild()}return c}},{key:"getNewSavedGame",value:function(){var t,e;return{name:"",meta:{created:Date.now(),updated:Date.now(),id:tt()},game:{store:{},stage:{scenes:[],audio:{sounds:[]},videos:[]},elementStates:[],currentAction:(null===(e=null===(t=this.story)||void 0===t?void 0:t.entryScene)||void 0===e?void 0:e.getSceneRoot().getId())||null,services:{}}}}},{key:"assertGameState",value:function(){if(!this.gameState)throw new Yc("No game state found, make sure you call this method in effect hooks or event handlers")}},{key:"assertPlayerElement",value:function(){if(this.assertGameState(),!this.gameState.playerCurrent)throw new Yc("Player Element Not Mounted")}}],n&&xm(e.prototype,n),o&&xm(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}();function Tm(t){return Tm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tm(t)}function Om(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Em(r.key),r)}}function Em(t){var e=function(t,e){if("object"!=Tm(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Tm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Tm(e)?e:e+""}Am.DefaultNamespaces={game:{}},Am.GameSpacesKey={game:"game"},Am.EventTypes={"event:character.prompt":"event:character.prompt","event:menu.choose":"event:menu.choose"};var jm=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=e,this.events=new F}return e=t,(n=[{key:"setPreference",value:function(e,n){this.settings[e]=n,this.events.emit(t.EventTypes["event:game.preference.change"],e,n)}},{key:"getPreference",value:function(t){return this.settings[t]}},{key:"getPreferences",value:function(){return this.settings}},{key:"onPreferenceChange",value:function(e,n){return this.events.on(t.EventTypes["event:game.preference.change"],(function(t,r){"string"==typeof e?e===t&&n&&n(r):e(t,r)}))}},{key:"importPreferences",value:function(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.setPreference(e,t[e])}},{key:"exportPreferences",value:function(){var t={};for(var e in this.settings)Object.prototype.hasOwnProperty.call(this.settings,e)&&(t[e]=this.settings[e]);return t}},{key:"togglePreference",value:function(t){this.setPreference(t,!this.getPreference(t))}}])&&Om(e.prototype,n),r&&Om(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Pm(t){var e,n,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=Pm(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}jm.EventTypes={"event:game.preference.change":"event:game.preference.change"};const Cm=function(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=Pm(t))&&(r&&(r+=" "),r+=e);return r};var Im=o(12),Rm=o.n(Im);function Dm(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Lm(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Lm(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lm(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Mm(t){return Mm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mm(t)}function Nm(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Fm(r.key),r)}}function Fm(t){var e=function(t,e){if("object"!=Mm(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Mm(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Mm(e)?e:e+""}var Bm=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.state={width:0,height:0,minWidth:800,minHeight:450,paused:!1,scale:0},this.events=(new F).setMaxListeners(1/0),this.lockers=[],this.updater=null}return e=t,(n=[{key:"update",value:function(e,n,r){this.state.width=e,this.state.height=n,this.state.scale=r,this.events.emit(t.EventTypes["event:aspectRatio.update"],e,n)}},{key:"updateMin",value:function(t,e){this.state.minWidth=t,this.state.minHeight=e}},{key:"lock",value:function(){var t=Symbol();return this.lockers.push(t),t}},{key:"unlock",value:function(t){if(t&&!this.lockers.includes(t))throw new Error("Locker not found");return this.lockers=this.lockers.filter((function(e){return e!==t})),this.triggerUpdate(),null}},{key:"isLocked",value:function(){return!!this.lockers.length}},{key:"getStyle",value:function(){return{width:"".concat(this.state.width,"px"),height:"".concat(this.state.height,"px")}}},{key:"setUpdate",value:function(t){this.updater=t}},{key:"pause",value:function(){this.state.paused=!0,this.events.emit(t.EventTypes["event:aspectRatio.pause"])}},{key:"resume",value:function(){this.state.paused=!1,this.events.emit(t.EventTypes["event:aspectRatio.resume"])}},{key:"onUpdate",value:function(e){return this.events.on(t.EventTypes["event:aspectRatio.update"],e).cancel}},{key:"requestUpdate",value:function(){this.events.emit(t.EventTypes["event:aspectRatio.requestUpdate"])}},{key:"onRequestedUpdate",value:function(e){return this.events.on(t.EventTypes["event:aspectRatio.requestUpdate"],e).cancel}},{key:"triggerUpdate",value:function(){this.updater&&this.updater()}}])&&Nm(e.prototype,n),r&&Nm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();Bm.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 Um=(0,Im.createContext)(null);function Vm(t){var e=t.children,n=Dm((0,Im.useState)((function(){return new Bm})),1)[0];return Rm().createElement(Um,{value:{ratio:n}},e)}function zm(){var t=(0,Im.useContext)(Um),e=Dm((0,Im.useReducer)((function(t){return t+1}),0),2)[1];if(!Um||!t)throw new Error("useRatio must be used within a RatioProvider");var n=t.ratio;return(0,Im.useEffect)((function(){return n.onUpdate((function(){e()}))}),[]),t}function Gm(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Hm(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hm(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hm(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var $m=Rm().createContext(null);function Wm(t){var e=t.children,n=t.game,r=new IS({}),o=Gm((0,Im.useState)(n||r),1)[0];return Rm().createElement($m,{value:o},e)}function qm(){var t=(0,Im.useContext)($m);if(!t)throw new Error("useGame must be used within a GameProvider");return t}function Ym(t){if("undefined"==typeof Proxy)return t;const e=new Map;return new Proxy(((...e)=>t(...e)),{get:(n,r)=>"create"===r?t:(e.has(r)||e.set(r,t(r)),e.get(r))})}function Xm(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}function Km(t,e,n={}){var r;const o=ln(t,e,"exit"===n.type?null===(r=t.presenceContext)||void 0===r?void 0:r.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=o||{};n.transitionOverride&&(i=n.transitionOverride);const a=o?()=>Promise.all(Fo(t,o,n)):()=>Promise.resolve(),s=t.variantChildren&&t.variantChildren.size?(r=0)=>{const{delayChildren:o=0,staggerChildren:a,staggerDirection:s}=i;return function(t,e,n=0,r=0,o=1,i){const a=[],s=(t.variantChildren.size-1)*r,u=1===o?(t=0)=>t*r:(t=0)=>s-t*r;return Array.from(t.variantChildren).sort(Zm).forEach(((t,r)=>{t.notify("AnimationStart",e),a.push(Km(t,e,{...i,delay:n+u(r)}).then((()=>t.notify("AnimationComplete",e))))})),Promise.all(a)}(t,e,o+r,a,s,n)}:()=>Promise.resolve(),{when:u}=i;if(u){const[t,e]="beforeChildren"===u?[a,s]:[s,a];return t().then((()=>e()))}return Promise.all([a(),s(n.delay)])}function Zm(t,e){return t.sortNodePosition(e)}const Qm=Ko.length;function Jm(t){if(!t)return;if(!t.isControllingVariants){const e=t.parent&&Jm(t.parent)||{};return void 0!==t.props.initial&&(e.initial=t.props.initial),e}const e={};for(let n=0;n<Qm;n++){const r=Ko[n],o=t.props[r];(Yo(o)||!1===o)&&(e[r]=o)}return e}const tv=[...Xo].reverse(),ev=Xo.length;function nv(t){return e=>Promise.all(e.map((({animation:e,options:n})=>function(t,e,n={}){let r;if(t.notify("AnimationStart",e),Array.isArray(e)){const o=e.map((e=>Km(t,e,n)));r=Promise.all(o)}else if("string"==typeof e)r=Km(t,e,n);else{const o="function"==typeof e?ln(t,e,n.custom):e;r=Promise.all(Fo(t,o,n))}return r.then((()=>{t.notify("AnimationComplete",e)}))}(t,e,n))))}function rv(t){let e=nv(t),n=av(),r=!0;const o=e=>(n,r)=>{var o;const i=ln(t,r,"exit"===e?null===(o=t.presenceContext)||void 0===o?void 0:o.custom:void 0);if(i){const{transition:t,transitionEnd:e,...r}=i;n={...n,...r,...e}}return n};function i(i){const{props:a}=t,s=Jm(t.parent)||{},u=[],c=new Set;let l={},f=1/0;for(let e=0;e<ev;e++){const h=tv[e],p=n[h],d=void 0!==a[h]?a[h]:s[h],y=Yo(d),m=h===i?p.isActive:null;!1===m&&(f=e);let v=d===s[h]&&d!==a[h]&&y;if(v&&r&&t.manuallyAnimateOnMount&&(v=!1),p.protectedKeys={...l},!p.isActive&&null===m||!d&&!p.prevProp||qo(d)||"boolean"==typeof d)continue;const g=ov(p.prevProp,d);let b=g||h===i&&p.isActive&&!v&&y||e>f&&y,w=!1;const S=Array.isArray(d)?d:[d];let k=S.reduce(o(h),{});!1===m&&(k={});const{prevResolvedValues:x={}}=p,_={...x,...k},A=e=>{b=!0,c.has(e)&&(w=!0,c.delete(e)),p.needsAnimating[e]=!0;const n=t.getValue(e);n&&(n.liveStyle=!1)};for(const t in _){const e=k[t],n=x[t];if(l.hasOwnProperty(t))continue;let r=!1;r=$e(e)&&$e(n)?!Xm(e,n):e!==n,r?null!=e?A(t):c.add(t):void 0!==e&&c.has(t)?A(t):p.protectedKeys[t]=!0}p.prevProp=d,p.prevResolvedValues=k,p.isActive&&(l={...l,...k}),r&&t.blockInitialAnimation&&(b=!1);b&&(!(v&&g)||w)&&u.push(...S.map((t=>({animation:t,options:{type:h}}))))}if(c.size){const e={};c.forEach((n=>{const r=t.getBaseTarget(n),o=t.getValue(n);o&&(o.liveStyle=!0),e[n]=null!=r?r:null})),u.push({animation:e})}let h=Boolean(u.length);return!r||!1!==a.initial&&a.initial!==a.animate||t.manuallyAnimateOnMount||(h=!1),r=!1,h?e(u):Promise.resolve()}return{animateChanges:i,setActive:function(e,r){var o;if(n[e].isActive===r)return Promise.resolve();null===(o=t.variantChildren)||void 0===o||o.forEach((t=>{var n;return null===(n=t.animationState)||void 0===n?void 0:n.setActive(e,r)})),n[e].isActive=r;const a=i(e);for(const t in n)n[t].protectedKeys={};return a},setAnimateFunction:function(n){e=n(t)},getState:()=>n,reset:()=>{n=av(),r=!0}}}function ov(t,e){return"string"==typeof e?e!==t:!!Array.isArray(e)&&!Xm(e,t)}function iv(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function av(){return{animate:iv(!0),whileInView:iv(),whileHover:iv(),whileTap:iv(),whileDrag:iv(),whileFocus:iv(),exit:iv()}}class sv{constructor(t){this.isMounted=!1,this.node=t}update(){}}let uv=0;const cv={animation:{Feature:class extends sv{constructor(t){super(t),t.animationState||(t.animationState=rv(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();qo(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:e}=this.node.prevProps||{};t!==e&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),null===(t=this.unmountControls)||void 0===t||t.call(this)}}},exit:{Feature:class extends sv{constructor(){super(...arguments),this.id=uv++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:e}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;const r=this.node.animationState.setActive("exit",!t);e&&!t&&r.then((()=>e(this.id)))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}}},lv={x:!1,y:!1};function fv(){return lv.x||lv.y}const hv=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary;function pv(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function dv(t){return{point:{x:t.pageX,y:t.pageY}}}function yv(t,e,n,r){return pv(t,e,(t=>e=>hv(e)&&t(e,dv(e)))(n),r)}const mv=(t,e)=>Math.abs(t-e);class vv{constructor(t,e,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:o=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const t=wv(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,n=function(t,e){const n=mv(t.x,e.x),r=mv(t.y,e.y);return Math.sqrt(n**2+r**2)}(t.offset,{x:0,y:0})>=3;if(!e&&!n)return;const{point:r}=t,{timestamp:o}=Qe;this.history.push({...r,timestamp:o});const{onStart:i,onMove:a}=this.handlers;e||(i&&i(this.lastMoveEvent,t),this.startEvent=this.lastMoveEvent),a&&a(this.lastMoveEvent,t)},this.handlePointerMove=(t,e)=>{this.lastMoveEvent=t,this.lastMoveEventInfo=gv(e,this.transformPagePoint),Ke.update(this.updatePoint,!0)},this.handlePointerUp=(t,e)=>{this.end();const{onEnd:n,onSessionEnd:r,resumeAnimation:o}=this.handlers;if(this.dragSnapToOrigin&&o&&o(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const i=wv("pointercancel"===t.type?this.lastMoveEventInfo:gv(e,this.transformPagePoint),this.history);this.startEvent&&n&&n(t,i),r&&r(t,i)},!hv(t))return;this.dragSnapToOrigin=o,this.handlers=e,this.transformPagePoint=n,this.contextWindow=r||window;const i=gv(dv(t),this.transformPagePoint),{point:a}=i,{timestamp:s}=Qe;this.history=[{...a,timestamp:s}];const{onSessionStart:u}=e;u&&u(t,wv(i,this.history)),this.removeListeners=ao(yv(this.contextWindow,"pointermove",this.handlePointerMove),yv(this.contextWindow,"pointerup",this.handlePointerUp),yv(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Ze(this.updatePoint)}}function gv(t,e){return e?{point:e(t.point)}:t}function bv(t,e){return{x:t.x-e.x,y:t.y-e.y}}function wv({point:t},e){return{point:t,delta:bv(t,kv(e)),offset:bv(t,Sv(e)),velocity:xv(e,.1)}}function Sv(t){return t[0]}function kv(t){return t[t.length-1]}function xv(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const o=kv(t);for(;n>=0&&(r=t[n],!(o.timestamp-r.timestamp>Nt(e)));)n--;if(!r)return{x:0,y:0};const i=Ft(o.timestamp-r.timestamp);if(0===i)return{x:0,y:0};const a={x:(o.x-r.x)/i,y:(o.y-r.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function _v(t){return t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"current")}function Av(t){return t.max-t.min}function Tv(t,e,n,r=.5){t.origin=r,t.originPoint=we(e.min,e.max,t.origin),t.scale=Av(n)/Av(e),t.translate=we(n.min,n.max,t.origin)-t.originPoint,(t.scale>=.9999&&t.scale<=1.0001||isNaN(t.scale))&&(t.scale=1),(t.translate>=-.01&&t.translate<=.01||isNaN(t.translate))&&(t.translate=0)}function Ov(t,e,n,r){Tv(t.x,e.x,n.x,r?r.originX:void 0),Tv(t.y,e.y,n.y,r?r.originY:void 0)}function Ev(t,e,n){t.min=n.min+e.min,t.max=t.min+Av(e)}function jv(t,e,n){t.min=e.min-n.min,t.max=t.min+Av(e)}function Pv(t,e,n){jv(t.x,e.x,n.x),jv(t.y,e.y,n.y)}function Cv(t,e,n){return{min:void 0!==e?t.min+e:void 0,max:void 0!==n?t.max+n-(t.max-t.min):void 0}}function Iv(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}const Rv=.35;function Dv(t,e,n){return{min:Lv(t,e),max:Lv(t,n)}}function Lv(t,e){return"number"==typeof t?t:t[e]||0}function Mv(t){return[t("x"),t("y")]}const Nv=({current:t})=>t?t.ownerDocument.defaultView:null,Fv=new WeakMap;class Bv{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={x:{min:0,max:0},y:{min:0,max:0}},this.visualElement=t}start(t,{snapToCursor:e=!1}={}){const{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;const{dragSnapToOrigin:r}=this.getProps();this.panSession=new vv(t,{onSessionStart:t=>{const{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),e&&this.snapToCursor(dv(t).point)},onStart:(t,e)=>{const{drag:n,dragPropagation:r,onDragStart:o}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(i=n)||"y"===i?lv[i]?null:(lv[i]=!0,()=>{lv[i]=!1}):lv.x||lv.y?null:(lv.x=lv.y=!0,()=>{lv.x=lv.y=!1}),!this.openDragLock))return;var i;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Mv((t=>{let e=this.getAxisMotionValue(t).get()||0;if(Zn.test(e)){const{projection:n}=this.visualElement;if(n&&n.layout){const r=n.layout.layoutBox[t];if(r){e=Av(r)*(parseFloat(e)/100)}}}this.originPoint[t]=e})),o&&Ke.postRender((()=>o(t,e))),hn(this.visualElement,"transform");const{animationState:a}=this.visualElement;a&&a.setActive("whileDrag",!0)},onMove:(t,e)=>{const{dragPropagation:n,dragDirectionLock:r,onDirectionLock:o,onDrag:i}=this.getProps();if(!n&&!this.openDragLock)return;const{offset:a}=e;if(r&&null===this.currentDirection)return this.currentDirection=function(t,e=10){let n=null;Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x");return n}(a),void(null!==this.currentDirection&&o&&o(this.currentDirection));this.updateAxis("x",e.point,a),this.updateAxis("y",e.point,a),this.visualElement.render(),i&&i(t,e)},onSessionEnd:(t,e)=>this.stop(t,e),resumeAnimation:()=>Mv((t=>{var e;return"paused"===this.getAnimationState(t)&&(null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.play())}))},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:r,contextWindow:Nv(this.visualElement)})}stop(t,e){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:r}=e;this.startAnimation(r);const{onDragEnd:o}=this.getProps();o&&Ke.postRender((()=>o(t,e)))}cancel(){this.isDragging=!1;const{projection:t,animationState:e}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),e&&e.setActive("whileDrag",!1)}updateAxis(t,e,n){const{drag:r}=this.getProps();if(!n||!Uv(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(i=function(t,{min:e,max:n},r){return void 0!==e&&t<e?t=r?we(e,t,r.min):Math.max(t,e):void 0!==n&&t>n&&(t=r?we(n,t,r.max):Math.min(t,n)),t}(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){var t;const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null===(t=this.visualElement.projection)||void 0===t?void 0:t.layout,o=this.constraints;e&&_v(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!e||!r)&&function(t,{top:e,left:n,bottom:r,right:o}){return{x:Cv(t.x,n,o),y:Cv(t.y,e,r)}}(r.layoutBox,e),this.elastic=function(t=Rv){return!1===t?t=0:!0===t&&(t=Rv),{x:Dv(t,"left","right"),y:Dv(t,"top","bottom")}}(n),o!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Mv((t=>{!1!==this.constraints&&this.getAxisMotionValue(t)&&(this.constraints[t]=function(t,e){const n={};return void 0!==e.min&&(n.min=e.min-t.min),void 0!==e.max&&(n.max=e.max-t.min),n}(r.layoutBox[t],this.constraints[t]))}))}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:e}=this.getProps();if(!t||!_v(t))return!1;const n=t.current;se(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=function(t,e,n){const r=Di(t,n),{scroll:o}=e;return o&&(Ci(r.x,o.offset.x),Ci(r.y,o.offset.y)),r}(n,r.root,this.visualElement.getTransformPagePoint());let i=function(t,e){return{x:Iv(t.x,e.x),y:Iv(t.y,e.y)}}(r.layout.layoutBox,o);if(e){const t=e(function({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}(i));this.hasMutatedConstraints=!!t,t&&(i=bi(t))}return i}startAnimation(t){const{drag:e,dragMomentum:n,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),s=this.constraints||{},u=Mv((a=>{if(!Uv(a,e,this.currentDirection))return;let u=s&&s[a]||{};i&&(u={min:0,max:0});const c=r?200:1e6,l=r?40:1e7,f={type:"inertia",velocity:n?t[a]:0,bounceStiffness:c,bounceDamping:l,timeConstant:750,restDelta:1,restSpeed:10,...o,...u};return this.startAxisValueAnimation(a,f)}));return Promise.all(u).then(a)}startAxisValueAnimation(t,e){const n=this.getAxisMotionValue(t);return hn(this.visualElement,t),n.start(Mo(t,n,0,e,this.visualElement,!1))}stopAnimation(){Mv((t=>this.getAxisMotionValue(t).stop()))}pauseAnimation(){Mv((t=>{var e;return null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.pause()}))}getAnimationState(t){var e;return null===(e=this.getAxisMotionValue(t).animation)||void 0===e?void 0:e.state}getAxisMotionValue(t){const e=`_drag${t.toUpperCase()}`,n=this.visualElement.getProps(),r=n[e];return r||this.visualElement.getValue(t,(n.initial?n.initial[t]:void 0)||0)}snapToCursor(t){Mv((e=>{const{drag:n}=this.getProps();if(!Uv(e,n,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(e);if(r&&r.layout){const{min:n,max:i}=r.layout.layoutBox[e];o.set(t[e]-we(n,i,.5))}}))}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:e}=this.getProps(),{projection:n}=this.visualElement;if(!_v(e)||!n||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Mv((t=>{const e=this.getAxisMotionValue(t);if(e&&!1!==this.constraints){const n=e.get();r[t]=function(t,e){let n=.5;const r=Av(t),o=Av(e);return o>r?n=Vt(e.min,e.max-r,t.min):r>o&&(n=Vt(t.min,t.max-o,e.min)),Gt(0,1,n)}({min:n,max:n},this.constraints[t])}}));const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),Mv((e=>{if(!Uv(e,t,null))return;const n=this.getAxisMotionValue(e),{min:o,max:i}=this.constraints[e];n.set(we(o,i,r[e]))}))}addListeners(){if(!this.visualElement.current)return;Fv.set(this.visualElement,this);const t=yv(this.visualElement.current,"pointerdown",(t=>{const{drag:e,dragListener:n=!0}=this.getProps();e&&n&&this.start(t)})),e=()=>{const{dragConstraints:t}=this.getProps();_v(t)&&t.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,r=n.addEventListener("measure",e);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Ke.read(e);const o=pv(window,"resize",(()=>this.scalePositionWithinConstraints())),i=n.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(Mv((e=>{const n=this.getAxisMotionValue(e);n&&(this.originPoint[e]+=t[e].translate,n.set(n.get()+t[e].translate))})),this.visualElement.render())}));return()=>{o(),t(),r(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:e=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=Rv,dragMomentum:a=!0}=t;return{...t,drag:e,dragDirectionLock:n,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function Uv(t,e,n){return!(!0!==e&&e!==t||null!==n&&n!==t)}const Vv=t=>(e,n)=>{t&&Ke.postRender((()=>t(e,n)))};var zv=o(848);const Gv=(0,Im.createContext)(null);function Hv(t=!0){const e=(0,Im.useContext)(Gv);if(null===e)return[!0,null];const{isPresent:n,onExitComplete:r,register:o}=e,i=(0,Im.useId)();(0,Im.useEffect)((()=>{t&&o(i)}),[t]);const a=(0,Im.useCallback)((()=>t&&r&&r(i)),[i,r,t]);return!n&&r?[!1,a]:[!0]}const $v=(0,Im.createContext)({}),Wv=(0,Im.createContext)({}),qv={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Yv(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Xv={correct:(t,e)=>{if(!e.target)return t;if("string"==typeof t){if(!Qn.test(t))return t;t=parseFloat(t)}return`${Yv(t,e.target.x)}% ${Yv(t,e.target.y)}%`}},Kv={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,o=hr.parse(t);if(o.length>5)return r;const i=hr.createTransformer(t),a="number"!=typeof o[0]?1:0,s=n.x.scale*e.x,u=n.y.scale*e.y;o[0+a]/=s,o[1+a]/=u;const c=we(s,u,.5);return"number"==typeof o[2+a]&&(o[2+a]/=c),"number"==typeof o[3+a]&&(o[3+a]/=c),i(o)}},{schedule:Zv,cancel:Qv}=Xe(queueMicrotask,!1);class Jv extends Im.Component{componentDidMount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:n,layoutId:r}=this.props,{projection:o}=t;var i;i=eg,Object.assign(di,i),o&&(e.group&&e.group.add(o),n&&n.register&&r&&n.register(o),o.root.didUpdate(),o.addEventListener("animationComplete",(()=>{this.safeToRemove()})),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),qv.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:e,visualElement:n,drag:r,isPresent:o}=this.props,i=n.projection;return i?(i.isPresent=o,r||t.layoutDependency!==e||void 0===e?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||Ke.postRender((()=>{const t=i.getStack();t&&t.members.length||this.safeToRemove()}))),null):null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Zv.postRender((()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()})))}componentWillUnmount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:n}=this.props,{projection:r}=t;r&&(r.scheduleCheckAfterUnmount(),e&&e.group&&e.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function tg(t){const[e,n]=Hv(),r=(0,Im.useContext)($v);return(0,zv.jsx)(Jv,{...t,layoutGroup:r,switchLayoutGroup:(0,Im.useContext)(Wv),isPresent:e,safeToRemove:n})}const eg={borderRadius:{...Xv,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Xv,borderTopRightRadius:Xv,borderBottomLeftRadius:Xv,borderBottomRightRadius:Xv,boxShadow:Kv},ng=(t,e)=>t.depth-e.depth;class rg{constructor(){this.children=[],this.isDirty=!1}add(t){je(this.children,t),this.isDirty=!0}remove(t){Pe(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(ng),this.isDirty=!1,this.children.forEach(t)}}function og(t,e){const n=nn.now(),r=({timestamp:o})=>{const i=o-n;i>=e&&(Ze(r),t(i-e))};return Ke.read(r,!0),()=>Ze(r)}function ig(t){const e=xe(t)?t.get():t;return n=e,Boolean(n&&"object"==typeof n&&n.mix&&n.toValue)?e.toValue():e;var n}const ag=["TopLeft","TopRight","BottomLeft","BottomRight"],sg=ag.length,ug=t=>"string"==typeof t?parseFloat(t):t,cg=t=>"number"==typeof t||Qn.test(t);function lg(t,e){return void 0!==t[e]?t[e]:t.borderRadius}const fg=pg(0,.5,Ln),hg=pg(.5,.95,ie);function pg(t,e,n){return r=>r<t?0:r>e?1:n(Vt(t,e,r))}function dg(t,e){t.min=e.min,t.max=e.max}function yg(t,e){dg(t.x,e.x),dg(t.y,e.y)}function mg(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function vg(t,e,n,r,o){return t=Ai(t-=e,1/n,r),void 0!==o&&(t=Ai(t,1/o,r)),t}function gg(t,e,[n,r,o],i,a){!function(t,e=0,n=1,r=.5,o,i=t,a=t){Zn.test(e)&&(e=parseFloat(e),e=we(a.min,a.max,e/100)-a.min);if("number"!=typeof e)return;let s=we(i.min,i.max,r);t===i&&(s-=e),t.min=vg(t.min,e,n,s,o),t.max=vg(t.max,e,n,s,o)}(t,e[n],e[r],e[o],e.scale,i,a)}const bg=["x","scaleX","originX"],wg=["y","scaleY","originY"];function Sg(t,e,n,r){gg(t.x,e,bg,n?n.x:void 0,r?r.x:void 0),gg(t.y,e,wg,n?n.y:void 0,r?r.y:void 0)}function kg(t){return 0===t.translate&&1===t.scale}function xg(t){return kg(t.x)&&kg(t.y)}function _g(t,e){return t.min===e.min&&t.max===e.max}function Ag(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Tg(t,e){return Ag(t.x,e.x)&&Ag(t.y,e.y)}function Og(t){return Av(t.x)/Av(t.y)}function Eg(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class jg{constructor(){this.members=[]}add(t){je(this.members,t),t.scheduleRender()}remove(t){if(Pe(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(t){const e=this.members.findIndex((e=>t===e));if(0===e)return!1;let n;for(let t=e;t>=0;t--){const e=this.members[t];if(!1!==e.isPresent){n=e;break}}return!!n&&(this.promote(n),!0)}promote(t,e){const n=this.lead;if(t!==n&&(this.prevLead=n,this.lead=t,t.show(),n)){n.instance&&n.scheduleRender(),t.scheduleRender(),t.resumeFrom=n,e&&(t.resumeFrom.preserveOpacity=!0),n.snapshot&&(t.snapshot=n.snapshot,t.snapshot.latestValues=n.animationValues||n.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;!1===r&&n.hide()}}exitAnimationComplete(){this.members.forEach((t=>{const{options:e,resumingFrom:n}=t;e.onExitComplete&&e.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()}))}scheduleRender(){this.members.forEach((t=>{t.instance&&t.scheduleRender(!1)}))}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const Pg={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},Cg="undefined"!=typeof window&&void 0!==window.MotionDebug,Ig=["","X","Y","Z"],Rg={visibility:"hidden"};let Dg=0;function Lg(t,e,n,r){const{latestValues:o}=e;o[t]&&(n[t]=o[t],e.setStaticValue(t,0),r&&(r[t]=0))}function Mg(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=yn(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:e,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ke,!(e||r))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&Mg(r)}function Ng({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:o}){return class{constructor(t={},n=(null==e?void 0:e())){this.id=Dg++,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,Cg&&(Pg.totalNodes=Pg.resolvedTargetDeltas=Pg.recalculatedProjection=0),this.nodes.forEach(Ug),this.nodes.forEach(qg),this.nodes.forEach(Yg),this.nodes.forEach(Vg),Cg&&window.MotionDebug.record(Pg)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=t,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let t=0;t<this.path.length;t++)this.path[t].shouldResetTransform=!0;this.root===this&&(this.nodes=new rg)}addEventListener(t,e){return this.eventHandlers.has(t)||this.eventHandlers.set(t,new rn),this.eventHandlers.get(t).add(e)}notifyListeners(t,...e){const n=this.eventHandlers.get(t);n&&n.notify(...e)}hasListeners(t){return this.eventHandlers.has(t)}mount(e,n=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=Bo(e),this.instance=e;const{layoutId:r,layout:o,visualElement:i}=this.options;if(i&&!i.current&&i.mount(e),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),n&&(o||r)&&(this.isLayoutDirty=!0),t){let n;const r=()=>this.root.updateBlockedByResize=!1;t(e,(()=>{this.root.updateBlockedByResize=!0,n&&n(),n=og(r,250),qv.hasAnimatedSinceResize&&(qv.hasAnimatedSinceResize=!1,this.nodes.forEach(Wg))}))}r&&this.root.registerSharedNode(r,this),!1!==this.options.animate&&i&&(r||o)&&this.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e,hasRelativeTargetChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const o=this.options.transition||i.getDefaultTransition()||tb,{onLayoutAnimationStart:a,onLayoutAnimationComplete:s}=i.getProps(),u=!this.targetLayout||!Tg(this.targetLayout,r)||n,c=!e&&n;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||c||e&&(u||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(t,c);const e={...Ve(o,"layout"),onPlay:a,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(e.delay=0,e.type=!1),this.startAnimation(e)}else e||Wg(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r}))}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const t=this.getStack();t&&t.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(Xg),this.animationId++)}getTransformTemplate(){const{visualElement:t}=this.options;return t&&t.getProps().transformTemplate}willUpdate(t=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Mg(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let t=0;t<this.path.length;t++){const e=this.path[t];e.shouldResetTransform=!0,e.updateScroll("snapshot"),e.options.layoutRoot&&e.willUpdate(!1)}const{layoutId:e,layout:n}=this.options;if(void 0===e&&!n)return;const r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,""):void 0,this.updateSnapshot(),t&&this.notifyListeners("willUpdate")}update(){this.updateScheduled=!1;if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(Gg);this.isUpdating||this.nodes.forEach(Hg),this.isUpdating=!1,this.nodes.forEach($g),this.nodes.forEach(Fg),this.nodes.forEach(Bg),this.clearAllSnapshots();const t=nn.now();Qe.delta=Gt(0,1e3/60,t-Qe.timestamp),Qe.timestamp=t,Qe.isProcessing=!0,Je.update.process(Qe),Je.preRender.process(Qe),Je.render.process(Qe),Qe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Zv.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(zg),this.sharedNodes.forEach(Kg)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ke.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ke.postRender((()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()}))}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure())}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let t=0;t<this.path.length;t++){this.path[t].updateScroll()}const t=this.layout;this.layout=this.measure(!1),this.layoutCorrected={x:{min:0,max:0},y:{min:0,max:0}},this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:e}=this.options;e&&e.notify("LayoutMeasure",this.layout.layoutBox,t?t.layoutBox:void 0)}updateScroll(t="measure"){let e=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===t&&(e=!1),e){const e=r(this.instance);this.scroll={animationId:this.root.animationId,phase:t,isRoot:e,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:e}}}resetTransform(){if(!o)return;const t=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,e=this.projectionDelta&&!xg(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,""):void 0,i=r!==this.prevTransformTemplateValue;t&&(e||ki(this.latestValues)||i)&&(o(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(t=!0){const e=this.measurePageBox();let n=this.removeElementScroll(e);var r;return t&&(n=this.removeTransform(n)),rb((r=n).x),rb(r.y),{animationId:this.root.animationId,measuredBox:e,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){var t;const{visualElement:e}=this.options;if(!e)return{x:{min:0,max:0},y:{min:0,max:0}};const n=e.measureViewportBox();if(!((null===(t=this.scroll)||void 0===t?void 0:t.wasRoot)||this.path.some(ib))){const{scroll:t}=this.root;t&&(Ci(n.x,t.offset.x),Ci(n.y,t.offset.y))}return n}removeElementScroll(t){var e;const n={x:{min:0,max:0},y:{min:0,max:0}};if(yg(n,t),null===(e=this.scroll)||void 0===e?void 0:e.wasRoot)return n;for(let e=0;e<this.path.length;e++){const r=this.path[e],{scroll:o,options:i}=r;r!==this.root&&o&&i.layoutScroll&&(o.wasRoot&&yg(n,t),Ci(n.x,o.offset.x),Ci(n.y,o.offset.y))}return n}applyTransform(t,e=!1){const n={x:{min:0,max:0},y:{min:0,max:0}};yg(n,t);for(let t=0;t<this.path.length;t++){const r=this.path[t];!e&&r.options.layoutScroll&&r.scroll&&r!==r.root&&Ri(n,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),ki(r.latestValues)&&Ri(n,r.latestValues)}return ki(this.latestValues)&&Ri(n,this.latestValues),n}removeTransform(t){const e={x:{min:0,max:0},y:{min:0,max:0}};yg(e,t);for(let t=0;t<this.path.length;t++){const n=this.path[t];if(!n.instance)continue;if(!ki(n.latestValues))continue;Si(n.latestValues)&&n.updateSnapshot();const r={x:{min:0,max:0},y:{min:0,max:0}};yg(r,n.measurePageBox()),Sg(e,n.latestValues,n.snapshot?n.snapshot.layoutBox:void 0,r)}return ki(this.latestValues)&&Sg(e,this.latestValues),e}setTargetDelta(t){this.targetDelta=t,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(t){this.options={...this.options,...t,crossfade:void 0===t.crossfade||t.crossfade}}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!==Qe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(t=!1){var e;const n=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=n.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=n.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=n.isSharedProjectionDirty);const r=Boolean(this.resumingFrom)||this!==n;if(!(t||r&&this.isSharedProjectionDirty||this.isProjectionDirty||(null===(e=this.parent)||void 0===e?void 0:e.isProjectionDirty)||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:o,layoutId:i}=this.options;if(this.layout&&(o||i)){if(this.resolvedRelativeTargetAt=Qe.timestamp,!this.targetDelta&&!this.relativeTarget){const t=this.getClosestProjectingParent();t&&t.layout&&1!==this.animationProgress?(this.relativeParent=t,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pv(this.relativeTargetOrigin,this.layout.layoutBox,t.layout.layoutBox),yg(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(this.relativeTarget||this.targetDelta){var a,s,u;if(this.target||(this.target={x:{min:0,max:0},y:{min:0,max:0}},this.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}}),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),a=this.target,s=this.relativeTarget,u=this.relativeParent.target,Ev(a.x,s.x,u.x),Ev(a.y,s.y,u.y)):this.targetDelta?(Boolean(this.resumingFrom)?this.target=this.applyTransform(this.layout.layoutBox):yg(this.target,this.layout.layoutBox),Ei(this.target,this.targetDelta)):yg(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const t=this.getClosestProjectingParent();t&&Boolean(t.resumingFrom)===Boolean(this.resumingFrom)&&!t.options.layoutScroll&&t.target&&1!==this.animationProgress?(this.relativeParent=t,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pv(this.relativeTargetOrigin,this.target,t.target),yg(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}Cg&&Pg.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(this.parent&&!Si(this.parent.latestValues)&&!xi(this.parent.latestValues))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var t;const e=this.getLead(),n=Boolean(this.resumingFrom)||this!==e;let r=!0;if((this.isProjectionDirty||(null===(t=this.parent)||void 0===t?void 0:t.isProjectionDirty))&&(r=!1),n&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(r=!1),this.resolvedRelativeTargetAt===Qe.timestamp&&(r=!1),r)return;const{layout:o,layoutId:i}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!o&&!i)return;yg(this.layoutCorrected,this.layout.layoutBox);const a=this.treeScale.x,s=this.treeScale.y;!function(t,e,n,r=!1){const o=n.length;if(!o)return;let i,a;e.x=e.y=1;for(let s=0;s<o;s++){i=n[s],a=i.projectionDelta;const{visualElement:o}=i.options;o&&o.props.style&&"contents"===o.props.style.display||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Ri(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),a&&(e.x*=a.x.scale,e.y*=a.y.scale,Ei(t,a)),r&&ki(i.latestValues)&&Ri(t,i.latestValues))}e.x<Pi&&e.x>ji&&(e.x=1),e.y<Pi&&e.y>ji&&(e.y=1)}(this.layoutCorrected,this.treeScale,this.path,n),!e.layout||e.target||1===this.treeScale.x&&1===this.treeScale.y||(e.target=e.layout.layoutBox,e.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}});const{target:u}=e;u?(this.projectionDelta&&this.prevProjectionDelta?(mg(this.prevProjectionDelta.x,this.projectionDelta.x),mg(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),Ov(this.projectionDelta,this.layoutCorrected,u,this.latestValues),this.treeScale.x===a&&this.treeScale.y===s&&Eg(this.projectionDelta.x,this.prevProjectionDelta.x)&&Eg(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",u)),Cg&&Pg.recalculatedProjection++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(t=!0){var e;if(null===(e=this.options.visualElement)||void 0===e||e.scheduleRender(),t){const t=this.getStack();t&&t.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDeltaWithTransform={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}}setAnimationOrigin(t,e=!1){const n=this.snapshot,r=n?n.latestValues:{},o={...this.latestValues},i={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!e;const a={x:{min:0,max:0},y:{min:0,max:0}},s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),u=this.getStack(),c=!u||u.members.length<=1,l=Boolean(s&&!c&&!0===this.options.crossfade&&!this.path.some(Jg));let f;this.animationProgress=0,this.mixTargetDelta=e=>{const n=e/1e3;var u,h,p,d,y,m;Zg(i.x,t.x,n),Zg(i.y,t.y,n),this.setTargetDelta(i),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pv(a,this.layout.layoutBox,this.relativeParent.layout.layoutBox),p=this.relativeTarget,d=this.relativeTargetOrigin,y=a,m=n,Qg(p.x,d.x,y.x,m),Qg(p.y,d.y,y.y,m),f&&(u=this.relativeTarget,h=f,_g(u.x,h.x)&&_g(u.y,h.y))&&(this.isProjectionDirty=!1),f||(f={x:{min:0,max:0},y:{min:0,max:0}}),yg(f,this.relativeTarget)),s&&(this.animationValues=o,function(t,e,n,r,o,i){o?(t.opacity=we(0,void 0!==n.opacity?n.opacity:1,fg(r)),t.opacityExit=we(void 0!==e.opacity?e.opacity:1,0,hg(r))):i&&(t.opacity=we(void 0!==e.opacity?e.opacity:1,void 0!==n.opacity?n.opacity:1,r));for(let o=0;o<sg;o++){const i=`border${ag[o]}Radius`;let a=lg(e,i),s=lg(n,i);void 0===a&&void 0===s||(a||(a=0),s||(s=0),0===a||0===s||cg(a)===cg(s)?(t[i]=Math.max(we(ug(a),ug(s),r),0),(Zn.test(s)||Zn.test(a))&&(t[i]+="%")):t[i]=s)}(e.rotate||n.rotate)&&(t.rotate=we(e.rotate||0,n.rotate||0,r))}(o,r,this.latestValues,n,l,c)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(t){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=Ke.update((()=>{qv.hasAnimatedSinceResize=!0,this.currentAnimation=Bi(0,1e3,{...t,onUpdate:e=>{this.mixTargetDelta(e),t.onUpdate&&t.onUpdate(e)},onComplete:()=>{t.onComplete&&t.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);const t=this.getStack();t&&t.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const t=this.getLead();let{targetWithTransforms:e,target:n,layout:r,latestValues:o}=t;if(e&&n&&r){if(this!==t&&this.layout&&r&&ob(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||{x:{min:0,max:0},y:{min:0,max:0}};const e=Av(this.layout.layoutBox.x);n.x.min=t.target.x.min,n.x.max=n.x.min+e;const r=Av(this.layout.layoutBox.y);n.y.min=t.target.y.min,n.y.max=n.y.min+r}yg(e,n),Ri(e,o),Ov(this.projectionDeltaWithTransform,this.layoutCorrected,e,o)}}registerSharedNode(t,e){this.sharedNodes.has(t)||this.sharedNodes.set(t,new jg);this.sharedNodes.get(t).add(e);const n=e.options.initialPromotionConfig;e.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(e):void 0})}isLead(){const t=this.getStack();return!t||t.lead===this}getLead(){var t;const{layoutId:e}=this.options;return e&&(null===(t=this.getStack())||void 0===t?void 0:t.lead)||this}getPrevLead(){var t;const{layoutId:e}=this.options;return e?null===(t=this.getStack())||void 0===t?void 0:t.prevLead:void 0}getStack(){const{layoutId:t}=this.options;if(t)return this.root.sharedNodes.get(t)}promote({needsReset:t,transition:e,preserveFollowOpacity:n}={}){const r=this.getStack();r&&r.promote(this,n),t&&(this.projectionDelta=void 0,this.needsReset=!0),e&&this.setOptions({transition:e})}relegate(){const t=this.getStack();return!!t&&t.relegate(this)}resetSkewAndRotation(){const{visualElement:t}=this.options;if(!t)return;let e=!1;const{latestValues:n}=t;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(e=!0),!e)return;const r={};n.z&&Lg("z",t,r,this.animationValues);for(let e=0;e<Ig.length;e++)Lg(`rotate${Ig[e]}`,t,r,this.animationValues),Lg(`skew${Ig[e]}`,t,r,this.animationValues);t.render();for(const e in r)t.setStaticValue(e,r[e]),this.animationValues&&(this.animationValues[e]=r[e]);t.scheduleRender()}getProjectionStyles(t){var e,n;if(!this.instance||this.isSVG)return;if(!this.isVisible)return Rg;const r={visibility:""},o=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,r.opacity="",r.pointerEvents=ig(null==t?void 0:t.pointerEvents)||"",r.transform=o?o(this.latestValues,""):"none",r;const i=this.getLead();if(!this.projectionDelta||!this.layout||!i.target){const e={};return this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=ig(null==t?void 0:t.pointerEvents)||""),this.hasProjected&&!ki(this.latestValues)&&(e.transform=o?o({},""):"none",this.hasProjected=!1),e}const a=i.animationValues||i.latestValues;this.applyTransformsToTarget(),r.transform=function(t,e,n){let r="";const o=t.x.translate/e.x,i=t.y.translate/e.y,a=(null==n?void 0:n.z)||0;if((o||i||a)&&(r=`translate3d(${o}px, ${i}px, ${a}px) `),1===e.x&&1===e.y||(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:t,rotate:e,rotateX:o,rotateY:i,skewX:a,skewY:s}=n;t&&(r=`perspective(${t}px) ${r}`),e&&(r+=`rotate(${e}deg) `),o&&(r+=`rotateX(${o}deg) `),i&&(r+=`rotateY(${i}deg) `),a&&(r+=`skewX(${a}deg) `),s&&(r+=`skewY(${s}deg) `)}const s=t.x.scale*e.x,u=t.y.scale*e.y;return 1===s&&1===u||(r+=`scale(${s}, ${u})`),r||"none"}(this.projectionDeltaWithTransform,this.treeScale,a),o&&(r.transform=o(a,r.transform));const{x:s,y:u}=this.projectionDelta;r.transformOrigin=`${100*s.origin}% ${100*u.origin}% 0`,i.animationValues?r.opacity=i===this?null!==(n=null!==(e=a.opacity)&&void 0!==e?e:this.latestValues.opacity)&&void 0!==n?n:1:this.preserveOpacity?this.latestValues.opacity:a.opacityExit:r.opacity=i===this?void 0!==a.opacity?a.opacity:"":void 0!==a.opacityExit?a.opacityExit:0;for(const t in di){if(void 0===a[t])continue;const{correct:e,applyTo:n}=di[t],o="none"===r.transform?a[t]:e(a[t],i);if(n){const t=n.length;for(let e=0;e<t;e++)r[n[e]]=o}else r[t]=o}return this.options.layoutId&&(r.pointerEvents=i===this?ig(null==t?void 0:t.pointerEvents)||"":"none"),r}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach((t=>{var e;return null===(e=t.currentAnimation)||void 0===e?void 0:e.stop()})),this.root.nodes.forEach(Gg),this.root.sharedNodes.clear()}}}function Fg(t){t.updateLayout()}function Bg(t){var e;const n=(null===(e=t.resumeFrom)||void 0===e?void 0:e.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&n&&t.hasListeners("didUpdate")){const{layoutBox:e,measuredBox:r}=t.layout,{animationType:o}=t.options,i=n.source!==t.layout.source;"size"===o?Mv((t=>{const r=i?n.measuredBox[t]:n.layoutBox[t],o=Av(r);r.min=e[t].min,r.max=r.min+o})):ob(o,n.layoutBox,e)&&Mv((r=>{const o=i?n.measuredBox[r]:n.layoutBox[r],a=Av(e[r]);o.max=o.min+a,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[r].max=t.relativeTarget[r].min+a)}));const a={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};Ov(a,e,n.layoutBox);const s={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};i?Ov(s,t.applyTransform(r,!0),n.measuredBox):Ov(s,e,n.layoutBox);const u=!xg(a);let c=!1;if(!t.resumeFrom){const r=t.getClosestProjectingParent();if(r&&!r.resumeFrom){const{snapshot:o,layout:i}=r;if(o&&i){const a={x:{min:0,max:0},y:{min:0,max:0}};Pv(a,n.layoutBox,o.layoutBox);const s={x:{min:0,max:0},y:{min:0,max:0}};Pv(s,e,i.layoutBox),Tg(a,s)||(c=!0),r.options.layoutRoot&&(t.relativeTarget=s,t.relativeTargetOrigin=a,t.relativeParent=r)}}}t.notifyListeners("didUpdate",{layout:e,snapshot:n,delta:s,layoutDelta:a,hasLayoutChanged:u,hasRelativeTargetChanged:c})}else if(t.isLead()){const{onExitComplete:e}=t.options;e&&e()}t.options.transition=void 0}function Ug(t){Cg&&Pg.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=Boolean(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Vg(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function zg(t){t.clearSnapshot()}function Gg(t){t.clearMeasurements()}function Hg(t){t.isLayoutDirty=!1}function $g(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Wg(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function qg(t){t.resolveTargetDelta()}function Yg(t){t.calcProjection()}function Xg(t){t.resetSkewAndRotation()}function Kg(t){t.removeLeadSnapshot()}function Zg(t,e,n){t.translate=we(e.translate,0,n),t.scale=we(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Qg(t,e,n,r){t.min=we(e.min,n.min,r),t.max=we(e.max,n.max,r)}function Jg(t){return t.animationValues&&void 0!==t.animationValues.opacityExit}const tb={duration:.45,ease:[.4,0,.1,1]},eb=t=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),nb=eb("applewebkit/")&&!eb("chrome/")?Math.round:ie;function rb(t){t.min=nb(t.min),t.max=nb(t.max)}function ob(t,e,n){return"position"===t||"preserve-aspect"===t&&(r=Og(e),o=Og(n),i=.2,!(Math.abs(r-o)<=i));var r,o,i}function ib(t){var e;return t!==t.root&&(null===(e=t.scroll)||void 0===e?void 0:e.wasRoot)}const ab=Ng({attachResizeListener:(t,e)=>pv(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),sb={current:void 0},ub=Ng({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!sb.current){const t=new ab({});t.mount(window),t.setOptions({layoutScroll:!0}),sb.current=t}return sb.current},resetTransform:(t,e)=>{t.style.transform=void 0!==e?e:"none"},checkIsScrollRoot:t=>Boolean("fixed"===window.getComputedStyle(t).position)}),cb={pan:{Feature:class extends sv{constructor(){super(...arguments),this.removePointerDownListener=ie}onPointerDown(t){this.session=new vv(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Nv(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:e,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Vv(t),onStart:Vv(e),onMove:n,onEnd:(t,e)=>{delete this.session,r&&Ke.postRender((()=>r(t,e)))}}}mount(){this.removePointerDownListener=yv(this.node.current,"pointerdown",(t=>this.onPointerDown(t)))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends sv{constructor(t){super(t),this.removeGroupControls=ie,this.removeListeners=ie,this.controls=new Bv(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ie}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:ub,MeasureLayout:tg}};function lb(t,e){const n=_e(t),r=new AbortController;return[n,{passive:!0,...e,signal:r.signal},()=>r.abort()]}function fb(t){return e=>{"touch"===e.pointerType||fv()||t(e)}}function hb(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover","Start"===n);const o=r["onHover"+n];o&&Ke.postRender((()=>o(e,dv(e))))}const pb=(t,e)=>!!e&&(t===e||pb(t,e.parentElement)),db=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const yb=new WeakSet;function mb(t){return e=>{"Enter"===e.key&&t(e)}}function vb(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function gb(t){return hv(t)&&!fv()}function bb(t,e,n={}){const[r,o,i]=lb(t,n),a=t=>{const r=t.currentTarget;if(!gb(t)||yb.has(r))return;yb.add(r);const i=e(t),a=(t,e)=>{window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",u),gb(t)&&yb.has(r)&&(yb.delete(r),"function"==typeof i&&i(t,{success:e}))},s=t=>{a(t,n.useGlobalTarget||pb(r,t.target))},u=t=>{a(t,!1)};window.addEventListener("pointerup",s,o),window.addEventListener("pointercancel",u,o)};return r.forEach((t=>{(function(t){return db.has(t.tagName)||-1!==t.tabIndex})(t)||null!==t.getAttribute("tabindex")||(t.tabIndex=0);(n.useGlobalTarget?window:t).addEventListener("pointerdown",a,o),t.addEventListener("focus",(t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const r=mb((()=>{if(yb.has(n))return;vb(n,"down");const t=mb((()=>{vb(n,"up")}));n.addEventListener("keyup",t,e),n.addEventListener("blur",(()=>vb(n,"cancel")),e)}));n.addEventListener("keydown",r,e),n.addEventListener("blur",(()=>n.removeEventListener("keydown",r)),e)})(t,o)),o)})),i}function wb(t,e,n){const{props:r}=t;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap","Start"===n);const o=r["onTap"+("End"===n?"":n)];o&&Ke.postRender((()=>o(e,dv(e))))}const Sb=new WeakMap,kb=new WeakMap,xb=t=>{const e=Sb.get(t.target);e&&e(t)},_b=t=>{t.forEach(xb)};function Ab(t,e,n){const r=function({root:t,...e}){const n=t||document;kb.has(n)||kb.set(n,{});const r=kb.get(n),o=JSON.stringify(e);return r[o]||(r[o]=new IntersectionObserver(_b,{root:t,...e})),r[o]}(e);return Sb.set(t,n),r.observe(t),()=>{Sb.delete(t),r.unobserve(t)}}const Tb={some:0,all:1};const Ob={inView:{Feature:class extends sv{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:e,margin:n,amount:r="some",once:o}=t,i={root:e?e.current:void 0,rootMargin:n,threshold:"number"==typeof r?r:Tb[r]};return Ab(this.node.current,i,(t=>{const{isIntersecting:e}=t;if(this.isInView===e)return;if(this.isInView=e,o&&!e&&this.hasEnteredView)return;e&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",e);const{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),i=e?n:r;i&&i(t)}))}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:t,prevProps:e}=this.node;["amount","margin","root"].some(function({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}(t,e))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends sv{mount(){const{current:t}=this.node;t&&(this.unmount=bb(t,(t=>(wb(this.node,t,"Start"),(t,{success:e})=>wb(this.node,t,e?"End":"Cancel"))),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends sv{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch(e){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=ao(pv(this.node.current,"focus",(()=>this.onFocus())),pv(this.node.current,"blur",(()=>this.onBlur())))}unmount(){}}},hover:{Feature:class extends sv{mount(){const{current:t}=this.node;t&&(this.unmount=function(t,e,n={}){const[r,o,i]=lb(t,n),a=fb((t=>{const{target:n}=t,r=e(t);if("function"!=typeof r||!n)return;const i=fb((t=>{r(t),n.removeEventListener("pointerleave",i)}));n.addEventListener("pointerleave",i,o)}));return r.forEach((t=>{t.addEventListener("pointerenter",a,o)})),i}(t,(t=>(hb(this.node,t,"Start"),t=>hb(this.node,t,"End")))))}unmount(){}}}},Eb={layout:{ProjectionNode:ub,MeasureLayout:tg}},jb=(0,Im.createContext)({strict:!1}),Pb=(0,Im.createContext)({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),Cb=(0,Im.createContext)({});function Ib(t){const{initial:e,animate:n}=function(t,e){if(Zo(t)){const{initial:e,animate:n}=t;return{initial:!1===e||Yo(e)?e:void 0,animate:Yo(n)?n:void 0}}return!1!==t.inherit?e:{}}(t,(0,Im.useContext)(Cb));return(0,Im.useMemo)((()=>({initial:e,animate:n})),[Rb(e),Rb(n)])}function Rb(t){return Array.isArray(t)?t.join(" "):t}const Db=Symbol.for("motionComponentSymbol");function Lb(t,e,n){return(0,Im.useCallback)((r=>{r&&t.onMount&&t.onMount(r),e&&(r?e.mount(r):e.unmount()),n&&("function"==typeof n?n(r):_v(n)&&(n.current=r))}),[e])}const Mb=Go?Im.useLayoutEffect:Im.useEffect;function Nb(t,e,n,r,o){var i,a;const{visualElement:s}=(0,Im.useContext)(Cb),u=(0,Im.useContext)(jb),c=(0,Im.useContext)(Gv),l=(0,Im.useContext)(Pb).reducedMotion,f=(0,Im.useRef)(null);r=r||u.renderer,!f.current&&r&&(f.current=r(t,{visualState:e,parent:s,props:n,presenceContext:c,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:l}));const h=f.current,p=(0,Im.useContext)(Wv);!h||h.projection||!o||"html"!==h.type&&"svg"!==h.type||function(t,e,n,r){const{layoutId:o,layout:i,drag:a,dragConstraints:s,layoutScroll:u,layoutRoot:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Fb(t.parent)),t.projection.setOptions({layoutId:o,layout:i,alwaysMeasureLayout:Boolean(a)||s&&_v(s),visualElement:t,animationType:"string"==typeof i?i:"both",initialPromotionConfig:r,layoutScroll:u,layoutRoot:c})}(f.current,n,o,p);const d=(0,Im.useRef)(!1);(0,Im.useInsertionEffect)((()=>{h&&d.current&&h.update(n,c)}));const y=n[dn],m=(0,Im.useRef)(Boolean(y)&&!(null===(i=window.MotionHandoffIsComplete)||void 0===i?void 0:i.call(window,y))&&(null===(a=window.MotionHasOptimisedAnimation)||void 0===a?void 0:a.call(window,y)));return Mb((()=>{h&&(d.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),Zv.render(h.render),m.current&&h.animationState&&h.animationState.animateChanges())})),(0,Im.useEffect)((()=>{h&&(!m.current&&h.animationState&&h.animationState.animateChanges(),m.current&&(queueMicrotask((()=>{var t;null===(t=window.MotionHandoffMarkAsComplete)||void 0===t||t.call(window,y)})),m.current=!1))})),h}function Fb(t){if(t)return!1!==t.options.allowProjection?t.projection:Fb(t.parent)}function Bb({preloadedFeatures:t,createVisualElement:e,useRender:n,useVisualState:r,Component:o}){var i,a;function s(t,i){let a;const s={...(0,Im.useContext)(Pb),...t,layoutId:Ub(t)},{isStatic:u}=s,c=Ib(t),l=r(t,u);if(!u&&Go){!function(){(0,Im.useContext)(jb).strict;0}();const t=function(t){const{drag:e,layout:n}=zo;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:(null==e?void 0:e.isEnabled(t))||(null==n?void 0:n.isEnabled(t))?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}(s);a=t.MeasureLayout,c.visualElement=Nb(o,l,s,e,t.ProjectionNode)}return(0,zv.jsxs)(Cb.Provider,{value:c,children:[a&&c.visualElement?(0,zv.jsx)(a,{visualElement:c.visualElement,...s}):null,n(o,t,Lb(l,c.visualElement,i),l,u,c.visualElement)]})}t&&function(t){for(const e in t)zo[e]={...zo[e],...t[e]}}(t),s.displayName=`motion.${"string"==typeof o?o:`create(${null!==(a=null!==(i=o.displayName)&&void 0!==i?i:o.name)&&void 0!==a?a:""})`}`;const u=(0,Im.forwardRef)(s);return u[Db]=o,u}function Ub({layoutId:t}){const e=(0,Im.useContext)($v).id;return e&&void 0!==t?e+"-"+t:t}const Vb=["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 zb(t){return"string"==typeof t&&!t.includes("-")&&!!(Vb.indexOf(t)>-1||/[A-Z]/u.test(t))}function Gb(t){const e=(0,Im.useRef)(null);return null===e.current&&(e.current=t()),e.current}const Hb=t=>(e,n)=>{const r=(0,Im.useContext)(Cb),o=(0,Im.useContext)(Gv),i=()=>function({scrapeMotionValuesFromProps:t,createRenderState:e,onUpdate:n},r,o,i){const a={latestValues:$b(r,o,i,t),renderState:e()};return n&&(a.onMount=t=>n({props:r,current:t,...a}),a.onUpdate=t=>n(t)),a}(t,e,r,o);return n?i():Gb(i)};function $b(t,e,n,r){const o={},i=r(t,{});for(const t in i)o[t]=ig(i[t]);let{initial:a,animate:s}=t;const u=Zo(t),c=Qo(t);e&&c&&!u&&!1!==t.inherit&&(void 0===a&&(a=e.initial),void 0===s&&(s=e.animate));let l=!!n&&!1===n.initial;l=l||!1===a;const f=l?s:a;if(f&&"boolean"!=typeof f&&!qo(f)){const e=Array.isArray(f)?f:[f];for(let n=0;n<e.length;n++){const r=cn(t,e[n]);if(r){const{transitionEnd:t,transition:e,...n}=r;for(const t in n){let e=n[t];if(Array.isArray(e)){e=e[l?e.length-1:0]}null!==e&&(o[t]=e)}for(const e in t)o[e]=t[e]}}}return o}const Wb=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),qb=()=>({style:{},transform:{},transformOrigin:{},vars:{},attrs:{}});const Yb=["x","y","width","height","cx","cy","r"],Xb={useVisualState:Hb({scrapeMotionValuesFromProps:vi,createRenderState:qb,onUpdate:({props:t,prevProps:e,current:n,renderState:r,latestValues:o})=>{if(!n)return;let i=!!t.drag;if(!i)for(const t in o)if(Ge.has(t)){i=!0;break}if(!i)return;let a=!e;if(e)for(let n=0;n<Yb.length;n++){const r=Yb[n];t[r]!==e[r]&&(a=!0)}a&&Ke.read((()=>{!function(t,e){try{e.dimensions="function"==typeof t.getBBox?t.getBBox():t.getBoundingClientRect()}catch(t){e.dimensions={x:0,y:0,width:0,height:0}}}(n,r),Ke.render((()=>{ci(r,o,fi(n.tagName),t.transformTemplate),pi(n,r)}))}))}})},Kb={useVisualState:Hb({scrapeMotionValuesFromProps:mi,createRenderState:Wb})};function Zb(t,e,n){for(const r in e)xe(e[r])||yi(r,n)||(t[r]=e[r])}function Qb(t,e){const n={};return Zb(n,t.style||{},t),Object.assign(n,function({transformTemplate:t},e){return(0,Im.useMemo)((()=>{const n={style:{},transform:{},transformOrigin:{},vars:{}};return ii(n,e,t),Object.assign({},n.vars,n.style)}),[e])}(t,e)),n}function Jb(t,e){const n={},r=Qb(t,e);return t.drag&&!1!==t.dragListener&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=!0===t.drag?"none":"pan-"+("x"===t.drag?"y":"x")),void 0===t.tabIndex&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const tw=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 ew(t){return t.startsWith("while")||t.startsWith("drag")&&"draggable"!==t||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||tw.has(t)}let nw=t=>!ew(t);try{(rw=require("@emotion/is-prop-valid").default)&&(nw=t=>t.startsWith("on")?!ew(t):rw(t))}catch(t){}var rw;function ow(t,e,n,r){const o=(0,Im.useMemo)((()=>{const n={style:{},transform:{},transformOrigin:{},vars:{},attrs:{}};return ci(n,e,fi(r),t.transformTemplate),{...n.attrs,style:{...n.style}}}),[e]);if(t.style){const e={};Zb(e,t.style,t),o.style={...e,...o.style}}return o}function iw(t=!1){return(e,n,r,{latestValues:o},i)=>{const a=(zb(e)?ow:Jb)(n,o,i,e),s=function(t,e,n){const r={};for(const o in t)"values"===o&&"object"==typeof t.values||(nw(o)||!0===n&&ew(o)||!e&&!ew(o)||t.draggable&&o.startsWith("onDrag"))&&(r[o]=t[o]);return r}(n,"string"==typeof e,t),u=e!==Im.Fragment?{...s,...a,ref:r}:{},{children:c}=n,l=(0,Im.useMemo)((()=>xe(c)?c.get():c),[c]);return(0,Im.createElement)(e,{...u,children:l})}}function aw(t,e){return function(n,{forwardMotionProps:r}={forwardMotionProps:!1}){return Bb({...zb(n)?Xb:Kb,preloadedFeatures:t,useRender:iw(r),createVisualElement:e,Component:n})}}const sw=Ym(aw({...cv,...Ob,...cb,...Eb},((t,e)=>zb(t)?new gi(e):new Li(e,{allowProjection:t!==Im.Fragment}))));function uw(){return uw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uw.apply(null,arguments)}function cw(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return lw(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?lw(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lw(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var fw=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function hw(t){var e=t.children,n=t.border,r=void 0===n?"solid":n,o=t.color,i=void 0===o?"red":o,a=t.tag,s=t.borderWidth,u=void 0===s?1:s,c=t.as,l=void 0===c?"div":c,f=t.ref,h=fw(t,["children","border","color","tag","borderWidth","as","ref"]),p=qm(),d=cw((0,Im.useState)(!1),2),y=d[0],m=d[1];if(!p.config.app.inspector)return Rm().createElement(l,uw({},h,{ref:f}),e);var v=Object.assign(Object.assign({},h),{onMouseEnter:function(){return m(!0)},onMouseLeave:function(){return m(!1)},style:Object.assign(Object.assign({},h.style||{}),{outline:"".concat(u,"px ").concat(r," ").concat(i),zIndex:y?1e3:"auto"})});return Rm().createElement(l,uw({},v,{ref:f}),a&&y&&Rm().createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black text-sm"},a),e)}function pw(t){var e=t.border,n=void 0===e?"solid":e,r=t.color,o=void 0===r?"red":r,i=t.tag,a=t.borderWidth,s=void 0===a?1:a,u=t.as,c=void 0===u?"img":u,l=fw(t,["border","color","tag","borderWidth","as"]),f=qm(),h=cw((0,Im.useState)(!1),2),p=h[0],d=h[1];if(!f.config.app.inspector)return Rm().createElement(c,l);var y=Object.assign(Object.assign({},l),{onMouseEnter:function(){return d(!0)},onMouseLeave:function(){return d(!1)},style:Object.assign(Object.assign({},l.style||{}),{outline:"".concat(n," ").concat(s,"px ").concat(o),zIndex:p?1e3:"auto"})});return Rm().createElement("div",null,Rm().createElement(c,y),i&&p&&Rm().createElement("span",{className:"absolute top-0 left-0 bg-white text-black border-2 border-black"},i))}const dw={Div:function(t){return Rm().createElement(hw,uw({},t,{as:"div"}))},Span:function(t){return Rm().createElement(hw,uw({},t,{as:"span"}))},Button:function(t){return Rm().createElement(hw,uw({},t,{as:"button"}))},Img:function(t){return Rm().createElement(pw,uw({},t,{as:"img"}))},mDiv:function(t){return Rm().createElement(hw,uw({},t,{as:sw.div,ref:t.ref,layout:t.layout}))}};function yw(){return yw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yw.apply(null,arguments)}function mw(t){var e=t.children,n=t.className,r=t.props,o=t.style,i=t.ref,a=zm().ratio,s=a.getStyle();return Rm().createElement("div",{className:Cm("inset-0",n),style:{width:"100%",height:"100%",minWidth:"".concat(a.state.minWidth,"px"),minHeight:"".concat(a.state.minHeight,"px")}},Rm().createElement("div",yw({style:Object.assign(Object.assign(Object.assign(Object.assign({},s),{position:"relative"}),(null==r?void 0:r.style)||{}),o||{})},r||{},{ref:i}),e))}function vw(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return gw(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gw(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gw(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function bw(t){var e=qm(),n=vw(Rm().useState(e.preference.getPreference(t)),2),r=n[0],o=n[1];return(0,Im.useEffect)((function(){return e.preference.onPreferenceChange(t,o).cancel}),[]),[r,function(n){e.preference.setPreference(t,n),o(n)}]}function ww(t){var e=t.children,n=t.className,r=t.style,o=zm().ratio,i=qm();return Rm().createElement(mw,{className:Cm("absolute pointer-events-none w-full h-full"),style:{transform:"scale(".concat(o.state.scale,")"),transformOrigin:"left top",width:i.config.width,height:i.config.height,pointerEvents:"none"}},Rm().createElement("div",{className:"absolute w-full h-full pointer-disabled"},Rm().createElement("div",{className:"h-full w-full pointer-disabled"},Rm().createElement("div",{className:Cm(n),style:r},e))))}function Sw(t){var e=t.children,n=t.className,r=t.style;return Rm().createElement(Rm().Fragment,null,Rm().createElement(ww,{style:r,className:n},e))}function kw(){return kw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kw.apply(null,arguments)}var xw=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function _w(t){var e=t.id,n=t.children,r=t.className,o=t.style,i=xw(t,["id","children","className","style"]);return Rm().createElement(sw.div,kw({className:Cm("w-full h-full"),key:e},i),Rm().createElement(ww,{className:r,style:o},n))}var Aw=Rm().createContext(null);var Tw=Rm().createContext(null);function Ow(){return Ow=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ow.apply(null,arguments)}var Ew=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function jw(t){var e=t.className,n=t.children,r=Ew(t,["className","children"]),o=zm().ratio,i=(0,Im.useRef)([]),a=(0,Im.useCallback)((function(t){return i.current.push(t),i.current.indexOf(t)}),[]),s=(0,Im.useCallback)((function(t){var e=i.current.indexOf(t);-1!==e&&i.current.splice(e,1)}),[]),u=(0,Im.useCallback)((function(t){return i.current.indexOf(t)}),[]);return Rm().createElement(Rm().Fragment,null,Rm().createElement(Tw,{value:{register:a,unregister:s,getIndex:u}},Rm().createElement("div",{style:{transform:"scale(".concat(o.state.scale,")"),transformOrigin:"left top"},className:Cm("w-full h-full")},Rm().createElement("div",Ow({className:Cm("z-20",e)},r),n))))}var Pw=Rm().createContext(null);var Cw=Rm().createContext(null);function Iw(){var t=Rm().useContext(Cw);if(!t)throw new Error("useSentenceContext must be used within a SentenceContext");return t}function Rw(){return Rw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Rw.apply(null,arguments)}function Dw(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Dw=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),s=new P(r||[]);return o(a,"_invoke",{value:T(t,n,s)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};c(w,a,(function(){return this}));var S=Object.getPrototypeOf,k=S&&S(S(C([])));k&&k!==n&&r.call(k,a)&&(w=k);var x=b.prototype=v.prototype=Object.create(w);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Mw(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function T(e,n,r){var o=h;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var u=O(s,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var c=f(e,n,r);if("normal"===c.type){if(o=r.done?y:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=y,r.method="throw",r.arg=c.arg)}}}function O(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,O(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=f(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function C(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(Mw(e)+" is not iterable")}return g.prototype=b,o(x,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(x),t},e.awrap=function(t){return{__await:t}},_(A.prototype),c(A.prototype,s,(function(){return this})),e.AsyncIterator=A,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new A(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(x),c(x,u,"Generator"),c(x,a,(function(){return this})),c(x,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return s.type="throw",s.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function Lw(t){return function(t){if(Array.isArray(t))return Bw(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Fw(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mw(t){return Mw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mw(t)}function Nw(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Fw(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fw(t,e){if(t){if("string"==typeof t)return Bw(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Bw(t,e):void 0}}function Bw(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Uw=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function Vw(t){var e=Dw().mark(B),n=t.sentence,r=t.gameState,o=t.useTypeEffect,i=void 0===o||o,a=t.onCompleted,s=t.finished,u=t.count,c=t.words,l=t.className,f=t.style,h=Uw(t,["sentence","gameState","useTypeEffect","onCompleted","finished","count","words","className","style"]),p=Nw((0,Im.useState)(!1),2),d=p[0],y=p[1],m=r.game,v=(0,Im.useMemo)((function(){return c||n.evaluate(Gp.getCtx({gameState:r}))}),[c,n,r]),g=Nw((0,Im.useState)([]),2),b=g[0],w=g[1],S=(0,Im.useRef)(B(v)),k=(0,Im.useRef)(null),x=(0,Im.useRef)(null),_=Nw((0,Im.useState)(0),2),A=_[0],T=_[1],O=Nw((0,Im.useReducer)((function(t){return t+1}),0),2)[1],E=Nw((0,Im.useState)(new Set),2),j=E[0],P=E[1],C=Nw((0,Im.useState)(!1),2),I=C[0],R=C[1];(0,Im.useEffect)((function(){if(i||L(!0),s&&!d)return k.current&&clearTimeout(k.current),k.current=null,L(!0),void(a&&a());if(!(d||s||I||k.current)){var t=S.current.next(),e=t.done,n=t.value;if(e)return y(!0),void(a&&a());if(xc.isPause(n))F(xc.from(n));else{M(n),O();var r="object"===Mw(n)&&"cps"in n&&void 0!==n.cps?Math.round(1e3/n.cps):Math.round(1e3/m.config.cps);x.current=setTimeout((function(){T((function(t){return t+1}))}),r)}}}),[A,s,I]),(0,Im.useEffect)((function(){if(u&&!k.current){if(I)return R(!1),void T((function(t){return t+1}));L(),T((function(t){return t+1}))}}),[u]);var D=i?b:function(){for(var t=[],e=B(v),n=!1,r=new Set;!n;){var o=e.next(),i=o.done,a=o.value;if(i)n=!0;else if(!xc.isPause(a)){if("\n"!==a&&r.has(a))continue;r.add(a);var s=t[t.length-1];s&&"\n"!==s&&"\n"!==a&&s.tag===a.tag?t[t.length-1]={text:s.text+a.text,config:a.config,tag:a.tag,tag2:a.tag2}:t.push(a)}}return t}();function L(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];x.current&&(clearTimeout(x.current),x.current=null);for(var e=!1;!e;){var n=S.current.next(),r=n.done,o=n.value;if(r)y(!0),a&&a(),e=!0;else if(xc.isPause(o)){if(t)continue;F(xc.from(o)),e=!0}else M(o)}}function M(t){w((function(e){if("\n"!==t&&j.has(t))return e;P((function(e){return new Set(e).add(t)}));var n=e[e.length-1];return n&&"\n"!==n&&"\n"!==t&&n.tag===t.tag?[].concat(Lw(e.slice(0,-1)),[{text:n.text+t.text,config:t.config,tag:t.tag,tag2:t.tag2}]):[].concat(Lw(e),[t])}))}function F(t){r.logger.info("Say","Paused",t),t.config.duration?k.current=setTimeout((function(){k.current=null,T((function(t){return t+1}))}),t.config.duration):R(!0)}function B(t){var n,r,o,i,a;return Dw().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Lw(t),r=0;case 2:if(!(r<n.length)){e.next=24;break}if(o=n[r],!xc.isPause(o.text)){e.next=8;break}return e.next=7,xc.from(o.text);case 7:return e.abrupt("continue",21);case 8:i=0;case 9:if(!(i<o.text.length)){e.next=21;break}if("\n"!==(a=o.text[i])){e.next=16;break}return e.next=14,"\n";case 14:e.next=18;break;case 16:return e.next=18,{text:a,config:o.config,tag:r,tag2:i,cps:o.config.cps};case 18:i++,e.next=9;break;case 21:r++,e.next=2;break;case 24:return e.abrupt("return");case 25:case"end":return e.stop()}}),e)}return Rm().createElement("div",Rw({},h,{className:Cm("whitespace-pre-wrap",{"font-bold":n.config.bold,italic:n.config.italic},l),style:Object.assign({},f)}),D.map((function(t,e){return"\n"===t?Rm().createElement("br",{key:e}):Rm().createElement(dw.Span,{tag:"say.word.".concat(e),key:e,style:Object.assign({color:N(t.config.color||n.config.color||m.config.defaultTextColor),fontFamily:t.config.fontFamily,fontSize:t.config.fontSize},m.config.app.debug?{outline:"1px dashed red"}:{}),className:Cm("whitespace-pre inline-block",{"font-bold":t.config.bold,italic:t.config.italic},t.config.className)},t.config.ruby?Rm().createElement("ruby",{className:"align-bottom inline-block"},Rm().createElement("rt",{className:"block text-center"},t.config.ruby),t.text):t.text)})))}function zw(t){return Rm().createElement(Vw,t)}function Gw(t){var e=Iw();return Rm().createElement(Vw,Rw({},t,{sentence:e.sentence,gameState:e.gameState,useTypeEffect:e.useTypeEffect,onCompleted:e.onCompleted,finished:e.finished,count:e.count,words:e.words}))}const Hw=Gw;function $w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ww(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ww(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ww(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qw(t){var e=t.className,n=t.style,r=(0,Im.useRef)(null),o=function(){var t=Rm().useContext(Tw);if(!t)throw new Error("useUIListContext must be used within a UIListContext");return t}(),i=o.register,a=o.unregister,s=o.getIndex,u=$w((0,Im.useState)(-1),2),c=u[0],l=u[1],f=function(){var t=Rm().useContext(Aw);if(!t)throw new Error("useUIMenuContext must be used within a UIMenuContext");return t}(),h=f.choose,p=f.evaluated,d=f.gameState,y=-1===c?null:p[c];return(0,Im.useLayoutEffect)((function(){if(r.current){var t=r;return i(t),l(s(t)),r.current.dataset.index=c.toString(),function(){return a(t)}}}),[i,a]),Rm().createElement(Rm().Fragment,null,Rm().createElement("button",{className:Cm(e),style:n,onClick:function(){-1!==c&&h(Object.assign(Object.assign({},p[c]),{evaluated:Oc.getText(p[c].words)}))},ref:r},y&&Rm().createElement(zw,{sentence:y.prompt,gameState:d,useTypeEffect:!1,words:y.words})))}class Yw extends Im.Component{getSnapshotBeforeUpdate(t){const e=this.props.childRef.current;if(e&&t.isPresent&&!this.props.isPresent){const t=this.props.sizeRef.current;t.height=e.offsetHeight||0,t.width=e.offsetWidth||0,t.top=e.offsetTop,t.left=e.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Xw({children:t,isPresent:e}){const n=(0,Im.useId)(),r=(0,Im.useRef)(null),o=(0,Im.useRef)({width:0,height:0,top:0,left:0}),{nonce:i}=(0,Im.useContext)(Pb);return(0,Im.useInsertionEffect)((()=>{const{width:t,height:a,top:s,left:u}=o.current;if(e||!r.current||!t||!a)return;r.current.dataset.motionPopId=n;const c=document.createElement("style");return i&&(c.nonce=i),document.head.appendChild(c),c.sheet&&c.sheet.insertRule(`\n [data-motion-pop-id="${n}"] {\n position: absolute !important;\n width: ${t}px !important;\n height: ${a}px !important;\n top: ${s}px !important;\n left: ${u}px !important;\n }\n `),()=>{document.head.removeChild(c)}}),[e]),(0,zv.jsx)(Yw,{isPresent:e,childRef:r,sizeRef:o,children:Im.cloneElement(t,{ref:r})})}const Kw=({children:t,initial:e,isPresent:n,onExitComplete:r,custom:o,presenceAffectsLayout:i,mode:a})=>{const s=Gb(Zw),u=(0,Im.useId)(),c=(0,Im.useCallback)((t=>{s.set(t,!0);for(const t of s.values())if(!t)return;r&&r()}),[s,r]),l=(0,Im.useMemo)((()=>({id:u,initial:e,isPresent:n,custom:o,onExitComplete:c,register:t=>(s.set(t,!1),()=>s.delete(t))})),i?[Math.random(),c]:[n,c]);return(0,Im.useMemo)((()=>{s.forEach(((t,e)=>s.set(e,!1)))}),[n]),Im.useEffect((()=>{!n&&!s.size&&r&&r()}),[n]),"popLayout"===a&&(t=(0,zv.jsx)(Xw,{isPresent:n,children:t})),(0,zv.jsx)(Gv.Provider,{value:l,children:t})};function Zw(){return new Map}const Qw=t=>t.key||"";function Jw(t){const e=[];return Im.Children.forEach(t,(t=>{(0,Im.isValidElement)(t)&&e.push(t)})),e}const tS=({children:t,custom:e,initial:n=!0,onExitComplete:r,presenceAffectsLayout:o=!0,mode:i="sync",propagate:a=!1})=>{const[s,u]=Hv(a),c=(0,Im.useMemo)((()=>Jw(t)),[t]),l=a&&!s?[]:c.map(Qw),f=(0,Im.useRef)(!0),h=(0,Im.useRef)(c),p=Gb((()=>new Map)),[d,y]=(0,Im.useState)(c),[m,v]=(0,Im.useState)(c);Mb((()=>{f.current=!1,h.current=c;for(let t=0;t<m.length;t++){const e=Qw(m[t]);l.includes(e)?p.delete(e):!0!==p.get(e)&&p.set(e,!1)}}),[m,l.length,l.join("-")]);const g=[];if(c!==d){let t=[...c];for(let e=0;e<m.length;e++){const n=m[e],r=Qw(n);l.includes(r)||(t.splice(e,0,n),g.push(n))}return"wait"===i&&g.length&&(t=g),v(Jw(t)),void y(c)}const{forceRender:b}=(0,Im.useContext)($v);return(0,zv.jsx)(zv.Fragment,{children:m.map((t=>{const d=Qw(t),y=!(a&&!s)&&(c===m||l.includes(d));return(0,zv.jsx)(Kw,{isPresent:y,initial:!(f.current&&!n)&&void 0,custom:y?void 0:e,presenceAffectsLayout:o,mode:i,onExitComplete:y?void 0:()=>{if(!p.has(d))return;p.set(d,!0);let t=!0;p.forEach((e=>{e||(t=!1)})),t&&(null==b||b(),v(h.current),a&&(null==u||u()),r&&r())},children:t},d)}))})};var eS=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function nS(t){var e=t.children,n=eS(t,["children"]),r=tS;return Rm().createElement(Rm().Fragment,null,Rm().createElement("div",n,Rm().createElement(r,null,e)))}var rS=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function oS(t){var e,n,r=rS(t,[]),o=Iw().sentence,i=qm();return Rm().createElement(Rm().Fragment,null,Rm().createElement("div",r,Rm().createElement("span",{style:{color:N((null===(e=o.config.character)||void 0===e?void 0:e.config.color)||i.config.defaultNametagColor)}},null===(n=o.config.character)||void 0===n?void 0:n.state.name)))}function iS(){return iS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},iS.apply(null,arguments)}function aS(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return sS(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sS(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var uS=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};function cS(t){var e=t.children,n=t.sentence,r=t.words,o=t.gameState,i=t.useTypeEffect,a=void 0===i||i,s=t.onClick,u=t.onFinished,c=uS(t,["children","sentence","words","gameState","useTypeEffect","onClick","onFinished"]),l=aS((0,Im.useState)(!1),2),f=l[0],h=l[1],p=o.game,d=aS((0,Im.useState)(0),2),y=d[0],m=d[1],v=zm().ratio,g=aS((0,Im.useState)(new W),1)[0],b=aS(bw(IS.Preferences.showDialog),1)[0];function w(){p.preference.getPreference(IS.Preferences.autoForward)&&g.cancelTask().scheduleTask((function(){s&&s()}),p.config.autoForwardDelay)}(0,Im.useEffect)((function(){if(window){var t=function(t){p.config.nextKey.includes(t.key)&&(f?s&&s():m((function(t){return t+1})))};return window.addEventListener("keyup",t),function(){window.removeEventListener("keyup",t)}}console.warn("Failed to add event listener, window is not available\nat Say.tsx: onElementClick")}),[f]),(0,Im.useEffect)((function(){return o.events.on(bm.EventTypes["event:state.player.skip"],(function(){o.logger.log("NarraLeaf-React: Say","Skipped"),f?s&&s(!0):(h(!0),null==u||u())})).cancel}),[f]),(0,Im.useEffect)((function(){var t=p.preference.onPreferenceChange(IS.Preferences.autoForward,(function(t){t&&f?w():g.cancelTask()}));return function(){t.cancel()}}),[f]),(0,Im.useEffect)((function(){return function(){g.cancelTask()}}),[]);var S={sentence:n,gameState:o,finished:f,useTypeEffect:a,count:y,words:r,onCompleted:function(){h(!0),null==u||u(),w()}};return Rm().createElement(Cw.Provider,{value:S},Rm().createElement("div",{"data-element-type":"dialog"},n.state.display&&Rm().createElement(dw.Div,{tag:"say.aspectScaleContainer",color:"blue",border:"dashed",className:Cm("absolute bottom-0 w-[calc(100%-40px)]",!b&&"invisible pointer-events-auto"),onClick:function(){f?(s&&s(),w()):m((function(t){return t+1}))},style:Object.assign({},$(p.config.useAspectScale,{width:p.config.dialogWidth,height:p.config.dialogHeight}))},Rm().createElement(dw.Div,{tag:"say.containerClassName",style:Object.assign({},$(p.config.useAspectScale,{transform:"scale(".concat(v.state.scale,")"),transformOrigin:"bottom left",width:"100%",height:"100%"}))},Rm().createElement("div",c,e)))))}function lS(t){var e=t.children,n=uS(t,["children"]),r=function(){var t=Rm().useContext(Pw);if(!t)throw new Error("useSayContext must be used within a SayContext");return t}();return Rm().createElement(cS,iS({},n,{sentence:r.action.sentence,words:r.action.words,gameState:r.gameState,useTypeEffect:r.useTypeEffect,onClick:r.onClick,onFinished:r.onFinished}),e)}const fS=lS;function hS(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return pS(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pS(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function dS(t){var e=t.action,n=t.onClick,r=t.useTypeEffect,o=void 0===r||r,i=t.gameState,a=hS((0,Im.useState)(!1),2),s=a[0],u=a[1],c=i.game.config.dialog;return Rm().createElement(Pw,{value:{action:e,onClick:n,onFinished:function(){u(!0)},useTypeEffect:o,gameState:i}},Rm().createElement(c,{isFinished:s}))}function yS(t){var e=t.prompt,n=t.choices,r=t.afterChoose,o=t.state,i=t.words,a=qm(),s=a.config.menu,u=(0,Im.useMemo)((function(){return n.map((function(t){return Object.assign(Object.assign({},t),{words:t.prompt.evaluate(Gp.getCtx({gameState:o}))})}))}),[]);return Rm().createElement(Rm().Fragment,null,Rm().createElement(Aw,{value:{evaluated:u,choose:function(t){r(t)},gameState:o}},Rm().createElement(mw,{className:"absolute"},e&&Rm().createElement(dS,{gameState:o,action:{sentence:e,words:i,character:null},useTypeEffect:!1})),Rm().createElement(dw.Div,{color:"green",border:"dashed",className:Cm("absolute"),style:{width:"".concat(a.config.width,"px"),height:"".concat(a.config.height,"px")}},Rm().createElement(s,{items:u.map((function(t,e){return e}))}))))}function mS(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return vS(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?vS(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function gS(t){var e=mS((0,Im.useState)(0),2),n=e[0],r=e[1];function o(){r((function(t){return t+1}))}return(0,Im.useEffect)((function(){o()}),null!=t?t:[]),[o,n]}function bS(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return wS(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wS(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function SS(t){var e=t.gameState,n=bS(gS(),1)[0],r=e.notificationMgr;(0,Im.useEffect)((function(){return r.onFlush((function(){n()})).cancel}),[]);var o=e.game.config.notification;return Rm().createElement("div",{className:"absolute top-0 left-0 w-full h-full pointer-events-none"},Rm().createElement(o,{notifications:r.toArray()}))}var kS={say:function(){return Rm().createElement(lS,null,Rm().createElement(oS,null),Rm().createElement(Gw,null))},menu:function(t){var e=t.items;return Rm().createElement(jw,{className:"absolute flex flex-col items-center justify-center min-w-full w-full h-full"},e.map((function(t){return Rm().createElement(qw,{key:t,className:"bg-white text-black p-2 mt-2 w-1/2"})})))},notification:function(t){var e=t.notifications;return Rm().createElement(nS,{className:"absolute top-0 left-0 w-full h-full"},e.map((function(t){var e=t.id,n=t.message;return Rm().createElement("div",{key:e,className:"absolute top-0 left-0 w-[100px] h-[80px]"},Rm().createElement("span",{className:"text-white text-2xl font-bold"},n))})))}};function xS(t){return xS="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xS(t)}function _S(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,AS(r.key),r)}}function AS(t){var e=function(t,e){if("object"!=xS(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=xS(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==xS(e)?e:e+""}var TS,OS=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.game=e,this.plugins=[],this.registerAll()},(e=[{key:"use",value:function(t){return this.plugins.push(t),this}},{key:"register",value:function(t){t.register(this.game)}},{key:"registerAll",value:function(){var t=this;this.plugins.forEach((function(e){return e.register(t.game)}))}},{key:"unregisterAll",value:function(){var t=this;this.plugins.forEach((function(e){return e.unregister(t.game)}))}},{key:"has",value:function(t){return this.plugins.some((function(e){return e.name===t.name}))}}])&&_S(t.prototype,e),n&&_S(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function ES(t){return ES="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ES(t)}function jS(t,e,n){return(e=CS(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PS(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,CS(r.key),r)}}function CS(t){var e=function(t,e){if("object"!=ES(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=ES(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ES(e)?e:e+""}(TS||(TS={})).game="game";var IS=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.hooks=new nt,this.liveGame=null,this.sideEffect=[],this.preference=new jm(t.DefaultPreference),this.config=D(t.DefaultConfig,e),this.plugins=new OS(this)},(e=[{key:"configure",value:function(t){var e;return this.config=D(this.config,t),null===(e=this.getLiveGame().getGameState())||void 0===e||e.events.emit(bm.EventTypes["event:state.player.requestFlush"]),this}},{key:"use",value:function(t){return this.plugins.has(t)||this.plugins.use(t).register(t),this}},{key:"getLiveGame",value:function(){if(!this.liveGame){var t=this.createLiveGame();return this.liveGame=t,t}return this.liveGame}},{key:"dispose",value:function(){var t;this.plugins.unregisterAll(),null===(t=this.liveGame)||void 0===t||t.dispose(),this.sideEffect.forEach((function(t){return t()}))}},{key:"addSideEffect",value:function(t){this.sideEffect.push(t)}},{key:"createLiveGame",value:function(){return new Am(this)}}])&&PS(t.prototype,e),n&&PS(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();IS.defaultSettings={volume:1},IS.DefaultPreference={autoForward:!1,skip:!0,showDialog:!0},IS.Preferences={autoForward:"autoForward",skip:"skip",showDialog:"showDialog"},IS.DefaultConfig={app:{debug:!1,logger:{log:!1,info:!1,warn:!0,error:!0,debug:!1,trace:!1,verbose:!1},inspector:!1,guard:jS(jS({},Pa.invalidExposedStateUnmounting,!0),Pa.unexpectedTimelineStatusChange,!0),screenshotQuality:1},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:3e3,allowSkipImageTransform:!0,allowSkipImageTransition:!0,allowSkipBackgroundTransform:!0,allowSkipBackgroundTransition:!1,allowSkipTextTransform:!0,allowSkipTextTransition:!0,allowSkipLayersTransform:!0,allowSkipVideo:!1,dialogWidth:1920,dialogHeight:216,defaultTextColor:"#000",defaultNametagColor:"#000",notification:kS.notification,menu:kS.menu,dialog:kS.say,onError:function(t){console.error(t)}},IS.GameSettingsNamespace=TS;var RS=o(72),DS=o.n(RS),LS=o(825),MS=o.n(LS),NS=o(659),FS=o.n(NS),BS=o(56),US=o.n(BS),VS=o(540),zS=o.n(VS),GS=o(113),HS=o.n(GS),$S=o(587),WS={};WS.styleTagTransform=HS(),WS.setAttributes=US(),WS.insert=FS().bind(null,"head"),WS.domAPI=MS(),WS.insertStyleElement=zS();DS()($S.A,WS);$S.A&&$S.A.locals&&$S.A.locals;var qS=o(33);function YS(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return XS(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?XS(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function XS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function KS(t){var e=t.src,n=t.width,r=t.height,o=YS((0,Im.useState)({x:0,y:0}),2),i=o[0],a=o[1],s=YS((0,Im.useState)(!1),2),u=s[0],c=s[1],l=(0,Im.useRef)(null),f=zm().ratio;return(0,Im.useEffect)((function(){var t=function(t){if(l.current){var e=l.current.getBoundingClientRect(),n=t.clientX-e.left,r=t.clientY-e.top;a({x:n,y:r}),u||c(!0)}};return window.addEventListener("mousemove",t),function(){window.removeEventListener("mousemove",t)}}),[u]),Rm().createElement(mw,{ref:l,className:"overflow-hidden absolute"},Rm().createElement("img",{src:e,style:{position:"absolute",left:i.x,top:i.y,width:n,height:r,pointerEvents:"none",zIndex:1001,display:u?"block":"none",cursor:"none",transform:"scale(".concat(f.state.scale,")")},alt:""}))}function ZS(t){return ZS="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ZS(t)}function QS(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,JS(r.key),r)}}function JS(t){var e=function(t,e){if("object"!=ZS(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=ZS(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ZS(e)?e:e+""}var tk=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.preloaded=[],this.events=new F}return e=t,(n=[{key:"add",value:function(e){var n=this.getSrc(e);return n&&this.has(n)||(this.preloaded.push(e),this.events.emit(t.EventTypes["event:preloaded.add"],e),this.events.emit(t.EventTypes["event:preloaded.change"])),this}},{key:"get",value:function(t){var e=this;return this.preloaded.find((function(n){return e.getSrc(n)===t}))}},{key:"has",value:function(t){var e=this;return Array.isArray(t)?t.every((function(t){return e.has(t)})):this.preloaded.some((function(n){return e.getSrc(n)===t}))}},{key:"remove",value:function(e){var n=this;if(Array.isArray(e)){var r=e.map((function(t){return n.getSrc(t)}));return this.preloaded=this.preloaded.filter((function(t){return!r.includes(n.getSrc(t))})),this}var o=this.getSrc(e);return this.preloaded=this.preloaded.filter((function(t){return n.getSrc(t)!==o})),this.events.emit(t.EventTypes["event:preloaded.remove"],e),this.events.emit(t.EventTypes["event:preloaded.change"]),this}},{key:"clear",value:function(){return this.preloaded=[],this}},{key:"getSrc",value:function(t){return Tu.getSrc(t)}}])&&QS(e.prototype,n),r&&QS(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function ek(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nk(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function rk(t){var e=t.children,n=t.className,r=t.gameState,o=ek((0,Im.useState)({}),2),i=o[0],a=o[1],s=zm().ratio,u=qm(),c=ek(gS(),1)[0],l=u.config.minWidth,f=u.config.minHeight;return(0,Im.useEffect)((function(){r.logger.debug("AspectRatio","mount, using interval",u.config.ratioUpdateInterval);var t=function(){if(s.isLocked())r.logger.weakWarn("Ratio is locked, skipping update");else{var t=document.getElementById(u.config.contentContainerId);if(t){var e,n,o=t.clientWidth,i=t.clientHeight,h=u.config.aspectRatio;o/i>h?(e=i*h,n=i):(e=o,n=o/h),e<l&&(e=l),n<f&&(n=f),a({width:"".concat(e,"px"),height:"".concat(n,"px"),margin:"auto",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",display:"flex",alignItems:"center",justifyContent:"center"});var p=e/u.config.width;s.update(e,n,p),s.updateMin(l,f),c()}}};s.setUpdate(t);var e=function(t,e){if(e<=0)return t;var n=null;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];n&&clearTimeout(n),n=setTimeout((function(){t.apply(void 0,o)}),e)}}((function(){t()}),u.config.ratioUpdateInterval);e(),window.addEventListener("resize",e);var n=s.onRequestedUpdate(e);return function(){window.removeEventListener("resize",e),n()}}),[s,u.config.ratioUpdateInterval]),(0,Im.useEffect)((function(){return r.events.on(bm.EventTypes["event:state.player.requestFlush"],c).cancel}),[r]),Rm().createElement("div",{id:u.config.contentContainerId,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},Rm().createElement("div",{className:Cm(n),style:i},e))}function ok(t){var e=t.error,n=t.errorInfo,r=qm();return r.config.onError&&r.config.onError(e),r.config.app.debug?Rm().createElement("div",{className:"text-left"},Rm().createElement("h1",null,"NarraLeaf-React cannot initialize the player correctly. (development mode)"),Rm().createElement("p",{className:"text-red-700"},"Message: ",e.message),Rm().createElement("pre",null,"Error Stack: ",null==e?void 0:e.stack),Rm().createElement("pre",null,"Component Stack: ",null==n?void 0:n.componentStack),Rm().createElement("pre",null,"Digest: ",null==n?void 0:n.digest)):Rm().createElement("div",{className:"bg-white w-full h-full"},Rm().createElement("h1",null,"NarraLeaf-React crashed due to an unknown error."),Rm().createElement("p",null,"Please contact the game developer for further assistance."))}function ik(t){return ik="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ik(t)}function ak(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,sk(r.key),r)}}function sk(t){var e=function(t,e){if("object"!=ik(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=ik(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ik(e)?e:e+""}function uk(t,e,n){return e=lk(e),function(t,e){if(e&&("object"==ik(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ck()?Reflect.construct(e,n||[],lk(t).constructor):e.apply(t,n))}function ck(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ck=function(){return!!t})()}function lk(t){return lk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},lk(t)}function fk(t,e){return fk=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},fk(t,e)}tk.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 hk=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=uk(this,e,arguments)).state={hasError:!1,error:null,errorInfo:null},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&fk(t,e)}(e,t),n=e,o=[{key:"getDerivedStateFromError",value:function(t){return{hasError:!0,error:t,errorInfo:null}}}],(r=[{key:"componentDidCatch",value:function(t,e){this.setState({error:t,errorInfo:e}),console.error(t,e)}},{key:"render",value:function(){return this.state.hasError?Rm().createElement(ok,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}])&&ak(n.prototype,r),o&&ak(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Rm().Component);function pk(t){return pk="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pk(t)}function dk(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return yk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yk(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function yk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function mk(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,vk(r.key),r)}}function vk(t){var e=function(t,e){if("object"!=pk(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=pk(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==pk(e)?e:e+""}var gk=function(){function t(e){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.game=e,this.src=new Map,this.preloadTasks=new Map,this.game.addSideEffect((function(){n.abortAll(),n.src.clear()}))}return e=t,r=[{key:"getImage",value:function(t,e,n){return function(t,e){return I(this,void 0,void 0,w().mark((function n(){return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise((function(n,r){fetch(t,e).then((function(t){return t.blob()})).then((function(t){var e=new FileReader;e.onload=function(){n(e.result)},e.readAsDataURL(t)})).catch(r)})));case 1:case"end":return n.stop()}}),n)})))}(t,Object.assign(Object.assign({},n),{signal:e}))}}],(n=[{key:"has",value:function(t){return this.src.has(t)}},{key:"add",value:function(t,e){return this.src.set(t,e),this}},{key:"remove",value:function(t){return this.src.delete(t),this}},{key:"get",value:function(t){return this.src.get(t)}},{key:"clear",value:function(){return this.src.clear(),this}},{key:"size",value:function(){return this.src.size}},{key:"isPreloading",value:function(t){return this.preloadTasks.has(t)}},{key:"preload",value:function(e,n){var r=this;if(this.src.has(n)||this.preloadTasks.has(n)){var o={abort:function(){},onFinished:function(){return o},onErrored:function(){return o}};return o}var i=n,a={};this.game.hooks.rawTrigger("preloadImage",(function(){return[i,function(t,e){i=t,a=Object.assign(Object.assign({},a),e)}]}));var s=new AbortController,u=s.signal,c=[],l={promise:t.getImage(i,u,a).then((function(t){r.preloadTasks.delete(n),t&&r.add(n,t)})).catch((function(t){e.logger.error("ImageCacheManager","Failed to preload image: ".concat(n),"Reason: ".concat(t)),c.forEach((function(e){return e(t)}))})),controller:s};this.preloadTasks.set(n,l);var f={abort:function(){s.abort(),r.preloadTasks.delete(n)},onFinished:function(t){return l.promise.then(t),f},onErrored:function(t){return c.push(t),f}};return f}},{key:"abortAll",value:function(){this.preloadTasks.forEach((function(t){t.controller.abort()})),this.preloadTasks.clear()}},{key:"abort",value:function(t){var e=this.preloadTasks.get(t);e&&(e.controller.abort(),this.preloadTasks.delete(t))}},{key:"preloadedSrc",value:function(){return Array.from(this.src.values())}},{key:"filter",value:function(t){var e,n=dk(this.src.keys());try{for(n.s();!(e=n.n()).done;){var r=e.value;t.includes(r)||this.src.delete(r)}}catch(t){n.e(t)}finally{n.f()}return this}}])&&mk(e.prototype,n),r&&mk(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function bk(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return wk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wk(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Sk=(0,Im.createContext)(null);function kk(t){var e=t.children,n=qm(),r=bk((0,Im.useState)((function(){return new tk})),1)[0],o=bk((0,Im.useState)((function(){return new gk(n)})),1)[0];return Rm().createElement(Rm().Fragment,null,Rm().createElement(Sk,{value:{preloaded:r,cacheManager:o}},e))}function xk(){if(!Sk)throw new Error("usePreloaded must be used within a PreloadedProvider");return(0,Im.useContext)(Sk)}function _k(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Tk(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Ak(t){return function(t){if(Array.isArray(t))return Ok(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Tk(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tk(t,e){if(t){if("string"==typeof t)return Ok(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ok(t,e):void 0}}function Ok(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ek(t){var e=t.state,n=xk(),r=n.preloaded,o=n.cacheManager,i=qm(),a=(0,Im.useRef)(new Set),s="Preload",u=e.getLastScene(),c=i.getLiveGame().getCurrentAction(),l=i.getLiveGame().story;function f(){e.logger.debug(s,"Preload unmounted"),r.events.emit(tk.EventTypes["event:preloaded.unmount"])}return(0,Im.useEffect)((function(){var t,n;if("undefined"==typeof fetch)return r.events.emit(tk.EventTypes["event:preloaded.ready"]),e.logger.warn(s,"Fetch is not supported in this environment, skipping preload"),f;if(!i.config.preloadAllImages)return r.events.emit(tk.EventTypes["event:preloaded.ready"]),e.logger.debug(s,"Preload all images is disabled, skipping preload"),f;if(i.config.forceClearCache&&(o.clear(),e.logger.weakWarn(s,"Cache cleared")),!l||!u)return e.logger.weakWarn(s,"Story/Scene not found, skipping preload"),f;var a=performance.now(),c=Tu.catSrc([].concat(Ak((null===(t=u.srcManager)||void 0===t?void 0:t.src)||[]),Ak((null===(n=u.srcManager)||void 0===n?void 0:n.getFutureSrc())||[]))),h=new q(i.config.preloadConcurrency,i.config.preloadDelay),p=[],d=e.logger.group(s,!0),y=[];e.logger.debug(s,"preloading:",c,u);var m,v=_k(c.image);try{var g=function(){var t=m.value,n=Tu.getSrc(t);return n?(p.push(n),o.has(n)||o.isPreloading(n)||y.includes(n)?(e.logger.debug(s,"Image already loaded (".concat(c.image.indexOf(t)+1,"/").concat(c.image.length,")"),n),y.push(n),0):(y.push(n),void h.addTask((function(){return new Promise((function(r){o.preload(e,n).onFinished((function(){e.logger.debug(s,"Image loaded (".concat(c.image.indexOf(t)+1,"/").concat(c.image.length,")"),n),r()})).onErrored((function(){e.logger.weakError(s,"Failed to preload image (".concat(c.image.indexOf(t)+1,"/").concat(c.image.length,")"),n),r()}))}))})))):0};for(v.s();!(m=v.n()).done;)g()}catch(t){v.e(t)}finally{v.f()}return d.end(),h.start().then((function(){e.logger.info(s,"Image preload","loaded ".concat(o.size()," images in ").concat(performance.now()-a,"ms")),i.config.waitForPreload&&r.events.emit(tk.EventTypes["event:preloaded.ready"]),o.filter(p)})),i.config.waitForPreload||r.events.emit(tk.EventTypes["event:preloaded.ready"]),r.events.emit(tk.EventTypes["event:preloaded.mount"]),f}),[u,l]),(0,Im.useEffect)((function(){a.current.clear()}),[u]),(0,Im.useEffect)((function(){if("undefined"!=typeof fetch&&!i.config.preloadAllImages)if(l){var t=performance.now(),n=i.getLiveGame().getAllPredictableActions(l,c,i.config.maxPreloadActions).map((function(t){return Tu.getPreloadableSrc(l,t)})).filter((function(t){return null!==t}));n.filter((function(t){return"scene"===(null==t?void 0:t.activeType)})).forEach((function(t){a.current.has(t)||a.current.add(t)}));var r=Tu.catSrc([].concat(Ak(a.current),Ak(n))),u=new q(i.config.preloadConcurrency,i.config.preloadDelay),f=[],h=e.logger.group(s);e.logger.debug(s,"preloading:",r);var p,d=_k(r.image);try{var y=function(){var t=p.value,n=Tu.getSrc(t);return n?(f.push(n),o.has(n)||o.isPreloading(n)?(e.logger.debug(s,"Image already loaded (".concat(r.image.indexOf(t)+1,"/").concat(r.image.length,")"),n),0):void u.addTask((function(){return new Promise((function(i){o.preload(e,n).onFinished((function(){e.logger.debug(s,"Image loaded (".concat(r.image.indexOf(t)+1,"/").concat(r.image.length,")"),n),i()})).onErrored((function(){e.logger.weakError(s,"Failed to preload image (".concat(r.image.indexOf(t)+1,"/").concat(r.image.length,")"),n),i()}))}))}))):0};for(d.s();!(p=d.n()).done;)y()}catch(t){d.e(t)}finally{d.f()}h.end(),u.start().then((function(){e.logger.info(s,"Image preload (quick reload)","loaded ".concat(o.size()," images in ").concat(performance.now()-t,"ms")),o.filter(f)}))}else e.logger.weakWarn(s,"Story not found, skipping preload")}),[c,l]),null}function jk(t){return jk="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jk(t)}function Pk(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ck(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ck(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ck(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ik(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Rk(r.key),r)}}function Rk(t){var e=function(t,e){if("object"!=jk(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=jk(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==jk(e)?e:e+""}var Dk,Lk,Mk=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.events=new F,this.current=null,this.history=[],this.historyIndex=-1,this.game=e,n&&(this.current=n,this.history.push(n),this.historyIndex=0)},(e=[{key:"getCurrentId",value:function(){return this.current}},{key:"push",value:function(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}},{key:"back",value:function(){return this.historyIndex>0?(this.historyIndex--,this.current=this.history[this.historyIndex],this.emitOnChange()):(this.current=null,this.emitOnChange()),this}},{key:"forward",value:function(){return this.historyIndex<this.history.length-1&&(this.historyIndex++,this.current=this.history[this.historyIndex],this.emitOnChange()),this}},{key:"clear",value:function(){return this.current=null,this.history=[],this.historyIndex=-1,this.emitOnChange(),this}},{key:"cleanHistory",value:function(){return this.history=this.current?[this.current]:[],this.historyIndex=this.current?0:-1,this}},{key:"isActive",value:function(){return null!==this.current}},{key:"emitOnChange",value:function(){this.events.emit("event:router.onChange")}}])&&Ik(t.prototype,e),n&&Ik(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}(),Nk=(0,Im.createContext)(null);function Fk(t){var e=t.children,n=qm(),r=Pk((0,Im.useState)((function(){return new Mk(n)})),1)[0];return Rm().createElement(Rm().Fragment,null,Rm().createElement(Nk,{value:{router:r}},e))}function Bk(){if(!(0,Im.useContext)(Nk))throw new Error("usePreloaded must be used within a PreloadedProvider");return(0,Im.useContext)(Nk).router}function Uk(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Vk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vk(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function zk(t){var e=t.children,n=Uk(gS(),1)[0],r=Bk();if((0,Im.useEffect)((function(){if(r)return r.events.on("event:router.onChange",n).cancel}),[]),!r)return null;var o=Rm().Children.toArray(e),i=_w,a=o.filter((function(t){return Rm().isValidElement(t)&&t.type===i})).find((function(t){return t.props.id===r.getCurrentId()})),s=Sw,u=o.find((function(t){return Rm().isValidElement(t)&&t.type===s})),c=tS;return Rm().createElement(Rm().Fragment,null,u,Rm().createElement(c,null,a))}function Gk(t){return function(t){if(Array.isArray(t))return Wk(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$k(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hk(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||$k(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $k(t,e){if(t){if("string"==typeof t)return Wk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wk(t,e):void 0}}function Wk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qk(t){var e=t.element,n=t.state,r=t.skipTransform,o=t.skipTransition,i=t.overwriteDefinition,a=t.onTransform,s=t.transitionsProps,u=void 0===s?[]:s,c=t.propOverwrite,l=Hk((0,Im.useState)(null),2),f=l[0],h=l[1],p=Hk((0,Im.useState)(null),2),d=p[0],y=p[1],m=Rm().useRef(null),v=Hk((0,Im.useState)((function(){return new J("displayable.refGroup")})),1)[0],g=(0,Im.useRef)(v.next()),b=(0,Im.useRef)(T()),w=qm().getLiveGame().getGameState(),S="function"==typeof u?u(f):u,k=Hk(gS([d,f,b]),1)[0];function x(t,e){if(!t.current)throw new Yc("Displayable: Trying to assign properties to unmounted element");var n=t.current,r={},o={};Object.keys(e).forEach((function(t){var n=t;"style"===n&&e.style?Object.assign(r,e.style):void 0!==e[n]&&"key"!==n&&(o[n]=e[n])})),Object.keys(r).length>0&&Object.assign(n.style,r);for(var i=c?c(o):o,a=0,s=Object.entries(i);a<s.length;a++){var u=Hk(s[a],2),l=u[0],f=u[1];n.getAttribute(l)!==f&&n.setAttribute(l,f)}}function _(t,e){d&&(d.abort(),y(null));var r=t.animate(n,{gameState:w,ref:m,overwrites:i}),o=new Ya(r);return w.timelines.attachTimeline(o),r.onSkipControllerRegister((function(t){t.onAbort((function(){o.abort()}))})),y(r),r.then((function(){y(null),function(t){w.logger.debug("Displayable","Transform applied",n.toStyle(w,i),m.current),k(),null==a||a(t)}(t),e()})),o}function A(){r&&d&&(d.abort(),y(null),w.logger.debug("transform skipped")),o&&f&&(f.controller.complete(),w.logger.debug("transition skipped"))}function T(){return[[Rm().createRef(),g.current]]}return(0,Im.useEffect)((function(){return w.events.depends([w.events.on(bm.EventTypes["event:state.player.skip"],A)]).cancel}),[d,f,b]),(0,Im.useEffect)((function(){if(f){if(b.current.some((function(t){return!Hk(t,1)[0].current})))throw new Yc("Displayable: Trying to access transition groups before they are mounted");var t=f.controller,e=f.task,n=t.onUpdate((function(t){b.current.forEach((function(n,r){var o=Hk(n,1)[0],i=e.resolve[r],a="function"==typeof i?i:i.resolver;if(!a)throw new Yc("Displayable: Trying to resolve element props but found no resolver. (reading: transitionTask.task.resolve[".concat(r,"])"));var s=a.apply(void 0,Gk(t)),u=D(S[r]||S[S.length-1]||{},s);x(o,c?c(u):u)}))}));return n.cancel}}),[f]),(0,Im.useEffect)((function(){if(!b.current||!b.current.length)throw new Yc("Displayable: Transition group refs are not initialized correctly");if(b.current.some((function(t){return!Hk(t,1)[0].current})))throw new Yc("Displayable: Trying to access transition groups before they are mounted");b.current.forEach((function(t,e){var n=Hk(t,1)[0];if(!n.current)throw new Yc("Displayable: Trying to assign properties to unmounted element");x(n,S[e]||S[S.length-1]||{})}))}),[f]),(0,Im.useEffect)((function(){if(!m.current)throw new Error("Scope not ready. Using element: ".concat(e.constructor.name))}),[]),(0,Im.useEffect)((function(){var t=n.toStyle(w,i);Object.assign(m.current.style,t),w.logger.debug("Displayable","Initial style applied",m.current,t)}),[]),{transformRef:m,transitionRefs:b.current,isTransforming:!!d,transitionTask:f,initDisplayable:function(t){return w.logger.debug("initDisplayable",e),_(Ta.immediate(n.get()),t)},applyTransform:_,applyTransition:function(t,e){f&&f.controller.complete();var n,r=t.createTask(w),o=t.requestAnimations(r.animations),i=(new L).registerSkipController(new z(o.cancel)),a=new Ya(i);if(i.skipController.onAbort((function(){o.cancel()})),o.onCanceled((function(){a.abort()})),w.timelines.attachTimeline(a),h({task:r,controller:o,transition:t,resolve:e}),b.current=r.resolve.map((function(t){var e=Rm().createRef(),r="function"==typeof t?void 0:t.key;if(!r)return[e,v.next()];if("target"===r)return[e,n=v.next()];if("current"===r)return[e,g.current];throw new Yc("Displayable: Invalid key type")})),!n)throw new Yc("Displayable: No target key found");return g.current=n,o.start(),o.onComplete((function(){b.current.forEach((function(t){Hk(t,1)[0].current=null})),b.current=T(),h(null),e(),i.resolve()})),a},deps:[d,f,b]}}function Yk(t){return function(t){if(Array.isArray(t))return Xk(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Xk(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xk(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Xk(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Kk(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=qm().getLiveGame().getGameState();return(0,Im.useEffect)((function(){var n="function"==typeof e?e():e;return r.mountState(t,n).unMount}),Yk(n)),[]}function Zk(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||Jk(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qk(t){return function(t){if(Array.isArray(t))return tx(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Jk(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jk(t,e){if(t){if("string"==typeof t)return tx(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tx(t,e):void 0}}function tx(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ex(t){var e=t.state,n=t.layer,r=t.children,o=qk({element:n,state:n.transformState,skipTransform:e.game.config.allowSkipLayersTransform,skipTransition:!1,transitionsProps:[{style:{width:"100%",height:"100%",transformOrigin:"center"}}]}),i=o.transformRef,a=o.transitionRefs,s=o.initDisplayable,u=o.applyTransition,c=o.applyTransform,l=o.deps;return Kk(n,{initDisplayable:s,applyTransition:u,applyTransform:c},Qk(l)),(0,Im.useEffect)((function(){return e.logger.debug("Layer","Layer mounted",n.getId()),function(){e.logger.debug("Layer","Layer unmounted",n.getId())}}),[]),Rm().createElement(Rm().Fragment,null,Rm().createElement(sw.div,{layout:!0,className:"absolute w-full h-full",ref:i,"data-element-type":"layer","data-layer-id":n.getId()},a.map((function(t){var e=Zk(t,2),n=e[0],o=e[1];return Rm().createElement("div",{className:"relative w-full h-full",ref:n,key:o},r)}))))}function nx(t){return function(t){if(Array.isArray(t))return ix(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ox(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rx(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||ox(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ox(t,e){if(t){if("string"==typeof t)return ix(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ix(t,e):void 0}}function ix(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ax(t){var e=t.state,n=t.text,r=zm().ratio,o=rx(gS(),1)[0],i=qk({element:n,state:n.transformState,skipTransform:e.game.config.allowSkipTextTransform,skipTransition:e.game.config.allowSkipTextTransition,overwriteDefinition:{overwrite:function(t){return{width:"fit-content",transform:Ta.propToCSSTransform(e,t,{translate:["left"===n.config.alignX?"0%":"right"===n.config.alignX?"-100%":void 0,"top"===n.config.alignY?"100%":"bottom"===n.config.alignY?"0%":void 0]})}}},transitionsProps:[{style:{width:"fit-content",whiteSpace:"nowrap",transform:"scale(".concat(r.state.scale,")"),transformOrigin:"".concat(n.config.alignX," ").concat(n.config.alignY),fontSize:"".concat(n.state.fontSize,"px")}}]}),a=i.transformRef,s=i.transitionRefs,u=i.initDisplayable,c=i.applyTransform,l=i.applyTransition,f=i.deps,h=i.isTransforming;return Kk(n,{initDisplayable:u,applyTransform:c,applyTransition:l,flush:o},nx(f)),Rm().createElement(dw.Div,{"data-element-type":"text"},Rm().createElement(dw.mDiv,{tag:"text.container",color:"green",border:"dashed",layout:h,ref:a,className:"absolute"},s.map((function(t){var e=rx(t,2),r=e[0],o=e[1];return Rm().createElement("span",{key:o,ref:r,className:n.config.className},Rm().createElement("span",null,n.state.text))}))))}function sx(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ux(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ux(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ux(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function cx(t){var e=t.ref,n=t.onSizeChanged,r=t.onLoad,o=t.autoFit,i=void 0!==o&&o,a=(0,Im.useRef)(null),s=zm().ratio,u=sx(Rm().useState((function(){return s.state.width})),2),c=u[0],l=u[1],f=sx(Rm().useState((function(){return s.state.height})),2),h=f[0],p=f[1],d=qm();function y(){var t=e||a;if(t.current&&t.current.naturalWidth)if(t.current.naturalWidth*t.current.naturalHeight==1){var r=s.state.width,o=s.state.height,u="".concat(r," / ").concat(o);l(r),p(o),t.current.style.aspectRatio=u,n&&n(r,o)}else{var c=i?d.config.width/t.current.naturalWidth:1,f=t.current.naturalWidth*s.state.scale*c,h=t.current.naturalHeight*s.state.scale*c;l(f),p(h),n&&n(f,h)}}return(0,Im.useEffect)((function(){return y(),s.onUpdate(y)}),[e]),(0,Im.useEffect)((function(){var t=new MutationObserver((function(t){t.forEach((function(t){"attributes"===t.type&&"src"===t.attributeName&&a.current&&y()}))}));return a.current&&t.observe(a.current,{attributes:!0}),function(){t.disconnect()}}),[]),Rm().createElement("img",{ref:e||a,onLoad:function(){y(),r&&r()},width:c,height:h,alt:"image"})}function lx(t){return function(t){if(Array.isArray(t))return px(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||hx(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fx(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||hx(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function hx(t,e){if(t){if("string"==typeof t)return px(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?px(t,e):void 0}}function px(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function dx(t){var e=t.image,n=t.state,r=fx((0,Im.useState)((function(){return new F})),1)[0],o=fx((0,Im.useState)([]),2),i=o[0],a=o[1],s=xk().cacheManager,u=(0,Im.useRef)([]),c=(0,Im.useRef)(null),l=qk({element:e,state:e.transformState,skipTransform:n.game.config.allowSkipImageTransform,skipTransition:n.game.config.allowSkipImageTransition,transitionsProps:function(t){var n=t?t.transition._getCurrentSrc():e.state.currentSrc;return[{style:{position:"absolute",transformOrigin:"center",backgroundColor:Hc.isColor(n)?Hc.colorToString(n):void 0,transform:"none",top:"auto",left:"auto",right:"auto",bottom:"auto"},src:Hc.isImageSrc(n)?Hc.srcToURL(n):qu.DefaultImagePlaceholder},{style:{position:"absolute",transformOrigin:"center",transform:"translate(-50%, -50%)",top:"50%",left:"50%",right:"auto",bottom:"auto",maxWidth:"none",maxHeight:"none"}}]},propOverwrite:function(t){var e;return t.src?(Hc.isDataURI(t.src)||s.has(t.src)||s.isPreloading(t.src)||u.current.includes(t.src)||(null===(e=n.game.getLiveGame().getGameState())||void 0===e||e.logger.warn("Image",'Image not preloaded: "'.concat(t.src,'". ')+"\nThis may be caused by complicated image action behavior that cannot be predicted. \nTo fix this issue, you can manually register the image using scene.preloadImage(YourImageSrc). "),u.current.push(t.src)),Object.assign(Object.assign({},t),{src:s.get(t.src)||t.src})):t}}),f=l.transformRef,h=l.transitionRefs,p=l.isTransforming,d=l.initDisplayable,y=l.applyTransition,m=l.applyTransform,v=l.deps;function g(t,e){c.current&&(r.emit("event:image.onLoad"),Object.assign(c.current.style,{width:"".concat(t,"px"),height:"".concat(e,"px")}))}function b(){r.emit("event:image.onLoad")}return Kk(e,{createWearable:function(t){a((function(e){return[].concat(lx(e),[t])}))},disposeWearable:function(t){a((function(e){return e.filter((function(e){return e.getId()!==t.getId()}))}))},initDisplayable:d,applyTransform:m,applyTransition:y,events:r},lx(v)),Rm().createElement(sw.div,{layout:p,ref:f,className:"absolute w-max h-max","data-element-type":"image"},Rm().createElement("div",{className:"relative h-full w-full",ref:c,"data-image-id":e.getId()},h.map((function(t,n){var r=fx(t,2),o=r[0],i=r[1];return Rm().createElement(cx,{key:i,ref:o,autoFit:e.config.autoFit,onSizeChanged:0===n?g:void 0,onLoad:0===n?b:void 0})})),Rm().createElement("div",{className:Cm("w-full h-full top-0 left-0 absolute")},i.map((function(t){return Rm().createElement("div",{className:Cm("w-full h-full relative"),key:"wearable-"+t.getId()},Rm().createElement(dx,{image:t,state:n}))})))))}function yx(t){var e=t.state,n=t.displayable;return Rm().createElement(Rm().Fragment,null,n.map((function(t){var n;if(t instanceof ph)return Rm().createElement(ax,{state:e,text:t,key:"text-"+t.getId()});if(t instanceof qu)return Rm().createElement(dx,{state:e,image:t,key:"image-"+t.getId()});throw new Error("Unsupported displayable type: "+((null===(n=null==t?void 0:t.constructor)||void 0===n?void 0:n.name)||t))})))}function mx(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||gx(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vx(t){return function(t){if(Array.isArray(t))return bx(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||gx(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gx(t,e){if(t){if("string"==typeof t)return bx(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bx(t,e):void 0}}function bx(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function wx(t){var e=t.state,n=t.className,r=t.elements,o=r.scene,i=r.layers,a=r.texts,s=r.menus,u=(0,Im.useRef)(!1);return(0,Im.useEffect)((function(){return o.events.depends([o.events.on(_p.EventTypes["event:scene.preUnmount"],(function(){if(o.state.backgroundMusic)return e.audioManager.stop(o.state.backgroundMusic).then((function(){o.state.backgroundMusic=null}))}))]).cancel}),[]),(0,Im.useEffect)((function(){return o.events.emit(_p.EventTypes["event:scene.mount"]),e.logger.debug("Scene","Scene mounted",o.getId()),function(){o.events.emit(_p.EventTypes["event:scene.unmount"]),e.logger.debug("Scene","Scene unmounted",o.getId())}}),[]),Kk(o,{setBackgroundMusic:function(t,n){return new Promise((function(r){o.state.backgroundMusic&&e.audioManager.stop(o.state.backgroundMusic,n).then((function(){o.state.backgroundMusic=null,t&&e.audioManager.play(t,{end:t.state.volume,duration:n}).then(r)}))}))}}),(0,Im.useEffect)((function(){e.events.emit(bm.EventTypes["event:state.onRender"])}),[]),Rm().createElement("div",{className:Cm(n,"w-full h-full absolute")},vx(i.entries()).sort((function(t,e){var n=mx(t,1)[0],r=mx(e,1)[0];return n.config.zIndex-r.config.zIndex})).map((function(t){var n=mx(t,2),r=n[0],o=n[1];return Rm().createElement(ex,{state:e,layer:r,key:r.getId()},Rm().createElement(yx,{state:e,displayable:o}))})),a.map((function(t){var n=t.action,r=t.onClick;return Rm().createElement(dS,{gameState:e,key:"say-"+n.id,action:n,onClick:function(t){t&&(u.current=!0),r(),e.stage.next(),setTimeout((function(){u.current=!1}),0)},useTypeEffect:!u.current})})),s.map((function(t,n){var r=t.action,o=t.onClick;return Rm().createElement("div",{key:"menu-"+n,"data-element-type":"menu"},Rm().createElement(yS,{state:e,prompt:r.prompt,choices:r.choices,afterChoose:function(t){o(t),e.stage.next()},words:r.words}))})),Rm().createElement(SS,{gameState:e}))}function Sx(t){var e=t.state,n=qm(),r=Bk();return(0,Im.useEffect)((function(){if(n.getLiveGame().gameState.playerCurrent){var t,o,i,a=(t=function(t){!n.config.skipKey.includes(t.key)||!n.preference.getPreference(IS.Preferences.skip)||r&&r.isActive()||(e.logger.verbose("KeyEventAnnouncer","Emitted event: state.player.skip"),e.events.emit(bm.EventTypes["event:state.player.skip"]))},o=n.config.skipInterval,i=0,function(){var e=Date.now();if(!(e-i<o))return i=e,t.apply(void 0,arguments)});return n.getLiveGame().onPlayerEvent("keydown",a).cancel}e.logger.warn("KeyEventAnnouncer","Failed to listen to playerElement events")}),[r]),Rm().createElement(Rm().Fragment,null)}function kx(t){var e=t.ref,n=zm().ratio;return(0,Im.useEffect)((function(){var t=e.current;if(t){var r=new ResizeObserver((function(){n.requestUpdate()}));return r.observe(t),function(){r.disconnect()}}}),[e.current]),null}function xx(t){var e=t.gameState,n=t.video,r=(0,Im.useRef)(null),o=function(t){return{show:(0,Im.useCallback)((function(){if(t.current){var e=t.current;e.style.opacity="1",e.style.pointerEvents="auto",e.style.visibility="visible"}}),[t]),hide:(0,Im.useCallback)((function(){if(t.current){var e=t.current;e.style.opacity="0",e.style.pointerEvents="none",e.style.visibility="hidden"}}),[t])}}(r),i=o.show,a=o.hide;return(0,Im.useEffect)((function(){return e.events.depends([e.events.on(bm.EventTypes["event:state.player.skip"],(function(){e.game.config.allowSkipVideo&&(r.current&&(r.current.pause(),r.current.currentTime=0,r.current.dispatchEvent(new Event("stopped"))),e.logger.log("NarraLeaf-React: Video","Skipped"))}))]).cancel}),[]),(0,Im.useEffect)((function(){a(),n.state.display&&i()}),[]),(0,Im.useEffect)((function(){if(r.current){var t=r.current,o=!1,s=function(){return new Yc("Failed to add event listener, ref is not available\nat Video.tsx: useEffect")},u=function(){!o&&t&&(o=!0,e.mountState(n,{show:function(){if(!r.current)throw s();i()},hide:function(){if(!r.current)throw s();a()},play:function(){if(!r.current)throw s();var t=r.current;return t.currentTime=0,new Promise((function(n){e.schedule((function(r){var o=r.retry;if(t.readyState<3){var i=function(){t.removeEventListener("loadeddata",i),o()};t.addEventListener("loadeddata",i)}else{var a=function(){u(),n()},s=function(){u(),n()},u=function(){t.removeEventListener("ended",a),t.removeEventListener("stopped",s)};t.addEventListener("ended",a),t.addEventListener("stopped",s),c.push(u),t.play().catch((function(t){e.logger.error("Failed to play video: "+t),u(),n()}))}}),10)}))},pause:function(){if(!r.current)throw s();r.current.pause()},resume:function(){if(!r.current)throw s();return r.current.play()},stop:function(){if(!r.current)throw s();r.current.pause(),r.current.dispatchEvent(new Event("stopped"))},seek:function(t){if(!r.current)throw s();r.current.currentTime=t}}))},c=[];return t.addEventListener("canplay",u),function(){o=!1,t.removeEventListener("canplay",u),c.forEach((function(t){return t()})),t.currentTime>0&&t.pause(),e.isStateMounted(n)&&e.unMountState(n)}}}),[e,n]),Rm().createElement("video",{ref:r,src:n.config.src,preload:"auto",muted:n.config.muted,playsInline:!0,width:"100%",height:"100%",onContextMenu:function(t){return t.preventDefault()}})}function _x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ax(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ax(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ax(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Tx(t,e){return t.handle(e)}function Ox(t){var e=t.story,n=void 0===e?Jp.empty():e,r=t.width,o=t.height,i=t.className,a=t.onReady,s=t.onEnd,u=t.children,c=t.active,l=void 0===c||c,f=_x((0,Im.useReducer)((function(t){return t+1}),0),2)[1],h=_x((0,Im.useState)(0),2),p=h[0],d=h[1],y=qm(),m=_x((0,Im.useReducer)(Tx,new bm(y,{update:f,forceUpdate:function(){v.logger.weakWarn("Player","force update"),(0,qS.flushSync)((function(){f()}))},forceRemount:function(){v.logger.weakWarn("Player","force remount"),(0,qS.flushSync)((function(){d((function(t){return t+1})),f()}))},next:j,dispatch:function(t){return g(t)}})),2),v=m[0],g=m[1],b=Rm().createRef(),w=Rm().createRef(),S=_x((0,Im.useState)(!1),2),k=S[0],x=S[1],_=Rm().useRef(!1),A=xk().preloaded,T=_x((0,Im.useState)(!1),2),O=T[0],E=T[1];function j(){for(var t=!1;!t;){var e=y.getLiveGame().next(v);if(!e)break;if(L.isAwaitable(e)){t=!0;break}if(e instanceof H){e.nextUnlock().then((function(){j()})),t=!0;break}g(e)}v.stage.update()}(0,Im.useEffect)((function(){return y.getLiveGame().setGameState(v),n&&!y.getLiveGame().isPlaying()&&y.getLiveGame().loadStory(n),v.playerCurrent=b.current,v.mainContentNode=w.current,function(){y.getLiveGame().setGameState(void 0),v.playerCurrent=null}}),[y,n]),(0,Im.useEffect)((function(){return Y((function(){x(!0);var t=v.getLastScene(),e=[];t?e.push(t.events.once("event:scene.mount",(function(){v.stage.next()})).cancel):v.stage.next();var n=v.events.on(bm.EventTypes["event:state.end"],(function(){s&&s({game:y,gameState:v,liveGame:y.getLiveGame(),storable:y.getLiveGame().getStorable()})}));return v.stage.update(),function(){t&&e.forEach((function(t){return t()})),n.cancel()}}))}),[]),(0,Im.useEffect)((function(){return Y((function(){k&&a&&!_.current&&(_.current=!0,v.stage.forceUpdate(),a({game:y,gameState:v,liveGame:y.getLiveGame(),storable:y.getLiveGame().getStorable()}))}))}),[k]),(0,Im.useEffect)((function(){return A.events.depends([A.events.on(tk.EventTypes["event:preloaded.ready"],(function(){E(!0),v.stage.update(),n&&j()}))]).cancel}),[]),(0,Im.useEffect)((function(){y.hooks.trigger("init",[])}),[]);var P=r||y.config.width,C=o||y.config.height;return Rm().createElement(hk,null,Rm().createElement("div",{style:{width:"number"==typeof P?"".concat(P,"px"):P,height:"number"==typeof C?"".concat(C,"px"):C},className:Cm(i,"__narraleaf_content-player"),ref:b,tabIndex:0},Rm().createElement(rk,{className:Cm("flex-grow overflow-auto"),gameState:v},Rm().createElement(kx,{ref:b}),Rm().createElement(mw,{className:"absolute",ref:w,style:{cursor:v.game.config.cursor?"none":"auto",overflow:v.game.config.showOverflow?"visible":"hidden"}},y.config.cursor&&Rm().createElement(KS,{src:y.config.cursor,width:y.config.cursorWidth,height:y.config.cursorHeight}),Rm().createElement(Ex,{show:O&&l,key:p},Rm().createElement(Sx,{state:v}),v.getSceneElements().map((function(t){return Rm().createElement(wx,{key:"scene-"+t.scene.getId(),state:v,elements:t})})),v.getVideos().map((function(t,e){return Rm().createElement("div",{className:"w-full h-full absolute",key:"video-"+e,"data-element-type":"video"},Rm().createElement(xx,{gameState:v,video:t}))}))),Rm().createElement(Ek,{state:v}),Rm().createElement(zk,null,u)))))}function Ex(t){var e=t.children,n=t.show;return Rm().createElement(Rm().Fragment,null,n?e:null)}function jx(t){var e=t.children,n=t.game;return Rm().createElement(Rm().Fragment,null,Rm().createElement(Vm,null,Rm().createElement(Wm,{game:n},Rm().createElement(kk,null,Rm().createElement(Fk,null,e)))))}function Px(t){return Px="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Px(t)}function Cx(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ix(r.key),r)}}function Ix(t){var e=function(t,e){if("object"!=Px(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Px(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Px(e)?e:e+""}function Rx(t,e,n){return e=Nx(e),function(t,e){if(e&&("object"==Px(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Dx()?Reflect.construct(e,n||[],Nx(t).constructor):e.apply(t,n))}function Dx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Dx=function(){return!!t})()}function Lx(t,e,n,r){var o=Mx(Nx(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Mx(){return Mx="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Nx(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Mx.apply(null,arguments)}function Nx(t){return Nx=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Nx(t)}function Fx(t,e){return Fx=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Fx(t,e)}(Lk=Dk||(Dk={})).image="narraleaf:image",Lk.text="narraleaf:text",Lk.layer="narraleaf:layer",Lk.scene="narraleaf:scene",Lk.video="narraleaf:video";var Bx=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Rx(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Fx(t,e)}(e,t),n=e,r=[{key:"_setPrevSrc",value:function(t){return this._prevSrc=t,this}},{key:"_setTargetSrc",value:function(t){return this._targetSrc=t,this}},{key:"_setCurrentSrc",value:function(t){return this._currentSrc=t,this}},{key:"_getPrevSrc",value:function(){return this._prevSrc}},{key:"_getTargetSrc",value:function(){return this._targetSrc}},{key:"_getCurrentSrc",value:function(){return this._currentSrc}},{key:"requestAnimations",value:function(t){var n=this,r=Lx(e,"requestAnimations",this,3)([t]);return r.onComplete((function(){n._setCurrentSrc(n._getTargetSrc())})),r}},{key:"asPrev",value:function(t){var n=this;return Lx(e,"asPrev",this,3)([function(){return D(t.apply(void 0,arguments),n._srcToProps(n._prevSrc))}])}},{key:"asTarget",value:function(t){var n=this;return Lx(e,"asTarget",this,3)([function(){return D(t.apply(void 0,arguments),n._srcToProps(n._targetSrc))}])}},{key:"_srcToProps",value:function(t){if(Hc.isColor(t))return{src:qu.DefaultImagePlaceholder,style:{backgroundColor:Hc.isRGBAColor(t)?Hc.RGBAColorToHex(t):t}};if(Hc.isImageSrc(t))return{src:Hc.srcToURL(t)};throw new qc("Image transition src cannot be identified, using: "+t)}}],r&&Cx(n.prototype,r),o&&Cx(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Vf);function Ux(t){return Ux="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ux(t)}function Vx(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zx(r.key),r)}}function zx(t){var e=function(t,e){if("object"!=Ux(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Ux(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ux(e)?e:e+""}function Gx(t,e,n){return e=$x(e),function(t,e){if(e&&("object"==Ux(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Hx()?Reflect.construct(e,n||[],$x(t).constructor):e.apply(t,n))}function Hx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Hx=function(){return!!t})()}function $x(t){return $x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$x(t)}function Wx(t,e){return Wx=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wx(t,e)}var qx=function(t){function e(t,n){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=Gx(this,e)).duration=t,r.easing=n,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wx(t,e)}(e,t),n=e,(r=[{key:"createTask",value:function(){return{animations:[{type:Rf.Number,start:0,end:1,duration:this.duration,ease:this.easing}],resolve:[this.asPrev((function(t){return{style:{opacity:1-t}}})),this.asTarget((function(t){return{style:{opacity:t}}}))]}}},{key:"copy",value:function(){return new e(this.duration,this.easing)}}])&&Vx(n.prototype,r),o&&Vx(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Bx);function Yx(t){return Yx="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yx(t)}function Xx(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Kx(r.key),r)}}function Kx(t){var e=function(t,e){if("object"!=Yx(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=Yx(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Yx(e)?e:e+""}function Zx(t,e,n){return e=Jx(e),function(t,e){if(e&&("object"==Yx(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Qx()?Reflect.construct(e,n||[],Jx(t).constructor):e.apply(t,n))}function Qx(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Qx=function(){return!!t})()}function Jx(t){return Jx=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Jx(t)}function t_(t,e){return t_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t_(t,e)}var e_=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0],o=arguments.length>2?arguments[2]:void 0;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=Zx(this,e)).duration=t,n.startPos=r,n.easing=o,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&t_(t,e)}(e,t),n=e,(r=[{key:"createTask",value:function(t){return{animations:[{type:Rf.Number,start:0,end:1,duration:this.duration,ease:this.easing},{type:Rf.Number,start:this.startPos[0],end:0,duration:this.duration,ease:this.easing},{type:Rf.Number,start:this.startPos[1],end:0,duration:this.duration,ease:this.easing}],resolve:[this.asPrev((function(){return{}})),this.asTarget((function(e,n,r){return{style:Object.assign(Object.assign({opacity:e},Hc.offset(["50%","50%"],[n,r],t.getStory().getInversionConfig())),{transform:"translate(-50%, 50%)"})}}))]}}},{key:"copy",value:function(){return new e(this.duration,this.startPos,this.easing)}}])&&Xx(n.prototype,r),o&&Xx(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Bx)})(),i})()));
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(`
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(`
4
+ [data-motion-pop-id="${n}"] {
5
+ position: absolute !important;
6
+ width: ${c}px !important;
7
+ height: ${u}px !important;
8
+ top: ${p}px !important;
9
+ left: ${f}px !important;
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.
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
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
+ 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
+ Wearable must be an Image with isWearable set to true
17
+ It seems like you are trying to add a non-wearable image to wearables
18
+ Image below violates the rule:
19
+ `+t)}_invalidTagGroupDefinitionError(){throw new Error("Invalid tag group definition. Tags in groups must be unique and not conflicting with each other.")}_setSrc(t,n,r){return r&&t.chain(this._applyTransition(r.copy(),i=>i._setPrevSrc(ue.resolveCurrentSrc(this))._setTargetSrc(n))),new ue(t,ue.ActionTypes.setSrc,new D().setContent([n]))}_setIsBackground(t){return Object.assign(this.config,{isBackground:t}),this}registerSrc(){return ee.isTagSrc(this)?this.srcManager.registerRawSrc(ee.getSrcFromTags(this.config.src.defaults,this.config.src.resolve)):k.isImageSrc(this.state.currentSrc)&&this.srcManager.registerRawSrc(k.srcToURL(this.state.currentSrc)),this}createImageConfig(t){let n=t.get();return ee.DefaultImageConfig.create({...n,src:ee.isTagDefinition(n.src)?n.src:null})}getInitialState(){return ee.DefaultImageState.create().assign({currentSrc:ee.getInitialSrc(this.userConfig.get())}).get()}getInitialTransformState(t){let[n]=t.extract(Se.DefaultTransformState.keys());return new Se(Se.DefaultTransformState.create(n.get()).get())}checkConfig(){for(let t of this.config.wearables)if(!t.config.isWearable)throw this._invalidWearableError(JSON.stringify(t.config));if(ee.isTagSrc(this)){let t=this.config.src,n=new Set;for(let s of t.groups)for(let c of s){if(n.has(c))throw this._invalidTagGroupDefinitionError();n.add(c)}let r=this.constructTagMap(t.groups),i=new Set;for(let s of t.defaults){if(i.has(s))throw new Error(`Tag conflict
20
+ Tag "${s}" is conflicting with another tag
21
+ Error found in config.tag.defaults`);if(!r.has(s))throw new Error(`Tag not found
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 rt,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 Ds=class Ds 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===ot.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===ot.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===ot.flush)return super.executeAction(t);if(this.type===ot.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(Ds.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()}};Ds.ActionTypes=ot;var ue=Ds;var Kt=class Kt 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=>{Kt.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(Kt,"scene:init")){let n=new b(i=>i),r=t.timelines.attachTimeline(n);return t.actionHistory.push(this,()=>{this.exit(t)},[],r),Kt.handleSceneInit(this.callee,{type:this.type,node:this.contentNode.getChild()},t,n)}else if(this.type===ge.exit){let n=Kt.createSceneSnapshot(this.callee,t);return t.actionHistory.push(this,r=>{let i=new b(s=>s);t.timelines.attachTimeline(i),Kt.handleSceneInit(this.callee,{type:this.type,node:this.contentNode.getChild()},t,i),Kt.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
+ Make sure you have registered the scene using story.register
25
+ Action: (id: ${this.getId()}) ${this.type}
26
+ At: ${this.__stack}`)}getSceneName(t){return typeof t=="string"?t:t.config.name}};Kt.ActionTypes=ge;var xe=Kt;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")}},Rs=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
+ Scene: ${c.config.name}
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===ot.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
+ 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:ct.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 Is=class Is 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:ct.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=Is.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()}};Is.ActionTypes=jr;var Bt=Is;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 Bt(this.chain(),Bt.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 Bt(this.chain(),Bt.ActionTypes.say,new D().setContent(c));return this.chain(u)}setName(t){let n=new Bt(this.chain(),Bt.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
+ 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 Pt=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})}};Pt.AnimationType=Ko;var Ir=class extends Pt{_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 Ls=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 wt{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 Ut,i=>{if(n){let c=new Ls(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 rt;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 _s=Lr;var Wt=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
+ 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 Wt(n,r)})}clear(){return this.namespaces={},this}};var Vs=class Vs extends le{constructor(t,n){super(),this.namespace=this.prefix(t),this.defaultContent=n}init(t){t.hasNamespace(this.namespace)||t.addNamespace(new Wt(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=Vs.NamespacePrefix){return n+":"+String(t)}createAction(t,n){return new _s(this.chain(),t,D.create(n))}};Vs.NamespacePrefix="persistent";var Bo=Vs,Ns=class Ns extends Bo{constructor(t){super(t,{}),this.namespace=this.prefix(t,Ns.LocalNamespacePrefix)}init(t){t.removeNamespace(this.namespace).addNamespace(new Wt(this.namespace,this.defaultContent))}};Ns.LocalNamespacePrefix="local";var Ms=Ns;var Mr=class extends ${executeAction(t){if(this.type===rr.action)return super.executeAction(t);throw super.unknownTypeError()}};Mr.ActionTypes=rr;var jt=class jt extends wt{constructor(t,n={}){super();let r=jt.DefaultUserConfig.create(n),i=jt.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 jt(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 jt.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())}};jt.DefaultUserConfig=new X({zIndex:0,...Se.DefaultTransformState.getDefaultConfig(),opacity:1}),jt.DefaultConfig=new X({name:"(anonymous)",zIndex:0}),jt.DefaultState=new X({displayables:[],zIndex:0});var Wo=jt;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 Ms(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 rt({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 Ut({allowFutureScene:!1}),i=>{let c=U({unloadScene:!0},r instanceof Pt?{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
+ Maybe you bind the same wearable image to multiple parent images
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 et)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 lt=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 $t=class $t extends Uo{constructor(n,r=$t.defaultConfig){super();this.entryScene=null;this.scenes=new Map;this.persistent=[];this.services=new Map;this.name=n,this.config=U($t.defaultConfig,r)}static empty(){return new $t("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
+ A pure object should:
41
+ 1. be an object literal
42
+ 2. not have any prototype
43
+ 3. no circular reference
44
+ 4. sub objects should also be pure objects or serializable data
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>$t.MAX_DEPTH)throw new Error(`Max depth reached while constructing scene roots (max depth: ${$t.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 Rs(n).run(this)}};$t.defaultConfig={origin:"bottom left"},$t.MAX_DEPTH=1e4;var Vr=$t;var Gs=class extends ${executeAction(t){let[n,r]=this.contentNode.getContent(),i=this.callee.triggerAction(lt.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 Gs(n,"service:action",new D().setContent([r,i]))}},Ic=class extends Rc{},Lc=class extends Ic{};var Et=class Et extends ${executeAction(t){let n=this,r=this.callee;if(n.is(Et,"video:play"))return this.changeStateAsync(t,i=>i.play());if(n.is(Et,"video:pause"))return this.changeState(t,i=>i.pause());if(n.is(Et,"video:stop"))return this.changeState(t,i=>i.stop());if(n.is(Et,"video:seek"))return this.changeState(t,i=>i.seek(n.contentNode.getContent()[0]));if(n.is(Et,"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(Et,"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(Et,"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)}};Et.ActionTypes=qn;var Fs=Et;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 Fs(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 Hs=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 Us=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
+ 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
+ ${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+`
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
+ 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
+ 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
+ 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 zt=class zt{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 Wt(zt.GameSpacesKey.game,zt.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
+ 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(zt.EventTypes["event:character.prompt"],t)}onMenuChoose(t){return this.events.on(zt.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.solved){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"]),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}".
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(Ht.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(oa,{image:T,state:t}))))))}function sl({state:o,displayable:t}){return ra.createElement(ra.Fragment,null,t.map(n=>{if(n instanceof Un)return ra.createElement(ol,{state:o,text:n,key:"text-"+n.getId()});if(n instanceof B)return ra.createElement(oa,{state:o,image:n,key:"image-"+n.getId()});throw new Error("Unsupported displayable type: "+(n?.constructor?.name||n))}))}import Dt,{useMemo as Rv,useCallback as ml,useRef as Iv}from"react";import ia from"react";var al=ia.createContext(null);function ud(){let o=ia.useContext(al);if(!o)throw new Error("useUIMenuContext must be used within a UIMenuContext");return o}var cl=ia.createContext(null);function pd(){let o=ia.useContext(cl);if(!o)throw new Error("useUIListContext must be used within a UIListContext");return o}import md from"react";function sa({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 ca,{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 Yt(){let o=fd.useContext(ll);if(!o)throw new Error("useDialogContext must be used within a DialogContext");return o}import aa,{useEffect as vv,useLayoutEffect as Sv,useMemo as xv,useState as bv}from"react";var Zt=class Zt{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(Zt.Events.complete):this.events.emit(Zt.Events.requestComplete)}forceSkip(){this.state==="ended"?this.events.emit(Zt.Events.complete):(this._forceSkipped=!0,this.events.emit(Zt.Events.forceSkip))}dispatchComplete(){if(this.state==="ended")return;let t=this.config.gameState.game.preference;this._state="ended",t.getPreference(de.Preferences.autoForward)&&this.scheduleAutoForward(),this.emitComplete()}emitComplete(){this.events.emit(Zt.Events.complete)}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()}scheduleAutoForward(){let t=this.config.gameState.game.preference;!t.getPreference(de.Preferences.autoForward)||this.state!=="ended"||this.autoForwardScheduler.cancelTask().scheduleTask(()=>{this.events.emit(Zt.Events.complete)},this.config.gameState.game.config.autoForwardDelay/t.getPreference(de.Preferences.gameSpeed))}};Zt.Events={requestComplete:"event:dialog.requestComplete",complete:"event:dialog.complete",forceSkip:"event:dialog.forceSkip"};var Jt=Zt;function Br({action:o,onFinished:t,useTypeEffect:n=!0,gameState:r}){let i=xv(()=>o.sentence?.evaluate(lt.getCtx({gameState:r})),[o.sentence,r]),[s]=bv(()=>new Jt({useTypeEffect:n,action:o,evaluatedWords:i||[],gameState:r})),c=r.game.config.dialog;return Sv(()=>s.events.depends([s.events.on(Jt.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"],()=>{r.logger.log("NarraLeaf-React: Say","Skipped",s.isIdle()),s.isIdle()?t?.(!0):s.forceSkip()}).cancel,[s]),aa.createElement(aa.Fragment,null,aa.createElement(ll,{value:s,key:o.id},aa.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
+ `?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]=ut();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(Jt.Events.requestComplete,()=>{c.logger.debug("Sentence.tsx","requestComplete"),u.current?.interact()}),r.events.on(Jt.Events.forceSkip,()=>{c.logger.debug("Sentence.tsx","forceSkip"),r.isEnded()||u.current?.forceSkip()})]).cancel,[r,l]),ul(()=>{s.preference.onPreferenceChange(de.Preferences.gameSpeed,()=>{u.current?.update()}),s.preference.onPreferenceChange(de.Preferences.autoForward,()=>{u.current?.update()})},[]);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
+ `&&H!==`
65
+ `&&Ie.tag===H.tag?[...j.slice(0,-1),{...H,text:Ie.text+H.text,config:H.config}]:[...j,H]})},oe=(H=!1)=>{c.logger.debug("Sentence.tsx","skipToEnd");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 vt=new b;if(c.timelines.attachTimeline(vt),vt.registerSkipController(new K(()=>{J(),j=!0,H.retry()})),vt.onSettled(()=>{J()}),A=vt,Ke.isPause(Oe)){let Rt=Ke.from(Oe),en=s.preference.getPreference(de.Preferences.gameSpeed);if(Rt.config.duration){let mt=Rt.config.duration/en;await xa(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 Rt=s.preference.getPreference(de.Preferences.gameSpeed),mt=(typeof Oe=="object"&&"cps"in Oe&&Oe.cps!==void 0?Oe.cps:s.config.cps)/Rt;await b.delay(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),...Jr(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=Yt();return Wn.createElement(hd,{...o,dialog:t,key:t.config.action.id})}var wv=pl;function la({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 ca.createElement(ca.Fragment,null,ca.createElement("button",{className:q(o),style:t,onClick:d,ref:r},m&&ca.createElement(gd,{dialog:new Jt({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(lt.getCtx({gameState:r}))})),[]);function m(d){n(d)}return Dt.createElement(Dt.Fragment,null,Dt.createElement(al,{value:{evaluated:l,choose:m,gameState:r}},Dt.createElement(cl,{value:{register:u,unregister:p,getIndex:f}},Dt.createElement(kt,{className:"absolute"},o&&Dt.createElement(Br,{gameState:r,action:{sentence:o,words:i,character:null},useTypeEffect:!1})),Dt.createElement(Bn.Div,{color:"green",border:"dashed",className:q("absolute"),style:{width:`${s.config.width}px`,height:`${s.config.height}px`}},Dt.createElement(a,{items:l.map((d,h)=>h)})))))}function yd({items:o}){return Dt.createElement(sa,{className:"absolute flex flex-col items-center justify-center min-w-full w-full h-full"},o.map(t=>Dt.createElement(la,{key:t,className:"bg-white text-black p-2 mt-2 w-1/2"})))}import Wr,{useEffect as Lv}from"react";import ua from"react";function pa({children:o,...t}){let n=cr;return ua.createElement(ua.Fragment,null,ua.createElement("div",{...t},ua.createElement(n,null,o)))}function dl({gameState:o}){let[t]=ut(),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"},Wr.createElement(r,{notifications:n.toArray()}))}function Td({notifications:o}){return Wr.createElement(pa,{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()}ma(()=>(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]),ma(()=>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()}}),[]),ma(()=>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]),ma(()=>S.events.depends([S.events.on(nt.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(Ys,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(kt,{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 fa from"react";function da({...o}){let{config:t}=Yt(),n=N();return fa.createElement(fa.Fragment,null,fa.createElement("div",{...o},fa.createElement("span",{style:{color:Pn(t.action.character?.config.color||n.config.defaultNametagColor)}},t.action.character?.state.name)))}function Bv(){let o=Yt(),t=Z.getText(o.config.evaluatedWords);return{done:o.isEnded(),text:t}}import $n,{useEffect as Ed}from"react";function jv({children:o,...t}){let n=N(),r=Yt(),{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:{...Jr(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=Yt();return!n.config.action.sentence||!n.config.action.words?null:$n.createElement(jv,{...t},o)}var Wv=kd;function Dd(){return $n.createElement(kd,null,$n.createElement(da,null),$n.createElement(pl,null))}var ha={say:Dd,menu:yd,notification:Td};var ga=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 Xs(Qt.DefaultPreference);this.config=U(Qt.DefaultConfig,t),this.plugins=new ga(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:ha.notification,menu:ha.menu,dialog:ha.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 Pt{_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}@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,at as CommonPosition,kr as CommonPositionType,kc as Condition,Ut as Control,ze as Coord2D,Wv as Dialog,bl as Dissolve,Hv as ExposedStateType,Al as FadeIn,de as Game,sa as GameMenu,Pd as GameProviders,ie as GameState,B as Image,zn as ImageTransition,kt as Isolated,la as Item,Be as Lambda,Wo as Layer,Cn as LiveGame,Dc as Menu,Wt as Namespace,da as Nametag,pa as Notifications,Xc as Page,Ke as Pause,Bo as Persistent,wd as Player,yt as Scene,lt as Script,Re as Sentence,Lc as Service,ct as Sound,el as Stage,_r as Storable,Vr as Story,Un as Text,Ir as TextTransition,wv as Texts,ce as Transform,Pt as Transition,_c as Video,Z as Word,nT as b,tT as c,oT as i,Bv as useDialog,N as useGame,xl as usePreference,Ur as useRouter};
73
+ /*! Bundled license information:
74
+
75
+ howler/dist/howler.js:
76
+ (*!
77
+ * howler.js v2.2.4
78
+ * howlerjs.com
79
+ *
80
+ * (c) 2013-2020, James Simpson of GoldFire Studios
81
+ * goldfirestudios.com
82
+ *
83
+ * MIT License
84
+ *)
85
+ (*!
86
+ * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
87
+ *
88
+ * howler.js v2.2.4
89
+ * howlerjs.com
90
+ *
91
+ * (c) 2013-2020, James Simpson of GoldFire Studios
92
+ * goldfirestudios.com
93
+ *
94
+ * MIT License
95
+ *)
96
+ */