pixospritz-core 0.10.1 → 1.0.1
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/README.md +36 -286
- package/dist/bundle.js +13 -3
- package/dist/bundle.js.map +1 -1
- package/dist/style.css +1 -0
- package/package.json +43 -44
- package/src/components/WebGLView.jsx +318 -0
- package/src/css/pixos.css +372 -0
- package/src/engine/actions/animate.js +41 -0
- package/src/engine/actions/changezone.js +135 -0
- package/src/engine/actions/chat.js +109 -0
- package/src/engine/actions/dialogue.js +90 -0
- package/src/engine/actions/face.js +22 -0
- package/src/engine/actions/greeting.js +28 -0
- package/src/engine/actions/interact.js +86 -0
- package/src/engine/actions/move.js +67 -0
- package/src/engine/actions/patrol.js +109 -0
- package/src/engine/actions/prompt.js +185 -0
- package/src/engine/actions/script.js +42 -0
- package/src/engine/core/audio/AudioSystem.js +543 -0
- package/src/engine/core/cutscene/PxcPlayer.js +956 -0
- package/src/engine/core/cutscene/manager.js +243 -0
- package/src/engine/core/database/index.js +75 -0
- package/src/engine/core/debug/index.js +371 -0
- package/src/engine/core/hud/index.js +765 -0
- package/src/engine/core/index.js +540 -0
- package/src/engine/core/input/gamepad/Controller.js +71 -0
- package/src/engine/core/input/gamepad/ControllerButtons.js +231 -0
- package/src/engine/core/input/gamepad/ControllerStick.js +173 -0
- package/src/engine/core/input/gamepad/index.js +592 -0
- package/src/engine/core/input/keyboard.js +196 -0
- package/src/engine/core/input/manager.js +485 -0
- package/src/engine/core/input/mouse.js +203 -0
- package/src/engine/core/input/touch.js +175 -0
- package/src/engine/core/mode/manager.js +199 -0
- package/src/engine/core/net/manager.js +535 -0
- package/src/engine/core/queue/action.js +83 -0
- package/src/engine/core/queue/event.js +82 -0
- package/src/engine/core/queue/index.js +44 -0
- package/src/engine/core/queue/loadable.js +33 -0
- package/src/engine/core/render/CameraEffects.js +494 -0
- package/src/engine/core/render/FrustumCuller.js +417 -0
- package/src/engine/core/render/LODManager.js +285 -0
- package/src/engine/core/render/ParticleManager.js +529 -0
- package/src/engine/core/render/TextureAtlas.js +465 -0
- package/src/engine/core/render/camera.js +338 -0
- package/src/engine/core/render/light.js +197 -0
- package/src/engine/core/render/manager.js +1079 -0
- package/src/engine/core/render/shaders.js +110 -0
- package/src/engine/core/render/skybox.js +342 -0
- package/src/engine/core/resource/manager.js +133 -0
- package/src/engine/core/resource/object.js +611 -0
- package/src/engine/core/resource/texture.js +103 -0
- package/src/engine/core/resource/tileset.js +177 -0
- package/src/engine/core/scene/avatar.js +215 -0
- package/src/engine/core/scene/speech.js +138 -0
- package/src/engine/core/scene/sprite.js +702 -0
- package/src/engine/core/scene/spritz.js +189 -0
- package/src/engine/core/scene/world.js +681 -0
- package/src/engine/core/scene/zone.js +1167 -0
- package/src/engine/core/store/index.js +110 -0
- package/src/engine/dynamic/animatedSprite.js +64 -0
- package/src/engine/dynamic/animatedTile.js +98 -0
- package/src/engine/dynamic/avatar.js +110 -0
- package/src/engine/dynamic/map.js +174 -0
- package/src/engine/dynamic/sprite.js +255 -0
- package/src/engine/dynamic/spritz.js +119 -0
- package/src/engine/events/EventSystem.js +609 -0
- package/src/engine/events/camera.js +142 -0
- package/src/engine/events/chat.js +75 -0
- package/src/engine/events/menu.js +186 -0
- package/src/engine/scripting/CallbackManager.js +514 -0
- package/src/engine/scripting/PixoScriptInterpreter.js +81 -0
- package/src/engine/scripting/PixoScriptLibrary.js +704 -0
- package/src/engine/shaders/effects/index.js +450 -0
- package/src/engine/shaders/fs.js +222 -0
- package/src/engine/shaders/particles/fs.js +41 -0
- package/src/engine/shaders/particles/vs.js +61 -0
- package/src/engine/shaders/picker/fs.js +34 -0
- package/src/engine/shaders/picker/init.js +62 -0
- package/src/engine/shaders/picker/vs.js +42 -0
- package/src/engine/shaders/pxsl/README.md +250 -0
- package/src/engine/shaders/pxsl/index.js +25 -0
- package/src/engine/shaders/pxsl/library.js +608 -0
- package/src/engine/shaders/pxsl/manager.js +338 -0
- package/src/engine/shaders/pxsl/specification.js +363 -0
- package/src/engine/shaders/pxsl/transpiler.js +753 -0
- package/src/engine/shaders/skybox/cosmic/fs.js +147 -0
- package/src/engine/shaders/skybox/cosmic/vs.js +23 -0
- package/src/engine/shaders/skybox/matrix/fs.js +127 -0
- package/src/engine/shaders/skybox/matrix/vs.js +23 -0
- package/src/engine/shaders/skybox/morning/fs.js +109 -0
- package/src/engine/shaders/skybox/morning/vs.js +23 -0
- package/src/engine/shaders/skybox/neon/fs.js +119 -0
- package/src/engine/shaders/skybox/neon/vs.js +23 -0
- package/src/engine/shaders/skybox/sky/fs.js +114 -0
- package/src/engine/shaders/skybox/sky/vs.js +23 -0
- package/src/engine/shaders/skybox/sunset/fs.js +101 -0
- package/src/engine/shaders/skybox/sunset/vs.js +23 -0
- package/src/engine/shaders/transition/blur/fs.js +42 -0
- package/src/engine/shaders/transition/blur/vs.js +26 -0
- package/src/engine/shaders/transition/cross/fs.js +36 -0
- package/src/engine/shaders/transition/cross/vs.js +26 -0
- package/src/engine/shaders/transition/crossBlur/fs.js +41 -0
- package/src/engine/shaders/transition/crossBlur/vs.js +25 -0
- package/src/engine/shaders/transition/dissolve/fs.js +78 -0
- package/src/engine/shaders/transition/dissolve/vs.js +24 -0
- package/src/engine/shaders/transition/fade/fs.js +31 -0
- package/src/engine/shaders/transition/fade/vs.js +27 -0
- package/src/engine/shaders/transition/iris/fs.js +52 -0
- package/src/engine/shaders/transition/iris/vs.js +24 -0
- package/src/engine/shaders/transition/pixelate/fs.js +44 -0
- package/src/engine/shaders/transition/pixelate/vs.js +24 -0
- package/src/engine/shaders/transition/slide/fs.js +53 -0
- package/src/engine/shaders/transition/slide/vs.js +24 -0
- package/src/engine/shaders/transition/swirl/fs.js +39 -0
- package/src/engine/shaders/transition/swirl/vs.js +26 -0
- package/src/engine/shaders/transition/wipe/fs.js +50 -0
- package/src/engine/shaders/transition/wipe/vs.js +24 -0
- package/src/engine/shaders/vs.js +60 -0
- package/src/engine/utils/CameraController.js +506 -0
- package/src/engine/utils/ObjHelper.js +551 -0
- package/src/engine/utils/debug-logger.js +110 -0
- package/src/engine/utils/enums.js +305 -0
- package/src/engine/utils/generator.js +156 -0
- package/src/engine/utils/index.js +21 -0
- package/src/engine/utils/loaders/ActionLoader.js +77 -0
- package/src/engine/utils/loaders/AudioLoader.js +157 -0
- package/src/engine/utils/loaders/EventLoader.js +66 -0
- package/src/engine/utils/loaders/ObjectLoader.js +67 -0
- package/src/engine/utils/loaders/SpriteLoader.js +77 -0
- package/src/engine/utils/loaders/TilesetLoader.js +103 -0
- package/src/engine/utils/loaders/index.js +21 -0
- package/src/engine/utils/math/matrix4.js +367 -0
- package/src/engine/utils/math/vector.js +458 -0
- package/src/engine/utils/obj/_old_js/index.js +46 -0
- package/src/engine/utils/obj/_old_js/layout.js +308 -0
- package/src/engine/utils/obj/_old_js/material.js +711 -0
- package/src/engine/utils/obj/_old_js/mesh.js +761 -0
- package/src/engine/utils/obj/_old_js/utils.js +647 -0
- package/src/engine/utils/obj/index.js +24 -0
- package/src/engine/utils/obj/js/index.js +277 -0
- package/src/engine/utils/obj/js/loader.js +232 -0
- package/src/engine/utils/obj/layout.js +246 -0
- package/src/engine/utils/obj/material.js +665 -0
- package/src/engine/utils/obj/mesh.js +657 -0
- package/src/engine/utils/obj/ts/index.ts +72 -0
- package/src/engine/utils/obj/ts/layout.ts +265 -0
- package/src/engine/utils/obj/ts/material.ts +760 -0
- package/src/engine/utils/obj/ts/mesh.ts +785 -0
- package/src/engine/utils/obj/ts/utils.ts +501 -0
- package/src/engine/utils/obj/utils.js +428 -0
- package/src/engine/utils/resources.js +18 -0
- package/src/index.jsx +55 -0
- package/src/spritz/player.js +18 -0
- package/src/spritz/readme.md +18 -0
- package/LICENSE +0 -437
- package/dist/bundle.js.LICENSE.txt +0 -31
package/dist/bundle.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
-
!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["calliope-pixos"]=e(require("react"),require("react-dom")):t["calliope-pixos"]=e(t.React,t.ReactDOM)}(this,((t,e)=>(()=>{var r={5019:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t,e,r){console.log({msg:"initializing animation",length:t,untilFrame:e,finish:r}),this.length=t,this.untilFrame=e,this.finish=r},tick:function(t){if(this.loaded){this.facing&&this.facing!=this.sprite.facing&&this.sprite.setFacing(this.facing);var e=this.startTime+this.length,r=(t-this.startTime)/this.length;t>=e&&(r=1,this.finish&&this.finish(!0));var n=Math.floor(r*this.untilFrame);return n!=this.sprite.animFrame&&this.sprite.setFrame(n),t>=e}}}},4146:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var n=r(9010),o=r(4395);function i(t){return i="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},i(t)}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,c){var u=f(t[o],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function s(t,e,r){return s=c()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&u(o,r.prototype),o},s.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function l(t){return function(t){if(Array.isArray(t))return f(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 f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(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 f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function h(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}const d={init:(p=a().mark((function t(e,r,i,c,u){var f,h,d,p,y,g,m,v,b,w,x,_,k,E,A,S,L,O,P,T,C,M,j,I,B,z,D,N,R=this;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==(g=null===(f=this.sprite.zone)||void 0===f||null===(h=f.world)||void 0===h?void 0:h.engine)||!g.renderManager){t.next=5;break}return console.log("fading out..."),t.next=5,g.renderManager.startTransition({effect:"cross",direction:"out",duration:500});case 5:return t.next=7,this.sprite.zone.world.loadZone(e,!1,!1,null);case 7:return this.fromZone=t.sent,t.next=10,this.sprite.zone.world.loadZone(i,!1,!1,null);case 10:this.toZone=t.sent,this.from=s(n.OW,l(r)),this.to=s(n.OW,l(c)),this.facing=o.Nm.fromOffset([Math.round(c.x-r.x),Math.round(c.y-r.y)]),this.length=u;try{m=this.toZone?this.toZone.spriteList.filter((function(t){return t.pos.x===R.to.x&&t.pos.y===R.to.y})):[],this.preserveHeight=m.some((function(t){return!0===t.preserveHeightOnWalk})),this.preserveHeight&&this.from&&(null===this.from.z||void 0===this.from.z)&&(E=this.from.x+(null!==(v=null===(b=this.sprite)||void 0===b||null===(w=b.hotspotOffset)||void 0===w?void 0:w.x)&&void 0!==v?v:0),A=this.from.y+(null!==(x=null===(_=this.sprite)||void 0===_||null===(k=_.hotspotOffset)||void 0===k?void 0:k.y)&&void 0!==x?x:0),this.from.z="function"==typeof this.fromZone.getHeight?this.fromZone.getHeight(E,A):0,this.preserveHeightSourceZ=this.from.z)}catch(t){}this.preserveHeight&&null!==(d=this.sprite)&&void 0!==d&&null!==(p=d.zone)&&void 0!==p&&null!==(y=p.engine)&&void 0!==y&&y.debug&&console.log("[changezone.init] preserveHeight true for transition from",null!==(S=null===(L=(O=this.from).toArray)||void 0===L?void 0:L.call(O))&&void 0!==S?S:this.from,"to",null!==(P=null===(T=(C=this.to).toArray)||void 0===T?void 0:T.call(C))&&void 0!==P?P:this.to);try{M=this.from.x+(this.sprite?this.sprite.hotspotOffset.x:0),j=this.from.y+(this.sprite?this.sprite.hotspotOffset.y:0),I=this.to.x+(this.sprite?this.sprite.hotspotOffset.x:0),B=this.to.y+(this.sprite?this.sprite.hotspotOffset.y:0),!this.from||null!==this.from.z&&void 0!==this.from.z||(this.from.z="function"==typeof this.fromZone.getHeight?this.fromZone.getHeight(M,j):0),!this.to||null!==this.to.z&&void 0!==this.to.z||(this.to.z="function"==typeof this.toZone.getHeight?this.toZone.getHeight(I,B):0)}catch(t){null!==(z=this.sprite)&&void 0!==z&&null!==(D=z.zone)&&void 0!==D&&null!==(N=D.engine)&&void 0!==N&&N.debug&&console.warn("changezone.init failed to compute z for from/to",(null==t?void 0:t.message)||t)}if(console.log({renderManager:null==g?void 0:g.renderManager,fromZoneId:e,toZoneId:i,from:r,to:c,length:u}),null==g||!g.renderManager){t.next=23;break}return console.log("fading in..."),t.next=23,g.renderManager.startTransition({effect:"cross",direction:"in",duration:500});case 23:case"end":return t.stop()}}),t,this)})),y=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=p.apply(t,e);function i(t){h(o,r,n,i,a,"next",t)}function a(t){h(o,r,n,i,a,"throw",t)}i(void 0)}))},function(t,e,r,n,o){return y.apply(this,arguments)}),tick:function(t){if(this.toZone.loaded&&this.fromZone.loaded){this.facing&&this.facing!=this.sprite.facing&&(this.sprite.facing=this.facing,this.sprite.setFrame(0));var e=this.startTime+this.length,r=(t-this.startTime)/this.length;if(t>=e)(0,n.t8)(this.to,this.sprite.pos),r=1;else{this.sprite.pos.x=this.from.x+r*(this.to.x-this.from.x),this.sprite.pos.y=this.from.y+r*(this.to.y-this.from.y);var o=this.sprite.pos.x+this.sprite.hotspotOffset.x,i=this.sprite.pos.y+this.sprite.hotspotOffset.y,a="number"==typeof this.from.z&&"number"==typeof this.to.z?this.from.z+r*(this.to.z-this.from.z):null;if(this.switchRenderZone||this.fromZone.isInZone(o,i)||(this.switchRenderZone=!0),this.preserveHeight){var s,c;this.sprite.pos.z=null!==(s=this.preserveHeightSourceZ)&&void 0!==s?s:this.sprite.pos.z,null!==(c=this.sprite.zone.engine)&&void 0!==c&&c.debug&&!this.__preserveLog&&(this.__preserveLog=!0,console.log("[changezone.tick] preserveHeight applied for sprite",this.sprite.id,"sourceZ=",this.preserveHeightSourceZ))}else{var u,l=(this.switchRenderZone?this.toZone:this.fromZone).getHeight(o,i);this.sprite.pos.z=null!==a?a:l,null!==(u=this.sprite.zone.engine)&&void 0!==u&&u.debug&&this.__tickLogCount<3&&(this.__tickLogCount||(this.__tickLogCount=0),this.__tickLogCount++,console.log("[changezone.tick] sprite",this.sprite.id,"frac=",r.toFixed(2),"hx,hy=",o.toFixed(2),i.toFixed(2),"zLerp=",null==a?void 0:a.toFixed(2),"zZone=",null==l?void 0:l.toFixed(2),"pos.z=",this.sprite.pos.z.toFixed(2)))}}var f=Math.floor(4*r);return f!=this.sprite.animFrame&&this.sprite.setFrame(f),this.sprite.zone.isInZone(this.sprite.pos.x,this.sprite.pos.y)||(this.fromZone.removeSprite(this.sprite.id),this.sprite.zone.world.runAfterTick(function(){this.toZone.addSprite(this.sprite)}.bind(this))),t>=e}}};var p,y},6023:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.engine=this.sprite.engine,this.text="",this.prompt=t,this.scrolling=e,this.line=0,this.options=r,this.completed=!1,this.lastKey=(new Date).getTime()},tick:function(t){return!!this.loaded&&(this.options&&this.options.autoclose&&(this.endTime=this.endTime?this.endTime:null!==(e=this.options.endTime)&&void 0!==e?e:(new Date).getTime()+1e4,t>this.endTime&&(this.completed=!0)),this.checkInput(t),this.textbox=this.engine.hud.scrollText(this.prompt+this.text,this.scrolling,this.options),this.completed);var e},checkInput:function(t){if(t>this.lastKey+100){var e=!1;switch(this.engine.keyboard.lastPressedCode()){case"Escape":this.completed=!0,e=!0;break;case"Backspace":var r=this.text.split("");r.pop(),this.text=r.join(""),this.lastKey=t,e=!0;break;case"Enter":this.sprite.setGreeting(this.text),this.sprite.speech.clearHud&&this.sprite.speech.clearHud(),this.speechbox=this.sprite.speech.scrollText(this.text),this.sprite.speech.loadImage(),this.completed=!0,e=!0}if(!e){var n=this.engine.keyboard.lastPressedKey();n&&(this.lastKey=t,this.text+=""+n)}}}}},3582:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var n=r(4395);function o(t){return o="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},o(t)}function i(){i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,a,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,a)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(i,a,s,c){var u=f(t[i],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==o(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var i;this._invoke=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){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,a,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}const s={init:(c=i().mark((function t(e,r){var n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.zone=r,this.moveLength=e,this.startTime=(new Date).getTime(),this.lastKey=(new Date).getTime(),this.completed=!1,t.next=7,this.zone.engine.resourceManager.audioLoader.loadFromZip(this.sprite.zip,null!==(n=this.sprite.danceSound)&&void 0!==n?n:"/pixospritz/audio/sewer-beat.mp3",!0);case 7:this.audio=t.sent,this.zone.audio&&this.zone.audio.pauseAudio(),this.audio&&this.audio.playAudio();case 10:case"end":return t.stop()}}),t,this)})),u=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=c.apply(t,e);function i(t){a(o,r,n,i,s,"next",t)}function s(t){a(o,r,n,i,s,"throw",t)}i(void 0)}))},function(t,e){return u.apply(this,arguments)}),tick:function(t){if(this.loaded){var e=new Uint8Array(this.audio.analyser.frequencyBinCount);if(this.audio.analyser.getByteFrequencyData(e),this.checkInput(t),t>this.startTime+this.moveLength){for(var r=this.sprite.facing==n.Nm.Right?n.Nm.Left:n.Nm.Right,o=null,i=0;i<16;i++)o=-e[i]/2;r=o>80?this.sprite.facing==n.Nm.Right?n.Nm.Down:n.Nm.Left:this.sprite.facing==n.Nm.Up?n.Nm.Left:n.Nm.Down,this.sprite.addAction(this.sprite.faceDir(r)).then((function(){})),this.startTime=t}return this.completed}},checkInput:function(t){if(t>this.lastKey+this.moveLength)return"q"===this.sprite.engine.keyboard.lastPressed("q")&&(this.audio&&this.audio.pauseAudio(),this.completed=!0),this.lastKey=(new Date).getTime(),null}};var c,u},3419:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.engine=this.sprite.engine,this.text=t,this.displayText="string"==typeof t?t:this.text.shift(),this.scrolling=e,this.options=r,this.completed=!1,this.lastText=!1,this.speechOutput=!0,this.lastKey=(new Date).getTime(),this.loaded=!0},tick:function(t){var e,r;if(this.loaded)return this.options&&this.options.autoclose&&(this.endTime=this.endTime?this.endTime:null!==(e=this.options.endTime)&&void 0!==e?e:(new Date).getTime()+(null!==(r=1e3*this.options.duration)&&void 0!==r?r:1e4),t>this.endTime&&(this.completed=!0)),this.checkInput(t),this.sprite.speak(this.displayText,!1,this),this.completed&&this.options.onClose&&(this.sprite.speech.clearHud&&this.sprite.speech.clearHud(),this.options.onClose()),this.completed},checkInput:function(t){if(t>this.lastKey+100){switch(this.engine.keyboard.lastPressedCode()){case"Escape":this.sprite.speak(!1),this.completed=!0;break;case"Enter":"string"==typeof this.text||0===this.text.length?(this.sprite.speak(!1),this.completed=!0):(this.completed=!1,this.displayText=this.text.shift(),window.speechSynthesis.cancel(),this.speechOutput=!0,this.sprite.speak(this.displayText,!1,this))}if(this.engine.gamepad.keyPressed("a"))return void("string"==typeof this.text||0===this.text.length?(this.sprite.speak(!1),this.completed=!0):(this.completed=!1,this.displayText=this.text.shift(),window.speechSynthesis.cancel(),this.speechOutput=!0,this.sprite.speak(this.displayText,!1,this)))}}}},8463:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t){this.facing=t},tick:function(t){return this.facing&&this.facing!=this.sprite.facing&&this.sprite.setFacing(this.facing),!0}}},3972:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.engine=this.sprite.engine,this.greeting=t,this.options=e,this.completed=!1},tick:function(t){if(this.loaded)return this.sprite.setGreeting(this.text),!0}}},1726:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>p});var n=r(9010),o=r(4395);function i(t){return i="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},i(t)}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,c){var u=f(t[o],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function s(t,e,r){return s=c()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&u(o,r.prototype),o},s.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function l(t){return function(t){if(Array.isArray(t))return f(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 f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(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 f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function h(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){h(i,n,o,a,s,"next",t)}function s(t){h(i,n,o,a,s,"throw",t)}a(void 0)}))}}const p={init:(g=d(a().mark((function t(e,r,i){var c=this;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.world=i,this.from=s(n.OW,l(e)),this.facing=r,this.offset=o.Nm.toOffset(r),this.lastKey=(new Date).getTime(),this.completed=!1,this.to=[e[0]+this.offset[0],e[1]+this.offset[1]],this.zone=i.zoneContaining.apply(i,l(this.to)),this.spriteList=this.zone.spriteList.filter((function(t){return t.pos.x===c.to[0]&&t.pos.y===c.to[1]})),this.objectList=this.zone.objectList.filter((function(t){return t.pos.x===c.to[0]&&t.pos.y===c.to[1]})),this.finish=this.finish.bind(this),this.interact();case 12:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return g.apply(this,arguments)}),interact:(y=d(a().mark((function t(){var e=this;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return 0===this.spriteList.length&&0===this.objectList.length&&(this.completed=!0),t.next=3,Promise.all(this.objectList.map(function(){var t=d(a().mark((function t(r){var n;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=r.faceDir(o.Nm.reverse(e.facing)))&&r.addAction(n),!r.interact){t.next=8;break}return t.next=5,e.zone.objectDict[r.id].interact(e.sprite,e.finish);case 5:t.t0=t.sent,t.next=9;break;case 8:t.t0=null;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:return t.next=5,Promise.all(this.spriteList.map(function(){var t=d(a().mark((function t(r){var n;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=r.faceDir(o.Nm.reverse(e.facing)))&&r.addAction(n),!r.interact){t.next=8;break}return t.next=5,e.zone.spriteDict[r.id].interact(e.sprite,e.finish);case 5:t.t0=t.sent,t.next=9;break;case 8:t.t0=null;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 5:case"end":return t.stop()}}),t,this)}))),function(){return y.apply(this,arguments)}),finish:function(t){t&&(this.completed=!0)},tick:function(t){if(this.loaded)return this.checkInput(t),this.completed},checkInput:function(t){if(t>this.lastKey+Math.max(this.length,200)){if("q"!==this.sprite.engine.keyboard.lastPressed("q"))return this.lastKey=(new Date).getTime(),null;this.completed=!0}this.sprite.engine.gamepad.keyPressed("a")&&(this.completed=!0)}};var y,g},6481:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>p});var n=r(9010),o=r(4395);function i(t){return i="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},i(t)}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,c){var u=f(t[o],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function s(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){s(i,n,o,a,c,"next",t)}function c(t){s(i,n,o,a,c,"throw",t)}a(void 0)}))}}function u(t,e,r){return u=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&f(o,r.prototype),o},u.apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function f(t,e){return f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},f(t,e)}function h(t){return function(t){if(Array.isArray(t))return d(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 d(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(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 d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}const p={init:function(t,e,r,i){var a=this;this.zone=i,this.from=u(n.OW,h(t)),this.to=u(n.OW,h(e)),this.facing=o.Nm.fromOffset([Math.round(e.x-t.x),Math.round(e.y-t.y)]),this.length=r,this.spriteList=this.zone.spriteList.filter((function(t){return t.pos.x===a.to.x&&t.pos.y===a.to.y}))},tick:function(t){if(this.loaded){this.facing&&this.facing!=this.sprite.facing&&this.sprite.setFacing(this.facing);var e=this.startTime+this.length,r=(t-this.startTime)/this.length;if(t>=e){this.sprite.pos.x=this.to.x,this.sprite.pos.y=this.to.y;var n=this.sprite.pos.x+this.sprite.hotspotOffset.x,o=this.sprite.pos.y+this.sprite.hotspotOffset.y;this.sprite.pos.z=this.sprite.zone.getHeight(n,o),r=1,this.onStep();var i=Math.floor(4*r);return i!=this.sprite.animFrame&&this.sprite.setFrame(i),t>=e}this.sprite.pos.x=this.from.x+r*(this.to.x-this.from.x),this.sprite.pos.y=this.from.y+r*(this.to.y-this.from.y);var a=this.sprite.pos.x+this.sprite.hotspotOffset.x,s=this.sprite.pos.y+this.sprite.hotspotOffset.y;this.sprite.pos.z=this.sprite.zone.getHeight(a,s);var c=Math.floor(4*r);return c!=this.sprite.animFrame&&this.sprite.setFrame(c),!1}},onStep:(y=c(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return 0===this.spriteList.length&&(this.completed=!0),t.next=3,Promise.all(this.spriteList.map(function(){var t=c(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.onStep){t.next=6;break}return t.next=3,e.onStep(e,e);case 3:t.t0=t.sent,t.next=7;break;case 6:t.t0=null;case 7:return t.abrupt("return",t.t0);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:case"end":return t.stop()}}),t,this)}))),function(){return y.apply(this,arguments)})};var y},955:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>y});var n=r(9010),o=r(4395),i=r(679);function a(t){return a="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},a(t)}function s(){s=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,s,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==a(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function c(t,e,r){return c=u()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&l(o,r.prototype),o},c.apply(null,arguments)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function l(t,e){return l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},l(t,e)}function f(t){return function(t){if(Array.isArray(t))return d(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(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 h(t,e){if(t){if("string"==typeof t)return d(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function p(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}const y={init:(g=s().mark((function t(e,r,o,i){var a,u,l;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.zone=i,this.from=c(n.OW,f(e)),this.to=c(n.OW,f(r)),this.lastKey=(new Date).getTime(),this.completed=!1,this.direction=1,t.next=8,this.zone.engine.resourceManager.audioLoader.loadFromZip(this.sprite.zip,null!==(a=this.sprite.patrolSound)&&void 0!==a?a:"sewer-beat.mp3",!0);case 8:this.audio=t.sent,u=this.sprite.zone.world.pathFind(e,r),d=2,l=function(t){if(Array.isArray(t))return t}(s=u)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(s,d)||h(s,d)||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.")}(),this.hasMoves=l[0],this.moveList=l[1],this.hasMoves||(this.completed=!0),this.moveIndex=1,this.moveLength=o,this.zone.audio&&this.zone.audio.pauseAudio(),this.audio&&this.audio.playAudio();case 18:case"end":return t.stop()}var s,d}),t,this)})),m=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=g.apply(t,e);function i(t){p(o,r,n,i,a,"next",t)}function a(t){p(o,r,n,i,a,"throw",t)}i(void 0)}))},function(t,e,r,n){return m.apply(this,arguments)}),tick:function(t){if(this.loaded){if(this.checkInput(t),t>this.startTime+this.moveLength){var e=this.moveList[this.moveIndex];if(this.moveList.length>2){var r=0==this.moveIndex?this.moveList[this.moveIndex+1]:this.moveIndex+1>=this.moveList.length?this.moveList[this.moveList.length-1]:this.moveList[this.moveIndex-1],n=o.Nm.fromOffset([Math.round(e[0]-r[0]),Math.round(e[1]-r[1])]);if(this.sprite.zone.isInZone(e[0],e[1]))this.currentAction=new i.aW(this.sprite.engine,"move",[r,e,this.moveLength,this.zone],this.sprite);else{var a=this.sprite.zone.world.zoneContaining(e[0],e[1]);a&&a.loaded&&a.isWalkable(e[0],e[1],o.Nm.reverse(n))?this.currentAction=new i.aW(this.sprite.engine,"changezone",[this.sprite.zone.id,this.sprite.pos.toArray(),a.id,e,this.moveLength],this.sprite):this.currentAction=this.sprite.faceDir(n)}this.sprite.facing!==n&&(this.currentAction=this.sprite.faceDir(n)),this.currentAction&&(this.currentAction.facing=n,this.sprite.addAction(Promise.resolve(this.currentAction)).then((function(){})))}this.moveIndex+this.direction>=this.moveList.length&&(this.direction*=-1,this.completed=!0,this.zone.audio&&this.zone.audio.playAudio(),this.audio&&this.audio.pauseAudio()),this.moveIndex+=this.direction,this.startTime=t}return this.completed}},checkInput:function(t){if(t>this.lastKey+Math.max(this.moveLength,200))return"q"===this.sprite.engine.keyboard.lastPressed("q")&&(this.zone.audio&&this.zone.audio.playAudio(),this.audio&&this.audio.pauseAudio(),this.completed=!0),this.lastKey=(new Date).getTime(),null}};var g,m},5214:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.engine=this.sprite.engine,this.text="",this.scrolling=r,this.line=0,this.options=n,this.completed=!1,this.lastKey=(new Date).getTime(),this.listenerId=this.engine.gamepad.attachListener(this.hookListener()),this.touches=[],this.menuDict=null!=t?t:{},this.activeMenus=null!=e?e:[],this.selectedMenu={},this.selectedMenuId=null,this.isTouched=!1},tick:function(t){var e,r=this;if(this.loaded)return this.options&&this.options.autoclose&&(this.endTime=this.endTime?this.endTime:null!==(e=this.options.endTime)&&void 0!==e?e:(new Date).getTime()+1e4,t>this.endTime&&(this.completed=!0)),this.checkInput(t),Object.keys(this.menuDict).filter((function(t){return r.activeMenus.includes(t)})).map((function(t){var e=r.menuDict[t],n=e.colours;e.active&&(n.background="#555"),r.engine.hud.drawButton(e.text,e.x,e.y,e.w,e.h,e.colours)})),this.textbox=this.engine.hud.scrollText(this.prompt+this.text,this.scrolling,this.options),this.completed&&this.unhookListener(),this.completed},unhookListener:function(){this.engine.gamepad.removeListener(this.listenerId),this.listenerId=null},hookListener:function(){var t=this,e=function(e){var r=e.touches;if(t.isTouched=!0,t.touches=r,t.isTouched&&t.touches.length>0&&t.lastKey+100<(new Date).getTime()){var n=t.touches[0].x,o=t.touches[0].y,i=t;i.activeMenus.filter((function(t){var e=i.menuDict[t];return n<e.x+e.w&&n>e.x&&o<e.y+e.h&&o>e.y})).map((function(e){var r=i.menuDict[e];r.trigger&&r.trigger(t),r.children&&(i.activeMenus=r.children)}))}},r=function(e){t.touches=e},n=function(e){t.isTouched=!1,t.touches=e};return{touchstart:e,touchmove:r,touchend:n,mousedown:e,mousemove:r,mouseup:n}},checkInput:function(t){if(t>this.lastKey+200){var e=!1;switch(this.engine.keyboard.lastPressedCode()){case"Escape":this.completed=!0,e=!0;break;case"Backspace":var r=this.text.split("");r.pop(),this.text=r.join(""),this.lastKey=t,e=!0;break;case"Enter":this.sprite.setGreeting(this.text),this.sprite.speech.clearHud&&this.sprite.speech.clearHud(),this.speechbox=this.sprite.speech.scrollText(this.text),this.sprite.speech.loadImage(),this.completed=!0,e=!0}if(!e){var n=this.engine.keyboard.lastPressedKey();n&&(this.lastKey=t,this.text+=""+n)}}}}},6027:(t,e,r)=>{"use strict";function n(t){return n="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},n(t)}function o(){o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,a,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,a)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(i,a,s,c){var u=f(t[i],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){o("next",t,s,c)}),(function(t){o("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return o("throw",t,s,c)}))}c(u.arg)}var i;this._invoke=function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,a,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function i(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}r.r(e),r.d(e,{default:()=>a});const a={init:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.zone=e,this.world=e.world,this.lastKey=(new Date).getTime(),this.completed=!1,this.onCompleted=function(){return console.log("script finished")},r&&(this.onCompleted=r),this.triggerId=t,this.triggerScript()},triggerScript:function(){var t=this;this.triggerId||(this.completed=!0),Promise.all(this.zone.scripts.filter((function(e){return e.id===t.triggerId})).map(function(){var e,r=(e=o().mark((function e(r){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.trigger.call(t.zone);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function s(t){i(a,n,o,s,c,"next",t)}function c(t){i(a,n,o,s,c,"throw",t)}s(void 0)}))});return function(t){return r.apply(this,arguments)}}())).then((function(){t.completed=!0}))},tick:function(t){if(this.loaded)return this.completed&&this.onCompleted(),this.completed}}},5490:(t,e,r)=>{"use strict";function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,{Ky:()=>s,ZP:()=>c,_C:()=>u}),r(9124);var s=new FontFace("minecraftia","url(/pixospritz/font/minecraftia.ttf)"),c=o((function t(e){var r=this;return i(this,t),a(this,"init",(function(){r.ctx=r.engine.ctx})),a(this,"drawButton",(function(t,e,n,o,i,a){var s=r.ctx;r.applyStyle({font:"20px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:a.background,globalAlpha:1}),s.fillStyle=a.background,s.beginPath(),s.rect(e,n,o,i),s.fill();var c=s.createLinearGradient(e,n,e,n+i/2);c.addColorStop(0,"rgba(255, 255, 255, 0.8)"),c.addColorStop(1,"rgba(0, 0, 0, 0.3)"),s.fillStyle=c,s.globalAlpha=.7,s.fillRect(e,n,o,i/2),s.fillStyle=a.text,s.fillText(t,e+o/2,n+i/2),s.beginPath(),s.strokeStyle="#fff",s.rect(e,n,o,i),s.stroke()})),a(this,"clearHud",(function(){r.ctx.clearRect(0,0,r.engine.ctx.canvas.width,r.engine.ctx.canvas.height)})),a(this,"setBackdrop",(function(t){r.backdropImage=t})),a(this,"setCutouts",(function(t){r.cutoutImages=t})),a(this,"applyStyle",(function(t){Object.assign(r.ctx,{font:"20px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:"#ffffff",globalAlpha:1},t)})),a(this,"writeText",(function(t,e,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;r.applyStyle({font:"24px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:"#ffffff"}),o?(r.ctx.drawImage(o,null!=e?e:r.ctx.canvas.clientWidth/2,null!=n?n:r.ctx.canvas.clientHeight/2,76,76),r.ctx.fillText(t,null!=e?e:r.ctx.canvas.clientWidth/2+80,null!=n?n:r.ctx.canvas.clientHeight/2)):r.ctx.fillText(t,null!=e?e:r.ctx.canvas.clientWidth/2,null!=n?n:r.ctx.canvas.clientHeight/2)})),a(this,"drawModeLabel",(function(){try{var t,e,n,o,i=null===(t=r.engine)||void 0===t||null===(e=t.spritz)||void 0===e||null===(n=e.world)||void 0===n||null===(o=n.modeManager)||void 0===o?void 0:o.getMode();if(!i)return;r.applyStyle({font:"18px invasion2000",textAlign:"left",textBaseline:"top",fillStyle:"#ff0"}),r.ctx.fillText("MODE: ".concat(i),12,12)}catch(t){}})),a(this,"drawHeightDebugOverlay",(function(){var t;if(null!==(t=r.engine)&&void 0!==t&&t.debugHeightOverlay)try{var e,n,o,i,a=null===(e=r.engine)||void 0===e||null===(n=e.spritz)||void 0===n?void 0:n.world;if(!a)return;var s=r.ctx,c=null===(o=r.engine)||void 0===o||null===(i=o.renderManager)||void 0===i?void 0:i.camera;if(!c)return;var u=function(t,e,n){var o=r.engine.gl,i=r.engine.renderManager,a=i.uModelMat,s=c.uViewMat,u=i.uProjMat,l=[t,e,n,1],f=a[0]*l[0]+a[4]*l[1]+a[8]*l[2]+a[12],h=a[1]*l[0]+a[5]*l[1]+a[9]*l[2]+a[13],d=a[2]*l[0]+a[6]*l[1]+a[10]*l[2]+a[14],p=a[3]*l[0]+a[7]*l[1]+a[11]*l[2]+a[15],y=s[0]*f+s[4]*h+s[8]*d+s[12]*p,g=s[1]*f+s[5]*h+s[9]*d+s[13]*p,m=s[2]*f+s[6]*h+s[10]*d+s[14]*p,v=s[3]*f+s[7]*h+s[11]*d+s[15]*p,b=u[0]*y+u[4]*g+u[8]*m+u[12]*v,w=u[1]*y+u[5]*g+u[9]*m+u[13]*v,x=u[3]*y+u[7]*g+u[11]*m+u[15]*v;if(Math.abs(x)<1e-4)return null;var _=w/x;return{x:(b/x*.5+.5)*o.canvas.width,y:(1-(.5*_+.5))*o.canvas.height,behind:x<0}};r.applyStyle({font:"12px monospace",textAlign:"center",textBaseline:"middle",fillStyle:"#0f0"}),a.zoneList.forEach((function(t){var e;if(t.loaded&&null!==(e=t.zoneData)&&void 0!==e&&e.cells)for(var r=t.zoneData.cells,n=0;n<r.length;n++)for(var o=0;o<r[n].length;o++)try{var i=t.getHeight(o+.5,n+.5),a=u(o+.5,n+.5,i);a&&!a.behind&&(s.fillStyle="#0ff",s.fillText("".concat(i.toFixed(2)),a.x,a.y))}catch(t){}})),r.applyStyle({font:"14px monospace",textAlign:"center",textBaseline:"bottom",fillStyle:"#ff0"}),a.spriteList.forEach((function(t){if(t.pos)try{var e=u(t.pos.x,t.pos.y,t.pos.z+.5);e&&!e.behind&&(s.fillStyle="#ff0",s.fillText("".concat(t.id,": z=").concat(t.pos.z.toFixed(2)),e.x,e.y))}catch(t){}})),r.applyStyle({font:"14px monospace",textAlign:"center",textBaseline:"bottom",fillStyle:"#f0f"}),a.objectList.forEach((function(t){if(t.pos)try{var e=u(t.pos.x,t.pos.y,t.pos.z+.5);e&&!e.behind&&(s.fillStyle="#f0f",s.fillText("".concat(t.id,": z=").concat(t.pos.z.toFixed(2)),e.x,e.y))}catch(t){}}))}catch(t){console.warn("drawHeightDebugOverlay error:",t)}})),a(this,"drawCutsceneElements",(function(){var t=r.ctx,e=t.canvas.width,n=t.canvas.height;r.backdropImage&&t.drawImage(r.backdropImage,0,0,e,n),r.cutoutImages.forEach((function(r){var o=r.image,i=r.position;if(o){var a="left"===i?50:e-250,s=n/2-100;"right"===i?(t.save(),t.scale(-1,1),t.drawImage(o,-a-200,s,200,200),t.restore()):t.drawImage(o,a,s,200,200)}}))})),a(this,"scrollText",(function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.drawCutsceneElements();var o=new u(r.engine.ctx);return o.init(t,10,2*r.engine.ctx.canvas.height/3,r.engine.ctx.canvas.width-20,r.engine.ctx.canvas.height/3-20,n),o.setOptions(n),e&&o.scroll((Math.sin((new Date).getTime()/3e3)+1)*o.maxScroll*.5),o.render(),o})),t._instance||(this.engine=e,this.backdropImage=null,this.cutoutImages=[],t._instance=this),t._instance})),u=o((function t(e){var r=this;i(this,t),a(this,"init",(function(t,e,n,o,i){var a,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};r.text=t,r.x=e,r.y=n,r.width=o,r.height=i,r.portrait=null!==(a=s.portrait)&&void 0!==a?a:null,r.setOptions(s),r.cleanit()})),a(this,"cleanit",(function(t){r.dirty&&(r.setFont(),r.getTextPos(),r.dirty=!1,t||r.fitText())})),a(this,"setOptions",(function(t){Object.keys(r).forEach((function(e){void 0!==t[e]&&(r[e]=t[e],r.dirty=!0)}))})),a(this,"setFont",(function(){r.fontStr=r.fontSize+"px "+r.font,r.textHeight=r.fontSize+Math.ceil(.05*r.fontSize)})),a(this,"getTextPos",(function(){"left"===r.align?r.textPos=2:"right"===r.align?r.textPos=Math.floor(r.width-r.scrollBox.width-r.fontSize/4):r.textPos=Math.floor((r.width- -r.scrollBox.width)/2)})),a(this,"fitText",(function(){var t=r.ctx;r.cleanit(!0),t.font=r.fontStr,t.textAlign=r.align,t.textBaseline="top";var e=r.text.split(" ");r.lines.length=0;for(var n="",o="";e.length>0;){var i=e.shift();t.measureText(n+o+i).width<r.width-r.scrollBox.width-r.scrollBox.width-(r.portrait?84:0)?(n+=o+i,o=" "):(""===o?n+=i:e.unshift(i),r.lines.push(n),o="",n="")}""!==n&&r.lines.push(n),r.maxScroll=(r.lines.length+.5)*r.textHeight-r.height})),a(this,"drawBorder",(function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=r.ctx,n=r.border.lineWidth/2;e.lineJoin=r.border.corner,e.lineWidth=r.border.lineWidth,e.strokeStyle=r.border.style,t?e.strokeRect(r.x-n+84,r.y-n,r.width+2*n-84,r.height+2*n):e.strokeRect(r.x-n,r.y-n,r.width+2*n,r.height+2*n)})),a(this,"drawScrollBox",(function(){var t=r.ctx,e=r.height/(r.lines.length*r.textHeight);t.fillStyle=r.scrollBox.background,t.fillRect(r.x+r.width-r.scrollBox.width,r.y,r.scrollBox.width,r.height),t.fillStyle=r.scrollBox.color;var n=r.height*e;n>r.height&&(n=r.height),t.fillRect(r.x+r.width-r.scrollBox.width,r.y-r.scrollY*e,r.scrollBox.width,n)})),a(this,"drawPortrait",(function(){r.ctx.drawImage(r.portrait.image,r.x,r.y+38,76,76)})),a(this,"scroll",(function(t){r.cleanit(),r.scrollY=-t,r.scrollY>0?r.scrollY=0:r.scrollY<-r.maxScroll&&(r.scrollY=-r.maxScroll)})),a(this,"scrollLines",(function(t){r.cleanit(),r.scrollY=-r.textHeight*t,r.scrollY>0?r.scrollY=0:r.scrollY<-r.maxScroll&&(r.scrollY=-r.maxScroll)})),a(this,"render",(function(){var t=r.ctx;r.cleanit(),t.font=r.fontStr,t.textAlign=r.align,r.portrait?(r.drawBorder(!0),r.drawPortrait(),t.save(),t.fillStyle=r.background,t.fillRect(r.x+84,r.y,r.width-84,r.height)):(r.drawBorder(),t.save(),t.fillStyle=r.background,t.fillRect(r.x,r.y,r.width,r.height)),r.drawScrollBox(),r.portrait?(t.beginPath(),t.rect(r.x+84,r.y,r.width-r.scrollBox.width-84,r.height),t.clip(),t.setTransform(1,0,0,1,r.x+84,Math.floor(r.y+r.scrollY))):(t.beginPath(),t.rect(r.x,r.y,r.width-r.scrollBox.width,r.height),t.clip(),t.setTransform(1,0,0,1,r.x,Math.floor(r.y+r.scrollY))),t.fillStyle=r.fontStyle;for(var e=0;e<r.lines.length;e++)t.fillText(r.lines[e],r.textPos,Math.floor(e*r.textHeight)+2);t.restore()})),this.ctx=e,this.dirty=!0,this.scrollY=0,this.fontSize=24,this.font="minecraftia",this.align="left",this.background="#333",this.border={lineWidth:2,style:"#fff",corner:"round"},this.scrollBox={width:5,background:"#777",color:"#999"},this.fontStyle="#fff",this.lines=[],this.x=0,this.y=0}))},9124:(t,e,r)=>{"use strict";r.d(e,{Z:()=>Fo});var n=r(9010);const o={Vector:n.OW,Vector4:n.Lt,clamp:function(t,e,r){return Math.max(e,Math.min(t,r))}},i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,a=Object.keys,s=Array.isArray;function c(t,e){return"object"!=typeof e||a(e).forEach((function(r){t[r]=e[r]})),t}"undefined"==typeof Promise||i.Promise||(i.Promise=Promise);const u=Object.getPrototypeOf,l={}.hasOwnProperty;function f(t,e){return l.call(t,e)}function h(t,e){"function"==typeof e&&(e=e(u(t))),("undefined"==typeof Reflect?a:Reflect.ownKeys)(e).forEach((r=>{p(t,r,e[r])}))}const d=Object.defineProperty;function p(t,e,r,n){d(t,e,c(r&&f(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function y(t){return{from:function(e){return t.prototype=Object.create(e.prototype),p(t.prototype,"constructor",t),{extend:h.bind(null,t.prototype)}}}}const g=Object.getOwnPropertyDescriptor;function m(t,e){let r;return g(t,e)||(r=u(t))&&m(r,e)}const v=[].slice;function b(t,e,r){return v.call(t,e,r)}function w(t,e){return e(t)}function x(t){if(!t)throw new Error("Assertion Failed")}function _(t){i.setImmediate?setImmediate(t):setTimeout(t,0)}function k(t,e){return t.reduce(((t,r,n)=>{var o=e(r,n);return o&&(t[o[0]]=o[1]),t}),{})}function E(t,e){if(f(t,e))return t[e];if(!e)return t;if("string"!=typeof e){for(var r=[],n=0,o=e.length;n<o;++n){var i=E(t,e[n]);r.push(i)}return r}var a=e.indexOf(".");if(-1!==a){var s=t[e.substr(0,a)];return void 0===s?void 0:E(s,e.substr(a+1))}}function A(t,e,r){if(t&&void 0!==e&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if("string"!=typeof e&&"length"in e){x("string"!=typeof r&&"length"in r);for(var n=0,o=e.length;n<o;++n)A(t,e[n],r[n])}else{var i=e.indexOf(".");if(-1!==i){var a=e.substr(0,i),c=e.substr(i+1);if(""===c)void 0===r?s(t)&&!isNaN(parseInt(a))?t.splice(a,1):delete t[a]:t[a]=r;else{var u=t[a];u||(u=t[a]={}),A(u,c,r)}}else void 0===r?s(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=r}}function S(t){var e={};for(var r in t)f(t,r)&&(e[r]=t[r]);return e}const L=[].concat;function O(t){return L.apply([],t)}const P="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(O([8,16,32,64].map((t=>["Int","Uint","Float"].map((e=>e+t+"Array")))))).filter((t=>i[t])),T=P.map((t=>i[t]));k(P,(t=>[t,!0]));let C=null;function M(t){C="undefined"!=typeof WeakMap&&new WeakMap;const e=j(t);return C=null,e}function j(t){if(!t||"object"!=typeof t)return t;let e=C&&C.get(t);if(e)return e;if(s(t)){e=[],C&&C.set(t,e);for(var r=0,n=t.length;r<n;++r)e.push(j(t[r]))}else if(T.indexOf(t.constructor)>=0)e=t;else{const r=u(t);for(var o in e=r===Object.prototype?{}:Object.create(r),C&&C.set(t,e),t)f(t,o)&&(e[o]=j(t[o]))}return e}const{toString:I}={};function B(t){return I.call(t).slice(8,-1)}const z="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof z?function(t){var e;return null!=t&&(e=t[z])&&e.apply(t)}:function(){return null},N={};function R(t){var e,r,n,o;if(1===arguments.length){if(s(t))return t.slice();if(this===N&&"string"==typeof t)return[t];if(o=D(t)){for(r=[];!(n=o.next()).done;)r.push(n.value);return r}if(null==t)return[t];if("number"==typeof(e=t.length)){for(r=new Array(e);e--;)r[e]=t[e];return r}return[t]}for(e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return r}const F="undefined"!=typeof Symbol?t=>"AsyncFunction"===t[Symbol.toStringTag]:()=>!1;var U="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function G(t,e){U=t,W=e}var W=()=>!0;const V=!new Error("").stack;function Z(){if(V)try{throw Z.arguments,new Error}catch(t){return t}return new Error}function $(t,e){var r=t.stack;return r?(e=e||0,0===r.indexOf(t.name)&&(e+=(t.name+t.message).split("\n").length),r.split("\n").slice(e).filter(W).map((t=>"\n"+t)).join("")):""}var Y=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],K=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Y),H={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function q(t,e){this._e=Z(),this.name=t,this.message=e}function X(t,e){return t+". Errors: "+Object.keys(e).map((t=>e[t].toString())).filter(((t,e,r)=>r.indexOf(t)===e)).join("\n")}function J(t,e,r,n){this._e=Z(),this.failures=e,this.failedKeys=n,this.successCount=r,this.message=X(t,e)}function Q(t,e){this._e=Z(),this.name="BulkError",this.failures=Object.keys(e).map((t=>e[t])),this.failuresByPos=e,this.message=X(t,e)}y(q).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+$(this._e,2))}},toString:function(){return this.name+": "+this.message}}),y(J).from(q),y(Q).from(q);var tt=K.reduce(((t,e)=>(t[e]=e+"Error",t)),{});const et=q;var rt=K.reduce(((t,e)=>{var r=e+"Error";function n(t,n){this._e=Z(),this.name=r,t?"string"==typeof t?(this.message=`${t}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof t&&(this.message=`${t.name} ${t.message}`,this.inner=t):(this.message=H[e]||r,this.inner=null)}return y(n).from(et),t[e]=n,t}),{});rt.Syntax=SyntaxError,rt.Type=TypeError,rt.Range=RangeError;var nt=Y.reduce(((t,e)=>(t[e+"Error"]=rt[e],t)),{}),ot=K.reduce(((t,e)=>(-1===["Syntax","Type","Range"].indexOf(e)&&(t[e+"Error"]=rt[e]),t)),{});function it(){}function at(t){return t}function st(t,e){return null==t||t===at?e:function(r){return e(t(r))}}function ct(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function ut(t,e){return t===it?e:function(){var r=t.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?ct(n,this.onsuccess):n),o&&(this.onerror=this.onerror?ct(o,this.onerror):o),void 0!==i?i:r}}function lt(t,e){return t===it?e:function(){t.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?ct(r,this.onsuccess):r),n&&(this.onerror=this.onerror?ct(n,this.onerror):n)}}function ft(t,e){return t===it?e:function(r){var n=t.apply(this,arguments);c(r,n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?ct(o,this.onsuccess):o),i&&(this.onerror=this.onerror?ct(i,this.onerror):i),void 0===n?void 0===a?void 0:a:c(n,a)}}function ht(t,e){return t===it?e:function(){return!1!==e.apply(this,arguments)&&t.apply(this,arguments)}}function dt(t,e){return t===it?e:function(){var r=t.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,o=arguments.length,i=new Array(o);o--;)i[o]=arguments[o];return r.then((function(){return e.apply(n,i)}))}return e.apply(this,arguments)}}ot.ModifyError=J,ot.DexieError=q,ot.BulkError=Q;var pt={};const[yt,gt,mt]="undefined"==typeof Promise?[]:(()=>{let t=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[t,u(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,u(e),t]})(),vt=gt&>.then,bt=yt&&yt.constructor,wt=!!mt;var xt=!1,_t=mt?()=>{mt.then(Zt)}:i.setImmediate?setImmediate.bind(null,Zt):i.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver((()=>{Zt(),t=null})).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Zt,0)},kt=function(t,e){Mt.push([t,e]),At&&(_t(),At=!1)},Et=!0,At=!0,St=[],Lt=[],Ot=null,Pt=at,Tt={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ge,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((t=>{try{ge(t[0],t[1])}catch(t){}}))}},Ct=Tt,Mt=[],jt=0,It=[];function Bt(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=it,this._lib=!1;var e=this._PSD=Ct;if(U&&(this._stackHolder=Z(),this._prev=null,this._numPrev=0),"function"!=typeof t){if(t!==pt)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Rt(this,this._value))}this._state=null,this._value=null,++e.ref,Nt(this,t)}const zt={get:function(){var t=Ct,e=ee;function r(r,n){var o=!t.global&&(t!==Ct||e!==ee);const i=o&&!ie();var a=new Bt(((e,a)=>{Ut(this,new Dt(de(r,t,o,i),de(n,t,o,i),e,a,t))}));return U&&Vt(a,this),a}return r.prototype=pt,r},set:function(t){p(this,"then",t&&t.prototype===pt?zt:{get:function(){return t},set:zt.set})}};function Dt(t,e,r,n,o){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.resolve=r,this.reject=n,this.psd=o}function Nt(t,e){try{e((e=>{if(null===t._state){if(e===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&$t();e&&"function"==typeof e.then?Nt(t,((t,r)=>{e instanceof Bt?e._then(t,r):e.then(t,r)})):(t._state=!0,t._value=e,Ft(t)),r&&Yt()}}),Rt.bind(null,t))}catch(e){Rt(t,e)}}function Rt(t,e){if(Lt.push(e),null===t._state){var r=t._lib&&$t();e=Pt(e),t._state=!1,t._value=e,U&&null!==e&&"object"==typeof e&&!e._promise&&function(r,n,o){try{(()=>{var r=m(e,"stack");e._promise=t,p(e,"stack",{get:()=>xt?r&&(r.get?r.get.apply(e):r.value):t.stack})}).apply(null,void 0)}catch(t){}}(),function(t){St.some((e=>e._value===t._value))||St.push(t)}(t),Ft(t),r&&Yt()}}function Ft(t){var e=t._listeners;t._listeners=[];for(var r=0,n=e.length;r<n;++r)Ut(t,e[r]);var o=t._PSD;--o.ref||o.finalize(),0===jt&&(++jt,kt((()=>{0==--jt&&Kt()}),[]))}function Ut(t,e){if(null!==t._state){var r=t._state?e.onFulfilled:e.onRejected;if(null===r)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++jt,kt(Gt,[r,t,e])}else t._listeners.push(e)}function Gt(t,e,r){try{Ot=e;var n,o=e._value;e._state?n=t(o):(Lt.length&&(Lt=[]),n=t(o),-1===Lt.indexOf(o)&&function(t){for(var e=St.length;e;)if(St[--e]._value===t._value)return void St.splice(e,1)}(e)),r.resolve(n)}catch(t){r.reject(t)}finally{Ot=null,0==--jt&&Kt(),--r.psd.ref||r.psd.finalize()}}function Wt(t,e,r){if(e.length===r)return e;var n="";if(!1===t._state){var o,i,a=t._value;null!=a?(o=a.name||"Error",i=a.message||a,n=$(a,0)):(o=a,i=""),e.push(o+(i?": "+i:"")+n)}return U&&((n=$(t._stackHolder,2))&&-1===e.indexOf(n)&&e.push(n),t._prev&&Wt(t._prev,e,r)),e}function Vt(t,e){var r=e?e._numPrev+1:0;r<100&&(t._prev=e,t._numPrev=r)}function Zt(){$t()&&Yt()}function $t(){var t=Et;return Et=!1,At=!1,t}function Yt(){var t,e,r;do{for(;Mt.length>0;)for(t=Mt,Mt=[],r=t.length,e=0;e<r;++e){var n=t[e];n[0].apply(null,n[1])}}while(Mt.length>0);Et=!0,At=!0}function Kt(){var t=St;St=[],t.forEach((t=>{t._PSD.onunhandled.call(null,t._value,t)}));for(var e=It.slice(0),r=e.length;r;)e[--r]()}function Ht(t){return new Bt(pt,!1,t)}function qt(t,e){var r=Ct;return function(){var n=$t(),o=Ct;try{return ue(r,!0),t.apply(this,arguments)}catch(t){e&&e(t)}finally{ue(o,!1),n&&Yt()}}}h(Bt.prototype,{then:zt,_then:function(t,e){Ut(this,new Dt(null,null,t,e,Ct))},catch:function(t){if(1===arguments.length)return this.then(null,t);var e=arguments[0],r=arguments[1];return"function"==typeof e?this.then(null,(t=>t instanceof e?r(t):Ht(t))):this.then(null,(t=>t&&t.name===e?r(t):Ht(t)))},finally:function(t){return this.then((e=>(t(),e)),(e=>(t(),Ht(e))))},stack:{get:function(){if(this._stack)return this._stack;try{xt=!0;var t=Wt(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{xt=!1}}},timeout:function(t,e){return t<1/0?new Bt(((r,n)=>{var o=setTimeout((()=>n(new rt.Timeout(e))),t);this.then(r,n).finally(clearTimeout.bind(null,o))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&p(Bt.prototype,Symbol.toStringTag,"Dexie.Promise"),Tt.env=le(),h(Bt,{all:function(){var t=R.apply(null,arguments).map(ae);return new Bt((function(e,r){0===t.length&&e([]);var n=t.length;t.forEach(((o,i)=>Bt.resolve(o).then((r=>{t[i]=r,--n||e(t)}),r)))}))},resolve:t=>{if(t instanceof Bt)return t;if(t&&"function"==typeof t.then)return new Bt(((e,r)=>{t.then(e,r)}));var e=new Bt(pt,!0,t);return Vt(e,Ot),e},reject:Ht,race:function(){var t=R.apply(null,arguments).map(ae);return new Bt(((e,r)=>{t.map((t=>Bt.resolve(t).then(e,r)))}))},PSD:{get:()=>Ct,set:t=>Ct=t},totalEchoes:{get:()=>ee},newPSD:ne,usePSD:fe,scheduler:{get:()=>kt,set:t=>{kt=t}},rejectionMapper:{get:()=>Pt,set:t=>{Pt=t}},follow:(t,e)=>new Bt(((r,n)=>ne(((e,r)=>{var n=Ct;n.unhandleds=[],n.onunhandled=r,n.finalize=ct((function(){!function(t){It.push((function e(){t(),It.splice(It.indexOf(e),1)})),++jt,kt((()=>{0==--jt&&Kt()}),[])}((()=>{0===this.unhandleds.length?e():r(this.unhandleds[0])}))}),n.finalize),t()}),e,r,n)))}),bt&&(bt.allSettled&&p(Bt,"allSettled",(function(){const t=R.apply(null,arguments).map(ae);return new Bt((e=>{0===t.length&&e([]);let r=t.length;const n=new Array(r);t.forEach(((t,o)=>Bt.resolve(t).then((t=>n[o]={status:"fulfilled",value:t}),(t=>n[o]={status:"rejected",reason:t})).then((()=>--r||e(n)))))}))})),bt.any&&"undefined"!=typeof AggregateError&&p(Bt,"any",(function(){const t=R.apply(null,arguments).map(ae);return new Bt(((e,r)=>{0===t.length&&r(new AggregateError([]));let n=t.length;const o=new Array(n);t.forEach(((t,i)=>Bt.resolve(t).then((t=>e(t)),(t=>{o[i]=t,--n||r(new AggregateError(o))}))))}))})));const Xt={awaits:0,echoes:0,id:0};var Jt=0,Qt=[],te=0,ee=0,re=0;function ne(t,e,r,n){var o=Ct,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++re;var a=Tt.env;i.env=wt?{Promise:Bt,PromiseProp:{value:Bt,configurable:!0,writable:!0},all:Bt.all,race:Bt.race,allSettled:Bt.allSettled,any:Bt.any,resolve:Bt.resolve,reject:Bt.reject,nthen:pe(a.nthen,i),gthen:pe(a.gthen,i)}:{},e&&c(i,e),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=fe(i,t,r,n);return 0===i.ref&&i.finalize(),s}function oe(){return Xt.id||(Xt.id=++Jt),++Xt.awaits,Xt.echoes+=100,Xt.id}function ie(){return!!Xt.awaits&&(0==--Xt.awaits&&(Xt.id=0),Xt.echoes=100*Xt.awaits,!0)}function ae(t){return Xt.echoes&&t&&t.constructor===bt?(oe(),t.then((t=>(ie(),t)),(t=>(ie(),me(t))))):t}function se(t){++ee,Xt.echoes&&0!=--Xt.echoes||(Xt.echoes=Xt.id=0),Qt.push(Ct),ue(t,!0)}function ce(){var t=Qt[Qt.length-1];Qt.pop(),ue(t,!1)}function ue(t,e){var r=Ct;if((e?!Xt.echoes||te++&&t===Ct:!te||--te&&t===Ct)||he(e?se.bind(null,t):ce),t!==Ct&&(Ct=t,r===Tt&&(Tt.env=le()),wt)){var n=Tt.env.Promise,o=t.env;gt.then=o.nthen,n.prototype.then=o.gthen,(r.global||t.global)&&(Object.defineProperty(i,"Promise",o.PromiseProp),n.all=o.all,n.race=o.race,n.resolve=o.resolve,n.reject=o.reject,o.allSettled&&(n.allSettled=o.allSettled),o.any&&(n.any=o.any))}}function le(){var t=i.Promise;return wt?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(i,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:gt.then,gthen:t.prototype.then}:{}}function fe(t,e,r,n,o){var i=Ct;try{return ue(t,!0),e(r,n,o)}finally{ue(i,!1)}}function he(t){vt.call(yt,t)}function de(t,e,r,n){return"function"!=typeof t?t:function(){var o=Ct;r&&oe(),ue(e,!0);try{return t.apply(this,arguments)}finally{ue(o,!1),n&&he(ie)}}}function pe(t,e){return function(r,n){return t.call(this,de(r,e),de(n,e))}}-1===(""+vt).indexOf("[native code]")&&(oe=ie=it);const ye="unhandledrejection";function ge(t,e){var r;try{r=e.onuncatched(t)}catch(t){}if(!1!==r)try{var n,o={promise:e,reason:t};if(i.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(ye,!0,!0),c(n,o)):i.CustomEvent&&c(n=new CustomEvent(ye,{detail:o}),o),n&&i.dispatchEvent&&(dispatchEvent(n),!i.PromiseRejectionEvent&&i.onunhandledrejection))try{i.onunhandledrejection(n)}catch(t){}U&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch(t){}}var me=Bt.reject;function ve(t,e,r,n){if(t.idbdb&&(t._state.openComplete||Ct.letThrough||t._vip)){var o=t._createTransaction(e,r,t._dbSchema);try{o.create()}catch(t){return me(t)}return o._promise(e,((t,e)=>ne((()=>(Ct.trans=o,n(t,e,o)))))).then((t=>o._completion.then((()=>t))))}if(t._state.openComplete)return me(new rt.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return me(new rt.DatabaseClosed);t.open().catch(it)}return t._state.dbReadyPromise.then((()=>ve(t,e,r,n)))}const be="3.2.0",we=String.fromCharCode(65535),xe=-1/0,_e="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",ke="String expected.",Ee=[],Ae="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Se=Ae,Le=Ae,Oe=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Pe="__dbnames",Te="readonly",Ce="readwrite";function Me(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const je={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ie(t){return"string"!=typeof t||/\./.test(t)?t=>t:e=>(void 0===e[t]&&t in e&&delete(e=M(e))[t],e)}class Be{_trans(t,e,r){const n=this._tx||Ct.trans,o=this.name;function i(t,r,n){if(!n.schema[o])throw new rt.NotFound("Table "+o+" not part of transaction");return e(n.idbtrans,n)}const a=$t();try{return n&&n.db===this.db?n===Ct.trans?n._promise(t,i,r):ne((()=>n._promise(t,i,r)),{trans:n,transless:Ct.transless||Ct}):ve(this.db,t,[this.name],i)}finally{a&&Yt()}}get(t,e){return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",(e=>this.core.get({trans:e,key:t}).then((t=>this.hook.reading.fire(t))))).then(e)}where(t){if("string"==typeof t)return new this.db.WhereClause(this,t);if(s(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const e=a(t);if(1===e.length)return this.where(e[0]).equals(t[e[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter((t=>t.compound&&e.every((e=>t.keyPath.indexOf(e)>=0))&&t.keyPath.every((t=>e.indexOf(t)>=0))))[0];if(r&&this.db._maxKey!==we)return this.where(r.name).equals(r.keyPath.map((e=>t[e])));!r&&U&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${e.join("+")}]`);const{idxByName:n}=this.schema,o=this.db._deps.indexedDB;function i(t,e){try{return 0===o.cmp(t,e)}catch(t){return!1}}const[c,u]=e.reduce((([e,r],o)=>{const a=n[o],c=t[o];return[e||a,e||!a?Me(r,a&&a.multi?t=>{const e=E(t,o);return s(e)&&e.some((t=>i(c,t)))}:t=>i(c,E(t,o))):r]}),[null,null]);return c?this.where(c.name).equals(t[c.keyPath]).filter(u):r?this.filter(u):this.where(e).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,s(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;const e=e=>{if(!e)return e;const r=Object.create(t.prototype);for(var n in e)if(f(e,n))try{r[n]=e[n]}catch(t){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=e,this.hook("reading",e),t}defineClass(){return this.mapToClass((function(t){c(this,t)}))}add(t,e){const{auto:r,keyPath:n}=this.schema.primKey;let o=t;return n&&r&&(o=Ie(n)(t)),this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"add",keys:null!=e?[e]:null,values:[o]}))).then((t=>t.numFailures?Bt.reject(t.failures[0]):t.lastResult)).then((e=>{if(n)try{A(t,n,e)}catch(t){}return e}))}update(t,e){if("object"!=typeof t||s(t))return this.where(":id").equals(t).modify(e);{const r=E(t,this.schema.primKey.keyPath);if(void 0===r)return me(new rt.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof e?a(e).forEach((r=>{A(t,r,e[r])})):e(t,{value:t,primKey:r})}catch(t){}return this.where(":id").equals(r).modify(e)}}put(t,e){const{auto:r,keyPath:n}=this.schema.primKey;let o=t;return n&&r&&(o=Ie(n)(t)),this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"put",values:[o],keys:null!=e?[e]:null}))).then((t=>t.numFailures?Bt.reject(t.failures[0]):t.lastResult)).then((e=>{if(n)try{A(t,n,e)}catch(t){}return e}))}delete(t){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"delete",keys:[t]}))).then((t=>t.numFailures?Bt.reject(t.failures[0]):void 0))}clear(){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"deleteRange",range:je}))).then((t=>t.numFailures?Bt.reject(t.failures[0]):void 0))}bulkGet(t){return this._trans("readonly",(e=>this.core.getMany({keys:t,trans:e}).then((t=>t.map((t=>this.hook.reading.fire(t)))))))}bulkAdd(t,e,r){const n=Array.isArray(e)?e:void 0,o=(r=r||(n?void 0:e))?r.allKeys:void 0;return this._trans("readwrite",(e=>{const{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new rt.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new rt.InvalidArgument("Arguments objects and keys must have the same length");const a=t.length;let s=i&&r?t.map(Ie(i)):t;return this.core.mutate({trans:e,type:"add",keys:n,values:s,wantResults:o}).then((({numFailures:t,results:e,lastResult:r,failures:n})=>{if(0===t)return o?e:r;throw new Q(`${this.name}.bulkAdd(): ${t} of ${a} operations failed`,n)}))}))}bulkPut(t,e,r){const n=Array.isArray(e)?e:void 0,o=(r=r||(n?void 0:e))?r.allKeys:void 0;return this._trans("readwrite",(e=>{const{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new rt.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new rt.InvalidArgument("Arguments objects and keys must have the same length");const a=t.length;let s=i&&r?t.map(Ie(i)):t;return this.core.mutate({trans:e,type:"put",keys:n,values:s,wantResults:o}).then((({numFailures:t,results:e,lastResult:r,failures:n})=>{if(0===t)return o?e:r;throw new Q(`${this.name}.bulkPut(): ${t} of ${a} operations failed`,n)}))}))}bulkDelete(t){const e=t.length;return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"delete",keys:t}))).then((({numFailures:t,lastResult:r,failures:n})=>{if(0===t)return r;throw new Q(`${this.name}.bulkDelete(): ${t} of ${e} operations failed`,n)}))}}function ze(t){var e={},r=function(r,n){if(n){for(var o=arguments.length,i=new Array(o-1);--o;)i[o-1]=arguments[o];return e[r].subscribe.apply(null,i),t}if("string"==typeof r)return e[r]};r.addEventType=i;for(var n=1,o=arguments.length;n<o;++n)i(arguments[n]);return r;function i(t,n,o){if("object"==typeof t)return c(t);n||(n=ht),o||(o=it);var i={subscribers:[],fire:o,subscribe:function(t){-1===i.subscribers.indexOf(t)&&(i.subscribers.push(t),i.fire=n(i.fire,t))},unsubscribe:function(t){i.subscribers=i.subscribers.filter((function(e){return e!==t})),i.fire=i.subscribers.reduce(n,o)}};return e[t]=r[t]=i,i}function c(t){a(t).forEach((function(e){var r=t[e];if(s(r))i(e,t[e][0],t[e][1]);else{if("asap"!==r)throw new rt.InvalidArgument("Invalid event config");var n=i(e,at,(function(){for(var t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];n.subscribers.forEach((function(t){_((function(){t.apply(null,e)}))}))}))}}))}}function De(t,e){return y(e).from({prototype:t}),e}function Ne(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function Re(t,e){t.filter=Me(t.filter,e)}function Fe(t,e,r){var n=t.replayFilter;t.replayFilter=n?()=>Me(n(),e()):e,t.justLimit=r&&!n}function Ue(t,e){if(t.isPrimKey)return e.primaryKey;const r=e.getIndexByKeyPath(t.index);if(!r)throw new rt.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return r}function Ge(t,e,r){const n=Ue(t,e.schema);return e.openCursor({trans:r,values:!t.keysOnly,reverse:"prev"===t.dir,unique:!!t.unique,query:{index:n,range:t.range}})}function We(t,e,r,n){const o=t.replayFilter?Me(t.filter,t.replayFilter()):t.filter;if(t.or){const i={},a=(t,r,n)=>{if(!o||o(r,n,(t=>r.stop(t)),(t=>r.fail(t)))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),f(i,s)||(i[s]=!0,e(t,r,n))}};return Promise.all([t.or._iterate(a,r),Ve(Ge(t,n,r),t.algorithm,a,!t.keysOnly&&t.valueMapper)])}return Ve(Ge(t,n,r),Me(t.algorithm,o),e,!t.keysOnly&&t.valueMapper)}function Ve(t,e,r,n){var o=qt(n?(t,e,o)=>r(n(t),e,o):r);return t.then((t=>{if(t)return t.start((()=>{var r=()=>t.continue();e&&!e(t,(t=>r=t),(e=>{t.stop(e),r=it}),(e=>{t.fail(e),r=it}))||o(t.value,t,(t=>r=t)),r()}))}))}function Ze(t,e){try{const r=$e(t),n=$e(e);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return t>e?1:t<e?-1:0;case"binary":return function(t,e){const r=t.length,n=e.length,o=r<n?r:n;for(let r=0;r<o;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return r===n?0:r<n?-1:1}(Ye(t),Ye(e));case"Array":return function(t,e){const r=t.length,n=e.length,o=r<n?r:n;for(let r=0;r<o;++r){const n=Ze(t[r],e[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(t,e)}}catch(t){}return NaN}function $e(t){const e=typeof t;if("object"!==e)return e;if(ArrayBuffer.isView(t))return"binary";const r=B(t);return"ArrayBuffer"===r?"binary":r}function Ye(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class Ke{_read(t,e){var r=this._ctx;return r.error?r.table._trans(null,me.bind(null,r.error)):r.table._trans("readonly",t).then(e)}_write(t){var e=this._ctx;return e.error?e.table._trans(null,me.bind(null,e.error)):e.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var e=this._ctx;e.algorithm=Me(e.algorithm,t)}_iterate(t,e){return We(this._ctx,t,e,this._ctx.table.core)}clone(t){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&c(r,t),e._ctx=r,e}raw(){return this._ctx.valueMapper=null,this}each(t){var e=this._ctx;return this._read((r=>We(e,t,r,e.table.core)))}count(t){return this._read((t=>{const e=this._ctx,r=e.table.core;if(Ne(e,!0))return r.count({trans:t,query:{index:Ue(e,r.schema),range:e.range}}).then((t=>Math.min(t,e.limit)));var n=0;return We(e,(()=>(++n,!1)),t,r).then((()=>n))})).then(t)}sortBy(t,e){const r=t.split(".").reverse(),n=r[0],o=r.length-1;function i(t,e){return e?i(t[r[e]],e-1):t[n]}var a="next"===this._ctx.dir?1:-1;function s(t,e){var r=i(t,o),n=i(e,o);return r<n?-a:r>n?a:0}return this.toArray((function(t){return t.sort(s)})).then(e)}toArray(t){return this._read((t=>{var e=this._ctx;if("next"===e.dir&&Ne(e,!0)&&e.limit>0){const{valueMapper:r}=e,n=Ue(e,e.table.core.schema);return e.table.core.query({trans:t,limit:e.limit,values:!0,query:{index:n,range:e.range}}).then((({result:t})=>r?t.map(r):t))}{const r=[];return We(e,(t=>r.push(t)),t,e.table.core).then((()=>r))}}),t)}offset(t){var e=this._ctx;return t<=0||(e.offset+=t,Ne(e)?Fe(e,(()=>{var e=t;return(t,r)=>0===e||(1===e?(--e,!1):(r((()=>{t.advance(e),e=0})),!1))})):Fe(e,(()=>{var e=t;return()=>--e<0}))),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Fe(this._ctx,(()=>{var e=t;return function(t,r,n){return--e<=0&&r(n),e>=0}}),!0),this}until(t,e){return Re(this._ctx,(function(r,n,o){return!t(r.value)||(n(o),e)})),this}first(t){return this.limit(1).toArray((function(t){return t[0]})).then(t)}last(t){return this.reverse().first(t)}filter(t){var e,r;return Re(this._ctx,(function(e){return t(e.value)})),e=this._ctx,r=t,e.isMatch=Me(e.isMatch,r),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each((function(e,r){t(r.key,r)}))}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each((function(e,r){t(r.primaryKey,r)}))}keys(t){var e=this._ctx;e.keysOnly=!e.isMatch;var r=[];return this.each((function(t,e){r.push(e.key)})).then((function(){return r})).then(t)}primaryKeys(t){var e=this._ctx;if("next"===e.dir&&Ne(e,!0)&&e.limit>0)return this._read((t=>{var r=Ue(e,e.table.core.schema);return e.table.core.query({trans:t,values:!1,limit:e.limit,query:{index:r,range:e.range}})})).then((({result:t})=>t)).then(t);e.keysOnly=!e.isMatch;var r=[];return this.each((function(t,e){r.push(e.primaryKey)})).then((function(){return r})).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys((function(t){return t[0]})).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var r={};return Re(this._ctx,(function(t){var e=t.primaryKey.toString(),n=f(r,e);return r[e]=!0,!n})),this}modify(t){var e=this._ctx;return this._write((r=>{var n;if("function"==typeof t)n=t;else{var o=a(t),i=o.length;n=function(e){for(var r=!1,n=0;n<i;++n){var a=o[n],s=t[a];E(e,a)!==s&&(A(e,a,s),r=!0)}return r}}const s=e.table.core,{outbound:c,extractKey:u}=s.schema.primaryKey,l=this.db._options.modifyChunkSize||200,f=[];let h=0;const d=[],p=(t,e)=>{const{failures:r,numFailures:n}=e;h+=t-n;for(let t of a(r))f.push(r[t])};return this.clone().primaryKeys().then((o=>{const i=a=>{const f=Math.min(l,o.length-a);return s.getMany({trans:r,keys:o.slice(a,a+f),cache:"immutable"}).then((h=>{const d=[],y=[],g=c?[]:null,m=[];for(let t=0;t<f;++t){const e=h[t],r={value:M(e),primKey:o[a+t]};!1!==n.call(r,r.value,r)&&(null==r.value?m.push(o[a+t]):c||0===Ze(u(e),u(r.value))?(y.push(r.value),c&&g.push(o[a+t])):(m.push(o[a+t]),d.push(r.value)))}const v=Ne(e)&&e.limit===1/0&&("function"!=typeof t||t===He)&&{index:e.index,range:e.range};return Promise.resolve(d.length>0&&s.mutate({trans:r,type:"add",values:d}).then((t=>{for(let e in t.failures)m.splice(parseInt(e),1);p(d.length,t)}))).then((()=>(y.length>0||v&&"object"==typeof t)&&s.mutate({trans:r,type:"put",keys:g,values:y,criteria:v,changeSpec:"function"!=typeof t&&t}).then((t=>p(y.length,t))))).then((()=>(m.length>0||v&&t===He)&&s.mutate({trans:r,type:"delete",keys:m,criteria:v}).then((t=>p(m.length,t))))).then((()=>o.length>a+f&&i(a+l)))}))};return i(0).then((()=>{if(f.length>0)throw new J("Error modifying one or more objects",f,h,d);return o.length}))}))}))}delete(){var t=this._ctx,e=t.range;return Ne(t)&&(t.isPrimKey&&!Le||3===e.type)?this._write((r=>{const{primaryKey:n}=t.table.core.schema,o=e;return t.table.core.count({trans:r,query:{index:n,range:o}}).then((e=>t.table.core.mutate({trans:r,type:"deleteRange",range:o}).then((({failures:t,lastResult:r,results:n,numFailures:o})=>{if(o)throw new J("Could not delete some values",Object.keys(t).map((e=>t[e])),e-o);return e-o}))))})):this.modify(He)}}const He=(t,e)=>e.value=null;function qe(t,e){return t<e?-1:t===e?0:1}function Xe(t,e){return t>e?-1:t===e?0:1}function Je(t,e,r){var n=t instanceof or?new t.Collection(t):t;return n._ctx.error=r?new r(e):new TypeError(e),n}function Qe(t){return new t.Collection(t,(()=>nr(""))).limit(0)}function tr(t,e,r,n,o,i){for(var a=Math.min(t.length,n.length),s=-1,c=0;c<a;++c){var u=e[c];if(u!==n[c])return o(t[c],r[c])<0?t.substr(0,c)+r[c]+r.substr(c+1):o(t[c],n[c])<0?t.substr(0,c)+n[c]+r.substr(c+1):s>=0?t.substr(0,s)+e[s]+r.substr(s+1):null;o(t[c],u)<0&&(s=c)}return a<n.length&&"next"===i?t+r.substr(t.length):a<t.length&&"prev"===i?t.substr(0,r.length):s<0?null:t.substr(0,s)+n[s]+r.substr(s+1)}function er(t,e,r,n){var o,i,a,s,c,u,l,f=r.length;if(!r.every((t=>"string"==typeof t)))return Je(t,ke);function h(t){o=function(t){return"next"===t?t=>t.toUpperCase():t=>t.toLowerCase()}(t),i=function(t){return"next"===t?t=>t.toLowerCase():t=>t.toUpperCase()}(t),a="next"===t?qe:Xe;var e=r.map((function(t){return{lower:i(t),upper:o(t)}})).sort((function(t,e){return a(t.lower,e.lower)}));s=e.map((function(t){return t.upper})),c=e.map((function(t){return t.lower})),u=t,l="next"===t?"":n}h("next");var d=new t.Collection(t,(()=>rr(s[0],c[f-1]+n)));d._ondirectionchange=function(t){h(t)};var p=0;return d._addAlgorithm((function(t,r,n){var o=t.key;if("string"!=typeof o)return!1;var h=i(o);if(e(h,c,p))return!0;for(var d=null,y=p;y<f;++y){var g=tr(o,h,s[y],c[y],a,u);null===g&&null===d?p=y+1:(null===d||a(d,g)>0)&&(d=g)}return r(null!==d?function(){t.continue(d+l)}:n),!1})),d}function rr(t,e,r,n){return{type:2,lower:t,upper:e,lowerOpen:r,upperOpen:n}}function nr(t){return{type:1,lower:t,upper:t}}class or{get Collection(){return this._ctx.table.db.Collection}between(t,e,r,n){r=!1!==r,n=!0===n;try{return this._cmp(t,e)>0||0===this._cmp(t,e)&&(r||n)&&(!r||!n)?Qe(this):new this.Collection(this,(()=>rr(t,e,!r,!n)))}catch(t){return Je(this,_e)}}equals(t){return null==t?Je(this,_e):new this.Collection(this,(()=>nr(t)))}above(t){return null==t?Je(this,_e):new this.Collection(this,(()=>rr(t,void 0,!0)))}aboveOrEqual(t){return null==t?Je(this,_e):new this.Collection(this,(()=>rr(t,void 0,!1)))}below(t){return null==t?Je(this,_e):new this.Collection(this,(()=>rr(void 0,t,!1,!0)))}belowOrEqual(t){return null==t?Je(this,_e):new this.Collection(this,(()=>rr(void 0,t)))}startsWith(t){return"string"!=typeof t?Je(this,ke):this.between(t,t+we,!0,!0)}startsWithIgnoreCase(t){return""===t?this.startsWith(t):er(this,((t,e)=>0===t.indexOf(e[0])),[t],we)}equalsIgnoreCase(t){return er(this,((t,e)=>t===e[0]),[t],"")}anyOfIgnoreCase(){var t=R.apply(N,arguments);return 0===t.length?Qe(this):er(this,((t,e)=>-1!==e.indexOf(t)),t,"")}startsWithAnyOfIgnoreCase(){var t=R.apply(N,arguments);return 0===t.length?Qe(this):er(this,((t,e)=>e.some((e=>0===t.indexOf(e)))),t,we)}anyOf(){const t=R.apply(N,arguments);let e=this._cmp;try{t.sort(e)}catch(t){return Je(this,_e)}if(0===t.length)return Qe(this);const r=new this.Collection(this,(()=>rr(t[0],t[t.length-1])));r._ondirectionchange=r=>{e="next"===r?this._ascending:this._descending,t.sort(e)};let n=0;return r._addAlgorithm(((r,o,i)=>{const a=r.key;for(;e(a,t[n])>0;)if(++n,n===t.length)return o(i),!1;return 0===e(a,t[n])||(o((()=>{r.continue(t[n])})),!1)})),r}notEqual(t){return this.inAnyRange([[xe,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=R.apply(N,arguments);if(0===t.length)return new this.Collection(this);try{t.sort(this._ascending)}catch(t){return Je(this,_e)}const e=t.reduce(((t,e)=>t?t.concat([[t[t.length-1][1],e]]):[[xe,e]]),null);return e.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,e){const r=this._cmp,n=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===t.length)return Qe(this);if(!t.every((t=>void 0!==t[0]&&void 0!==t[1]&&n(t[0],t[1])<=0)))return Je(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",rt.InvalidArgument);const s=!e||!1!==e.includeLowers,c=e&&!0===e.includeUppers;let u,l=n;function f(t,e){return l(t[0],e[0])}try{u=t.reduce((function(t,e){let n=0,o=t.length;for(;n<o;++n){const o=t[n];if(r(e[0],o[1])<0&&r(e[1],o[0])>0){o[0]=i(o[0],e[0]),o[1]=a(o[1],e[1]);break}}return n===o&&t.push(e),t}),[]),u.sort(f)}catch(t){return Je(this,_e)}let h=0;const d=c?t=>n(t,u[h][1])>0:t=>n(t,u[h][1])>=0,p=s?t=>o(t,u[h][0])>0:t=>o(t,u[h][0])>=0;let y=d;const g=new this.Collection(this,(()=>rr(u[0][0],u[u.length-1][1],!s,!c)));return g._ondirectionchange=t=>{"next"===t?(y=d,l=n):(y=p,l=o),u.sort(f)},g._addAlgorithm(((t,e,r)=>{for(var o=t.key;y(o);)if(++h,h===u.length)return e(r),!1;return!!function(t){return!d(t)&&!p(t)}(o)||(0===this._cmp(o,u[h][1])||0===this._cmp(o,u[h][0])||e((()=>{l===n?t.continue(u[h][0]):t.continue(u[h][1])})),!1)})),g}startsWithAnyOf(){const t=R.apply(N,arguments);return t.every((t=>"string"==typeof t))?0===t.length?Qe(this):this.inAnyRange(t.map((t=>[t,t+we]))):Je(this,"startsWithAnyOf() only works with strings")}}function ir(t){return qt((function(e){return ar(e),t(e.target.error),!1}))}function ar(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const sr="storagemutated",cr="x-storagemutated-1",ur=ze(null,sr);class lr{_lock(){return x(!Ct.global),++this._reculock,1!==this._reculock||Ct.global||(Ct.lockOwnerFor=this),this}_unlock(){if(x(!Ct.global),0==--this._reculock)for(Ct.global||(Ct.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{fe(t[1],t[0])}catch(t){}}return this}_locked(){return this._reculock&&Ct.lockOwnerFor!==this}create(t){if(!this.mode)return this;const e=this.db.idbdb,r=this.db._state.dbOpenError;if(x(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new rt.DatabaseClosed(r);case"MissingAPIError":throw new rt.MissingAPI(r.message,r);default:throw new rt.OpenFailed(r)}if(!this.active)throw new rt.TransactionInactive;return x(null===this._completion._state),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):e.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=qt((e=>{ar(e),this._reject(t.error)})),t.onabort=qt((e=>{ar(e),this.active&&this._reject(new rt.Abort(t.error)),this.active=!1,this.on("abort").fire(e)})),t.oncomplete=qt((()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&ur.storagemutated.fire(t.mutatedParts)})),this}_promise(t,e,r){if("readwrite"===t&&"readwrite"!==this.mode)return me(new rt.ReadOnly("Transaction is readonly"));if(!this.active)return me(new rt.TransactionInactive);if(this._locked())return new Bt(((n,o)=>{this._blockedFuncs.push([()=>{this._promise(t,e,r).then(n,o)},Ct])}));if(r)return ne((()=>{var t=new Bt(((t,r)=>{this._lock();const n=e(t,r,this);n&&n.then&&n.then(t,r)}));return t.finally((()=>this._unlock())),t._lib=!0,t}));var n=new Bt(((t,r)=>{var n=e(t,r,this);n&&n.then&&n.then(t,r)}));return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(t){var e=this._root();const r=Bt.resolve(t);if(e._waitingFor)e._waitingFor=e._waitingFor.then((()=>r));else{e._waitingFor=r,e._waitingQueue=[];var n=e.idbtrans.objectStore(e.storeNames[0]);!function t(){for(++e._spinCount;e._waitingQueue.length;)e._waitingQueue.shift()();e._waitingFor&&(n.get(-1/0).onsuccess=t)}()}var o=e._waitingFor;return new Bt(((t,n)=>{r.then((r=>e._waitingQueue.push(qt(t.bind(null,r)))),(t=>e._waitingQueue.push(qt(n.bind(null,t))))).finally((()=>{e._waitingFor===o&&(e._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new rt.Abort))}table(t){const e=this._memoizedTables||(this._memoizedTables={});if(f(e,t))return e[t];const r=this.schema[t];if(!r)throw new rt.NotFound("Table "+t+" not part of transaction");const n=new this.db.Table(t,r,this);return n.core=this.db.core.table(t),e[t]=n,n}}function fr(t,e,r,n,o,i,a){return{name:t,keyPath:e,unique:r,multi:n,auto:o,compound:i,src:(r&&!a?"&":"")+(n?"*":"")+(o?"++":"")+hr(e)}}function hr(t){return"string"==typeof t?t:t?"["+[].join.call(t,"+")+"]":""}function dr(t,e,r){return{name:t,primKey:e,indexes:r,mappedClass:null,idxByName:k(r,(t=>[t.name,t]))}}let pr=t=>{try{return t.only([[]]),pr=()=>[[]],[[]]}catch(t){return pr=()=>we,we}};function yr(t){return null==t?()=>{}:"string"==typeof t?function(t){return 1===t.split(".").length?e=>e[t]:e=>E(e,t)}(t):e=>E(e,t)}function gr(t){return[].slice.call(t)}let mr=0;function vr(t){return null==t?":id":"string"==typeof t?t:`[${t.join("+")}]`}function br({_novip:t},e){const r=e.db,n=function(t,e,{IDBKeyRange:r,indexedDB:n},o){const i=function(t,e){return e.reduce(((t,{create:e})=>({...t,...e(t)})),t)}(function(t,e,r){function n(t){if(3===t.type)return null;if(4===t.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:r,upper:n,lowerOpen:o,upperOpen:i}=t;return void 0===r?void 0===n?null:e.upperBound(n,!!i):void 0===n?e.lowerBound(r,!!o):e.bound(r,n,!!o,!!i)}const{schema:o,hasGetAll:i}=function(t,e){const r=gr(t.objectStoreNames);return{schema:{name:t.name,tables:r.map((t=>e.objectStore(t))).map((t=>{const{keyPath:e,autoIncrement:r}=t,n=s(e),o=null==e,i={},a={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:n,keyPath:e,autoIncrement:r,unique:!0,extractKey:yr(e)},indexes:gr(t.indexNames).map((e=>t.index(e))).map((t=>{const{name:e,unique:r,multiEntry:n,keyPath:o}=t,a={name:e,compound:s(o),keyPath:o,unique:r,multiEntry:n,extractKey:yr(o)};return i[vr(o)]=a,a})),getIndexByKeyPath:t=>i[vr(t)]};return i[":id"]=a.primaryKey,null!=e&&(i[vr(e)]=a.primaryKey),a}))},hasGetAll:r.length>0&&"getAll"in e.objectStore(r[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,r),a=o.tables.map((t=>function(t){const e=t.name;return{name:e,schema:t,mutate:function({trans:t,type:r,keys:o,values:i,range:a}){return new Promise(((s,c)=>{s=qt(s);const u=t.objectStore(e),l=null==u.keyPath,f="put"===r||"add"===r;if(!f&&"delete"!==r&&"deleteRange"!==r)throw new Error("Invalid operation type: "+r);const{length:h}=o||i||{length:1};if(o&&i&&o.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===h)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let d;const p=[],y=[];let g=0;const m=t=>{++g,ar(t)};if("deleteRange"===r){if(4===a.type)return s({numFailures:g,failures:y,results:[],lastResult:void 0});3===a.type?p.push(d=u.clear()):p.push(d=u.delete(n(a)))}else{const[t,e]=f?l?[i,o]:[i,null]:[o,null];if(f)for(let n=0;n<h;++n)p.push(d=e&&void 0!==e[n]?u[r](t[n],e[n]):u[r](t[n])),d.onerror=m;else for(let e=0;e<h;++e)p.push(d=u[r](t[e])),d.onerror=m}const v=t=>{const e=t.target.result;p.forEach(((t,e)=>null!=t.error&&(y[e]=t.error))),s({numFailures:g,failures:y,results:"delete"===r?o:p.map((t=>t.result)),lastResult:e})};d.onerror=t=>{m(t),v(t)},d.onsuccess=v}))},getMany:({trans:t,keys:r})=>new Promise(((n,o)=>{n=qt(n);const i=t.objectStore(e),a=r.length,s=new Array(a);let c,u=0,l=0;const f=t=>{const e=t.target;s[e._pos]=e.result,++l===u&&n(s)},h=ir(o);for(let t=0;t<a;++t)null!=r[t]&&(c=i.get(r[t]),c._pos=t,c.onsuccess=f,c.onerror=h,++u);0===u&&n(s)})),get:({trans:t,key:r})=>new Promise(((n,o)=>{n=qt(n);const i=t.objectStore(e).get(r);i.onsuccess=t=>n(t.target.result),i.onerror=ir(o)})),query:function(t){return r=>new Promise(((o,i)=>{o=qt(o);const{trans:a,values:s,limit:c,query:u}=r,l=c===1/0?void 0:c,{index:f,range:h}=u,d=a.objectStore(e),p=f.isPrimaryKey?d:d.index(f.name),y=n(h);if(0===c)return o({result:[]});if(t){const t=s?p.getAll(y,l):p.getAllKeys(y,l);t.onsuccess=t=>o({result:t.target.result}),t.onerror=ir(i)}else{let t=0;const e=s||!("openKeyCursor"in p)?p.openCursor(y):p.openKeyCursor(y),r=[];e.onsuccess=n=>{const i=e.result;return i?(r.push(s?i.value:i.primaryKey),++t===c?o({result:r}):void i.continue()):o({result:r})},e.onerror=ir(i)}}))}(i),openCursor:function({trans:t,values:r,query:o,reverse:i,unique:a}){return new Promise(((s,c)=>{s=qt(s);const{index:u,range:l}=o,f=t.objectStore(e),h=u.isPrimaryKey?f:f.index(u.name),d=i?a?"prevunique":"prev":a?"nextunique":"next",p=r||!("openKeyCursor"in h)?h.openCursor(n(l),d):h.openKeyCursor(n(l),d);p.onerror=ir(c),p.onsuccess=qt((e=>{const r=p.result;if(!r)return void s(null);r.___id=++mr,r.done=!1;const n=r.continue.bind(r);let o=r.continuePrimaryKey;o&&(o=o.bind(r));const i=r.advance.bind(r),a=()=>{throw new Error("Cursor not stopped")};r.trans=t,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw new Error("Cursor not started")},r.fail=qt(c),r.next=function(){let t=1;return this.start((()=>t--?this.continue():this.stop())).then((()=>this))},r.start=t=>{const e=new Promise(((t,e)=>{t=qt(t),p.onerror=ir(e),r.fail=e,r.stop=e=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,t(e)}})),s=()=>{if(p.result)try{t()}catch(t){r.fail(t)}else r.done=!0,r.start=()=>{throw new Error("Cursor behind last entry")},r.stop()};return p.onsuccess=qt((t=>{p.onsuccess=s,s()})),r.continue=n,r.continuePrimaryKey=o,r.advance=i,s(),e},s(r)}),c)}))},count({query:t,trans:r}){const{index:o,range:i}=t;return new Promise(((t,a)=>{const s=r.objectStore(e),c=o.isPrimaryKey?s:s.index(o.name),u=n(i),l=u?c.count(u):c.count();l.onsuccess=qt((e=>t(e.target.result))),l.onerror=ir(a)}))}}}(t))),c={};return a.forEach((t=>c[t.name]=t)),{stack:"dbcore",transaction:t.transaction.bind(t),table(t){if(!c[t])throw new Error(`Table '${t}' not found`);return c[t]},MIN_KEY:-1/0,MAX_KEY:pr(e),schema:o}}(e,r,o),t.dbcore);return{dbcore:i}}(t._middlewares,r,t._deps,e);t.core=n.dbcore,t.tables.forEach((e=>{const r=e.name;t.core.schema.tables.some((t=>t.name===r))&&(e.core=t.core.table(r),t[r]instanceof t.Table&&(t[r].core=e.core))}))}function wr({_novip:t},e,r,n){r.forEach((r=>{const o=n[r];e.forEach((e=>{const n=m(e,r);(!n||"value"in n&&void 0===n.value)&&(e===t.Transaction.prototype||e instanceof t.Transaction?p(e,r,{get(){return this.table(r)},set(t){d(this,r,{value:t,writable:!0,configurable:!0,enumerable:!0})}}):e[r]=new t.Table(r,o))}))}))}function xr({_novip:t},e){e.forEach((e=>{for(let r in e)e[r]instanceof t.Table&&delete e[r]}))}function _r(t,e){return t._cfg.version-e._cfg.version}function kr(t,e){const r={del:[],add:[],change:[]};let n;for(n in t)e[n]||r.del.push(n);for(n in e){const o=t[n],i=e[n];if(o){const t={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto&&!Ae)t.recreate=!0,r.change.push(t);else{const e=o.idxByName,n=i.idxByName;let a;for(a in e)n[a]||t.del.push(a);for(a in n){const r=e[a],o=n[a];r?r.src!==o.src&&t.change.push(o):t.add.push(o)}(t.del.length>0||t.add.length>0||t.change.length>0)&&r.change.push(t)}}else r.add.push([n,i])}return r}function Er(t,e,r,n){const o=t.db.createObjectStore(e,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach((t=>Ar(o,t))),o}function Ar(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Sr(t,e,r){const n={};return b(e.objectStoreNames,0).forEach((t=>{const e=r.objectStore(t);let o=e.keyPath;const i=fr(hr(o),o||"",!1,!1,!!e.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let t=0;t<e.indexNames.length;++t){const r=e.index(e.indexNames[t]);o=r.keyPath;var s=fr(r.name,o,!!r.unique,!!r.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}n[t]=dr(t,i,a)})),n}function Lr({_novip:t},e,r){const n=r.db.objectStoreNames;for(let o=0;o<n.length;++o){const i=n[o],a=r.objectStore(i);t._hasGetAll="getAll"in a;for(let t=0;t<a.indexNames.length;++t){const r=a.indexNames[t],n=a.index(r).keyPath,o="string"==typeof n?n:"["+b(n).join("+")+"]";if(e[i]){const t=e[i].idxByName[o];t&&(t.name=r,delete e[i].idxByName[o],e[i].idxByName[r]=t)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&i.WorkerGlobalScope&&i instanceof i.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class Or{_parseStoresSpec(t,e){a(t).forEach((r=>{if(null!==t[r]){var n=t[r].split(",").map(((t,e)=>{const r=(t=t.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return fr(r,n||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),s(n),0===e)})),o=n.shift();if(o.multi)throw new rt.Schema("Primary key cannot be multi-valued");n.forEach((t=>{if(t.auto)throw new rt.Schema("Only primary key can be marked as autoIncrement (++)");if(!t.keyPath)throw new rt.Schema("Index must have a name and cannot be an empty string")})),e[r]=dr(r,o,n)}}))}stores(t){const e=this.db;this._cfg.storesSource=this._cfg.storesSource?c(this._cfg.storesSource,t):t;const r=e._versions,n={};let o={};return r.forEach((t=>{c(n,t._cfg.storesSource),o=t._cfg.dbschema={},t._parseStoresSpec(n,o)})),e._dbSchema=o,xr(e,[e._allTables,e,e.Transaction.prototype]),wr(e,[e._allTables,e,e.Transaction.prototype,this._cfg.tables],a(o),o),e._storeNames=a(o),this}upgrade(t){return this._cfg.contentUpgrade=dt(this._cfg.contentUpgrade||it,t),this}}function Pr(t,e){let r=t._dbNamesDB;return r||(r=t._dbNamesDB=new Xr(Pe,{addons:[],indexedDB:t,IDBKeyRange:e}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function Tr(t){return t&&"function"==typeof t.databases}function Cr(t){return ne((function(){return Ct.letThrough=!0,t()}))}function Mr(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()})).finally((function(){return clearInterval(t)})):Promise.resolve()}function jr(t){const e=t._state,{indexedDB:r}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then((()=>e.dbOpenError?me(e.dbOpenError):t));U&&(e.openCanceller._stackHolder=Z()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const n=e.openCanceller;function o(){if(e.openCanceller!==n)throw new rt.DatabaseClosed("db.open() was cancelled")}let i=e.dbReadyResolve,s=null,c=!1;return Bt.race([n,("undefined"==typeof navigator?Bt.resolve():Mr()).then((()=>new Bt(((n,i)=>{if(o(),!r)throw new rt.MissingAPI;const u=t.name,l=e.autoSchema?r.open(u):r.open(u,Math.round(10*t.verno));if(!l)throw new rt.MissingAPI;l.onerror=ir(i),l.onblocked=qt(t._fireOnBlocked),l.onupgradeneeded=qt((n=>{if(s=l.transaction,e.autoSchema&&!t._options.allowEmptyDB){l.onerror=ar,s.abort(),l.result.close();const t=r.deleteDatabase(u);t.onsuccess=t.onerror=qt((()=>{i(new rt.NoSuchDatabase(`Database ${u} doesnt exist`))}))}else{s.onerror=ir(i);var o=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;c=o<1,t._novip.idbdb=l.result,function(t,e,r,n){const o=t._dbSchema,i=t._createTransaction("readwrite",t._storeNames,o);i.create(r),i._completion.catch(n);const s=i._reject.bind(i),c=Ct.transless||Ct;ne((()=>{Ct.trans=i,Ct.transless=c,0===e?(a(o).forEach((t=>{Er(r,t,o[t].primKey,o[t].indexes)})),br(t,r),Bt.follow((()=>t.on.populate.fire(i))).catch(s)):function({_novip:t},e,r,n){const o=[],i=t._versions;let s=t._dbSchema=Sr(0,t.idbdb,n),c=!1;return i.filter((t=>t._cfg.version>=e)).forEach((i=>{o.push((()=>{const o=s,u=i._cfg.dbschema;Lr(t,o,n),Lr(t,u,n),s=t._dbSchema=u;const l=kr(o,u);l.add.forEach((t=>{Er(n,t[0],t[1].primKey,t[1].indexes)})),l.change.forEach((t=>{if(t.recreate)throw new rt.Upgrade("Not yet support for changing primary key");{const e=n.objectStore(t.name);t.add.forEach((t=>Ar(e,t))),t.change.forEach((t=>{e.deleteIndex(t.name),Ar(e,t)})),t.del.forEach((t=>e.deleteIndex(t)))}}));const f=i._cfg.contentUpgrade;if(f&&i._cfg.version>e){br(t,n),r._memoizedTables={},c=!0;let e=S(u);l.del.forEach((t=>{e[t]=o[t]})),xr(t,[t.Transaction.prototype]),wr(t,[t.Transaction.prototype],a(e),e),r.schema=e;const i=F(f);let s;i&&oe();const h=Bt.follow((()=>{if(s=f(r),s&&i){var t=ie.bind(null,null);s.then(t,t)}}));return s&&"function"==typeof s.then?Bt.resolve(s):h.then((()=>s))}})),o.push((e=>{c&&Se||function(t,e){[].slice.call(e.db.objectStoreNames).forEach((r=>null==t[r]&&e.db.deleteObjectStore(r)))}(i._cfg.dbschema,e),xr(t,[t.Transaction.prototype]),wr(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),r.schema=t._dbSchema}))})),function t(){return o.length?Bt.resolve(o.shift()(r.idbtrans)).then(t):Bt.resolve()}().then((()=>{var t,e;e=n,a(t=s).forEach((r=>{e.db.objectStoreNames.contains(r)||Er(e,r,t[r].primKey,t[r].indexes)}))}))}(t,e,i,r).catch(s)}))}(t,o/10,s,i)}}),i),l.onsuccess=qt((()=>{s=null;const r=t._novip.idbdb=l.result,o=b(r.objectStoreNames);if(o.length>0)try{const n=r.transaction(1===(i=o).length?i[0]:i,"readonly");e.autoSchema?function({_novip:t},e,r){t.verno=e.version/10;const n=t._dbSchema=Sr(0,e,r);t._storeNames=b(e.objectStoreNames,0),wr(t,[t._allTables],a(n),n)}(t,r,n):(Lr(t,t._dbSchema,n),function(t,e){const r=kr(Sr(0,t.idbdb,e),t._dbSchema);return!(r.add.length||r.change.some((t=>t.add.length||t.change.length)))}(t,n)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),br(t,n)}catch(t){}var i;Ee.push(t),r.onversionchange=qt((r=>{e.vcFired=!0,t.on("versionchange").fire(r)})),r.onclose=qt((e=>{t.on("close").fire(e)})),c&&function({indexedDB:t,IDBKeyRange:e},r){!Tr(t)&&r!==Pe&&Pr(t,e).put({name:r}).catch(it)}(t._deps,u),n()}),i)}))))]).then((()=>(o(),e.onReadyBeingFired=[],Bt.resolve(Cr((()=>t.on.ready.fire(t.vip)))).then((function r(){if(e.onReadyBeingFired.length>0){let n=e.onReadyBeingFired.reduce(dt,it);return e.onReadyBeingFired=[],Bt.resolve(Cr((()=>n(t.vip)))).then(r)}}))))).finally((()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1})).then((()=>t)).catch((r=>{e.dbOpenError=r;try{s&&s.abort()}catch(t){}return n===e.openCanceller&&t._close(),me(r)})).finally((()=>{e.openComplete=!0,i()}))}function Ir(t){var e=e=>t.next(e),r=o(e),n=o((e=>t.throw(e)));function o(t){return e=>{var o=t(e),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(r,n):s(i)?Promise.all(i).then(r,n):r(i)}}return o(e)()}function Br(t,e,r){var n=arguments.length;if(n<2)throw new rt.InvalidArgument("Too few arguments");for(var o=new Array(n-1);--n;)o[n-1]=arguments[n];r=o.pop();var i=O(o);return[t,i,r]}function zr(t,e,r,n,o){return Bt.resolve().then((()=>{const i=Ct.transless||Ct,a=t._createTransaction(e,r,t._dbSchema,n),s={trans:a,transless:i};n?a.idbtrans=n.idbtrans:a.create();const c=F(o);let u;c&&oe();const l=Bt.follow((()=>{if(u=o.call(a,a),u)if(c){var t=ie.bind(null,null);u.then(t,t)}else"function"==typeof u.next&&"function"==typeof u.throw&&(u=Ir(u))}),s);return(u&&"function"==typeof u.then?Bt.resolve(u).then((t=>a.active?t:me(new rt.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):l.then((()=>u))).then((t=>(n&&a._resolve(),a._completion.then((()=>t))))).catch((t=>(a._reject(t),me(t))))}))}function Dr(t,e,r){const n=s(t)?t.slice():[t];for(let t=0;t<r;++t)n.push(e);return n}const Nr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return{...t,table(e){const r=t.table(e),{schema:n}=r,o={},i=[];function a(t,e,r){const n=vr(t),s=o[n]=o[n]||[],c=null==t?0:"string"==typeof t?1:t.length,u=e>0,l={...r,isVirtual:u,keyTail:e,keyLength:c,extractKey:yr(t),unique:!u&&r.unique};return s.push(l),l.isPrimaryKey||i.push(l),c>1&&a(2===c?t[0]:t.slice(0,c-1),e+1,r),s.sort(((t,e)=>t.keyTail-e.keyTail)),l}const s=a(n.primaryKey.keyPath,0,n.primaryKey);o[":id"]=[s];for(const t of n.indexes)a(t.keyPath,0,t);function c(e){const r=e.query.index;return r.isVirtual?{...e,query:{index:r,range:(n=e.query.range,o=r.keyTail,{type:1===n.type?2:n.type,lower:Dr(n.lower,n.lowerOpen?t.MAX_KEY:t.MIN_KEY,o),lowerOpen:!0,upper:Dr(n.upper,n.upperOpen?t.MIN_KEY:t.MAX_KEY,o),upperOpen:!0})}}:e;var n,o}const u={...r,schema:{...n,primaryKey:s,indexes:i,getIndexByKeyPath:function(t){const e=o[vr(t)];return e&&e[0]}},count:t=>r.count(c(t)),query:t=>r.query(c(t)),openCursor(e){const{keyTail:n,isVirtual:o,keyLength:i}=e.query.index;return o?r.openCursor(c(e)).then((r=>r&&function(r){const o=Object.create(r,{continue:{value:function(o){null!=o?r.continue(Dr(o,e.reverse?t.MAX_KEY:t.MIN_KEY,n)):e.unique?r.continue(r.key.slice(0,i).concat(e.reverse?t.MIN_KEY:t.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(e,o){r.continuePrimaryKey(Dr(e,t.MAX_KEY,n),o)}},primaryKey:{get:()=>r.primaryKey},key:{get(){const t=r.key;return 1===i?t[0]:t.slice(0,i)}},value:{get:()=>r.value}});return o}(r))):r.openCursor(e)}};return u}}}};function Rr(t,e,r,n){return r=r||{},n=n||"",a(t).forEach((o=>{if(f(e,o)){var i=t[o],a=e[o];if("object"==typeof i&&"object"==typeof a&&i&&a){const t=B(i);t!==B(a)?r[n+o]=e[o]:"Object"===t?Rr(i,a,r,n+o+"."):i!==a&&(r[n+o]=e[o])}else i!==a&&(r[n+o]=e[o])}else r[n+o]=void 0})),a(e).forEach((o=>{f(t,o)||(r[n+o]=e[o])})),r}const Fr={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const r=t.table(e),{primaryKey:n}=r.schema,o={...r,mutate(t){const o=Ct.trans,{deleting:i,creating:a,updating:s}=o.table(e).hook;switch(t.type){case"add":if(a.fire===it)break;return o._promise("readwrite",(()=>c(t)),!0);case"put":if(a.fire===it&&s.fire===it)break;return o._promise("readwrite",(()=>c(t)),!0);case"delete":if(i.fire===it)break;return o._promise("readwrite",(()=>c(t)),!0);case"deleteRange":if(i.fire===it)break;return o._promise("readwrite",(()=>function(t){return u(t.trans,t.range,1e4)}(t)),!0)}return r.mutate(t);function c(t){const e=Ct.trans,o=t.keys||function(t,e){return"delete"===e.type?e.keys:e.keys||e.values.map(t.extractKey)}(n,t);if(!o)throw new Error("Keys missing");return"delete"!==(t="add"===t.type||"put"===t.type?{...t,keys:o}:{...t}).type&&(t.values=[...t.values]),t.keys&&(t.keys=[...t.keys]),function(t,e,r){return"add"===e.type?Promise.resolve([]):t.getMany({trans:e.trans,keys:r,cache:"immutable"})}(r,t,o).then((c=>{const u=o.map(((r,o)=>{const u=c[o],l={onerror:null,onsuccess:null};if("delete"===t.type)i.fire.call(l,r,u,e);else if("add"===t.type||void 0===u){const i=a.fire.call(l,r,t.values[o],e);null==r&&null!=i&&(r=i,t.keys[o]=r,n.outbound||A(t.values[o],n.keyPath,r))}else{const n=Rr(u,t.values[o]),i=s.fire.call(l,n,r,u,e);if(i){const e=t.values[o];Object.keys(i).forEach((t=>{f(e,t)?e[t]=i[t]:A(e,t,i[t])}))}}return l}));return r.mutate(t).then((({failures:e,results:r,numFailures:n,lastResult:i})=>{for(let n=0;n<o.length;++n){const i=r?r[n]:o[n],a=u[n];null==i?a.onerror&&a.onerror(e[n]):a.onsuccess&&a.onsuccess("put"===t.type&&c[n]?t.values[n]:i)}return{failures:e,results:r,numFailures:n,lastResult:i}})).catch((t=>(u.forEach((e=>e.onerror&&e.onerror(t))),Promise.reject(t))))}))}function u(t,e,o){return r.query({trans:t,values:!1,query:{index:n,range:e},limit:o}).then((({result:r})=>c({type:"delete",keys:r,trans:t}).then((n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<o?{failures:[],numFailures:0,lastResult:void 0}:u(t,{...e,lower:r[r.length-1],lowerOpen:!0},o)))))}}};return o}})};function Ur(t,e,r){try{if(!e)return null;if(e.keys.length<t.length)return null;const n=[];for(let o=0,i=0;o<e.keys.length&&i<t.length;++o)0===Ze(e.keys[o],t[i])&&(n.push(r?M(e.values[o]):e.values[o]),++i);return n.length===t.length?n:null}catch(t){return null}}const Gr={stack:"dbcore",level:-1,create:t=>({table:e=>{const r=t.table(e);return{...r,getMany:t=>{if(!t.cache)return r.getMany(t);const e=Ur(t.keys,t.trans._cache,"clone"===t.cache);return e?Bt.resolve(e):r.getMany(t).then((e=>(t.trans._cache={keys:t.keys,values:"clone"===t.cache?M(e):e},e)))},mutate:t=>("add"!==t.type&&(t.trans._cache=null),r.mutate(t))}}})};function Wr(t){return!("from"in t)}const Vr=function(t,e){if(!this){const e=new Vr;return t&&"d"in t&&c(e,t),e}c(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Zr(t,e,r){const n=Ze(e,r);if(isNaN(n))return;if(n>0)throw RangeError();if(Wr(t))return c(t,{from:e,to:r,d:1});const o=t.l,i=t.r;if(Ze(r,t.from)<0)return o?Zr(o,e,r):t.l={from:e,to:r,d:1,l:null,r:null},Kr(t);if(Ze(e,t.to)>0)return i?Zr(i,e,r):t.r={from:e,to:r,d:1,l:null,r:null},Kr(t);Ze(e,t.from)<0&&(t.from=e,t.l=null,t.d=i?i.d+1:1),Ze(r,t.to)>0&&(t.to=r,t.r=null,t.d=t.l?t.l.d+1:1);const a=!t.r;o&&!t.l&&$r(t,o),i&&a&&$r(t,i)}function $r(t,e){Wr(e)||function t(e,{from:r,to:n,l:o,r:i}){Zr(e,r,n),o&&t(e,o),i&&t(e,i)}(t,e)}function Yr(t){let e=Wr(t)?null:{s:0,n:t};return{next(t){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&Ze(t,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||Ze(t,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Kr(t){var e,r;const n=((null===(e=t.r)||void 0===e?void 0:e.d)||0)-((null===(r=t.l)||void 0===r?void 0:r.d)||0),o=n>1?"r":n<-1?"l":"";if(o){const e="r"===o?"l":"r",r={...t},n=t[o];t.from=n.from,t.to=n.to,t[o]=n[o],r[o]=n[e],t[e]=r,r.d=Hr(r)}t.d=Hr(t)}function Hr({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}h(Vr.prototype,{add(t){return $r(this,t),this},addKey(t){return Zr(this,t,t),this},addKeys(t){return t.forEach((t=>Zr(this,t,t))),this},[z](){return Yr(this)}});const qr={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,r=new Vr(t.MIN_KEY,t.MAX_KEY);return{...t,table:n=>{const o=t.table(n),{schema:i}=o,{primaryKey:c}=i,{extractKey:u,outbound:l}=c,f={...o,mutate:t=>{const a=t.trans,c=a.mutatedParts||(a.mutatedParts={}),u=t=>{const r=`idb://${e}/${n}/${t}`;return c[r]||(c[r]=new Vr)},l=u(""),f=u(":dels"),{type:h}=t;let[d,p]="deleteRange"===t.type?[t.range]:"delete"===t.type?[t.keys]:t.values.length<50?[[],t.values]:[];const y=t.trans._cache;return o.mutate(t).then((t=>{if(s(d)){"delete"!==h&&(d=t.results),l.addKeys(d);const e=Ur(d,y);e||"add"===h||f.addKeys(d),(e||p)&&function(t,e,r,n){e.indexes.forEach((function(e){const o=t(e.name||"");function i(t){return null!=t?e.extractKey(t):null}const a=t=>e.multiEntry&&s(t)?t.forEach((t=>o.addKey(t))):o.addKey(t);(r||n).forEach(((t,e)=>{const o=r&&i(r[e]),s=n&&i(n[e]);0!==Ze(o,s)&&(null!=o&&a(o),null!=s&&a(s))}))}))}(u,i,e,p)}else if(d){const t={from:d.lower,to:d.upper};f.add(t),l.add(t)}else l.add(r),f.add(r),i.indexes.forEach((t=>u(t.name).add(r)));return t}))}},h=({query:{index:e,range:r}})=>{var n,o;return[e,new Vr(null!==(n=r.lower)&&void 0!==n?n:t.MIN_KEY,null!==(o=r.upper)&&void 0!==o?o:t.MAX_KEY)]},d={get:t=>[c,new Vr(t.key)],getMany:t=>[c,(new Vr).addKeys(t.keys)],count:h,query:h,openCursor:h};return a(d).forEach((t=>{f[t]=function(i){const{subscr:a}=Ct;if(a){const s=t=>{const r=`idb://${e}/${n}/${t}`;return a[r]||(a[r]=new Vr)},c=s(""),f=s(":dels"),[h,p]=d[t](i);if(s(h.name||"").add(p),!h.isPrimaryKey){if("count"!==t){const e="query"===t&&l&&i.values&&o.query({...i,values:!1});return o[t].apply(this,arguments).then((r=>{if("query"===t){if(l&&i.values)return e.then((({result:t})=>(c.addKeys(t),r)));const t=i.values?r.result.map(u):r.result;i.values?c.addKeys(t):f.addKeys(t)}else if("openCursor"===t){const t=r,e=i.values;return t&&Object.create(t,{key:{get:()=>(f.addKey(t.primaryKey),t.key)},primaryKey:{get(){const e=t.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(t.primaryKey),t.value)}})}return r}))}f.add(r)}}return o[t].apply(this,arguments)}})),f}}}};class Xr{constructor(t,e){this._middlewares={},this.verno=0;const r=Xr.dependencies;this._options=e={addons:Xr.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...e},this._deps={indexedDB:e.indexedDB,IDBKeyRange:e.IDBKeyRange};const{addons:n}=e;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:it,dbReadyPromise:null,cancelOpen:it,openCanceller:null,autoSchema:!0};var i;o.dbReadyPromise=new Bt((t=>{o.dbReadyResolve=t})),o.openCanceller=new Bt(((t,e)=>{o.cancelOpen=e})),this._state=o,this.name=t,this.on=ze(this,"populate","blocked","versionchange","close",{ready:[dt,it]}),this.on.ready.subscribe=w(this.on.ready.subscribe,(t=>(e,r)=>{Xr.vip((()=>{const n=this._state;if(n.openComplete)n.dbOpenError||Bt.resolve().then(e),r&&t(e);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(e),r&&t(e);else{t(e);const n=this;r||t((function t(){n.on.ready.unsubscribe(e),n.on.ready.unsubscribe(t)}))}}))})),this.Collection=(i=this,De(Ke.prototype,(function(t,e){this.db=i;let r=je,n=null;if(e)try{r=e()}catch(t){n=t}const o=t._ctx,a=o.table,s=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:r,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:n,or:o.or,valueMapper:s!==at?s:null}}))),this.Table=function(t){return De(Be.prototype,(function(e,r,n){this.db=t,this._tx=n,this.name=e,this.schema=r,this.hook=t._allTables[e]?t._allTables[e].hook:ze(null,{creating:[ut,it],reading:[st,at],updating:[ft,it],deleting:[lt,it]})}))}(this),this.Transaction=function(t){return De(lr.prototype,(function(e,r,n,o,i){this.db=t,this.mode=e,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=ze(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Bt(((t,e)=>{this._resolve=t,this._reject=e})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(t=>{var e=this.active;return this.active=!1,this.on.error.fire(t),this.parent?this.parent._reject(t):e&&this.idbtrans&&this.idbtrans.abort(),me(t)}))}))}(this),this.Version=function(t){return De(Or.prototype,(function(e){this.db=t,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(t){return De(or.prototype,(function(e,r,n){this.db=t,this._ctx={table:e,index:":id"===r?null:r,or:n};const o=t._deps.indexedDB;if(!o)throw new rt.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(t,e)=>o.cmp(e,t),this._max=(t,e)=>o.cmp(t,e)>0?t:e,this._min=(t,e)=>o.cmp(t,e)<0?t:e,this._IDBKeyRange=t._deps.IDBKeyRange}))}(this),this.on("versionchange",(t=>{t.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(t=>{!t.newVersion||t.newVersion<t.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${t.oldVersion/10}`)})),this._maxKey=pr(e.IDBKeyRange),this._createTransaction=(t,e,r,n)=>new this.Transaction(t,e,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=t=>{this.on("blocked").fire(t),Ee.filter((t=>t.name===this.name&&t!==this&&!t._state.vcFired)).map((e=>e.on("versionchange").fire(t)))},this.use(Nr),this.use(Fr),this.use(qr),this.use(Gr),this.vip=Object.create(this,{_vip:{value:!0}}),n.forEach((t=>t(this)))}version(t){if(isNaN(t)||t<.1)throw new rt.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new rt.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const e=this._versions;var r=e.filter((e=>e._cfg.version===t))[0];return r||(r=new this.Version(t),e.push(r),e.sort(_r),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(t){return this.idbdb&&(this._state.openComplete||Ct.letThrough||this._vip)?t():new Bt(((t,e)=>{if(this._state.openComplete)return e(new rt.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void e(new rt.DatabaseClosed);this.open().catch(it)}this._state.dbReadyPromise.then(t,e)})).then(t)}use({stack:t,create:e,level:r,name:n}){n&&this.unuse({stack:t,name:n});const o=this._middlewares[t]||(this._middlewares[t]=[]);return o.push({stack:t,create:e,level:null==r?10:r,name:n}),o.sort(((t,e)=>t.level-e.level)),this}unuse({stack:t,name:e,create:r}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter((t=>r?t.create!==r:!!e&&t.name!==e))),this}open(){return jr(this)}_close(){const t=this._state,e=Ee.indexOf(this);if(e>=0&&Ee.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(t){}this._novip.idbdb=null}t.dbReadyPromise=new Bt((e=>{t.dbReadyResolve=e})),t.openCanceller=new Bt(((e,r)=>{t.cancelOpen=r}))}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new rt.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,e=this._state;return new Bt(((r,n)=>{const o=()=>{this.close();var t=this._deps.indexedDB.deleteDatabase(this.name);t.onsuccess=qt((()=>{!function({indexedDB:t,IDBKeyRange:e},r){!Tr(t)&&r!==Pe&&Pr(t,e).delete(r).catch(it)}(this._deps,this.name),r()})),t.onerror=ir(n),t.onblocked=this._fireOnBlocked};if(t)throw new rt.InvalidArgument("Arguments not allowed in db.delete()");e.isBeingOpened?e.dbReadyPromise.then(o):o()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const t=this._state.dbOpenError;return t&&"DatabaseClosed"===t.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return a(this._allTables).map((t=>this._allTables[t]))}transaction(){const t=Br.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,e,r){let n=Ct.trans;n&&n.db===this&&-1===t.indexOf("!")||(n=null);const o=-1!==t.indexOf("?");let i,a;t=t.replace("!","").replace("?","");try{if(a=e.map((t=>{var e=t instanceof this.Table?t.name:t;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e})),"r"==t||t===Te)i=Te;else{if("rw"!=t&&t!=Ce)throw new rt.InvalidArgument("Invalid transaction mode: "+t);i=Ce}if(n){if(n.mode===Te&&i===Ce){if(!o)throw new rt.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");n=null}n&&a.forEach((t=>{if(n&&-1===n.storeNames.indexOf(t)){if(!o)throw new rt.SubTransaction("Table "+t+" not included in parent transaction.");n=null}})),o&&n&&!n.active&&(n=null)}}catch(t){return n?n._promise(null,((e,r)=>{r(t)})):me(t)}const s=zr.bind(null,this,i,a,n,r);return n?n._promise(i,s,"lock"):Ct.trans?fe(Ct.transless,(()=>this._whenReady(s))):this._whenReady(s)}table(t){if(!f(this._allTables,t))throw new rt.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const Jr="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class Qr{constructor(t){this._subscribe=t}subscribe(t,e,r){return this._subscribe(t&&"function"!=typeof t?t:{next:t,error:e,complete:r})}[Jr](){return this}}function tn(t,e){return a(e).forEach((r=>{$r(t[r]||(t[r]=new Vr),e[r])})),t}let en;try{en={indexedDB:i.indexedDB||i.mozIndexedDB||i.webkitIndexedDB||i.msIndexedDB,IDBKeyRange:i.IDBKeyRange||i.webkitIDBKeyRange}}catch(t){en={indexedDB:null,IDBKeyRange:null}}const rn=Xr;function nn(t){let e=on;try{on=!0,ur.storagemutated.fire(t)}finally{on=e}}h(rn,{...ot,delete:t=>new rn(t,{addons:[]}).delete(),exists:t=>new rn(t,{addons:[]}).open().then((t=>(t.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(t){try{return function({indexedDB:t,IDBKeyRange:e}){return Tr(t)?Promise.resolve(t.databases()).then((t=>t.map((t=>t.name)).filter((t=>t!==Pe)))):Pr(t,e).toCollection().primaryKeys()}(rn.dependencies).then(t)}catch(t){return me(new rt.MissingAPI)}},defineClass:()=>function(t){c(this,t)},ignoreTransaction:t=>Ct.trans?fe(Ct.transless,t):t(),vip:Cr,async:function(t){return function(){try{var e=Ir(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Bt.resolve(e)}catch(t){return me(t)}}},spawn:function(t,e,r){try{var n=Ir(t.apply(r,e||[]));return n&&"function"==typeof n.then?n:Bt.resolve(n)}catch(t){return me(t)}},currentTransaction:{get:()=>Ct.trans||null},waitFor:function(t,e){const r=Bt.resolve("function"==typeof t?rn.ignoreTransaction(t):t).timeout(e||6e4);return Ct.trans?Ct.trans.waitFor(r):r},Promise:Bt,debug:{get:()=>U,set:t=>{G(t,"dexie"===t?()=>!0:Oe)}},derive:y,extend:c,props:h,override:w,Events:ze,on:ur,liveQuery:function(t){return new Qr((e=>{const r=F(t);let n=!1,o={},i={};const s={get closed(){return n},unsubscribe:()=>{n=!0,ur.storagemutated.unsubscribe(f)}};e.start&&e.start(s);let c=!1,u=!1;function l(){return a(i).some((t=>o[t]&&function(t,e){const r=Yr(e);let n=r.next();if(n.done)return!1;let o=n.value;const i=Yr(t);let a=i.next(o.from),s=a.value;for(;!n.done&&!a.done;){if(Ze(s.from,o.to)<=0&&Ze(s.to,o.from)>=0)return!0;Ze(o.from,s.from)<0?o=(n=r.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[t],i[t])))}const f=t=>{tn(o,t),l()&&h()},h=()=>{if(c||n)return;o={};const a={},d=function(e){r&&oe();const n=()=>ne(t,{subscr:e,trans:null}),o=Ct.trans?fe(Ct.transless,n):n();return r&&o.then(ie,ie),o}(a);u||(ur(sr,f),u=!0),c=!0,Promise.resolve(d).then((t=>{c=!1,n||(l()?h():(o={},i=a,e.next&&e.next(t)))}),(t=>{c=!1,e.error&&e.error(t),s.unsubscribe()}))};return h(),s}))},extendObservabilitySet:tn,getByKeyPath:E,setByKeyPath:A,delByKeyPath:function(t,e){"string"==typeof e?A(t,e,void 0):"length"in e&&[].map.call(e,(function(e){A(t,e,void 0)}))},shallowClone:S,deepClone:M,getObjectDiff:Rr,cmp:Ze,asap:_,minKey:xe,addons:[],connections:Ee,errnames:tt,dependencies:en,semVer:be,version:be.split(".").map((t=>parseInt(t))).reduce(((t,e,r)=>t+e/Math.pow(10,2*r)))}),rn.maxKey=pr(rn.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(ur(sr,(t=>{if(!on){let e;Ae?(e=document.createEvent("CustomEvent"),e.initCustomEvent(cr,!0,!0,t)):e=new CustomEvent(cr,{detail:t}),on=!0,dispatchEvent(e),on=!1}})),addEventListener(cr,(({detail:t})=>{on||nn(t)})));let on=!1;if("undefined"!=typeof BroadcastChannel){const t=new BroadcastChannel(cr);ur(sr,(e=>{on||t.postMessage(e)})),t.onmessage=t=>{t.data&&nn(t.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){ur(sr,(t=>{try{on||("undefined"!=typeof localStorage&&localStorage.setItem(cr,JSON.stringify({trig:Math.random(),changedParts:t})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((e=>e.postMessage({type:cr,changedParts:t}))))}catch(t){}})),addEventListener("storage",(t=>{if(t.key===cr){const e=JSON.parse(t.newValue);e&&nn(e.changedParts)}}));const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",(function({data:t}){t&&t.type===cr&&nn(t.changedParts)}))}function an(t){return an="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},an(t)}function sn(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function cn(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?sn(Object(r),!0).forEach((function(e){pn(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sn(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function un(){un=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==an(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ln(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function fn(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ln(i,n,o,a,s,"next",t)}function s(t){ln(i,n,o,a,s,"throw",t)}a(void 0)}))}}function hn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function dn(t,e,r){return e&&hn(t.prototype,e),r&&hn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function pn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Bt.rejectionMapper=function(t,e){if(!t||t instanceof q||t instanceof TypeError||t instanceof SyntaxError||!t.name||!nt[t.name])return t;var r=new nt[t.name](e||t.message,t);return"stack"in t&&p(r,"stack",{get:function(){return this.inner.stack}}),r},G(U,Oe);var yn=dn((function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),pn(this,"dbGet",function(){var t=fn(un().mark((function t(r,n){return un().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.db[r].get(n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),pn(this,"dbAdd",function(){var t=fn(un().mark((function t(r,n){return un().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.db[r].add(cn({},n));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),pn(this,"dbUpdate",function(){var t=fn(un().mark((function t(r,n,o){return un().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.db[r].update(n,cn({},o));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}()),pn(this,"dbRemove",function(){var t=fn(un().mark((function t(r,n){return un().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.db[r].delete(n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),this.db=new Xr("hyperspace"),this.db.version(1).stores({tileset:"++id, name, creator, type, checksum, signature, timestamp",inventory:"++id, name, creator, type, checksum, signature, timestamp",spirits:"++id, name, creator, type, checksum, signature, timestamp",abilities:"++id, name, creator, type checksum, signature, timestamp",models:"++id, name, creator, type, checksum, signature, timestamp",accounts:"++id, name, type, checksum, signature, timestamp",dht:"++id, name, type, ip, checksum, signature, timestamp",msg:"++id, name, type, ip, checksum, signature, timestamp",tmp:"++id, key, value, timestamp"})}));function gn(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function mn(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?gn(Object(r),!0).forEach((function(e){wn(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):gn(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function vn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function bn(t,e,r){return e&&vn(t.prototype,e),r&&vn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function wn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var xn=bn((function t(){var e=this;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),wn(this,"all",(function(){return Object.assign({},e.store)})),wn(this,"keys",(function(){return Object.keys(e.store)})),wn(this,"values",(function(){return Object.keys(e.store).map((function(t){return e.store[t]}))})),wn(this,"size",(function(){return Object.keys(e.store).length})),wn(this,"get",(function(t){if(!e.store[t])throw"no key set";return e.store[t]})),wn(this,"add",(function(t,r){if(e.store[t])throw"key already exists";return e.store[t]=mn({},r)})),wn(this,"set",(function(t,r){return e.store[t]=mn({},r)})),wn(this,"delete",(function(t){return e.store[t]=null})),t._instance||(this.store={},t._instance=this),t._instance})),_n=r(5490),kn=r(9327),En=r(7122),An=r(7974);function Sn(t){return Sn="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},Sn(t)}function Ln(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function On(t,e){return On=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},On(t,e)}function Pn(t,e){if(e&&("object"===Sn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Tn(t)}function Tn(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Cn(t){return Cn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Cn(t)}var Mn=function(t){!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&&On(t,e)}(s,t);var e,r,n,o,i,a=(e=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,n=Cn(e);if(r){var o=Cn(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return Pn(this,t)});function s(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=a.call(this)).engine=e,r.src=t,r.glTexture=e.gl.createTexture(),r.image=new Image,r.image.onload=r.onImageLoaded.bind(Tn(r)),r.image.src=t,r.loaded=!1,r.onLoadActions=new An.Z,r}return n=s,(o=[{key:"onImageLoaded",value:function(){var t=this.engine.gl;t.bindTexture(t.TEXTURE_2D,this.glTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.bindTexture(t.TEXTURE_2D,null),this.loaded=!0,this.onLoadActions.run()}},{key:"attach",value:function(){var t=this.engine.gl;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.glTexture),t.uniform1i(this.engine.renderManager.shaderProgram.samplerUniform,0)}}])&&Ln(n.prototype,o),i&&Ln(n,i),Object.defineProperty(n,"prototype",{writable:!1}),s}(r(5849).Z);function jn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function In(t,e,r){return e&&jn(t.prototype,e),r&&jn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Bn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var zn=In((function t(e,r,n){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Bn(this,"runWhenLoaded",(function(t){o.loaded?t():o.onLoadActions.add(t)})),Bn(this,"loadImage",(function(){var t=o.engine.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,o.glTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o.canvas),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_NEAREST),t.generateMipmap(t.TEXTURE_2D),t.bindTexture(t.TEXTURE_2D,null),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),o.loaded=!0,o.onLoadActions.run()})),Bn(this,"attach",(function(){var t=o.engine.gl;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o.glTexture),t.uniform1i(o.engine.renderManager.shaderProgram.samplerUniform,0)})),Bn(this,"clearHud",(function(){var t=o.ctx;t.clearRect(0,0,t.canvas.width,t.canvas.height),o.loadImage()})),Bn(this,"writeText",(function(t,e,r){var n=o.ctx;n.save(),n.font="32px minecraftia",n.textAlign="center",n.textBaseline="middle",n.fillStyle="white",n.fillText(t,null!=e?e:n.canvas.width/2,null!=r?r:n.canvas.height/2),n.restore()})),Bn(this,"scrollText",(function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=new _n._C(o.ctx);return r.portrait?n.init(t,10,10,o.canvas.width-20-84,2*o.canvas.height/3-20,r):n.init(t,10,10,o.canvas.width-20,2*o.canvas.height/3-20,r),n.setOptions(r),e&&n.scroll((Math.sin((new Date).getTime()/3e3)+1)*n.maxScroll*.5),n.render(),n})),this.id=n,this.engine=r,this.canvas=e,this.ctx=e.getContext("2d"),this.glTexture=r.gl.createTexture(),this.loaded=!1,this.onLoadActions=new An.Z,this.loadImage()})),Dn=r(6345);function Nn(t){return Nn="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},Nn(t)}function Rn(){Rn=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==Nn(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Fn(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Un(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Gn(t,e,r){return e&&Un(t.prototype,e),r&&Un(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Wn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Vn=Gn((function t(e){var r=this;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Wn(this,"loadTexture",(function(t){return r.textures[t]||(r.textures[t]=new Mn(t,r.engine)),r.textures[t]})),Wn(this,"loadTextureFromZip",function(){var t,e=(t=Rn().mark((function t(e,n){var o,i,a,s;return Rn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.textures[e]){t.next=2;break}return t.abrupt("return",r.textures[e]);case 2:return t.next=4,n.file("textures/".concat(e)).async("arrayBuffer");case 4:return o=t.sent,i=new Uint8Array(o),a=new Blob([i.buffer]),s=URL.createObjectURL(a),r.textures[e]=new Mn(s,r.engine),t.abrupt("return",r.textures[e]);case 10:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Fn(i,n,o,a,s,"next",t)}function s(t){Fn(i,n,o,a,s,"throw",t)}a(void 0)}))});return function(t,r){return e.apply(this,arguments)}}()),Wn(this,"loadSpeech",(function(t,e){return r.speeches[t]||(r.speeches[t]=new zn(e,r.engine,t)),r.speeches[t]})),t._instance||(this.engine=e,this.objLoader=Dn.NQ,this.audioLoader=new En.m(this),this.textures={},this.speeches={},t._instance=this),t._instance}));function Zn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function $n(t,e,r){return e&&Zn(t.prototype,e),r&&Zn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Kn=$n((function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Yn(this,"register",(function(t,e){r.scenes[t]=Array.isArray(e)?e.slice():[]})),Yn(this,"start",(function(t){var e=r.scenes[t];e?(r.queue=e.slice(),r.active=!0,r._currentPromise=null,r.currentBackdrop=null,r.currentCutouts=[]):console.warn("Cutscene not found:",t)})),Yn(this,"skip",(function(){r.queue=[],r.active=!1})),Yn(this,"isRunning",(function(){return r.active})),Yn(this,"update",(function(){if(r.active&&!r._currentPromise){var t=r.queue.shift();if(t){var e;switch(t.type){case"action":e=r.runAction(t);break;case"wait":e=r.wait(t.ms||0);break;case"transition":e=r.transition(t);break;case"load_zone":e=r.loadZone(t);break;case"set_backdrop":e=r.setBackdrop(t);break;case"show_cutout":e=r.showCutout(t);break;default:console.warn("Unknown cutscene step:",t.type),e=Promise.resolve()}r._currentPromise=e,e.then((function(){r._currentPromise=null,r.update()}))}else r.active=!1}})),Yn(this,"wait",(function(t){return new Promise((function(e){return setTimeout(e,t)}))})),Yn(this,"transition",(function(t){var e=r.engine.renderManager;if(!e)return Promise.resolve();var n=t.effect||"fade",o=t.direction||"out",i=t.duration||500;return e.startTransition({effect:n,direction:o,duration:i})})),Yn(this,"runAction",(function(t){var e=t.action;return e?e():Promise.resolve()})),Yn(this,"loadZone",(function(t){var e=t.zone,n=t.remotely,o=void 0!==n&&n,i=t.zip;return e&&r.engine.spritz&&r.engine.spritz.world?(t.effect,t.duration,i?r.engine.spritz.world.loadZoneFromZip(e,i,!1,null):r.engine.spritz.world.loadZone(e,o,!1,null)):Promise.resolve()})),Yn(this,"setBackdrop",(function(t){return r.currentBackdrop=t.backdrop||null,Promise.resolve()})),Yn(this,"showCutout",(function(t){var e=t.sprite,n=t.cutout,o=t.position,i=void 0===o?"left":o;return e&&n&&(r.currentCutouts=r.currentCutouts.filter((function(t){return t.sprite!==e})),r.currentCutouts.push({sprite:e,cutout:n,position:i})),Promise.resolve()})),this.engine=e,this.scenes={},this.queue=[],this.active=!1,this._currentPromise=null,this.currentBackdrop=null,this.currentCutouts=[]})),Hn=r(1248);function qn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Xn=function(){function t(e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t._instance||(this.activeKeys=[],this.activeCodes=[],this.hooks=[],this.shift=!1,this.engine=e,t._instance=this),t._instance}var e,r;return e=t,r=[{key:"init",value:function(){window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}},{key:"onKeyDown",value:function(e){e.preventDefault();var r=String.fromCharCode(e.keyCode).toLowerCase();t._instance.activeKeys.indexOf(r)<0&&t._instance.activeKeys.push(r),t._instance.activeCodes.indexOf(e.key)<0&&t._instance.activeCodes.push(e.key),t._instance.shift=e.shiftKey;try{(t._instance.hooks||[]).forEach((function(t){return t(e,"down")}))}catch(t){}}},{key:"onKeyUp",value:function(e){var r=String.fromCharCode(e.keyCode).toLowerCase(),n=t._instance.activeKeys.indexOf(r);n>-1&&t._instance.activeKeys.splice(n,1),(n=t._instance.activeCodes.indexOf(e.key))>-1&&t._instance.activeCodes.splice(n,1),t._instance.shift=e.shiftKey;try{(t._instance.hooks||[]).forEach((function(t){return t(e,"up")}))}catch(t){}}},{key:"addHook",value:function(t){t&&(this.hooks=this.hooks||[],this.hooks.push(t))}},{key:"removeHook",value:function(t){if(t&&this.hooks){var e=this.hooks.indexOf(t);e>=0&&this.hooks.splice(e,1)}}},{key:"isKeyPressed",value:function(t){return this.activeKeys.includes(t.toLowerCase())}},{key:"isCodePressed",value:function(t){return this.activeCodes.includes(t)}},{key:"lastPressed",value:function(e){for(var r=e.toLowerCase(),n=null,o=-1,i=0;i<r.length;i++){var a=r[i],s=t._instance.activeKeys.indexOf(a);s>o&&(n=a,o=s)}return n}},{key:"lastPressedCode",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=null,n=e.toLowerCase();t._instance.activeCodes.length>0;)if(r=t._instance.activeCodes.pop(),-1===n.indexOf(r.toLowerCase()))return r;return null}},{key:"lastPressedKey",value:function(){return t._instance.activeKeys[t._instance.activeKeys.length-1]||null}}],r&&qn(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Jn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Qn=function(){function t(e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t._instance||(this.engine=e,this.buttons=[!1,!1,!1],this.position={x:0,y:0},this.movement={x:0,y:0},this._hooks=[],t._instance=this),t._instance}var e,r;return e=t,r=[{key:"init",value:function(){var t=this.engine.canvas;t.addEventListener("mousedown",this.onMouseDown.bind(this)),t.addEventListener("mouseup",this.onMouseUp.bind(this)),t.addEventListener("mousemove",this.onMouseMove.bind(this)),t.addEventListener("contextmenu",(function(t){return t.preventDefault()}))}},{key:"onMouseDown",value:function(t){t.preventDefault();var e=t.target,r=e.getBoundingClientRect(),n=e.width/r.width,o=e.height/r.height;this.position.x=(t.clientX-r.left)*n,this.position.y=(t.clientY-r.top)*o,t.button>=0&&t.button<3&&(this.buttons[t.button]=!0),this._notifyHooks(t,"down")}},{key:"onMouseUp",value:function(t){t.preventDefault();var e=t.target,r=e.getBoundingClientRect(),n=e.width/r.width,o=e.height/r.height;this.position.x=(t.clientX-r.left)*n,this.position.y=(t.clientY-r.top)*o,t.button>=0&&t.button<3&&(this.buttons[t.button]=!1),this._notifyHooks(t,"up")}},{key:"onMouseMove",value:function(t){var e=t.target,r=e.getBoundingClientRect(),n=e.width/r.width,o=e.height/r.height,i=(t.clientX-r.left)*n,a=(t.clientY-r.top)*o;this.movement.x=i-this.position.x,this.movement.y=a-this.position.y,this.position.x=i,this.position.y=a,this._notifyHooks(t,"move")}},{key:"_notifyHooks",value:function(t,e){try{this._hooks.forEach((function(r){try{r(t,e)}catch(t){}}))}catch(t){}}},{key:"isButtonPressed",value:function(t){return"string"==typeof t&&(t={left:0,middle:1,right:2}[t]),this.buttons[t]||!1}},{key:"getPosition",value:function(){return this.position}},{key:"getMovement",value:function(){return this.movement}},{key:"addHook",value:function(t){"function"==typeof t&&this._hooks.push(t)}},{key:"removeHook",value:function(t){var e=this._hooks.indexOf(t);e>=0&&this._hooks.splice(e,1)}}],r&&Jn(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function to(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function eo(t,e,r){return e&&to(t.prototype,e),r&&to(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ro(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var no=eo((function t(e,r,n,o,i,a){var s=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ro(this,"init",(function(){var t=s.layout,e=s.width;s.x=e-t.x,s.y=t.y+3*s.radius/8,s.dx=s.x,s.dy=s.y,s.gamepad.map["x-dir"]=0,s.gamepad.map["y-dir"]=0,s.gamepad.map["x-axis"]=0,s.gamepad.map["y-axis"]=0})),ro(this,"draw",(function(){var t=s.ctx;t.fillStyle=s.colours.joystick.base,t.beginPath(),t.arc(s.x,s.y,s.radius,0,2*Math.PI,!1),t.fill(),t.closePath(),t.fillStyle=s.colours.joystick.dust,t.beginPath(),t.arc(s.x,s.y,s.radius-5,0,2*Math.PI,!1),t.fill(),t.closePath(),t.fillStyle=s.colours.joystick.stick,t.beginPath(),t.arc(s.x,s.y,10,0,2*Math.PI,!1),t.fill(),t.closePath(),t.fillStyle=s.colours.joystick.ball,t.beginPath(),t.arc(s.dx,s.dy,s.radius-10,0,2*Math.PI,!1),t.fill(),t.closePath()})),ro(this,"state",(function(t,e){var r=s.gamepad,n=r.touches,o=r.map,i=r.checkInput,a=n[t].x,c=n[t].y,u=parseInt(a-s.x),l=parseInt(c-s.y),f=parseInt(Math.sqrt(u*u+l*l));f<1.2*s.radius&&(e?"mousedown"===e&&(n[t].id="stick"):n[t].id="stick"),f<2.5*s.radius&&(e?"stick"==n[t].id&&"mouseup"===e&&(delete n[t].id,s.reset()):n[t].id="stick"),"stick"==n[t].id&&(Math.abs(parseInt(u))<s.radius/2&&(s.dx=s.x+u),Math.abs(parseInt(l))<s.radius/2&&(s.dy=s.y+l),o["x-axis"]=(s.dx-s.x)/(s.radius/2),o["y-axis"]=(s.dy-s.y)/(s.radius/2),o["x-dir"]=Math.round(o["x-axis"]),o["y-dir"]=Math.round(o["y-axis"]),f>2.5*s.radius&&(s.reset(),delete n[t].id),"function"==typeof i&&s.gamepad.checkInput())})),ro(this,"reset",(function(){var t=s.gamepad.map;s.dx=s.x,s.dy=s.y,t["x-dir"]=0,t["y-dir"]=0,t["x-axis"]=0,t["y-axis"]=0})),this.ctx=e,this.gamepad=a,this.width=e.canvas.width,this.height=e.canvas.height,this.layout=r,this.touches=n,this.radius=i,this.x=0,this.y=0,this.dx=0,this.dy=0,this.gamepad.map["x-dir"]=0,this.gamepad.map["y-dir"]=0,this.gamepad.map["x-axis"]=0,this.gamepad.map["y-axis"]=0,this.colours=o}));function oo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}CanvasRenderingContext2D.prototype.roundRect=function(t,e,r,n,o){return r<2*o&&(o=r/2),n<2*o&&(o=n/2),this.beginPath(),this.moveTo(t+o,e),this.arcTo(t+r,e,t+r,e+n,o),this.arcTo(t+r,e+n,t,e+n,o),this.arcTo(t,e+n,t,e,o),this.arcTo(t,e,t+r,e,o),this.closePath(),this};var io=function(){function t(e,r,n,o,i,a,s,c){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ctx=e,this.gamepad=c,this.layout=r,this.radius=s,this.touches=n,this.start=o,this.select=i,this.colours=a}var e,r;return e=t,r=[{key:"init",value:function(){for(var t=this.layout,e=this.ctx,r=this.gamepad.buttonsLayout,n=e.canvas.width,o=0;o<r.length;o++){var i=r[o],a=t.x-i.x,s=t.y-i.y;if(i.r){var c=i.r;r[o].hit={x:[a-c,a+2*c],y:[s-c,s+2*c],active:!1}}else{if(i.x=n/3-i.w,this.start&&this.select)switch(i.name){case"select":i.x=n/2-i.w-2*i.h;break;case"start":i.x=n/2}a=i.x,s=t.y-i.y,r[o].hit={x:[a,a+i.w],y:[s,s+i.h],active:!1}}this.gamepad.map[i.name]=0}}},{key:"draw",value:function(){for(var t=this.ctx,e=this.layout,r=0;r<this.gamepad.buttonsLayout.length;r++){var n=this.gamepad.buttonsLayout[r],o=n.color,i=e.x-n.x,a=e.y-n.y;if(n.dx=i,n.dy=a,n.r){var s=n.r;n.hit&&n.hit.active&&(t.fillStyle=o,t.beginPath(),t.arc(i,a,s+5,0,2*Math.PI,!1),t.fill(),t.closePath()),t.fillStyle=o,t.beginPath(),t.arc(i,a,s,0,2*Math.PI,!1),t.fill(),t.closePath(),t.strokeStyle=o,t.lineWidth=2,t.stroke(),t.fillStyle="rgba(255,255,255,1)",t.textAlign="center",t.textBaseline="middle",t.font="minecraftia 12px",t.fillText(n.name,i,a)}else{var c=n.w,u=n.h;i=isNaN(n.x)?t.canvas.width/2:n.x,s=10,t.fillStyle=o,n.hit&&n.hit.active&&t.roundRect(i-5,a-5,c+10,u+10,2*s).fill(),t.roundRect(i,a,c,u,s).fill(),t.strokeStyle=o,t.lineWidth=2,t.stroke(),t.fillStyle="rgba(0,0,0,0.5)",t.textAlign="center",t.textBaseline="middle",t.font="minecraftia 12px",t.fillText(n.name,i+c/2,a+2*u)}n.key&&(t.fillStyle="rgba(0,0,0,0.25)",t.textAlign="center",t.textBaseline="middle",t.font="minecraftia 12px","start"!=n.name&&"select"!=n.name||(i+=c/2),t.fillText(n.key,i,a-1.5*s))}}},{key:"state",value:function(t,e,r){var n=this.gamepad,o=n.touches,i=n.checkInput,a=n.width;if("stick"!=o[t].id){var s={x:o[t].x,y:o[t].y},c=this.gamepad.buttonsLayout[e],u=c.name,l=parseInt(s.x-c.dx),f=parseInt(s.y-c.dy),h=a;if(c.r?h=parseInt(Math.sqrt(l*l+f*f)):s.x>c.hit.x[0]&&s.x<c.hit.x[1]&&s.y>c.hit.y[0]&&s.y<c.hit.y[1]&&(h=0),h<this.radius&&"stick"!=o[t].id)if(r)switch(r){case"mousedown":o[t].id=u;break;case"mouseup":delete o[t].id,this.reset(e)}else o[t].id=u;o[t].id==u&&(this.gamepad.map[u]=1,c.hit.active=!0,h>this.radius&&(c.hit.active=!1,this.gamepad.map[u]=0,delete o[t].id),"function"==typeof i&&this.gamepad.checkInput())}}},{key:"reset",value:function(t){this.gamepad.buttonsLayout[t].hit.active=!1,this.gamepad.map[this.gamepad.buttonsLayout[t].name]=0}}],r&&oo(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function ao(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var so=function(){function t(e,r,n,o,i,a,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ctx=e,this.gamepad=s,this.width=e.canvas.width,this.height=e.canvas.height,this.radius=e.canvas.width/10,this.touches=n,this.start=o,this.select=i,this.buttonOffset=r,this.colours=a,this.layout={x:this.width-this.buttonOffset.x,y:this.height-this.buttonOffset.y},this.stick=new no(this.ctx,this.layout,this.touches,this.colours,this.radius,this.gamepad),this.buttons=new io(this.ctx,this.layout,this.touches,this.start,this.select,this.colours,this.radius,this.gamepad)}var e,r;return e=t,(r=[{key:"init",value:function(){this.stick.init(),this.buttons.init()}},{key:"draw",value:function(){this.stick.draw(),this.buttons.draw()}}])&&ao(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function co(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var uo=function(){function t(e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t._instance||(this.engine=e,this.dirty=!0,this.showTrace=!0,this.showDebug=!0,this.opacity=.4,this.font="minecraftia",this.start=!1,this.select=!1,this.touches={},this.lastKey=(new Date).getTime(),this.listeners=[],this.map={},this.x=0,this.y=0,this.colours={red:"rgba(255,0,0,".concat(this.opacity,")"),green:"rgba(5,220,30,".concat(this.opacity,")"),blue:"rgba(5,30,220,".concat(this.opacity,")"),purple:"rgba(240,5,240,".concat(this.opacity,")"),yellow:"rgba(240,240,5,".concat(this.opacity,")"),cyan:"rgba(5,240,240,".concat(this.opacity,")"),black:"rgba(5,5,5,".concat(this.opacity,")"),white:"rgba(250,250,250,".concat(this.opacity,")"),joystick:{base:"rgba(0,0,0,".concat(this.opacity,")"),dust:"rgba(0,0,0,".concat(this.opacity,")"),stick:"rgba(214,214,214,1)",ball:"rgba(245,245,245,1)"}},t._instance=this),t._instance}var e,r;return e=t,r=[{key:"init",value:function(){this.fontSize=this.engine.gp.canvas.width/12,this.radius=this.engine.gp.canvas.width/12,this.buttonOffset={x:2.5*this.radius,y:105};var t=[{x:-this.radius-this.radius/2+this.radius/4,y:-this.radius/4,r:3/4*this.radius,color:this.colours.red,name:"b"},{x:this.radius-this.radius/2,y:-(this.radius+this.radius/2),r:3/4*this.radius,color:this.colours.green,name:"a"},{x:this.radius-this.radius/2,y:this.radius,r:3/4*this.radius,color:this.colours.blue,name:"x"},{x:3*this.radius-this.radius/2-this.radius/4,y:0-this.radius/4,r:3/4*this.radius,color:this.colours.yellow,name:"y"}];this.start&&t.push({color:this.colours.black,y:-55,w:50,h:15,name:"start"}),this.select&&t.push({y:-55,w:50,h:15,color:this.colours.black,name:"select"}),this.buttonsLayout=t,this.controller=new so(this.engine.gp,this.buttonOffset,this.touches,this.start,this.select,this.colours,this),this.initOptions()}},{key:"initOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setOptions(t),this.resize(),this.loadCanvas()}},{key:"attachListener",value:function(t){return this.listeners.push(t)}},{key:"removeListener",value:function(t){this.listeners.splice(t-1,1)}},{key:"checkInput",value:function(){return this.map}},{key:"resize",value:function(){this.width=this.engine.gp.canvas.width,this.height=this.engine.gp.canvas.height,this.controller.init()}},{key:"loadCanvas",value:function(){var t=this,e=this.controller,r=this.width,n=this.height;this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="center",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 14px",this.engine.gp.fillText("loading",r/2,n/2),e.stick.draw(),e.buttons.draw(),window.addEventListener("resize",(function(){return t.resize()})),setTimeout((function(){this.ready=!0}),250)}},{key:"setOptions",value:function(t){var e=this;Object.keys(this).forEach((function(r){void 0!==t[r]&&(e[r]=t[r],e.dirty=!0)}))}},{key:"debounce",value:function(){var t=this.controller,e=this.buttonsLayout,r=this.lastKey;this.lastKey=(new Date).getTime()+100;for(var n=0;n<e.length;n++)t.buttons.reset(n);return r<this.lastKey}},{key:"keyPressed",value:function(t){return 1===this.map[t]&&this.debounce()}},{key:"listen",value:function(t){var e,r=this.touches,n=this.controller,o=this.buttonsLayout;if(t.type){var i=t.type;-1!=t.type.indexOf("mouse")&&(t.identifier="desktop",t={touches:[t]});var a=this.getPosition(this.engine.gp.canvas);this.listeners.map((function(e){if(e[i])return e[i](t)}));for(var s=0;s<(t.touches.length>5?5:t.touches.length);s++)r[c=t.touches[s].identifier]?(r[c].x=t.touches[s].pageX-a.x,r[c].y=t.touches[s].pageY-a.y):r[c]={x:t.touches[s].pageX-a.x,y:t.touches[s].pageY-a.y,leftClick:!1,rightClick:!1};for(var c in r)switch(i){case"touchstart":case"touchmove":if(this.disableScroll(),n.stick.state(c),(new Date).getTime()>this.lastKey+150){for(s=0;s<o.length;s++)n.buttons.state(c,s);this.lastKey=(new Date).getTime()}break;case"touchend":for(s=0;s<o.length;s++)n.buttons.reset(s);break;case"mousemove":r[c].leftClick,this.x=r[c].x,this.y=r[c].y;break;case"mousedown":t.touches&&null!==(e=t.touches[0])&&void 0!==e&&e.which?(r[c].leftClick=1===t.touches[0].which,r[c].rightClick=3===t.touches[0].which):"button"in t&&(r[c].leftClick=1==t.button,r[c].rightClick=2==t.button),n.stick.state(c,i);for(s=0;s<o.length;s++)n.buttons.state(c,s,i);break;case"mouseup":for(n.stick.state(c,i),s=0;s<o.length;s++)n.buttons.state(c,s,i);r[c].leftClick=0,r[c].rightClick=0}if("touchend"==t.type){for("stick"==r[c=t.changedTouches[0].identifier].id&&n.stick.reset(),s=0;s<o.length;s++)r[c].id==o[s].name&&n.buttons.reset(s);if(r[c]&&delete r[c],t.changedTouches.length>t.touches.length){var u=0,l=t.changedTouches.length-t.touches.length;for(var c in r)u>=l&&delete r[c],u++}if(0==t.touches.length){for(r={},s=0;s<o.length;s++)n.buttons.reset(s);n.stick.reset()}this.enableScroll()}}else{var f=t,h=0;for(var d in f){switch(d){case"%":f[d]&&(h+=1);break;case"&":f[d]&&(h+=2);break;case"'":f[d]&&(h+=4);break;case"(":f[d]&&(h+=8);break;default:if(f[d])for(s=0;s<o.length;s++)o[s].key&&o[s].key==d&&(r[o[s].name]={id:o[s].name,x:o[s].hit.x[0]+o[s].w/2,y:o[s].hit.y[0]+o[s].h/2},n.buttons.state(o[s].name,s,"mousedown"));else if(!f[d]){for(s=0;s<o.length;s++)o[s].key&&o[s].key==d&&(n.buttons.reset(s),delete r[o[s].name]);delete f[d]}}switch(n.stick.dx=n.stick.x,n.stick.dy=n.stick.y,h){case 1:n.stick.dx=n.stick.x-n.stick.radius/2;break;case 2:n.stick.dy=n.stick.y-n.stick.radius/2;break;case 3:n.stick.dx=n.stick.x-n.stick.radius/2,n.stick.dy=n.stick.y-n.stick.radius/2;break;case 4:n.stick.dx=n.stick.x+n.stick.radius/2;break;case 6:n.stick.dx=n.stick.x+n.stick.radius/2,n.stick.dy=n.stick.y-n.stick.radius/2;break;case 8:n.stick.dy=n.stick.y+n.stick.radius/2;break;case 9:n.stick.dx=n.stick.x-n.stick.radius/2,n.stick.dy=n.stick.y+n.stick.radius/2;break;case 12:n.stick.dx=n.stick.x+n.stick.radius/2,n.stick.dy=n.stick.y+n.stick.radius/2;break;default:n.stick.dx=n.stick.x,n.stick.dy=n.stick.y}0!=h?(r.stick={id:"stick"},n.stick.state("stick","mousemove")):(n.stick.reset(),delete r.stick)}}return this.map}},{key:"render",value:function(){this.engine.gp.clearRect(0,0,this.engine.gp.canvas.width,this.engine.gp.canvas.height),this.showDebug&&this.debug(),this.showTrace&&this.trace(),this.controller.stick.draw(),this.controller.buttons.draw()}},{key:"debug",value:function(){this.gp,this.map;var t=this.touches;for(var e in this.dy=30,this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="left",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 20px",this.engine.gp.fillText("debug",10,this.dy),this.engine.gp.font="minecraftia 14px",this.dy+=5,t){this.dy+=10;var r=e+" : "+JSON.stringify(t[e]).slice(1,-1);this.engine.gp.fillText(r,10,this.dy)}}},{key:"trace",value:function(){var t=this.map;for(var e in this.dy=30,this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="right",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 20px",this.engine.gp.fillText("trace",this.width-10,this.dy),this.engine.gp.font="minecraftia 14px",this.dy+=5,t){this.dy+=10;var r=e+" : "+t[e];this.engine.gp.fillText(r,this.width-10,this.dy)}}},{key:"getPosition",value:function(t){for(var e=0,r=0;t;)e+=t.offsetLeft-t.scrollLeft+t.clientLeft,r+=t.offsetTop-t.scrollTop+t.clientTop,t=t.offsetParent;return{x:e,y:r}}},{key:"enableScroll",value:function(){document.body.removeEventListener("touchmove",this.preventDefault)}},{key:"disableScroll",value:function(){document.body.addEventListener("touchmove",this.preventDefault,{passive:!1})}},{key:"preventDefault",value:function(t){t.preventDefault(),t.stopPropagation()}}],r&&co(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function lo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var fo=function(){function t(e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t._instance||(this.engine=e,this.touches=[],this.gestures={},this.hooks=[],this.startTime=0,this.startPos={x:0,y:0},t._instance=this),t._instance}var e,r;return e=t,r=[{key:"init",value:function(){var t=this.engine.canvas;t.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),t.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),t.addEventListener("touchend",this.onTouchEnd.bind(this),{passive:!1})}},{key:"onTouchStart",value:function(t){if(t.preventDefault(),this.touches=Array.from(t.touches),1===this.touches.length){var e=this.touches[0];this.startTime=Date.now(),this.startPos={x:e.clientX,y:e.clientY}}this._notifyHooks(t,"start")}},{key:"onTouchMove",value:function(t){t.preventDefault(),this.touches=Array.from(t.touches),this._notifyHooks(t,"move")}},{key:"onTouchEnd",value:function(t){var e=this;if(t.preventDefault(),this.touches=Array.from(t.touches),0===this.touches.length&&this.startTime>0){var r=Date.now()-this.startTime,n=t.changedTouches[0],o={x:n.clientX,y:n.clientY},i=o.x-this.startPos.x,a=o.y-this.startPos.y,s=Math.sqrt(i*i+a*a);r<300&&s<10?(this.gestures.tap=!0,setTimeout((function(){return delete e.gestures.tap}),100)):Math.abs(i)>Math.abs(a)&&Math.abs(i)>50?i>0?(this.gestures.swipe_right=!0,setTimeout((function(){return delete e.gestures.swipe_right}),100)):(this.gestures.swipe_left=!0,setTimeout((function(){return delete e.gestures.swipe_left}),100)):Math.abs(a)>Math.abs(i)&&Math.abs(a)>50&&(a>0?(this.gestures.swipe_down=!0,setTimeout((function(){return delete e.gestures.swipe_down}),100)):(this.gestures.swipe_up=!0,setTimeout((function(){return delete e.gestures.swipe_up}),100)))}this._notifyHooks(t,"end")}},{key:"_notifyHooks",value:function(t,e){try{this.hooks.forEach((function(r){return r(t,e)}))}catch(t){}}},{key:"isGestureActive",value:function(t){return!!this.gestures[t]}},{key:"getTouches",value:function(){return this.touches}},{key:"addHook",value:function(t){t&&this.hooks.push(t)}},{key:"removeHook",value:function(t){var e=this.hooks.indexOf(t);e>=0&&this.hooks.splice(e,1)}}],r&&lo(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),ho=r(679),po=r(4395);function yo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function go(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?yo(Object(r),!0).forEach((function(e){mo(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yo(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function mo(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var bo=function(){function t(e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t._instance||(this.engine=e,this.keyboard=new Xn(e),this.mouse=new Qn(e),this.gamepad=new uo(e),this.touch=new fo(e),this.mappings={},this.hooks={},this.currentMode="default",this.actionStates={},this.lastActionTime={},this.actionPressed={},t._instance=this),t._instance}var e,r;return e=t,(r=[{key:"init",value:function(){this.keyboard.init(),this.mouse.init(),this.gamepad.init(),this.touch.init(),this.setModeMappings("default",{actions:{move_up:{keyboard:"w",gamepad:"up",touch:"swipe_up"},move_down:{keyboard:"s",gamepad:"down",touch:"swipe_down"},move_left:{keyboard:"a",gamepad:"left",touch:"swipe_left"},move_right:{keyboard:"d",gamepad:"right",touch:"swipe_right"},interact:{keyboard:"k",gamepad:"a",touch:"tap"},select:{mouse:"left",touch:"tap"},select_right:{mouse:"right"},camera_pan_left:{keyboard:"ArrowLeft"},camera_pan_right:{keyboard:"ArrowRight"},camera_pan_up:{keyboard:"ArrowUp"},camera_pan_down:{keyboard:"ArrowDown"},camera_zoom_in:{keyboard:"q"},camera_zoom_out:{keyboard:"e"},camera_rotate_left:{keyboard:"z"},camera_rotate_right:{keyboard:"x"},menu:{keyboard:"m",gamepad:"y"},run:{keyboard:"r",gamepad:"y"},bind_camera:{keyboard:"b"},fixed_camera:{keyboard:"c"},help:{keyboard:"h"},chat:{keyboard:" "},clear_speech:{keyboard:"Escape"},patrol:{keyboard:"p"},dance:{keyboard:"u"},height_up:{keyboard:"y"},height_down:{keyboard:"f"}}})}},{key:"setModeMappings",value:function(t,e){this.mappings[t]=e}},{key:"addActionHook",value:function(t,e){this.hooks[t]||(this.hooks[t]=[]),this.hooks[t].push(e)}},{key:"registerActionHook",value:function(t,e){this.hooks[t]||(this.hooks[t]=[]),this.hooks[t].push(e)}},{key:"removeActionHook",value:function(t,e){if(this.hooks[t]){var r=this.hooks[t].indexOf(e);r>-1&&this.hooks[t].splice(r,1)}}},{key:"update",value:function(){var t=this,e=this.mappings[this.currentMode]||this.mappings.default,r=go(go({},this.mappings.default.actions),e.actions),n=function(e){var n,o=r[e],i=!1;o.keyboard&&((n=o.keyboard).length>1?t.keyboard.isCodePressed(n):t.keyboard.isKeyPressed(n))&&(i=!0),o.gamepad&&(t.gamepad.keyPressed(o.gamepad)||"up"===o.gamepad&&t.gamepad.map["y-axis"]<-.5||"down"===o.gamepad&&t.gamepad.map["y-axis"]>.5||"left"===o.gamepad&&t.gamepad.map["x-axis"]<-.5||"right"===o.gamepad&&t.gamepad.map["x-axis"]>.5)&&(i=!0),o.mouse&&t.mouse.isButtonPressed(o.mouse)&&(i=!0),o.touch&&t.touch.isGestureActive(o.touch)&&(i=!0);var a=t.actionStates[e];t.actionStates[e]=i,t.actionPressed[e]=i&&!a,i&&!a&&(t.lastActionTime[e]=Date.now(),t.hooks[e]&&t.hooks[e].forEach((function(r){return r(e,t.currentMode)})))};for(var o in r)n(o)}},{key:"isActionActive",value:function(t){return!!this.actionStates[t]}},{key:"isActionPressed",value:function(t){return!!this.actionPressed[t]}},{key:"setMode",value:function(t){this.mappings[t]||"default"===t?(this.currentMode=t,this.engine&&this.engine.modeManager&&this.engine.modeManager.set(t)):console.warn('Input mode "'.concat(t,'" not found, staying in "').concat(this.currentMode,'"'))}},{key:"handleInput",value:function(t){return!(!this.engine||!this.engine.modeManager)&&this.engine.modeManager.handleInput(t)}},{key:"getActionInput",value:function(t){var e=(this.mappings[this.currentMode]||this.mappings.default).actions[t];if(!e)return null;if(e.keyboard&&this.keyboard.isKeyPressed(e.keyboard))return"keyboard:"+e.keyboard;if(e.gamepad){if(this.gamepad.keyPressed(e.gamepad))return"gamepad:"+e.gamepad;if("up"===e.gamepad&&this.gamepad.map["y-axis"]<-.5)return"gamepad:up";if("down"===e.gamepad&&this.gamepad.map["y-axis"]>.5)return"gamepad:down";if("left"===e.gamepad&&this.gamepad.map["x-axis"]<-.5)return"gamepad:left";if("right"===e.gamepad&&this.gamepad.map["x-axis"]>.5)return"gamepad:right"}return e.mouse&&this.mouse.isButtonPressed(e.mouse)?"mouse:"+e.mouse:e.touch&&this.touch.isGestureActive(e.touch)?"touch:"+e.touch:null}},{key:"getMode",value:function(){return this.currentMode}},{key:"getAvatarAction",value:function(t){var e,r=this.mappings[this.currentMode]||this.mappings.default,o=go(go({},this.mappings.default.actions),r.actions);for(var i in o)if(this.isActionActive(i))switch(i){case"menu":return t.openMenu({main:{text:"Close Menu",x:100,y:100,w:150,h:75,colours:{top:"#333",bottom:"#777",background:"#999"},trigger:function(t){t.completed=!0}}},["main"]);case"chat":return new ho.aW(this.engine,"chat",[">:",!0,{autoclose:!1}],t);case"dance":return new ho.aW(this.engine,"dance",[300,t.zone],t);case"patrol":return new ho.aW(this.engine,"patrol",[t.pos.toArray(),new n.OW(8,13,t.pos.z).toArray(),600,t.zone],t);case"run":return new ho.aW(this.engine,"patrol",[t.pos.toArray(),new n.OW(8,13,t.pos.z).toArray(),200,t.zone],t);case"interact":return new ho.aW(this.engine,"interact",[t.pos.toArray(),t.facing,t.zone.world],t);case"help":return new ho.aW(this.engine,"dialogue",["Welcome! You pressed help! Press Escape to close",!1,{autoclose:!0}],t);case"clear_speech":return t.speech.clearHud();case"move_up":var a=po.Nm.getCameraRelativeDirection("forward",this.engine.renderManager.camera.cameraDir);return t.handleWalk("w",{},a);case"move_down":var s=po.Nm.getCameraRelativeDirection("backward",this.engine.renderManager.camera.cameraDir);return t.handleWalk("s",{},s);case"move_left":var c=po.Nm.getCameraRelativeDirection("left",this.engine.renderManager.camera.cameraDir);return t.handleWalk("a",{},c);case"move_right":var u=po.Nm.getCameraRelativeDirection("right",this.engine.renderManager.camera.cameraDir);return t.handleWalk("d",{},u);case"face_up":return t.faceDir("N");case"face_down":return t.faceDir("S");case"face_left":return t.faceDir("W");case"face_right":return t.faceDir("E");default:if(i.startsWith("camera_")){var l=this.engine.renderManager.camera.cameraVector,f=this.engine.renderManager.camera.cameraVector,h=po.Nm.adjustCameraDirection(f);switch(i){case"camera_rotate_left":(f=l.sub(new n.OW(0,0,1))).z=Math.round(f.z%9),0===f.z&&8===l.z&&(l.z=0),0===f.z&&7===l.z&&(f.z=8),t.faceDir(po.Nm.spriteSequence(h)),t.zone.world.addEvent(new ho.q1(this.engine,"camera",["pan",{from:l,to:f,duration:1}],t.zone.world));break;case"camera_rotate_right":(f=l.add(new n.OW(0,0,1))).z=Math.round(null!==(e=f.z%9)&&void 0!==e?e:8),0===f.z&&8===l.z&&(l.z=0),0===f.z&&7===l.z&&(f.z=8),t.faceDir(po.Nm.spriteSequence(h)),t.zone.world.addEvent(new ho.q1(this.engine,"camera",["pan",{from:l,to:f,duration:1}],t.zone.world));break;case"camera_zoom_in":case"camera_zoom_out":case"camera_pan_left":case"camera_pan_right":case"camera_pan_up":case"camera_pan_down":break;case"camera_bind":t.bindCamera=!0;break;case"camera_unbind":t.bindCamera=!1}return null}return new ho.aW(this.engine,i,[],t)}return null}},{key:"bindAction",value:function(t,e,r){this.mappings[this.currentMode]||(this.mappings[this.currentMode]={actions:{}}),this.mappings[this.currentMode].actions[t]||(this.mappings[this.currentMode].actions[t]={}),this.mappings[this.currentMode].actions[t][e]=r}},{key:"unbindAction",value:function(t,e){this.mappings[this.currentMode]&&this.mappings[this.currentMode].actions[t]&&delete this.mappings[this.currentMode].actions[t][e]}}])&&vo(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function wo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function xo(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?wo(Object(r),!0).forEach((function(e){Co(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):wo(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _o(t,e,r){return _o=ko()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Eo(o,r.prototype),o},_o.apply(null,arguments)}function ko(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Eo(t,e){return Eo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Eo(t,e)}function Ao(t,e){if(t){if("string"==typeof t)return So(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?So(t,e):void 0}}function So(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Lo(t){return Lo="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},Lo(t)}function Oo(){Oo=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==Lo(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Po(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function To(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Co(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Mo=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.ws=null,this.clientId=null,this.players=new Map,this.authority="server",this.zoneId=null,this.setAuthorityFromManifest()}var e,n,o,i;return e=t,n=[{key:"connect",value:(o=Oo().mark((function t(e){var r=this;return Oo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.ws&&this.disconnect(),this.ws=new WebSocket(e),t.abrupt("return",new Promise((function(t,e){r.ws.onopen=function(){console.log("WebSocket connection established"),t()},r.ws.onmessage=function(t){r.handleMessage(t.data)},r.ws.onclose=function(){console.log("WebSocket connection closed")},r.ws.onerror=function(t){console.error("WebSocket error:",t),e(t)}})));case 3:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,e=arguments;return new Promise((function(r,n){var i=o.apply(t,e);function a(t){Po(i,r,n,a,s,"next",t)}function s(t){Po(i,r,n,a,s,"throw",t)}a(void 0)}))},function(t){return i.apply(this,arguments)})},{key:"safeStringify",value:function(t){try{return JSON.stringify(t)}catch(r){try{var e={};return Object.keys(t||{}).forEach((function(r){var n=t[r];n&&"object"===Lo(n)?e[r]=Array.isArray(n)?"[Array(".concat(n.length,")]"):"{".concat(n.constructor&&n.constructor.name,"}"):e[r]=n})),JSON.stringify(e)}catch(e){return String(t)}}}},{key:"disconnect",value:function(){this.ws&&(this.ws.close(),this.ws=null)}},{key:"send",value:function(t,e){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:t,payload:e}))}},{key:"handleMessage",value:function(t){try{var e=JSON.parse(t);switch(console.log("Received message from server:",e),e.type){case"connected":this.clientId=e.clientId,this.engine.store.set("clientId",this.clientId),console.log("Connected to server with client ID: ".concat(this.clientId));break;case"zone-loaded":this.handleZoneLoaded(e.payload);break;case"zone-change":this.handleZoneChange(e.payload);break;case"zone-joined":this.handleZoneJoined(e.payload);break;case"player-joined":this.handlePlayerJoined(e.payload);break;case"player-left":this.handlePlayerLeft(e.payload);break;case"players-update":this.handlePlayersUpdate(e.payload);break;case"zone-state":this.handleZoneState(e.payload);break;case"avatar-update":this.handleAvatarUpdate(e.payload);break;case"action":this.handleAction(e.payload);break;default:console.log("Unknown message type: ".concat(e.type))}}catch(e){var r="string"==typeof t?t.length>1e3?t.slice(0,1e3)+"... (truncated)":t:this.safeStringify(t);console.error("Failed to parse message from server. Parse error:",e),console.error("Raw message preview:",r)}}},{key:"loadZone",value:function(t,e){var r,n=e.getZoneData?e.getZoneData():e;try{r=JSON.parse(JSON.stringify(n))}catch(n){console.warn("Zone data contains circular refs, sending minimal zone info instead"),r={id:t,name:e&&e.name}}this.send("load-zone",{zoneId:t,zone:r})}},{key:"joinZone",value:function(t){this.zoneId=t;var e=this.engine.spritz.world.getAvatar(),r=e.getAvatarData(),n={id:r.id||e.objId||e.id||"avatar",templateLoaded:!!r.templateLoaded,animFrame:r.animFrame||0,facing:r.facing||0,fixed:!!r.fixed,isSelected:!!r.isSelected,x:e&&e.pos?e.pos.x:r.pos&&r.pos.x||0,y:e&&e.pos?e.pos.y:r.pos&&r.pos.y||0,z:e&&e.pos?e.pos.z:r.pos&&r.pos.z||0,drawOffset:r.drawOffset?{x:r.drawOffset.x,y:r.drawOffset.y}:void 0,hotspotOffset:r.hotspotOffset?{x:r.hotspotOffset.x,y:r.hotspotOffset.y}:void 0,scale:r.scale?{x:r.scale.x,y:r.scale.y}:void 0};this.send("join-zone",{zoneId:t,avatar:n})}},{key:"sendAction",value:function(t,e){if("server"===this.authority){var r={action:t.constructor.name.toLowerCase(),params:t.params,spriteId:e.id};this.send("action",r)}else this.handleAction({clientId:this.clientId,action:t.constructor.name.toLowerCase(),params:t.params,spriteId:e.id})}},{key:"updateAvatarPosition",value:function(t){if(this.ws&&this.ws.readyState===WebSocket.OPEN){var e={avatar:{id:t.id,x:t.pos.x,y:t.pos.y,z:t.pos.z,facing:t.facing}},r=JSON.parse(JSON.stringify(e));this.send("update-avatar",r)}}},{key:"handleZoneLoaded",value:function(t){console.log("Loaded zone ".concat(t.zoneId)),this.joinZone(t.zoneId)}},{key:"handleZoneJoined",value:function(t){var e=this;console.log("Joined zone ".concat(t.zoneId," with players:"),t.players),t.players.forEach((function(t){return e.handlePlayerJoined({client:t})})),this.send("zone-state-request",{zoneId:t.zoneId})}},{key:"getZoneSprites",value:function(t){var e=this.engine.spritz.world;if(!e)return[];var r=e.getZoneById(t);return r?r.spriteList.map((function(t){return{id:t.id,objId:t.objId,x:t.pos.x,y:t.pos.y,z:t.pos.z,avatar:t.getAvatarData?t.getAvatarData():t}})):[]}},{key:"handleZoneChange",value:function(t){console.log("Change zone ".concat(t.zoneId))}},{key:"handlePlayerJoined",value:function(t){if(t.client.clientId!==this.clientId){console.log("Player ".concat(t.client.clientId," joined the zone"));try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText("Player ".concat(t.client.clientId," joined"),!0,{autoclose:!0,duration:3e3})}catch(t){}var e=this.engine.spritz.world;e&&(e.addRemoteAvatar(t.client.clientId,t.client.avatar),this.players.set(t.client.clientId,Object.assign({},t.client.avatar,{clientId:t.client.clientId})))}}},{key:"handlePlayerLeft",value:function(t){console.log("Player ".concat(t.clientId," left the zone"));try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText("Player ".concat(t.clientId," left"),!0,{autoclose:!0,duration:3e3})}catch(t){}var e=this.players.get(t.clientId);if(e){var r=this.engine.spritz.world;r&&r.removeAvatar(e),this.players.delete(t.clientId)}}},{key:"handlePlayersUpdate",value:function(t){var e=this;console.log("Players update:",t.players);try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText("Players in zone: ".concat(t.players.map((function(t){return t.clientId})).join(", ")),!0,{autoclose:!0,duration:3e3})}catch(t){}var r,n=new Set(this.players.keys()),o=new Set(t.players.map((function(t){return t.clientId}))),i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ao(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(n);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!o.has(a)){var s=this.engine.spritz.world;s&&s.removeRemoteAvatar(a),this.players.delete(a)}}}catch(t){i.e(t)}finally{i.f()}t.players.forEach((function(t){if(t.clientId!==e.clientId){var r=e.engine.spritz.world;r&&(e.players.has(t.clientId)?(r.updateRemoteAvatar(t.clientId,t.avatar),e.players.set(t.clientId,t.avatar)):(r.addRemoteAvatar(t.clientId,t.avatar),e.players.set(t.clientId,t.avatar)))}}))}},{key:"handleAction",value:function(e){if(e.clientId!==this.clientId){console.log("Received action from ".concat(e.clientId,":"),e);var n=this.engine.spritz.world.remoteAvatars.get(e.clientId);if(n)try{var o=null,i=this.engine.spritz&&this.engine.spritz.world;if(i&&"function"==typeof i.actionFactory&&(o=i.actionFactory(e.action)),o){var a=_o(o,[n].concat(function(t){if(Array.isArray(t))return So(t)}(c=Object.values(e.params||{}))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(c)||Ao(c)||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.")}()));n.addAction(a)}else{t._ActionLoader||(t._ActionLoader=r(1183).a);var s=new t._ActionLoader(this.engine,e.action,e.params||{},n,(function(){}));s&&null==s.instances&&console.warn("ActionLoader returned unexpected instance for action",e.action,s)}}catch(t){console.warn("Failed to handle action payload",e,t)}}var c}},{key:"handleZoneState",value:function(t){var e=this;console.log("Received zone state for ".concat(t.zoneId,":"),t.sprites);var r=this.engine.spritz.world;if(r){var n=r.getZoneById(t.zoneId);n&&t.sprites.forEach((function(t){if(t.clientId!==e.clientId)try{if(t.clientId&&r.remoteAvatars&&r.remoteAvatars.has(t.clientId))r.updateRemoteAvatar(t.clientId,xo({x:t.x,y:t.y,z:t.z||0,facing:t.avatar&&t.avatar.facing||t.facing,animFrame:t.avatar&&t.avatar.animFrame||t.animFrame},t.avatar||{}));else{var o=n.spriteDict[t.id];if(o)o.pos.x=t.x,o.pos.y=t.y,o.pos.z=t.z||0,t.avatar&&(null!=t.avatar.facing&&(o.facing=t.avatar.facing),null!=t.avatar.animFrame&&(o.animFrame=t.avatar.animFrame));else{var i=xo({id:t.id||"player-".concat(t.clientId),x:t.x,y:t.y,z:t.z||0,facing:t.avatar&&t.avatar.facing||t.facing,animFrame:t.avatar&&t.avatar.animFrame||t.animFrame},t.avatar||{});t.clientId&&"function"==typeof r.addRemoteAvatar?r.addRemoteAvatar(t.clientId,i):"function"==typeof r.createAvatar&&r.createAvatar(i)}}}catch(t){console.warn("Error handling zone state sprite update:",t)}}))}}},{key:"setAuthorityFromManifest",value:function(){this.engine&&this.engine.spritz&&this.engine.spritz.manifest&&this.engine.spritz.manifest.network&&(this.authority=this.engine.spritz.manifest.network.authority||"server")}},{key:"handleAvatarUpdate",value:function(t){console.log("Received avatar update for ".concat(t.clientId,":"),t.avatar);var e=this.engine.spritz.world;e&&(e.updateRemoteAvatar(t.clientId,t.avatar)||e.addRemoteAvatar(t.clientId,xo({id:t.avatar.id||"player-".concat(t.clientId)},t.avatar)),this.players.set(t.clientId,t.avatar))}},{key:"setAuthority",value:function(t){this.authority=t}}],n&&To(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();Co(Mo,"_ActionLoader",null);var jo=r(3203),Io=function(t){var e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.background="rgba(0, 0, 0, 0.6)",e.style.color="#0f0",e.style.padding="4px",e.style.fontFamily="monospace",e.style.fontSize="12px",e.style.zIndex="10000",e.style.pointerEvents="none",e.style.display="none",t.flagDebugDiv=e,document.body.appendChild(e),window.addEventListener("keydown",(function(e){"F4"===e.key&&(t.showFlagDebug=!t.showFlagDebug,t.store.set("Debug::Flag::showDebug",t.showFlagDebug),t.flagDebugDiv.style.display=t.showFlagDebug?"block":"none")}))},Bo=function(t){var e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.background="rgba(0, 0, 0, 0.6)",e.style.color="#0f0",e.style.padding="4px",e.style.fontFamily="monospace",e.style.fontSize="12px",e.style.zIndex="10000",e.style.pointerEvents="none",e.style.display="none",t.webglDebugDiv=e,document.body.appendChild(e),window.addEventListener("keydown",(function(e){"F3"===e.key&&(t.showWebglDebug=!t.showWebglDebug,t.store.set("Debug::Webgl::showDebug",t.showWebglDebug),t.webglDebugDiv.style.display=t.showWebglDebug?"block":"none")}));try{var r=t.keyboard,o=function(e,r){if("down"===r&&"F5"===e.key){try{e.preventDefault(),e.stopPropagation()}catch(t){}t.showFreeCam=!t.showFreeCam,t.store.set("Debug::FreeCam::show",t.showFreeCam);var n=new CustomEvent("pixos:freecam:toggle");window.dispatchEvent(n)}};r.addHook&&r.addHook(o),t._debugFreeCamHook=o}catch(t){}window.addEventListener("pixos:freecam:toggle",(function(){var e=t.renderManager;if(e&&e.camera){var r=t.canvas||document.body,o=function(t){try{t.preventDefault(),t.stopPropagation()}catch(t){}var r=.5*(t.deltaY>0?1:-1);try{e.camera.zoom&&e.camera.zoom(r),c++}catch(t){}},i=function(t){var r=.002*(t.movementX||0),n=.002*(t.movementY||0);try{var o=1.5*-r,i=1.5*-n;e.camera&&(e.camera.yaw+=o,e.camera.pitch=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,e.camera.pitch+i)),e.camera.updateViewFromAngles&&e.camera.updateViewFromAngles(),c++)}catch(t){}},a=null,s=null,c=0,u=!0;if(t.showFreeCam){var l;t._freeCamSaved=(0,jo.Ue)();try{console.log("[FreeCam] ENTER - current viewMat:",Array.from(e.camera.uViewMat))}catch(t){}(0,jo.t8)(e.camera.uViewMat,t._freeCamSaved);try{t._freeCamSavedState={position:new n.OW(e.camera.cameraPosition.x,e.camera.cameraPosition.y,e.camera.cameraPosition.z),yaw:e.camera.yaw,pitch:e.camera.pitch,distance:e.camera.cameraDistance,target:e.camera.cameraTarget?new n.OW(e.camera.cameraTarget.x,e.camera.cameraTarget.y,e.camera.cameraTarget.z):null,viewMat:(0,jo.Ue)()},(0,jo.t8)(e.camera.uViewMat,t._freeCamSavedState.viewMat);try{console.log("[FreeCam] ENTER - savedState.viewMat:",Array.from(t._freeCamSavedState.viewMat))}catch(t){}}catch(t){}null!==(l=t.spritz)&&void 0!==l&&l.world&&(t.spritz.world.isPaused=!0),t._freecamActive=!0;var f=document.createElement("div");f.style.position="absolute",f.style.bottom="8px",f.style.left="50%",f.style.transform="translateX(-50%)",f.style.background="rgba(0,0,0,0.6)",f.style.color="#fff",f.style.padding="6px 10px",f.style.fontFamily="monospace",f.style.fontSize="12px",f.style.zIndex="10001",f.id="pixos-freecam-info",f.innerHTML="FREE CAM (F5 to exit) WASD/Arrows: move & strafe Q/E: yaw R/F: pitch Wheel: zoom",document.body.appendChild(f);var h=function(){var n=document.pointerLockElement===r||document.mozPointerLockElement===r;try{var o=document.getElementById("pixos-freecam-status");o&&(o.innerText="Keys: "+JSON.stringify(t.keyboard&&t.keyboard.activeCodes||[])+" | pointerLock: "+(n?"yes":"no"));try{console.log("[FreeCam] pointerLock change - locked:",n,"viewMat:",Array.from(e.camera.uViewMat))}catch(t){}}catch(t){}};document.addEventListener("pointerlockchange",h),document.addEventListener("mozpointerlockchange",h);try{t._bodyOverflowSaved=document.body.style.overflow,document.body.style.overflow="hidden"}catch(t){}try{r.requestPointerLock=r.requestPointerLock||r.mozRequestPointerLock,r.requestPointerLock()}catch(t){}window.addEventListener("wheel",o,{passive:!1,capture:!0}),document.addEventListener("pointermove",i,{capture:!0}),document.addEventListener("mousemove",i,{capture:!0}),a=requestAnimationFrame((function n(){var o=(t.keyboard&&t.keyboard.activeCodes||[]).map((function(t){return(t||"").toString().toLowerCase()}));try{e.camera&&((o.indexOf("w")>=0||o.indexOf("arrowup")>=0)&&(e.camera.translateCam("UP"),c++),(o.indexOf("s")>=0||o.indexOf("arrowdown")>=0)&&(e.camera.translateCam("DOWN"),c++),(o.indexOf("a")>=0||o.indexOf("arrowleft")>=0)&&(e.camera.translateCam("LEFT"),c++),(o.indexOf("d")>=0||o.indexOf("arrowright")>=0)&&(e.camera.translateCam("RIGHT"),c++),o.indexOf("q")>=0&&(e.camera.yaw-=.03,e.camera.updateViewFromAngles(),c++),o.indexOf("e")>=0&&(e.camera.yaw+=.03,e.camera.updateViewFromAngles(),c++),o.indexOf("r")>=0&&(e.camera.pitch=Math.max(-Math.PI/2+.01,e.camera.pitch-.03),e.camera.updateViewFromAngles(),c++),o.indexOf("f")>=0&&(e.camera.pitch=Math.min(Math.PI/2-.01,e.camera.pitch+.03),e.camera.updateViewFromAngles(),c++))}catch(t){}a=requestAnimationFrame(n),s||((s=document.createElement("div")).id="pixos-freecam-status",s.style.position="absolute",s.style.top="8px",s.style.left="50%",s.style.transform="translateX(-50%)",s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.padding="6px 10px",s.style.fontFamily="monospace",s.style.fontSize="12px",s.style.zIndex="10002",document.body.appendChild(s));try{var i=e.camera||{};if(u){try{console.log("[FreeCam] FIRST TICK viewMat:",Array.from(e.camera.uViewMat))}catch(t){}u=!1}var l=i.cameraPosition?[i.cameraPosition.x,i.cameraPosition.y,i.cameraPosition.z]:["n/a"],f=void 0!==i.yaw?i.yaw.toFixed(3):"n/a",h=void 0!==i.pitch?i.pitch.toFixed(3):"n/a",d=e.camera&&e.camera.uViewMat?Array.from(e.camera.uViewMat).slice(0,8).map((function(t){return t.toFixed(3)})):[];s.innerText="Keys: "+JSON.stringify(o)+"\npointerLock: "+(document.pointerLockElement===r?"yes":"no")+"\npos: "+JSON.stringify(l)+" yaw:"+f+" pitch:"+h+"\nuViewMat (trim): "+JSON.stringify(d)+"\nmoves: "+c}catch(t){}})),t._freecamHandlers={onWheel:o,onPointerMove:i,rafId:a,captureClick:function(t){t&&t.preventDefault();try{r&&r.parentElement&&r.parentElement.focus&&r.parentElement.focus()}catch(t){}try{r.requestPointerLock=r.requestPointerLock||r.mozRequestPointerLock,r.requestPointerLock()}catch(t){}},onPointerLockChange:h}}else{var d;if(t._freeCamSavedState){try{try{console.log("[FreeCam] EXIT - restoring savedState.viewMat:",Array.from(t._freeCamSavedState.viewMat))}catch(t){}(0,jo.t8)(t._freeCamSavedState.viewMat,e.camera.uViewMat);try{e.camera&&(void 0!==t._freeCamSavedState.yaw&&(e.camera.yaw=t._freeCamSavedState.yaw),void 0!==t._freeCamSavedState.pitch&&(e.camera.pitch=t._freeCamSavedState.pitch),void 0!==t._freeCamSavedState.distance&&(e.camera.cameraDistance=t._freeCamSavedState.distance),t._freeCamSavedState.target&&(e.camera.cameraTarget=t._freeCamSavedState.target),e.camera.updateViewFromAngles&&e.camera.updateViewFromAngles())}catch(t){}}catch(t){}t._freeCamSavedState=null}else if(t._freeCamSaved)try{try{console.log("[FreeCam] EXIT - restoring _freeCamSaved:",Array.from(t._freeCamSaved))}catch(t){}(0,jo.t8)(t._freeCamSaved,e.camera.uViewMat);try{e.camera.setFromViewMatrix(e.camera.uViewMat)}catch(t){}}catch(t){}null!==(d=t.spritz)&&void 0!==d&&d.world&&(t.spritz.world.isPaused=!1),t._freecamActive=!1;var p=document.getElementById("pixos-freecam-info");p&&document.body.removeChild(p);try{document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock,document.exitPointerLock()}catch(t){}if(t._freecamHandlers){window.removeEventListener("wheel",t._freecamHandlers.onWheel,{capture:!0}),document.removeEventListener("pointermove",t._freecamHandlers.onPointerMove,{capture:!0}),document.removeEventListener("mousemove",t._freecamHandlers.onPointerMove,{capture:!0});try{t._freecamHandlers.onPointerLockChange&&(document.removeEventListener("pointerlockchange",t._freecamHandlers.onPointerLockChange),document.removeEventListener("mozpointerlockchange",t._freecamHandlers.onPointerLockChange))}catch(t){}cancelAnimationFrame(t._freecamHandlers.rafId),t._freecamHandlers=null}try{var y;document.body.style.overflow=null!==(y=t._bodyOverflowSaved)&&void 0!==y?y:""}catch(t){}try{var g=document.getElementById("pixos-freecam-status");g&&document.body.removeChild(g)}catch(t){}}}}))};function zo(t){return zo="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},zo(t)}function Do(){Do=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==zo(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function No(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Ro(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Fo=function(){function t(e,r,n,i,a,s,c){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.canvas=e,this.hudCanvas=r,this.gamepadCanvas=i,this.mipmap=n,this.fileUpload=a,this.width=s,this.height=c,this.utils=o,this.networkManager=new Mo(this),this.resourceManager=new Vn(this),this.renderManager=new kn.Z(this),this.hud=new _n.ZP(this),this.inputManager=new bo(this),this.voice=new SpeechSynthesisUtterance,this.database=new yn,this.store=new xn,this.cutsceneManager=new Kn(this),this.modeManager=new Hn.Z(this),this.debug=!1,this.debugHeightOverlay=!1,this.running=!1,this.gl=null,this.ctx=null,this.gp=null,this.frameCount=0,this.spritz=null,this.fullscreen=!1,this.time=0,this.requestId=null,this.screenSize=this.screenSize.bind(this),this.render=this.render.bind(this),this.init=this.init.bind(this),this.close=this.close.bind(this)}var e,r,n,i;return e=t,r=[{key:"init",value:(n=Do().mark((function t(e){var r,n,o,i,a;return Do().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=this.hudCanvas.getContext("2d"),i=this.canvas.getContext("webgl2",{antialias:!0,depth:!0,preserveDrawingBuffer:!1}),a=this.gamepadCanvas.getContext("2d"),i){t.next=5;break}throw new Error("WebGL: unable to initialize");case 5:if(o){t.next=7;break}throw new Error("Canvas: unable to initialize HUD");case 7:if(a){t.next=9;break}throw new Error("Gamepad: unable to initialize Mobile Canvas");case 9:if(o.canvas.width=i.canvas.clientWidth,o.canvas.height=i.canvas.clientHeight,this.gl=i,this.ctx=o,this.gp=a,this.frameCount=0,this.spritz=e,this.fullscreen=!1,this.time=(new Date).getTime(),this.inputManager.init(),this.hud.init(),this.renderManager.init(),this.gamepad=this.inputManager.gamepad,this.keyboard=this.inputManager.keyboard,this.mouse=this.inputManager.mouse,this.touch=this.inputManager.touch,this.touchHandler=this.gamepad.listen.bind(this.gamepad),null===(r=e.manifest)||void 0===r||null===(n=r.network)||void 0===n||!n.enabled){t.next=30;break}return t.next=29,this.networkManager.connect(e.manifest.network.url);case 29:e.manifest.network.authority&&this.networkManager.setAuthority(e.manifest.network.authority);case 30:return t.next=32,e.init(this);case 32:Bo(this),Io(this);case 34:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function a(t){No(i,r,o,a,s,"next",t)}function s(t){No(i,r,o,a,s,"throw",t)}a(void 0)}))},function(t){return i.apply(this,arguments)})},{key:"render",value:function(){this.frameCount++,this.renderManager&&this.renderManager.resetDebugCounters&&this.renderManager.resetDebugCounters(),this.hud.clearHud(),this.hud.drawModeLabel&&this.hud.drawModeLabel(),this.renderManager.clearScreen();var t=(new Date).getTime();this.inputManager.update(),this.modeManager.hasPicker()&&(this.renderManager.activatePickerShaderProgram(!1),this.spritz.render(this,t),this.getSelectedObject("sprite|object|tile",!1)),this.inputManager.handleInput(t)||this.spritz.update(t);var e=this.modeManager.getMode();e&&this.inputManager.getMode()!==e&&this.inputManager.setMode(e);var r=this.renderManager.engine.gl;if(this.renderManager.clearScreen(),r.depthMask(!1),this.renderManager.renderSkybox(),r.depthMask(!0),this.renderManager.activateShaderProgram(),this.modeManager.update(t),this.renderManager&&this.renderManager.updateParticles)try{this.renderManager.updateParticles(t)}catch(t){console.warn("updateParticles failed",t)}if(this.spritz.render(this),this.cutsceneManager.update(),this.renderManager.updateTransition(),this.renderManager&&this.renderManager.renderParticles)try{this.renderManager.renderParticles()}catch(t){console.warn("renderParticles failed",t)}if(this.gamepad.render(),this.debugHeightOverlay&&this.hud.drawHeightDebugOverlay)try{this.hud.drawHeightDebugOverlay()}catch(t){console.warn("drawHeightDebugOverlay failed",t)}!function(t){(function(t){if(t.showWebglDebug&&t.webglDebugDiv){var e="undefined"!=typeof performance?performance.now():Date.now(),r=e-t.lastDebugTime,n=r>0?(1e3/r).toFixed(1):"0";t.lastDebugTime=e;var o=t.gl,i="",a="",s="";if(o)try{i=o.getParameter(o.RENDERER),a=o.getParameter(o.VENDOR),s=o.getParameter(o.VERSION)}catch(t){}var c=t.renderManager.debug||{};t.webglDebugDiv.innerHTML="FPS: "+n+"<br>Tiles Drawn: "+(c.tilesDrawn||0)+"<br>Sprites Drawn: "+(c.spritesDrawn||0)+"<br>Objects Drawn: "+(c.objectsDrawn||0)+"<br>Renderer: "+i+"<br>Vendor: "+a+"<br>GL Version: "+s}})(t),function(t){if(t.showFlagDebug&&t.flagDebugDiv){t.store.set("Debug::Flag::UpdateTime",Date.now());var e=t.store.all();console.log({self:t,keys:JSON.stringify(e),store:t.store.keys()});var r=Object.keys(e).map((function(t){return t+": "+JSON.stringify(e[t])+"<br>"}));t.flagDebugDiv.innerHTML="FLAGS:<br>"+r.join("")}}(t)}(this),this.requestId=requestAnimationFrame(this.render)}},{key:"close",value:function(){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=null)}},{key:"getSelectedObject",value:function(){var t,e,r,n,o,i,a=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"sprite|object|tile",c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this._freecamActive)return null;if((null===(t=this.spritz.world)||void 0===t||null===(e=t.spriteList)||void 0===e?void 0:e.length)<=0&&(null===(r=this.spritz.world)||void 0===r||null===(n=r.objectList)||void 0===n?void 0:n.length)<=0&&(null===(o=this.spritz.world)||void 0===o||null===(i=o.zoneList)||void 0===i?void 0:i.length)<=0)return null;var u=this.gl,l=new Uint8Array(4),f=this.gamepad.x||0,h=this.gamepad.y||0,d=c?0:f*u.canvas.width/u.canvas.clientWidth,p=c?0:u.canvas.height-h*u.canvas.height/u.canvas.clientHeight-1;u.readPixels(d,p,1,1,u.RGBA,u.UNSIGNED_BYTE,l);var y=l[0]+(l[1]<<8)+(l[2]<<16);return this.inputManager.isActionPressed("select")?(s.split("|").forEach((function(t){switch(t){case"sprite":a.spritz.world.spriteList=a.spritz.world.spriteList.map((function(t){return t.objId===y?(t.isSelected=!0,a.spritz.world.spriteDict[t.id]&&(a.spritz.world.spriteDict[t.id].isSelected=!0,a.modeManager.handleSelect(t.zone,t,null,"sprite")||"function"==typeof a.spritz.world.spriteDict[t.id].onSelect&&a.spritz.world.spriteDict[t.id].onSelect(t.zone,t))):t.isSelected=!1,t}));break;case"object":a.spritz.world.objectList=a.spritz.world.objectList.map((function(t){return t.objId===y?(t.isSelected=!0,a.spritz.world.objectDict[t.id]&&(a.spritz.world.objectDict[t.id].isSelected=!0,a.modeManager.handleSelect(t.zone,t,null,"object")||"function"==typeof a.spritz.world.objectDict[t.id].onSelect&&a.spritz.world.objectDict[t.id].onSelect(t.zone,t))):t.isSelected=!1,t}));break;case"tile":var e=l[0],r=l[1],n=l[2];a.spritz.world.zoneList.forEach((function(t){t.objId===e&&(a.modeManager.handleSelect(t,r,n,"tile")||"function"==typeof t.onSelect&&t.onSelect(r,n))})),0!==y&&console.log("TILE SELECTION:",{zoneObjId:e,row:r,cell:n,zones:a.spritz.world.zoneList})}})),y):y}},{key:"setGreeting",value:function(t){this.globalStore?this.globalStore.greeting=t:console.warn("globalStore is not available to set greeting.")}},{key:"speechSynthesis",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=this.voice,c=null!==(e=window.speechSynthesis.getVoices())&&void 0!==e?e:[];s.voice=r||c[0],o&&(s.rate=o),i&&(s.volume=i),a&&(s.pitch=a),s.text=t,s.lang=n,window.speechSynthesis.speak(s)}},{key:"screenSize",value:function(){return{width:this.canvas.clientWidth,height:this.canvas.clientHeight}}}],r&&Ro(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1248:(t,e,r)=>{"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==s(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function s(t){return s="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},s(t)}function c(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,s,"next",t)}function s(t){c(i,n,o,a,s,"throw",t)}a(void 0)}))}}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}r.d(e,{Z:()=>f});var f=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.currentMode=null,this.registered=Object.create(null)}var e,r,n;return e=t,r=[{key:"register",value:function(t,e){var r=this;if(this.registered[t]=e,this.currentMode&&this.currentMode.name===t){var n=this.currentMode.params||{};u(a().mark((function e(){var o,i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=r.registered[t],r.currentMode.handlers=o,!o||!o.setup){e.next=8;break}return e.next=6,o.setup(n);case 6:(i=e.sent)&&"object"===s(i)&&(Object.assign(o,i),r.registered[t]=o,r.currentMode.handlers=o);case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.warn('Mode late-register setup failed for mode "'.concat(t,'":'),e.t0);case 13:case"end":return e.stop()}}),e,null,[[0,10]])})))()}}},{key:"set",value:function(t){var e=this;this.registered[t]?(this.currentMode&&this.currentMode.handlers.teardown&&u(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.currentMode.handlers.teardown(e.currentMode.params);case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),console.warn('Mode teardown failed for mode "'.concat(e.currentMode.name,'":'),t.t0);case 8:case"end":return t.stop()}}),t,null,[[0,5]])})))(),this.currentMode={name:t,handlers:this.registered[t],params:{}},this.currentMode.handlers.setup&&u(a().mark((function r(){var n;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e.currentMode.handlers.setup(e.currentMode.params);case 3:(n=r.sent)&&(e.currentMode.handlers=o(o({},e.currentMode.handlers),n)),r.next=10;break;case 7:r.prev=7,r.t0=r.catch(0),console.warn('Mode setup failed for mode "'.concat(t,'":'),r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})))()):console.warn('Mode "'.concat(t,'" not registered'))}},{key:"update",value:(n=u(a().mark((function t(e){var r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.currentMode){t.next=2;break}return t.abrupt("return");case 2:if(!(r=this.currentMode.handlers)||!r.update){t.next=12;break}return t.prev=4,t.next=7,r.update(e,this.currentMode.params);case 7:t.next=12;break;case 9:t.prev=9,t.t0=t.catch(4),console.warn('Mode update failed for mode "'.concat(this.currentMode.name,'":'),t.t0);case 12:case"end":return t.stop()}}),t,this,[[4,9]])}))),function(t){return n.apply(this,arguments)})},{key:"handleInput",value:function(t){if(!this.currentMode)return!1;var e=this.currentMode.handlers;try{if(e&&e.checkInput)return!!e.checkInput(t,this.currentMode.params)}catch(t){console.warn('Mode input handler failed for mode "'.concat(this.currentMode.name,'":'),t)}return!1}},{key:"handleSelect",value:function(t,e,r,n){if(!this.currentMode)return!1;var o=this.currentMode.handlers;try{if(o&&o.onSelect)return!!o.onSelect(t,e,r,n,this.currentMode.params)}catch(t){console.warn('Mode onSelect handler failed for mode "'.concat(this.currentMode.name,'":'),t)}return!1}},{key:"getMode",value:function(){var t;return(null===(t=this.currentMode)||void 0===t?void 0:t.name)||null}},{key:"hasPicker",value:function(){var t,e;return!0===(null===(t=this.currentMode)||void 0===t||null===(e=t.handlers)||void 0===e?void 0:e.picker)}}],r&&l(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},7974:(t,e,r)=>{"use strict";function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}r.d(e,{Z:()=>o});var o=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.actions=[]}var e,r;return e=t,r=[{key:"add",value:function(t){this.actions.push(t)}},{key:"run",value:function(){var t=arguments;this.actions=this.actions.filter((function(e){return e(t)}))}}],r&&n(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},5849:(t,e,r)=>{"use strict";function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}r.d(e,{Z:()=>o});var o=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,r;return e=t,(r=[{key:"runWhenLoaded",value:function(t){this.loaded?t():this.onLoadActions.add(t)}},{key:"update",value:function(t){Object.assign(this,t)}}])&&n(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4013:(t,e,r)=>{"use strict";r.d(e,{Z:()=>y});var n=r(3203),o=r(9010),i=r(4395);function a(t,e,r){return a=s()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&c(o,r.prototype),o},a.apply(null,arguments)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r(9327);var p=f((function t(e){var r=this;h(this,t),d(this,"setTarget",(function(t){r.cameraTarget=t,r.updateViewFromAngles()})),d(this,"setCamera",(function(){(0,n.t8)((0,n.Ue)(),r.uViewMat),(0,n.Iu)(r.uViewMat,r.uViewMat,[0,0,-15]),(0,n.U1)(r.uViewMat,r.uViewMat,(0,o.Id)(r.cameraAngle*r.cameraVector.x),[1,0,0]),(0,n.U1)(r.uViewMat,r.uViewMat,(0,o.Id)(r.cameraAngle*r.cameraVector.y),[0,1,0]),(0,n.U1)(r.uViewMat,r.uViewMat,(0,o.Id)(r.cameraAngle*r.cameraVector.z),[0,0,1]),(0,o.tk)(r.cameraPosition,r.cameraOffset),(0,n.Iu)(r.uViewMat,r.uViewMat,r.cameraOffset.toArray()),r.cameraDir=i.Nm.adjustCameraDirection(r.cameraVector)})),d(this,"changeAngle",(function(t){r.lookAt(r.cameraPosition.toArray(),r.cameraOffset.toArray(),t)})),d(this,"lookAt",(function(t,e,i){var s=(0,n.Fv)((0,n.fk)(t,e));Number.isFinite(s[0])&&Number.isFinite(s[1])&&Number.isFinite(s[2])||(s=[0,0,1]);var c,l=a(o.OW,function(t){if(Array.isArray(t))return u(t)}(c=s)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(c)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(c)||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.")}());0===l.length()&&(l=new o.OW(0,0,1));var f=i.cross(l).normal();0===f.length()&&(f=new o.OW(1,0,0));var h=l.cross(f).normal(),d=[f.x,f.y,f.z,0,h.x,h.y,h.z,0,l.x,l.y,l.z,0,t.x,t.y,t.z,1];r.uViewMat=(0,n.t8)(d,r.uViewMat)})),d(this,"setFromViewMatrix",(function(t){if(t)try{r.cameraPosition=new o.OW(t[12],t[13],t[14]);var e=t[8],n=t[9],i=t[10],a=-e,s=-n,c=-i;r.yaw=Math.atan2(s,a),r.pitch=Math.asin(c/Math.max(1e-6,Math.hypot(a,s,c)));var u=Math.hypot(a,s,c),l=new o.OW(a/(u||1),s/(u||1),c/(u||1));r.cameraDistance=r.cameraDistance||15,r.cameraTarget=r.cameraPosition.add(l.mul(-1*r.cameraDistance))}catch(t){}})),d(this,"updateViewFromAngles",(function(){Number.isFinite(r.yaw)||(r.yaw=0),Number.isFinite(r.pitch)||(r.pitch=0),(!Number.isFinite(r.cameraDistance)||r.cameraDistance<=0)&&(r.cameraDistance=Math.max(.1,Math.abs(r.cameraDistance)||15));var t=r.cameraTarget.x+r.cameraDistance*Math.cos(r.pitch)*Math.cos(r.yaw),e=r.cameraTarget.y+r.cameraDistance*Math.cos(r.pitch)*Math.sin(r.yaw),n=r.cameraTarget.z+r.cameraDistance*Math.sin(r.pitch),i=new o.OW(t,e,n);r.cameraPosition=new o.OW(i.x,i.y,i.z);var a=new o.OW(r.cameraTarget.x,r.cameraTarget.y,r.cameraTarget.z),s=new o.OW(0,0,1);r.lookAt(i,a,s);var c=180*r.yaw/Math.PI%360;c<0&&(c+=360);var u=(90-c+360)%360,l=Math.round(u/45)%8;r.cameraDir=["N","NE","E","SE","S","SW","W","NW"][l],r.cameraVector.z=l})),d(this,"translateCam",(function(t){var e=new o.OW(Math.cos(r.pitch)*Math.cos(r.yaw),Math.cos(r.pitch)*Math.sin(r.yaw),Math.sin(r.pitch)).normal(),n=new o.OW(-Math.sin(r.yaw),Math.cos(r.yaw),0).normal();switch(t){case"UP":r.cameraTarget=r.cameraTarget.add(e.mul(.5));break;case"DOWN":r.cameraTarget=r.cameraTarget.add(e.mul(-.5));break;case"LEFT":r.cameraTarget=r.cameraTarget.add(n.mul(-.5));break;case"RIGHT":r.cameraTarget=r.cameraTarget.add(n.mul(.5))}r.updateViewFromAngles()})),d(this,"rotateCam",(function(t){var e=.05;switch(t){case"LEFT":r.yaw-=e;break;case"RIGHT":r.yaw+=e;break;case"UP":r.pitch=Math.max(-Math.PI/2+.01,r.pitch-e);break;case"DOWN":r.pitch=Math.min(Math.PI/2-.01,r.pitch+e)}r.updateViewFromAngles()})),d(this,"zoom",(function(t){r.cameraDistance=Math.max(.1,r.cameraDistance+t),r.updateViewFromAngles()})),d(this,"panCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.yaw-=t,r.updateViewFromAngles()})),d(this,"panCCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.yaw+=t,r.updateViewFromAngles()})),d(this,"pitchCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.pitch-=t,r.updateViewFromAngles()})),d(this,"pitchCCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.pitch+=t,r.updateViewFromAngles()})),d(this,"tiltCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.pitch-=.1*t,r.updateViewFromAngles()})),d(this,"tiltCCW",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.PI/4;r.pitch+=.1*t,r.updateViewFromAngles()})),Number.prototype.clamp=function(t,e){return this<t?t:this>e?e:this},this.renderingManager=e,this.uViewMat=(0,n.Ue)(),this.fov=45,this.thetaLimits=a(o.OW,[1.5*Math.PI,1.8*Math.PI,0]),this.cameraAngle=45,this.cameraVector=a(o.OW,[1,0,0]),this.cameraDir="N",this.cameraPosition=new o.OW(8,8,-1),this.yaw=0,this.pitch=0,this.cameraDistance=15,this.cameraTarget=new o.OW(8,8,-1),this.cameraOffset=new o.OW(0,0,0)})),y=f((function t(e){return h(this,t),t.instance||(this.camera=new p(e),t.instance=this),t.instance}))},9327:(t,e,r)=>{"use strict";r.d(e,{Z:()=>T});var n=r(3203),o=r(9010),i=r(6345),a=r(4013);function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r(9124);var f=c((function t(e){var r=this;return u(this,t),l(this,"addLight",(function(t,e,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[.8,.8,.8],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[1,1,1],a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[1,1,1],c=!(arguments.length>7&&void 0!==arguments[7])||arguments[7],u=r.renderManager.shaderProgram,l=r.lights.length;if(!(l>=u.maxLights)){var f=new h(r.renderManager.engine,t,n,e,o,i,a,s,c);return r.lights[t]=f,t}})),l(this,"updateLight",(function(t,e,n,o,i,a,s,c){var u=r.lights[t];u&&(e&&(u.pos=e),n&&(u.color=n),o&&(u.attenuation=o),i&&(u.direction=i),a&&(u.density=a),s&&(u.scatteringCoefficients=s),c&&(u.enabled=c),r.lights[t]=u)})),l(this,"removeLight",(function(t){delete r.lights[t]})),l(this,"tick",(function(){for(var t=Object.keys(r.lights),e=0;e<t.length;e++)r.lights[t[e]].tick()})),l(this,"render",(function(){var t=r.renderManager.shaderProgram,e=t.uLights;if(e)for(var n=0;n<t.maxLights;n++){var o=Object.keys(r.lights);r.lights[o[n]]&&r.lights[o[n]].enabled&&r.lights[o[n]].draw(e[n])}})),l(this,"setMatrixUniforms",(function(){r.tick(),r.render()})),t.instance||(this.lights={},this.renderManager=e,this.engine=e.engine,t.instance=this),t.instance})),h=c((function t(e,r,n,o,i,a,s,c,f){var h=this;u(this,t),l(this,"tick",(function(){h.frame++})),l(this,"draw",(function(t){var e=h.engine.gl;e.uniform1f(t.enabled,h.enabled),e.uniform3fv(t.position,h.pos),e.uniform3fv(t.color,h.color),e.uniform3fv(t.attenuation,h.attenuation),e.uniform3fv(t.direction,h.direction),e.uniform3fv(t.scatteringCoefficients,h.scatteringCoefficients),e.uniform1f(t.density,h.density)})),this.engine=e,this.id=null!=r?r:"light",this.color=null!=n?n:[1,1,1],this.pos=null!=o?o:[0,0,0],this.attenuation=null!=i?i:[.5,.1,0],this.density=null!=s?s:.8,this.scatteringCoefficients=null!=c?c:[.5,.5,.5],this.direction=null!=a?a:[1,1,1],this.enabled=null==f||f,this.frame=0}));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 p(){p=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function y(){}var g={};s(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=f.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==d(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=y,s(b,"constructor",y),s(y,"constructor",h),h.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,a,"Generator"),s(b,o,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function y(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){y(i,n,o,a,s,"next",t)}function s(t){y(i,n,o,a,s,"throw",t)}a(void 0)}))}}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function v(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var b=function(){function t(e){var r=this;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,"loadShader",(function(t,e){var n=r.engine.gl,o=n.createShader(t);if(n.shaderSource(o,e),n.compileShader(o),!n.getShaderParameter(o,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(o);throw n.deleteShader(o),new Error("An error occurred compiling the shaders: ".concat(i))}return o})),v(this,"initTextureShaderProgram",(function(t){var e=t.vs,n=t.fs,o=r.engine.gl,i=r,a=r.loadShader(o.VERTEX_SHADER,e),s=r.loadShader(o.FRAGMENT_SHADER,n),c=o.createProgram();if(o.attachShader(c,a),o.attachShader(c,s),o.linkProgram(c),!o.getProgramParameter(c,o.LINK_STATUS))throw new Error("WebGL unable to initialize the shader program: ".concat(c));return c.aVertexPosition=o.getAttribLocation(c,"aVertexPosition"),o.enableVertexAttribArray(c.aVertexPosition),c.uSkyboxTexture=o.getUniformLocation(c,"uSkyboxTexture"),c.uSkyboxCenter=o.getUniformLocation(c,"uSkyboxCenter"),c.uProjectionMatrix=o.getUniformLocation(c,"uProjectionMatrix"),c.uModelMatrix=o.getUniformLocation(c,"uModelMatrix"),c.uViewMatrix=o.getUniformLocation(c,"uViewMatrix"),c.setMatrixUniforms=function(){var t=i.uModelMat,e=i.camera.uViewMat,r=i.uProjMat;o.uniformMatrix4fv(this.uProjectionMatrix,!1,r),o.uniformMatrix4fv(this.uModelMatrix,!1,t),o.uniformMatrix4fv(this.uViewMatrix,!1,e)},r.shaderProgram=c,c})),t.instance||(this.renderManager=e,this.engine=e.engine,t.instance=this),t.instance}var e,n,o,i;return e=t,n=[{key:"setSkyboxShader",value:(i=g(p().mark((function t(e){var n,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.engine.gl){t.next=2;break}return t.abrupt("return");case 2:return this.gl=this.engine.gl,t.next=5,r(4970)("./".concat(e,"/vs.js"));case 5:return n=t.sent.default(),t.next=8,r(746)("./".concat(e,"/fs.js"));case 8:o=t.sent.default(),this.shaderProgram=this.initSkyboxShaderProgram(n,o);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"init",value:(o=g(p().mark((function t(){var e,n,o,i,a,s=arguments;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=s.length>0&&void 0!==s[0]?s[0]:null,n=s.length>1&&void 0!==s[1]?s[1]:"cosmic",o=s.length>2&&void 0!==s[2]?s[2]:[0,0,0],this.engine.gl){t.next=5;break}return t.abrupt("return");case 5:if(this.gl=this.engine.gl,!e){t.next=13;break}return t.next=9,this.engine.resourceManager.loadTextureFromZip(e,this.engine.spritz.zip);case 9:this.texture=t.sent,this.texture.runWhenLoaded(this.createTextureSkyboxProgram),t.next=20;break;case 13:return t.next=15,r(4970)("./"+n+"/vs.js");case 15:return i=t.sent.default(),t.next=18,r(746)("./"+n+"/fs.js");case 18:a=t.sent.default(),this.shaderProgram=this.initSkyboxShaderProgram(i,a);case 20:this.cubeMap=this.createDefaultCubeMap(),this.skyboxCenter=o,this.buffer=this.createSkyboxBuffer(),this.initialized=!0;case 24:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"createDefaultCubeMap",value:function(){var t=this.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_CUBE_MAP,e),[{target:t.TEXTURE_CUBE_MAP_POSITIVE_X,color:[255,0,0,255]},{target:t.TEXTURE_CUBE_MAP_NEGATIVE_X,color:[0,255,0,255]},{target:t.TEXTURE_CUBE_MAP_POSITIVE_Y,color:[0,0,255,255]},{target:t.TEXTURE_CUBE_MAP_NEGATIVE_Y,color:[255,255,0,255]},{target:t.TEXTURE_CUBE_MAP_POSITIVE_Z,color:[0,255,255,255]},{target:t.TEXTURE_CUBE_MAP_NEGATIVE_Z,color:[255,0,255,255]}].forEach((function(e){var r=e.target,n=e.color,o=new Uint8Array(n);t.texImage2D(r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,o)})),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}},{key:"createSkyboxBuffer",value:function(){this.vertices=[-1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1],this.numVertices=this.vertices.length/3;var t=this.gl.createBuffer();return this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.vertices),this.gl.STATIC_DRAW),t}},{key:"initSkyboxShaderProgram",value:function(t,e){var r=this.engine.gl,n=this.loadShader(r.VERTEX_SHADER,t),o=this.loadShader(r.FRAGMENT_SHADER,e),i=r.createProgram();if(r.attachShader(i,n),r.attachShader(i,o),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS))throw new Error("WebGL unable to initialize the skybox shader program");return i.aPosition=r.getAttribLocation(i,"aPosition"),r.enableVertexAttribArray(i.aPosition),i.pMatrixUniform=r.getUniformLocation(i,"uProjectionMatrix"),i.uSkybox=r.getUniformLocation(i,"uSkybox"),i.uViewDirectionProjectionInverse=r.getUniformLocation(i,"uViewDirectionProjectionInverse"),i.uTime=r.getUniformLocation(i,"uTime"),i.uResolution=r.getUniformLocation(i,"uResolution"),i}},{key:"renderSkybox",value:function(t){if(this.initialized&&this.shaderProgram){var e=this.engine.gl;e.useProgram(this.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.enableVertexAttribArray(this.shaderProgram.aPosition),e.vertexAttribPointer(this.shaderProgram.aPosition,3,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this.cubeMap),e.uniform1i(this.shaderProgram.uSkybox,0),e.uniformMatrix4fv(this.shaderProgram.uViewDirectionProjectionInverse,!1,t);var r=.001*Date.now();if(-1!==this.shaderProgram.uTime&&null!==this.shaderProgram.uTime&&e.uniform1f(this.shaderProgram.uTime,r),void 0!==this.shaderProgram.uResolution){var n=e.drawingBufferWidth||this.engine.canvas.width||800,o=e.drawingBufferHeight||this.engine.canvas.height||600;e.uniform2f(this.shaderProgram.uResolution,n,o)}e.drawArrays(e.TRIANGLE_STRIP,0,this.numVertices),e.bindBuffer(e.ARRAY_BUFFER,null),e.useProgram(null)}}},{key:"createTextureSkyboxProgram",value:function(){return this.initShaderProgram({vs:"#version 300 es\n in vec3 aVertexPosition;\n uniform mat4 uProjectionMatrix;\n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n void main() {\n gl_Position = uProjectionMatrix * uModelMatrix * uViewMatrix * vec4(aVertexPosition, 1.0);\n }\n ",fs:"#version 300 es\n precision highp float;\n uniform sampler2D uSkyboxTexture;\n uniform vec3 uSkyboxCenter;\n out vec4 outColor;\n void main() {\n vec3 direction = normalize(gl_FragCoord.xyz - uSkyboxCenter);\n vec4 skyboxColor = texture(uSkyboxTexture, direction.xy);\n float dotProduct = dot(direction, skyboxColor.rgb);\n if (dotProduct < 0.01) {\n discard;\n } else {\n outColor = vec4(dotProduct, dotProduct, dotProduct, 1.0);\n }\n }\n "})}}],n&&m(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _(t,e,r){return e&&x(t.prototype,e),r&&x(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function k(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var E=_((function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),k(this,"init",(function(){var t=r.engine.gl;t&&(r.vertexPosBuf=r.renderManager.createBuffer([-.5,-.5,0,-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,.5,0,.5,-.5,0],t.STATIC_DRAW,3),r.vertexTexBuf=r.renderManager.createBuffer([0,0,0,1,1,1,0,0,1,1,1,0],t.STATIC_DRAW,2),r.initialized=!0)})),k(this,"emit",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Array.isArray(t)?t:t.toArray?t.toArray():[0,0,0],o=n[0],i=n[1],a=n[2]||0,s=r.engine.spritz.world.zoneContaining(o,i),c=a;s&&(c+=s.getHeight(o,i)),n=[o,i,c];for(var u=Object.assign({count:8,life:1e3,speed:.02,spread:.5,size:.5,color:[1,.7,.2],gravity:[0,-98e-5,0],drag:.995},e),l=0;l<u.count;l++){var f=(2*Math.random()-1)*u.spread,h=(2*Math.random()-1)*u.spread,d=(2*Math.random()-1)*u.spread,p=f*u.speed*(.5+1.5*Math.random()),y=h*u.speed*(.5+1.5*Math.random()),g=d*u.speed*(.5+1.5*Math.random()),m={pos:[n[0],n[1],n[2]],vel:[p,y,g],life:u.life,age:0,size:u.size*(.8+.8*Math.random()),color:u.color,gravity:u.gravity,drag:u.drag};r.particles.push(m)}})),k(this,"preset",(function(t){switch((t||"").toLowerCase()){case"sparks":return{count:12,life:700,speed:.06,spread:1.2,size:.15,color:[1,.8,.2],gravity:[0,-.002,0]};case"flame":return{count:200,life:2e3,speed:.02,spread:.8,size:.06,color:[1,.5,.1],gravity:[0,-3e-4,0],drag:.995};case"water":return{count:20,life:800,speed:.05,spread:1.5,size:.12,color:[.6,.7,1],gravity:[0,-.003,0],drag:.996};case"weapon":return{count:6,life:600,speed:.08,spread:.3,size:.18,color:[1,1,.6],gravity:[0,-.001,0]};default:return null}})),k(this,"update",(function(t){r.lastUpdateTime||(r.lastUpdateTime=t);var e=t-r.lastUpdateTime;if(r.lastUpdateTime=t,e)for(var n=r.particles.length-1;n>=0;n--){var o=r.particles[n];o.vel[0]+=(o.gravity[0]||0)*e,o.vel[1]+=(o.gravity[1]||0)*e,o.vel[2]+=(o.gravity[2]||0)*e,o.vel[0]*=Math.pow(o.drag||1,e/16.6667),o.vel[1]*=Math.pow(o.drag||1,e/16.6667),o.vel[2]*=Math.pow(o.drag||1,e/16.6667),o.pos[0]+=o.vel[0]*e,o.pos[1]+=o.vel[1]*e,o.pos[2]+=o.vel[2]*e,o.age+=e,o.age>=o.life&&r.particles.splice(n,1)}})),k(this,"render",(function(){if(r.initialized||r.init(),r.initialized&&r.particles.length){var t=r.renderManager,e=r.engine.gl,i=t.particleShaderProgram;if(i){e.useProgram(i),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.enableVertexAttribArray(i.aVertexPosition),e.enableVertexAttribArray(i.aTextureCoord);var a,s=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return w(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(r.particles);try{for(s.s();!(a=s.n()).done;){var c=a.value;t.mvPushMatrix();var u=t.uModelMat;u[12]=c.pos[0],u[13]=c.pos[1],u[14]=c.pos[2],(0,n.U1)(t.uModelMat,t.uModelMat,(0,o.Id)(t.camera.cameraAngle*t.camera.cameraVector.z),[0,0,-1]);var l=new o.OW(c.size,c.size,c.size);i.setMatrixUniforms({scale:l,color:c.color}),t.bindBuffer(r.vertexPosBuf,i.aVertexPosition),t.bindBuffer(r.vertexTexBuf,i.aTextureCoord),e.drawArrays(e.TRIANGLES,0,r.vertexPosBuf.numItems),t.mvPopMatrix()}}catch(t){s.e(t)}finally{s.f()}e.bindBuffer(e.ARRAY_BUFFER,null),e.useProgram(null)}}})),this.renderManager=e,this.engine=e.engine,this.particles=[],this.initialized=!1,this.vertexPosBuf=null,this.vertexTexBuf=null,this.lastUpdateTime=null}));function A(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return S(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(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 S(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function O(t,e,r){return e&&L(t.prototype,e),r&&L(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var T=O((function t(e){var s=this;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),P(this,"init",(function(){var t=s.engine,e=t.spritz,n=t.gl;if(n.clearColor(0,1,0,1),n.clearDepth(1),n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL),s.framebuffer=n.createFramebuffer(),s.initShaderProgram(e.shaders),s.initParticleShaderProgram(),s.initShaderEffects({id:"picker",vs:r(1704).Z(),fs:r(1108).Z(),init:r(5911).Z}),e.effects)for(var o in e.effects);s.initProjection(),s.skyboxManager.init(),s.initializedWebGl=!0})),P(this,"loadShader",(function(t,e){var r=s.engine.gl,n=r.createShader(t);if(r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS)){var o=r.getShaderInfoLog(n);throw r.deleteShader(n),new Error("An error occurred compiling the shaders: ".concat(o))}return n})),P(this,"initShaderProgram",(function(t){var e=t.vs,r=t.fs,o=s.engine.gl,a=s,c=s.loadShader(o.VERTEX_SHADER,e),u=s.loadShader(o.FRAGMENT_SHADER,r),l=o.createProgram();if(o.attachShader(l,c),o.attachShader(l,u),o.bindAttribLocation(l,0,"aVertexPosition"),o.bindAttribLocation(l,1,"aTextureCoord"),o.linkProgram(l),!o.getProgramParameter(l,o.LINK_STATUS))throw new Error("WebGL unable to initialize the shader program: ".concat(o.getProgramInfoLog(l)));l.aVertexNormal=o.getAttribLocation(l,"aVertexNormal"),l.aVertexNormal>=0&&o.enableVertexAttribArray(l.aVertexNormal),l.aVertexPosition=o.getAttribLocation(l,"aVertexPosition"),l.aVertexPosition>=0&&o.enableVertexAttribArray(l.aVertexPosition),l.aTextureCoord=o.getAttribLocation(l,"aTextureCoord"),l.aTextureCoord>=0&&o.enableVertexAttribArray(l.aTextureCoord),l.uDiffuse=o.getUniformLocation(l,"uDiffuse"),l.uSpecular=o.getUniformLocation(l,"uSpecular"),l.uSpecularExponent=o.getUniformLocation(l,"uSpecularExponent"),l.pMatrixUniform=o.getUniformLocation(l,"uProjectionMatrix"),l.mMatrixUniform=o.getUniformLocation(l,"uModelMatrix"),l.vMatrixUniform=o.getUniformLocation(l,"uViewMatrix"),l.nMatrixUniform=o.getUniformLocation(l,"uNormalMatrix"),l.samplerUniform=o.getUniformLocation(l,"uSampler"),l.diffuseMapUniform=o.getUniformLocation(l,"uDiffuseMap"),l.cameraPosition=o.getUniformLocation(l,"uCameraPosition"),l.runTransition=o.getUniformLocation(l,"runTransition"),l.useSampler=o.getUniformLocation(l,"useSampler"),l.useDiffuse=o.getUniformLocation(l,"useDiffuse"),l.isSelected=o.getUniformLocation(l,"isSelected"),l.colorMultiplier=o.getUniformLocation(l,"uColorMultiplier"),l.scale=o.getUniformLocation(l,"u_scale"),l.id=o.getUniformLocation(l,"u_id"),l.maxLights=32,l.uLights=[];for(var f=0;f<l.maxLights;f++)l.uLights[f]={enabled:o.getUniformLocation(l,"uLights[".concat(f,"].enabled")),color:o.getUniformLocation(l,"uLights[".concat(f,"].color")),position:o.getUniformLocation(l,"uLights[".concat(f,"].position")),attenuation:o.getUniformLocation(l,"uLights[".concat(f,"].attenuation")),direction:o.getUniformLocation(l,"uLights[".concat(f,"].direction")),scatteringCoefficients:o.getUniformLocation(l,"uLights[".concat(f,"].scatteringCoefficients")),density:o.getUniformLocation(l,"uLights[".concat(f,"].density"))};l.setMatrixUniforms=function(t){var e=t.id,r=void 0===e?null:e,i=t.scale,s=void 0===i?null:i,c=t.sampler,u=void 0===c?1:c,f=t.isSelected,h=void 0!==f&&f,d=t.colorMultiplier,p=void 0===d?null:d;o.useProgram(l),o.uniformMatrix4fv(this.pMatrixUniform,!1,a.uProjMat),o.uniformMatrix4fv(this.mMatrixUniform,!1,a.uModelMat),o.uniformMatrix4fv(this.vMatrixUniform,!1,a.camera.uViewMat),a.normalMatrix=(0,n.Ez)(),(0,n.XL)(a.normalMatrix,a.uModelMat),o.uniformMatrix3fv(this.nMatrixUniform,!1,a.normalMatrix),o.uniform3fv(this.scale,s?s.toArray():a.scale.toArray()),o.uniform4fv(this.id,r||[1,0,0,0]),o.uniform1f(this.isSelected,h?1:0),o.uniform4fv(this.colorMultiplier,p||[1,1,1,1]),o.uniform1f(this.useSampler,u),o.uniform1f(this.runTransition,a.isTransitioning?1:0),o.uniform3fv(this.cameraPosition,a.camera.cameraPosition.toArray()),a.lightManager.setMatrixUniforms()};var h={aVertexPosition:i.NQ.Layout.POSITION.key,aVertexNormal:i.NQ.Layout.NORMAL.key,aTextureCoord:i.NQ.Layout.UV.key};return l.applyAttributePointers=function(t){var e=t.vertexBuffer.layout;for(var r in h)if(h.hasOwnProperty(r)&&-1!==l[r]){var n=h[r];if(-1!==l[r]){var i=e.attributeMap[n];o.vertexAttribPointer(l[r],i.size,o[i.type],i.normalized,i.stride,i.offset)}}},s.shaderProgram=l,l})),P(this,"initParticleShaderProgram",(function(){var t=s.engine.gl,e=s,n=r(8062).Z(),o=r(4399).Z(),i=s.loadShader(t.VERTEX_SHADER,n),a=s.loadShader(t.FRAGMENT_SHADER,o),c=t.createProgram();if(t.attachShader(c,i),t.attachShader(c,a),t.bindAttribLocation(c,0,"aVertexPosition"),t.bindAttribLocation(c,1,"aTextureCoord"),t.linkProgram(c),!t.getProgramParameter(c,t.LINK_STATUS))throw new Error("WebGL unable to initialize the particle shader program: ".concat(t.getProgramInfoLog(c)));return c.aVertexPosition=t.getAttribLocation(c,"aVertexPosition"),t.enableVertexAttribArray(c.aVertexPosition),c.aTextureCoord=t.getAttribLocation(c,"aTextureCoord"),t.enableVertexAttribArray(c.aTextureCoord),c.pMatrixUniform=t.getUniformLocation(c,"uProjectionMatrix"),c.mMatrixUniform=t.getUniformLocation(c,"uModelMatrix"),c.vMatrixUniform=t.getUniformLocation(c,"uViewMatrix"),c.scaleUniform=t.getUniformLocation(c,"uScale"),c.particleColorUniform=t.getUniformLocation(c,"uParticleColor"),c.setMatrixUniforms=function(r){var n=r.color,o=void 0===n?null:n,i=r.scale,a=void 0===i?null:i;t.useProgram(c),t.uniformMatrix4fv(this.pMatrixUniform,!1,e.uProjMat),t.uniformMatrix4fv(this.mMatrixUniform,!1,e.uModelMat),t.uniformMatrix4fv(this.vMatrixUniform,!1,e.camera.uViewMat),t.uniform3fv(this.scaleUniform,a?a.toArray():e.scale.toArray()),t.uniform3fv(this.particleColorUniform,o||[1,1,1])},s.particleShaderProgram=c,c})),P(this,"updateParticles",(function(t){s.particleManager&&"function"==typeof s.particleManager.update&&s.particleManager.update(t)})),P(this,"renderParticles",(function(){s.particleManager&&"function"==typeof s.particleManager.render&&s.particleManager.render()})),P(this,"activateShaderProgram",(function(){var t=s.engine.gl;t.useProgram(s.shaderProgram),t.bindFramebuffer(t.FRAMEBUFFER,null),s.initProjection()})),P(this,"activatePickerShaderProgram",(function(t){var e=s.engine.gl;e.useProgram(s.effectPrograms.picker),t?(e.bindFramebuffer(e.FRAMEBUFFER,s.framebuffer),s.initProjection(),s.applyPixelFrustum()):(e.bindFramebuffer(e.FRAMEBUFFER,null),s.initProjection())})),P(this,"activateShaderEffectProgram",(function(t){s.engine.gl.useProgram(s.effectPrograms[t])})),P(this,"initShaderEffects",(function(t){var e=t.vs,r=t.fs,n=t.id,o=t.init,i=s.engine.gl,a=s,c=s.loadShader(i.VERTEX_SHADER,e),u=s.loadShader(i.FRAGMENT_SHADER,r),l=i.createProgram();if(i.attachShader(l,c),i.attachShader(l,u),i.bindAttribLocation(l,0,"aVertexPosition"),i.bindAttribLocation(l,1,"aTextureCoord"),i.linkProgram(l),!i.getProgramParameter(l,i.LINK_STATUS))throw new Error("WebGL unable to initialize the shader effect program: ".concat(i.getProgramInfoLog(l)));return s.effectPrograms[n]=o.call(a,l),s.effects.push(n),i.deleteShader(c),i.deleteShader(u),s.effectPrograms[n]})),P(this,"initProjection",(function(){var t=s.engine.gl,e=(0,o.Id)(s.camera.fov),r=t.canvas.clientWidth/t.canvas.clientHeight;t.enable(t.DEPTH_TEST),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.enable(t.BLEND),t.viewport(0,0,t.canvas.width,t.canvas.height),s.uProjMat=(0,n.G3)(e,r,.1,100),s.camera.uViewMat||(s.camera.uViewMat=(0,n.Ue)()),s.uProjMat[5]*=-1})),P(this,"enableCulling",(function(){var t=s.engine.gl;t.enable(t.CULL_FACE),t.cullFace(t.BACK)})),P(this,"disableCulling",(function(){var t=s.engine.gl;t.disable(t.CULL_FACE)})),P(this,"enableBlending",(function(){var t=s.engine.gl;t.enable(t.BLEND)})),P(this,"disableBlending",(function(){var t=s.engine.gl;t.disable(t.BLEND)})),P(this,"clearScreen",(function(){var t=s.engine.gl;t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)})),P(this,"applyPixelFrustum",(function(){var t=s.engine.gl,e=t.canvas.clientWidth/t.canvas.clientHeight,r=.1*Math.tan(.5*(0,o.Id)(s.camera.fov)),i=-r,a=e*i,c=e*r,u=Math.abs(c-a),l=Math.abs(r-i),f=s.engine.gamepad.x||0,h=s.engine.gamepad.y||0,d=f*t.canvas.width/t.canvas.clientWidth,p=t.canvas.height-h*t.canvas.height/t.canvas.clientHeight-1,y=a+d*u/t.canvas.width,g=i+p*l/t.canvas.height,m=u/t.canvas.width,v=l/t.canvas.height;t.enable(t.DEPTH_TEST),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.enable(t.BLEND),t.viewport(0,0,1,1),s.uProjMat=(0,n.oy)(y,y+m,g,g+v,.1,100),s.uProjMat[5]*=-1})),P(this,"toggleFullscreen",(function(){if(s.fullscreen){try{document.exitFullscreen()}catch(t){}s.fullscreen=!1}else try{s.engine.gamepadcanvas.parentElement.requestFullscreen(),s.fullscreen=!0}catch(t){}})),P(this,"mvPushMatrix",(function(){var t=(0,n.Ue)();(0,n.t8)(s.uModelMat,t);var e=(0,n.Ue)();(0,n.t8)(s.camera.uViewMat,e),s.modelViewMatrixStack.push([t,e])})),P(this,"mvPopMatrix",(function(){if(0===s.modelViewMatrixStack.length)throw new Error("Invalid popMatrix! Matrix stack is empty.");var t=A(s.modelViewMatrixStack.pop(),2);s.uModelMat=t[0],s.camera.uViewMat=t[1]})),P(this,"transition",(function(){(new Date).getMilliseconds()>=s.transitionTime&&(s.isTransitioning=!1)})),P(this,"createBuffer",(function(t,e,r){var n=s.engine.gl,o=n.createBuffer();return o.itemSize=r,o.numItems=t.length/r,n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t),e),n.bindBuffer(n.ARRAY_BUFFER,null),o})),P(this,"updateBuffer",(function(t,e){var r=s.engine.gl;r.bindBuffer(r.ARRAY_BUFFER,t),r.bufferSubData(r.ARRAY_BUFFER,0,new Float32Array(e)),r.bindBuffer(r.ARRAY_BUFFER,null)})),P(this,"bindBuffer",(function(t,e){var r=s.engine.gl;r.bindBuffer(r.ARRAY_BUFFER,t),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.itemSize,r.FLOAT,!1,0,0)})),P(this,"startTransition",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.effect,r=void 0===e?"fade":e,n=t.direction,o=void 0===n?"out":n,i=t.duration,a=void 0===i?1e3:i,c=function(){return s.isTransitioning=!0,s.transitionEffect=r,s.transitionDirection=o,s.transitionDuration=a,s.transitionStartTime=performance.now(),new Promise((function(t){s.transitionCallback=t}))};if(s.isTransitioning){var u=s.transitionCallback;return new Promise((function(t){s.transitionCallback=function(){null==u||u(),c().then(t)}}))}return c()})),P(this,"updateTransition",(function(){if(s.isTransitioning){var t=(performance.now()-s.transitionStartTime)/s.transitionDuration;if(t>=1&&(t=1),s.renderTransition(t),t>=1){s.isTransitioning=!1;var e=s.transitionCallback;s.transitionCallback=null,e&&e()}}})),P(this,"initTransitionProgram",(function(t){var e=s.engine.gl;if(!s.transitionGL[t]){var n=t;n.startsWith("fade")&&(n="fade");var o=function(t){var e=null,n=null,o=(t||"").toLowerCase();return"cross"===o?(e=r(6404).Z(),n=r(4522).Z()):"crossblur"===o||"cross-blur"===o?(e=r(9357).Z(),n=r(7319).Z()):"swirl"===o?(e=r(9188).Z(),n=r(8946).Z()):"blur"===o||"blur-in"===o||"blur-out"===o?(e=r(1564).Z(),n=r(5311).Z()):(e=r(8900).Z(),n=r(2913).Z()),[e,n]}(n),i=A(o,2),a=i[0],c=i[1],u=s.loadShader(e.VERTEX_SHADER,a),l=s.loadShader(e.FRAGMENT_SHADER,c),f=e.createProgram();if(e.attachShader(f,u),e.attachShader(f,l),e.bindAttribLocation(f,0,"aPosition"),e.linkProgram(f),!e.getProgramParameter(f,e.LINK_STATUS))throw new Error('Could not link transition shader program for effect "'.concat(t,'": ').concat(e.getProgramInfoLog(f)));var h=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,h);var d=new Float32Array([-1,-1,-1,1,1,-1,1,1]);e.bufferData(e.ARRAY_BUFFER,d,e.STATIC_DRAW);var p=e.getUniformLocation(f,"uProgress"),y=e.getUniformLocation(f,"uDirection");s.transitionGL[t]={program:f,buffer:h,uProgress:p,uDirection:y},e.deleteShader(u),e.deleteShader(l)}})),P(this,"renderTransition",(function(t){if(s.engine.spritz.loaded){var e=s.engine.gl,r=s.transitionEffect||"fade";s.initTransitionProgram(r);var n=s.transitionGL[r];if(n){var o=e.isEnabled(e.DEPTH_TEST),i=e.isEnabled(e.BLEND),a=e.getParameter(e.BLEND_SRC_RGB),c=e.getParameter(e.BLEND_DST_RGB);e.useProgram(n.program),e.bindBuffer(e.ARRAY_BUFFER,n.buffer),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.uniform1f(n.uProgress,t);var u="in"===s.transitionDirection?1:0;e.uniform1f(n.uDirection,u),e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLE_STRIP,0,4),o?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),i||e.disable(e.BLEND),e.blendFunc(a,c),e.bindBuffer(e.ARRAY_BUFFER,null),e.useProgram(null)}}})),P(this,"renderSkybox",(function(){s.engine.spritz.loaded&&s.skyboxManager.renderSkybox(s.uProjMat)})),P(this,"resetDebugCounters",(function(){s.debug&&(s.debug.tilesDrawn=0,s.debug.spritesDrawn=0,s.debug.objectsDrawn=0)})),t._instance||(this.engine=e,this.fullscreen=e.fullscreen,this.uProjMat=(0,n.Ue)(),this.uModelMat=(0,n.Ue)(),this.normalMatrix=(0,n.Ez)(),this.modelViewMatrixStack=[],this.scale=new o.OW(1,1,1),this.initializedWebGl=!1,this.effects=[],this.effectPrograms={},this.framebuffer=null,this.isTransitioning=!1,this.transitionEffect=null,this.transitionDirection="out",this.transitionDuration=0,this.transitionStartTime=0,this.transitionCallback=null,this.transitionGL={},this.debug={tilesDrawn:0,spritesDrawn:0,objectsDrawn:0},this.cameraManager=new a.Z(this),this.camera=this.cameraManager.camera,this.lightManager=new f(this),this.skyboxManager=new b(this),this.particleManager=new E(this),this.particleShaderProgram=null,this.shaderProgram=null,t._instance=this),t._instance}))},2737:(t,e,r)=>{"use strict";r.d(e,{Z:()=>p});var n=r(9010),o=r(4395),i=r(679);function a(t){return a="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},a(t)}function s(t,e,r){return s=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&c(o,r.prototype),o},s.apply(null,arguments)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function u(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function d(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var p=function(t){!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&&c(t,e)}(y,t);var e,r,a,p=(e=y,r=f(),function(){var t,n=h(e);if(r){var o=h(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return u(this,t)});function y(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,y),d(l(e=p.call(this,t)),"getAvatarData",(function(){return{id:e.objId,templateLoaded:e.templateLoaded,drawOffset:e.drawOffset,hotspotOffset:e.hotspotOffset,animFrame:e.animFrame,fixed:e.fixed,pos:e.pos,scale:e.scale,facing:e.facing,actionDict:e.actionDict,actionList:e.actionList,gender:e.gender,speech:e.speech,portrait:e.portrait,inventory:e.inventory,blocking:e.blocking,override:e.override,isLit:e.isLit,lightIndex:e.lightIndex,lightColor:e.lightColor,density:e.density,isSelected:e.isSelected}})),d(l(e),"init",(function(){console.log({msg:"- avatar hook",id:e.id,pos:e.pos,avatar:l(e)})})),d(l(e),"tick",(function(t){if(!e.actionList.length){var r=e.checkInput();r&&e.addAction(r).then((function(){e.engine.networkManager&&e.engine.networkManager.ws&&e.engine.networkManager.ws.readyState===WebSocket.OPEN&&e.engine.networkManager.sendAction(r,l(e))}))}e.engine.networkManager&&e.engine.networkManager.ws&&e.engine.networkManager.ws.readyState===WebSocket.OPEN&&e.engine.networkManager.updateAvatarPosition(l(e)),e.bindCamera&&(0,n.t8)(e.pos,e.engine.renderManager.camera.cameraPosition)})),d(l(e),"checkInput",(function(){return e.engine.inputManager.getAvatarAction(l(e))})),d(l(e),"openMenu",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new i.aW(e.engine,"prompt",[t,r,!1,{autoclose:!1}],l(e))})),d(l(e),"handleWalk",(function(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,c=600,u=null!==a?a:o.Nm.None;if(null===a)switch(t){case"w":u=o.Nm.Up;break;case"s":u=o.Nm.Down;break;case"a":u=o.Nm.Left;break;case"d":u=o.Nm.Right;break;case"u":return new i.aW(e.engine,"dance",[300,e.zone],l(e));case"p":return new i.aW(e.engine,"patrol",[e.pos.toArray(),new n.OW(8,13,e.pos.z).toArray(),600,e.zone],l(e));case"r":return new i.aW(e.engine,"patrol",[e.pos.toArray(),new n.OW(8,13,e.pos.z).toArray(),200,e.zone],l(e))}if(1===r["x-dir"]&&(u=o.Nm.Right),-1===r["x-dir"]&&(u=o.Nm.Left),1===r["y-dir"]&&(u=o.Nm.Down),-1===r["y-dir"]&&(u=o.Nm.Up),c=e.engine.keyboard.shift||e.engine.gamepad.keyPressed("y")?200:600,e.facing!==u)return e.faceDir(u);var f=e.pos,h=o.Nm.toOffset(u),d=s(n.OW,[Math.round(f.x+h[0]),Math.round(f.y+h[1]),0]);if(!e.zone.isInZone(d.x,d.y)){var p=e.zone.world.zoneContaining(d.x,d.y);return p&&p.loaded&&p.isWalkable(d.x,d.y,o.Nm.reverse(u))?new i.aW(e.engine,"changezone",[e.zone.id,e.pos.toArray(),p.id,d.toArray(),c],l(e)):e.faceDir(u)}return e.zone.isWalkable(d.x,d.y,o.Nm.reverse(u))?new i.aW(e.engine,"move",[e.pos.toArray(),d.toArray(),c,e.zone],l(e)):e.faceDir(u)})),e.isLit=!0,e.isSelected=!0,e}return a=y,Object.defineProperty(a,"prototype",{writable:!1}),a}(r(4485).Z)},4485:(t,e,r)=>{"use strict";r.d(e,{Z:()=>b});var n=r(9010),o=r(4395),i=r(7974),a=r(679),s=r(3203);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 u(t,e,r){return u=g()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&d(o,r.prototype),o},u.apply(null,arguments)}function l(){l=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h={};function d(){}function p(){}function y(){}var g={};s(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==c(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,s(b,"constructor",y),s(y,"constructor",p),p.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,a,"Generator"),s(b,o,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function f(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function h(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){f(i,n,o,a,s,"next",t)}function s(t){f(i,n,o,a,s,"throw",t)}a(void 0)}))}}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function p(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return y(t)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},m(t)}function v(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var b=function(t){!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&&d(t,e)}(b,t);var e,r,c,f=(e=b,r=g(),function(){var t,n=m(e);if(r){var o=m(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return p(this,t)});function b(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,b),v(y(e=f.call(this)),"onLoad",(function(t){if(!e.loaded)if(e.src&&e.sheetSize&&e.tileSize&&e.frames){if(console.log({msg:"sprite load",instanceData:t,objId:e.objId}),e.zone=t.zone,t.id&&(e.id=t.id),t.pos&&(e.pos=t.pos,e.pos&&(null===e.pos.z||void 0===e.pos.z)))try{var r,n,o,i,a=e.pos.x+(null!==(r=null===(n=e.hotspotOffset)||void 0===n?void 0:n.x)&&void 0!==r?r:0),s=e.pos.y+(null!==(o=null===(i=e.hotspotOffset)||void 0===i?void 0:i.y)&&void 0!==o?o:0),c=e.zone.getHeight(a,s);e.pos.z="number"==typeof c?c:0}catch(t){console.warn("Error computing sprite height from zone",t),e.pos.z=0}if(t.isLit&&(e.isLit=t.isLit),t.attenuation&&(e.attenuation=t.attenuation),t.direction&&(e.direction=t.direction),t.lightColor&&(e.lightColor=t.lightColor),t.density&&(e.density=t.density),t.scatteringCoefficients&&(e.scatteringCoefficients=t.scatteringCoefficients),t.rotation&&(e.rotation=t.rotation),t.facing&&0!==t.facing&&(e.facing=t.facing),t.zones&&null!==t.zones&&(e.zones=t.zones),t.onStep&&"function"==typeof t.onStep){var u=e.onStep;e.onStep=h(l().mark((function r(){return l().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.onStep(y(e),y(e));case 2:return r.next=4,u(y(e),y(e));case 4:case"end":return r.stop()}}),r)})))}if(t.onSelect&&"function"==typeof t.onSelect){var f=e.onSelect;e.onSelect=h(l().mark((function r(){return l().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.onSelect(y(e),y(e));case 2:return r.next=4,f(y(e),y(e));case 4:case"end":return r.stop()}}),r)})))}var d;e.texture=e.engine.resourceManager.loadTexture(e.src),e.texture.runWhenLoaded(e.onTilesetOrTextureLoaded),e.vertexTexBuf=e.engine.renderManager.createBuffer(e.getTexCoords(),e.engine.gl.DYNAMIC_DRAW,2),e.enableSpeech&&(e.speech=e.engine.resourceManager.loadSpeech(e.id,e.engine.mipmap),e.speech.runWhenLoaded(e.onTilesetOrTextureLoaded),e.speechTexBuf=e.engine.renderManager.createBuffer(e.getSpeechBubbleTexture(),e.engine.gl.DYNAMIC_DRAW,2)),e.portraitSrc&&(e.portrait=e.engine.resourceManager.loadTexture(e.portraitSrc),e.portrait.runWhenLoaded(e.onTilesetOrTextureLoaded)),e.isLit&&(console.log({msg:"Adding Light Loaded",id:e.id,pos:e.pos.toArray()}),e.lightIndex=e.engine.renderManager.lightManager.addLight(e.id,e.pos.toArray(),e.lightColor,null!==(d=e.attenuation)&&void 0!==d?d:[.01,.01,.01],e.direction,e.density,e.scatteringCoefficients,!0)),e.zone.tileset.runWhenDefinitionLoaded(e.onTilesetDefinitionLoaded)}else console.error("Invalid sprite definition")})),v(y(e),"onLoadFromZip",function(){var t=h(l().mark((function t(r,n){var o,i,a,s,c,u,f,d,p;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.loaded){t.next=2;break}return t.abrupt("return");case 2:if(e.src&&e.sheetSize&&e.tileSize&&e.frames){t.next=5;break}return console.error("Invalid sprite definition"),t.abrupt("return");case 5:if(console.log({msg:"sprite load from zip",instanceData:r}),e.update(r),e.zone=r.zone,r.id&&(e.id=r.id),r.isLit&&(e.isLit=r.isLit),r.lightColor&&(e.lightColor=r.lightColor),r.density&&(e.density=r.density),r.attenuation&&(e.attenuation=r.attenuation),r.direction&&(e.direction=r.direction),r.scatteringCoefficients&&(e.scatteringCoefficients=r.scatteringCoefficients),r.fixed&&(e.fixed=r.fixed),r.pos&&(e.pos=r.pos,e.pos&&(null===e.pos.z||void 0===e.pos.z)))try{c=e.pos.x+(null!==(o=null===(i=e.hotspotOffset)||void 0===i?void 0:i.x)&&void 0!==o?o:0),u=e.pos.y+(null!==(a=null===(s=e.hotspotOffset)||void 0===s?void 0:s.y)&&void 0!==a?a:0),f=e.zone.getHeight(c,u),e.pos.z="number"==typeof f?f:0}catch(t){console.warn("Error computing sprite height from zone",t),e.pos.z=0}return r.facing&&0!==r.facing&&(e.facing=r.facing),r.zones&&null!==r.zones&&(e.zones=r.zones),r.onStep&&"function"==typeof r.onStep&&(d=e.onStep,e.onStep=h(l().mark((function t(){return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.onStep(y(e),y(e));case 2:return t.next=4,d(y(e),y(e));case 4:case"end":return t.stop()}}),t)})))),t.next=22,e.engine.resourceManager.loadTextureFromZip(e.src,n);case 22:if(e.texture=t.sent,e.texture.runWhenLoaded(e.onTilesetOrTextureLoaded),e.vertexTexBuf=e.engine.renderManager.createBuffer(e.getTexCoords(),e.engine.gl.DYNAMIC_DRAW,2),e.enableSpeech&&(e.speech=e.engine.resourceManager.loadSpeech(e.id,e.engine.mipmap),e.speech.runWhenLoaded(e.onTilesetOrTextureLoaded),e.speechTexBuf=e.engine.renderManager.createBuffer(e.getSpeechBubbleTexture(),e.engine.gl.DYNAMIC_DRAW,2)),!e.portraitSrc){t.next=31;break}return t.next=29,e.engine.resourceManager.loadTextureFromZip(e.portraitSrc,n);case 29:e.portrait=t.sent,e.portrait.runWhenLoaded(e.onTilesetOrTextureLoaded);case 31:e.isLit&&(e.lightIndex=e.engine.renderManager.lightManager.addLight(e.id,e.pos.toArray(),e.lightColor,null!==(p=e.attenuation)&&void 0!==p?p:[.01,.01,.01],e.direction,e.density,e.scatteringCoefficients,!0)),e.zone.tileset.runWhenDefinitionLoaded(e.onTilesetDefinitionLoaded);case 33:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),v(y(e),"onTilesetDefinitionLoaded",(function(){var t=e.zone.tileset.tileSize,r=[e.tileSize[0]/t,e.tileSize[1]/t],n=[[0,0,0],[r[0],0,0],[r[0],0,r[1]],[0,0,r[1]]],o=[[n[2],n[3],n[0]],[n[2],n[0],n[1]]].flat(3);e.vertexPosBuf=e.engine.renderManager.createBuffer(o,e.engine.gl.STATIC_DRAW,3),e.enableSpeech&&(e.speechVerBuf=e.engine.renderManager.createBuffer(e.getSpeechBubbleVertices(),e.engine.gl.STATIC_DRAW,3)),e.zone.tileset.runWhenLoaded(e.onTilesetOrTextureLoaded)})),v(y(e),"onTilesetOrTextureLoaded",(function(){!y(e)||e.loaded||!e.zone.tileset.loaded||!e.texture.loaded||e.enableSpeech&&e.speech&&!e.speech.loaded||e.portrait&&!e.portrait.loaded||(e.init(),e.enableSpeech&&e.speech&&e.speech.clearHud&&(e.speech.clearHud(),e.speech.writeText(e.id),e.speech.loadImage()),e.loaded=!0,e.onLoadActions.run())})),v(y(e),"getTexCoords",(function(){var t,r=o.Nm.spriteSequence(e.facing,e.engine.renderManager.camera.cameraDir),n=null!==(t=e.frames[r])&&void 0!==t?t:e.frames.N,i=n.length,a=n[e.animFrame%i],s=e.sheetSize,c=e.tileSize,u=[(a[0]+c[0])/s[0],a[1]/s[1]],l=[a[0]/s[0],(a[1]+c[1])/s[1]],f=[u,[l[0],u[1]],l,[u[0],l[1]]];return[[f[0],f[1],f[2]],[f[0],f[2],f[3]]].flat(3)})),v(y(e),"getSpeechBubbleTexture",(function(){return[[1,1],[0,1],[0,0],[1,1],[0,0],[1,0]].flat(3)})),v(y(e),"getSpeechBubbleVertices",(function(){return[u(n.OW,[2,0,4]).toArray(),u(n.OW,[0,0,4]).toArray(),u(n.OW,[0,0,2]).toArray(),u(n.OW,[2,0,4]).toArray(),u(n.OW,[0,0,2]).toArray(),u(n.OW,[2,0,2]).toArray()].flat(3)})),v(y(e),"draw",(function(){var t;if(e.loaded){if(e.engine&&e.engine.renderManager&&e.engine.renderManager.debug&&e.engine.renderManager.debug.spritesDrawn++,e.isLit){var r=e.pos.toArray();e.engine.renderManager.lightManager.updateLight(e.lightIndex,r)}var o;e.engine.renderManager.mvPushMatrix(),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(null!==(t=e.drawOffset[e.engine.renderManager.camera.cameraDir])&&void 0!==t?t:e.drawOffset.N).toArray()),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,e.pos.toArray()),e.fixed||(e.engine.renderManager.shaderProgram.setMatrixUniforms({id:e.getPickingId(),scale:new n.OW(1,Math.cos(e.engine.renderManager.camera.cameraAngle/180),1)}),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,[.5*e.engine.renderManager.camera.cameraVector.x,.5*e.engine.renderManager.camera.cameraVector.y,0]),(0,s.U1)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(0,n.Id)(e.engine.renderManager.camera.cameraAngle*e.engine.renderManager.camera.cameraVector.z),[0,0,-1]),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,[-.5*e.engine.renderManager.camera.cameraVector.x,-.5*e.engine.renderManager.camera.cameraVector.y,0])),e.engine.renderManager.bindBuffer(e.vertexPosBuf,e.engine.renderManager.shaderProgram.aVertexPosition),e.engine.renderManager.bindBuffer(e.vertexTexBuf,e.engine.renderManager.shaderProgram.aTextureCoord),e.texture.attach(),e.engine.renderManager.effectPrograms.picker.setMatrixUniforms({sampler:1,id:e.getPickingId()}),e.isSelected?e.engine.renderManager.shaderProgram.setMatrixUniforms({id:e.getPickingId(),isSelected:!0,sampler:1,colorMultiplier:8&e.engine.frameCount?[1,0,0,1]:[1,1,0,1]}):e.engine.renderManager.shaderProgram.setMatrixUniforms({id:e.getPickingId(),sampler:1}),e.engine.gl.depthFunc(e.engine.gl.ALWAYS),e.engine.gl.drawArrays(e.engine.gl.TRIANGLES,0,e.vertexPosBuf.numItems),e.engine.gl.depthFunc(e.engine.gl.LESS),e.engine.renderManager.mvPopMatrix(),e.enableSpeech&&(e.engine.renderManager.mvPushMatrix(),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(null!==(o=e.drawOffset[e.engine.renderManager.camera.cameraDir])&&void 0!==o?o:e.drawOffset.N).toArray()),(0,s.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,e.pos.toArray()),(0,s.U1)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(0,n.Id)(e.engine.renderManager.camera.cameraAngle*e.engine.renderManager.camera.cameraVector.z),[0,0,-1]),e.engine.renderManager.bindBuffer(e.speechVerBuf,e.engine.renderManager.shaderProgram.aVertexPosition),e.engine.renderManager.bindBuffer(e.speechTexBuf,e.engine.renderManager.shaderProgram.aTextureCoord),e.speech.attach(),e.engine.renderManager.shaderProgram.setMatrixUniforms({id:e.getPickingId()}),e.engine.gl.depthFunc(e.engine.gl.ALWAYS),e.engine.gl.drawArrays(e.engine.gl.TRIANGLES,0,e.speechVerBuf.numItems),e.engine.gl.depthFunc(e.engine.gl.LESS),e.engine.renderManager.mvPopMatrix())}})),v(y(e),"getPickingId",(function(){return[(e.objId>>0&255)/255,(e.objId>>8&255)/255,(e.objId>>16&255)/255,255]})),v(y(e),"setFrame",(function(t){e.animFrame=t,e.engine.renderManager.updateBuffer(e.vertexTexBuf,e.getTexCoords())})),v(y(e),"setFacing",(function(t){t&&(e.facing=t),e.setFrame(e.animFrame)})),v(y(e),"addAction",function(){var t=h(l().mark((function t(r){return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.resolve(r);case 2:r=t.sent,e.actionDict[r.id]&&e.removeAction(r.id),e.actionDict[r.id]=r,e.actionList.push(r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),v(y(e),"removeAction",(function(t){e.actionList=e.actionList.filter((function(e){return e.id!==t})),delete e.actionDict[t]})),v(y(e),"removeAllActions",(function(){e.actionList=[],e.actionDict={}})),v(y(e),"tickOuter",(function(t){if(e.loaded){e.actionList.sort((function(t,e){var r=t.startTime-e.startTime;return r?t.id>e.id?1:-1:r}));var r=[];e.actionList.forEach((function(e){if(e.loaded&&!(e.startTime>t))try{e.tick(t)&&(r.push(e),e.onComplete())}catch(t){console.error(t),r.push(e)}})),r.forEach((function(t){return e.removeAction(t.id)})),e.tick&&e.tick(t)}})),v(y(e),"init",(function(){})),v(y(e),"loadRemote",function(){var t=h(l().mark((function t(r){var n;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(r);case 2:if((n=t.sent).ok){t.next=5;break}throw new Error;case 5:e.update(n.json());case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),v(y(e),"speak",(function(t){var r,n,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!t&&e.speech.clearHud?e.speech.clearHud():(i.speechOutput&&(e.speechSynthesis(t),i.speechOutput=!1),e.textbox=e.engine.hud.scrollText(e.id+":> "+t,!0,{portrait:null!==(r=e.portrait)&&void 0!==r&&r}),o&&e.speech&&(e.speech.scrollText(t,!1,{portrait:null!==(n=e.portrait)&&void 0!==n&&n}),e.speech.loadImage()))})),v(y(e),"speechSynthesis",(function(t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=e.voice,c=null!==(r=window.speechSynthesis.getVoices())&&void 0!==r?r:[];s.voice=e.gender?"male"==e.gender?c[7]:c[28]:c[0],o&&(s.rate=o),i&&(s.volume=i),a&&(s.pitch=a),s.text=t,s.lang=n,window.speechSynthesis.speak(s)})),v(y(e),"interact",function(){var t=h(l().mark((function t(r,n){var o;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=null,t.t0=e.state,t.next=4;break;case 4:return t.abrupt("break",5);case 5:return n&&n(!0),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),v(y(e),"faceDir",(function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!r&&e.facing==t||t===o.Nm.None?null:new a.aW(e.engine,"face",[t],y(e))})),v(y(e),"setGreeting",(function(t){return e.speech.clearHud&&e.speech.clearHud(),e.speech.writeText(t),e.speech.loadImage(),new a.aW(e.engine,"greeting",[t,{autoclose:!0}],y(e))})),e.objId=Math.round(100*Math.random())+11,e.engine=t,e.templateLoaded=!1,e.drawOffset=new n.OW(0,0,0),e.hotspotOffset=new n.OW(0,0,0),e.animFrame=0,e.fixed=!1,e.pos=new n.OW(0,0,0),e.scale=new n.OW(1,1,1),e.facing=o.Nm.Right,e.actionDict={},e.actionList=[],e.gender=null,e.speech={},e.portrait=null,e.onLoadActions=new i.Z,e.inventory=[],e.blocking=!0,e.override=!1,e.isLit=!0,e.lightIndex=null,e.lightColor=[.1,1,.1],e.density=1,e.voice=new SpeechSynthesisUtterance,e.isSelected=!1,e}return c=b,Object.defineProperty(c,"prototype",{writable:!1}),c}(r(5849).Z)},8826:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var n=r(9010),o=(r(4013),r(4395));const i={init:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.engine=this.world.engine,this.cameraAction=t,this.options=e,this.completed=!1,this.startTime=(new Date).getTime(),this.endTime=null},tick:function(t){if(this.loaded){var e=this.engine.renderManager.camera,r=0;switch(this.options.duration&&(r=(t-this.startTime)/(1e3*this.options.duration))>=1&&(r=1,this.completed=!0),this.cameraAction){case"pan":if(this.options.from&&this.options.to){var i=this.options.from,a=this.options.to,s=(0,n.t7)(i,a,r,new n.OW(0,0,0));e.cameraVector.x=s.x,e.cameraVector.y=s.y,e.cameraVector.z=s.z,e.cameraDir=o.Nm.adjustCameraDirection(e.cameraVector)}break;case"zoom":if("number"==typeof this.options.zoomDelta){var c=e.cameraDistance,u=c+this.options.zoomDelta;e.cameraDistance=(0,n.t7)(c,u,r),e.updateViewFromAngles()}break;case"rotate":if("number"==typeof this.options.yawDelta||"number"==typeof this.options.pitchDelta){var l=e.yaw,f=e.pitch,h=l+(this.options.yawDelta||0),d=f+(this.options.pitchDelta||0);e.yaw=(0,n.t7)(l,h,r),e.pitch=(0,n.t7)(f,d,r),e.updateViewFromAngles()}break;case"translate":this.options.translateDirection&&(this.completed||e.translateCam(this.options.translateDirection));break;case"focus":console.warn('Camera action "focus" not yet implemented.')}return this.options.duration&&!this.endTime&&(this.endTime=this.startTime+1e3*this.options.duration),this.endTime&&t>this.endTime&&(this.completed=!0),this.completed}}}},3565:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.engine=this.world.engine,this.text="",this.prompt=t,this.scrolling=e,this.line=0,this.options=r,this.completed=!1,this.lastKey=(new Date).getTime()},tick:function(t){var e;if(this.loaded)return this.options&&this.options.autoclose&&(this.endTime=this.endTime?this.endTime:null!==(e=this.options.endTime)&&void 0!==e?e:(new Date).getTime()+1e4,t>this.endTime&&(this.completed=!0)),this.checkInput(t),this.textbox=this.engine.hud.scrollText(this.prompt+this.text,this.scrolling,this.options),this.completed},checkInput:function(t){if(t>this.lastKey+200){var e=!1;switch(this.engine.keyboard.lastPressedCode()){case"Escape":this.completed=!0,e=!0;break;case"Backspace":var r=this.text.split("");r.pop(),this.text=r.join(""),this.lastKey=t,e=!0;break;case"Enter":this.engine.hud.scrollText(this.text),this.completed=!0,e=!0}if(!e){var n=this.engine.keyboard.lastPressedKey();n&&(this.lastKey=t,this.text+=""+n)}}}}},48:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={init:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{autoclose:!1,closeOnEnter:!1};this.engine=this.world.engine,this.text="",this.prompt="",this.scrolling=r,this.line=0,this.options=n,this.completed=!1,this.onOpen=t.start.onOpen,this.lastKey=(new Date).getTime(),this.touches=[],this.menuDict=null!=t?t:{},this.activeMenus=null!=e?e:[],this.selectedMenu={},this.selectedMenuId=null,this.isTouched=!1,this.speechOutput=!1,this.quittable=!0,this.listenerId=this.engine.gamepad.attachListener(this.hookListener()),this.speechOutput=!0,window.speechSynthesis.onvoiceschanged=function(){}},tick:function(t){var e,r=this;if(this.loaded)return this.options&&this.options.autoclose&&(this.endTime=this.endTime?this.endTime:null!==(e=this.options.endTime)&&void 0!==e?e:(new Date).getTime()+1e4,t>this.endTime&&(this.completed=!0)),this.checkInput(t),Object.keys(this.menuDict).filter((function(t){return r.activeMenus.includes(t)})).map((function(t){var e=r.menuDict[t],n=e.colours;e.active&&(n.background="#555"),r.engine.hud.drawButton(e.text,e.x,e.y,e.w,e.h,e.colours),e.prompt&&(r.speechOutput&&r.engine.speechSynthesis(e.prompt),r.textbox=r.engine.hud.scrollText(e.prompt,r.scrolling,r.options))})),this.speechOutput=!1,this.completed&&(this.unhookListener(),window.speechSynthesis.cancel()),this.completed},unhookListener:function(){this.engine.gamepad.removeListener(this.listenerId),this.listenerId=null},hookListener:function(){var t=this;this.onOpen&&this.onOpen(this);var e=function(e){var r=e.touches;if(t.isTouched=!0,t.touches=r,t.isTouched&&t.touches.length>0&&t.lastKey+100<(new Date).getTime()){var n=t.touches[0].x,o=t.touches[0].y,i=t;i.activeMenus.filter((function(t){var e=i.menuDict[t];return n<e.x+e.w&&n>e.x&&o<e.y+e.h&&o>e.y})).map((function(e){var r=i.menuDict[e];r.trigger&&r.trigger(t),r.children&&(i.activeMenus=r.children)}))}},r=function(e){t.touches=e},n=function(e){t.isTouched=!1,t.touches=e};return{touchstart:e,touchmove:r,touchend:n,mousedown:e,mousemove:r,mouseup:n}},checkInput:function(t){var e=this;if(t>this.lastKey+200)switch(this.engine.keyboard.lastPressedCode()){case"Escape":this.quittable&&(this.completed=!0);break;case"Enter":Object.keys(this.menuDict).filter((function(t){return e.activeMenus.includes(t)})).map((function(t){var r=e.menuDict[t];r.onEnter&&r.trigger(e)})),(this.quittable||this.options.closeOnEnter)&&(this.completed=!0)}}}},6083:(t,e,r)=>{"use strict";r.d(e,{Z:()=>Te});var n={};r.r(n),r.d(n,{coerceArgToFunction:()=>Y,coerceArgToNumber:()=>V,coerceArgToString:()=>Z,coerceArgToTable:()=>$,coerceToBoolean:()=>F,coerceToNumber:()=>U,coerceToString:()=>G,ensureArray:()=>K,hasOwnProperty:()=>H,posrelat:()=>N,tostring:()=>D,type:()=>z});var o={};r.r(o),r.d(o,{sprintf:()=>_t,version:()=>gt,vsprintf:()=>xt});var i={};r.r(i),r.d(i,{LuaError:()=>M,Table:()=>j,createEnv:()=>ke,utils:()=>n});var a=r(679);function s(t){return s="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},s(t)}function c(){c=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==s(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,a,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function u(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){u(i,n,o,a,s,"next",t)}function s(t){u(i,n,o,a,s,"throw",t)}a(void 0)}))}}function f(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=d(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function h(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||d(t)||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){if(t){if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var m=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y(this,t),this.engine=e,this.callbacks={onDialogueShow:r.onDialogueShow||null,onBackdropChange:r.onBackdropChange||null,onCutsceneEnd:r.onEnd||r.onCutsceneEnd||null},this.characters={},this.currentBackdrop=null,this.isPlaying=!1,this.isPaused=!1,this.bgmAudio=null,this.sfxAudio=null,this.voiceAudio=null}var e,r,n,o,i,a,s,u,d;return e=t,r=[{key:"parseScript",value:function(t){for(var e=t.split("\n"),r=[],n=null,o=!1,i=[],a=0;a<e.length;a++){var s=e[a].trim();if(s&&!s.startsWith("#"))if(o&&s.includes('"""'))(s=s.replace('"""',"").trim())&&i.push(s),n.text=i.join("\n"),r.push(n),n=null,o=!1,i=[];else if(o)i.push(s);else if(s.startsWith("@")){var c=this.parseCommand(s);c&&r.push(c)}else if(s.startsWith("wait "))r.push({type:"wait",duration:parseInt(s.replace("wait","").trim())});else if("waitInput"!==s&&"wait_input"!==s){if(s.includes(":")){var u=s.startsWith("*");u&&(s=s.substring(1).trim());var l=h(s.split(":")),f=l[0],d=l.slice(1).join(":").trim(),p=d.match(/^\[([^\]]+)\]/),y=p?this.parseBracket(p[1]):{},g=p?d.substring(p[0].length).trim():d;if(g.startsWith('"""')){o=!0,i=(g=g.replace('"""',"").trim())?[g]:[],n={type:"dialogue",actor:f.trim(),text:"",isCutin:u,meta:y};continue}r.push({type:"dialogue",actor:f.trim(),text:g.replace(/^["']|["']$/g,""),isCutin:u,meta:y})}}else r.push({type:"waitInput"})}return r}},{key:"parseCommand",value:function(t){var e=t.substring(1).trim().split(/\s+/),r=e[0],n=e.slice(1).join(" "),o=n.match(/\[([^\]]+)\]/),i=o?this.parseBracket(o[1]):{},a=o?n.replace(o[0],"").trim():n;switch(r){case"backdrop":return{type:"backdrop",url:a||i.url,options:i};case"char":return{type:"char",name:a.split(/\s+/)[0],sprite:i.sprite};case"do":return{type:"hook",action:a.split(/\s+/)[0],args:i};case"transition":return{type:"transition",effect:a||i.effect||"fade",options:i};case"end":return{type:"end"};default:return console.warn("[PxcPlayer] Unknown command:",r),null}}},{key:"parseBracket",value:function(t){var e,r={},n=f(t.split(","));try{for(n.s();!(e=n.n()).done;){var o=h(e.value.split("=")),i=o[0],a=o.slice(1).join("=").trim();r[i.trim()]=a||!0}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"playCutscene",value:(d=l(c().mark((function t(e){var r,n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isPlaying){t.next=3;break}return console.warn("[PxcPlayer] Cutscene already playing"),t.abrupt("return");case 3:this.isPlaying=!0,r=this.parseScript(e),console.log("[PxcPlayer] Playing cutscene with",r.length,"events"),n=f(r),t.prev=7,n.s();case 9:if((o=n.n()).done){t.next=17;break}if(i=o.value,this.isPlaying){t.next=13;break}return t.abrupt("break",17);case 13:return t.next=15,this.handleEvent(i);case 15:t.next=9;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(7),n.e(t.t0);case 22:return t.prev=22,n.f(),t.finish(22);case 25:this.isPlaying=!1,this.cleanup(),this.callbacks.onCutsceneEnd&&this.callbacks.onCutsceneEnd();case 28:case"end":return t.stop()}}),t,this,[[7,19,22,25]])}))),function(t){return d.apply(this,arguments)})},{key:"handleEvent",value:(u=l(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.type,t.next="backdrop"===t.t0?3:"char"===t.t0?6:"dialogue"===t.t0?8:"hook"===t.t0?11:"transition"===t.t0?14:"wait"===t.t0?17:"waitInput"===t.t0?20:"end"===t.t0?23:25;break;case 3:return t.next=5,this.showBackdrop(e.url,e.options);case 5:return t.abrupt("break",26);case 6:return this.defineCharacter(e.name,e.sprite),t.abrupt("break",26);case 8:return t.next=10,this.showDialogue(e);case 10:return t.abrupt("break",26);case 11:return t.next=13,this.doHook(e.action,e.args);case 13:return t.abrupt("break",26);case 14:return t.next=16,this.doTransition(e.effect,e.options);case 16:return t.abrupt("break",26);case 17:return t.next=19,this.wait(e.duration);case 19:return t.abrupt("break",26);case 20:return t.next=22,this.waitForInput();case 22:return t.abrupt("break",26);case 23:return this.isPlaying=!1,t.abrupt("break",26);case 25:console.warn("[PxcPlayer] Unknown event type:",e.type);case 26:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"showBackdrop",value:(s=l(c().mark((function t(e){var r,n=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.length>1&&void 0!==n[1]?n[1]:{},this.currentBackdrop=e,console.log("[PxcPlayer] Backdrop:",e,r),this.callbacks.onBackdropChange&&this.callbacks.onBackdropChange(e,r),!r.fadeIn){t.next=7;break}return t.next=7,this.wait(parseInt(r.fadeIn));case 7:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"defineCharacter",value:function(t,e){this.characters[t]={sprite:e},console.log("[PxcPlayer] Defined character:",t,e)}},{key:"showDialogue",value:(a=l(c().mark((function t(e){var r,n;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.characters[e.actor],n=r?r.sprite:null,console.log("[PxcPlayer] Dialogue:",e.actor,e.text),!e.meta.voice){t.next=6;break}return t.next=6,this.playVoiceBlocking(e.meta.voice);case 6:return this.callbacks.onDialogueShow&&this.callbacks.onDialogueShow({actor:e.actor,text:e.text,sprite:n,expression:e.meta.expression||"neutral",position:e.meta.position||"center",isCutin:e.isCutin,meta:e.meta}),t.next=9,this.wait(100);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"doHook",value:(i=l(c().mark((function t(e,r){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log("[PxcPlayer] Hook:",e,r),t.t0=e,t.next="playBgm"===t.t0?4:"playSfx"===t.t0?6:"playVoice"===t.t0?8:"stopBgm"===t.t0?11:"stopAll"===t.t0?13:15;break;case 4:return this.playBgm(r.name),t.abrupt("break",16);case 6:return this.playSfx(r.name),t.abrupt("break",16);case 8:return t.next=10,this.playVoiceBlocking(r.name);case 10:return t.abrupt("break",16);case 11:return this.stopBgm(),t.abrupt("break",16);case 13:return this.stopAll(),t.abrupt("break",16);case 15:console.warn("[PxcPlayer] Unknown hook action:",e);case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"playBgm",value:function(t){var e=this;this.stopBgm(),console.log("[PxcPlayer] Playing BGM:",t),this.engine&&this.engine.assetLoader&&this.engine.assetLoader.load(t).then((function(t){e.bgmAudio=new Audio(t),e.bgmAudio.loop=!0,e.bgmAudio.volume=.7,e.bgmAudio.play().catch((function(t){return console.warn("[PxcPlayer] BGM autoplay blocked:",t)}))})).catch((function(t){return console.error("[PxcPlayer] Failed to load BGM:",t)}))}},{key:"playSfx",value:function(t){console.log("[PxcPlayer] Playing SFX:",t),this.engine&&this.engine.assetLoader&&this.engine.assetLoader.load(t).then((function(t){var e=new Audio(t);e.volume=.8,e.play().catch((function(t){return console.warn("[PxcPlayer] SFX autoplay blocked:",t)}))})).catch((function(t){return console.error("[PxcPlayer] Failed to load SFX:",t)}))}},{key:"playVoiceBlocking",value:(o=l(c().mark((function t(e){var r=this;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("[PxcPlayer] Playing Voice:",e),t.abrupt("return",new Promise((function(t){r.engine&&r.engine.assetLoader?r.engine.assetLoader.load(e).then((function(e){r.voiceAudio=new Audio(e),r.voiceAudio.volume=1,r.voiceAudio.onended=function(){return t()},r.voiceAudio.play().catch((function(e){console.warn("[PxcPlayer] Voice autoplay blocked:",e),t()}))})).catch((function(e){console.error("[PxcPlayer] Failed to load voice:",e),t()})):t()})));case 2:case"end":return t.stop()}}),t)}))),function(t){return o.apply(this,arguments)})},{key:"stopBgm",value:function(){this.bgmAudio&&(this.bgmAudio.pause(),this.bgmAudio=null)}},{key:"stopAll",value:function(){this.stopBgm(),this.sfxAudio&&(this.sfxAudio.pause(),this.sfxAudio=null),this.voiceAudio&&(this.voiceAudio.pause(),this.voiceAudio=null)}},{key:"doTransition",value:(n=l(c().mark((function t(e){var r,n,o,i=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=i.length>1&&void 0!==i[1]?i[1]:{},console.log("[PxcPlayer] Transition:",e,r),!this.engine||!this.engine.renderManager){t.next=9;break}return n=r.duration||500,o=r.direction||"out",t.next=7,this.engine.renderManager.startTransition({effect:e,direction:o,duration:n});case 7:t.next=11;break;case 9:return t.next=11,this.wait(r.duration||500);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"wait",value:function(t){return new Promise((function(e){return setTimeout(e,t)}))}},{key:"waitForInput",value:function(){return new Promise((function(t){var e=function e(){document.removeEventListener("click",e),document.removeEventListener("keydown",e),t()};document.addEventListener("click",e),document.addEventListener("keydown",e)}))}},{key:"cleanup",value:function(){this.stopAll(),this.characters={},this.currentBackdrop=null}},{key:"stop",value:function(){this.isPlaying=!1,this.cleanup()}}],r&&g(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function v(t){return v="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},v(t)}function b(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=x(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(t,e)||x(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 x(t,e){if(t){if("string"==typeof t)return _(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_(t,e):void 0}}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function k(){k=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=x(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(S([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function _(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),s(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){E(i,n,o,a,s,"next",t)}function s(t){E(i,n,o,a,s,"throw",t)}a(void 0)}))}}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach((function(e){T(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function O(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function P(t,e,r){return e&&O(t.prototype,e),r&&O(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function T(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var C=P((function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),T(this,"getLibrary",(function(t,e){return console.log({msg:"creating pixoscript library",envScope:e}),new r.pixoscript.Table(L(L({},e),{},{get_caller:function(){return e._this},get_subject:function(){return e.subject},get_map:function(){return e.map||e.zone},get_zone:function(){return e.map||e.zone},get_world:function(){return t.spritz.world},send_action:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=t.networkManager;if(r&&r.ws){var n=r.sendAction(e.toObject());return e?function(){return Promise.resolve(n)}:n}return!!e&&function(){return Promise.resolve(!1)}},all_flags:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=t.store.all();return e?function(){return Promise.resolve(r)}:r},has_flag:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.log("checking flag via lua",e,r);var n=t.store.keys().includes(e);return r?function(){return Promise.resolve(n)}:n},set_flag:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];console.log("setting flag via lua",e,n);var o=t.store.set(e,r.toObject());return n?function(){return Promise.resolve(o)}:o},add_flag:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.log("adding flag via lua",e,n),t.store.add(e,r.toObject()),!n||function(){return Promise.resolve(!0)}},get_flag:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.log("getting flag via lua",e,r);var n=t.store.get(e);return r?function(){return Promise.resolve(n)}:n},remove_all_zones:function(){return console.log({msg:"removing all zones via lua"}),t.spritz.world.removeAllZones()},load_zone_from_zip:function(e,r){return console.log({msg:"loading zone from zip via lua",world:t.spritz.world,z:e,zip:r}),t.spritz.world.loadZoneFromZip(e,r,!1)},register_cutscene:function(e,n){try{var o=r.pixoscript.utils.ensureArray(n.toObject()).map((function(t){return t&&"function"==typeof t.toObject?t.toObject():t}));t.cutsceneManager.register(e,o)}catch(t){console.warn("Failed to register cutscene from Lua",t)}},start_cutscene:function(e){try{t.cutsceneManager.start(e)}catch(t){console.warn("Failed to start cutscene",e,t)}},skip_cutscene:function(){try{t.cutsceneManager.skip()}catch(t){console.warn("Failed to skip cutscene",t)}},set_backdrop:function(e){try{t.cutsceneManager.setBackdrop({backdrop:e})}catch(t){console.warn("Failed to set backdrop",t)}},show_cutout:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left";try{t.cutsceneManager.showCutout({sprite:e,cutout:r,position:n})}catch(t){console.warn("Failed to show cutout",t)}},play_cutscene:function(t){return function(){return new Promise((function(r){if(console.log({msg:"playing cutscene via lua",zone:e.zone,cutscene:t}),e.zone.playCutscene)return console.log({msg:"cutscene function found"}),e.zone.playCutscene(t).then((function(){r()}));r()}))}},run_cutscene:function(e){return function(){return new Promise((function(n){try{var o=r.pixoscript.utils.ensureArray(e.toObject()).map((function(t){return t&&"function"==typeof t.toObject?t.toObject():t})),i="__lua_cutscene_"+Date.now()+"_"+Math.floor(1e4*Math.random());t.cutsceneManager.register(i,o),t.cutsceneManager.start(i),function e(){t.cutsceneManager.isRunning()?setTimeout(e,30):n()}()}catch(t){console.warn("Failed to run cutscene",t),n()}}))}},run_transition:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"fade",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"out",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;return function(){new Promise((function(o){var i=t.renderManager;return i||o(),i.startTransition({effect:e,direction:r,duration:n}).then((function(){return o()}))}))}},sprite_dialogue:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(){return new Promise((function(o){return console.log({msg:"playing dialogue via lua",zone:e.zone,spriteId:t,dialogue:r}),n.onClose=function(){return o()},e.zone.spriteDialogue(t,r,n).then((function(){console.log({msg:"played dialogue via lua",zone:e.zone,spriteId:t,dialogue:r})}))}))}},move_sprite:function(t,n,o){return function(){return new Promise((function(i){return console.log({msg:"moving sprite via lua",zone:e.zone,spriteId:t,location:n,running:o}),e.zone.moveSprite(t,r.pixoscript.utils.ensureArray(n.toObject()),o).then((function(){console.log({msg:"moved sprite via lua",zone:e.zone,spriteId:t,location:n,running:o}),i()}))}))}},load_scripts:function(t){return console.log({msg:"loading scripts via lua",scripts:t,envScope:e}),e.zone.loadScripts(t)},play_pxc_cutscene:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(){return new Promise(function(){var n=A(k().mark((function n(o){var i,a,s;return k().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,console.log("[PixoScript] Loading .pxc cutscene:",e),n.next=4,t.assetLoader.load(e);case 4:if(i=n.sent){n.next=9;break}return console.error("[PixoScript] Failed to load cutscene:",e),o(),n.abrupt("return");case 9:return a={onDialogueShow:r.onDialogueShow||function(t){console.log("[PxcPlayer] Dialogue:",t.actor,t.text)},onBackdropChange:r.onBackdropChange||function(t,e){console.log("[PxcPlayer] Backdrop:",t)},onEnd:function(){console.log("[PxcPlayer] Cutscene ended"),r.onEnd&&r.onEnd(),o()}},s=new m(t,a),n.next=13,s.playCutscene(i);case 13:n.next=19;break;case 15:n.prev=15,n.t0=n.catch(0),console.error("[PixoScript] Error playing .pxc cutscene:",n.t0),o();case 19:case"end":return n.stop()}}),n,null,[[0,15]])})));return function(t){return n.apply(this,arguments)}}())}},play_pxc_script:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(){return new Promise(function(){var n=A(k().mark((function n(o){var i,a;return k().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,console.log("[PixoScript] Playing inline .pxc script"),i={onDialogueShow:r.onDialogueShow||function(t){console.log("[PxcPlayer] Dialogue:",t.actor,t.text)},onBackdropChange:r.onBackdropChange||function(t,e){console.log("[PxcPlayer] Backdrop:",t)},onEnd:function(){console.log("[PxcPlayer] Cutscene ended"),r.onEnd&&r.onEnd(),o()}},a=new m(t,i),n.next=6,a.playCutscene(e);case 6:n.next=12;break;case 8:n.prev=8,n.t0=n.catch(0),console.error("[PixoScript] Error playing inline .pxc script:",n.t0),o();case 12:case"end":return n.stop()}}),n,null,[[0,8]])})));return function(t){return n.apply(this,arguments)}}())}},set_camera:function(){t.renderManager.camera.setCamera()},get_camera_vector:function(){return t.renderManager.camera.cameraTarget},look_at:function(e,n,o){var i=r.pixoscript.utils.ensureArray(e.toObject()),a=r.pixoscript.utils.ensureArray(n.toObject()),s=r.pixoscript.utils.ensureArray(o.toObject());t.renderManager.camera.lookAt(i,a,s)},pan_camera:function(e,r,n){return console.log({msg:"panning camera via lua",from:e,to:r,duration:n}),function(){return new Promise((function(o){t.spritz.world.addEvent(new a.q1(t,"camera",["pan",{from:e,to:r,duration:n}],t.spritz.world,A(k().mark((function t(){return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o();case 1:case"end":return t.stop()}}),t)})))))}))}},_pan:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.PI/4;"CCW"===e?t.renderManager.camera.panCCW(r.pixoscript.utils.coerceToNumber(n)):t.renderManager.camera.panCW(r.pixoscript.utils.coerceToNumber(n))},pitch:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.PI/4;"CCW"===e?t.renderManager.camera.pitchCCW(r.pixoscript.utils.coerceToNumber(n)):t.renderManager.camera.pitchCW(r.pixoscript.utils.coerceToNumber(n))},tilt:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.PI/4;"CCW"===e?t.renderManager.camera.tiltCCW(r.pixoscript.utils.coerceToNumber(n)):t.renderManager.camera.tiltCW(r.pixoscript.utils.coerceToNumber(n))},bind_action:function(e,r,n){try{t.inputManager&&t.inputManager.bindAction(e,r,n)}catch(t){console.warn("bind_action failed",t)}},unbind_action:function(e,r){try{t.inputManager&&t.inputManager.unbindAction(e,r)}catch(t){console.warn("unbind_action failed",t)}},register_action_hook:function(e,r){try{t.inputManager&&t.inputManager.registerActionHook(e,r)}catch(t){console.warn("register_action_hook failed",t)}},is_action_active:function(e){try{return!!t.inputManager&&t.inputManager.isActionActive(e)}catch(t){return console.warn("is_action_active failed",t),!1}},get_action_input:function(e){try{return t.inputManager?t.inputManager.getActionInput(e):null}catch(t){return console.warn("get_action_input failed",t),null}},vector:function(e){var n=w(r.pixoscript.utils.ensureArray(e.toObject()),3),o=n[0],i=n[1],a=n[2];return new t.utils.Vector(o,i,a)},vec_sub:function(t,e){return t.sub(e)},sync:(o=A(k().mark((function t(e){var r,n,o;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=b(e.toObject()),t.prev=1,r.s();case 3:if((n=r.n()).done){t.next=9;break}return o=n.value,t.next=7,o();case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,null,[[1,11,14,17]])}))),function(t){return o.apply(this,arguments)}),as_obj:function(t){return t.toObject()},as_array:function(t){return r.pixoscript.utils.ensureArray(t.toObject())},as_table:function(t){for(var e=new r.pixoscript.Table,n=0,o=Object.entries(t);n<o.length;n++){var i=w(o[n],2),a=i[0],s=i[1];e.set(a,s)}return e},log:function(t){console.log(t)},to:function(t,e){for(var r=0,n=Object.entries(e.toObject());r<n.length;r++){var o=w(n[r],2),i=o[0],a=o[1];t[i]=a}},set_mode:function(e,r){try{console.log("pixos.set_mode called ->",e,r);var n=t.spritz.world;if(n&&n.modeManager){var o=r&&"function"==typeof r.toObject?r.toObject():r;n.modeManager.set(e,o)}}catch(t){console.warn("set_mode failed",t)}},get_mode:function(){try{return t.spritz.world.modeManager.getMode()}catch(t){return null}},set_mode_mappings:function(e,r){try{if(console.log("pixos.set_mode_mappings called ->",e,r),t&&t.inputManager){var n=r&&"function"==typeof r.toObject?r.toObject():r;t.inputManager.setModeMappings(e,n)}}catch(t){console.warn("set_mode_mappings failed",t)}},register_mode:function(e,r){try{if(!e)return void console.warn("pixos.register_mode called with undefined name");console.log("pixos.register_mode called ->",e);var n=t.spritz.world;if(!n||!n.modeManager)return;var o={},i=r&&"function"==typeof r.toObject?r.toObject():r||{};i.setup&&(o.setup=i.setup),i.update&&(o.update=i.update),i.teardown&&(o.teardown=i.teardown),i.check_input&&(o.check_input=i.check_input),i.on_select&&(o.on_select=i.on_select),void 0!==i.picker&&(o.picker=i.picker),n.modeManager.register(e,o)}catch(t){console.warn("register_mode failed",t)}},from:function(t,e){return t[e]},length:function(t){return t.length||0},callback_finish:function(t){console.log({msg:"callback finish",success:t}),e.finish&&e.finish(t>0)},set_skybox_shader:(n=A(k().mark((function e(r){var n,o;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(n=t.renderManager)||void 0===n||null===(o=n.skyboxManager)||void 0===o||!o.setSkyboxShader){e.next=3;break}return e.next=3,t.renderManager.skyboxManager.setSkyboxShader(r);case 3:case"end":return e.stop()}}),e)}))),function(t){return n.apply(this,arguments)}),emit_particles:function(e,r){try{var n=e&&"function"==typeof e.toObject?e.toObject():e||[0,0,0],o=r&&"function"==typeof r.toObject?r.toObject():r||{};if(t.renderManager&&t.renderManager.particleManager){if(o.preset){var i=t.renderManager.particleManager.preset(o.preset);i&&Object.assign(o,i)}t.renderManager.particleManager.emit(n,o)}}catch(t){console.warn("emit_particles failed",t)}},create_particles:function(e,r){try{var n=e&&"function"==typeof e.toObject?e.toObject():e||[0,0,0],o=r||null;if(t.renderManager&&t.renderManager.particleManager){var i=o?t.renderManager.particleManager.preset(o):{};t.renderManager.particleManager.emit(n,i||{})}}catch(t){console.warn("create_particles failed",t)}},clear_particles:function(){try{t.renderManager&&t.renderManager.particleManager&&(t.renderManager.particleManager.particles=[])}catch(t){console.warn("clear_particles failed",t)}},get_particle_count:function(){try{return t.renderManager&&t.renderManager.particleManager?t.renderManager.particleManager.particles.length:0}catch(t){return console.warn("get_particle_count failed",t),0}}}));var n,o})),this.pixoscript=e}));class M extends Error{constructor(t){super(),this.message=t}toString(){return`LuaError: ${this.message}`}}class j{constructor(t){if(this.numValues=[void 0],this.strValues={},this.keys=[],this.values=[],this.metatable=null,void 0!==t)if("function"!=typeof t){if(Array.isArray(t))this.insert(...t);else for(const e in t)if(H(t,e)){let r=t[e];null===r&&(r=void 0),this.set(e,r)}}else t(this)}get(t){const e=this.rawget(t);if(void 0===e&&this.metatable){const e=this.metatable.get("__index");if(e instanceof j)return e.get(t);if("function"==typeof e){const r=e.call(void 0,this,t);return r instanceof Array?r[0]:r}}return e}rawget(t){switch(typeof t){case"string":if(H(this.strValues,t))return this.strValues[t];break;case"number":if(t>0&&t%1==0)return this.numValues[t]}const e=this.keys.indexOf(D(t));return-1===e?void 0:this.values[e]}getMetaMethod(t){return this.metatable&&this.metatable.rawget(t)}set(t,e){const r=this.metatable&&this.metatable.get("__newindex");if(r&&void 0===this.rawget(t)){if(r instanceof j)return r.set(t,e);if("function"==typeof r)return r(this,t,e)}this.rawset(t,e)}setFn(t){return e=>this.set(t,e)}rawset(t,e){switch(typeof t){case"string":return void(this.strValues[t]=e);case"number":if(t>0&&t%1==0)return void(this.numValues[t]=e)}const r=D(t),n=this.keys.indexOf(r);n>-1?this.values[n]=e:(this.values[this.keys.length]=e,this.keys.push(r))}insert(...t){this.numValues.push(...t)}toObject(){const t=0===Object.keys(this.strValues).length&&this.getn()>0,e=t?[]:{};for(let r=1;r<this.numValues.length;r++){const n=this.numValues[r],o=n instanceof j?n.toObject():n;t?e[r-1]=o:e[String(r-1)]=o}for(const t in this.strValues)if(H(this.strValues,t)){const r=this.strValues[t],n=r instanceof j?r.toObject():r;e[t]=n}return e}getn(){const t=this.numValues,e=[];for(const r in t)H(t,r)&&(e[r]=!0);let r=0;for(;e[r+1];)r+=1;if(r>0&&void 0===t[r]){let e=0;for(;r-e>1;){const n=Math.floor((e+r)/2);void 0===t[n]?r=n:e=n}return e}return r}}const I=/^[-+]?[0-9]*\.?([0-9]+([eE][-+]?[0-9]+)?)?$/,B=/^(-)?0x([0-9a-fA-F]*)\.?([0-9a-fA-F]*)$/;function z(t){const e=typeof t;switch(e){case"undefined":return"nil";case"number":case"string":case"boolean":case"function":return e;case"object":if(t instanceof j)return"table";if(t instanceof Function)return"function"}}function D(t){if(t instanceof j){const r=t.getMetaMethod("__tostring");return r?r(t)[0]:e(t,"table: 0x")}return t instanceof Function?e(t,"function: 0x"):G(t);function e(t,e){const r=t.toString();if(r.indexOf(e)>-1)return r;const n=e+Math.floor(4294967295*Math.random()).toString(16);return t.toString=()=>n,n}}function N(t,e){return t>=0?t:-t>e?0:e+t+1}function R(t,e){if(e)throw new M(`${e}`.replace(/%type/gi,z(t)))}function F(t){return!(!1===t||void 0===t)}function U(t,e){if("number"==typeof t)return t;switch(t){case void 0:return;case"inf":return 1/0;case"-inf":return-1/0;case"nan":return NaN}const r=`${t}`;if(r.match(I))return parseFloat(r);const n=r.match(B);if(n){const[,t,e,r]=n;let o=parseInt(e,16)||0;return r&&(o+=parseInt(r,16)/Math.pow(16,r.length)),t&&(o*=-1),o}void 0!==e&&R(t,e)}function G(t,e){if("string"==typeof t)return t;switch(t){case void 0:case null:return"nil";case 1/0:return"inf";case-1/0:return"-inf"}return"number"==typeof t?Number.isNaN(t)?"nan":`${t}`:"boolean"==typeof t?`${t}`:void 0===e?"nil":void R(t,e)}function W(t,e,r,n,o){return e(t,`bad argument #${o} to '${n}' (${r} expected, got %type)`)}function V(t,e,r){return W(t,U,"number",e,r)}function Z(t,e,r){return W(t,G,"string",e,r)}function $(t,e,r){if(t instanceof j)return t;{const n=z(t);throw new M(`bad argument #${r} to '${e}' (table expected, got ${n})`)}}function Y(t,e,r){if(t instanceof Function)return t;{const n=z(t);throw new M(`bad argument #${r} to '${e}' (function expected, got ${n})`)}}const K=t=>t instanceof Array?t:[t],H=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class q{constructor(t={}){this._variables=t}get(t){return this._variables[t]}set(t,e){H(this._variables,t)||!this.parent?this.setLocal(t,e):this.parent.set(t,e)}setLocal(t,e){this._variables[t]=e}setVarargs(t){this._varargs=t}getVarargs(){return this._varargs||this.parent&&this.parent.getVarargs()||[]}extend(){const t=Object.create(this._variables),e=new q(t);return e.parent=this,e}}var X=r(5233);const J=t=>"IfClause"===t.type||"ElseifClause"===t.type||"ElseClause"===t.type||"WhileStatement"===t.type||"DoStatement"===t.type||"RepeatStatement"===t.type||"FunctionDeclaration"===t.type||"ForNumericStatement"===t.type||"ForGenericStatement"===t.type||"Chunk"===t.type;class Q extends String{constructor(t,e){super(),this.base=t,this.property=e}get(){return`__lua.get(${this.base}, ${this.property})`}set(t){return`${this.base}.set(${this.property}, ${t})`}setFn(){return`${this.base}.setFn(${this.property})`}toString(){return this.get()}valueOf(){return this.get()}}const tt={not:"not","-":"unm","~":"bnot","#":"len"},et={"+":"add","-":"sub","*":"mul","%":"mod","^":"pow","/":"div","//":"idiv","&":"band","|":"bor","~":"bxor","<<":"shl",">>":"shr","..":"concat","~=":"neq","==":"eq","<":"lt","<=":"le",">":"gt",">=":"ge"},rt=t=>{switch(t.type){case"LabelStatement":return`case '${t.label.name}': label = undefined`;case"BreakStatement":return"break";case"GotoStatement":return`label = '${t.label.name}'; continue`;case"ReturnStatement":return`return ${it(t.arguments)}`;case"IfStatement":return t.clauses.map((t=>rt(t))).join(" else ");case"IfClause":case"ElseifClause":return`if (__lua.bool(${ot(t.condition)})) {\n${nt(t)}\n}`;case"ElseClause":return`{\n${nt(t)}\n}`;case"WhileStatement":return`while(${ot(t.condition)}) {\n${nt(t)}\n}`;case"DoStatement":return`\n${nt(t)}\n`;case"RepeatStatement":{const e=ot(t.condition);return`do {\n${nt(t)}\n} while (!(${e}))`}case"LocalStatement":case"AssignmentStatement":return st(t);case"CallStatement":return rt(t.expression);case"FunctionDeclaration":{const e=e=>{const r=e.join(";\n"),n=nt(t,r);return`(${0===e.length?"":"...args"}) => {\n${n}${-1===t.body.findIndex((t=>"ReturnStatement"===t.type))?"\nreturn []":""}\n}`},r=t.parameters.map((t=>"VarargLiteral"===t.type?`$${ht.get(t)}.setVarargs(args)`:`$${ht.get(t)}.setLocal('${t.name}', args.shift())`));if(null===t.identifier)return e(r);if("Identifier"===t.identifier.type)return`$${ht.get(t.identifier)}.${t.isLocal?"setLocal":"set"}('${t.identifier.name}', ${e(r)})`;const n=rt(t.identifier);return":"===t.identifier.indexer&&r.unshift(`$${ht.get(t)}.setLocal('self', args.shift())`),n.set(e(r))}case"ForNumericStatement":{const e=t.variable.name,r=`let ${e} = ${ot(t.start)}, end = ${ot(t.end)}, step = ${null===t.step?1:ot(t.step)}`,n=`step > 0 ? ${e} <= end : ${e} >= end`,o=`${e} += step`,i=`$${ht.get(t.variable)}.setLocal('${e}', ${e});`;return`for (${r}; ${n}; ${o}) {\n${nt(t,i)}\n}`}case"ForGenericStatement":{const e=it(t.iterators),r=t.variables.map(((t,e)=>`$${ht.get(t)}.setLocal('${t.name}', res[${e}])`)).join(";\n");return`for (let [iterator, table, next] = ${e}, res = __lua.call(iterator, table, next); res[0] !== undefined; res = __lua.call(iterator, table, res[0])) {\n${nt(t,r)}\n}`}case"Chunk":return`'use strict'\nconst $0 = __lua.globalScope\nlet vars\nlet vals\nlet label\n\n${nt(t)}`;case"Identifier":return`$${ht.get(t)}.get('${t.name}')`;case"StringLiteral":return`\`${t.value.replace(/([^\\])?\\(\d{1,3})/g,((t,e,r)=>`${e||""}${String.fromCharCode(r)}`)).replace(/\\/g,"\\\\").replace(/`/g,"\\`")}\``;case"NumericLiteral":return t.value.toString();case"BooleanLiteral":return t.value?"true":"false";case"NilLiteral":return"undefined";case"VarargLiteral":return`$${ht.get(t)}.getVarargs()`;case"TableConstructorExpression":return 0===t.fields.length?"new __lua.Table()":`new __lua.Table(t => {\n${t.fields.map(((t,e,r)=>"TableKey"===t.type?`t.rawset(${rt(t.key)}, ${ot(t.value)})`:"TableKeyString"===t.type?`t.rawset('${t.key.name}', ${ot(t.value)})`:"TableValue"===t.type?e===r.length-1&&ut(t.value)?`t.insert(...${rt(t.value)})`:`t.insert(${ot(t.value)})`:void 0)).join(";\n")}\n})`;case"UnaryExpression":{const e=tt[t.operator],r=ot(t.argument);if(!e)throw new Error(`Unhandled unary operator: ${t.operator}`);return`__lua.${e}(${r})`}case"BinaryExpression":{const e=ot(t.left),r=ot(t.right),n=et[t.operator];if(!n)throw new Error(`Unhandled binary operator: ${t.operator}`);return`__lua.${n}(${e}, ${r})`}case"LogicalExpression":{const e=ot(t.left),r=ot(t.right),n=t.operator;if("and"===n)return`__lua.and(${e},${r})`;if("or"===n)return`__lua.or(${e},${r})`;throw new Error(`Unhandled logical operator: ${t.operator}`)}case"MemberExpression":{const e=ot(t.base);return new Q(e,`'${t.identifier.name}'`)}case"IndexExpression":{const e=ot(t.base),r=ot(t.index);return new Q(e,r)}case"CallExpression":case"TableCallExpression":case"StringCallExpression":{const e=ot(t.base),r="CallExpression"===t.type?at(t.arguments).join(", "):ot("TableCallExpression"===t.type?t.arguments:t.argument);return e instanceof Q&&"MemberExpression"===t.base.type&&":"===t.base.indexer?`__lua.call(${e}, ${e.base}, ${r})`:`__lua.call(${e}, ${r})`}default:throw new Error(`No generator found for: ${t.type}`)}},nt=(t,e="")=>{const r=ht.get(t),n=void 0===r?"":`const $${r} = $${ft.get(r)}.extend();`,o=t.body.map((t=>rt(t))).join(";\n"),i=pt.get(t);if(void 0===i)return`${n}\n${e}\n${o}`;const a=`L${i}: do { switch(label) { case undefined:`,s=dt.get(i);return`${n}\n${a}\n${e}\n${o}\n${(void 0===s?"":`break; default: continue L${s}\n`)+"} } while (label)"}`},ot=t=>{const e=rt(t);return ut(t)?`${e}[0]`:e},it=t=>1===t.length&&ut(t[0])?rt(t[0]):`[${at(t).join(", ")}]`,at=t=>t.map(((t,e,r)=>{const n=rt(t);return ut(t)?e===r.length-1?`...${n}`:`${n}[0]`:n})),st=t=>{const e=[],r=[],n=t.variables.length>1&&t.init.length>0&&!t.init.every(lt);for(let o=0;o<t.variables.length;o++){const i=t.variables[o],a=t.init[o],s=n?`vars[${o}]`:void 0===a?"undefined":ot(a);if("Identifier"===i.type){const r="LocalStatement"===t.type?"setLocal":"set";e.push(`$${ht.get(i)}.${r}('${i.name}', ${s})`)}else{const t=rt(i);n?(e.push(`vals[${r.length}](${s})`),r.push(t.setFn())):e.push(t.set(s))}}for(let r=t.variables.length;r<t.init.length;r++){const n=t.init[r];ct(n)&&e.push(rt(n))}return n&&(e.unshift(`vars = ${it(t.init)}`),r.length>0&&e.unshift(`vals = [${r.join(", ")}]`)),e.join(";\n")},ct=t=>"CallExpression"===t.type||"StringCallExpression"===t.type||"TableCallExpression"===t.type,ut=t=>ct(t)||"VarargLiteral"===t.type,lt=t=>"StringLiteral"===t.type||"NumericLiteral"===t.type||"BooleanLiteral"===t.type||"NilLiteral"===t.type||"TableConstructorExpression"===t.type,ft=new Map,ht=new Map,dt=new Map,pt=new Map,yt=t=>{const e=X.parse(t.replace(/^#.*/,""),{scope:!1,comments:!1,luaVersion:"5.3",encodingMode:"x-user-defined"});return(t=>{const e=[];let r=0;const n=new Map,o=(()=>{let t=0;return()=>(t+=1,t)})(),i=t=>{if(J(t)){!function(){const t=r;r=o(),n.set(r,t)}();for(let n=0;n<t.body.length;n++){const o=t.body[n];switch(o.type){case"LocalStatement":e.push({type:"local",name:o.variables[0].name,scope:r});break;case"LabelStatement":if(e.find((t=>"label"===t.type&&t.name===o.label.name&&t.scope===r)))throw new Error(`label '${o.label.name}' already defined`);e.push({type:"label",name:o.label.name,scope:r,last:"RepeatStatement"!==t.type&&t.body.slice(n).every((t=>"LabelStatement"===t.type))});break;case"GotoStatement":e.push({type:"goto",name:o.label.name,scope:r});break;case"IfStatement":o.clauses.forEach((t=>i(t)));break;default:i(o)}}r=n.get(r)}};i(t);for(let t=0;t<e.length;t++){const r=e[t];if("goto"===r.type){const n=e.filter((t=>"label"===t.type&&t.name===r.name&&t.scope<=r.scope)).sort(((t,e)=>Math.abs(r.scope-t.scope)-Math.abs(r.scope-e.scope)))[0];if(!n)throw new Error(`no visible label '${r.name}' for <goto>`);const o=e.findIndex((t=>t===n));if(o>t){const i=e.slice(t,o).filter((t=>"local"===t.type&&t.scope===n.scope));if(!n.last&&i.length>0)throw new Error(`<goto ${r.name}> jumps into the scope of local '${i[0].name}'`)}}}})(e),(t=>{let e=0,r=0;const n=(t,o,i)=>{let a=o,s=i;J(t)?((-1!==t.body.findIndex((t=>"LocalStatement"===t.type||"FunctionDeclaration"===t.type&&t.isLocal))||"FunctionDeclaration"===t.type&&(t.parameters.length>0||t.identifier&&"MemberExpression"===t.identifier.type)||"ForNumericStatement"===t.type||"ForGenericStatement"===t.type)&&(e+=1,a=e,ht.set(t,e),ft.set(e,o)),-1!==t.body.findIndex((t=>"LabelStatement"===t.type||"GotoStatement"===t.type))&&(s=r,pt.set(t,r),"Chunk"!==t.type&&"FunctionDeclaration"!==t.type&&dt.set(r,i),r+=1)):"Identifier"!==t.type&&"VarargLiteral"!==t.type||ht.set(t,o),((t,e,r,n,o)=>{const i=(t,i=!0)=>{if(!t)return;const a=!1===i&&n?ft.get(r):r;Array.isArray(t)?t.forEach((t=>e(t,a,o))):e(t,a,o)};switch(t.type){case"LocalStatement":case"AssignmentStatement":i(t.variables),i(t.init);break;case"UnaryExpression":i(t.argument);break;case"BinaryExpression":case"LogicalExpression":i(t.left),i(t.right);break;case"FunctionDeclaration":i(t.identifier,!1),i(t.parameters),i(t.body);break;case"ForGenericStatement":i(t.variables),i(t.iterators,!1),i(t.body);break;case"IfClause":case"ElseifClause":case"WhileStatement":case"RepeatStatement":i(t.condition,!1);case"Chunk":case"ElseClause":case"DoStatement":i(t.body);break;case"ForNumericStatement":i(t.variable),i(t.start,!1),i(t.end,!1),i(t.step,!1),i(t.body);break;case"ReturnStatement":i(t.arguments);break;case"IfStatement":i(t.clauses);break;case"MemberExpression":i(t.base),i(t.identifier);break;case"IndexExpression":i(t.base),i(t.index);break;case"LabelStatement":i(t.label);break;case"CallStatement":i(t.expression);break;case"GotoStatement":i(t.label);break;case"TableConstructorExpression":i(t.fields);break;case"TableKey":case"TableKeyString":i(t.key);case"TableValue":i(t.value);break;case"CallExpression":case"TableCallExpression":i(t.base),i(t.arguments);break;case"StringCallExpression":i(t.base),i(t.argument)}})(t,n,a,o!==a,s)};n(t,e,r)})(e),rt(e).toString()};const gt="1.3.1";var mt={};function vt(t){if(mt[t])return mt[t];for(var e=[],r=0,n=0,o=!1,i="",a="",s="",c="",u="",l=0,f=t.length;n<f;++n)if(l=t.charCodeAt(n),o)if(l>=48&&l<58)c.length?c+=String.fromCharCode(l):48!=l||s.length?s+=String.fromCharCode(l):a+=String.fromCharCode(l);else switch(l){case 36:c.length?c+="$":"*"==s.charAt(0)?s+="$":(i=s+"$",s="");break;case 39:a+="'";break;case 45:a+="-";break;case 43:a+="+";break;case 32:a+=" ";break;case 35:a+="#";break;case 46:c=".";break;case 42:"."==c.charAt(0)?c+="*":s+="*";break;case 104:case 108:if(u.length>1)throw"bad length "+u+String(l);u+=String.fromCharCode(l);break;case 76:case 106:case 122:case 116:case 113:case 90:case 119:if(""!==u)throw"bad length "+u+String.fromCharCode(l);u=String.fromCharCode(l);break;case 73:if(""!==u)throw"bad length "+u+"I";u="I";break;case 100:case 105:case 111:case 117:case 120:case 88:case 102:case 70:case 101:case 69:case 103:case 71:case 97:case 65:case 99:case 67:case 115:case 83:case 112:case 110:case 68:case 85:case 79:case 109:case 98:case 66:case 121:case 89:case 74:case 86:case 84:case 37:o=!1,c.length>1&&(c=c.substr(1)),e.push([String.fromCharCode(l),t.substring(r,n+1),i,a,s,c,u]),r=n+1,u=c=s=a=i="";break;default:throw new Error("Invalid format string starting with |"+t.substring(r,n+1)+"|")}else{if(37!==l)continue;r<n&&e.push(["L",t.substring(r,n)]),r=n,o=!0}return r<t.length&&e.push(["L",t.substring(r)]),mt[t]=e}var bt=JSON.stringify;function wt(t,e){for(var r="",n=0,o=0,i=0,a="",s=0;s<t.length;++s){var c=t[s],u=c[0].charCodeAt(0);if(76!==u)if(37!==u){var l="",f=0,h=10,d=4,p=!1,y=c[3],g=y.indexOf("#")>-1;if(c[2])n=parseInt(c[2],10)-1;else if(109===u&&!g){r+="Success";continue}var m=0;c[4].length>0&&(m="*"!==c[4].charAt(0)?parseInt(c[4],10):1===c[4].length?e[o++]:e[parseInt(c[4].substr(1),10)-1]);var v=-1;c[5].length>0&&(v="*"!==c[5].charAt(0)?parseInt(c[5],10):1===c[5].length?e[o++]:e[parseInt(c[5].substr(1),10)-1]),c[2]||(n=o++);var b=e[n],w=c[6];switch(u){case 83:case 115:l=String(b),v>=0&&(l=l.substr(0,v)),(m>l.length||-m>l.length)&&((-1==y.indexOf("-")||m<0)&&-1!=y.indexOf("0")?l=(a=m-l.length>=0?"0".repeat(m-l.length):"")+l:(a=m-l.length>=0?" ".repeat(m-l.length):"",l=y.indexOf("-")>-1?l+a:a+l));break;case 67:case 99:switch(typeof b){case"number":var x=b;67==u||108===w.charCodeAt(0)?(x&=4294967295,l=String.fromCharCode(x)):(x&=255,l=String.fromCharCode(x));break;case"string":l=b.charAt(0);break;default:l=String(b).charAt(0)}(m>l.length||-m>l.length)&&((-1==y.indexOf("-")||m<0)&&-1!=y.indexOf("0")?l=(a=m-l.length>=0?"0".repeat(m-l.length):"")+l:(a=m-l.length>=0?" ".repeat(m-l.length):"",l=y.indexOf("-")>-1?l+a:a+l));break;case 68:d=8;case 100:case 105:f=-1,p=!0;break;case 85:d=8;case 117:f=-1;break;case 79:d=8;case 111:f=-1,h=8;break;case 120:f=-1,h=-16;break;case 88:f=-1,h=16;break;case 66:d=8;case 98:f=-1,h=2;break;case 70:case 102:f=1;break;case 69:case 101:f=2;break;case 71:case 103:f=3;break;case 65:case 97:f=4;break;case 112:i="number"==typeof b?b:b?Number(b.l):-1,isNaN(i)&&(i=-1),l=g?i.toString(10):"0x"+(i=Math.abs(i)).toString(16).toLowerCase();break;case 110:b&&(b.len=r.length);continue;case 109:l=b instanceof Error?b.message?b.message:b.errno?"Error number "+b.errno:"Error "+String(b):"Success";break;case 74:l=(g?bt:JSON.stringify)(b);break;case 86:l=null==b?"null":String(b.valueOf());break;case 84:l=g?(l=Object.prototype.toString.call(b).substr(8)).substr(0,l.length-1):typeof b;break;case 89:case 121:l=b?g?"yes":"true":g?"no":"false",89==u&&(l=l.toUpperCase()),v>=0&&(l=l.substr(0,v)),(m>l.length||-m>l.length)&&((-1==y.indexOf("-")||m<0)&&-1!=y.indexOf("0")?l=(a=m-l.length>=0?"0".repeat(m-l.length):"")+l:(a=m-l.length>=0?" ".repeat(m-l.length):"",l=y.indexOf("-")>-1?l+a:a+l))}if(m<0&&(m=-m,y+="-"),-1==f){switch(i=Number(b),w){case"hh":d=1;break;case"h":d=2;break;case"l":case"L":case"q":case"ll":case"j":case"t":case"z":case"Z":case"I":4==d&&(d=8)}switch(d){case 1:i&=255,p&&i>127&&(i-=256);break;case 2:i&=65535,p&&i>32767&&(i-=65536);break;case 4:i=p?0|i:i>>>0;break;default:i=isNaN(i)?0:Math.round(i)}if(d>4&&i<0&&!p)if(16==h||-16==h)l=(i>>>0).toString(16),l=(16-(l=((i=Math.floor((i-(i>>>0))/Math.pow(2,32)))>>>0).toString(16)+(8-l.length>=0?"0".repeat(8-l.length):"")+l).length>=0?"f".repeat(16-l.length):"")+l,16==h&&(l=l.toUpperCase());else if(8==h)l=(10-(l=(i>>>0).toString(8)).length>=0?"0".repeat(10-l.length):"")+l,l="1"+(21-(l=(l=((i=Math.floor((i-(i>>>0&1073741823))/Math.pow(2,30)))>>>0).toString(8)+l.substr(l.length-10)).substr(l.length-20)).length>=0?"7".repeat(21-l.length):"")+l;else{i=-i%1e16;for(var _=[1,8,4,4,6,7,4,4,0,7,3,7,0,9,5,5,1,6,1,6],k=_.length-1;i>0;)(_[k]-=i%10)<0&&(_[k]+=10,_[k-1]--),--k,i=Math.floor(i/10);l=_.join("")}else l=-16===h?i.toString(16).toLowerCase():16===h?i.toString(16).toUpperCase():i.toString(h);if(0!==v||"0"!=l||8==h&&g){if(l.length<v+("-"==l.substr(0,1)?1:0)&&(l="-"!=l.substr(0,1)?(v-l.length>=0?"0".repeat(v-l.length):"")+l:l.substr(0,1)+(v+1-l.length>=0?"0".repeat(v+1-l.length):"")+l.substr(1)),!p&&g&&0!==i)switch(h){case-16:l="0x"+l;break;case 16:l="0X"+l;break;case 8:"0"!=l.charAt(0)&&(l="0"+l);break;case 2:l="0b"+l}}else l="";p&&"-"!=l.charAt(0)&&(y.indexOf("+")>-1?l="+"+l:y.indexOf(" ")>-1&&(l=" "+l)),m>0&&l.length<m&&(y.indexOf("-")>-1?l+=m-l.length>=0?" ".repeat(m-l.length):"":y.indexOf("0")>-1&&v<0&&l.length>0?(v>l.length&&(l=(v-l.length>=0?"0".repeat(v-l.length):"")+l),a=m-l.length>=0?(v>0?" ":"0").repeat(m-l.length):"",l=l.charCodeAt(0)<48?"x"==l.charAt(2).toLowerCase()?l.substr(0,3)+a+l.substring(3):l.substr(0,1)+a+l.substring(1):"x"==l.charAt(1).toLowerCase()?l.substr(0,2)+a+l.substring(2):a+l):l=(m-l.length>=0?" ".repeat(m-l.length):"")+l)}else if(f>0){i=Number(b),null===b&&(i=NaN),"L"==w&&(d=12);var E=isFinite(i);if(E){var A=0;-1==v&&4!=f&&(v=6),3==f&&(0===v&&(v=1),v>(A=+(l=i.toExponential(1)).substr(l.indexOf("e")+1))&&A>=-4?(f=11,v-=A+1):(f=12,v-=1));var S=i<0||1/i==-1/0?"-":"";switch(i<0&&(i=-i),f){case 1:case 11:if(i<1e21){l=i.toFixed(v),1==f?0===v&&g&&-1==l.indexOf(".")&&(l+="."):g?-1==l.indexOf(".")&&(l+="."):l=l.replace(/(\.\d*[1-9])0*$/,"$1").replace(/\.0*$/,"");break}A=+(l=i.toExponential(20)).substr(l.indexOf("e")+1),l=l.charAt(0)+l.substr(2,l.indexOf("e")-2),l+=A-l.length+1>=0?"0".repeat(A-l.length+1):"",(g||v>0&&11!==f)&&(l=l+"."+(v>=0?"0".repeat(v):""));break;case 2:case 12:A=(l=i.toExponential(v)).indexOf("e"),l.length-A==3&&(l=l.substr(0,A+2)+"0"+l.substr(A+2)),g&&-1==l.indexOf(".")?l=l.substr(0,A)+"."+l.substr(A):g||12!=f||(l=l.replace(/\.0*e/,"e").replace(/\.(\d*[1-9])0*e/,".$1e"));break;case 4:if(0===i){l="0x0"+(g||v>0?"."+(v>=0?"0".repeat(v):""):"")+"p+0";break}var L=(l=i.toString(16)).charCodeAt(0);if(48==L){for(L=2,A=-4,i*=16;48==l.charCodeAt(L++);)A-=4,i*=16;L=(l=i.toString(16)).charCodeAt(0)}var O=l.indexOf(".");if(l.indexOf("(")>-1){var P=l.match(/\(e(.*)\)/),T=P?+P[1]:0;A+=4*T,i/=Math.pow(16,T)}else O>1?(A+=4*(O-1),i/=Math.pow(16,O-1)):-1==O&&(A+=4*(l.length-1),i/=Math.pow(16,l.length-1));if(d>8?L<50?(A-=3,i*=8):L<52?(A-=2,i*=4):L<56&&(A-=1,i*=2):L>=56?(A+=3,i/=8):L>=52?(A+=2,i/=4):L>=50&&(A+=1,i/=2),(l=i.toString(16)).length>1){if(l.length>v+2&&l.charCodeAt(v+2)>=56){var C=102==l.charCodeAt(0);l=(i+8*Math.pow(16,-v-1)).toString(16),C&&49==l.charCodeAt(0)&&(A+=4)}v>0?(l=l.substr(0,v+2)).length<v+2&&(l.charCodeAt(0)<48?l=l.charAt(0)+(v+2-l.length>=0?"0".repeat(v+2-l.length):"")+l.substr(1):l+=v+2-l.length>=0?"0".repeat(v+2-l.length):""):0===v&&(l=l.charAt(0)+(g?".":""))}else v>0?l=l+"."+(v>=0?"0".repeat(v):""):g&&(l+=".");l="0x"+l+"p"+(A>=0?"+"+A:A)}""===S&&(y.indexOf("+")>-1?S="+":y.indexOf(" ")>-1&&(S=" ")),l=S+l}else i<0?l="-":y.indexOf("+")>-1?l="+":y.indexOf(" ")>-1&&(l=" "),l+=isNaN(i)?"nan":"inf";m>l.length&&(y.indexOf("-")>-1?l+=m-l.length>=0?" ".repeat(m-l.length):"":y.indexOf("0")>-1&&l.length>0&&E?(a=m-l.length>=0?"0".repeat(m-l.length):"",l=l.charCodeAt(0)<48?"x"==l.charAt(2).toLowerCase()?l.substr(0,3)+a+l.substring(3):l.substr(0,1)+a+l.substring(1):"x"==l.charAt(1).toLowerCase()?l.substr(0,2)+a+l.substring(2):a+l):l=(m-l.length>=0?" ".repeat(m-l.length):"")+l),u<96&&(l=l.toUpperCase())}r+=l}else r+="%";else r+=c[1]}return r}function xt(t,e){return wt(vt(t),e)}function _t(){for(var t=new Array(arguments.length-1),e=0;e<t.length;++e)t[e]=arguments[e+1];return wt(vt(arguments[0]),t)}const{sprintf:kt}=o,Et={"([^a-zA-Z0-9%(])-":"$1*?","([^%])-([^a-zA-Z0-9?])":"$1*?$2","([^%])\\.":"$1[\\s\\S]","(.)-$":"$1*?","%a":"[a-zA-Z]","%A":"[^a-zA-Z]","%c":"[\0-]","%C":"[^\0-]","%d":"\\d","%D":"[^d]","%l":"[a-z]","%L":"[^a-z]","%p":"[.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%P":"[^.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%s":"[ \\t\\n\\f\\v\\r]","%S":"[^ \t\n\f\v\r]","%u":"[A-Z]","%U":"[^A-Z]","%w":"[a-zA-Z0-9]","%W":"[^a-zA-Z0-9]","%x":"[a-fA-F0-9]","%X":"[^a-fA-F0-9]","%([^a-zA-Z])":"\\$1"};function At(t){let e=t.replace(/\\/g,"\\\\");for(const t in Et)H(Et,t)&&(e=e.replace(new RegExp(t,"g"),Et[t]));let r=0;for(let t=0,n=e.length;t<n;t++){if(t&&"\\"===e.substr(t-1,1))continue;const o=e.substr(t,1);"["!==o&&"]"!==o||("]"===o&&(r-=1),r>0&&(e=e.substr(0,t)+e.substr(t+1),t-=1,n-=1),"["===o&&(r+=1))}return e}const St=new j({byte:function(t,e,r){const n=Z(t,"byte",1),o=void 0===e?1:V(e,"byte",2),i=void 0===r?o:V(r,"byte",3);return n.substring(o-1,i).split("").map((t=>t.charCodeAt(0)))},char:function(...t){return t.map(((t,e)=>{const r=V(t,"char",e);return String.fromCharCode(r)})).join("")},find:function(t,e,r,n){const o=Z(t,"find",1),i=Z(e,"find",2),a=void 0===r?1:V(r,"find",3);if(void 0===n||!V(n,"find",4)){const t=new RegExp(At(i)),e=o.substr(a-1).search(t);if(e<0)return;const r=o.substr(a-1).match(t),n=[e+a,e+a+r[0].length-1];return r.shift(),[...n,...r]}const s=o.indexOf(i,a-1);return-1===s?void 0:[s+1,s+i.length]},format:function(t,...e){let r=-1;return t.replace(/%%|%([-+ #0]*)?(\d*)?(?:\.(\d*))?(.)/g,((t,n,o,i,a)=>{if("%%"===t)return"%";if(!a.match(/[AEGXacdefgioqsux]/))throw new M(`invalid option '%${t}' to 'format'`);if(n&&n.length>5)throw new M("invalid format (repeated flags)");if(o&&o.length>2)throw new M("invalid format (width too long)");if(i&&i.length>2)throw new M("invalid format (precision too long)");r+=1;const s=e[r];if(void 0===s)throw new M(`bad argument #${r} to 'format' (no value)`);return/A|a|E|e|f|G|g/.test(a)||/c|d|i|o|u|X|x/.test(a)?kt(t,V(s,"format",r)):"q"===a?`"${s.replace(/([\n"])/g,"\\$1")}"`:kt(t,"s"===a?D(s):s)}))},gmatch:function(t,e){const r=Z(t,"gmatch",1),n=At(Z(e,"gmatch",2)),o=new RegExp(n,"g"),i=r.match(o);return()=>{const t=i.shift();if(void 0===t)return[];const e=new RegExp(n).exec(t);return e.shift(),e.length?e:[t]}},gsub:function(t,e,r,n){let o=Z(t,"gsub",1);const i=void 0===n?1/0:V(n,"gsub",3),a=At(Z(e,"gsub",2)),s="function"==typeof r?t=>{const e=r(t[0])[0];return void 0===e?t[0]:e}:r instanceof j?t=>r.get(t[0]).toString():t=>`${r}`.replace(/%([0-9])/g,((e,r)=>t[r]));let c,u,l="",f=0;for(;f<i&&o&&(c=o.match(a));){const t=c[0].length>0?o.substr(0,c.index):void 0===u?"":o.substr(0,1);u=c[0],l+=`${t}${s(c)}`,o=o.substr(`${t}${u}`.length),f+=1}return`${l}${o}`},len:function(t){return Z(t,"len",1).length},lower:function(t){return Z(t,"lower",1).toLowerCase()},match:function(t,e,r=0){let n=Z(t,"match",1);const o=Z(e,"match",2),i=V(r,"match",3);n=n.substr(i);const a=n.match(new RegExp(At(o)));if(a)return a[1]?(a.shift(),a):a[0]},rep:function(t,e,r){const n=Z(t,"rep",1),o=V(e,"rep",2),i=void 0===r?"":Z(r,"rep",3);return Array(o).fill(n).join(i)},reverse:function(t){return Z(t,"reverse",1).split("").reverse().join("")},sub:function(t,e=1,r=-1){const n=Z(t,"sub",1);let o=N(V(e,"sub",2),n.length),i=N(V(r,"sub",3),n.length);return o<1&&(o=1),i>n.length&&(i=n.length),o<=i?n.substr(o-1,i-o+1):""},upper:function(t){return Z(t,"upper",1).toUpperCase()}}),Lt=new j({__index:St});function Ot(t,e){if(void 0===e)throw new M("Bad argument #2 to ipairs() iterator");const r=e+1,n=t.numValues;if(n[r]&&void 0!==n[r])return[r,n[r]]}function Pt(t,e){if(F(t))return[t,e];const r=void 0===e?"Assertion failed!":Z(e,"assert",2);throw new M(r)}function Tt(){return[]}function Ct(t){const e=Z(t,"error",1);throw new M(e)}function Mt(t){if(t instanceof j&&t.metatable){return t.metatable.rawget("__metatable")||t.metatable}if("string"==typeof t)return Lt}function jt(t){const e=$(t,"ipairs",1),r=e.getMetaMethod("__pairs")||e.getMetaMethod("__ipairs");return r?r(e).slice(0,3):[Ot,e,0]}function It(t,e){const r=$(t,"next",1);let n=void 0===e;if(n||"number"==typeof e&&e>0){const t=r.numValues,o=Object.keys(t);let i=1;if(!n){const t=o.indexOf(`${e}`);t>=0&&(n=!0,i+=t)}if(n)for(;void 0!==o[i];i++){const e=Number(o[i]),r=t[e];if(void 0!==r)return[e,r]}}for(const t in r.strValues)if(H(r.strValues,t))if(n){if(void 0!==r.strValues[t])return[t,r.strValues[t]]}else t===e&&(n=!0);for(const t in r.keys)if(H(r.keys,t)){const o=r.keys[t];if(n){if(void 0!==r.values[t])return[o,r.values[t]]}else o===e&&(n=!0)}}function Bt(t){const e=$(t,"pairs",1),r=e.getMetaMethod("__pairs");return r?r(e).slice(0,3):[It,e,void 0]}function zt(t,...e){if("function"!=typeof t)throw new M("Attempt to call non-function");try{return[!0,...t(...e)]}catch(t){return[!1,t&&t.toString()]}}function Dt(t,e){return t===e}function Nt(t,e){return $(t,"rawget",1).rawget(e)}function Rt(t){if(t instanceof j)return t.getn();if("string"==typeof t)return t.length;throw new M("attempt to get length of an unsupported value")}function Ft(t,e,r){const n=$(t,"rawset",1);if(void 0===e)throw new M("table index is nil");return n.rawset(e,r),n}function Ut(t,...e){if("#"===t)return e.length;if("number"==typeof t){const r=N(Math.trunc(t),e.length);return e.slice(r-1)}throw new M(`bad argument #1 to 'select' (number expected, got ${z(t)})`)}function Gt(t,e){const r=$(t,"setmetatable",1);if(r.metatable&&r.metatable.rawget("__metatable"))throw new M("cannot change a protected metatable");return r.metatable=null==e?null:$(e,"setmetatable",2),r}function Wt(t,e){const r=G(t).trim(),n=void 0===e?10:V(e,"tonumber",2);if(10!==n&&"nil"===r)throw new M("bad argument #1 to 'tonumber' (string expected, got nil)");if(n<2||n>36)throw new M("bad argument #2 to 'tonumber' (base out of range)");if(""!==r)return 10===n?U(r):new RegExp(`^${16===n?"(0x)?":""}[${"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".substr(0,n)}]*$`,"gi").test(r)?parseInt(r,n):void 0}function Vt(t,e,...r){if("function"!=typeof t||"function"!=typeof e)throw new M("Attempt to call non-function");try{return[!0,...t(...r)]}catch(t){return[!1,e(t)[0]]}}const Zt=(t,e,r,n)=>{const o=t instanceof j&&t.getMetaMethod(r)||e instanceof j&&e.getMetaMethod(r);return o?o(t,e)[0]:n(U(t,"attempt to perform arithmetic on a %type value"),U(e,"attempt to perform arithmetic on a %type value"))},$t=(t,e,r,n)=>"string"==typeof t&&"string"==typeof e||"number"==typeof t&&"number"==typeof e?n(t,e):Zt(t,e,r,n),Yt=t=>F(t),Kt=(t,e)=>{const r=e!==t&&t instanceof j&&e instanceof j&&t.metatable===e.metatable&&t.getMetaMethod("__eq");return r?!!r(t,e)[0]:t===e},Ht=(t,e)=>$t(t,e,"__lt",((t,e)=>t<e)),qt=(t,e)=>$t(t,e,"__le",((t,e)=>t<=e)),Xt={bool:Yt,and:(t,e)=>F(t)?e:t,or:(t,e)=>F(t)?t:e,not:t=>!Yt(t),unm:t=>{const e=t instanceof j&&t.getMetaMethod("__unm");return e?e(t)[0]:-1*U(t,"attempt to perform arithmetic on a %type value")},bnot:t=>{const e=t instanceof j&&t.getMetaMethod("__bnot");return e?e(t)[0]:~U(t,"attempt to perform arithmetic on a %type value")},len:t=>{if(t instanceof j){const e=t.getMetaMethod("__len");return e?e(t)[0]:t.getn()}if("string"==typeof t)return t.length;throw new M("attempt to get length of an unsupported value")},add:(t,e)=>Zt(t,e,"__add",((t,e)=>t+e)),sub:(t,e)=>Zt(t,e,"__sub",((t,e)=>t-e)),mul:(t,e)=>Zt(t,e,"__mul",((t,e)=>t*e)),mod:(t,e)=>Zt(t,e,"__mod",((t,e)=>{if(0===e||e===-1/0||e===1/0||isNaN(t)||isNaN(e))return NaN;const r=Math.abs(e);let n=Math.abs(t)%r;return t*e<0&&(n=r-n),e<0&&(n*=-1),n})),pow:(t,e)=>Zt(t,e,"__pow",Math.pow),div:(t,e)=>Zt(t,e,"__div",((t,e)=>{if(void 0===e)throw new M("attempt to perform arithmetic on a nil value");return t/e})),idiv:(t,e)=>Zt(t,e,"__idiv",((t,e)=>{if(void 0===e)throw new M("attempt to perform arithmetic on a nil value");return Math.floor(t/e)})),band:(t,e)=>Zt(t,e,"__band",((t,e)=>t&e)),bor:(t,e)=>Zt(t,e,"__bor",((t,e)=>t|e)),bxor:(t,e)=>Zt(t,e,"__bxor",((t,e)=>t^e)),shl:(t,e)=>Zt(t,e,"__shl",((t,e)=>t<<e)),shr:(t,e)=>Zt(t,e,"__shr",((t,e)=>t>>e)),concat:(t,e)=>{const r=t instanceof j&&t.getMetaMethod("__concat")||e instanceof j&&e.getMetaMethod("__concat");return r?r(t,e)[0]:`${G(t,"attempt to concatenate a %type value")}${G(e,"attempt to concatenate a %type value")}`},neq:(t,e)=>!Kt(t,e),eq:Kt,lt:Ht,le:qt,gt:(t,e)=>!qt(t,e),ge:(t,e)=>!Ht(t,e)},Jt=Number.MAX_SAFE_INTEGER,Qt=Number.MIN_SAFE_INTEGER,te=Math.PI;let ee=1;function re(){return ee=16807*ee%2147483647,ee/2147483647}function ne(t,e){const r=V(t,"atan",1),n=void 0===e?1:V(e,"atan",2);return Math.atan2(r,n)}function oe(t){const e=V(t,"exp",1);return Math.exp(e)}function ie(t){const e=U(t);if(void 0!==e)return Math.floor(e)}const ae=new j({abs:function(t){const e=V(t,"abs",1);return Math.abs(e)},acos:function(t){const e=V(t,"acos",1);return Math.acos(e)},asin:function(t){const e=V(t,"asin",1);return Math.asin(e)},atan:ne,atan2:function(t,e){return ne(t,e)},ceil:function(t){const e=V(t,"ceil",1);return Math.ceil(e)},cos:function(t){const e=V(t,"cos",1);return Math.cos(e)},cosh:function(t){const e=V(t,"cosh",1);return(oe(e)+oe(-e))/2},deg:function(t){return 180*V(t,"deg",1)/Math.PI},exp:oe,floor:function(t){const e=V(t,"floor",1);return Math.floor(e)},fmod:function(t,e){return V(t,"fmod",1)%V(e,"fmod",2)},frexp:function(t){let e=V(t,"frexp",1);if(0===e)return[0,0];const r=e>0?1:-1;e*=r;const n=Math.floor(Math.log(e)/Math.log(2))+1;return[e/Math.pow(2,n)*r,n]},huge:1/0,ldexp:function(t,e){const r=V(t,"ldexp",1),n=V(e,"ldexp",2);return r*Math.pow(2,n)},log:function(t,e){const r=V(t,"log",1);if(void 0===e)return Math.log(r);{const t=V(e,"log",2);return Math.log(r)/Math.log(t)}},log10:function(t){const e=V(t,"log10",1);return Math.log(e)/Math.log(10)},max:function(...t){const e=t.map(((t,e)=>V(t,"max",e+1)));return Math.max(...e)},min:function(...t){const e=t.map(((t,e)=>V(t,"min",e+1)));return Math.min(...e)},maxinteger:Jt,mininteger:Qt,modf:function(t){const e=V(t,"modf",1),r=Math.floor(e);return[r,e-r]},pi:te,pow:function(t,e){const r=V(t,"pow",1),n=V(e,"pow",2);return Math.pow(r,n)},rad:function(t){const e=V(t,"rad",1);return Math.PI/180*e},random:function(t,e){if(void 0===t&&void 0===e)return re();const r=V(t,"random",1),n=void 0!==e?r:1,o=void 0!==e?V(e,"random",2):r;if(n>o)throw new Error("bad argument #2 to 'random' (interval is empty)");return Math.floor(re()*(o-n+1)+n)},randomseed:function(t){ee=V(t,"randomseed",1)},sin:function(t){const e=V(t,"sin",1);return Math.sin(e)},sinh:function(t){const e=V(t,"sinh",1);return(oe(e)-oe(-e))/2},sqrt:function(t){const e=V(t,"sqrt",1);return Math.sqrt(e)},tan:function(t){const e=V(t,"tan",1);return Math.tan(e)},tanh:function(t){const e=V(t,"tanh",1);return(oe(e)-oe(-e))/(oe(e)+oe(-e))},tointeger:ie,type:function(t){const e=U(t);if(void 0!==e)return ie(e)===e?"integer":"float"},ult:function(t,e){const r=V(t,"ult",1),n=V(e,"ult",2),o=t=>t>>>0;return o(r)<o(n)}});function se(t){return $(t,"maxn",1).numValues.length-1}const ce=new j({getn:function(t){return $(t,"getn",1).getn()},concat:function(t,e="",r=1,n){const o=$(t,"concat",1),i=Z(e,"concat",2),a=V(r,"concat",3),s=void 0===n?se(o):V(n,"concat",4);return[].concat(o.numValues).splice(a,s-a+1).join(i)},insert:function(t,e,r){const n=$(t,"insert",1),o=void 0===r?n.numValues.length:V(e,"insert",2),i=void 0===r?e:r;n.numValues.splice(o,0,void 0),n.set(o,i)},maxn:se,move:function(t,e,r,n,o){const i=$(t,"move",1),a=V(e,"move",2),s=V(r,"move",3),c=V(n,"move",4),u=void 0===o?i:$(o,"move",5);if(s>=a){if(a<=0&&s>=Number.MAX_SAFE_INTEGER+a)throw new M("too many elements to move");const t=s-a+1;if(c>Number.MAX_SAFE_INTEGER-t+1)throw new M("destination wrap around");if(c>s||c<=a||u!==i)for(let e=0;e<t;e++){const t=i.get(a+e);u.set(c+e,t)}else for(let e=t-1;e>=0;e--){const t=i.get(a+e);u.set(c+e,t)}}return u},pack:function(...t){const e=new j(t);return e.rawset("n",t.length),e},remove:function(t,e){const r=$(t,"remove",1),n=r.getn(),o=void 0===e?n:V(e,"remove",2);if(o>n||o<0)return;const i=r.numValues,a=i.splice(o,1)[0];let s=o;for(;s<n&&void 0===i[s];)delete i[s],s+=1;return a},sort:function(t,e){const r=$(t,"sort",1);let n;if(e){const t=Y(e,"sort",2);n=(e,r)=>F(t(e,r)[0])?-1:1}else n=(t,e)=>t<e?-1:1;const o=r.numValues;o.shift(),o.sort(n).unshift(void 0)},unpack:function(t,e,r){const n=$(t,"unpack",1),o=void 0===e?1:V(e,"unpack",2),i=void 0===r?n.getn():V(r,"unpack",3);return n.numValues.slice(o,i+1)}}),ue=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],le=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=[31,28,31,30,31,30,31,31,30,31,30,31],he={"%":()=>"%",Y:(t,e)=>`${e?t.getUTCFullYear():t.getFullYear()}`,y:(t,e)=>he.Y(t,e).substr(-2),b:(t,e)=>he.B(t,e).substr(0,3),B:(t,e)=>le[e?t.getUTCMonth():t.getMonth()],m:(t,e)=>`0${(e?t.getUTCMonth():t.getMonth())+1}`.substr(-2),U:(t,e)=>pe(t,0,e),W:(t,e)=>pe(t,1,e),j:(t,e)=>{let r=e?t.getUTCDate():t.getDate();const n=e?t.getUTCMonth():t.getMonth(),o=e?t.getUTCFullYear():t.getFullYear();return r+=fe.slice(0,n).reduce(((t,e)=>t+e),0),n>1&&o%4==0&&(r+=1),`00${r}`.substr(-3)},d:(t,e)=>`0${e?t.getUTCDate():t.getDate()}`.substr(-2),a:(t,e)=>he.A(t,e).substr(0,3),A:(t,e)=>ue[e?t.getUTCDay():t.getDay()],w:(t,e)=>`${e?t.getUTCDay():t.getDay()}`,H:(t,e)=>`0${e?t.getUTCHours():t.getHours()}`.substr(-2),I:(t,e)=>`0${(e?t.getUTCHours():t.getHours())%12||12}`.substr(-2),M:(t,e)=>`0${e?t.getUTCMinutes():t.getMinutes()}`.substr(-2),S:(t,e)=>`0${e?t.getUTCSeconds():t.getSeconds()}`.substr(-2),c:(t,e)=>t.toLocaleString(void 0,e?{timeZone:"UTC"}:void 0),x:(t,e)=>`${he.m(t,e)}/${he.d(t,e)}/${he.y(t,e)}`,X:(t,e)=>`${he.H(t,e)}:${he.M(t,e)}:${he.S(t,e)}`,p:(t,e)=>(e?t.getUTCHours():t.getHours())<12?"AM":"PM",Z:(t,e)=>{if(e)return"UTC";const r=t.toString().match(/[A-Z][A-Z][A-Z]/);return r?r[0]:""}};function de(t){const e=t.getFullYear(),r=new Date(e,0);return t.getTimezoneOffset()!==r.getTimezoneOffset()}function pe(t,e,r){const n=parseInt(he.j(t,r),10),o=new Date(t.getFullYear(),0,1,12),i=(8-(r?o.getUTCDay():o.getDay())+e)%7;return`0${Math.floor((n-i)/7)+1}`.substr(-2)}function ye(t="%c",e){const r="!"===t.substr(0,1),n=r?t.substr(1):t,o=new Date;return e&&o.setTime(1e3*e),"*t"===n?new j({year:parseInt(he.Y(o,r),10),month:parseInt(he.m(o,r),10),day:parseInt(he.d(o,r),10),hour:parseInt(he.H(o,r),10),min:parseInt(he.M(o,r),10),sec:parseInt(he.S(o,r),10),wday:parseInt(he.w(o,r),10)+1,yday:parseInt(he.j(o,r),10),isdst:de(o)}):n.replace(/%[%YybBmUWjdaAwHIMScxXpZ]/g,(t=>he[t[1]](o,r)))}function ge(t="C"){if("C"===t)return"C"}function me(t){let e=Math.round(Date.now()/1e3);if(!t)return e;const r=t.rawget("year"),n=t.rawget("month"),o=t.rawget("day"),i=t.rawget("hour")||12,a=t.rawget("min"),s=t.rawget("sec");return r&&(e+=31557600*r),n&&(e+=2629800*n),o&&(e+=86400*o),i&&(e+=3600*i),a&&(e+=60*a),s&&(e+=s),e}function ve(t,e){return V(t,"difftime",1)-V(e,"difftime",2)}const be=(t,...e)=>{if(t instanceof Function)return K(t(...e));const r=t instanceof j&&t.getMetaMethod("__call");if(r)return K(r(t,...e));throw new M("attempt to call an uncallable type")},we=new j;we.metatable=Lt;const xe=(t,e)=>{if(t instanceof j)return t.get(e);if("string"==typeof t)return we.get(e);throw new M("no table or metatable found for given type")},_e=(t,e,r)=>{const n=new Function("__lua",e),o=new q(t.strValues).extend();r&&o.setVarargs([r]);const i=n({globalScope:o,...Xt,Table:j,call:be,get:xe});return void 0===i?[void 0]:i};function ke(t={}){const e={LUA_PATH:"./?.lua",stdin:"",stdout:console.log,...t},r=function(t,e){function r(t,r,n,i){let a,s="";if(t instanceof Function){let e=" ";for(;""!==e&&void 0!==e;)s+=e,e=t()[0]}else s=Z(t,"load",1);try{a=yt(s)}catch(t){return[void 0,t.message]}return()=>e(i||o,a)}function n(e,n,o){const i=void 0===e?t.stdin:Z(e,"loadfile",1);if(!t.fileExists)throw new M("loadfile requires the config.fileExists function");if(!t.fileExists(i))return[void 0,"file not found"];if(!t.loadFile)throw new M("loadfile requires the config.loadFile function");return r(t.loadFile(i),0,0,o)}const o=new j({_VERSION:"Lua 5.3",assert:Pt,dofile:function(t){const e=n(t);if(Array.isArray(e)&&void 0===e[0])throw new M(e[1]);return e()},collectgarbage:Tt,error:Ct,getmetatable:Mt,ipairs:jt,load:r,loadfile:n,next:It,pairs:Bt,pcall:zt,print:function(...e){const r=e.map((t=>D(t))).join("\t");t.stdout(r)},rawequal:Dt,rawget:Nt,rawlen:Rt,rawset:Ft,select:Ut,setmetatable:Gt,tonumber:Wt,tostring:D,type:z,xpcall:Vt});return o}(e,_e),{libPackage:n,_require:o}=((t,e)=>{const n=e.LUA_PATH,o=["/",";","?","!","-"].join("\n"),i=new j,a=new j,s=(t,r,n,o)=>{if(!e.fileExists)throw new M("package.searchpath requires the config.fileExists function");let i=Z(t,"searchpath",1);const a=Z(r,"searchpath",2),s=void 0===n?".":Z(n,"searchpath",3),c=void 0===o?"/":Z(o,"searchpath",4);i=i.replace(s,c);const u=a.split(";").map((t=>t.replace("?",i)));for(const t of u)if(e.fileExists(t))return t;return[void 0,`The following files don't exist: ${u.join(" ")}`]},c=new j([t=>{const e=a.rawget(t);return void 0===e?[void 0]:[e]},t=>{const n=s(t,u.rawget("path"));if(Array.isArray(n)&&void 0===n[0])return[n[1]];if(!e.loadFile)throw new M("package.searchers requires the config.loadFile function");return[(t,n)=>((t,e)=>_e(r,yt(t),e)[0])(e.loadFile(n),t),n]}]),u=new j({path:n,config:o,loaded:i,preload:a,searchers:c,searchpath:s});return{libPackage:u,_require:function(t){const e=Z(t,"require",1),r=i.rawget(e);if(r)return r;const n=c.numValues.filter((t=>!!t));for(const t of n){const r=t(e);if(void 0!==r[0]&&"string"!=typeof r[0]){const t=(0,r[0])(e,r[1]),n=void 0===t||t;return i.rawset(e,n),n}}throw new M(`Module '${e}' not found!`)}}})(0,e),i=n.get("loaded"),a=(t,e)=>{r.rawset(t,e),i.rawset(t,e)};a("_G",r),a("package",n),a("math",ae),a("table",ce),a("string",St),a("os",(t=>new j({date:ye,exit:function(e){if(!t.osExit)throw new M("os.exit requires the config.osExit function");let r=0;"boolean"==typeof e&&!1===e?r=1:"number"==typeof e&&(r=e),t.osExit(r)},setlocale:ge,time:me,difftime:ve}))(e)),r.rawset("require",o);const s=t=>{const e=yt(t);return{exec:()=>_e(r,e)[0]}};return{parse:s,parseFile:t=>{if(!e.fileExists)throw new M("parseFile requires the config.fileExists function");if(!e.loadFile)throw new M("parseFile requires the config.loadFile function");if(!e.fileExists(t))throw new M("file not found");return s(e.loadFile(t))},loadLib:a}}function Ee(t){return Ee="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},Ee(t)}function Ae(){Ae=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==Ee(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Se(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Le(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Oe(t,e,r){return e&&Le(t.prototype,e),r&&Le(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Pe(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Te=Oe((function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Pe(this,"setScope",(function(t){r.scope=t})),Pe(this,"getScope",(function(){return r.scope})),Pe(this,"createEnv",(function(){return r.env=r.pixoscript.createEnv({}),r.env})),Pe(this,"initLibrary",(function(){r.env||r.createEnv(),r.library=r.pixosLib.getLibrary(r.engine,r.scope),r.env.loadLib("pixos",r.library)})),Pe(this,"run",function(){var t,e=(t=Ae().mark((function t(e){return Ae().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.env||r.createEnv(),r.library||r.initLibrary(),t.abrupt("return",r.env.parse(e).exec());case 3:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Se(i,n,o,a,s,"next",t)}function s(t){Se(i,n,o,a,s,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}()),this.engine=e,this.pixoscript=i,this.pixosLib=new C(this.pixoscript),this.scope={},this.env=null,this.library=null}))},4399:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n\n varying vec2 vTextureCoord;\n varying vec3 vColor;\n\n void main(void) {\n // Simple particle color (could be extended with texture sampling)\n gl_FragColor = vec4(vColor, 1.0);\n }\n "}r.d(e,{Z:()=>n})},8062:(t,e,r)=>{"use strict";function n(){return"\n attribute vec3 aVertexPosition;\n attribute vec2 aTextureCoord;\n\n uniform mat4 uProjectionMatrix;\n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform vec3 uScale;\n uniform vec3 uParticleColor;\n\n varying vec2 vTextureCoord;\n varying vec3 vColor;\n\n void main(void) {\n // Apply model matrix for particle position and scale\n vec4 worldPosition = uModelMatrix * vec4(aVertexPosition * uScale, 1.0);\n\n // Output position\n gl_Position = uProjectionMatrix * uViewMatrix * worldPosition;\n\n // Pass texture coordinates and color to fragment shader\n vTextureCoord = aTextureCoord;\n vColor = uParticleColor;\n }\n "}r.d(e,{Z:()=>n})},1108:(t,e,r)=>{"use strict";function n(){return"\n precision highp float;\n \n uniform vec4 u_id;\n uniform float useSampler;\n uniform sampler2D uSampler;\n\n varying vec2 vTextureCoord;\n\n void main() {\n if(useSampler == 1.0) { // sampler\n vec4 texelColors = texture2D(uSampler, vTextureCoord);\n gl_FragColor= vec4(vec3(u_id),texelColors.a);\n } else {\n gl_FragColor = vec4(vec3(u_id),1.0);\n }\n }\n "}r.d(e,{Z:()=>n})},5911:(t,e,r)=>{"use strict";function n(t){var e=this.engine.gl,r=this;return t.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),t.aVertexPosition>=0&&e.enableVertexAttribArray(t.aVertexPosition),t.aTextureCoord=e.getAttribLocation(t,"aTextureCoord"),t.aTextureCoord>=0&&e.enableVertexAttribArray(t.aTextureCoord),t.aVertexNormal=e.getAttribLocation(t,"aVertexNormal"),t.aVertexNormal>=0&&e.enableVertexAttribArray(t.aVertexNormal),t.pMatrixUniform=e.getUniformLocation(t,"uProjectionMatrix"),t.mMatrixUniform=e.getUniformLocation(t,"uModelMatrix"),t.vMatrixUniform=e.getUniformLocation(t,"uViewMatrix"),t.samplerUniform=e.getUniformLocation(t,"uSampler"),t.useSampler=e.getUniformLocation(t,"useSampler"),t.scale=e.getUniformLocation(t,"u_scale"),t.id=e.getUniformLocation(t,"u_id"),t.setMatrixUniforms=function(n){var o=n.scale,i=void 0===o?null:o,a=n.id,s=void 0===a?null:a,c=n.sampler,u=void 0===c?1:c;e.useProgram(t),e.uniformMatrix4fv(t.pMatrixUniform,!1,r.uProjMat),e.uniformMatrix4fv(t.mMatrixUniform,!1,r.uModelMat),e.uniformMatrix4fv(t.vMatrixUniform,!1,r.camera.uViewMat),e.uniform3fv(t.scale,i?i.toArray():r.scale.toArray()),e.uniform4fv(t.id,s||[1,0,0,0]),e.uniform1f(t.useSampler,u),e.uniform1i(t.samplerUniform,0)},t}r.d(e,{Z:()=>n})},1704:(t,e,r)=>{"use strict";function n(){return"\n attribute vec3 aVertexPosition;\n attribute vec2 aTextureCoord;\n \n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjectionMatrix;\n \n varying vec4 vWorldVertex;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n uniform vec3 u_scale;\n \n void main() {\n // Multiply the position by the matrix.\n vec3 scaledPosition = aVertexPosition * u_scale;\n vTextureCoord = aTextureCoord;\n \n vWorldVertex = uModelMatrix * vec4(aVertexPosition, 1.0);\n vPosition = uModelMatrix * vec4(scaledPosition, 1.0);\n\n gl_Position = uProjectionMatrix * uViewMatrix * vPosition;\n }\n "}r.d(e,{Z:()=>n})},7745:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n varying vec4 vPosition;\n\n // Simple hash for star placement\n float hash(vec3 p) {\n return fract(sin(dot(p, vec3(12.9898,78.233,45.164))) * 43758.5453);\n }\n\n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n\n // Starfield effect\n float starDensity = 0.0007; // Lower = more stars\n float brightness = 0.0;\n float star = step(1.0 - starDensity, hash(dir * 100.0));\n if (star > 0.0) {\n brightness = 0.8 + 0.2 * hash(dir * 200.0);\n }\n\n // Nebula color (subtle blue/purple)\n float nebula = pow(abs(dir.y), 2.0) * 0.3;\n vec3 nebulaColor = mix(vec3(0.05,0.05,0.15), vec3(0.2,0.1,0.3), nebula);\n\n // Combine star and nebula\n vec3 color = nebulaColor + brightness * vec3(1.0, 1.0, 1.0);\n gl_FragColor = vec4(color, 1.0);\n }\n"}r.r(e),r.d(e,{default:()=>n})},5564:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},5401:(t,e,r)=>{"use strict";function n(){return'\n precision highp float;\n uniform mat4 uViewDirectionProjectionInverse;\n varying vec4 vPosition;\n uniform float uTime;\n uniform vec2 uResolution;\n\n const float PI = 3.141592653589793;\n\n // simple float hash from vec2\n float hash12(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n }\n\n // value noise (cheap)\n float noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n float a = hash12(i + vec2(0.0, 0.0));\n float b = hash12(i + vec2(1.0, 0.0));\n float c = hash12(i + vec2(0.0, 1.0));\n float d = hash12(i + vec2(1.0, 1.0));\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;\n }\n\n // smooth pulse shape\n float pulse(float x, float wid) {\n return smoothstep(0.0, wid, x) * (1.0 - smoothstep(1.0 - wid, 1.0, x));\n }\n\n void main() {\n // Reconstruct view direction from interpolated clip-space position\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n\n // convert direction -> equirectangular-like UV so "columns" wrap horizontally\n float u = atan(dir.z, dir.x) / (2.0 * PI) + 0.5;\n float v = asin(clamp(dir.y, -1.0, 1.0)) / PI + 0.5;\n vec2 uv = vec2(u, v);\n\n // Column layout\n float colsBase = mix(120.0, 240.0, clamp(uResolution.x / 1600.0, 0.0, 1.0));\n float horizonBias = 1.0 - abs(v - 0.5) * 2.0;\n float cols = max(32.0, colsBase * (0.6 + 0.8 * horizonBias));\n\n float colIndexF = floor(uv.x * cols);\n float colX = (colIndexF + 0.5) / cols;\n\n // per-column seed & speed variety\n float seed = hash12(vec2(colIndexF, floor(uTime * 10.0)));\n float speed = 0.8 + hash12(vec2(colIndexF, 9.0)) * 2.2;\n\n // vertical tiling for character cells\n float charSize = mix(0.018, 0.035, clamp(uResolution.y/900.0, 0.0, 1.0));\n float rows = 1.0 / charSize;\n\n float yScaled = uv.y * rows;\n float yCell = floor(yScaled);\n float yFrac = fract(yScaled);\n\n // falling offset based on time and column seed\n float fall = fract((uTime * speed * 0.25) + seed * 10.0);\n\n float dropPos = fract(seed * 7.3 + uTime * 0.25 * speed);\n float drop2 = fract(seed * 3.1 + uTime * 0.57 * speed * 0.7);\n\n float d1 = abs(yCell / rows - dropPos);\n float d2 = abs(yCell / rows - drop2);\n\n float head = exp(-pow((yFrac + fract(yCell*0.9183) * 0.35), 2.0) * 40.0);\n float tail = exp(-d1 * 8.0) + 0.5 * exp(-d2 * 12.0);\n\n float glyphSeed = hash12(vec2(colIndexF, yCell));\n float glyphPulse = pulse(fract(yScaled - (seed*3.0 + uTime*0.9*speed)), 0.12);\n float glyph = smoothstep(0.35, 0.55, glyphSeed + 0.2 * noise2(vec2(colIndexF * 0.13, yCell * 0.07 + uTime * 0.1)));\n\n float brightness = clamp( 1.6 * head + 0.9 * tail * glyph + 0.35 * glyph * glyphPulse, 0.0, 1.6);\n\n float colWidth = 1.0 / cols * 0.9;\n float colMask = smoothstep(0.0, 1.0, 1.0 - abs(uv.x - colX) / (colWidth * 0.6));\n\n float jitter = noise2(vec2(colIndexF * 0.7, yCell * 0.9 + uTime * 0.2)) * 0.5;\n float charV = smoothstep(0.0, 1.0, 1.0 - abs(yFrac - (0.5 + jitter*0.2)) * 2.0);\n\n float intensity = brightness * colMask * charV;\n\n vec3 baseGreen = vec3(0.1, 0.95, 0.15);\n vec3 headColor = mix(baseGreen * 0.6, vec3(1.0, 1.0, 0.9), clamp(head * 2.0, 0.0, 1.0));\n vec3 tailColor = baseGreen * (0.6 + 0.8 * glyph);\n\n float headFactor = clamp(head * 2.0, 0.0, 1.0);\n vec3 col = mix(tailColor, headColor, headFactor) * intensity;\n\n float bgNoise = 0.04 * (noise2(uv * 400.0 + uTime * 0.03));\n float verticalVignette = pow(1.0 - abs(v - 0.5) * 1.6, 1.8);\n vec3 bg = vec3(0.01, 0.03, 0.01) * verticalVignette + bgNoise;\n\n float stars = smoothstep(0.9996, 1.0, noise2(uv * 2000.0 + uTime * 0.1));\n vec3 starCol = vec3(0.6, 1.0, 0.6) * stars * 1.2;\n\n vec3 final = col + bg + starCol;\n\n float glow = pow(intensity, 1.6) * 0.9;\n final += vec3(glow * 0.14, glow * 0.22, glow * 0.06);\n\n final = 1.0 - exp(-final * 1.6);\n final = pow(final, vec3(0.9));\n\n gl_FragColor = vec4(final, 1.0);\n }\n'}r.r(e),r.d(e,{default:()=>n})},488:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},2628:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n \n varying vec4 vPosition;\n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n gl_FragColor = textureCube(uSkybox, normalize(t.xyz / t.w));\n }\n"}r.r(e),r.d(e,{default:()=>n})},939:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},471:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n uniform samplerCube uSkybox;\n varying vec4 vPosition; // Interpolated position of the vertex in world space.\n uniform mat4 uViewDirectionProjectionInverse; // Matrix to transform view direction into projection space for texture lookup.\n uniform float uTime; // Time uniform, if you want to animate your noise pattern\n\n // Simplex noise function (you can use a different type of noise if you prefer)\n float simplexNoise(vec3 p) {\n return fract(sin(dot(p, vec3(12.9898, 78.233, 45.123))) * 43758.5453);\n }\n\n void main() {\n // Transform the view direction to projection space for texture lookup\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n \n // Generate a simple abstract pattern based on noise and time\n float n = simplexNoise(vec3(vPosition.x, vPosition.y, uTime)); // Using the current time for animation\n \n // Map the noise value to a color: white for high values, black for low values\n vec3 skyColor = mix(vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), n);\n \n // Apply the calculated color to the fragment\n gl_FragColor = vec4(skyColor, 1.0);\n }\n\n"}r.r(e),r.d(e,{default:()=>n})},202:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},8143:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n \n varying vec4 vPosition;\n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n gl_FragColor = textureCube(uSkybox, normalize(t.xyz / t.w));\n }\n"}r.r(e),r.d(e,{default:()=>n})},6568:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},8135:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n \n varying vec4 vPosition;\n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n gl_FragColor = textureCube(uSkybox, normalize(t.xyz / t.w));\n }\n"}r.r(e),r.d(e,{default:()=>n})},8299:(t,e,r)=>{"use strict";function n(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}r.r(e),r.d(e,{default:()=>n})},5311:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n\n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUV, center);\n\n // Radius grows [0..1] for OUT, shrinks for IN\n float radius = (uDirection > 0.5) ? (1.0 - uProgress) : uProgress;\n\n // Blur width relative to screen; tweak for softer/harder edge\n float feather = 0.20; // 20% of radius as feather\n float edge0 = radius - feather * 0.5;\n float edge1 = radius + feather * 0.5;\n\n float mask = smoothstep(edge0, edge1, dist);\n\n // Black overlay with soft edge\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "}r.d(e,{Z:()=>n})},1564:(t,e,r)=>{"use strict";function n(){return"\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n "}r.d(e,{Z:()=>n})},4522:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n float mask;\n // When uDirection == 1.0 (transition in), the black area shrinks\n // from right to left. Otherwise, it grows from left to right.\n if (uDirection > 0.5) {\n mask = step(1.0 - uProgress, vUV.x);\n } else {\n mask = step(vUV.x, uProgress);\n }\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "}r.d(e,{Z:()=>n})},6404:(t,e,r)=>{"use strict";function n(){return"\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n "}r.d(e,{Z:()=>n})},7319:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n\n void main() {\n // Determine wipe center position depending on direction\n float pos = (uDirection > 0.5) ? (1.0 - uProgress) : uProgress;\n\n // Feather width in UV space\n float feather = 0.12;\n\n // Distance from the moving edge (vertical line at x=pos)\n float d = vUV.x - pos;\n\n // Soft mask around the edge using smoothstep\n float mask = smoothstep(-feather, feather, d);\n\n // Black overlay with soft edge\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "}r.d(e,{Z:()=>n})},9357:(t,e,r)=>{"use strict";function n(){return"\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n "}r.d(e,{Z:()=>n})},2913:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n float alpha = uDirection > 0.5 ? (1.0 - uProgress) : uProgress;\n gl_FragColor = vec4(0.0, 0.0, 0.0, alpha);\n }\n "}r.d(e,{Z:()=>n})},8900:(t,e,r)=>{"use strict";function n(){return"\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n "}r.d(e,{Z:()=>n})},8946:(t,e,r)=>{"use strict";function n(){return"\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUV, center);\n float mask;\n if (uDirection > 0.5) {\n // transition in: shrink the black disc\n mask = step(uProgress, dist);\n } else {\n // transition out: grow the black disc\n mask = step(dist, uProgress);\n }\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "}r.d(e,{Z:()=>n})},9188:(t,e,r)=>{"use strict";function n(){return"\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n "}r.d(e,{Z:()=>n})},4395:(t,e,r)=>{"use strict";r.d(e,{Ee:()=>u,Nm:()=>s});var n=r(9010);function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t){return i="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},i(t)}function a(t){return t*Math.PI/180}var s={None:0,Right:1,Up:2,Left:4,Down:8,All:15,fromOffset:function(t){return t[0]>0?s.Right:t[0]<0?s.Left:t[1]>0?s.Down:t[1]<0?s.Up:0},toOffset:function(t){switch(t){case s.Right:return[1,0];case s.Up:return[0,-1];case s.Left:return[-1,0];case s.Down:return[0,1]}return[0,0]},reverse:function(t){switch(t){case s.Right:return s.Left;case s.Up:return s.Down;case s.Left:return s.Right;case s.Down:return s.Up}return s.None},rotate:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];switch(t){case s.Right:return e?s.Up:s.Down;case s.Up:return e?s.Left:s.Right;case s.Left:return e?s.Down:s.Up;case s.Down:return e?s.Right:s.Left}return s.None},adjustCameraDirection:function(t){switch(t.z%8){case 0:return"N";case 1:case-7:return"NW";case 2:case-6:return"W";case 3:case-5:return"SW";case 4:case-4:return"S";case 5:case-3:return"SE";case 6:case-2:return"E";case 7:case-1:return"NE"}},getCameraRelativeDirection:function(t,e){var r={N:{forward:s.Up,backward:s.Down,left:s.Left,right:s.Right},NE:{forward:s.Down,backward:s.Up,left:s.Left,right:s.Right},E:{forward:s.Right,backward:s.Left,left:s.Up,right:s.Down},SE:{forward:s.Down,backward:s.Up,left:s.Right,right:s.Left},S:{forward:s.Down,backward:s.Up,left:s.Right,right:s.Left},SW:{forward:s.Right,backward:s.Left,left:s.Down,right:s.Up},W:{forward:s.Left,backward:s.Right,left:s.Down,right:s.Up},NW:{forward:s.Right,backward:s.Left,left:s.Up,right:s.Down}};return(r[e]||r.N)[t]||s.None},spriteSequence:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"N";switch(e){case"N":switch(t){case s.Up:return"N";case s.Right:return"E";case s.Down:return"S";case s.Left:return"W"}case"E":switch(t){case s.Up:return"W";case s.Right:return"N";case s.Down:return"E";case s.Left:return"S"}case"S":switch(t){case s.Up:return"S";case s.Right:return"W";case s.Down:return"N";case s.Left:return"E"}case"W":switch(t){case s.Up:return"E";case s.Right:return"S";case s.Down:return"W";case s.Left:return"N"}case"NE":switch(t){case s.Up:return"NW";case s.Right:return"SE";case s.Down:return"NE";case s.Left:return"SW"}case"SE":switch(t){case s.Up:return"SW";case s.Right:return"NW";case s.Down:return"SE";case s.Left:return"NE"}case"SW":switch(t){case s.Up:return"NE";case s.Right:return"SW";case s.Down:return"NW";case s.Left:return"SE"}case"NW":switch(t){case s.Up:return"SE";case s.Right:return"NE";case s.Down:return"SW";case s.Left:return"NW"}}return"S"},drawOffset:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"N";switch(e){case"NE":return t.cross(new n.OW(Math.sin(a(315)),2*Math.cos(a(315)),0));case"NW":return t.cross(new n.OW(-2*Math.sin(a(315)),-Math.cos(a(315)),0));case"SE":return t.cross(new n.OW(Math.sin(a(225)),Math.cos(a(225)),0));case"SW":return t.cross(new n.OW(Math.sin(a(135)),Math.cos(a(135)),0));case"E":return t.cross(new n.OW(Math.sin(a(270)),Math.cos(a(270)),0));case"W":return t.cross(new n.OW(Math.sin(a(90)),Math.cos(a(90)),0));case"S":return t.cross(new n.OW(Math.sin(a(180)),Math.cos(a(180)),0));case"N":return t.cross(new n.OW(Math.sin(a(0)),Math.cos(a(0)),0));default:return t}},objectSequence:function(t){switch(t){case s.Right:return[0,90,0];case s.Up:return[0,0,0];case s.Left:return[0,-90,0];case s.Down:return[0,180,0]}return[0,0,0]}},c=function(t){return t&&"object"===i(t)&&!Array.isArray(t)},u=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];if(!n.length)return e;var a=n.shift();if(c(e)&&c(a))for(var s in a){var u;c(a[s])?(e[s]||Object.assign(e,o({},s,{})),t(e[s],a[s])):Object.assign(e,o({},s,a[s]&&Array.isArray(a[s])?[].concat(null!==(u=e[s])&&void 0!==u?u:[],a[s]):a[s]))}return t.apply(void 0,[e].concat(n))}},1183:(t,e,r)=>{"use strict";function n(t){return n="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},n(t)}function o(){o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,a,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,a)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(i,a,s,c){var u=f(t[i],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){o("next",t,s,c)}),(function(t){o("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return o("throw",t,s,c)}))}c(u.arg)}var i;this._invoke=function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,a,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function i(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}r.d(e,{a:()=>d});var s=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.sprite=r,this.callback=n,this.time=(new Date).getTime(),this.id=r.id+"-"+e+"-"+this.time}var e,r,n,s;return e=t,r=[{key:"configure",value:function(t,e,r,n,o){this.sprite=e,this.id=r,this.type=t,this.startTime=n,this.creationArgs=o}},{key:"onLoad",value:(n=o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.init.apply(this,e);case 2:this.loaded=!0;case 3:case"end":return t.stop()}}),t,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,o){var a=n.apply(t,e);function s(t){i(a,r,o,s,c,"next",t)}function c(t){i(a,r,o,s,c,"throw",t)}s(void 0)}))},function(t){return s.apply(this,arguments)})},{key:"serialize",value:function(){return{id:this.id,time:this.startTime,zone:this.sprite.zone.id,sprite:this.sprite.id,type:this.type,args:this.creationArgs}}},{key:"onComplete",value:function(){return this.callback?this.callback():null}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();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 u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};s(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==c(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,s(b,"constructor",y),s(y,"constructor",p),p.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,a,"Generator"),s(b,o,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function l(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function f(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){l(i,n,o,a,s,"next",t)}function s(t){l(i,n,o,a,s,"throw",t)}a(void 0)}))}}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var d=function(){function t(e,r,n,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.type=r,this.args=n,this.sprite=o,this.callback=i,this.instances={},this.definitions=[],this.assets={};var a=(new Date).getTime(),s=o.id+"-"+r+"-"+a;return this.load(r,function(){var t=f(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.onLoad(n);case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),(function(t){t.configure(r,o,s,a,n)}))}var e,n,o;return e=t,n=[{key:"load",value:(o=f(u().mark((function t(e){var n,o,i,a=arguments;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("Loading Action: "+e),n=a[1],o=a[2],this.instances[e]||(this.instances[e]=[]),console.log({afterLoad:n,runConfigure:o}),i=new s(this.type,this.sprite,this.callback),Object.assign(i,r(4668)("./"+e+".js").default),i.templateLoaded=!0,console.log("Notifying in Action: "+e),t.next=11,Promise.all(this.instances[e].map(function(){var t=f(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log({instance:e}),!e.afterLoad){t.next=4;break}return t.next=4,e.afterLoad(e.instance);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 11:return o&&o(i),n&&(i.templateLoaded?n(i):this.instances[e].push({instance:i,afterLoad:n})),console.log("Ending load Action: "+e),t.abrupt("return",i);case 15:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})}],n&&h(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}()},7122:(t,e,r)=>{"use strict";r.d(e,{m:()=>h});const n=new class{loopOnThresolds(t,e,r){let n=.95;"function"!=typeof e&&"boolean"!=typeof e||(r=e||r,e=.3),void 0===e&&(e=.3),"function"!=typeof r&&(r=this.noop);const o=e,i={};do{let e=!1;if(n-=.05,t(i,n,(t=>{e=t})),e)break}while(n>o);return r(i)}generateObjectModel(t,e){return this.loopOnThresolds(((e,r)=>{e[r.toString()]=JSON.parse(JSON.stringify(t))}),(t=>e?e(JSON.parse(JSON.stringify(t))):t))}noop(){}},o=new class{getLowPassSource(t,e){const{numberOfChannels:r,length:n,sampleRate:o}=t,i=new e(r,n,o),a=i.createBufferSource();a.buffer=t;const s=i.createBiquadFilter();return s.type="lowpass",a.connect(s),s.connect(i.destination),a}findPeaksAtThresold(t,e,r){let n=[];const{length:o}=t;for(let i=r;i<o;i+=1)t[i]>e&&(n.push(i),i+=1e4);return 0===n.length&&(n=void 0),{peaks:n,thresold:e}}computeBPM(t,e,r){let o=!1;n.loopOnThresolds(((n,i,a)=>o?a(!0):t[i].length>15?(o=!0,r(null,[this.identifyIntervals,this.groupByTempo(e),this.getTopCandidates].reduce(((t,e)=>e(t)),t[i]),i)):void 0),(()=>(o||r(new Error("Could not find enough samples for a reliable detection.")),!1)))}getTopCandidates(t){return t.sort(((t,e)=>e.count-t.count)).splice(0,5)}identifyIntervals(t){const e=[];for(const[r,n]of t.entries())for(let o=0;o<10;o+=1){const i=t[r+o]-n;e.some((t=>t.interval===i&&(t.count+=1,t.count)))||e.push({interval:i,count:1})}return e}groupByTempo(t){return e=>{const r=[];for(const n of e)if(0!==n.interval){n.interval=Math.abs(n.interval);let e=60/(n.interval/t);for(;e<90;)e*=2;for(;e>180;)e/=2;e=Math.round(e),r.some((t=>t.tempo===e&&(t.count+=n.count,t.count)))||r.push({tempo:e,count:n.count})}return r}}};class i{constructor(t={}){this.options={debug:!1,scriptNode:{bufferSize:4096},continuousAnalysis:!1,stabilizedBpmCount:2e3,computeBPMDelay:1e4,stabilizationTime:2e4,pushTime:2e3,pushCallback:(t,e)=>{if(t)throw new Error(t)},onBpmStabilized:t=>{this.clearValidPeaks(t)},OfflineAudioContext:"object"==typeof window&&(window.OfflineAudioContext||window.webkitOfflineAudioContext)},this.logger=(...t)=>{this.options.debug&&console.log(...t)},Object.assign(this.options,t),this.minValidThresold=.3,this.cumulatedPushTime=0,this.timeoutPushTime=null,this.timeoutStabilization=null,this.validPeaks=n.generateObjectModel([]),this.nextIndexPeaks=n.generateObjectModel(0),this.chunkCoeff=1}reset(){this.minValidThresold=.3,this.cumulatedPushTime=0,this.timeoutPushTime=null,this.timeoutStabilization=null,this.validPeaks=n.generateObjectModel([]),this.nextIndexPeaks=n.generateObjectModel(0),this.chunkCoeff=1}clearValidPeaks(t){this.logger(`[clearValidPeaks] function: under ${t}`),this.minValidThresold=t.toFixed(2),n.loopOnThresolds(((e,r)=>{r<t&&(delete this.validPeaks[r],delete this.nextIndexPeaks[r])}))}analyze(t){const e=this.options.scriptNode.bufferSize*this.chunkCoeff,r=e-this.options.scriptNode.bufferSize,i=o.getLowPassSource(t.inputBuffer,this.options.OfflineAudioContext);i.start(0),n.loopOnThresolds(((t,n)=>{if(this.nextIndexPeaks[n]>=e)return;const a=this.nextIndexPeaks[n]%this.options.scriptNode.bufferSize,{peaks:s,thresold:c}=o.findPeaksAtThresold(i.buffer.getChannelData(0),n,a);if(void 0!==s)for(const t of Object.keys(s)){const e=s[t];void 0!==e&&(this.nextIndexPeaks[c]=r+e+1e4,this.validPeaks[c].push(r+e))}}),this.minValidThresold,(()=>{this.chunkCoeff++,null===this.timeoutPushTime&&(this.timeoutPushTime=setTimeout((()=>{this.cumulatedPushTime+=this.options.pushTime,this.timeoutPushTime=null,o.computeBPM(this.validPeaks,t.inputBuffer.sampleRate,((t,e,r)=>{this.options.pushCallback(t,e,r),!t&&e&&e[0].count>=this.options.stabilizedBpmCount&&(this.logger("[freezePushBack]"),this.timeoutPushTime="never",this.minValidThresold=1),this.cumulatedPushTime>=this.options.computeBPMDelay&&this.minValidThresold<r&&(this.logger("[onBpmStabilized] function: Fired !"),this.options.onBpmStabilized(r),this.options.continuousAnalysis&&(clearTimeout(this.timeoutStabilization),this.timeoutStabilization=setTimeout((()=>{this.logger("[timeoutStabilization] setTimeout: Fired !"),this.options.computeBPMDelay=0,this.reset()}),this.options.stabilizationTime)))}))}),this.options.pushTime))}))}}function a(t){return a="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},a(t)}function s(){s=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,s,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==a(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function c(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}"undefined"!=typeof window&&(window.RealTimeBPMAnalyzer=i);var h=function(){function t(e){u(this,t),this.engine=e,this.definitions=[],this.instances={}}var e,r;return f(t,[{key:"load",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instances[t])return this.instances[t];var r=new d(t,e);this.instances[t]=r;var n=this;return e&&Object.keys(n.instances).filter((function(e){return t!==e})).forEach((function(t){n.instances[t]&&n.instances[t].pauseAudio()})),r.loaded=!0,r}},{key:"loadFromZip",value:(e=s().mark((function t(e,r){var n,o,i,a,c,u=arguments;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],!this.instances[r]){t.next=3;break}return t.abrupt("return",this.instances[r]);case 3:return console.log({msg:"let the beat roll in!"}),t.next=6,e.file("audio/".concat(r)).async("arrayBuffer").then((function(t){var e=new Uint8Array(t);return new Blob([e.buffer])}));case 6:return o=t.sent,i=URL.createObjectURL(o),console.log({msg:"loading audio track...",url:i}),a=new d(i,n),this.instances[r]=a,c=this,n&&Object.keys(c.instances).filter((function(t){return r!==t})).forEach((function(t){c.instances[t]&&c.instances[t].pauseAudio()})),a.loaded=!0,t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)})),r=function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(t){c(i,n,o,a,s,"next",t)}function s(t){c(i,n,o,a,s,"throw",t)}a(void 0)}))},function(t,e){return r.apply(this,arguments)})}]),t}(),d=function(){function t(e){var r=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];u(this,t),this.src=e,this.playing=!1,this.audio=new Audio(e),this.audioContext=new AudioContext,this.bpm=0,this.analyser=this.audioContext.createAnalyser(),this.audioSource=this.audioContext.createMediaElementSource(this.audio),this.audioSource.connect(this.analyser),this.audioNode=this.audioContext.createScriptProcessor(4096,1,1),this.audioNode.connect(this.audioContext.destination),this.audioSource.connect(this.audioNode),this.audioSource.connect(this.audioContext.destination);var o=new i({scriptNode:{bufferSize:4096},pushTime:2e3,pushCallback:function(t,e){r.bpm=e}});this.audioNode.onaudioprocess=function(t){o.analyze(t)},n&&this.audio.addEventListener("ended",(function(){this.currentTime=0,this.play()}),!1),this.audio.load()}return f(t,[{key:"isPlaying",value:function(){return this.playing}},{key:"playAudio",value:function(){var t=this.audio.play();this.playing=!0,void 0!==t&&t.then((function(t){})).catch((function(t){console.info(t)}))}},{key:"pauseAudio",value:function(){var t=this.audio.pause();this.playing=!1,void 0!==t&&t.then((function(t){})).catch((function(t){console.info(t)}))}}]),t}()},679:(t,e,r)=>{"use strict";r.d(e,{aW:()=>Ut.a,q1:()=>Kt,Gq:()=>Ft,jf:()=>wt,e5:()=>w});var n=r(7974),o=r(5849);function i(t){return i="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},i(t)}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function d(){}function p(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,c){var u=f(t[o],t,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(b,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function s(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function u(t,e){if(e&&("object"===i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function h(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var d=function(t){!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&&c(t,e)}(d,t);var e,r,o,i=(r=d,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=f(r);if(o){var n=f(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function d(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,d),h(l(e=i.call(this)),"onJsonLoaded",(function(t){Object.keys(t).map((function(r){e[r]=t[r]})),e.definitionLoaded=!0,e.onDefinitionLoadActions.run(),e.texture=e.engine.resourceManager.loadTexture(e.src),e.texture.runWhenLoaded(e.onTextureLoaded),e.bgColor&&e.engine.gl.clearColor(e.bgColor[0]/255,e.bgColor[1]/255,e.bgColor[2]/255,1)})),h(l(e),"onJsonLoadedFromZip",function(){var t,r=(t=a().mark((function t(r,n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Object.keys(r).map((function(t){e[t]=r[t]})),e.definitionLoaded=!0,e.onDefinitionLoadActions.run(),t.next=5,e.engine.resourceManager.loadTextureFromZip(e.src,n);case 5:e.texture=t.sent,e.texture.runWhenLoaded(e.onTextureLoaded),e.bgColor&&e.engine.gl.clearColor(e.bgColor[0]/255,e.bgColor[1]/255,e.bgColor[2]/255,1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){s(i,n,o,a,c,"next",t)}function c(t){s(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t,e){return r.apply(this,arguments)}}()),h(l(e),"onTextureLoaded",(function(){e.loaded=!0,e.onLoadActions.run()})),h(l(e),"runWhenDefinitionLoaded",(function(t){e.definitionLoaded?t():e.onDefinitionLoadActions.add(t)})),h(l(e),"getTileVertices",(function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=r[0],i=r[1],a=null!==n?n:r[2];if(null!==n&&console.log("[Tileset.getTileVertices] tile=".concat(t,", offset=[").concat(r,"], heightOverride=").concat(n,", zOffset=").concat(a)),!e.geometry[t]||!e.geometry[t].vertices){if(console.warn("[Tileset.getTileVertices] Missing geometry for tile id ".concat(t,". Attempting fallback.")),!e.geometry[0]||!e.geometry[0].vertices){var s=[[[0,0,0],[1,0,0],[1,0,1]],[[0,0,0],[1,0,1],[0,0,1]]];return s.map((function(t){return t.map((function(t){return[t[0]+r[0],t[1]+i,t[2]+a]}))})).flat(3)}t=0}return e.geometry[t].vertices.map((function(t){return t.map((function(t){return[t[0]+o,t[1]+i,t[2]+a]}))})).flat(3)})),h(l(e),"getTileTexCoords",(function(t,r){var n=e.textures[r],o=[e.tileSize/e.sheetSize[0],e.tileSize/e.sheetSize[1]];return e.geometry[t].surfaces.map((function(t){return t.map((function(t){return[(t[0]+n[0])*o[0],(t[1]+n[1])*o[1]]}))})).flat(3)})),h(l(e),"getWalkability",(function(t){return e.geometry[t].type})),h(l(e),"getTileWalkPoly",(function(t){return e.geometry[t].walkPoly})),h(l(e),"getTileMetadata",(function(t){return e.tileMetadata[t]||{}})),e.engine=t,e.src=null,e.sheetSize=[0,0],e.tileSize=0,e.tiles={},e.tileMetadata={},e.loaded=!1,e.onLoadActions=new n.Z,e.onDefinitionLoadActions=new n.Z,e}return e=d,Object.defineProperty(e,"prototype",{writable:!1}),e}(o.Z),p=r(4395);function y(t){return y="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},y(t)}function g(){g=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(p=v);var b=d.prototype=f.prototype=Object.create(p);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==y(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=d,s(b,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,a,"Generator"),s(b,o,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function m(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function v(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){m(i,n,o,a,s,"next",t)}function s(t){m(i,n,o,a,s,"throw",t)}a(void 0)}))}}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var w=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.tilesets={}}var e,r,n,o;return e=t,r=[{key:"loadFromZip",value:(o=v(g().mark((function t(e,r,n){var o,i,a,s;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("loading tileset from zip: "+r+" for "+n),!(o=this.tilesets[r])){t.next=4;break}return t.abrupt("return",o);case 4:return i=new d(this.engine),this.tilesets[r]=i,i.name=r,t.t0=JSON,t.next=10,e.file("tilesets/".concat(r,"/tileset.json")).async("string");case 10:return t.t1=t.sent,a=t.t0.parse.call(t.t0,t.t1),t.next=14,this.loadTilesetData(a,e);case 14:return s=t.sent,t.next=17,i.onJsonLoadedFromZip(s,e);case 17:return t.abrupt("return",i);case 18:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return o.apply(this,arguments)})},{key:"loadTilesetData",value:(n=v(g().mark((function t(e,r){return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.extends){t.next=4;break}return t.next=3,Promise.all(e.extends.map(function(){var t=v(g().mark((function t(n){var o;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=JSON,t.next=3,r.file("tilesets/"+n+"/tileset.json").async("string");case 3:t.t1=t.sent,o=t.t0.parse.call(t.t0,t.t1),e=(0,p.Ee)(e,o);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:e.extends=null;case 4:return console.log({tilesetJson:e}),t.abrupt("return",{name:e.name,src:e.src,sheetSize:e.sheetSize,sheetOffsetX:e.sheetOffsetX,sheetOffsetY:e.sheetOffsetY,tileSize:e.tileSize,bgColor:e.bgColor,textures:e.textures,geometry:e.geometry,tiles:e.tiles});case 6:case"end":return t.stop()}}),t)}))),function(t,e){return n.apply(this,arguments)})}],r&&b(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),x=r(9010),_=r(2737),k=r(6083);function E(t){return E="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},E(t)}function A(t,e,r){return A=I()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&C(o,r.prototype),o},A.apply(null,arguments)}function S(t){return function(t){if(Array.isArray(t))return L(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 L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(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 L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function O(){O=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(A([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==E(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function P(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function T(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){P(i,n,o,a,s,"next",t)}function s(t){P(i,n,o,a,s,"throw",t)}a(void 0)}))}}function C(t,e){return C=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},C(t,e)}function M(t,e){if(e&&("object"===E(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return j(t)}function j(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function I(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function z(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var D=function(t){!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&&C(t,e)}(i,t);var e,r,n,o=(e=i,r=I(),function(){var t,n=B(e);if(r){var o=B(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return M(this,t)});function i(t,e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),z(j(n=o.call(this,t)),"loadJson",T(O().mark((function t(){var e;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.json.extends){t.next=4;break}return t.next=3,Promise.all(n.json.extends.map(function(){var t=T(O().mark((function t(e){var r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=JSON,t.next=3,n.zip.file("sprites/"+e+".json").async("string");case 3:t.t1=t.sent,r=t.t0.parse.call(t.t0,t.t1),Object.assign(n.json,r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:n.json.extends=null;case 4:n.update(n.json),n.src=n.json.src,n.portraitSrc=n.json.portraitSrc,n.sheetSize=n.json.sheetSize,n.tileSize=n.json.tileSize,n.state=null!==(e=n.json.state)&&void 0!==e?e:"intro",n.frames=n.json.frames,n.hotspotOffset=A(x.OW,S(n.json.hotspotOffset)),n.drawOffset={},Object.keys(n.json.drawOffset).forEach((function(t){n.drawOffset[t]=A(x.OW,S(n.json.drawOffset[t]))})),n.bindCamera=n.json.bindCamera,n.enableSpeech=n.json.enableSpeech;case 16:case"end":return t.stop()}}),t)})))),z(j(n),"onSelect",function(){var t=T(O().mark((function t(e,r){var o,i,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.selectTrigger){t.next=2;break}return t.abrupt("return");case 2:if("interact"!==n.selectTrigger){t.next=6;break}return t.next=5,n.interact(j(n));case 5:return t.abrupt("return",t.sent);case 6:if(t.prev=6,console.log({trigger:n.selectTrigger}),(o=n.zip.file("triggers/".concat(n.selectTrigger,".lua")))||(o=n.zip.file("triggers/".concat(n.selectTrigger,".pxs"))),o){t.next=12;break}throw new Error("No Lua Script Found");case 12:return t.next=14,o.async("string");case 14:return i=t.sent,console.log({msg:"trigger lua statement",luaScript:i}),(a=new k.Z(n.engine)).setScope({_this:e,zone:r.zone,subject:r}),a.initLibrary(),a.run('print("hello world lua")'),t.next=22,a.run(i);case 22:return t.abrupt("return",t.sent);case 25:t.prev=25,t.t0=t.catch(6),console.log({msg:"no lua script found",e:t.t0});case 28:case"end":return t.stop()}}),t,null,[[6,25]])})));return function(e,r){return t.apply(this,arguments)}}()),n.json=e,n.zip=r,n}return n=i,Object.defineProperty(n,"prototype",{writable:!1}),n}(_.Z);function N(t){return N="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},N(t)}function R(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=G(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function F(t,e,r){return F=q()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Y(o,r.prototype),o},F.apply(null,arguments)}function U(t){return function(t){if(Array.isArray(t))return W(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||G(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 G(t,e){if(t){if("string"==typeof t)return W(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?W(t,e):void 0}}function W(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function V(){V=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==N(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Z(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function $(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Z(i,n,o,a,s,"next",t)}function s(t){Z(i,n,o,a,s,"throw",t)}a(void 0)}))}}function Y(t,e){return Y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Y(t,e)}function K(t,e){if(e&&("object"===N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return H(t)}function H(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function q(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function X(t){return X=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},X(t)}function J(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Q=function(t){!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&&Y(t,e)}(i,t);var e,r,n,o=(e=i,r=q(),function(){var t,n=X(e);if(r){var o=X(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return K(this,t)});function i(t,e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),J(H(n=o.call(this,t)),"loadJson",$(V().mark((function t(){var e;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.json.extends){t.next=4;break}return t.next=3,Promise.all(n.json.extends.map(function(){var t=$(V().mark((function t(e){var r;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=JSON,t.next=3,n.zip.file("sprites/"+e+".json").async("string");case 3:t.t1=t.sent,r=t.t0.parse.call(t.t0,t.t1),console.log({old:n.json,new:r}),n.json=(0,p.Ee)(n.json,r);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:n.json.extends=null;case 4:n.update(n.json),n.src=n.json.src,n.portraitSrc=n.json.portraitSrc,n.sheetSize=n.json.sheetSize,n.tileSize=n.json.tileSize,n.isLit=n.json.isLit,n.direction=n.json.direction,n.attenuation=n.json.attenuation,n.density=n.json.density,n.lightColor=n.json.lightColor,n.state=null!==(e=n.json.state)&&void 0!==e?e:"intro",n.frames=n.json.frames,n.drawOffset={},Object.keys(n.json.drawOffset).forEach((function(t){n.drawOffset[t]=F(x.OW,U(n.json.drawOffset[t]))})),n.hotspotOffset=F(x.OW,U(n.json.hotspotOffset)),n.bindCamera=n.json.bindCamera,n.enableSpeech=n.json.enableSpeech;case 21:case"end":return t.stop()}}),t)})))),J(H(n),"interact",function(){var t=$(V().mark((function t(e){var r,o,i,a,s,c,u,l,f=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=f.length>1&&void 0!==f[1]?f[1]:function(){},i=null,a=null!==(r=n.json.states)&&void 0!==r?r:[],s={},t.next=6,Promise.all(a.map(function(){var t=$(V().mark((function t(r){var i,a,c,u;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.loadActionDynamically(r,e,o);case 2:i=t.sent,a=R(i);try{for(a.s();!(c=a.n()).done;)u=c.value,console.log({msg:"loading action",action:u})}catch(t){a.e(t)}finally{a.f()}console.log({msg:"switching state",state:r.name}),s[r.name]={next:r.next,actions:i};case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:console.log({msg:"loading stateMachine",stateMachine:s}),i=[],c=R(s[n.state].actions),t.prev=9,c.s();case 11:if((u=c.n()).done){t.next=20;break}return l=u.value,t.t0=i,t.next=16,l(H(n),e,o);case 16:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 18:t.next=11;break;case 20:t.next=25;break;case 22:t.prev=22,t.t2=t.catch(9),c.e(t.t2);case 25:return t.prev=25,c.f(),t.finish(25);case 28:return n.state=s[n.state].next,o&&o(!1),t.abrupt("return",i);case 31:case"end":return t.stop()}}),t,null,[[9,22,25,28]])})));return function(e){return t.apply(this,arguments)}}()),J(H(n),"loadActionDynamically",function(){var t=$(V().mark((function t(e,r,o){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log({sprite:r,state:e}),t.next=3,Promise.all(e.actions.map(function(){var t=$(V().mark((function t(e){var i,a;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log({msg:"preping actions",action:e}),!e.callback||""===e.callback){t.next=7;break}return t.next=4,n.zip.file("callbacks/"+e.callback+".lua").async("string");case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0='print("no callback")';case 8:i=t.t0,a=function(){console.log("calling callback");var t=new k.Z(n.engine);return t.setScope({_this:H(n),zone:r.zone,subject:r,finish:o}),t.initLibrary(),t.run('print("hello world lua - sprite callback")'),t.run(i)},t.t1=e.type,t.next="dialogue"===t.t1?13:"animate"===t.t1?15:17;break;case 13:return console.log({_this:H(n),finish:o}),t.abrupt("return",function(){var t=$(V().mark((function t(r,n,o){var i;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log({msg:"dialogue"}),i=new r.ActionLoader(r.engine,"dialogue",[JSON.stringify(e.dialogue),!1,{autoclose:!0,onClose:function(){return o(!0)}}],r,a),console.log({msg:"action to load",actionToLoad:i}),r.addAction(i);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}());case 15:return console.log({_this:H(n),finish:o}),t.abrupt("return",function(){var t=$(V().mark((function t(r,n,o){var i;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log({msg:"animate",_this:r,sprite:n,finish:o,action:e}),i=new r.ActionLoader(r.engine,"animate",[].concat(U(e.animate),[function(){return o(!0)}]),r,a),console.log({msg:"action to load",actionToLoad:i}),r.addAction(i);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}());case 17:return t.abrupt("return",function(){var t=$(V().mark((function t(e,r,n){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.log({msg:"no action found",_this:e,sprite:r,_finish:n});case 1:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}());case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}()),J(H(n),"onSelect",function(){var t=$(V().mark((function t(e,r){var o,i,a;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.selectTrigger){t.next=2;break}return t.abrupt("return");case 2:if("interact"!==n.selectTrigger){t.next=6;break}return t.next=5,n.interact(r,(function(){}));case 5:return t.abrupt("return",t.sent);case 6:if(t.prev=6,console.log({trigger:n.selectTrigger}),(o=n.zip.file("triggers/".concat(n.selectTrigger,".lua")))||(o=n.zip.file("triggers/".concat(n.selectTrigger,".pxs"))),o){t.next=12;break}throw new Error("No Lua Script Found");case 12:return t.next=14,o.async("string");case 14:return i=t.sent,console.log({msg:"trigger lua statement",luaScript:i}),(a=new k.Z(n.engine)).setScope({_this:H(n),zone:r.zone,subject:r}),a.initLibrary(),a.run('print("hello world lua")'),t.next=22,a.run(i);case 22:return t.abrupt("return",t.sent);case 25:t.prev=25,t.t0=t.catch(6),console.log({msg:"no lua script found",e:t.t0});case 28:case"end":return t.stop()}}),t,null,[[6,25]])})));return function(e,r){return t.apply(this,arguments)}}()),J(H(n),"onStep",function(){var t=$(V().mark((function t(e,r){var o,i,a;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.stepTrigger){t.next=2;break}return t.abrupt("return");case 2:if(t.prev=2,console.log({trigger:n.stepTrigger}),(o=n.zip.file("triggers/".concat(n.stepTrigger,".lua")))||(o=n.zip.file("triggers/".concat(n.stepTrigger,".pxs"))),o){t.next=8;break}throw new Error("No Lua Script Found");case 8:return t.next=10,o.async("string");case 10:return i=t.sent,console.log({msg:"trigger lua statement",luaScript:i}),(a=new k.Z(n.engine)).setScope({_this:H(n),zone:r.zone,subject:r}),a.initLibrary(),a.run('print("hello world lua")'),t.next=18,a.run(i);case 18:return t.abrupt("return",t.sent);case 21:t.prev=21,t.t0=t.catch(2),console.log({msg:"no lua script found",e:t.t0});case 24:case"end":return t.stop()}}),t,null,[[2,21]])})));return function(e,r){return t.apply(this,arguments)}}()),n.engine=t,n.json=e,n.zip=r,n.ActionLoader=Ut.a,n}return n=i,Object.defineProperty(n,"prototype",{writable:!1}),n}(r(4485).Z);function tt(t){return tt="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},tt(t)}function et(t,e){return et=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},et(t,e)}function rt(t,e){if(e&&("object"===tt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return nt(t)}function nt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ot(t){return ot=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ot(t)}function it(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var at=function(t){!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&&et(t,e)}(i,t);var e,r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ot(r);if(n){var o=ot(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return rt(this,t)});function i(t,e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),it(nt(n=o.call(this,t,e,r)),"init",(function(){n.json.randomJitter?n.triggerTime=n.json.triggerTime+Math.floor(Math.random()*n.json.randomJitter):n.triggerTime=n.json.triggerTime})),it(nt(n),"tick",(function(t){0!=n.lastTime?(n.accumTime+=t-n.lastTime,n.accumTime<n.frameTime||0==n.animFrame&&n.accumTime<n.triggerTime||(5==n.animFrame?(n.setFrame(0),n.triggerTime=1e3+Math.floor(4e3*Math.random())):(n.setFrame(n.animFrame+1),n.accumTime=0,n.lastTime=t))):n.lastTime=t})),n}return e=i,Object.defineProperty(e,"prototype",{writable:!1}),e}(Q),st=r(3203);function ct(t){return ct="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},ct(t)}function ut(t,e){return ut=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ut(t,e)}function lt(t,e){if(e&&("object"===ct(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return ft(t)}function ft(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}function dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var pt=function(t){!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&&ut(t,e)}(i,t);var e,r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ht(r);if(n){var o=ht(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return lt(this,t)});function i(t,e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),dt(ft(n=o.call(this,t,e,r)),"init",(function(){n.json.randomJitter?n.triggerTime=n.json.triggerTime+Math.floor(Math.random()*n.json.randomJitter):n.triggerTime=n.json.triggerTime})),dt(ft(n),"tick",(function(t){0!=n.lastTime?(n.accumTime+=t-n.lastTime,n.accumTime<n.frameTime||0==n.animFrame&&n.accumTime<n.triggerTime||(4==n.animFrame?(n.setFrame(0),n.triggerTime=2e3+Math.floor(4e3*Math.random())):(n.setFrame(n.animFrame+1),n.accumTime=0,n.lastTime=t))):n.lastTime=t})),dt(ft(n),"draw",(function(t){var e;n.loaded&&(t.renderManager.mvPushMatrix(),(0,st.Iu)(t.renderManager.uModelMat,t.renderManager.uModelMat,n.pos.toArray()),(0,st.Iu)(t.renderManager.uModelMat,t.renderManager.uModelMat,(null!==(e=n.drawOffset[t.renderManager.camera.cameraDir])&&void 0!==e?e:n.drawOffset.N).toArray()),(0,st.U1)(t.renderManager.uModelMat,t.renderManager.uModelMat,(0,x.Id)(90),[1,0,0]),t.renderManager.bindBuffer(n.vertexPosBuf,t.renderManager.shaderProgram.aVertexPosition),t.renderManager.bindBuffer(n.vertexTexBuf,t.renderManager.shaderProgram.aTextureCoord),n.texture.attach(),t.renderManager.effectPrograms.picker.setMatrixUniforms({id:n.getPickingId()}),t.renderManager.shaderProgram.setMatrixUniforms({id:n.getPickingId()}),t.gl.drawArrays(t.gl.TRIANGLES,0,n.vertexPosBuf.numItems),t.renderManager.mvPopMatrix())})),n}return e=i,Object.defineProperty(e,"prototype",{writable:!1}),e}(Q);function yt(t){return yt="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},yt(t)}function gt(){gt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==yt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function mt(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,s,"next",t)}function s(t){mt(i,n,o,a,s,"throw",t)}a(void 0)}))}}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var wt=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.definitions=[],this.instances={}}var e,r,n;return e=t,r=[{key:"loadFromZip",value:(n=vt(gt().mark((function t(e,r,n){var o,i,a,s,c=arguments;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("loading sprite from zip: "+r+" for "+n),o=c[3],i=c[4],this.instances[r]||(this.instances[r]=[]),a="",t.prev=5,t.t0=JSON,t.next=9,e.file("sprites/".concat(r,".json")).async("string");case 9:t.t1=t.sent,a=t.t0.parse.call(t.t0,t.t1),t.next=16;break;case 13:t.prev=13,t.t2=t.catch(5),console.error(t.t2);case 16:s={},t.t3=a.type,t.next="animated-sprite"===t.t3?20:"animated-tile"===t.t3?24:"avatar"===t.t3?28:32;break;case 20:return s=new at(this.engine,a,e),t.next=23,s.loadJson();case 23:return t.abrupt("break",36);case 24:return s=new pt(this.engine,a,e),t.next=27,s.loadJson();case 27:return t.abrupt("break",36);case 28:return s=new D(this.engine,a,e),t.next=31,s.loadJson();case 31:return t.abrupt("break",36);case 32:return s=new Q(this.engine,a,e),t.next=35,s.loadJson();case 35:return t.abrupt("break",36);case 36:if(s.templateLoaded=!0,this.instances[r].forEach(function(){var t=vt(gt().mark((function t(e){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.afterLoad){t.next=3;break}return t.next=3,e.afterLoad(e.instance);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),!i){t.next=41;break}return t.next=41,i(s);case 41:if(!o){t.next=48;break}if(!s.templateLoaded){t.next=47;break}return t.next=45,o(s);case 45:t.next=48;break;case 47:this.instances[r].push({instance:s,afterLoad:o});case 48:return t.abrupt("return",s);case 49:case"end":return t.stop()}}),t,this,[[5,13]])}))),function(t,e,r){return n.apply(this,arguments)})}],r&&bt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),xt=(r(5867),r(1073));function _t(t){return _t="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},_t(t)}function kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Et(t,e,r){return Et=Mt()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Pt(o,r.prototype),o},Et.apply(null,arguments)}function At(){At=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==_t(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function St(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Lt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){St(i,n,o,a,s,"next",t)}function s(t){St(i,n,o,a,s,"throw",t)}a(void 0)}))}}function Ot(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Pt(t,e){return Pt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Pt(t,e)}function Tt(t,e){if(e&&("object"===_t(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Ct(t)}function Ct(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Mt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function jt(t){return jt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},jt(t)}function It(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Bt=function(t){!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&&Pt(t,e)}(c,t);var e,r,o,i,a,s=(e=c,r=Mt(),function(){var t,n=jt(e);if(r){var o=jt(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return Tt(this,t)});function c(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),It(Ct(e=s.call(this)),"onLoad",(function(t){if(!e.loaded){if(e.zone=t.zone,t.id&&(e.id=t.id),t.pos&&(e.pos=t.pos,e.pos&&(null===e.pos.z||void 0===e.pos.z)))try{var r,n,o,i,a=e.pos.x+(null!==(r=null===(n=e.hotspotOffset)||void 0===n?void 0:n.x)&&void 0!==r?r:0),s=e.pos.y+(null!==(o=null===(i=e.hotspotOffset)||void 0===i?void 0:i.y)&&void 0!==o?o:0),c=e.zone.getHeight(a,s);e.pos.z="number"==typeof c?c:0}catch(t){console.warn("Error computing object height from zone",t),e.pos.z=0}t.isLit&&(e.isLit=t.isLit),t.lightColor&&(e.lightColor=t.lightColor),t.attenuation&&(e.attenuation=t.attenuation),t.direction&&(e.direction=t.direction),t.rotation&&(e.rotation=t.rotation),t.facing&&0!==t.facing&&(e.facing=t.facing),t.zones&&null!==t.zones&&(e.zones=t.zones);for(var u,l,f,h=t.mesh,d=null,p=null,y=null,g=0;g<h.vertices.length;g+=3){var m=h.vertices.slice(g,g+3);(null==u||m[0]>u)&&(u=m[0]),(null==d||m[0]<d)&&(d=m[0]),(null==l||m[1]>l)&&(l=m[1]),(null==p||m[1]<p)&&(p=m[1]),(null==f||m[2]>f)&&(f=m[2]),(null==y||m[2]<y)&&(y=m[2])}var v=new x.OW(u-d,f-y,l-p);e.size=v,e.scale=new x.OW(1/Math.max(v.x,v.z),1/Math.max(v.x,v.z),1/Math.max(v.x,v.z)),t.useScale&&(e.scale=t.useScale),e.drawOffset=new x.OW(.5,.5,0),e.mesh=h,e.engine.resourceManager.objLoader.initMeshBuffers(e.engine.gl,e.mesh),e.enableSpeech&&(e.speech=e.engine.resourceManager.loadSpeech(e.id,e.engine.mipmap),e.speech.runWhenLoaded(e.onTilesetOrTextureLoaded),e.speechTexBuf=e.engine.renderManager.createBuffer(e.getSpeechBubbleTexture(),e.engine.gl.DYNAMIC_DRAW,2)),e.portraitSrc&&(e.portrait=e.engine.resourceManager.loadTexture(e.portraitSrc),e.portrait.runWhenLoaded(e.onTilesetOrTextureLoaded)),e.isLit&&(e.lightIndex=e.engine.renderManager.lightManager.addLight(e.id,e.pos.toArray(),e.lightColor,[.01,.01,.01])),e.zone.tileset.runWhenDefinitionLoaded(e.onTilesetDefinitionLoaded)}})),It(Ct(e),"onLoadFromZip",function(){var t=Lt(At().mark((function t(r,n){var o,i,a,s,c,u,l,f,h,d,p,y,g,m,v,b,w;return At().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.loaded){t.next=2;break}return t.abrupt("return");case 2:if(e.zone=r.zone,r.id&&(e.id=r.id),r.pos&&(e.pos=r.pos,e.pos&&(null===e.pos.z||void 0===e.pos.z)))try{c=e.pos.x+(null!==(o=null===(i=e.hotspotOffset)||void 0===i?void 0:i.x)&&void 0!==o?o:0),u=e.pos.y+(null!==(a=null===(s=e.hotspotOffset)||void 0===s?void 0:s.y)&&void 0!==a?a:0),l=e.zone.getHeight(c,u),e.pos.z="number"==typeof l?l:0}catch(t){console.warn("Error computing object height from zone",t),e.pos.z=0}for(r.isLit&&(e.isLit=r.isLit),r.lightColor&&(e.lightColor=r.lightColor),r.attenuation&&(e.attenuation=r.attenuation),r.density&&(e.density=r.density),r.scatteringCoefficients&&(e.scatteringCoefficients=r.scatteringCoefficients),r.direction&&(e.direction=r.direction),r.rotation&&(e.rotation=r.rotation),r.facing&&0!==r.facing&&(e.facing=r.facing),r.zones&&null!==r.zones&&(e.zones=r.zones),f=r.mesh,d=null,y=null,m=null,v=0;v<f.vertices.length;v+=3)b=f.vertices.slice(v,v+3),(null==h||b[0]>h)&&(h=b[0]),(null==d||b[0]<d)&&(d=b[0]),(null==p||b[1]>p)&&(p=b[1]),(null==y||b[1]<y)&&(y=b[1]),(null==g||b[2]>g)&&(g=b[2]),(null==m||b[2]<m)&&(m=b[2]);if(w=new x.OW(h-d,g-m,p-y),e.size=w,e.scale=new x.OW(1/Math.max(w.x,w.z),1/Math.max(w.x,w.z),1/Math.max(w.x,w.z)),r.useScale&&(e.scale=r.useScale),e.drawOffset=new x.OW(.5,.5,0),e.mesh=f,e.engine.resourceManager.objLoader.initMeshBuffers(e.engine.gl,e.mesh),e.enableSpeech&&(e.speech=e.engine.resourceManager.loadSpeech(e.id,e.engine.mipmap),e.speech.runWhenLoaded(e.onTilesetOrTextureLoaded),e.speechTexBuf=e.engine.renderManager.createBuffer(e.getSpeechBubbleTexture(),e.engine.gl.DYNAMIC_DRAW,2)),!e.portraitSrc){t.next=32;break}return t.next=30,e.engine.resourceManager.loadTextureFromZip(e.portraitSrc,n);case 30:e.portrait=t.sent,e.portrait.runWhenLoaded(e.onTilesetOrTextureLoaded);case 32:e.isLit&&(e.lightIndex=e.engine.renderManager.lightManager.addLight(e.id,e.pos.toArray(),e.lightColor,e.attenuation,e.direction,e.density,e.scatteringCoefficients,!0)),e.zone.tileset.runWhenDefinitionLoaded(e.onTilesetDefinitionLoaded);case 34:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),It(Ct(e),"onTilesetDefinitionLoaded",(function(){e.zone.tileset.runWhenLoaded(e.onTilesetOrTextureLoaded)})),It(Ct(e),"onTilesetOrTextureLoaded",(function(){!Ct(e)||e.loaded||e.enableSpeech&&e.speech&&!e.speech.loaded||e.portrait&&!e.portrait.loaded||(e.init(),e.enableSpeech&&e.speech&&e.speech.clearHud&&(e.speech.clearHud(),e.speech.writeText(e.id),e.speech.loadImage()),e.loaded=!0,e.onLoadActions.run())})),It(Ct(e),"getSpeechBubbleTexture",(function(){return[[1,1],[0,1],[0,0],[1,1],[0,0],[1,0]].flat(3)})),It(Ct(e),"getSpeechBubbleVertices",(function(){return[Et(x.OW,[2,0,4]).toArray(),Et(x.OW,[0,0,4]).toArray(),Et(x.OW,[0,0,2]).toArray(),Et(x.OW,[2,0,4]).toArray(),Et(x.OW,[0,0,2]).toArray(),Et(x.OW,[2,0,2]).toArray()].flat(3)})),It(Ct(e),"attach",(function(t){var r=e.engine.gl;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t),r.uniform1i(e.engine.renderManager.shaderProgram.diffuseMapUniform,0)})),It(Ct(e),"drawTexturedObj",(function(){var t=Ct(e),r=t.engine,n=t.mesh;n.indicesPerMaterial.length>=1&&Object.keys(n.materialsByIndex).length>0?n.indicesPerMaterial.forEach((function(t,o){var i,a;r.renderManager.bindBuffer(n.vertexBuffer,r.renderManager.shaderProgram.aVertexPosition),r.renderManager.bindBuffer(n.textureBuffer,r.renderManager.shaderProgram.aTextureCoord),r.renderManager.bindBuffer(n.normalBuffer,r.renderManager.shaderProgram.aVertexNormal),r.gl.uniform3fv(r.renderManager.shaderProgram.uDiffuse,n.materialsByIndex[o].diffuse),r.gl.uniform1f(r.renderManager.shaderProgram.uSpecularExponent,n.materialsByIndex[o].specularExponent),(null===(i=n.materialsByIndex[o])||void 0===i||null===(a=i.mapDiffuse)||void 0===a?void 0:a.glTexture)?(e.attach(n.materialsByIndex[o].mapDiffuse.glTexture),r.gl.uniform1f(r.renderManager.shaderProgram.useDiffuse,1)):r.gl.uniform1f(r.renderManager.shaderProgram.useDiffuse,0),r.gl.uniform3fv(r.renderManager.shaderProgram.uSpecular,n.materialsByIndex[o].specular),r.gl.uniform1f(r.renderManager.shaderProgram.uSpecularExponent,n.materialsByIndex[o].specularExponent);var s=(0,xt._buildBuffer)(r.gl,r.gl.ELEMENT_ARRAY_BUFFER,t,1);r.gl.bindBuffer(r.gl.ELEMENT_ARRAY_BUFFER,s),r.renderManager.effectPrograms.picker.setMatrixUniforms({scale:e.scale,id:e.getPickingId(),sampler:0}),r.renderManager.shaderProgram.setMatrixUniforms({isSelected:e.isSelected,colorMultiplier:8&e.engine.frameCount?[1,0,0,1]:[1,1,0,1],scale:e.scale,sampler:0}),r.gl.drawElements(r.gl.TRIANGLES,s.numItems,r.gl.UNSIGNED_SHORT,0)})):(r.renderManager.bindBuffer(n.vertexBuffer,r.renderManager.shaderProgram.aVertexPosition),r.renderManager.bindBuffer(n.normalBuffer,r.renderManager.shaderProgram.aVertexNormal),r.renderManager.bindBuffer(n.textureBuffer,r.renderManager.shaderProgram.aTextureCoord),r.gl.bindBuffer(r.gl.ELEMENT_ARRAY_BUFFER,n.indexBuffer),r.gl.uniform3fv(r.renderManager.shaderProgram.uDiffuse,[.6,.3,.6]),r.gl.uniform3fv(r.renderManager.shaderProgram.uSpecular,[.1,.1,.2]),r.gl.uniform1f(r.renderManager.shaderProgram.uSpecularExponent,2),r.renderManager.effectPrograms.picker.setMatrixUniforms({scale:e.scale,id:e.getPickingId(),sampler:0}),r.renderManager.shaderProgram.setMatrixUniforms({isSelected:e.isSelected,colorMultiplier:8&e.engine.frameCount?[1,0,0,1]:[1,1,0,1],scale:e.scale,sampler:0}),r.gl.drawElements(r.gl.TRIANGLES,n.indexBuffer.numItems,r.gl.UNSIGNED_SHORT,0))})),It(Ct(e),"getPickingId",(function(){return[(e.objId>>0&255)/255,(e.objId>>8&255)/255,(e.objId>>16&255)/255,255]})),It(Ct(e),"drawObj",(function(){var t=Ct(e),r=t.engine,n=t.mesh;r.gl.disableVertexAttribArray(r.renderManager.shaderProgram.aTextureCoord),r.renderManager.bindBuffer(n.vertexBuffer,r.renderManager.shaderProgram.aVertexPosition),r.renderManager.bindBuffer(n.normalBuffer,r.renderManager.shaderProgram.aVertexNormal),r.gl.bindBuffer(r.gl.ELEMENT_ARRAY_BUFFER,n.indexBuffer),r.renderManager.effectPrograms.picker.setMatrixUniforms({scale:e.scale,id:e.getPickingId(),sampler:1}),r.renderManager.shaderProgram.setMatrixUniforms({scale:e.scale,sampler:1}),r.gl.drawElements(r.gl.TRIANGLES,n.indexBuffer.numItems,r.gl.UNSIGNED_SHORT,0)})),It(Ct(e),"draw",(function(){if(e.loaded){e.engine&&e.engine.renderManager&&e.engine.renderManager.debug&&e.engine.renderManager.debug.objectsDrawn++;var t=Ct(e),r=t.engine,n=t.mesh;if(r.gl.enableVertexAttribArray(r.renderManager.shaderProgram.aVertexNormal),r.gl.enableVertexAttribArray(r.renderManager.shaderProgram.aTextureCoord),r.renderManager.mvPushMatrix(),(0,st.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,e.drawOffset.toArray()),(0,st.Iu)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,e.pos.toArray()),(0,st.U1)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(0,x.Id)(90),[1,0,0]),e.rotation&&e.rotation.toArray){var o=Math.max.apply(Math,function(t){if(Array.isArray(t))return kt(t)}(i=e.rotation.toArray())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return kt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?kt(t,e):void 0}}(i)||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.")}());o>0&&(0,st.U1)(e.engine.renderManager.uModelMat,e.engine.renderManager.uModelMat,(0,x.Id)(o),[e.rotation.x/o,e.rotation.y/o,e.rotation.z/o])}n.textures.length?e.drawTexturedObj():e.drawObj(),r.renderManager.mvPopMatrix(),r.gl.enableVertexAttribArray(r.renderManager.shaderProgram.aTextureCoord),r.gl.disableVertexAttribArray(r.renderManager.shaderProgram.aVertexNormal)}var i})),It(Ct(e),"setFacing",(function(t){t&&(e.facing=t),e.rotation=p.Nm.objectSequence(t)})),It(Ct(e),"removeAction",(function(t){e.actionList=e.actionList.filter((function(e){return e.id!==t})),delete e.actionDict[t]})),It(Ct(e),"removeAllActions",(function(){e.actionList=[],e.actionDict={}})),It(Ct(e),"tickOuter",(function(t){if(e.loaded){e.actionList.sort((function(t,e){var r=t.startTime-e.startTime;return r?t.id>e.id?1:-1:r}));var r=[];e.actionList.forEach((function(e){!e.loaded||e.startTime>t||e.tick(t)&&(r.push(e),e.onComplete())})),r.forEach((function(t){return e.removeAction(t.id)})),e.tick&&e.tick(t)}})),It(Ct(e),"init",(function(){console.log("- object hook",e.id,e.pos,e.objId)})),It(Ct(e),"speak",(function(t){var r,n,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(e.textbox=e.engine.hud.scrollText(e.id+":> "+t,!0,{portrait:null!==(r=e.portrait)&&void 0!==r&&r}),o&&e.speech&&(e.speech.scrollText(t,!1,{portrait:null!==(n=e.portrait)&&void 0!==n&&n}),e.speech.loadImage())):e.speech.clearHud()})),It(Ct(e),"interact",function(){var t=Lt(At().mark((function t(r,n){var o;return At().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=null,t.t0=e.state,t.next=4;break;case 4:return t.abrupt("break",5);case 5:return n&&n(!0),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),It(Ct(e),"setFacing",(function(t){t&&(e.facing=t),e.rotation=p.Nm.objectSequence(t)})),It(Ct(e),"faceDir",(function(t){return e.facing==t||t===p.Nm.None?null:new Ut.a(e.engine,"face",[t],Ct(e))})),It(Ct(e),"setGreeting",(function(t){return e.speech.clearHud&&e.speech.clearHud(),e.speech.writeText(t),e.speech.loadImage(),new Ut.a(e.engine,"greeting",[t,{autoclose:!0}],Ct(e))})),e.objId=Math.floor(100*Math.random()),e.engine=t,e.templateLoaded=!1,e.drawOffset=new x.OW(0,0,0),e.hotspotOffset=new x.OW(0,0,0),e.pos=new x.OW(0,0,0),e.size=new x.OW(1,1,1),e.scale=new x.OW(1,1,1),e.rotation=new x.OW(0,0,0),e.facing=p.Nm.Right,e.actionDict={},e.actionList=[],e.speech={},e.portrait=null,e.isLit=!0,e.lightColor=[1,1,1],e.lightIndex=null,e.onLoadActions=new n.Z,e.inventory=[],e.blocking=!0,e.override=!1,e.isSelected=!1,e}return o=c,i=[{key:"addAction",value:(a=Lt(At().mark((function t(e){return At().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.resolve(e);case 2:e=t.sent,this.actionDict[e.id]&&this.removeAction(e.id),this.actionDict[e.id]=e,this.actionList.push(e);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})}],i&&Ot(o.prototype,i),Object.defineProperty(o,"prototype",{writable:!1}),c}(o.Z);function zt(t){return zt="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},zt(t)}function Dt(){Dt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==zt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Nt(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Ft=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.definitions=[],this.instances={}}var e,r,n,o;return e=t,r=[{key:"loadFromZip",value:(n=Dt().mark((function t(e,r){var n,o,i,a,s,c,u=arguments;return Dt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=u[2],i=u[3],this.instances[r.id]||(this.instances[r.id]=[]),(a=new Bt(this.engine)).update(r),s={obj:"".concat(a.type,".obj"),mtl:null!==(n=r.mtl)&&void 0!==n&&n,mtlTextureRoot:"textures",downloadMtlTextures:!0,enableWTextureCoord:!1,name:a.id},t.next=8,this.engine.resourceManager.objLoader.downloadModelsFromZip(this.engine.gl,[s],e);case 8:return c=t.sent,a.mesh=c[r.type],a.templateLoaded=!0,this.instances[a.id].forEach((function(t){t.afterLoad&&t.afterLoad(t.instance)})),i&&i(a),o&&(a.templateLoaded?o(a):this.instances[a.id].push({instance:a,afterLoad:o})),a.loaded=!0,t.abrupt("return",a);case 16:case"end":return t.stop()}}),t,this)})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function a(t){Nt(i,r,o,a,s,"next",t)}function s(t){Nt(i,r,o,a,s,"throw",t)}a(void 0)}))},function(t,e){return o.apply(this,arguments)})}],r&&Rt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),Ut=r(1183);function Gt(t){return Gt="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},Gt(t)}function Wt(){Wt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==Gt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Vt(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Zt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var $t=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.world=r,this.callback=n,this.time=(new Date).getTime(),this.id=r.id+"-"+e+"-"+this.time}var e,r,n,o;return e=t,r=[{key:"configure",value:function(t,e,r,n,o){this.world=e,this.id=r,this.type=t,this.startTime=n,this.creationArgs=o}},{key:"onLoad",value:(n=Wt().mark((function t(e){return Wt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.init.apply(this,e);case 2:this.loaded=!0;case 3:case"end":return t.stop()}}),t,this)})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function a(t){Vt(i,r,o,a,s,"next",t)}function s(t){Vt(i,r,o,a,s,"throw",t)}a(void 0)}))},function(t){return o.apply(this,arguments)})},{key:"serialize",value:function(){return{id:this.id,time:this.startTime,world:this.world.id,type:this.type,args:this.creationArgs}}},{key:"onComplete",value:function(){return this.callback?this.callback():null}}],r&&Zt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Kt=function(){function t(e,r,n,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.engine=e,this.type=r,this.args=n,this.world=o,this.callback=i,this.instances={},this.definitions=[],this.assets={};var a=(new Date).getTime(),s=o.id+"-"+r+"-"+a;return this.load(r,(function(t){t.onLoad(n)}),(function(t){t.configure(r,o,s,a,n)}))}var e,n;return e=t,n=[{key:"load",value:function(t){var e=arguments[1],n=arguments[2];this.instances[t]||(this.instances[t]=[]);var o=new $t(this.type,this.world,this.callback);return Object.assign(o,r(7996)("./"+t+".js").default),o.templateLoaded=!0,this.instances[t].forEach((function(t){t.afterLoad&&t.afterLoad(t.instance)})),n&&n(o),e&&(o.templateLoaded?e(o):this.instances[t].push({instance:o,afterLoad:e})),o}}],n&&Yt(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();r(7122)},3203:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(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 o(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}r.d(e,{Ez:()=>c,Fv:()=>g,G3:()=>u,Iu:()=>f,U1:()=>d,Ue:()=>s,XL:()=>y,fk:()=>h,oy:()=>l,t8:()=>p});var a=1e-6,s=function(){var t=new Float32Array(16);return t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},c=function(){var t=new Float32Array(9);return t[0]=1,t[4]=1,t[8]=1,t},u=function(t,e,r,n){var o=new Float32Array(16),i=1/Math.tan(t/2);if(o[0]=i/e,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=i,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=-1,o[11]=-1,o[12]=0,o[13]=0,o[14]=-2*r,o[15]=0,null!=n&&n!==1/0&&n!==r){var a=1/(r-n);o[10]=(n+r)*a,o[14]=2*n*r*a}return o},l=function(t,e,r,n,o,i){var a=new Float32Array(16);return a[0]=2*o/(e-t),a[1]=0,a[2]=(e+t)/(e-t),a[3]=0,a[4]=0,a[5]=2*o/(n-r),a[6]=(n+r)/(n-r),a[7]=0,a[8]=0,a[9]=0,a[10]=-(i+o)/(i-o),a[11]=-2*i*o/(i-o),a[12]=0,a[13]=0,a[14]=-1,a[15]=0,a},f=function(t,e,r){var o=t,i=n(r,3),a=i[0],s=i[1],c=i[2],u=n(e,12),l=u[0],f=u[1],h=u[2],d=u[3],p=u[4],y=u[5],g=u[6],m=u[7],v=u[8],b=u[9],w=u[10],x=u[11];return t!==e&&(o[0]=l,o[1]=f,o[2]=h,o[3]=d,o[4]=p,o[5]=y,o[6]=g,o[7]=m,o[8]=v,o[9]=b,o[10]=w,o[11]=x),o[12]=l*a+p*s+v*c+e[12],o[13]=f*a+y*s+b*c+e[13],o[14]=h*a+g*s+w*c+e[14],o[15]=d*a+m*s+x*c+e[15],o},h=function(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]},d=function(t,e,r,o){var i=t,s=n(o,3),c=s[0],u=s[1],l=s[2],f=Math.hypot(c,u,l);if(f<a)throw new Error("Matrix4*4 rotate has wrong axis");c*=f=1/f,u*=f,l*=f;var h=Math.sin(r),d=Math.cos(r),p=1-d,y=n(e,12),g=y[0],m=y[1],v=y[2],b=y[3],w=y[4],x=y[5],_=y[6],k=y[7],E=y[8],A=y[9],S=y[10],L=y[11],O=c*c*p+d,P=u*c*p+l*h,T=l*c*p-u*h,C=c*u*p-l*h,M=u*u*p+d,j=l*u*p+c*h,I=c*l*p+u*h,B=u*l*p-c*h,z=l*l*p+d;return i[0]=g*O+w*P+E*T,i[1]=m*O+x*P+A*T,i[2]=v*O+_*P+S*T,i[3]=b*O+k*P+L*T,i[4]=g*C+w*M+E*j,i[5]=m*C+x*M+A*j,i[6]=v*C+_*M+S*j,i[7]=b*C+k*M+L*j,i[8]=g*I+w*B+E*z,i[9]=m*I+x*B+A*z,i[10]=v*I+_*B+S*z,i[11]=b*I+k*B+L*z,e!==t&&(i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i};function p(t,e){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function y(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],d=e[11],p=e[12],y=e[13],g=e[14],m=e[15],v=r*s-n*a,b=r*c-o*a,w=r*u-i*a,x=n*c-o*s,_=n*u-i*s,k=o*u-i*c,E=l*y-f*p,A=l*g-h*p,S=l*m-d*p,L=f*g-h*y,O=f*m-d*y,P=h*m-d*g,T=v*P-b*O+w*L+x*S-_*A+k*E;return T?(T=1/T,t[0]=(s*P-c*O+u*L)*T,t[1]=(c*S-a*P-u*A)*T,t[2]=(a*O-s*S+u*E)*T,t[3]=(o*O-n*P-i*L)*T,t[4]=(r*P-o*S+i*A)*T,t[5]=(n*S-r*O-i*E)*T,t[6]=(y*k-g*_+m*x)*T,t[7]=(g*w-p*k-m*b)*T,t[8]=(p*_-y*w+m*v)*T,t):null}var g=function(t){var e,r=Math.hypot.apply(Math,function(t){if(Array.isArray(t))return i(t)}(e=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||o(e)||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.")}());return!r||Math.abs(r)<a?[0,0,1]:[t[0]/r,t[1]/r,t[2]/r]}},9010:(t,e,r)=>{"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}r.d(e,{Id:()=>f,Lt:()=>s,OW:()=>a,t7:()=>l,t8:()=>c,tk:()=>u});var a=function(){function t(e,r,o){n(this,t),this.x=e,this.y=r,this.z=o}return i(t,[{key:"add",value:function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z)}},{key:"sub",value:function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z)}},{key:"mul",value:function(e){return new t(this.x*e,this.y*e,this.z*e)}},{key:"mul3",value:function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z)}},{key:"cross",value:function(e){return new t(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"distance",value:function(t){return this.sub(t).length()}},{key:"normal",value:function(){if(0===this.x&&0===this.y&&0===this.z)return new t(0,0,0);var e=this.length();return new t(this.x/e,this.y/e,this.z/e)}},{key:"dot",value:function(t){return this.x*t.x+this.y*t.y+this.z*t.z}},{key:"toArray",value:function(){return[this.x,this.y,this.z]}},{key:"toString",value:function(){return"( ".concat(this.x,", ").concat(this.y,", ").concat(this.z," )")}},{key:"negate",value:function(){return new t(-1*this.x,-1*this.y,-1*this.z)}}]),t}(),s=function(){function t(e,r,o,i){n(this,t),this.x=e,this.y=r,this.z=o,this.w=i}return i(t,[{key:"add",value:function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)}},{key:"sub",value:function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}},{key:"mul",value:function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"distance",value:function(t){return this.sub(t).length()}},{key:"normal",value:function(){if(0===this.x&&0===this.y&&0===this.z&&0===this.w)return new t(0,0,0,0);var e=this.length();return new t(this.x/e,this.y/e,this.z/e,this.w/e)}},{key:"dot",value:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}},{key:"toArray",value:function(){return[this.x,this.y,this.z,this.w]}},{key:"toString",value:function(){return"( ".concat(this.x,", ").concat(this.y,", ").concat(this.z,", ").concat(this.w," )")}},{key:"negate",value:function(){return new a(-1*this.x,-1*this.y,-1*this.z,-1*this.w)}}]),t}();function c(t,e){e.x=t.x,e.y=t.y,e.z=t.z}function u(t,e){return e||(e=new a(-t.x,-t.y,-t.z)),e.x=-t.x,e.y=-t.y,e.z=-t.z,e}function l(t,e,r,n){return n||(n=t),n.x=t.x+r*(e.x-t.x),n.y=t.y+r*(e.y-t.y),n.z=t.z+r*(e.z-t.z),n}function f(t){return t*Math.PI/180}},6345:(t,e,r)=>{"use strict";e.NQ=void 0;var n=r(8354);n.default;var o=r(5121);o.Material,o.MaterialLibrary;var i=r(3068);i.Layout,i.TYPES,i.DuplicateAttributeException,i.Attribute;var a=r(1073);a.downloadModelsFromZip,a.downloadModels,a.downloadMeshes,a.initMeshBuffers,a.deleteMeshBuffers;e.NQ={Attribute:i.Attribute,DuplicateAttributeException:i.DuplicateAttributeException,Layout:i.Layout,Material:o.Material,MaterialLibrary:o.MaterialLibrary,Mesh:n.default,TYPES:i.TYPES,downloadModelsFromZip:a.downloadModelsFromZip,downloadModels:a.downloadModels,downloadMeshes:a.downloadMeshes,initMeshBuffers:a.initMeshBuffers,deleteMeshBuffers:a.deleteMeshBuffers,version:"2.0.3"}},3068:function(t,e){"use strict";var r,n,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0,e.Layout=e.Attribute=e.DuplicateAttributeException=e.TYPES=void 0,function(t){t.BYTE="BYTE",t.UNSIGNED_BYTE="UNSIGNED_BYTE",t.SHORT="SHORT",t.UNSIGNED_SHORT="UNSIGNED_SHORT",t.FLOAT="FLOAT"}(n=e.TYPES||(e.TYPES={}));var a=function(t){function e(e){return t.call(this,"found duplicate attribute: ".concat(e.key))||this}return o(e,t),e}(Error);e.DuplicateAttributeException=a;var s=function(t,e,r,n){switch(void 0===n&&(n=!1),this.key=t,this.size=e,this.type=r,this.normalized=n,r){case"BYTE":case"UNSIGNED_BYTE":this.sizeOfType=1;break;case"SHORT":case"UNSIGNED_SHORT":this.sizeOfType=2;break;case"FLOAT":this.sizeOfType=4;break;default:throw new Error("Unknown gl type: ".concat(r))}this.sizeInBytes=this.sizeOfType*e};e.Attribute=s;var c=function(){function t(){for(var t,e,r,n,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];this.attributes=o,this.attributeMap={};var c=0,u=0;try{for(var l=i(o),f=l.next();!f.done;f=l.next()){var h=f.value;if(this.attributeMap[h.key])throw new a(h);c%h.sizeOfType!=0&&(c+=h.sizeOfType-c%h.sizeOfType,console.warn("Layout requires padding before "+h.key+" attribute")),this.attributeMap[h.key]={attribute:h,size:h.size,type:h.type,normalized:h.normalized,offset:c},c+=h.sizeInBytes,u=Math.max(u,h.sizeOfType)}}catch(e){t={error:e}}finally{try{f&&!f.done&&(e=l.return)&&e.call(l)}finally{if(t)throw t.error}}c%u!=0&&(c+=u-c%u,console.warn("Layout requires padding at the back")),this.stride=c;try{for(var d=i(o),p=d.next();!p.done;p=d.next())h=p.value,this.attributeMap[h.key].stride=this.stride}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}}return t.POSITION=new s("position",3,n.FLOAT),t.NORMAL=new s("normal",3,n.FLOAT),t.TANGENT=new s("tangent",3,n.FLOAT),t.BITANGENT=new s("bitangent",3,n.FLOAT),t.UV=new s("uv",2,n.FLOAT),t.MATERIAL_INDEX=new s("materialIndex",1,n.SHORT),t.MATERIAL_ENABLED=new s("materialEnabled",1,n.UNSIGNED_SHORT),t.AMBIENT=new s("ambient",3,n.FLOAT),t.DIFFUSE=new s("diffuse",3,n.FLOAT),t.SPECULAR=new s("specular",3,n.FLOAT),t.SPECULAR_EXPONENT=new s("specularExponent",3,n.FLOAT),t.EMISSIVE=new s("emissive",3,n.FLOAT),t.TRANSMISSION_FILTER=new s("transmissionFilter",3,n.FLOAT),t.DISSOLVE=new s("dissolve",1,n.FLOAT),t.ILLUMINATION=new s("illumination",1,n.UNSIGNED_SHORT),t.REFRACTION_INDEX=new s("refractionIndex",1,n.FLOAT),t.SHARPNESS=new s("sharpness",1,n.FLOAT),t.MAP_DIFFUSE=new s("mapDiffuse",1,n.SHORT),t.MAP_AMBIENT=new s("mapAmbient",1,n.SHORT),t.MAP_SPECULAR=new s("mapSpecular",1,n.SHORT),t.MAP_SPECULAR_EXPONENT=new s("mapSpecularExponent",1,n.SHORT),t.MAP_DISSOLVE=new s("mapDissolve",1,n.SHORT),t.ANTI_ALIASING=new s("antiAliasing",1,n.UNSIGNED_SHORT),t.MAP_BUMP=new s("mapBump",1,n.SHORT),t.MAP_DISPLACEMENT=new s("mapDisplacement",1,n.SHORT),t.MAP_DECAL=new s("mapDecal",1,n.SHORT),t.MAP_EMISSIVE=new s("mapEmissive",1,n.SHORT),t}();e.Layout=c},5121:function(t,e){"use strict";var r=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0,e.MaterialLibrary=e.Material=void 0;var o=function(t){this.name=t,this.ambient=[0,0,0],this.diffuse=[0,0,0],this.specular=[0,0,0],this.emissive=[0,0,0],this.transmissionFilter=[0,0,0],this.dissolve=0,this.specularExponent=0,this.transparency=0,this.illumination=0,this.refractionIndex=1,this.sharpness=0,this.mapDiffuse={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapAmbient={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapSpecular={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapSpecularExponent={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDissolve={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.antiAliasing=!1,this.mapBump={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDisplacement={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDecal={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapEmissive={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapReflections=[]};e.Material=o;var i=new o("sentinel"),a=function(){function t(t){this.data=t,this.currentMaterial=i,this.materials={},this.parse()}return t.prototype.parse_newmtl=function(t){var e=t[0];this.currentMaterial=new o(e),this.materials[e]=this.currentMaterial},t.prototype.parseColor=function(t){if("spectral"==t[0])throw new Error("The MTL parser does not support spectral curve files. You will need to convert the MTL colors to either RGB or CIEXYZ.");if("xyz"==t[0])throw new Error("The MTL parser does not currently support XYZ colors. Either convert the XYZ values to RGB or create an issue to add support for XYZ");if(3==t.length){var e=r(t,3),n=e[0],o=e[1],i=e[2];return[parseFloat(n),parseFloat(o),parseFloat(i)]}var a=parseFloat(t[0]);return[a,a,a]},t.prototype.parse_Ka=function(t){this.currentMaterial.ambient=this.parseColor(t)},t.prototype.parse_Kd=function(t){this.currentMaterial.diffuse=this.parseColor(t)},t.prototype.parse_Ks=function(t){this.currentMaterial.specular=this.parseColor(t)},t.prototype.parse_Ke=function(t){this.currentMaterial.emissive=this.parseColor(t)},t.prototype.parse_Tf=function(t){this.currentMaterial.transmissionFilter=this.parseColor(t)},t.prototype.parse_d=function(t){this.currentMaterial.dissolve=parseFloat(t.pop()||"0")},t.prototype.parse_illum=function(t){this.currentMaterial.illumination=parseInt(t[0])},t.prototype.parse_Ni=function(t){this.currentMaterial.refractionIndex=parseFloat(t[0])},t.prototype.parse_Ns=function(t){this.currentMaterial.specularExponent=parseInt(t[0])},t.prototype.parse_sharpness=function(t){this.currentMaterial.sharpness=parseInt(t[0])},t.prototype.parse_cc=function(t,e){e.colorCorrection="on"==t[0]},t.prototype.parse_blendu=function(t,e){e.horizontalBlending="on"==t[0]},t.prototype.parse_blendv=function(t,e){e.verticalBlending="on"==t[0]},t.prototype.parse_boost=function(t,e){e.boostMipMapSharpness=parseFloat(t[0])},t.prototype.parse_mm=function(t,e){e.modifyTextureMap.brightness=parseFloat(t[0]),e.modifyTextureMap.contrast=parseFloat(t[1])},t.prototype.parse_ost=function(t,e,r){for(;t.length<3;)t.push(r.toString());e.u=parseFloat(t[0]),e.v=parseFloat(t[1]),e.w=parseFloat(t[2])},t.prototype.parse_o=function(t,e){this.parse_ost(t,e.offset,0)},t.prototype.parse_s=function(t,e){this.parse_ost(t,e.scale,1)},t.prototype.parse_t=function(t,e){this.parse_ost(t,e.turbulence,0)},t.prototype.parse_texres=function(t,e){e.textureResolution=parseFloat(t[0])},t.prototype.parse_clamp=function(t,e){e.clamp="on"==t[0]},t.prototype.parse_bm=function(t,e){e.bumpMultiplier=parseFloat(t[0])},t.prototype.parse_imfchan=function(t,e){e.imfChan=t[0]},t.prototype.parse_type=function(t,e){e.reflectionType=t[0]},t.prototype.parseOptions=function(t){var e,r,n={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},o={};for(t.reverse();t.length;){var i=t.pop();i.startsWith("-")?o[e=i.substr(1)]=[]:e&&o[e].push(i)}for(e in o)if(o.hasOwnProperty(e)){r=o[e];var a=this["parse_".concat(e)];a&&a.bind(this)(r,n)}return n},t.prototype.parseMap=function(t){var e,n,o="";t[0].startsWith("-")?(o=t.pop(),n=t):(o=(e=r(t))[0],n=e.slice(1));var i=this.parseOptions(n);return i.filename=o.replace(/\\/g,"/"),i},t.prototype.parse_map_Ka=function(t){this.currentMaterial.mapAmbient=this.parseMap(t)},t.prototype.parse_map_Kd=function(t){this.currentMaterial.mapDiffuse=this.parseMap(t)},t.prototype.parse_map_Ks=function(t){this.currentMaterial.mapSpecular=this.parseMap(t)},t.prototype.parse_map_Ke=function(t){this.currentMaterial.mapEmissive=this.parseMap(t)},t.prototype.parse_map_Ns=function(t){this.currentMaterial.mapSpecularExponent=this.parseMap(t)},t.prototype.parse_map_d=function(t){this.currentMaterial.mapDissolve=this.parseMap(t)},t.prototype.parse_map_aat=function(t){this.currentMaterial.antiAliasing="on"==t[0]},t.prototype.parse_map_bump=function(t){this.currentMaterial.mapBump=this.parseMap(t)},t.prototype.parse_bump=function(t){this.parse_map_bump(t)},t.prototype.parse_disp=function(t){this.currentMaterial.mapDisplacement=this.parseMap(t)},t.prototype.parse_decal=function(t){this.currentMaterial.mapDecal=this.parseMap(t)},t.prototype.parse_refl=function(t){this.currentMaterial.mapReflections.push(this.parseMap(t))},t.prototype.parse=function(){var t,e,o=this.data.split(/\r?\n/);try{for(var a=n(o),s=a.next();!s.done;s=a.next()){var c=s.value;if((c=c.trim())&&!c.startsWith("#")){var u=r(c.split(/\s/)),l=u[0],f=u.slice(1),h=this["parse_".concat(l)];h?h.bind(this)(f):console.warn("Don't know how to parse the directive: \"".concat(l,'"'))}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}delete this.data,this.currentMaterial=i},t}();e.MaterialLibrary=a},8354:function(t,e,r){"use strict";var n=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};e.__esModule=!0;var s=r(3068),c=function(){function t(t,e){var r,n,s,c;this.name="",this.indicesPerMaterial=[],this.materialsByIndex={},this.tangents=[],this.bitangents=[],(e=e||{}).materials=e.materials||{},e.enableWTextureCoord=!!e.enableWTextureCoord,this.vertexNormals=[],this.textures=[],this.indices=[],this.textureStride=e.enableWTextureCoord?3:2;var l=[],f=[],h=[],d=[],p={},y=-1,g=0,m={verts:[],norms:[],textures:[],hashindices:{},indices:[[]],materialIndices:[],index:0},v=/^v\s/,b=/^vn\s/,w=/^vt\s/,x=/^f\s/,_=/\s+/,k=/^usemtl/,E=t.split("\n");try{for(var A=o(E),S=A.next();!S.done;S=A.next()){var L=S.value;if((L=L.trim())&&!L.startsWith("#")){var O=L.split(_);if(O.shift(),v.test(L))l.push.apply(l,a([],i(O),!1));else if(b.test(L))f.push.apply(f,a([],i(O),!1));else if(w.test(L)){var P=parseFloat(O[0]),T=O.length>1?1-parseFloat(O[1]):0;if(e.enableWTextureCoord){var C=O.length>2?parseFloat(O[2]):0;h.push(P.toString(),T.toString(),C.toString())}else h.push(P.toString(),T.toString())}else if(k.test(L)){var M=O[0];M in p||(d.push(M),p[M]=d.length-1,p[M]>0&&m.indices.push([])),g=y=p[M]}else if(x.test(L)){var j=u(O);try{for(var I=(s=void 0,o(j)),B=I.next();!B.done;B=I.next())for(var z=B.value,D=0,N=z.length;D<N;D++){var R=z[D]+","+y;if(R in m.hashindices)m.indices[g].push(m.hashindices[R]);else{var F=z[D].split("/"),U=F.length-1;if(m.verts.push(+l[3*(+F[0]-1)+0]),m.verts.push(+l[3*(+F[0]-1)+1]),m.verts.push(+l[3*(+F[0]-1)+2]),h.length){var G=e.enableWTextureCoord?3:2;m.textures.push(+h[(+F[1]-1)*G+0]),m.textures.push(+h[(+F[1]-1)*G+1]),e.enableWTextureCoord&&m.textures.push(+h[(+F[1]-1)*G+2])}m.norms.push(+f[3*(+F[U]-1)+0]),m.norms.push(+f[3*(+F[U]-1)+1]),m.norms.push(+f[3*(+F[U]-1)+2]),m.materialIndices.push(y),m.hashindices[R]=m.index,m.indices[g].push(m.hashindices[R]),m.index+=1}}}catch(t){s={error:t}}finally{try{B&&!B.done&&(c=I.return)&&c.call(I)}finally{if(s)throw s.error}}}}}}catch(t){r={error:t}}finally{try{S&&!S.done&&(n=A.return)&&n.call(A)}finally{if(r)throw r.error}}this.vertices=m.verts,this.vertexNormals=m.norms,this.textures=m.textures,this.vertexMaterialIndices=m.materialIndices,this.indices=m.indices[g],this.indicesPerMaterial=m.indices,this.materialNames=d,this.materialIndices=p,this.materialsByIndex={},e.calcTangentsAndBitangents&&this.calculateTangentsAndBitangents()}return t.prototype.calculateTangentsAndBitangents=function(){console.assert(!!(this.vertices&&this.vertices.length&&this.vertexNormals&&this.vertexNormals.length&&this.textures&&this.textures.length),"Missing attributes for calculating tangents and bitangents");for(var t={tangents:a([],i(new Array(this.vertices.length)),!1).map((function(t){return 0})),bitangents:a([],i(new Array(this.vertices.length)),!1).map((function(t){return 0}))},e=this.indices,r=this.vertices,n=this.vertexNormals,o=this.textures,s=0;s<e.length;s+=3){var c=e[s+0],u=e[s+1],l=e[s+2],f=r[3*c+0],h=r[3*c+1],d=r[3*c+2],p=o[2*c+0],y=o[2*c+1],g=r[3*u+0],m=r[3*u+1],v=r[3*u+2],b=o[2*u+0],w=o[2*u+1],x=g-f,_=m-h,k=v-d,E=r[3*l+0]-f,A=r[3*l+1]-h,S=r[3*l+2]-d,L=b-p,O=w-y,P=o[2*l+0]-p,T=o[2*l+1]-y,C=L*T-O*P,M=1/Math.abs(C<1e-4?1:C),j=(x*T-E*O)*M,I=(_*T-A*O)*M,B=(k*T-S*O)*M,z=(E*L-x*P)*M,D=(A*L-_*P)*M,N=(S*L-k*P)*M,R=n[3*c+0],F=n[3*c+1],U=n[3*c+2],G=n[3*u+0],W=n[3*u+1],V=n[3*u+2],Z=n[3*l+0],$=n[3*l+1],Y=n[3*l+2],K=j*R+I*F+B*U,H=j*G+I*W+B*V,q=j*Z+I*$+B*Y,X=j-R*K,J=I-F*K,Q=B-U*K,tt=j-G*H,et=I-W*H,rt=B-V*H,nt=j-Z*q,ot=I-$*q,it=B-Y*q,at=Math.sqrt(X*X+J*J+Q*Q),st=Math.sqrt(tt*tt+et*et+rt*rt),ct=Math.sqrt(nt*nt+ot*ot+it*it),ut=z*R+D*F+N*U,lt=z*G+D*W+N*V,ft=z*Z+D*$+N*Y,ht=z-R*ut,dt=D-F*ut,pt=N-U*ut,yt=z-G*lt,gt=D-W*lt,mt=N-V*lt,vt=z-Z*ft,bt=D-$*ft,wt=N-Y*ft,xt=Math.sqrt(ht*ht+dt*dt+pt*pt),_t=Math.sqrt(yt*yt+gt*gt+mt*mt),kt=Math.sqrt(vt*vt+bt*bt+wt*wt);t.tangents[3*c+0]+=X/at,t.tangents[3*c+1]+=J/at,t.tangents[3*c+2]+=Q/at,t.tangents[3*u+0]+=tt/st,t.tangents[3*u+1]+=et/st,t.tangents[3*u+2]+=rt/st,t.tangents[3*l+0]+=nt/ct,t.tangents[3*l+1]+=ot/ct,t.tangents[3*l+2]+=it/ct,t.bitangents[3*c+0]+=ht/xt,t.bitangents[3*c+1]+=dt/xt,t.bitangents[3*c+2]+=pt/xt,t.bitangents[3*u+0]+=yt/_t,t.bitangents[3*u+1]+=gt/_t,t.bitangents[3*u+2]+=mt/_t,t.bitangents[3*l+0]+=vt/kt,t.bitangents[3*l+1]+=bt/kt,t.bitangents[3*l+2]+=wt/kt}this.tangents=t.tangents,this.bitangents=t.bitangents},t.prototype.makeBufferData=function(t){var e,r,n=this.vertices.length/3,i=new ArrayBuffer(t.stride*n);i.numItems=n;for(var a=new DataView(i),c=0,u=0;c<n;c++){u=c*t.stride;try{for(var l=(e=void 0,o(t.attributes)),f=l.next();!f.done;f=l.next()){var h=f.value,d=u+t.attributeMap[h.key].offset;switch(h.key){case s.Layout.POSITION.key:a.setFloat32(d,this.vertices[3*c],!0),a.setFloat32(d+4,this.vertices[3*c+1],!0),a.setFloat32(d+8,this.vertices[3*c+2],!0);break;case s.Layout.UV.key:a.setFloat32(d,this.textures[2*c],!0),a.setFloat32(d+4,this.textures[2*c+1],!0);break;case s.Layout.NORMAL.key:a.setFloat32(d,this.vertexNormals[3*c],!0),a.setFloat32(d+4,this.vertexNormals[3*c+1],!0),a.setFloat32(d+8,this.vertexNormals[3*c+2],!0);break;case s.Layout.MATERIAL_INDEX.key:a.setInt16(d,this.vertexMaterialIndices[c],!0);break;case s.Layout.AMBIENT.key:var p=this.vertexMaterialIndices[c];if(!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.ambient[0],!0),a.setFloat32(d+4,y.ambient[1],!0),a.setFloat32(d+8,y.ambient[2],!0);break;case s.Layout.DIFFUSE.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.diffuse[0],!0),a.setFloat32(d+4,y.diffuse[1],!0),a.setFloat32(d+8,y.diffuse[2],!0);break;case s.Layout.SPECULAR.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.specular[0],!0),a.setFloat32(d+4,y.specular[1],!0),a.setFloat32(d+8,y.specular[2],!0);break;case s.Layout.SPECULAR_EXPONENT.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.specularExponent,!0);break;case s.Layout.EMISSIVE.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.emissive[0],!0),a.setFloat32(d+4,y.emissive[1],!0),a.setFloat32(d+8,y.emissive[2],!0);break;case s.Layout.TRANSMISSION_FILTER.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.transmissionFilter[0],!0),a.setFloat32(d+4,y.transmissionFilter[1],!0),a.setFloat32(d+8,y.transmissionFilter[2],!0);break;case s.Layout.DISSOLVE.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.dissolve,!0);break;case s.Layout.ILLUMINATION.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setInt16(d,y.illumination,!0);break;case s.Layout.REFRACTION_INDEX.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.refractionIndex,!0);break;case s.Layout.SHARPNESS.key:if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setFloat32(d,y.sharpness,!0);break;case s.Layout.ANTI_ALIASING.key:var y;if(p=this.vertexMaterialIndices[c],!(y=this.materialsByIndex[p])){console.warn('Material "'+this.materialNames[p]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}a.setInt16(d,y.antiAliasing?1:0,!0)}}}catch(t){e={error:t}}finally{try{f&&!f.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}}return i},t.prototype.makeIndexBufferData=function(){var t=new Uint16Array(this.indices);return t.numItems=this.indices.length,t},t.prototype.makeIndexBufferDataForMaterials=function(){for(var t,e=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=(t=new Array).concat.apply(t,a([],i(r.map((function(t){return e.indicesPerMaterial[t]}))),!1)),s=new Uint16Array(o);return s.numItems=o.length,s},t.prototype.addMaterialLibrary=function(t){for(var e in t.materials)if(e in this.materialIndices){var r=t.materials[e],n=this.materialIndices[r.name];this.materialsByIndex[n]=r}},t}();function u(t){var e;return n(this,(function(r){switch(r.label){case 0:return t.length<=3?[4,t]:[3,2];case 1:return r.sent(),[3,9];case 2:return 4!==t.length?[3,5]:[4,[t[0],t[1],t[2]]];case 3:return r.sent(),[4,[t[2],t[3],t[0]]];case 4:return r.sent(),[3,9];case 5:e=1,r.label=6;case 6:return e<t.length-1?[4,[t[0],t[e],t[e+1]]]:[3,9];case 7:r.sent(),r.label=8;case 8:return e++,[3,6];case 9:return[2]}}))}e.default=c},1073:function(t,e,r){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};e.__esModule=!0,e.deleteMeshBuffers=e.initMeshBuffers=e._buildBuffer=e.downloadMeshes=e.downloadModels=e.downloadModelsFromZip=void 0;var i=r(8354),a=r(5121);function s(t,e){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(e)),r}function c(t,e,r){var o,i,a=["mapDiffuse","mapAmbient","mapSpecular","mapDissolve","mapBump","mapDisplacement","mapDecal","mapEmissive"];r.endsWith("/")||(r+="/");var c=[];for(var u in e.materials)if(e.materials.hasOwnProperty(u)){var l=e.materials[u],f=function(e){var n=l[e];if(!n||!n.filename)return"continue";var o=r+n.filename;c.push(fetch(o).then((function(t){if(!t.ok)throw new Error;return t.blob()})).then((function(e){var r=new Image;r.src=URL.createObjectURL(e),n.texture=r;var o=s(t,[128,192,86,255]);return n.glTexture=o,r.onload=function(){t.bindTexture(t.TEXTURE_2D,n.glTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n.texture);var e=function(t){return 0==(t&t-1)&&t>0};e(r.width)&&e(r.height)?(t.generateMipmap(t.TEXTURE_2D),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)},new Promise((function(t){return r.onload=function(){return t(n)}}))})).catch((function(){console.error("Unable to download texture: ".concat(o))})))};try{for(var h=(o=void 0,n(a)),d=h.next();!d.done;d=h.next())f(d.value)}catch(t){o={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(o)throw o.error}}}return Promise.all(c)}function u(t,e,r,o){var i,a,c=["mapDiffuse","mapAmbient","mapSpecular","mapDissolve","mapBump","mapDisplacement","mapDecal","mapEmissive"];r.endsWith("/")||(r+="/");var u=[];for(var l in e.materials)if(e.materials.hasOwnProperty(l)){var f=e.materials[l],h=function(e){var n=f[e];if(!n||!n.filename)return"continue";var i=r+n.filename;u.push(o.file(i).async("arrayBuffer").then((function(t){var e=new Uint8Array(t);return new Blob([e.buffer])})).then((function(e){var r=new Image;r.src=URL.createObjectURL(e),n.texture=r;var o=s(t,[128,192,86,255]);return n.glTexture=o,r.onload=function(){t.bindTexture(t.TEXTURE_2D,n.glTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n.texture);var e=function(t){return 0==(t&t-1)&&t>0};e(r.width)&&e(r.height)?(t.generateMipmap(t.TEXTURE_2D),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)},new Promise((function(t){return r.onload=function(){return t(n)}}))})).catch((function(){console.error("Unable to download texture from zip: ".concat(i))})))};try{for(var d=(i=void 0,n(c)),p=d.next();!p.done;p=d.next())h(p.value)}catch(t){i={error:t}}finally{try{p&&!p.done&&(a=d.return)&&a.call(d)}finally{if(i)throw i.error}}}return Promise.all(u)}function l(t){return"string"!=typeof t.mtl?t.obj.replace(/\.obj$/,".mtl"):t.mtl}function f(t,e,r,n){var o=t.createBuffer(),i=e===t.ARRAY_BUFFER?Float32Array:Uint16Array;return t.bindBuffer(e,o),t.bufferData(e,new i(r),t.STATIC_DRAW),o.itemSize=n,o.numItems=r.length/n,o}e.downloadModelsFromZip=function(t,e,r){var s,c,f=[],h=function(e){if(!e.obj)throw new Error('"obj" attribute of model object not set. The .obj file is required to be set in order to use downloadModels()');var n={indicesPerMaterial:!!e.indicesPerMaterial,calcTangentsAndBitangents:!!e.calcTangentsAndBitangents},o=e.obj.split("/"),s=o[o.length-1].replace(".obj",""),c=Promise.resolve(s),h=r.file("models/".concat(s,".obj")).async("string").then((function(t){return new i.default(t,n)})),d=void 0;if(e.mtl){var p=l(e);d=r.file("models/".concat(s,".mtl")).async("string").then((function(n){var o=new a.MaterialLibrary(n);if(!1!==e.downloadMtlTextures){var i=e.mtlTextureRoot;return i||(i=p.substr(0,p.lastIndexOf("/"))),Promise.all([Promise.resolve(o),u(t,o,i,r)])}return Promise.all([Promise.resolve(o),void 0])})).then((function(t){return t}))}var y=[c,h,d];f.push(Promise.all(y))};try{for(var d=n(e),p=d.next();!p.done;p=d.next())h(p.value)}catch(t){s={error:t}}finally{try{p&&!p.done&&(c=d.return)&&c.call(d)}finally{if(s)throw s.error}}return Promise.all(f).then((function(t){var e,r,i={};try{for(var a=n(t),s=a.next();!s.done;s=a.next()){var c=s.value,u=o(c,3),l=u[0],f=u[1],h=u[2];f.name=l,h&&f.addMaterialLibrary(h[0]),i[l]=f}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return i}))},e.downloadModels=function(t,e){var r,s,u=[],f=function(e){if(!e.obj)throw new Error('"obj" attribute of model object not set. The .obj file is required to be set in order to use downloadModels()');var r={indicesPerMaterial:!!e.indicesPerMaterial,calcTangentsAndBitangents:!!e.calcTangentsAndBitangents},n=e.name;if(!n){var o=e.obj.split("/");n=o[o.length-1].replace(".obj","")}var s=Promise.resolve(n),f=fetch(e.obj).then((function(t){return t.text()})).then((function(t){return new i.default(t,r)})),h=void 0;if(e.mtl){var d=l(e);h=fetch(d).then((function(t){return t.text()})).then((function(r){var n=new a.MaterialLibrary(r);if(!1!==e.downloadMtlTextures){var o=e.mtlTextureRoot;return o||(o=d.substr(0,d.lastIndexOf("/"))),Promise.all([Promise.resolve(n),c(t,n,o)])}return Promise.all([Promise.resolve(n),void 0])})).then((function(t){return t}))}var p=[s,f,h];u.push(Promise.all(p))};try{for(var h=n(e),d=h.next();!d.done;d=h.next())f(d.value)}catch(t){r={error:t}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}return Promise.all(u).then((function(t){var e,r,i={};try{for(var a=n(t),s=a.next();!s.done;s=a.next()){var c=s.value,u=o(c,3),l=u[0],f=u[1],h=u[2];f.name=l,h&&f.addMaterialLibrary(h[0]),i[l]=f}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return i}))},e.downloadMeshes=function(t,e,r){void 0===r&&(r={});var a=[],s=function(e){if(!t.hasOwnProperty(e))return"continue";var r=t[e];a.push(fetch(r).then((function(t){return t.text()})).then((function(t){return[e,new i.default(t)]})))};for(var c in t)s(c);Promise.all(a).then((function(t){var i,a;try{for(var s=n(t),c=s.next();!c.done;c=s.next()){var u=o(c.value,2),l=u[0],f=u[1];r[l]=f}}catch(t){i={error:t}}finally{try{c&&!c.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return e(r)}))},e._buildBuffer=f,e.initMeshBuffers=function(t,e){return e.normalBuffer=f(t,t.ARRAY_BUFFER,e.vertexNormals,3),e.textureBuffer=f(t,t.ARRAY_BUFFER,e.textures,e.textureStride),e.vertexBuffer=f(t,t.ARRAY_BUFFER,e.vertices,3),e.indexBuffer=f(t,t.ELEMENT_ARRAY_BUFFER,e.indices,1),e},e.deleteMeshBuffers=function(t,e){t.deleteBuffer(e.normalBuffer),t.deleteBuffer(e.textureBuffer),t.deleteBuffer(e.vertexBuffer),t.deleteBuffer(e.indexBuffer)}},5867:(t,e,r)=>{"use strict";r.d(e,{Z:()=>n});const n={tilesetRequestUrl:function(t){return"/pixospritz/tilesets/"+t+"/tileset.json"},zoneRequestUrl:function(t){return"/pixospritz/maps/"+t+"/map.json"},artResourceUrl:function(t){return"/pixospritz/art/"+t}}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=c(t),a=i[0],s=i[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),l=0,f=s>0?a-4:a;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],a=16383,s=0,c=n-o;s<c;s+=a)i.push(u(t,s,s+a>c?c:s+a));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=i.length;a<s;++a)r[a]=i[a],n[i.charCodeAt(a)]=a;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var o,i,a=[],s=e;s<n;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},8764:(t,e,r)=>{"use strict";const n=r(9742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=function(t){return+t!=t&&(t=0),c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const o=function(t){if(c.isBuffer(t)){const e=0|p(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),s(t<0?0:0|p(t))}function h(t){const e=t.length<0?0:0|p(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function p(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(o)return n?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){let i,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){let n=-1;for(i=r;i<s;i++)if(u(t,i)===u(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===c)return n*a}else-1!==n&&(i-=i-n),n=-1}else for(r+c>s&&(r=s-c),i=r;i>=0;i--){let r=!0;for(let n=0;n<c;n++)if(u(t,i+n)!==u(e,n)){r=!1;break}if(r)return i}return-1}function w(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let a;for(n>i/2&&(n=i/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(q(n))return a;t[r+a]=n}return a}function x(t,e,r,n){return K($(e,t.length-r),t,r,n)}function _(t,e,r,n){return K(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function k(t,e,r,n){return K(Y(e),t,r,n)}function E(t,e,r,n){return K(function(t,e){let r,n,o;const i=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,a=e>239?4:e>223?3:e>191?2:1;if(o+a<=r){let r,n,s,c;switch(a){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(i=c));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=t[o+1],n=t[o+2],s=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=a}return function(t){const e=t.length;if(e<=L)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=L));return r}(n)}e.kMaxLength=a,c.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},c.allocUnsafe=function(t){return f(t)},c.allocUnsafeSlow=function(t){return f(t)},c.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==c.prototype},c.compare=function(t,e){if(H(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),H(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=c.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(H(e,Uint8Array))o+e.length>n.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},c.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},c.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):g.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(i,a),u=this.slice(n,o),l=t.slice(e,r);for(let t=0;t<s;++t)if(u[t]!==l[t]){i=u[t],a=l[t];break}return i<a?-1:a<i?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const L=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function T(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=X[t[n]];return o}function C(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function M(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function I(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function B(t,e,r,n,o){G(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function z(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,i){return e=+e,r>>>=0,i||z(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||z(t,0,r,8),o.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),c.prototype.readBigUInt64BE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),c.prototype.readBigInt64BE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),c.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||j(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||j(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=J((function(t,e=0){return I(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=J((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);j(this,t,e,r,n-1,-n)}let o=0,i=1,a=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);j(this,t,e,r,n-1,-n)}let o=r-1,i=1,a=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/i>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=J((function(t,e=0){return I(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=J((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=c.isBuffer(t)?t:c.from(t,n),a=i.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%a]}return this};const R={};function F(t,e,r){R[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function U(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new R.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,o,i)}function W(t,e){if("number"!=typeof t)throw new R.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new R.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new R.ERR_BUFFER_OUT_OF_BOUNDS;throw new R.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=U(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=U(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const Z=/[^+/0-9A-Za-z-_]/g;function $(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Y(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},1895:(t,e,r)=>{"use strict";r.d(e,{Z:()=>s});var n=r(7537),o=r.n(n),i=r(3645),a=r.n(i)()(o());a.push([t.id,"/* *** ----------------------------------------------- **\n** Calliope - Site Generator \t **\n** ----------------------------------------------- **\n** Copyright (c) 2020-2025 - Kyle Derby MacInnis **\n** **\n** Any unauthorized distribution or transfer **\n** of this work is strictly prohibited. **\n** **\n** All Rights Reserved. **\n** ----------------------------------------------- **\n\\* */\n\n:root {\n --color-bg: #0a0a0f;\n --color-primary: #00ff88;\n --color-secondary: #00ccff;\n --color-accent: #ff0055;\n --color-border: #2a2a3e;\n --glow-primary: rgba(0, 255, 136, 0.5);\n --glow-secondary: rgba(0, 204, 255, 0.5);\n}\n\n.pixos {\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 16px;\n width: 100%;\n text-shadow: #000 2px 2px 0px;\n position: relative;\n align-items: center;\n align-content: center;\n}\n\n.renderSurface {\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n width: 100%;\n}\n\n.materialSelector {\n background: rgba(10, 10, 15, 0.95);\n margin: auto;\n position: relative;\n border: 2px solid var(--color-border);\n border-radius: 4px;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);\n}\n.materialSelector tr {\n height: 70px;\n}\n.materialSelector td {\n background-position: 0px 0px;\n cursor: pointer;\n margin: 0;\n opacity: 0.5;\n padding: 0;\n width: 70px;\n transition: opacity 0.2s;\n}\n.materialSelector td:hover {\n opacity: 1;\n box-shadow: 0 0 10px var(--glow-primary);\n}\n\n.nickname {\n color: var(--color-primary);\n cursor: default;\n left: 42%;\n position: absolute;\n top: 40%;\n width: 300px;\n text-shadow: 0 0 10px var(--glow-primary);\n}\n.nickname input {\n background: rgba(10, 10, 15, 0.8);\n border-bottom: 2px solid var(--color-primary);\n border: 1px solid var(--color-border);\n border-radius: 4px;\n color: var(--color-primary);\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 16px;\n outline: none;\n width: 100%;\n padding: 8px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n}\n.nickname input:focus {\n border-color: var(--color-primary);\n box-shadow: 0 0 15px var(--glow-primary);\n}\n\n.joininfo {\n color: var(--color-primary);\n cursor: default;\n font-size: 16px;\n position: absolute;\n text-align: center;\n top: 42%;\n width: 99%;\n text-shadow: 0 0 10px var(--glow-primary);\n}\n\n.chatbox {\n background: rgba(10, 10, 15, 0.95);\n border: 2px solid var(--color-border);\n border-radius: 8px;\n bottom: 55px;\n color: var(--color-primary);\n cursor: default;\n height: 195px;\n left: 20px;\n overflow: hidden;\n padding: 10px;\n position: absolute;\n width: 600px;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.5);\n}\n\n.chatbox_text {\n bottom: 8px;\n position: absolute;\n text-shadow: none;\n font-size: 12px;\n line-height: 1.6;\n}\n\n.chatbox_entry {\n background: rgba(10, 10, 15, 0.95);\n border: 2px solid var(--color-border);\n border-radius: 4px;\n bottom: 18px;\n color: var(--color-primary);\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 12px;\n height: 30px;\n left: 20px;\n outline: none;\n padding: 8px 10px;\n position: absolute;\n width: 610px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n}\n.chatbox_entry:focus {\n border-color: var(--color-primary);\n box-shadow: 0 0 15px var(--glow-primary);\n}\n\nhtml {\n height: 100%;\n}\n\n.pixos-body {\n height: 100%;\n margin: 0;\n overflow: hidden;\n background: linear-gradient(to bottom, #202020, #111119);\n}\n\n.rain {\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n}\n\n.snow {\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n}\n\n.rain.back-row {\n z-index: 1;\n bottom: 60px;\n opacity: 0.5;\n}\n.snow.back-row {\n z-index: 1;\n bottom: 60px;\n opacity: 0.8;\n}\n\nbody.back-row-toggle .rain.back-row .snow.back-row {\n display: block;\n}\n\n.drop {\n position: absolute;\n bottom: 100%;\n width: 15px;\n height: 120px;\n pointer-events: none;\n animation: drop 0.5s linear infinite;\n}\n\n.flake {\n position: absolute;\n bottom: 100%;\n width: 24px;\n height: 24px;\n pointer-events: none;\n animation: snow 2.5s linear infinite;\n}\n\n@keyframes drop {\n 0% {\n transform: translateY(0vh);\n }\n 75% {\n transform: translateY(90vh);\n }\n 100% {\n transform: translateY(90vh);\n }\n}\n\n@keyframes snow {\n 0% {\n transform: translateY(0vh);\n }\n 70% {\n transform: translateY(50vh);\n }\n 85% {\n transform: translateY(85vh);\n }\n 75% {\n transform: translateY(75vh);\n }\n 100% {\n transform: translateY(95vh);\n transform: translateX(30vw);\n }\n}\n\n.stem {\n width: 1px;\n height: 60%;\n margin-left: 7px;\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.25));\n animation: stem 0.5s linear infinite;\n}\n\n@keyframes stem {\n 0% {\n opacity: 1;\n }\n 65% {\n opacity: 1;\n }\n 75% {\n opacity: 0;\n }\n 100% {\n opacity: 0;\n }\n}\n\n.splat {\n width: 15px;\n height: 10px;\n border-top: 2px dotted rgba(255, 255, 255, 0.5);\n border-radius: 50%;\n opacity: 1;\n transform: scale(0);\n animation: splat 0.5s linear infinite;\n}\n\nbody.splat-toggle .splat {\n display: block;\n}\n\n@keyframes splat {\n 0% {\n opacity: 1;\n transform: scale(0);\n }\n 80% {\n opacity: 1;\n transform: scale(0);\n }\n 90% {\n opacity: 0.5;\n transform: scale(1);\n }\n 100% {\n opacity: 0;\n transform: scale(1.5);\n }\n}\n\n.toggles {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 3;\n}\n\n.toggle {\n position: absolute;\n left: 20px;\n width: 50px;\n height: 50px;\n line-height: 51px;\n box-sizing: border-box;\n text-align: center;\n font-family: sans-serif;\n font-size: 10px;\n font-weight: bold;\n background-color: rgba(255, 255, 255, 0.2);\n color: rgba(0, 0, 0, 0.5);\n border-radius: 50%;\n cursor: pointer;\n transition: background-color 0.3s;\n}\n\n.toggle:hover {\n background-color: rgba(255, 255, 255, 0.25);\n}\n\n.toggle:active {\n background-color: rgba(255, 255, 255, 0.3);\n}\n\n.toggle.active {\n background-color: rgba(255, 255, 255, 0.4);\n}\n\n.splat-toggle {\n top: 20px;\n}\n\n.back-row-toggle {\n top: 90px;\n line-height: 12px;\n padding-top: 14px;\n}\n\n.single-toggle {\n top: 160px;\n}\n\nbody.single-toggle .drop {\n display: none;\n}\n\nbody.single-toggle .drop:nth-child(10) {\n display: block;\n}\n","",{version:3,sources:["webpack://./pixospritz/src/css/pixos.css"],names:[],mappings:"AAAA;;;;;;;;;;oDAUoD;;AAEpD;EACE,mBAAmB;EACnB,wBAAwB;EACxB,0BAA0B;EAC1B,uBAAuB;EACvB,uBAAuB;EACvB,sCAAsC;EACtC,wCAAwC;AAC1C;;AAEA;EACE,uDAAuD;EACvD,eAAe;EACf,WAAW;EACX,6BAA6B;EAC7B,kBAAkB;EAClB,mBAAmB;EACnB,qBAAqB;AACvB;;AAEA;EACE,YAAY;EACZ,OAAO;EACP,kBAAkB;EAClB,MAAM;EACN,WAAW;AACb;;AAEA;EACE,kCAAkC;EAClC,YAAY;EACZ,kBAAkB;EAClB,qCAAqC;EACrC,kBAAkB;EAClB,uCAAuC;AACzC;AACA;EACE,YAAY;AACd;AACA;EACE,4BAA4B;EAC5B,eAAe;EACf,SAAS;EACT,YAAY;EACZ,UAAU;EACV,WAAW;EACX,wBAAwB;AAC1B;AACA;EACE,UAAU;EACV,wCAAwC;AAC1C;;AAEA;EACE,2BAA2B;EAC3B,eAAe;EACf,SAAS;EACT,kBAAkB;EAClB,QAAQ;EACR,YAAY;EACZ,yCAAyC;AAC3C;AACA;EACE,iCAAiC;EACjC,6CAA6C;EAC7C,qCAAqC;EACrC,kBAAkB;EAClB,2BAA2B;EAC3B,uDAAuD;EACvD,eAAe;EACf,aAAa;EACb,WAAW;EACX,YAAY;EACZ,uCAAuC;AACzC;AACA;EACE,kCAAkC;EAClC,wCAAwC;AAC1C;;AAEA;EACE,2BAA2B;EAC3B,eAAe;EACf,eAAe;EACf,kBAAkB;EAClB,kBAAkB;EAClB,QAAQ;EACR,UAAU;EACV,yCAAyC;AAC3C;;AAEA;EACE,kCAAkC;EAClC,qCAAqC;EACrC,kBAAkB;EAClB,YAAY;EACZ,2BAA2B;EAC3B,eAAe;EACf,aAAa;EACb,UAAU;EACV,gBAAgB;EAChB,aAAa;EACb,kBAAkB;EAClB,YAAY;EACZ,0EAA0E;AAC5E;;AAEA;EACE,WAAW;EACX,kBAAkB;EAClB,iBAAiB;EACjB,eAAe;EACf,gBAAgB;AAClB;;AAEA;EACE,kCAAkC;EAClC,qCAAqC;EACrC,kBAAkB;EAClB,YAAY;EACZ,2BAA2B;EAC3B,uDAAuD;EACvD,eAAe;EACf,YAAY;EACZ,UAAU;EACV,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,YAAY;EACZ,uCAAuC;AACzC;AACA;EACE,kCAAkC;EAClC,wCAAwC;AAC1C;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,SAAS;EACT,gBAAgB;EAChB,wDAAwD;AAC1D;;AAEA;EACE,kBAAkB;EAClB,OAAO;EACP,WAAW;EACX,YAAY;EACZ,UAAU;AACZ;;AAEA;EACE,kBAAkB;EAClB,OAAO;EACP,WAAW;EACX,YAAY;EACZ,UAAU;AACZ;;AAEA;EACE,UAAU;EACV,YAAY;EACZ,YAAY;AACd;AACA;EACE,UAAU;EACV,YAAY;EACZ,YAAY;AACd;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,WAAW;EACX,aAAa;EACb,oBAAoB;EACpB,oCAAoC;AACtC;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,oBAAoB;EACpB,oCAAoC;AACtC;;AAEA;EACE;IACE,0BAA0B;EAC5B;EACA;IACE,2BAA2B;EAC7B;EACA;IACE,2BAA2B;EAC7B;AACF;;AAEA;EACE;IACE,0BAA0B;EAC5B;EACA;IACE,2BAA2B;EAC7B;EACA;IACE,2BAA2B;EAC7B;EACA;IACE,2BAA2B;EAC7B;EACA;IACE,2BAA2B;IAC3B,2BAA2B;EAC7B;AACF;;AAEA;EACE,UAAU;EACV,WAAW;EACX,gBAAgB;EAChB,yFAAyF;EACzF,oCAAoC;AACtC;;AAEA;EACE;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;EACA;IACE,UAAU;EACZ;AACF;;AAEA;EACE,WAAW;EACX,YAAY;EACZ,+CAA+C;EAC/C,kBAAkB;EAClB,UAAU;EACV,mBAAmB;EACnB,qCAAqC;AACvC;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE;IACE,UAAU;IACV,mBAAmB;EACrB;EACA;IACE,UAAU;IACV,mBAAmB;EACrB;EACA;IACE,YAAY;IACZ,mBAAmB;EACrB;EACA;IACE,UAAU;IACV,qBAAqB;EACvB;AACF;;AAEA;EACE,kBAAkB;EAClB,MAAM;EACN,OAAO;EACP,UAAU;AACZ;;AAEA;EACE,kBAAkB;EAClB,UAAU;EACV,WAAW;EACX,YAAY;EACZ,iBAAiB;EACjB,sBAAsB;EACtB,kBAAkB;EAClB,uBAAuB;EACvB,eAAe;EACf,iBAAiB;EACjB,0CAA0C;EAC1C,yBAAyB;EACzB,kBAAkB;EAClB,eAAe;EACf,iCAAiC;AACnC;;AAEA;EACE,2CAA2C;AAC7C;;AAEA;EACE,0CAA0C;AAC5C;;AAEA;EACE,0CAA0C;AAC5C;;AAEA;EACE,SAAS;AACX;;AAEA;EACE,SAAS;EACT,iBAAiB;EACjB,iBAAiB;AACnB;;AAEA;EACE,UAAU;AACZ;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,cAAc;AAChB",sourcesContent:["/* *** ----------------------------------------------- **\n** Calliope - Site Generator \t **\n** ----------------------------------------------- **\n** Copyright (c) 2020-2025 - Kyle Derby MacInnis **\n** **\n** Any unauthorized distribution or transfer **\n** of this work is strictly prohibited. **\n** **\n** All Rights Reserved. **\n** ----------------------------------------------- **\n\\* */\n\n:root {\n --color-bg: #0a0a0f;\n --color-primary: #00ff88;\n --color-secondary: #00ccff;\n --color-accent: #ff0055;\n --color-border: #2a2a3e;\n --glow-primary: rgba(0, 255, 136, 0.5);\n --glow-secondary: rgba(0, 204, 255, 0.5);\n}\n\n.pixos {\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 16px;\n width: 100%;\n text-shadow: #000 2px 2px 0px;\n position: relative;\n align-items: center;\n align-content: center;\n}\n\n.renderSurface {\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n width: 100%;\n}\n\n.materialSelector {\n background: rgba(10, 10, 15, 0.95);\n margin: auto;\n position: relative;\n border: 2px solid var(--color-border);\n border-radius: 4px;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);\n}\n.materialSelector tr {\n height: 70px;\n}\n.materialSelector td {\n background-position: 0px 0px;\n cursor: pointer;\n margin: 0;\n opacity: 0.5;\n padding: 0;\n width: 70px;\n transition: opacity 0.2s;\n}\n.materialSelector td:hover {\n opacity: 1;\n box-shadow: 0 0 10px var(--glow-primary);\n}\n\n.nickname {\n color: var(--color-primary);\n cursor: default;\n left: 42%;\n position: absolute;\n top: 40%;\n width: 300px;\n text-shadow: 0 0 10px var(--glow-primary);\n}\n.nickname input {\n background: rgba(10, 10, 15, 0.8);\n border-bottom: 2px solid var(--color-primary);\n border: 1px solid var(--color-border);\n border-radius: 4px;\n color: var(--color-primary);\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 16px;\n outline: none;\n width: 100%;\n padding: 8px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n}\n.nickname input:focus {\n border-color: var(--color-primary);\n box-shadow: 0 0 15px var(--glow-primary);\n}\n\n.joininfo {\n color: var(--color-primary);\n cursor: default;\n font-size: 16px;\n position: absolute;\n text-align: center;\n top: 42%;\n width: 99%;\n text-shadow: 0 0 10px var(--glow-primary);\n}\n\n.chatbox {\n background: rgba(10, 10, 15, 0.95);\n border: 2px solid var(--color-border);\n border-radius: 8px;\n bottom: 55px;\n color: var(--color-primary);\n cursor: default;\n height: 195px;\n left: 20px;\n overflow: hidden;\n padding: 10px;\n position: absolute;\n width: 600px;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.5);\n}\n\n.chatbox_text {\n bottom: 8px;\n position: absolute;\n text-shadow: none;\n font-size: 12px;\n line-height: 1.6;\n}\n\n.chatbox_entry {\n background: rgba(10, 10, 15, 0.95);\n border: 2px solid var(--color-border);\n border-radius: 4px;\n bottom: 18px;\n color: var(--color-primary);\n font-family: 'Press Start 2P', 'Courier New', monospace;\n font-size: 12px;\n height: 30px;\n left: 20px;\n outline: none;\n padding: 8px 10px;\n position: absolute;\n width: 610px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n}\n.chatbox_entry:focus {\n border-color: var(--color-primary);\n box-shadow: 0 0 15px var(--glow-primary);\n}\n\nhtml {\n height: 100%;\n}\n\n.pixos-body {\n height: 100%;\n margin: 0;\n overflow: hidden;\n background: linear-gradient(to bottom, #202020, #111119);\n}\n\n.rain {\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n}\n\n.snow {\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n}\n\n.rain.back-row {\n z-index: 1;\n bottom: 60px;\n opacity: 0.5;\n}\n.snow.back-row {\n z-index: 1;\n bottom: 60px;\n opacity: 0.8;\n}\n\nbody.back-row-toggle .rain.back-row .snow.back-row {\n display: block;\n}\n\n.drop {\n position: absolute;\n bottom: 100%;\n width: 15px;\n height: 120px;\n pointer-events: none;\n animation: drop 0.5s linear infinite;\n}\n\n.flake {\n position: absolute;\n bottom: 100%;\n width: 24px;\n height: 24px;\n pointer-events: none;\n animation: snow 2.5s linear infinite;\n}\n\n@keyframes drop {\n 0% {\n transform: translateY(0vh);\n }\n 75% {\n transform: translateY(90vh);\n }\n 100% {\n transform: translateY(90vh);\n }\n}\n\n@keyframes snow {\n 0% {\n transform: translateY(0vh);\n }\n 70% {\n transform: translateY(50vh);\n }\n 85% {\n transform: translateY(85vh);\n }\n 75% {\n transform: translateY(75vh);\n }\n 100% {\n transform: translateY(95vh);\n transform: translateX(30vw);\n }\n}\n\n.stem {\n width: 1px;\n height: 60%;\n margin-left: 7px;\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.25));\n animation: stem 0.5s linear infinite;\n}\n\n@keyframes stem {\n 0% {\n opacity: 1;\n }\n 65% {\n opacity: 1;\n }\n 75% {\n opacity: 0;\n }\n 100% {\n opacity: 0;\n }\n}\n\n.splat {\n width: 15px;\n height: 10px;\n border-top: 2px dotted rgba(255, 255, 255, 0.5);\n border-radius: 50%;\n opacity: 1;\n transform: scale(0);\n animation: splat 0.5s linear infinite;\n}\n\nbody.splat-toggle .splat {\n display: block;\n}\n\n@keyframes splat {\n 0% {\n opacity: 1;\n transform: scale(0);\n }\n 80% {\n opacity: 1;\n transform: scale(0);\n }\n 90% {\n opacity: 0.5;\n transform: scale(1);\n }\n 100% {\n opacity: 0;\n transform: scale(1.5);\n }\n}\n\n.toggles {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 3;\n}\n\n.toggle {\n position: absolute;\n left: 20px;\n width: 50px;\n height: 50px;\n line-height: 51px;\n box-sizing: border-box;\n text-align: center;\n font-family: sans-serif;\n font-size: 10px;\n font-weight: bold;\n background-color: rgba(255, 255, 255, 0.2);\n color: rgba(0, 0, 0, 0.5);\n border-radius: 50%;\n cursor: pointer;\n transition: background-color 0.3s;\n}\n\n.toggle:hover {\n background-color: rgba(255, 255, 255, 0.25);\n}\n\n.toggle:active {\n background-color: rgba(255, 255, 255, 0.3);\n}\n\n.toggle.active {\n background-color: rgba(255, 255, 255, 0.4);\n}\n\n.splat-toggle {\n top: 20px;\n}\n\n.back-row-toggle {\n top: 90px;\n line-height: 12px;\n padding-top: 14px;\n}\n\n.single-toggle {\n top: 160px;\n}\n\nbody.single-toggle .drop {\n display: none;\n}\n\nbody.single-toggle .drop:nth-child(10) {\n display: block;\n}\n"],sourceRoot:""}]);const s=a},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r="",n=void 0!==e[5];return e[4]&&(r+="@supports (".concat(e[4],") {")),e[2]&&(r+="@media ".concat(e[2]," {")),n&&(r+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),r+=t(e),n&&(r+="}"),e[2]&&(r+="}"),e[4]&&(r+="}"),r})).join("")},e.i=function(t,r,n,o,i){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(n)for(var s=0;s<this.length;s++){var c=this[s][0];null!=c&&(a[c]=!0)}for(var u=0;u<t.length;u++){var l=[].concat(t[u]);n&&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),r&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=r):l[2]=r),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),e.push(l))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],r=t[3];if(!r)return e;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),i="/*# ".concat(o," */"),a=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[e].concat(a).concat([i]).join("\n")}return[e].join("\n")}},3162:function(t,e,r){var n;void 0===(n=function(){"use strict";function e(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){s(n.response,e,r)},n.onerror=function(){console.error("could not download file")},n.send()}function n(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function o(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(r){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof r.g&&r.g.global===r.g?r.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),s=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(t,r,a){var s=i.URL||i.webkitURL,c=document.createElement("a");r=r||t.name||"download",c.download=r,c.rel="noopener","string"==typeof t?(c.href=t,c.origin===location.origin?o(c):n(c.href)?e(t,r,a):o(c,c.target="_blank")):(c.href=s.createObjectURL(t),setTimeout((function(){s.revokeObjectURL(c.href)}),4e4),setTimeout((function(){o(c)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,r,i){if(r=r||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(console.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}(t,i),r);else if(n(t))e(t,r,i);else{var a=document.createElement("a");a.href=t,a.target="_blank",setTimeout((function(){o(a)}))}}:function(t,r,n,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof t)return e(t,r,n);var s="application/octet-stream"===t.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||s&&c||a)&&"undefined"!=typeof FileReader){var l=new FileReader;l.onloadend=function(){var t=l.result;t=u?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=t:location=t,o=null},l.readAsDataURL(t)}else{var f=i.URL||i.webkitURL,h=f.createObjectURL(t);o?o.location=h:location.href=h,o=null,setTimeout((function(){f.revokeObjectURL(h)}),4e4)}});i.saveAs=s.saveAs=s,t.exports=s}.apply(e,[]))||(t.exports=n)},8679:(t,e,r)=>{"use strict";var n=r(9864),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function c(t){return n.isMemo(t)?a:s[t.$$typeof]||o}s[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[n.Memo]=a;var u=Object.defineProperty,l=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,h=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,p=Object.prototype;t.exports=function t(e,r,n){if("string"!=typeof r){if(p){var o=d(r);o&&o!==p&&t(e,o,n)}var a=l(r);f&&(a=a.concat(f(r)));for(var s=c(e),y=c(r),g=0;g<a.length;++g){var m=a[g];if(!(i[m]||n&&n[m]||y&&y[m]||s&&s[m])){var v=h(r,m);try{u(e,m,v)}catch(t){}}}}return e}},645:(t,e)=>{e.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,c=(1<<s)-1,u=c>>1,l=-7,f=r?o-1:0,h=r?-1:1,d=t[e+f];for(f+=h,i=d&(1<<-l)-1,d>>=-l,l+=s;l>0;i=256*i+t[e+f],f+=h,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=n;l>0;a=256*a+t[e+f],f+=h,l-=8);if(0===i)i=1-u;else{if(i===c)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),i-=u}return(d?-1:1)*a*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var a,s,c,u=8*i-o-1,l=(1<<u)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+f>=1?h/c:h*Math.pow(2,1-f))*c>=2&&(a++,c/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(e*c-1)*Math.pow(2,o),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;t[r+d]=255&s,d+=p,s/=256,o-=8);for(a=a<<o|s,u+=o;u>0;t[r+d]=255&a,d+=p,a/=256,u-=8);t[r+d-p]|=128*y}},5733:(t,e,r)=>{var n=r(8764).Buffer;t.exports=function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[a]={exports:{}};e[a][0].call(u.exports,(function(t){return o(e[a][1][t]||t)}),u,u.exports,t,e,r,n)}return r[a].exports}for(var i=void 0,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(t,e,r){"use strict";var n=t("./utils"),o=t("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(t){for(var e,r,o,a,s,c,u,l=[],f=0,h=t.length,d=h,p="string"!==n.getTypeOf(t);f<t.length;)d=h-f,o=p?(e=t[f++],r=f<h?t[f++]:0,f<h?t[f++]:0):(e=t.charCodeAt(f++),r=f<h?t.charCodeAt(f++):0,f<h?t.charCodeAt(f++):0),a=e>>2,s=(3&e)<<4|r>>4,c=1<d?(15&r)<<2|o>>6:64,u=2<d?63&o:64,l.push(i.charAt(a)+i.charAt(s)+i.charAt(c)+i.charAt(u));return l.join("")},r.decode=function(t){var e,r,n,a,s,c,u=0,l=0,f="data:";if(t.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var h,d=3*(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"")).length/4;if(t.charAt(t.length-1)===i.charAt(64)&&d--,t.charAt(t.length-2)===i.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=o.uint8array?new Uint8Array(0|d):new Array(0|d);u<t.length;)e=i.indexOf(t.charAt(u++))<<2|(a=i.indexOf(t.charAt(u++)))>>4,r=(15&a)<<4|(s=i.indexOf(t.charAt(u++)))>>2,n=(3&s)<<6|(c=i.indexOf(t.charAt(u++))),h[l++]=e,64!==s&&(h[l++]=r),64!==c&&(h[l++]=n);return h}},{"./support":30,"./utils":32}],2:[function(t,e,r){"use strict";var n=t("./external"),o=t("./stream/DataWorker"),i=t("./stream/Crc32Probe"),a=t("./stream/DataLengthProbe");function s(t,e,r,n,o){this.compressedSize=t,this.uncompressedSize=e,this.crc32=r,this.compression=n,this.compressedContent=o}s.prototype={getContentWorker:function(){var t=new o(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new o(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(t,e,r){return t.pipe(new i).pipe(new a("uncompressedSize")).pipe(e.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",e)},e.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,r){"use strict";var n=t("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(t){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,r){"use strict";var n=t("./utils"),o=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==n.getTypeOf(t)?function(t,e,r,n){var i=o,a=0+r;t^=-1;for(var s=0;s<a;s++)t=t>>>8^i[255&(t^e[s])];return-1^t}(0|e,t,t.length):function(t,e,r,n){var i=o,a=0+r;t^=-1;for(var s=0;s<a;s++)t=t>>>8^i[255&(t^e.charCodeAt(s))];return-1^t}(0|e,t,t.length):0}},{"./utils":32}],5:[function(t,e,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(t,e,r){"use strict";var n;n="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:n}},{lie:37}],7:[function(t,e,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,o=t("pako"),i=t("./utils"),a=t("./stream/GenericWorker"),s=n?"uint8array":"array";function c(t,e){a.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}r.magic="\b\0",i.inherits(c,a),c.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(i.transformTo(s,t.data),!1)},c.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(t){return new c("Deflate",t)},r.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,r){"use strict";function n(t,e){var r,n="";for(r=0;r<e;r++)n+=String.fromCharCode(255&t),t>>>=8;return n}function o(t,e,r,o,a,l){var f,h,d=t.file,p=t.compression,y=l!==s.utf8encode,g=i.transformTo("string",l(d.name)),m=i.transformTo("string",s.utf8encode(d.name)),v=d.comment,b=i.transformTo("string",l(v)),w=i.transformTo("string",s.utf8encode(v)),x=m.length!==d.name.length,_=w.length!==v.length,k="",E="",A="",S=d.dir,L=d.date,O={crc32:0,compressedSize:0,uncompressedSize:0};e&&!r||(O.crc32=t.crc32,O.compressedSize=t.compressedSize,O.uncompressedSize=t.uncompressedSize);var P=0;e&&(P|=8),y||!x&&!_||(P|=2048);var T=0,C=0;S&&(T|=16),"UNIX"===a?(C=798,T|=function(t,e){var r=t;return t||(r=e?16893:33204),(65535&r)<<16}(d.unixPermissions,S)):(C=20,T|=function(t){return 63&(t||0)}(d.dosPermissions)),f=L.getUTCHours(),f<<=6,f|=L.getUTCMinutes(),f<<=5,f|=L.getUTCSeconds()/2,h=L.getUTCFullYear()-1980,h<<=4,h|=L.getUTCMonth()+1,h<<=5,h|=L.getUTCDate(),x&&(E=n(1,1)+n(c(g),4)+m,k+="up"+n(E.length,2)+E),_&&(A=n(1,1)+n(c(b),4)+w,k+="uc"+n(A.length,2)+A);var M="";return M+="\n\0",M+=n(P,2),M+=p.magic,M+=n(f,2),M+=n(h,2),M+=n(O.crc32,4),M+=n(O.compressedSize,4),M+=n(O.uncompressedSize,4),M+=n(g.length,2),M+=n(k.length,2),{fileRecord:u.LOCAL_FILE_HEADER+M+g+k,dirRecord:u.CENTRAL_FILE_HEADER+n(C,2)+M+n(b.length,2)+"\0\0\0\0"+n(T,4)+n(o,4)+g+k+b}}var i=t("../utils"),a=t("../stream/GenericWorker"),s=t("../utf8"),c=t("../crc32"),u=t("../signature");function l(t,e,r,n){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(l,a),l.prototype.push=function(t){var e=t.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,a.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:r?(e+100*(r-n-1))/r:100}}))},l.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var r=o(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},l.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,r=o(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),e)this.push({data:function(t){return u.DATA_DESCRIPTOR+n(t.crc32,4)+n(t.compressedSize,4)+n(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},l.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e<this.dirRecords.length;e++)this.push({data:this.dirRecords[e],meta:{percent:100}});var r=this.bytesWritten-t,o=function(t,e,r,o,a){var s=i.transformTo("string",a(o));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(t,2)+n(t,2)+n(e,4)+n(r,4)+n(s.length,2)+s}(this.dirRecords.length,r,t,this.zipComment,this.encodeFileName);this.push({data:o,meta:{percent:100}})},l.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},l.prototype.registerPrevious=function(t){this._sources.push(t);var e=this;return t.on("data",(function(t){e.processChunk(t)})),t.on("end",(function(){e.closedSource(e.previous.streamInfo),e._sources.length?e.prepareNextSource():e.end()})),t.on("error",(function(t){e.error(t)})),this},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},l.prototype.error=function(t){var e=this._sources;if(!a.prototype.error.call(this,t))return!1;for(var r=0;r<e.length;r++)try{e[r].error(t)}catch(t){}return!0},l.prototype.lock=function(){a.prototype.lock.call(this);for(var t=this._sources,e=0;e<t.length;e++)t[e].lock()},e.exports=l},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,e,r){"use strict";var n=t("../compressions"),o=t("./ZipFileWorker");r.generateWorker=function(t,e,r){var i=new o(e.streamFiles,r,e.platform,e.encodeFileName),a=0;try{t.forEach((function(t,r){a++;var o=function(t,e){var r=t||e,o=n[r];if(!o)throw new Error(r+" is not a valid compression method !");return o}(r.options.compression,e.compression),s=r.options.compressionOptions||e.compressionOptions||{},c=r.dir,u=r.date;r._compressWorker(o,s).withStreamInfo("file",{name:t,dir:c,date:u,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(i)})),i.entriesCount=a}catch(t){i.error(t)}return i}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,e,r){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var t=new n;for(var e in this)"function"!=typeof this[e]&&(t[e]=this[e]);return t}}(n.prototype=t("./object")).loadAsync=t("./load"),n.support=t("./support"),n.defaults=t("./defaults"),n.version="3.7.1",n.loadAsync=function(t,e){return(new n).loadAsync(t,e)},n.external=t("./external"),e.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,e,r){"use strict";var n=t("./utils"),o=t("./external"),i=t("./utf8"),a=t("./zipEntries"),s=t("./stream/Crc32Probe"),c=t("./nodejsUtils");function u(t){return new o.Promise((function(e,r){var n=t.decompressed.getContentWorker().pipe(new s);n.on("error",(function(t){r(t)})).on("end",(function(){n.streamInfo.crc32!==t.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):e()})).resume()}))}e.exports=function(t,e){var r=this;return e=n.extend(e||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),c.isNode&&c.isStream(t)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",t,!0,e.optimizedBinaryString,e.base64).then((function(t){var r=new a(e);return r.load(t),r})).then((function(t){var r=[o.Promise.resolve(t)],n=t.files;if(e.checkCRC32)for(var i=0;i<n.length;i++)r.push(u(n[i]));return o.Promise.all(r)})).then((function(t){for(var n=t.shift(),o=n.files,i=0;i<o.length;i++){var a=o[i];r.file(a.fileNameStr,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:e.createFolders})}return n.zipComment.length&&(r.comment=n.zipComment),r}))}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,e,r){"use strict";var n=t("../utils"),o=t("../stream/GenericWorker");function i(t,e){o.call(this,"Nodejs stream input adapter for "+t),this._upstreamEnded=!1,this._bindStream(e)}n.inherits(i,o),i.prototype._bindStream=function(t){var e=this;(this._stream=t).pause(),t.on("data",(function(t){e.push({data:t,meta:{percent:0}})})).on("error",(function(t){e.isPaused?this.generatedError=t:e.error(t)})).on("end",(function(){e.isPaused?e._upstreamEnded=!0:e.end()}))},i.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},e.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,e,r){"use strict";var n=t("readable-stream").Readable;function o(t,e,r){n.call(this,e),this._helper=t;var o=this;t.on("data",(function(t,e){o.push(t)||o._helper.pause(),r&&r(e)})).on("error",(function(t){o.emit("error",t)})).on("end",(function(){o.push(null)}))}t("../utils").inherits(o,n),o.prototype._read=function(){this._helper.resume()},e.exports=o},{"../utils":32,"readable-stream":16}],14:[function(t,e,r){"use strict";e.exports={isNode:void 0!==n,newBufferFrom:function(t,e){if(n.from&&n.from!==Uint8Array.from)return n.from(t,e);if("number"==typeof t)throw new Error('The "data" argument must not be a number');return new n(t,e)},allocBuffer:function(t){if(n.alloc)return n.alloc(t);var e=new n(t);return e.fill(0),e},isBuffer:function(t){return n.isBuffer(t)},isStream:function(t){return t&&"function"==typeof t.on&&"function"==typeof t.pause&&"function"==typeof t.resume}}},{}],15:[function(t,e,r){"use strict";function n(t,e,r){var n,o=i.getTypeOf(e),s=i.extend(r||{},c);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(t=y(t)),s.createFolders&&(n=p(t))&&g.call(this,n,!0);var f="string"===o&&!1===s.binary&&!1===s.base64;r&&void 0!==r.binary||(s.binary=!f),(e instanceof u&&0===e.uncompressedSize||s.dir||!e||0===e.length)&&(s.base64=!1,s.binary=!0,e="",s.compression="STORE",o="string");var m;m=e instanceof u||e instanceof a?e:h.isNode&&h.isStream(e)?new d(t,e):i.prepareContent(t,e,s.binary,s.optimizedBinaryString,s.base64);var v=new l(t,m,s);this.files[t]=v}var o=t("./utf8"),i=t("./utils"),a=t("./stream/GenericWorker"),s=t("./stream/StreamHelper"),c=t("./defaults"),u=t("./compressedObject"),l=t("./zipObject"),f=t("./generate"),h=t("./nodejsUtils"),d=t("./nodejs/NodejsStreamInputAdapter"),p=function(t){"/"===t.slice(-1)&&(t=t.substring(0,t.length-1));var e=t.lastIndexOf("/");return 0<e?t.substring(0,e):""},y=function(t){return"/"!==t.slice(-1)&&(t+="/"),t},g=function(t,e){return e=void 0!==e?e:c.createFolders,t=y(t),this.files[t]||n.call(this,t,null,{dir:!0,createFolders:e}),this.files[t]};function m(t){return"[object RegExp]"===Object.prototype.toString.call(t)}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(t){var e,r,n;for(e in this.files)n=this.files[e],(r=e.slice(this.root.length,e.length))&&e.slice(0,this.root.length)===this.root&&t(r,n)},filter:function(t){var e=[];return this.forEach((function(r,n){t(r,n)&&e.push(n)})),e},file:function(t,e,r){if(1!==arguments.length)return t=this.root+t,n.call(this,t,e,r),this;if(m(t)){var o=t;return this.filter((function(t,e){return!e.dir&&o.test(t)}))}var i=this.files[this.root+t];return i&&!i.dir?i:null},folder:function(t){if(!t)return this;if(m(t))return this.filter((function(e,r){return r.dir&&t.test(e)}));var e=this.root+t,r=g.call(this,e),n=this.clone();return n.root=r.name,n},remove:function(t){t=this.root+t;var e=this.files[t];if(e||("/"!==t.slice(-1)&&(t+="/"),e=this.files[t]),e&&!e.dir)delete this.files[t];else for(var r=this.filter((function(e,r){return r.name.slice(0,t.length)===t})),n=0;n<r.length;n++)delete this.files[r[n].name];return this},generate:function(t){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(t){var e,r={};try{if((r=i.extend(t||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");i.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";e=f.generateWorker(this,r,n)}catch(t){(e=new a("error")).error(t)}return new s(e,r.type||"string",r.mimeType)},generateAsync:function(t,e){return this.generateInternalStream(t).accumulate(e)},generateNodeStream:function(t,e){return(t=t||{}).type||(t.type="nodebuffer"),this.generateInternalStream(t).toNodejsStream(e)}};e.exports=v},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,e,r){e.exports=t("stream")},{stream:void 0}],17:[function(t,e,r){"use strict";var n=t("./DataReader");function o(t){n.call(this,t);for(var e=0;e<this.data.length;e++)t[e]=255&t[e]}t("../utils").inherits(o,n),o.prototype.byteAt=function(t){return this.data[this.zero+t]},o.prototype.lastIndexOfSignature=function(t){for(var e=t.charCodeAt(0),r=t.charCodeAt(1),n=t.charCodeAt(2),o=t.charCodeAt(3),i=this.length-4;0<=i;--i)if(this.data[i]===e&&this.data[i+1]===r&&this.data[i+2]===n&&this.data[i+3]===o)return i-this.zero;return-1},o.prototype.readAndCheckSignature=function(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),n=t.charCodeAt(2),o=t.charCodeAt(3),i=this.readData(4);return e===i[0]&&r===i[1]&&n===i[2]&&o===i[3]},o.prototype.readData=function(t){if(this.checkOffset(t),0===t)return[];var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=o},{"../utils":32,"./DataReader":18}],18:[function(t,e,r){"use strict";var n=t("../utils");function o(t){this.data=t,this.length=t.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(t){this.checkIndex(this.index+t)},checkIndex:function(t){if(this.length<this.zero+t||t<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+t+"). Corrupted zip ?")},setIndex:function(t){this.checkIndex(t),this.index=t},skip:function(t){this.setIndex(this.index+t)},byteAt:function(t){},readInt:function(t){var e,r=0;for(this.checkOffset(t),e=this.index+t-1;e>=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},readString:function(t){return n.transformTo("string",this.readData(t))},readData:function(t){},lastIndexOfSignature:function(t){},readAndCheckSignature:function(t){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=o},{"../utils":32}],19:[function(t,e,r){"use strict";var n=t("./Uint8ArrayReader");function o(t){n.call(this,t)}t("../utils").inherits(o,n),o.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,r){"use strict";var n=t("./DataReader");function o(t){n.call(this,t)}t("../utils").inherits(o,n),o.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},o.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},o.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},o.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,e,r){"use strict";var n=t("./ArrayReader");function o(t){n.call(this,t)}t("../utils").inherits(o,n),o.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,r){"use strict";var n=t("../utils"),o=t("../support"),i=t("./ArrayReader"),a=t("./StringReader"),s=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");e.exports=function(t){var e=n.getTypeOf(t);return n.checkSupport(e),"string"!==e||o.uint8array?"nodebuffer"===e?new s(t):o.uint8array?new c(n.transformTo("uint8array",t)):new i(n.transformTo("array",t)):new a(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,r){"use strict";var n=t("./GenericWorker"),o=t("../utils");function i(t){n.call(this,"ConvertWorker to "+t),this.destType=t}o.inherits(i,n),i.prototype.processChunk=function(t){this.push({data:o.transformTo(this.destType,t.data),meta:t.meta})},e.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,r){"use strict";var n=t("./GenericWorker"),o=t("../crc32");function i(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(i,n),i.prototype.processChunk=function(t){this.streamInfo.crc32=o(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,r){"use strict";var n=t("../utils"),o=t("./GenericWorker");function i(t){o.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}n.inherits(i,o),i.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}o.prototype.processChunk.call(this,t)},e.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,r){"use strict";var n=t("../utils"),o=t("./GenericWorker");function i(t){o.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=n.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}n.inherits(i,o),i.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,r){"use strict";function n(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var r=0;r<this._listeners[t].length;r++)this._listeners[t][r].call(this,e)},pipe:function(t){return t.registerPrevious(this)},registerPrevious:function(t){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=t.streamInfo,this.mergeStreamInfo(),this.previous=t;var e=this;return t.on("data",(function(t){e.processChunk(t)})),t.on("end",(function(){e.end()})),t.on("error",(function(t){e.error(t)})),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var t=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),t=!0),this.previous&&this.previous.resume(),!t},flush:function(){},processChunk:function(t){this.push(t)},withStreamInfo:function(t,e){return this.extraStreamInfo[t]=e,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var t in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(t)&&(this.streamInfo[t]=this.extraStreamInfo[t])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var t="Worker "+this.name;return this.previous?this.previous+" -> "+t:t}},e.exports=n},{}],29:[function(t,e,r){"use strict";var o=t("../utils"),i=t("./ConvertWorker"),a=t("./GenericWorker"),s=t("../base64"),c=t("../support"),u=t("../external"),l=null;if(c.nodestream)try{l=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function f(t,e,r){var n=e;switch(e){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=e,this._mimeType=r,o.checkSupport(n),this._worker=t.pipe(new i(n)),t.lock()}catch(t){this._worker=new a("error"),this._worker.error(t)}}f.prototype={accumulate:function(t){return function(t,e){return new u.Promise((function(r,i){var a=[],c=t._internalType,u=t._outputType,l=t._mimeType;t.on("data",(function(t,r){a.push(t),e&&e(r)})).on("error",(function(t){a=[],i(t)})).on("end",(function(){try{var t=function(t,e,r){switch(t){case"blob":return o.newBlob(o.transformTo("arraybuffer",e),r);case"base64":return s.encode(e);default:return o.transformTo(t,e)}}(u,function(t,e){var r,o=0,i=null,a=0;for(r=0;r<e.length;r++)a+=e[r].length;switch(t){case"string":return e.join("");case"array":return Array.prototype.concat.apply([],e);case"uint8array":for(i=new Uint8Array(a),r=0;r<e.length;r++)i.set(e[r],o),o+=e[r].length;return i;case"nodebuffer":return n.concat(e);default:throw new Error("concat : unsupported type '"+t+"'")}}(c,a),l);r(t)}catch(t){i(t)}a=[]})).resume()}))}(this,t)},on:function(t,e){var r=this;return"data"===t?this._worker.on(t,(function(t){e.call(r,t.data,t.meta)})):this._worker.on(t,(function(){o.delay(e,arguments,r)})),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(t){if(o.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new l(this,{objectMode:"nodebuffer"!==this._outputType},t)}},e.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,e,r){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer=void 0!==n,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var o=new ArrayBuffer(0);try{r.blob=0===new Blob([o],{type:"application/zip"}).size}catch(t){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(o),r.blob=0===i.getBlob("application/zip").size}catch(t){r.blob=!1}}}try{r.nodestream=!!t("readable-stream").Readable}catch(t){r.nodestream=!1}},{"readable-stream":16}],31:[function(t,e,r){"use strict";for(var n=t("./utils"),o=t("./support"),i=t("./nodejsUtils"),a=t("./stream/GenericWorker"),s=new Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(){a.call(this,"utf-8 decode"),this.leftOver=null}function l(){a.call(this,"utf-8 encode")}s[254]=s[254]=1,r.utf8encode=function(t){return o.nodebuffer?i.newBufferFrom(t,"utf-8"):function(t){var e,r,n,i,a,s=t.length,c=0;for(i=0;i<s;i++)55296==(64512&(r=t.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=t.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),c+=r<128?1:r<2048?2:r<65536?3:4;for(e=o.uint8array?new Uint8Array(c):new Array(c),i=a=0;a<c;i++)55296==(64512&(r=t.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=t.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?e[a++]=r:(r<2048?e[a++]=192|r>>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e}(t)},r.utf8decode=function(t){return o.nodebuffer?n.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,r,o,i,a=t.length,c=new Array(2*a);for(e=r=0;e<a;)if((o=t[e++])<128)c[r++]=o;else if(4<(i=s[o]))c[r++]=65533,e+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&e<a;)o=o<<6|63&t[e++],i--;1<i?c[r++]=65533:o<65536?c[r++]=o:(o-=65536,c[r++]=55296|o>>10&1023,c[r++]=56320|1023&o)}return c.length!==r&&(c.subarray?c=c.subarray(0,r):c.length=r),n.applyFromCharCode(c)}(t=n.transformTo(o.uint8array?"uint8array":"array",t))},n.inherits(u,a),u.prototype.processChunk=function(t){var e=n.transformTo(o.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var i=e;(e=new Uint8Array(i.length+this.leftOver.length)).set(this.leftOver,0),e.set(i,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var a=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+s[t[r]]>e?r:e}(e),c=e;a!==e.length&&(o.uint8array?(c=e.subarray(0,a),this.leftOver=e.subarray(a,e.length)):(c=e.slice(0,a),this.leftOver=e.slice(a,e.length))),this.push({data:r.utf8decode(c),meta:t.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,n.inherits(l,a),l.prototype.processChunk=function(t){this.push({data:r.utf8encode(t.data),meta:t.meta})},r.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,r){"use strict";var n=t("./support"),o=t("./base64"),i=t("./nodejsUtils"),a=t("set-immediate-shim"),s=t("./external");function c(t){return t}function u(t,e){for(var r=0;r<t.length;++r)e[r]=255&t.charCodeAt(r);return e}r.newBlob=function(t,e){r.checkSupport("blob");try{return new Blob([t],{type:e})}catch(r){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(e)}catch(t){throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(t,e,r){var n=[],o=0,i=t.length;if(i<=r)return String.fromCharCode.apply(null,t);for(;o<i;)"array"===e||"nodebuffer"===e?n.push(String.fromCharCode.apply(null,t.slice(o,Math.min(o+r,i)))):n.push(String.fromCharCode.apply(null,t.subarray(o,Math.min(o+r,i)))),o+=r;return n.join("")},stringifyByChar:function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(t){return!1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,i.allocBuffer(1)).length}catch(t){return!1}}()}};function f(t){var e=65536,n=r.getTypeOf(t),o=!0;if("uint8array"===n?o=l.applyCanBeUsed.uint8array:"nodebuffer"===n&&(o=l.applyCanBeUsed.nodebuffer),o)for(;1<e;)try{return l.stringifyByChunk(t,n,e)}catch(t){e=Math.floor(e/2)}return l.stringifyByChar(t)}function h(t,e){for(var r=0;r<t.length;r++)e[r]=t[r];return e}r.applyFromCharCode=f;var d={};d.string={string:c,array:function(t){return u(t,new Array(t.length))},arraybuffer:function(t){return d.string.uint8array(t).buffer},uint8array:function(t){return u(t,new Uint8Array(t.length))},nodebuffer:function(t){return u(t,i.allocBuffer(t.length))}},d.array={string:f,array:c,arraybuffer:function(t){return new Uint8Array(t).buffer},uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return i.newBufferFrom(t)}},d.arraybuffer={string:function(t){return f(new Uint8Array(t))},array:function(t){return h(new Uint8Array(t),new Array(t.byteLength))},arraybuffer:c,uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return i.newBufferFrom(new Uint8Array(t))}},d.uint8array={string:f,array:function(t){return h(t,new Array(t.length))},arraybuffer:function(t){return t.buffer},uint8array:c,nodebuffer:function(t){return i.newBufferFrom(t)}},d.nodebuffer={string:f,array:function(t){return h(t,new Array(t.length))},arraybuffer:function(t){return d.nodebuffer.uint8array(t).buffer},uint8array:function(t){return h(t,new Uint8Array(t.length))},nodebuffer:c},r.transformTo=function(t,e){if(e=e||"",!t)return e;r.checkSupport(t);var n=r.getTypeOf(e);return d[n][t](e)},r.getTypeOf=function(t){return"string"==typeof t?"string":"[object Array]"===Object.prototype.toString.call(t)?"array":n.nodebuffer&&i.isBuffer(t)?"nodebuffer":n.uint8array&&t instanceof Uint8Array?"uint8array":n.arraybuffer&&t instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(t){if(!n[t.toLowerCase()])throw new Error(t+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(t){var e,r,n="";for(r=0;r<(t||"").length;r++)n+="\\x"+((e=t.charCodeAt(r))<16?"0":"")+e.toString(16).toUpperCase();return n},r.delay=function(t,e,r){a((function(){t.apply(r||null,e||[])}))},r.inherits=function(t,e){function r(){}r.prototype=e.prototype,t.prototype=new r},r.extend=function(){var t,e,r={};for(t=0;t<arguments.length;t++)for(e in arguments[t])arguments[t].hasOwnProperty(e)&&void 0===r[e]&&(r[e]=arguments[t][e]);return r},r.prepareContent=function(t,e,i,a,c){return s.Promise.resolve(e).then((function(t){return n.blob&&(t instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(t)))&&"undefined"!=typeof FileReader?new s.Promise((function(e,r){var n=new FileReader;n.onload=function(t){e(t.target.result)},n.onerror=function(t){r(t.target.error)},n.readAsArrayBuffer(t)})):t})).then((function(e){var l=r.getTypeOf(e);return l?("arraybuffer"===l?e=r.transformTo("uint8array",e):"string"===l&&(c?e=o.decode(e):i&&!0!==a&&(e=function(t){return u(t,n.uint8array?new Uint8Array(t.length):new Array(t.length))}(e))),e):s.Promise.reject(new Error("Can't read the data of '"+t+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"set-immediate-shim":54}],33:[function(t,e,r){"use strict";var n=t("./reader/readerFor"),o=t("./utils"),i=t("./signature"),a=t("./zipEntry"),s=(t("./utf8"),t("./support"));function c(t){this.files=[],this.loadOptions=t}c.prototype={checkSignature:function(t){if(!this.reader.readAndCheckSignature(t)){this.reader.index-=4;var e=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(e)+", expected "+o.pretty(t)+")")}},isSignature:function(t,e){var r=this.reader.index;this.reader.setIndex(t);var n=this.reader.readString(4)===e;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var t=this.reader.readData(this.zipCommentLength),e=s.uint8array?"uint8array":"array",r=o.transformTo(e,t);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var t,e,r,n=this.zip64EndOfCentralSize-44;0<n;)t=this.reader.readInt(2),e=this.reader.readInt(4),r=this.reader.readData(e),this.zip64ExtensibleData[t]={id:t,length:e,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var t,e;for(t=0;t<this.files.length;t++)e=this.files[t],this.reader.setIndex(e.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),e.readLocalPart(this.reader),e.handleUTF8(),e.processAttributes()},readCentralDir:function(){var t;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(t=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(t);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var t=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(t<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(t);var e=t;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(t=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(t),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=e-r;if(0<n)this.isSignature(e,i.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(t){this.reader=n(t)},load:function(t){this.prepareReader(t),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},e.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(t,e,r){"use strict";var n=t("./reader/readerFor"),o=t("./utils"),i=t("./compressedObject"),a=t("./crc32"),s=t("./utf8"),c=t("./compressions"),u=t("./support");function l(t,e){this.options=t,this.loadOptions=e}l.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(t){var e,r;if(t.skip(22),this.fileNameLength=t.readInt(2),r=t.readInt(2),this.fileName=t.readData(this.fileNameLength),t.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(e=function(t){for(var e in c)if(c.hasOwnProperty(e)&&c[e].magic===t)return c[e];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,e,t.readData(this.compressedSize))},readCentralPart:function(t){this.versionMadeBy=t.readInt(2),t.skip(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4);var e=t.readInt(2);if(this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");t.skip(e),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var t=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(t){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(t){var e,r,n,o=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4<o;)e=t.readInt(2),r=t.readInt(2),n=t.readData(r),this.extraFields[e]={id:e,length:r,value:n};t.setIndex(o)},handleUTF8:function(){var t=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=s.utf8decode(this.fileName),this.fileCommentStr=s.utf8decode(this.fileComment);else{var e=this.findExtraFieldUnicodePath();if(null!==e)this.fileNameStr=e;else{var r=o.transformTo(t,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=o.transformTo(t,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var t=this.extraFields[28789];if(t){var e=n(t.value);return 1!==e.readInt(1)||a(this.fileName)!==e.readInt(4)?null:s.utf8decode(e.readData(t.length-5))}return null},findExtraFieldUnicodeComment:function(){var t=this.extraFields[25461];if(t){var e=n(t.value);return 1!==e.readInt(1)||a(this.fileComment)!==e.readInt(4)?null:s.utf8decode(e.readData(t.length-5))}return null}},e.exports=l},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,e,r){"use strict";function n(t,e,r){this.name=t,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=e,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var o=t("./stream/StreamHelper"),i=t("./stream/DataWorker"),a=t("./utf8"),s=t("./compressedObject"),c=t("./stream/GenericWorker");n.prototype={internalStream:function(t){var e=null,r="string";try{if(!t)throw new Error("No output type specified.");var n="string"===(r=t.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),e=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(e=e.pipe(new a.Utf8EncodeWorker)),!i&&n&&(e=e.pipe(new a.Utf8DecodeWorker))}catch(t){(e=new c("error")).error(t)}return new o(e,r,"")},async:function(t,e){return this.internalStream(t).accumulate(e)},nodeStream:function(t,e){return this.internalStream(t||"nodebuffer").toNodejsStream(e)},_compressWorker:function(t,e){if(this._data instanceof s&&this._data.compression.magic===t.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new a.Utf8EncodeWorker)),s.createWorkerFrom(r,t,e)},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof c?this._data:new i(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],l=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)n.prototype[u[f]]=l;e.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,e,n){(function(t){"use strict";var r,n,o=t.MutationObserver||t.WebKitMutationObserver;if(o){var i=0,a=new o(l),s=t.document.createTextNode("");a.observe(s,{characterData:!0}),r=function(){s.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){l(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(l,0)};else{var c=new t.MessageChannel;c.port1.onmessage=l,r=function(){c.port2.postMessage(0)}}var u=[];function l(){var t,e;n=!0;for(var r=u.length;r;){for(e=u,u=[],t=-1;++t<r;)e[t]();r=u.length}n=!1}e.exports=function(t){1!==u.push(t)||n||r()}}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(t,e,r){"use strict";var n=t("immediate");function o(){}var i={},a=["REJECTED"],s=["FULFILLED"],c=["PENDING"];function u(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,t!==o&&d(this,t)}function l(t,e,r){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function f(t,e,r){n((function(){var n;try{n=e(r)}catch(n){return i.reject(t,n)}n===t?i.reject(t,new TypeError("Cannot resolve promise with itself")):i.resolve(t,n)}))}function h(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function d(t,e){var r=!1;function n(e){r||(r=!0,i.reject(t,e))}function o(e){r||(r=!0,i.resolve(t,e))}var a=p((function(){e(o,n)}));"error"===a.status&&n(a.value)}function p(t,e){var r={};try{r.value=t(e),r.status="success"}catch(t){r.status="error",r.value=t}return r}(e.exports=u).prototype.finally=function(t){if("function"!=typeof t)return this;var e=this.constructor;return this.then((function(r){return e.resolve(t()).then((function(){return r}))}),(function(r){return e.resolve(t()).then((function(){throw r}))}))},u.prototype.catch=function(t){return this.then(null,t)},u.prototype.then=function(t,e){if("function"!=typeof t&&this.state===s||"function"!=typeof e&&this.state===a)return this;var r=new this.constructor(o);return this.state!==c?f(r,this.state===s?t:e,this.outcome):this.queue.push(new l(r,t,e)),r},l.prototype.callFulfilled=function(t){i.resolve(this.promise,t)},l.prototype.otherCallFulfilled=function(t){f(this.promise,this.onFulfilled,t)},l.prototype.callRejected=function(t){i.reject(this.promise,t)},l.prototype.otherCallRejected=function(t){f(this.promise,this.onRejected,t)},i.resolve=function(t,e){var r=p(h,e);if("error"===r.status)return i.reject(t,r.value);var n=r.value;if(n)d(t,n);else{t.state=s,t.outcome=e;for(var o=-1,a=t.queue.length;++o<a;)t.queue[o].callFulfilled(e)}return t},i.reject=function(t,e){t.state=a,t.outcome=e;for(var r=-1,n=t.queue.length;++r<n;)t.queue[r].callRejected(e);return t},u.resolve=function(t){return t instanceof this?t:i.resolve(new this(o),t)},u.reject=function(t){var e=new this(o);return i.reject(e,t)},u.all=function(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var r=t.length,n=!1;if(!r)return this.resolve([]);for(var a=new Array(r),s=0,c=-1,u=new this(o);++c<r;)l(t[c],c);return u;function l(t,o){e.resolve(t).then((function(t){a[o]=t,++s!==r||n||(n=!0,i.resolve(u,a))}),(function(t){n||(n=!0,i.reject(u,t))}))}},u.race=function(t){if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var e=t.length,r=!1;if(!e)return this.resolve([]);for(var n,a=-1,s=new this(o);++a<e;)n=t[a],this.resolve(n).then((function(t){r||(r=!0,i.resolve(s,t))}),(function(t){r||(r=!0,i.reject(s,t))}));return s}},{immediate:36}],38:[function(t,e,r){"use strict";var n={};(0,t("./lib/utils/common").assign)(n,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),e.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,e,r){"use strict";var n=t("./zlib/deflate"),o=t("./utils/common"),i=t("./utils/strings"),a=t("./zlib/messages"),s=t("./zlib/zstream"),c=Object.prototype.toString;function u(t){if(!(this instanceof u))return new u(t);this.options=o.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&0<e.windowBits?e.windowBits=-e.windowBits:e.gzip&&0<e.windowBits&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=n.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==r)throw new Error(a[r]);if(e.header&&n.deflateSetHeader(this.strm,e.header),e.dictionary){var l;if(l="string"==typeof e.dictionary?i.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(r=n.deflateSetDictionary(this.strm,l)))throw new Error(a[r]);this._dict_set=!0}}function l(t,e){var r=new u(e);if(r.push(t,!0),r.err)throw r.msg||a[r.err];return r.result}u.prototype.push=function(t,e){var r,a,s=this.strm,u=this.options.chunkSize;if(this.ended)return!1;a=e===~~e?e:!0===e?4:0,"string"==typeof t?s.input=i.string2buf(t):"[object ArrayBuffer]"===c.call(t)?s.input=new Uint8Array(t):s.input=t,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new o.Buf8(u),s.next_out=0,s.avail_out=u),1!==(r=n.deflate(s,a))&&0!==r)return this.onEnd(r),!(this.ended=!0);0!==s.avail_out&&(0!==s.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(i.buf2binstring(o.shrinkBuf(s.output,s.next_out))):this.onData(o.shrinkBuf(s.output,s.next_out)))}while((0<s.avail_in||0===s.avail_out)&&1!==r);return 4===a?(r=n.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==a||(this.onEnd(0),!(s.avail_out=0))},u.prototype.onData=function(t){this.chunks.push(t)},u.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},r.Deflate=u,r.deflate=l,r.deflateRaw=function(t,e){return(e=e||{}).raw=!0,l(t,e)},r.gzip=function(t,e){return(e=e||{}).gzip=!0,l(t,e)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,e,r){"use strict";var n=t("./zlib/inflate"),o=t("./utils/common"),i=t("./utils/strings"),a=t("./zlib/constants"),s=t("./zlib/messages"),c=t("./zlib/zstream"),u=t("./zlib/gzheader"),l=Object.prototype.toString;function f(t){if(!(this instanceof f))return new f(t);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&0<=e.windowBits&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(0<=e.windowBits&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),15<e.windowBits&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var r=n.inflateInit2(this.strm,e.windowBits);if(r!==a.Z_OK)throw new Error(s[r]);this.header=new u,n.inflateGetHeader(this.strm,this.header)}function h(t,e){var r=new f(e);if(r.push(t,!0),r.err)throw r.msg||s[r.err];return r.result}f.prototype.push=function(t,e){var r,s,c,u,f,h,d=this.strm,p=this.options.chunkSize,y=this.options.dictionary,g=!1;if(this.ended)return!1;s=e===~~e?e:!0===e?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof t?d.input=i.binstring2buf(t):"[object ArrayBuffer]"===l.call(t)?d.input=new Uint8Array(t):d.input=t,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new o.Buf8(p),d.next_out=0,d.avail_out=p),(r=n.inflate(d,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&y&&(h="string"==typeof y?i.string2buf(y):"[object ArrayBuffer]"===l.call(y)?new Uint8Array(y):y,r=n.inflateSetDictionary(this.strm,h)),r===a.Z_BUF_ERROR&&!0===g&&(r=a.Z_OK,g=!1),r!==a.Z_STREAM_END&&r!==a.Z_OK)return this.onEnd(r),!(this.ended=!0);d.next_out&&(0!==d.avail_out&&r!==a.Z_STREAM_END&&(0!==d.avail_in||s!==a.Z_FINISH&&s!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(c=i.utf8border(d.output,d.next_out),u=d.next_out-c,f=i.buf2string(d.output,c),d.next_out=u,d.avail_out=p-u,u&&o.arraySet(d.output,d.output,c,u,0),this.onData(f)):this.onData(o.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(g=!0)}while((0<d.avail_in||0===d.avail_out)&&r!==a.Z_STREAM_END);return r===a.Z_STREAM_END&&(s=a.Z_FINISH),s===a.Z_FINISH?(r=n.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===a.Z_OK):s!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(d.avail_out=0))},f.prototype.onData=function(t){this.chunks.push(t)},f.prototype.onEnd=function(t){t===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},r.Inflate=f,r.inflate=h,r.inflateRaw=function(t,e){return(e=e||{}).raw=!0,h(t,e)},r.ungzip=h},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,e,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])}}return t},r.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var o={arraySet:function(t,e,r,n,o){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),o);else for(var i=0;i<n;i++)t[o+i]=e[r+i]},flattenChunks:function(t){var e,r,n,o,i,a;for(e=n=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),e=o=0,r=t.length;e<r;e++)i=t[e],a.set(i,o),o+=i.length;return a}},i={arraySet:function(t,e,r,n,o){for(var i=0;i<n;i++)t[o+i]=e[r+i]},flattenChunks:function(t){return[].concat.apply([],t)}};r.setTyped=function(t){t?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,o)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,i))},r.setTyped(n)},{}],42:[function(t,e,r){"use strict";var n=t("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(t){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){i=!1}for(var a=new n.Buf8(256),s=0;s<256;s++)a[s]=252<=s?6:248<=s?5:240<=s?4:224<=s?3:192<=s?2:1;function c(t,e){if(e<65537&&(t.subarray&&i||!t.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(t,e));for(var r="",a=0;a<e;a++)r+=String.fromCharCode(t[a]);return r}a[254]=a[254]=1,r.string2buf=function(t){var e,r,o,i,a,s=t.length,c=0;for(i=0;i<s;i++)55296==(64512&(r=t.charCodeAt(i)))&&i+1<s&&56320==(64512&(o=t.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(o-56320),i++),c+=r<128?1:r<2048?2:r<65536?3:4;for(e=new n.Buf8(c),i=a=0;a<c;i++)55296==(64512&(r=t.charCodeAt(i)))&&i+1<s&&56320==(64512&(o=t.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(o-56320),i++),r<128?e[a++]=r:(r<2048?e[a++]=192|r>>>6:(r<65536?e[a++]=224|r>>>12:(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63),e[a++]=128|r>>>6&63),e[a++]=128|63&r);return e},r.buf2binstring=function(t){return c(t,t.length)},r.binstring2buf=function(t){for(var e=new n.Buf8(t.length),r=0,o=e.length;r<o;r++)e[r]=t.charCodeAt(r);return e},r.buf2string=function(t,e){var r,n,o,i,s=e||t.length,u=new Array(2*s);for(r=n=0;r<s;)if((o=t[r++])<128)u[n++]=o;else if(4<(i=a[o]))u[n++]=65533,r+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&r<s;)o=o<<6|63&t[r++],i--;1<i?u[n++]=65533:o<65536?u[n++]=o:(o-=65536,u[n++]=55296|o>>10&1023,u[n++]=56320|1023&o)}return c(u,n)},r.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0||0===r?e:r+a[t[r]]>e?r:e}},{"./common":41}],43:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){for(var o=65535&t|0,i=t>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3<r?2e3:r;i=i+(o=o+e[n++]|0)|0,--a;);o%=65521,i%=65521}return o|i<<16|0}},{}],44:[function(t,e,r){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,e,r){"use strict";var n=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e,r,o){var i=n,a=o+r;t^=-1;for(var s=o;s<a;s++)t=t>>>8^i[255&(t^e[s])];return-1^t}},{}],46:[function(t,e,r){"use strict";var n,o=t("../utils/common"),i=t("./trees"),a=t("./adler32"),s=t("./crc32"),c=t("./messages"),u=-2,l=258,f=262,h=113;function d(t,e){return t.msg=c[e],e}function p(t){return(t<<1)-(4<t?9:0)}function y(t){for(var e=t.length;0<=--e;)t[e]=0}function g(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(o.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function m(t,e){i._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,g(t.strm)}function v(t,e){t.pending_buf[t.pending++]=e}function b(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function w(t,e){var r,n,o=t.max_chain_length,i=t.strstart,a=t.prev_length,s=t.nice_match,c=t.strstart>t.w_size-f?t.strstart-(t.w_size-f):0,u=t.window,h=t.w_mask,d=t.prev,p=t.strstart+l,y=u[i+a-1],g=u[i+a];t.prev_length>=t.good_match&&(o>>=2),s>t.lookahead&&(s=t.lookahead);do{if(u[(r=e)+a]===g&&u[r+a-1]===y&&u[r]===u[i]&&u[++r]===u[i+1]){i+=2,r++;do{}while(u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&u[++i]===u[++r]&&i<p);if(n=l-(p-i),i=p-l,a<n){if(t.match_start=e,s<=(a=n))break;y=u[i+a-1],g=u[i+a]}}}while((e=d[e&h])>c&&0!=--o);return a<=t.lookahead?a:t.lookahead}function x(t){var e,r,n,i,c,u,l,h,d,p,y=t.w_size;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=y+(y-f)){for(o.arraySet(t.window,t.window,y,y,0),t.match_start-=y,t.strstart-=y,t.block_start-=y,e=r=t.hash_size;n=t.head[--e],t.head[e]=y<=n?n-y:0,--r;);for(e=r=y;n=t.prev[--e],t.prev[e]=y<=n?n-y:0,--r;);i+=y}if(0===t.strm.avail_in)break;if(u=t.strm,l=t.window,h=t.strstart+t.lookahead,p=void 0,(d=i)<(p=u.avail_in)&&(p=d),r=0===p?0:(u.avail_in-=p,o.arraySet(l,u.input,u.next_in,p,h),1===u.state.wrap?u.adler=a(u.adler,l,p,h):2===u.state.wrap&&(u.adler=s(u.adler,l,p,h)),u.next_in+=p,u.total_in+=p,p),t.lookahead+=r,t.lookahead+t.insert>=3)for(c=t.strstart-t.insert,t.ins_h=t.window[c],t.ins_h=(t.ins_h<<t.hash_shift^t.window[c+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[c+3-1])&t.hash_mask,t.prev[c&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=c,c++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<f&&0!==t.strm.avail_in)}function _(t,e){for(var r,n;;){if(t.lookahead<f){if(x(t),t.lookahead<f&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-f&&(t.match_length=w(t,r)),t.match_length>=3)if(n=i._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,0!=--t.match_length;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=i._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(m(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(m(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(m(t,!1),0===t.strm.avail_out)?1:2}function k(t,e){for(var r,n,o;;){if(t.lookahead<f){if(x(t),t.lookahead<f&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-f&&(t.match_length=w(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&4096<t.strstart-t.match_start)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){for(o=t.strstart+t.lookahead-3,n=i._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=o&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!=--t.prev_length;);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(m(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=i._tr_tally(t,0,t.window[t.strstart-1]))&&m(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=i._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(m(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(m(t,!1),0===t.strm.avail_out)?1:2}function E(t,e,r,n,o){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=o}function A(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(1146),this.dyn_dtree=new o.Buf16(122),this.bl_tree=new o.Buf16(78),y(this.dyn_ltree),y(this.dyn_dtree),y(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(16),this.heap=new o.Buf16(573),y(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(573),y(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function S(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:h,t.adler=2===e.wrap?0:1,e.last_flush=0,i._tr_init(e),0):d(t,u)}function L(t){var e=S(t);return 0===e&&function(t){t.window_size=2*t.w_size,y(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function O(t,e,r,n,i,a){if(!t)return u;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):15<n&&(s=2,n-=16),i<1||9<i||8!==r||n<8||15<n||e<0||9<e||a<0||4<a)return d(t,u);8===n&&(n=9);var c=new A;return(t.state=c).strm=t,c.wrap=s,c.gzhead=null,c.w_bits=n,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=i+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new o.Buf8(2*c.w_size),c.head=new o.Buf16(c.hash_size),c.prev=new o.Buf16(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new o.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=e,c.strategy=a,c.method=r,L(t)}n=[new E(0,0,0,0,(function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(x(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,m(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-f&&(m(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(m(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(m(t,!1),t.strm.avail_out),1)})),new E(4,4,8,4,_),new E(4,5,16,8,_),new E(4,6,32,32,_),new E(4,4,16,16,k),new E(8,16,32,32,k),new E(8,16,128,128,k),new E(8,32,128,256,k),new E(32,128,258,1024,k),new E(32,258,258,4096,k)],r.deflateInit=function(t,e){return O(t,e,8,15,8,0)},r.deflateInit2=O,r.deflateReset=L,r.deflateResetKeep=S,r.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?u:(t.state.gzhead=e,0):u},r.deflate=function(t,e){var r,o,a,c;if(!t||!t.state||5<e||e<0)return t?d(t,u):u;if(o=t.state,!t.output||!t.input&&0!==t.avail_in||666===o.status&&4!==e)return d(t,0===t.avail_out?-5:u);if(o.strm=t,r=o.last_flush,o.last_flush=e,42===o.status)if(2===o.wrap)t.adler=0,v(o,31),v(o,139),v(o,8),o.gzhead?(v(o,(o.gzhead.text?1:0)+(o.gzhead.hcrc?2:0)+(o.gzhead.extra?4:0)+(o.gzhead.name?8:0)+(o.gzhead.comment?16:0)),v(o,255&o.gzhead.time),v(o,o.gzhead.time>>8&255),v(o,o.gzhead.time>>16&255),v(o,o.gzhead.time>>24&255),v(o,9===o.level?2:2<=o.strategy||o.level<2?4:0),v(o,255&o.gzhead.os),o.gzhead.extra&&o.gzhead.extra.length&&(v(o,255&o.gzhead.extra.length),v(o,o.gzhead.extra.length>>8&255)),o.gzhead.hcrc&&(t.adler=s(t.adler,o.pending_buf,o.pending,0)),o.gzindex=0,o.status=69):(v(o,0),v(o,0),v(o,0),v(o,0),v(o,0),v(o,9===o.level?2:2<=o.strategy||o.level<2?4:0),v(o,3),o.status=h);else{var f=8+(o.w_bits-8<<4)<<8;f|=(2<=o.strategy||o.level<2?0:o.level<6?1:6===o.level?2:3)<<6,0!==o.strstart&&(f|=32),f+=31-f%31,o.status=h,b(o,f),0!==o.strstart&&(b(o,t.adler>>>16),b(o,65535&t.adler)),t.adler=1}if(69===o.status)if(o.gzhead.extra){for(a=o.pending;o.gzindex<(65535&o.gzhead.extra.length)&&(o.pending!==o.pending_buf_size||(o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),g(t),a=o.pending,o.pending!==o.pending_buf_size));)v(o,255&o.gzhead.extra[o.gzindex]),o.gzindex++;o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),o.gzindex===o.gzhead.extra.length&&(o.gzindex=0,o.status=73)}else o.status=73;if(73===o.status)if(o.gzhead.name){a=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),g(t),a=o.pending,o.pending===o.pending_buf_size)){c=1;break}c=o.gzindex<o.gzhead.name.length?255&o.gzhead.name.charCodeAt(o.gzindex++):0,v(o,c)}while(0!==c);o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),0===c&&(o.gzindex=0,o.status=91)}else o.status=91;if(91===o.status)if(o.gzhead.comment){a=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),g(t),a=o.pending,o.pending===o.pending_buf_size)){c=1;break}c=o.gzindex<o.gzhead.comment.length?255&o.gzhead.comment.charCodeAt(o.gzindex++):0,v(o,c)}while(0!==c);o.gzhead.hcrc&&o.pending>a&&(t.adler=s(t.adler,o.pending_buf,o.pending-a,a)),0===c&&(o.status=103)}else o.status=103;if(103===o.status&&(o.gzhead.hcrc?(o.pending+2>o.pending_buf_size&&g(t),o.pending+2<=o.pending_buf_size&&(v(o,255&t.adler),v(o,t.adler>>8&255),t.adler=0,o.status=h)):o.status=h),0!==o.pending){if(g(t),0===t.avail_out)return o.last_flush=-1,0}else if(0===t.avail_in&&p(e)<=p(r)&&4!==e)return d(t,-5);if(666===o.status&&0!==t.avail_in)return d(t,-5);if(0!==t.avail_in||0!==o.lookahead||0!==e&&666!==o.status){var w=2===o.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(x(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=i._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(m(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(m(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(m(t,!1),0===t.strm.avail_out)?1:2}(o,e):3===o.strategy?function(t,e){for(var r,n,o,a,s=t.window;;){if(t.lookahead<=l){if(x(t),t.lookahead<=l&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&0<t.strstart&&(n=s[o=t.strstart-1])===s[++o]&&n===s[++o]&&n===s[++o]){a=t.strstart+l;do{}while(n===s[++o]&&n===s[++o]&&n===s[++o]&&n===s[++o]&&n===s[++o]&&n===s[++o]&&n===s[++o]&&n===s[++o]&&o<a);t.match_length=l-(a-o),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=i._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=i._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(m(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(m(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(m(t,!1),0===t.strm.avail_out)?1:2}(o,e):n[o.level].func(o,e);if(3!==w&&4!==w||(o.status=666),1===w||3===w)return 0===t.avail_out&&(o.last_flush=-1),0;if(2===w&&(1===e?i._tr_align(o):5!==e&&(i._tr_stored_block(o,0,0,!1),3===e&&(y(o.head),0===o.lookahead&&(o.strstart=0,o.block_start=0,o.insert=0))),g(t),0===t.avail_out))return o.last_flush=-1,0}return 4!==e?0:o.wrap<=0?1:(2===o.wrap?(v(o,255&t.adler),v(o,t.adler>>8&255),v(o,t.adler>>16&255),v(o,t.adler>>24&255),v(o,255&t.total_in),v(o,t.total_in>>8&255),v(o,t.total_in>>16&255),v(o,t.total_in>>24&255)):(b(o,t.adler>>>16),b(o,65535&t.adler)),g(t),0<o.wrap&&(o.wrap=-o.wrap),0!==o.pending?0:1)},r.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&103!==e&&e!==h&&666!==e?d(t,u):(t.state=null,e===h?d(t,-3):0):u},r.deflateSetDictionary=function(t,e){var r,n,i,s,c,l,f,h,d=e.length;if(!t||!t.state)return u;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return u;for(1===s&&(t.adler=a(t.adler,e,d,0)),r.wrap=0,d>=r.w_size&&(0===s&&(y(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new o.Buf8(r.w_size),o.arraySet(h,e,d-r.w_size,r.w_size,0),e=h,d=r.w_size),c=t.avail_in,l=t.next_in,f=t.input,t.avail_in=d,t.next_in=0,t.input=e,x(r);r.lookahead>=3;){for(n=r.strstart,i=r.lookahead-2;r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--i;);r.strstart=n,r.lookahead=2,x(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=l,t.input=f,t.avail_in=c,r.wrap=s,0},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,e,r){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,o,i,a,s,c,u,l,f,h,d,p,y,g,m,v,b,w,x,_,k,E,A,S;r=t.state,n=t.next_in,A=t.input,o=n+(t.avail_in-5),i=t.next_out,S=t.output,a=i-(e-t.avail_out),s=i+(t.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,f=r.wnext,h=r.window,d=r.hold,p=r.bits,y=r.lencode,g=r.distcode,m=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;t:do{p<15&&(d+=A[n++]<<p,p+=8,d+=A[n++]<<p,p+=8),b=y[d&m];e:for(;;){if(d>>>=w=b>>>24,p-=w,0==(w=b>>>16&255))S[i++]=65535&b;else{if(!(16&w)){if(0==(64&w)){b=y[(65535&b)+(d&(1<<w)-1)];continue e}if(32&w){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}x=65535&b,(w&=15)&&(p<w&&(d+=A[n++]<<p,p+=8),x+=d&(1<<w)-1,d>>>=w,p-=w),p<15&&(d+=A[n++]<<p,p+=8,d+=A[n++]<<p,p+=8),b=g[d&v];r:for(;;){if(d>>>=w=b>>>24,p-=w,!(16&(w=b>>>16&255))){if(0==(64&w)){b=g[(65535&b)+(d&(1<<w)-1)];continue r}t.msg="invalid distance code",r.mode=30;break t}if(_=65535&b,p<(w&=15)&&(d+=A[n++]<<p,(p+=8)<w&&(d+=A[n++]<<p,p+=8)),c<(_+=d&(1<<w)-1)){t.msg="invalid distance too far back",r.mode=30;break t}if(d>>>=w,p-=w,(w=i-a)<_){if(l<(w=_-w)&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(E=h,(k=0)===f){if(k+=u-w,w<x){for(x-=w;S[i++]=h[k++],--w;);k=i-_,E=S}}else if(f<w){if(k+=u+f-w,(w-=f)<x){for(x-=w;S[i++]=h[k++],--w;);if(k=0,f<x){for(x-=w=f;S[i++]=h[k++],--w;);k=i-_,E=S}}}else if(k+=f-w,w<x){for(x-=w;S[i++]=h[k++],--w;);k=i-_,E=S}for(;2<x;)S[i++]=E[k++],S[i++]=E[k++],S[i++]=E[k++],x-=3;x&&(S[i++]=E[k++],1<x&&(S[i++]=E[k++]))}else{for(k=i-_;S[i++]=S[k++],S[i++]=S[k++],S[i++]=S[k++],2<(x-=3););x&&(S[i++]=S[k++],1<x&&(S[i++]=S[k++]))}break}}break}}while(n<o&&i<s);n-=x=p>>3,d&=(1<<(p-=x<<3))-1,t.next_in=n,t.next_out=i,t.avail_in=n<o?o-n+5:5-(n-o),t.avail_out=i<s?s-i+257:257-(i-s),r.hold=d,r.bits=p}},{}],49:[function(t,e,r){"use strict";var n=t("../utils/common"),o=t("./adler32"),i=t("./crc32"),a=t("./inffast"),s=t("./inftrees"),c=-2;function u(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function l(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):c}function h(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,f(t)):c}function d(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15<e)?c:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,h(t))):c}function p(t,e){var r,n;return t?(n=new l,(t.state=n).window=null,0!==(r=d(t,e))&&(t.state=null),r):c}var y,g,m=!0;function v(t){if(m){var e;for(y=new n.Buf32(512),g=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,y,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,g,0,t.work,{bits:5}),m=!1}t.lencode=y,t.lenbits=9,t.distcode=g,t.distbits=5}function b(t,e,r,o){var i,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),o>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(o<(i=a.wsize-a.wnext)&&(i=o),n.arraySet(a.window,e,r-o,i,a.wnext),(o-=i)?(n.arraySet(a.window,e,r-o,o,0),a.wnext=o,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}r.inflateReset=h,r.inflateReset2=d,r.inflateResetKeep=f,r.inflateInit=function(t){return p(t,15)},r.inflateInit2=p,r.inflate=function(t,e){var r,l,f,h,d,p,y,g,m,w,x,_,k,E,A,S,L,O,P,T,C,M,j,I,B=0,z=new n.Buf8(4),D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return c;12===(r=t.state).mode&&(r.mode=13),d=t.next_out,f=t.output,y=t.avail_out,h=t.next_in,l=t.input,p=t.avail_in,g=r.hold,m=r.bits,w=p,x=y,M=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;m<16;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(2&r.wrap&&35615===g){z[r.check=0]=255&g,z[1]=g>>>8&255,r.check=i(r.check,z,2,0),m=g=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&g)<<8)+(g>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&g)){t.msg="unknown compression method",r.mode=30;break}if(m-=4,C=8+(15&(g>>>=4)),0===r.wbits)r.wbits=C;else if(C>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<<C,t.adler=r.check=1,r.mode=512&g?10:12,m=g=0;break;case 2:for(;m<16;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(r.flags=g,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=g>>8&1),512&r.flags&&(z[0]=255&g,z[1]=g>>>8&255,r.check=i(r.check,z,2,0)),m=g=0,r.mode=3;case 3:for(;m<32;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.head&&(r.head.time=g),512&r.flags&&(z[0]=255&g,z[1]=g>>>8&255,z[2]=g>>>16&255,z[3]=g>>>24&255,r.check=i(r.check,z,4,0)),m=g=0,r.mode=4;case 4:for(;m<16;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.head&&(r.head.xflags=255&g,r.head.os=g>>8),512&r.flags&&(z[0]=255&g,z[1]=g>>>8&255,r.check=i(r.check,z,2,0)),m=g=0,r.mode=5;case 5:if(1024&r.flags){for(;m<16;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.length=g,r.head&&(r.head.extra_len=g),512&r.flags&&(z[0]=255&g,z[1]=g>>>8&255,r.check=i(r.check,z,2,0)),m=g=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(p<(_=r.length)&&(_=p),_&&(r.head&&(C=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,l,h,_,C)),512&r.flags&&(r.check=i(r.check,l,_,h)),p-=_,h+=_,r.length-=_),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===p)break t;for(_=0;C=l[h+_++],r.head&&C&&r.length<65536&&(r.head.name+=String.fromCharCode(C)),C&&_<p;);if(512&r.flags&&(r.check=i(r.check,l,_,h)),p-=_,h+=_,C)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===p)break t;for(_=0;C=l[h+_++],r.head&&C&&r.length<65536&&(r.head.comment+=String.fromCharCode(C)),C&&_<p;);if(512&r.flags&&(r.check=i(r.check,l,_,h)),p-=_,h+=_,C)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;m<16;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(g!==(65535&r.check)){t.msg="header crc mismatch",r.mode=30;break}m=g=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;m<32;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}t.adler=r.check=u(g),m=g=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=d,t.avail_out=y,t.next_in=h,t.avail_in=p,r.hold=g,r.bits=m,2;t.adler=r.check=1,r.mode=12;case 12:if(5===e||6===e)break t;case 13:if(r.last){g>>>=7&m,m-=7&m,r.mode=27;break}for(;m<3;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}switch(r.last=1&g,m-=1,3&(g>>>=1)){case 0:r.mode=14;break;case 1:if(v(r),r.mode=20,6!==e)break;g>>>=2,m-=2;break t;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}g>>>=2,m-=2;break;case 14:for(g>>>=7&m,m-=7&m;m<32;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if((65535&g)!=(g>>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&g,m=g=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(_=r.length){if(p<_&&(_=p),y<_&&(_=y),0===_)break t;n.arraySet(f,l,h,_,d),p-=_,h+=_,y-=_,d+=_,r.length-=_;break}r.mode=12;break;case 17:for(;m<14;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(r.nlen=257+(31&g),g>>>=5,m-=5,r.ndist=1+(31&g),g>>>=5,m-=5,r.ncode=4+(15&g),g>>>=4,m-=4,286<r.nlen||30<r.ndist){t.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;m<3;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.lens[D[r.have++]]=7&g,g>>>=3,m-=3}for(;r.have<19;)r.lens[D[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,j={bits:r.lenbits},M=s(0,r.lens,0,19,r.lencode,0,r.work,j),r.lenbits=j.bits,M){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;S=(B=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,L=65535&B,!((A=B>>>24)<=m);){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(L<16)g>>>=A,m-=A,r.lens[r.have++]=L;else{if(16===L){for(I=A+2;m<I;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(g>>>=A,m-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}C=r.lens[r.have-1],_=3+(3&g),g>>>=2,m-=2}else if(17===L){for(I=A+3;m<I;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}m-=A,C=0,_=3+(7&(g>>>=A)),g>>>=3,m-=3}else{for(I=A+7;m<I;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}m-=A,C=0,_=11+(127&(g>>>=A)),g>>>=7,m-=7}if(r.have+_>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;_--;)r.lens[r.have++]=C}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,j={bits:r.lenbits},M=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,j),r.lenbits=j.bits,M){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,j={bits:r.distbits},M=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,j),r.distbits=j.bits,M){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(6<=p&&258<=y){t.next_out=d,t.avail_out=y,t.next_in=h,t.avail_in=p,r.hold=g,r.bits=m,a(t,x),d=t.next_out,f=t.output,y=t.avail_out,h=t.next_in,l=t.input,p=t.avail_in,g=r.hold,m=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;S=(B=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,L=65535&B,!((A=B>>>24)<=m);){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(S&&0==(240&S)){for(O=A,P=S,T=L;S=(B=r.lencode[T+((g&(1<<O+P)-1)>>O)])>>>16&255,L=65535&B,!(O+(A=B>>>24)<=m);){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}g>>>=O,m-=O,r.back+=O}if(g>>>=A,m-=A,r.back+=A,r.length=L,0===S){r.mode=26;break}if(32&S){r.back=-1,r.mode=12;break}if(64&S){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&S,r.mode=22;case 22:if(r.extra){for(I=r.extra;m<I;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.length+=g&(1<<r.extra)-1,g>>>=r.extra,m-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;S=(B=r.distcode[g&(1<<r.distbits)-1])>>>16&255,L=65535&B,!((A=B>>>24)<=m);){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(0==(240&S)){for(O=A,P=S,T=L;S=(B=r.distcode[T+((g&(1<<O+P)-1)>>O)])>>>16&255,L=65535&B,!(O+(A=B>>>24)<=m);){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}g>>>=O,m-=O,r.back+=O}if(g>>>=A,m-=A,r.back+=A,64&S){t.msg="invalid distance code",r.mode=30;break}r.offset=L,r.extra=15&S,r.mode=24;case 24:if(r.extra){for(I=r.extra;m<I;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}r.offset+=g&(1<<r.extra)-1,g>>>=r.extra,m-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===y)break t;if(_=x-y,r.offset>_){if((_=r.offset-_)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}k=_>r.wnext?(_-=r.wnext,r.wsize-_):r.wnext-_,_>r.length&&(_=r.length),E=r.window}else E=f,k=d-r.offset,_=r.length;for(y<_&&(_=y),y-=_,r.length-=_;f[d++]=E[k++],--_;);0===r.length&&(r.mode=21);break;case 26:if(0===y)break t;f[d++]=r.length,y--,r.mode=21;break;case 27:if(r.wrap){for(;m<32;){if(0===p)break t;p--,g|=l[h++]<<m,m+=8}if(x-=y,t.total_out+=x,r.total+=x,x&&(t.adler=r.check=r.flags?i(r.check,f,x,d-x):o(r.check,f,x,d-x)),x=y,(r.flags?g:u(g))!==r.check){t.msg="incorrect data check",r.mode=30;break}m=g=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;m<32;){if(0===p)break t;p--,g+=l[h++]<<m,m+=8}if(g!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=30;break}m=g=0}r.mode=29;case 29:M=1;break t;case 30:M=-3;break t;case 31:return-4;default:return c}return t.next_out=d,t.avail_out=y,t.next_in=h,t.avail_in=p,r.hold=g,r.bits=m,(r.wsize||x!==t.avail_out&&r.mode<30&&(r.mode<27||4!==e))&&b(t,t.output,t.next_out,x-t.avail_out)?(r.mode=31,-4):(w-=t.avail_in,x-=t.avail_out,t.total_in+=w,t.total_out+=x,r.total+=x,r.wrap&&x&&(t.adler=r.check=r.flags?i(r.check,f,x,t.next_out-x):o(r.check,f,x,t.next_out-x)),t.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==w&&0===x||4===e)&&0===M&&(M=-5),M)},r.inflateEnd=function(t){if(!t||!t.state)return c;var e=t.state;return e.window&&(e.window=null),t.state=null,0},r.inflateGetHeader=function(t,e){var r;return t&&t.state?0==(2&(r=t.state).wrap)?c:((r.head=e).done=!1,0):c},r.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?c:11===r.mode&&o(1,e,n,0)!==r.check?-3:b(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):c},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,e,r){"use strict";var n=t("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(t,e,r,c,u,l,f,h){var d,p,y,g,m,v,b,w,x,_=h.bits,k=0,E=0,A=0,S=0,L=0,O=0,P=0,T=0,C=0,M=0,j=null,I=0,B=new n.Buf16(16),z=new n.Buf16(16),D=null,N=0;for(k=0;k<=15;k++)B[k]=0;for(E=0;E<c;E++)B[e[r+E]]++;for(L=_,S=15;1<=S&&0===B[S];S--);if(S<L&&(L=S),0===S)return u[l++]=20971520,u[l++]=20971520,h.bits=1,0;for(A=1;A<S&&0===B[A];A++);for(L<A&&(L=A),k=T=1;k<=15;k++)if(T<<=1,(T-=B[k])<0)return-1;if(0<T&&(0===t||1!==S))return-1;for(z[1]=0,k=1;k<15;k++)z[k+1]=z[k]+B[k];for(E=0;E<c;E++)0!==e[r+E]&&(f[z[e[r+E]]++]=E);if(v=0===t?(j=D=f,19):1===t?(j=o,I-=257,D=i,N-=257,256):(j=a,D=s,-1),k=A,m=l,P=E=M=0,y=-1,g=(C=1<<(O=L))-1,1===t&&852<C||2===t&&592<C)return 1;for(;;){for(b=k-P,x=f[E]<v?(w=0,f[E]):f[E]>v?(w=D[N+f[E]],j[I+f[E]]):(w=96,0),d=1<<k-P,A=p=1<<O;u[m+(M>>P)+(p-=d)]=b<<24|w<<16|x|0,0!==p;);for(d=1<<k-1;M&d;)d>>=1;if(0!==d?(M&=d-1,M+=d):M=0,E++,0==--B[k]){if(k===S)break;k=e[r+f[E]]}if(L<k&&(M&g)!==y){for(0===P&&(P=L),m+=A,T=1<<(O=k-P);O+P<S&&!((T-=B[O+P])<=0);)O++,T<<=1;if(C+=1<<O,1===t&&852<C||2===t&&592<C)return 1;u[y=M&g]=L<<24|O<<16|m-l|0}}return 0!==M&&(u[m+M]=k-P<<24|64<<16|0),h.bits=L,0}},{"../utils/common":41}],51:[function(t,e,r){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,e,r){"use strict";var n=t("../utils/common");function o(t){for(var e=t.length;0<=--e;)t[e]=0}var i=256,a=286,s=30,c=15,u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],l=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);o(d);var p=new Array(60);o(p);var y=new Array(512);o(y);var g=new Array(256);o(g);var m=new Array(29);o(m);var v,b,w,x=new Array(s);function _(t,e,r,n,o){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=o,this.has_stree=t&&t.length}function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function E(t){return t<256?y[t]:y[256+(t>>>7)]}function A(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function S(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,A(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function L(t,e,r){S(t,r[2*e],r[2*e+1])}function O(t,e){for(var r=0;r|=1&t,t>>>=1,r<<=1,0<--e;);return r>>>1}function P(t,e,r){var n,o,i=new Array(16),a=0;for(n=1;n<=c;n++)i[n]=a=a+r[n-1]<<1;for(o=0;o<=e;o++){var s=t[2*o+1];0!==s&&(t[2*o]=O(i[s]++,s))}}function T(t){var e;for(e=0;e<a;e++)t.dyn_ltree[2*e]=0;for(e=0;e<s;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function C(t){8<t.bi_valid?A(t,t.bi_buf):0<t.bi_valid&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function M(t,e,r,n){var o=2*e,i=2*r;return t[o]<t[i]||t[o]===t[i]&&n[e]<=n[r]}function j(t,e,r){for(var n=t.heap[r],o=r<<1;o<=t.heap_len&&(o<t.heap_len&&M(e,t.heap[o+1],t.heap[o],t.depth)&&o++,!M(e,n,t.heap[o],t.depth));)t.heap[r]=t.heap[o],r=o,o<<=1;t.heap[r]=n}function I(t,e,r){var n,o,a,s,c=0;if(0!==t.last_lit)for(;n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],o=t.pending_buf[t.l_buf+c],c++,0===n?L(t,o,e):(L(t,(a=g[o])+i+1,e),0!==(s=u[a])&&S(t,o-=m[a],s),L(t,a=E(--n),r),0!==(s=l[a])&&S(t,n-=x[a],s)),c<t.last_lit;);L(t,256,e)}function B(t,e){var r,n,o,i=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,l=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==i[2*r]?(t.heap[++t.heap_len]=l=r,t.depth[r]=0):i[2*r+1]=0;for(;t.heap_len<2;)i[2*(o=t.heap[++t.heap_len]=l<2?++l:0)]=1,t.depth[o]=0,t.opt_len--,s&&(t.static_len-=a[2*o+1]);for(e.max_code=l,r=t.heap_len>>1;1<=r;r--)j(t,i,r);for(o=u;r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],j(t,i,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,i[2*o]=i[2*r]+i[2*n],t.depth[o]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,i[2*r+1]=i[2*n+1]=o,t.heap[1]=o++,j(t,i,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,o,i,a,s,u=e.dyn_tree,l=e.max_code,f=e.stat_desc.static_tree,h=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,y=e.stat_desc.max_length,g=0;for(i=0;i<=c;i++)t.bl_count[i]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)y<(i=u[2*u[2*(n=t.heap[r])+1]+1]+1)&&(i=y,g++),u[2*n+1]=i,l<n||(t.bl_count[i]++,a=0,p<=n&&(a=d[n-p]),s=u[2*n],t.opt_len+=s*(i+a),h&&(t.static_len+=s*(f[2*n+1]+a)));if(0!==g){do{for(i=y-1;0===t.bl_count[i];)i--;t.bl_count[i]--,t.bl_count[i+1]+=2,t.bl_count[y]--,g-=2}while(0<g);for(i=y;0!==i;i--)for(n=t.bl_count[i];0!==n;)l<(o=t.heap[--r])||(u[2*o+1]!==i&&(t.opt_len+=(i-u[2*o+1])*u[2*o],u[2*o+1]=i),n--)}}(t,e),P(i,l,t.bl_count)}function z(t,e,r){var n,o,i=-1,a=e[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)o=a,a=e[2*(n+1)+1],++s<c&&o===a||(s<u?t.bl_tree[2*o]+=s:0!==o?(o!==i&&t.bl_tree[2*o]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,i=o,u=(s=0)===a?(c=138,3):o===a?(c=6,3):(c=7,4))}function D(t,e,r){var n,o,i=-1,a=e[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(o=a,a=e[2*(n+1)+1],!(++s<c&&o===a)){if(s<u)for(;L(t,o,t.bl_tree),0!=--s;);else 0!==o?(o!==i&&(L(t,o,t.bl_tree),s--),L(t,16,t.bl_tree),S(t,s-3,2)):s<=10?(L(t,17,t.bl_tree),S(t,s-3,3)):(L(t,18,t.bl_tree),S(t,s-11,7));i=o,u=(s=0)===a?(c=138,3):o===a?(c=6,3):(c=7,4)}}o(x);var N=!1;function R(t,e,r,o){S(t,0+(o?1:0),3),function(t,e,r,o){C(t),A(t,r),A(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}r._tr_init=function(t){N||(function(){var t,e,r,n,o,i=new Array(16);for(n=r=0;n<28;n++)for(m[n]=r,t=0;t<1<<u[n];t++)g[r++]=n;for(g[r-1]=n,n=o=0;n<16;n++)for(x[n]=o,t=0;t<1<<l[n];t++)y[o++]=n;for(o>>=7;n<s;n++)for(x[n]=o<<7,t=0;t<1<<l[n]-7;t++)y[256+o++]=n;for(e=0;e<=c;e++)i[e]=0;for(t=0;t<=143;)d[2*t+1]=8,t++,i[8]++;for(;t<=255;)d[2*t+1]=9,t++,i[9]++;for(;t<=279;)d[2*t+1]=7,t++,i[7]++;for(;t<=287;)d[2*t+1]=8,t++,i[8]++;for(P(d,287,i),t=0;t<s;t++)p[2*t+1]=5,p[2*t]=O(t,5);v=new _(d,u,257,a,c),b=new _(p,l,0,s,c),w=new _(new Array(0),f,0,19,7)}(),N=!0),t.l_desc=new k(t.dyn_ltree,v),t.d_desc=new k(t.dyn_dtree,b),t.bl_desc=new k(t.bl_tree,w),t.bi_buf=0,t.bi_valid=0,T(t)},r._tr_stored_block=R,r._tr_flush_block=function(t,e,r,n){var o,a,s=0;0<t.level?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<i;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),B(t,t.l_desc),B(t,t.d_desc),s=function(t){var e;for(z(t,t.dyn_ltree,t.l_desc.max_code),z(t,t.dyn_dtree,t.d_desc.max_code),B(t,t.bl_desc),e=18;3<=e&&0===t.bl_tree[2*h[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),o=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=o&&(o=a)):o=a=r+5,r+4<=o&&-1!==e?R(t,e,r,n):4===t.strategy||a===o?(S(t,2+(n?1:0),3),I(t,d,p)):(S(t,4+(n?1:0),3),function(t,e,r,n){var o;for(S(t,e-257,5),S(t,r-1,5),S(t,n-4,4),o=0;o<n;o++)S(t,t.bl_tree[2*h[o]+1],3);D(t,t.dyn_ltree,e-1),D(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),I(t,t.dyn_ltree,t.dyn_dtree)),T(t),n&&C(t)},r._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(g[r]+i+1)]++,t.dyn_dtree[2*E(e)]++),t.last_lit===t.lit_bufsize-1},r._tr_align=function(t){S(t,2,3),L(t,256,d),function(t){16===t.bi_valid?(A(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,r){"use strict";e.exports="function"==typeof setImmediate?setImmediate:function(){var t=[].slice.apply(arguments);t.splice(1,0,0),setTimeout.apply(null,t)}},{}]},{},[10])(10)},5233:function(t,e,r){var n,o,i;t=r.nmd(t),function(a,s,c){"use strict";var u={function:!0,object:!0},l=u[typeof e]&&e&&!e.nodeType&&e,f=u.object&&t&&!t.nodeType&&t,h=l&&f&&"object"==typeof r.g&&r.g,d=f&&f.exports===l&&l;!h||h.global!==h&&h.window!==h&&h.self,o=[e],void 0===(i="function"==typeof(n=c)?n.apply(e,o):n)||(t.exports=i),l&&d&&c(f.exports)}(0,0,(function(t){"use strict";var e,r,n,o,i;t.version="0.3.1";var a=t.defaultOptions={wait:!1,comments:!0,scope:!1,locations:!1,ranges:!1,onCreateNode:null,onCreateScope:null,onDestroyScope:null,onLocalDeclaration:null,luaVersion:"5.1",encodingMode:"none"};function s(t,e){return e=e||0,t<128?String.fromCharCode(t):t<2048?String.fromCharCode(192|e|t>>6,128|e|63&t):t<65536?String.fromCharCode(224|e|t>>12,128|e|t>>6&63,128|e|63&t):t<1114112?String.fromCharCode(240|e|t>>18,128|e|t>>12&63,128|e|t>>6&63,128|e|63&t):null}function c(t){return function(e){var r=t.exec(e);if(!r)return e;M(null,d.invalidCodeUnit,function(t,e){for(var r=t.toString(16);r.length<4;)r="0"+r;return r}(r[0].charCodeAt(0)).toUpperCase())}}var u={"pseudo-latin1":{fixup:c(/[^\x00-\xff]/),encodeByte:function(t){return null===t?"":String.fromCharCode(t)},encodeUTF8:function(t){return s(t)}},"x-user-defined":{fixup:c(/[^\x00-\x7f\uf780-\uf7ff]/),encodeByte:function(t){return null===t?"":t>=128?String.fromCharCode(63232|t):String.fromCharCode(t)},encodeUTF8:function(t){return s(t,63232)}},none:{discardStrings:!0,fixup:function(t){return t},encodeByte:function(t){return""},encodeUTF8:function(t){return""}}},l=32,f=128,h=256;t.tokenTypes={EOF:1,StringLiteral:2,Keyword:4,Identifier:8,NumericLiteral:16,Punctuator:l,BooleanLiteral:64,NilLiteral:f,VarargLiteral:h};var d=t.errors={unexpected:"unexpected %1 '%2' near '%3'",unexpectedEOF:"unexpected symbol near '<eof>'",expected:"'%1' expected near '%2'",expectedToken:"%1 expected near '%2'",unfinishedString:"unfinished string near '%1'",malformedNumber:"malformed number near '%1'",decimalEscapeTooLarge:"decimal escape too large near '%1'",invalidEscape:"invalid escape sequence near '%1'",hexadecimalDigitExpected:"hexadecimal digit expected near '%1'",braceExpected:"missing '%1' near '%2'",tooLargeCodepoint:"UTF-8 value too large near '%1'",unfinishedLongString:"unfinished long string (starting at line %1) near '%2'",unfinishedLongComment:"unfinished long comment (starting at line %1) near '%2'",ambiguousSyntax:"ambiguous syntax (function call x new statement) near '%1'",noLoopToBreak:"no loop to break near '%1'",labelAlreadyDefined:"label '%1' already defined on line %2",labelNotVisible:"no visible label '%1' for <goto>",gotoJumpInLocalScope:"<goto %1> jumps into the scope of local '%2'",cannotUseVararg:"cannot use '...' outside a vararg function near '%1'",invalidCodeUnit:"code unit U+%1 is not allowed in the current encoding mode"},p=t.ast={labelStatement:function(t){return{type:"LabelStatement",label:t}},breakStatement:function(){return{type:"BreakStatement"}},gotoStatement:function(t){return{type:"GotoStatement",label:t}},returnStatement:function(t){return{type:"ReturnStatement",arguments:t}},ifStatement:function(t){return{type:"IfStatement",clauses:t}},ifClause:function(t,e){return{type:"IfClause",condition:t,body:e}},elseifClause:function(t,e){return{type:"ElseifClause",condition:t,body:e}},elseClause:function(t){return{type:"ElseClause",body:t}},whileStatement:function(t,e){return{type:"WhileStatement",condition:t,body:e}},doStatement:function(t){return{type:"DoStatement",body:t}},repeatStatement:function(t,e){return{type:"RepeatStatement",condition:t,body:e}},localStatement:function(t,e){return{type:"LocalStatement",variables:t,init:e}},assignmentStatement:function(t,e){return{type:"AssignmentStatement",variables:t,init:e}},callStatement:function(t){return{type:"CallStatement",expression:t}},functionStatement:function(t,e,r,n){return{type:"FunctionDeclaration",identifier:t,isLocal:r,parameters:e,body:n}},forNumericStatement:function(t,e,r,n,o){return{type:"ForNumericStatement",variable:t,start:e,end:r,step:n,body:o}},forGenericStatement:function(t,e,r){return{type:"ForGenericStatement",variables:t,iterators:e,body:r}},chunk:function(t){return{type:"Chunk",body:t}},identifier:function(t){return{type:"Identifier",name:t}},literal:function(t,e,r){return{type:t=2===t?"StringLiteral":16===t?"NumericLiteral":64===t?"BooleanLiteral":t===f?"NilLiteral":"VarargLiteral",value:e,raw:r}},tableKey:function(t,e){return{type:"TableKey",key:t,value:e}},tableKeyString:function(t,e){return{type:"TableKeyString",key:t,value:e}},tableValue:function(t){return{type:"TableValue",value:t}},tableConstructorExpression:function(t){return{type:"TableConstructorExpression",fields:t}},binaryExpression:function(t,e,r){return{type:"and"===t||"or"===t?"LogicalExpression":"BinaryExpression",operator:t,left:e,right:r}},unaryExpression:function(t,e){return{type:"UnaryExpression",operator:t,argument:e}},memberExpression:function(t,e,r){return{type:"MemberExpression",indexer:e,identifier:r,base:t}},indexExpression:function(t,e){return{type:"IndexExpression",base:t,index:e}},callExpression:function(t,e){return{type:"CallExpression",base:t,arguments:e}},tableCallExpression:function(t,e){return{type:"TableCallExpression",base:t,arguments:e}},stringCallExpression:function(t,e){return{type:"StringCallExpression",base:t,argument:e}},comment:function(t,e){return{type:"Comment",value:t,raw:e}}};function y(t){if(ot){var e=it.pop();e.complete(),e.bless(t)}return r.onCreateNode&&r.onCreateNode(t),t}var g=Array.prototype.slice,m=(Object.prototype.toString,function(t,e){for(var r=0,n=t.length;r<n;++r)if(t[r]===e)return r;return-1});function v(t){var e=g.call(arguments,1);return t=t.replace(/%(\d)/g,(function(t,r){return""+e[r-1]||""})),t}Array.prototype.indexOf&&(m=function(t,e){return t.indexOf(e)});var b,w,x,_,k,E,A,S,L,O,P,T=function(t){for(var e,r,n=g.call(arguments,1),o=0,i=n.length;o<i;++o)for(r in e=n[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t};function C(t){return Object.create?Object.create(t,{line:{writable:!0,value:t.line},index:{writable:!0,value:t.index},column:{writable:!0,value:t.column}}):t}function M(t){var e,r,n=v.apply(null,g.call(arguments,1));throw null===t||void 0===t.line?(r=b-S+1,(e=C(new SyntaxError(v("[%1:%2] %3",A,r,n)))).index=b,e.line=A,e.column=r):(r=t.range[0]-t.lineStart,(e=C(new SyntaxError(v("[%1:%2] %3",t.line,r,n)))).line=t.line,e.index=t.range[0],e.column=r),e}function j(t){return e.slice(t.range[0],t.range[1])||t.value}function I(t,e){M(e,d.expectedToken,t,j(e))}function B(t){var e=j(_);if(void 0!==t.type){var r;switch(t.type){case 2:r="string";break;case 4:r="keyword";break;case 8:r="identifier";break;case 16:r="number";break;case l:r="symbol";break;case 64:r="boolean";break;case f:return M(t,d.unexpected,"symbol","nil",e);case 1:return M(t,d.unexpectedEOF)}return M(t,d.unexpected,r,j(t),e)}return M(t,d.unexpected,"symbol",t,e)}function z(){for(N();45===e.charCodeAt(b)&&45===e.charCodeAt(b+1);)G(),N();if(b>=n)return{type:1,value:"<eof>",line:A,lineStart:S,range:[b,b]};var t,r,a,s=e.charCodeAt(b),c=e.charCodeAt(b+1);if(E=b,function(t){return t>=65&&t<=90||t>=97&&t<=122||95===t||!!(o.extendedIdentifiers&&t>=128)}(s))return function(){for(var t,r;q(e.charCodeAt(++b)););return!function(t){switch(t.length){case 2:return"do"===t||"if"===t||"in"===t||"or"===t;case 3:return"and"===t||"end"===t||"for"===t||"not"===t;case 4:return"else"===t||"then"===t||!(!o.labels||o.contextualGoto)&&"goto"===t;case 5:return"break"===t||"local"===t||"until"===t||"while"===t;case 6:return"elseif"===t||"repeat"===t||"return"===t;case 8:return"function"===t}return!1}(t=i.fixup(e.slice(E,b)))?"true"===t||"false"===t?(r=64,t="true"===t):"nil"===t?(r=f,t=null):r=8:r=4,{type:r,value:t,line:A,lineStart:S,range:[E,b]}}();switch(s){case 39:case 34:return function(){for(var t,r=e.charCodeAt(b++),o=A,a=S,s=b,c=i.discardStrings?null:"";r!==(t=e.charCodeAt(b++));)if((b>n||Y(t))&&(c+=e.slice(s,b-1),M(null,d.unfinishedString,e.slice(E,b-1))),92===t){if(!i.discardStrings){var u=e.slice(s,b-1);c+=i.fixup(u)}var l=U();i.discardStrings||(c+=l),s=b}return i.discardStrings||(c+=i.encodeByte(null),c+=i.fixup(e.slice(s,b-1))),{type:2,value:c,line:o,lineStart:a,lastLine:A,lastLineStart:S,range:[E,b]}}();case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return F();case 46:return K(c)?F():46===c?46===e.charCodeAt(b+2)?{type:h,value:"...",line:A,lineStart:S,range:[E,b+=3]}:R(".."):R(".");case 61:return R(61===c?"==":"=");case 62:return o.bitwiseOperators&&62===c?R(">>"):R(61===c?">=":">");case 60:return o.bitwiseOperators&&60===c?R("<<"):R(61===c?"<=":"<");case 126:if(61===c)return R("~=");if(!o.bitwiseOperators)break;return R("~");case 58:return o.labels&&58===c?R("::"):R(":");case 91:return 91===c||61===c?(t=A,r=S,!1===(a=W(!1))&&M(w,d.expected,"[",j(w)),{type:2,value:i.discardStrings?null:i.fixup(a),line:t,lineStart:r,lastLine:A,lastLineStart:S,range:[E,b]}):R("[");case 47:return o.integerDivision&&47===c?R("//"):R("/");case 38:case 124:if(!o.bitwiseOperators)break;case 42:case 94:case 37:case 44:case 123:case 125:case 93:case 40:case 41:case 59:case 35:case 45:case 43:return R(e.charAt(b))}return B(e.charAt(b))}function D(){var t=e.charCodeAt(b),r=e.charCodeAt(b+1);return!!Y(t)&&(10===t&&13===r&&++b,13===t&&10===r&&++b,++A,S=++b,!0)}function N(){for(;b<n;)if(9===(t=e.charCodeAt(b))||32===t||11===t||12===t)++b;else if(!D())break;var t}function R(t){return b+=t.length,{type:l,value:t,line:A,lineStart:S,range:[E,b]}}function F(){var t=e.charAt(b),r=e.charAt(b+1),n="0"===t&&"xX".indexOf(r||null)>=0?function(){var t,r,n,o,i=0,a=1,s=1;for(o=b+=2,H(e.charCodeAt(b))||M(null,d.malformedNumber,e.slice(E,b));H(e.charCodeAt(b));)++b;t=parseInt(e.slice(o,b),16);var c=!1;if("."===e.charAt(b)){for(c=!0,r=++b;H(e.charCodeAt(b));)++b;i=e.slice(r,b),i=r===b?0:parseInt(i,16)/Math.pow(16,b-r)}var u=!1;if("pP".indexOf(e.charAt(b)||null)>=0){for(u=!0,++b,"+-".indexOf(e.charAt(b)||null)>=0&&(s="+"===e.charAt(b++)?1:-1),n=b,K(e.charCodeAt(b))||M(null,d.malformedNumber,e.slice(E,b));K(e.charCodeAt(b));)++b;a=e.slice(n,b),a=Math.pow(2,a*s)}return{value:(t+i)*a,hasFractionPart:c||u}}():function(){for(;K(e.charCodeAt(b));)++b;var t=!1;if("."===e.charAt(b))for(t=!0,++b;K(e.charCodeAt(b));)++b;var r=!1;if("eE".indexOf(e.charAt(b)||null)>=0)for(r=!0,++b,"+-".indexOf(e.charAt(b)||null)>=0&&++b,K(e.charCodeAt(b))||M(null,d.malformedNumber,e.slice(E,b));K(e.charCodeAt(b));)++b;return{value:parseFloat(e.slice(E,b)),hasFractionPart:t||r}}(),i=function(){if(o.imaginaryNumbers)return"iI".indexOf(e.charAt(b)||null)>=0&&(++b,!0)}();return function(){if(o.integerSuffixes)if("uU".indexOf(e.charAt(b)||null)>=0)if(++b,"lL".indexOf(e.charAt(b)||null)>=0){if(++b,"lL".indexOf(e.charAt(b)||null)>=0)return++b,"ULL";M(null,d.malformedNumber,e.slice(E,b))}else M(null,d.malformedNumber,e.slice(E,b));else if("lL".indexOf(e.charAt(b)||null)>=0){if(++b,"lL".indexOf(e.charAt(b)||null)>=0)return++b,"LL";M(null,d.malformedNumber,e.slice(E,b))}}()&&(i||n.hasFractionPart)&&M(null,d.malformedNumber,e.slice(E,b)),{type:16,value:n.value,line:A,lineStart:S,range:[E,b]}}function U(){var t=b;switch(e.charAt(b)){case"a":return++b,"";case"n":return++b,"\n";case"r":return++b,"\r";case"t":return++b,"\t";case"v":return++b,"\v";case"b":return++b,"\b";case"f":return++b,"\f";case"\r":case"\n":return D(),"\n";case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;K(e.charCodeAt(b))&&b-t<3;)++b;var r=e.slice(t,b),n=parseInt(r,10);return n>255&&M(null,d.decimalEscapeTooLarge,"\\"+n),i.encodeByte(n,"\\"+r);case"z":if(o.skipWhitespaceEscape)return++b,N(),"";break;case"x":if(o.hexEscapes){if(H(e.charCodeAt(b+1))&&H(e.charCodeAt(b+2)))return b+=3,i.encodeByte(parseInt(e.slice(t+1,b),16),"\\"+e.slice(t,b));M(null,d.hexadecimalDigitExpected,"\\"+e.slice(t,b+2))}break;case"u":if(o.unicodeEscapes)return function(){var t=b++;for("{"!==e.charAt(b++)&&M(null,d.braceExpected,"{","\\"+e.slice(t,b)),H(e.charCodeAt(b))||M(null,d.hexadecimalDigitExpected,"\\"+e.slice(t,b));48===e.charCodeAt(b);)++b;for(var r=b;H(e.charCodeAt(b));)++b-r>6&&M(null,d.tooLargeCodepoint,"\\"+e.slice(t,b));var n=e.charAt(b++);"}"!==n&&('"'===n||"'"===n?M(null,d.braceExpected,"}","\\"+e.slice(t,b--)):M(null,d.hexadecimalDigitExpected,"\\"+e.slice(t,b)));var o=parseInt(e.slice(r,b-1)||"0",16),a="\\"+e.slice(t,b);return o>1114111&&M(null,d.tooLargeCodepoint,a),i.encodeUTF8(o,a)}();break;case"\\":case'"':case"'":return e.charAt(b++)}return o.strictEscapes&&M(null,d.invalidEscape,"\\"+e.slice(t,b+1)),e.charAt(b++)}function G(){E=b,b+=2;var t=e.charAt(b),o="",i=!1,a=b,s=S,c=A;if("["===t&&(!1===(o=W(!0))?o=t:i=!0),!i){for(;b<n&&!Y(e.charCodeAt(b));)++b;r.comments&&(o=e.slice(a,b))}if(r.comments){var u=p.comment(o,e.slice(E,b));r.locations&&(u.loc={start:{line:c,column:E-s},end:{line:A,column:b-S}}),r.ranges&&(u.range=[E,b]),r.onCreateNode&&r.onCreateNode(u),k.push(u)}}function W(t){var r,o=0,i="",a=!1,s=A;for(++b;"="===e.charAt(b+o);)++o;if("["!==e.charAt(b+o))return!1;for(b+=o+1,Y(e.charCodeAt(b))&&D(),r=b;b<n;){for(;Y(e.charCodeAt(b));)D();if("]"===e.charAt(b++)){a=!0;for(var c=0;c<o;++c)"="!==e.charAt(b+c)&&(a=!1);"]"!==e.charAt(b+o)&&(a=!1)}if(a)return i+=e.slice(r,b-1),b+=o+1,i}M(null,t?d.unfinishedLongComment:d.unfinishedLongString,s,"<eof>")}function V(){x=w,w=_,_=z()}function Z(t){return t===w.value&&(V(),!0)}function $(t){t===w.value?V():M(w,d.expected,t,j(w))}function Y(t){return 10===t||13===t}function K(t){return t>=48&&t<=57}function H(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function q(t){return t>=65&&t<=90||t>=97&&t<=122||95===t||t>=48&&t<=57||!!(o.extendedIdentifiers&&t>=128)}function X(t){if(1===t.type)return!0;if(4!==t.type)return!1;switch(t.value){case"else":case"elseif":case"end":case"until":return!0;default:return!1}}function J(){var t=L[O++].slice();L.push(t),r.onCreateScope&&r.onCreateScope()}function Q(){L.pop(),--O,r.onDestroyScope&&r.onDestroyScope()}function tt(t){r.onLocalDeclaration&&r.onLocalDeclaration(t),-1===m(L[O],t)&&L[O].push(t)}function et(t){tt(t.name),rt(t,!0)}function rt(t,e){e||-1!==function(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===r)return n;return-1}(P,0,t.name)||P.push(t),t.isLocal=e}function nt(t){return-1!==m(L[O],t)}Object.assign&&(T=Object.assign),t.SyntaxError=SyntaxError,t.lex=z;var ot,it=[];function at(){return new st(w)}function st(t){r.locations&&(this.loc={start:{line:t.line,column:t.range[0]-t.lineStart},end:{line:0,column:0}}),r.ranges&&(this.range=[t.range[0],0])}function ct(){ot&&it.push(at())}function ut(t){ot&&it.push(t)}function lt(){this.scopes=[],this.pendingGotos=[]}function ft(){this.level=0,this.loopLevels=[]}function ht(){return o.labels?new lt:new ft}function dt(t){for(var e,r=[];!X(w);){if("return"===w.value||!o.relaxedBreak&&"break"===w.value){r.push(pt(t));break}e=pt(t),Z(";"),e&&r.push(e)}return r}function pt(t){if(ct(),l===w.type&&Z("::"))return function(t){var e=w,n=gt();return r.scope&&(tt("::"+e.value+"::"),rt(n,!0)),$("::"),t.addLabel(e.value,e),y(p.labelStatement(n))}(t);if(!o.emptyStatement||!Z(";")){if(t.raiseDeferredErrors(),4===w.type)switch(w.value){case"local":return V(),function(t){var e,n=x;if(8===w.type){var o=[],i=[];do{e=gt(),o.push(e),t.addLocal(e.name,n)}while(Z(","));if(Z("="))do{var a=wt(t);i.push(a)}while(Z(","));if(r.scope)for(var s=0,c=o.length;s<c;++s)et(o[s]);return y(p.localStatement(o,i))}if(Z("function"))return e=gt(),t.addLocal(e.name,n),r.scope&&(et(e),J()),mt(e,!0);I("<name>",w)}(t);case"if":return V(),function(t){var e,n,o,i=[];for(ot&&(o=it[it.length-1],it.push(o)),e=wt(t),$("then"),r.scope&&J(),t.pushScope(),n=dt(t),t.popScope(),r.scope&&Q(),i.push(y(p.ifClause(e,n))),ot&&(o=at());Z("elseif");)ut(o),e=wt(t),$("then"),r.scope&&J(),t.pushScope(),n=dt(t),t.popScope(),r.scope&&Q(),i.push(y(p.elseifClause(e,n))),ot&&(o=at());return Z("else")&&(ot&&(o=new st(x),it.push(o)),r.scope&&J(),t.pushScope(),n=dt(t),t.popScope(),r.scope&&Q(),i.push(y(p.elseClause(n)))),$("end"),y(p.ifStatement(i))}(t);case"return":return V(),function(t){var e=[];if("end"!==w.value){var r=bt(t);for(null!=r&&e.push(r);Z(",");)r=wt(t),e.push(r);Z(";")}return y(p.returnStatement(e))}(t);case"function":return V(),mt(function(){var t,e,n;for(ot&&(n=at()),t=gt(),r.scope&&(rt(t,nt(t.name)),J());Z(".");)ut(n),e=gt(),t=y(p.memberExpression(t,".",e));return Z(":")&&(ut(n),e=gt(),t=y(p.memberExpression(t,":",e)),r.scope&&tt("self")),t}());case"while":return V(),function(t){var e=wt(t);$("do"),r.scope&&J(),t.pushScope(!0);var n=dt(t);return t.popScope(),r.scope&&Q(),$("end"),y(p.whileStatement(e,n))}(t);case"for":return V(),function(t){var e,n=gt();if(r.scope&&(J(),et(n)),Z("=")){var o=wt(t);$(",");var i=wt(t),a=Z(",")?wt(t):null;return $("do"),t.pushScope(!0),e=dt(t),t.popScope(),$("end"),r.scope&&Q(),y(p.forNumericStatement(n,o,i,a,e))}for(var s=[n];Z(",");)n=gt(),r.scope&&et(n),s.push(n);$("in");var c=[];do{var u=wt(t);c.push(u)}while(Z(","));return $("do"),t.pushScope(!0),e=dt(t),t.popScope(),$("end"),r.scope&&Q(),y(p.forGenericStatement(s,c,e))}(t);case"repeat":return V(),function(t){r.scope&&J(),t.pushScope(!0);var e=dt(t);$("until"),t.raiseDeferredErrors();var n=wt(t);return t.popScope(),r.scope&&Q(),y(p.repeatStatement(n,e))}(t);case"break":return V(),t.isInLoop()||M(w,d.noLoopToBreak,w.value),y(p.breakStatement());case"do":return V(),function(t){r.scope&&J(),t.pushScope();var e=dt(t);return t.popScope(),r.scope&&Q(),$("end"),y(p.doStatement(e))}(t);case"goto":return V(),yt(t)}return o.contextualGoto&&8===w.type&&"goto"===w.value&&8===_.type&&"goto"!==_.value?(V(),yt(t)):(ot&&it.pop(),function(t){var e,n,o,i,a,s=[];for(ot&&(n=at());;){if(ot&&(e=at()),8===w.type)a=w.value,i=gt(),r.scope&&rt(i,nt(a)),o=!0;else{if("("!==w.value)return B(w);V(),i=wt(t),$(")"),o=!1}t:for(;;){switch(2===w.type?'"':w.value){case".":case"[":o=!0;break;case":":case"(":case"{":case'"':o=null;break;default:break t}i=kt(i,e,t)}if(s.push(i),","!==w.value)break;if(!o)return B(w);V()}if(1===s.length&&null===o)return ut(e),y(p.callStatement(s[0]));if(!o)return B(w);$("=");var c=[];do{c.push(wt(t))}while(Z(","));return ut(n),y(p.assignmentStatement(s,c))}(t))}ot&&it.pop()}function yt(t){var e=w.value,r=x,n=gt();return t.addGoto(e,r),y(p.gotoStatement(n))}function gt(){ct();var t=w.value;return 8!==w.type&&I("<name>",w),V(),y(p.identifier(t))}function mt(t,e){var n=ht();n.pushScope();var o=[];if($("("),!Z(")"))for(;;){if(8===w.type){var i=gt();if(r.scope&&et(i),o.push(i),Z(","))continue}else h===w.type?(n.allowVararg=!0,o.push(At(n))):I("<name> or '...'",w);$(")");break}var a=dt(n);return n.popScope(),$("end"),r.scope&&Q(),e=e||!1,y(p.functionStatement(t,o,e,a))}function vt(t){for(var e,r,n=[];;){if(ct(),l===w.type&&Z("["))e=wt(t),$("]"),$("="),r=wt(t),n.push(y(p.tableKey(e,r)));else if(8===w.type)"="===_.value?(e=gt(),V(),r=wt(t),n.push(y(p.tableKeyString(e,r)))):(r=wt(t),n.push(y(p.tableValue(r))));else{if(null==(r=bt(t))){it.pop();break}n.push(y(p.tableValue(r)))}if(!(",;".indexOf(w.value)>=0))break;V()}return $("}"),y(p.tableConstructorExpression(n))}function bt(t){return _t(0,t)}function wt(t){var e=bt(t);if(null!=e)return e;I("<expression>",w)}function xt(t){var e=t.charCodeAt(0),r=t.length;if(1===r)switch(e){case 94:return 12;case 42:case 47:case 37:return 10;case 43:case 45:return 9;case 38:return 6;case 126:return 5;case 124:return 4;case 60:case 62:return 3}else if(2===r)switch(e){case 47:return 10;case 46:return 8;case 60:case 62:return"<<"===t||">>"===t?7:3;case 61:case 126:return 3;case 111:return 1}else if(97===e&&"and"===t)return 2;return 0}function _t(t,e){var n,o,i,a=w.value;if(ot&&(o=at()),function(t){return l===t.type?"#-~".indexOf(t.value)>=0:4===t.type&&"not"===t.value}(w)){ct(),V();var s=_t(10,e);null==s&&I("<expression>",w),n=y(p.unaryExpression(a,s))}if(null==n&&null==(n=At(e))&&(n=function(t){var e,n,o;if(ot&&(o=at()),8===w.type)n=w.value,e=gt(),r.scope&&rt(e,nt(n));else{if(!Z("("))return null;e=wt(t),$(")")}for(;;){var i=kt(e,o,t);if(null===i)break;e=i}return e}(e)),null==n)return null;for(;a=w.value,!(0===(i=l===w.type||4===w.type?xt(a):0)||i<=t);){"^"!==a&&".."!==a||--i,V();var c=_t(i,e);null==c&&I("<expression>",w),ot&&it.push(o),n=y(p.binaryExpression(a,n,c))}return n}function kt(t,e,r){var n,o;if(l===w.type)switch(w.value){case"[":return ut(e),V(),n=wt(r),$("]"),y(p.indexExpression(t,n));case".":return ut(e),V(),o=gt(),y(p.memberExpression(t,".",o));case":":return ut(e),V(),o=gt(),t=y(p.memberExpression(t,":",o)),ut(e),Et(t,r);case"(":case"{":return ut(e),Et(t,r)}else if(2===w.type)return ut(e),Et(t,r);return null}function Et(t,e){if(l===w.type)switch(w.value){case"(":o.emptyStatement||w.line!==x.line&&M(null,d.ambiguousSyntax,w.value),V();var r=[],n=bt(e);for(null!=n&&r.push(n);Z(",");)n=wt(e),r.push(n);return $(")"),y(p.callExpression(t,r));case"{":ct(),V();var i=vt(e);return y(p.tableCallExpression(t,i))}else if(2===w.type)return y(p.stringCallExpression(t,At(e)));I("function arguments",w)}function At(t){var n,o=w.value,i=w.type;if(ot&&(n=at()),i!==h||t.allowVararg||M(w,d.cannotUseVararg,w.value),466&i){ut(n);var a=e.slice(w.range[0],w.range[1]);return V(),y(p.literal(i,o,a))}return 4===i&&"function"===o?(ut(n),V(),r.scope&&J(),mt(null)):Z("{")?(ut(n),vt(t)):void 0}st.prototype.complete=function(){r.locations&&(this.loc.end.line=x.lastLine||x.line,this.loc.end.column=x.range[1]-(x.lastLineStart||x.lineStart)),r.ranges&&(this.range[1]=x.range[1])},st.prototype.bless=function(t){if(this.loc){var e=this.loc;t.loc={start:{line:e.start.line,column:e.start.column},end:{line:e.end.line,column:e.end.column}}}this.range&&(t.range=[this.range[0],this.range[1]])},lt.prototype.isInLoop=function(){for(var t=this.scopes.length;t-- >0;)if(this.scopes[t].isLoop)return!0;return!1},lt.prototype.pushScope=function(t){var e={labels:{},locals:[],deferredGotos:[],isLoop:!!t};this.scopes.push(e)},lt.prototype.popScope=function(){for(var t=0;t<this.pendingGotos.length;++t){var e=this.pendingGotos[t];e.maxDepth>=this.scopes.length&&--e.maxDepth<=0&&M(e.token,d.labelNotVisible,e.target)}this.scopes.pop()},lt.prototype.addGoto=function(t,e){for(var r=[],n=0;n<this.scopes.length;++n){var o=this.scopes[n];if(r.push(o.locals.length),Object.prototype.hasOwnProperty.call(o.labels,t))return}this.pendingGotos.push({maxDepth:this.scopes.length,target:t,token:e,localCounts:r})},lt.prototype.addLabel=function(t,e){var r=this.currentScope();if(Object.prototype.hasOwnProperty.call(r.labels,t))M(e,d.labelAlreadyDefined,t,r.labels[t].line);else{for(var n=[],o=0;o<this.pendingGotos.length;++o){var i=this.pendingGotos[o];i.maxDepth>=this.scopes.length&&i.target===t?i.localCounts[this.scopes.length-1]<r.locals.length&&r.deferredGotos.push(i):n.push(i)}this.pendingGotos=n}r.labels[t]={localCount:r.locals.length,line:e.line}},lt.prototype.addLocal=function(t,e){this.currentScope().locals.push({name:t,token:e})},lt.prototype.currentScope=function(){return this.scopes[this.scopes.length-1]},lt.prototype.raiseDeferredErrors=function(){for(var t=this.currentScope(),e=t.deferredGotos,r=0;r<e.length;++r){var n=e[r];M(n.token,d.gotoJumpInLocalScope,n.target,t.locals[n.localCounts[this.scopes.length-1]].name)}},ft.prototype.isInLoop=function(){return!!this.loopLevels.length},ft.prototype.pushScope=function(t){++this.level,t&&this.loopLevels.push(this.level)},ft.prototype.popScope=function(){var t=this.loopLevels,e=t.length;e&&t[e-1]===this.level&&t.pop(),--this.level},ft.prototype.addGoto=ft.prototype.addLabel=function(){throw new Error("This should never happen")},ft.prototype.addLocal=ft.prototype.raiseDeferredErrors=function(){},t.parse=function(s,c){if(void 0===c&&"object"==typeof s&&(c=s,s=void 0),c||(c={}),e=s||"",r=T({},a,c),b=0,A=1,S=0,n=e.length,L=[[]],O=0,P=[],it=[],!Object.prototype.hasOwnProperty.call(St,r.luaVersion))throw new Error(v("Lua version '%1' not supported",r.luaVersion));if(o=T({},St[r.luaVersion]),void 0!==r.extendedIdentifiers&&(o.extendedIdentifiers=!!r.extendedIdentifiers),!Object.prototype.hasOwnProperty.call(u,r.encodingMode))throw new Error(v("Encoding mode '%1' not supported",r.encodingMode));return i=u[r.encodingMode],r.comments&&(k=[]),r.wait?t:Ot()};var St={5.1:{},5.2:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,relaxedBreak:!0},5.3:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,bitwiseOperators:!0,integerDivision:!0,relaxedBreak:!0},LuaJIT:{labels:!0,contextualGoto:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,imaginaryNumbers:!0,integerSuffixes:!0}};function Lt(r){return e+=String(r),n=e.length,t}function Ot(t){void 0!==t&&Lt(t),e&&"#!"===e.substr(0,2)&&(e=e.replace(/^.*/,(function(t){return t.replace(/./g," ")}))),n=e.length,ot=r.locations||r.ranges,_=z();var o=function(){V(),ct(),r.scope&&J();var t=ht();t.allowVararg=!0,t.pushScope();var e=dt(t);return t.popScope(),r.scope&&Q(),1!==w.type&&B(w),ot&&!e.length&&(x=w),y(p.chunk(e))}();if(r.comments&&(o.comments=k),r.scope&&(o.globals=P),it.length>0)throw new Error("Location tracking failed. This is most likely a bug in luaparse");return o}t.write=Lt,t.end=Ot}))},2703:(t,e,r)=>{"use strict";var n=r(414);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,r,o,i,a){if(a!==n){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function e(){return t}t.isRequired=t;var r={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return r.PropTypes=r,r}},5697:(t,e,r)=>{t.exports=r(2703)()},414:t=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},9921:(t,e)=>{"use strict";var r="function"==typeof Symbol&&Symbol.for,n=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,a=r?Symbol.for("react.strict_mode"):60108,s=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,u=r?Symbol.for("react.context"):60110,l=r?Symbol.for("react.async_mode"):60111,f=r?Symbol.for("react.concurrent_mode"):60111,h=r?Symbol.for("react.forward_ref"):60112,d=r?Symbol.for("react.suspense"):60113,p=r?Symbol.for("react.suspense_list"):60120,y=r?Symbol.for("react.memo"):60115,g=r?Symbol.for("react.lazy"):60116,m=r?Symbol.for("react.block"):60121,v=r?Symbol.for("react.fundamental"):60117,b=r?Symbol.for("react.responder"):60118,w=r?Symbol.for("react.scope"):60119;function x(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case n:switch(t=t.type){case l:case f:case i:case s:case a:case d:return t;default:switch(t=t&&t.$$typeof){case u:case h:case g:case y:case c:return t;default:return e}}case o:return e}}}function _(t){return x(t)===f}e.AsyncMode=l,e.ConcurrentMode=f,e.ContextConsumer=u,e.ContextProvider=c,e.Element=n,e.ForwardRef=h,e.Fragment=i,e.Lazy=g,e.Memo=y,e.Portal=o,e.Profiler=s,e.StrictMode=a,e.Suspense=d,e.isAsyncMode=function(t){return _(t)||x(t)===l},e.isConcurrentMode=_,e.isContextConsumer=function(t){return x(t)===u},e.isContextProvider=function(t){return x(t)===c},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===n},e.isForwardRef=function(t){return x(t)===h},e.isFragment=function(t){return x(t)===i},e.isLazy=function(t){return x(t)===g},e.isMemo=function(t){return x(t)===y},e.isPortal=function(t){return x(t)===o},e.isProfiler=function(t){return x(t)===s},e.isStrictMode=function(t){return x(t)===a},e.isSuspense=function(t){return x(t)===d},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===f||t===s||t===a||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===g||t.$$typeof===y||t.$$typeof===c||t.$$typeof===u||t.$$typeof===h||t.$$typeof===v||t.$$typeof===b||t.$$typeof===w||t.$$typeof===m)},e.typeOf=x},9864:(t,e,r)=>{"use strict";t.exports=r(9921)},3872:(t,e,r)=>{"use strict";r.d(e,{collect:()=>q});const n={currentComponent:null,isBatchUpdating:!1,isInBrowser:"undefined"!=typeof window,listeners:new Map,manualListeners:[],nextVersionMap:new WeakMap,proxyIsMuted:!1,redirectToNext:!0,store:{}},o=Symbol("PATH"),i=Symbol("ORIGINAL"),a="RR_DEBUG",s=t=>!!t&&"object"==typeof t&&t.constructor===Object,c=t=>Array.isArray(t),u=t=>t instanceof Map,l=t=>t instanceof Set,f=t=>s(t)||c(t)||u(t)||l(t),h=t=>t===o||"constructor"===t||"toJSON"===t||"@@toStringTag"===t||t===Symbol.toStringTag,d=t=>"function"==typeof t,p=t=>s(t)?Object.assign({},t):c(t)?t.slice():u(t)?new Map(t):l(t)?new Set(t):t,y=(t,e)=>u(t)?t.get(e):l(t)?e:(c(t),t[e]),g=(t,e,r)=>{if(s(t))t[e]=r;else if(c(t))t[e]=r;else if(u(t))t.set(e,r);else{if(!l(t))throw Error("Unexpected type");t.add(r)}},m=t=>{if(s(t))return Object.keys(t).length;if(c(t))return t.length;if(u(t)||l(t))return t.size;throw Error("Unexpected type")},v=(t,e)=>{const r=[],n=t=>{const o=e(t,r.slice()),i=void 0!==o?o:t,a=(t,e)=>{r.push(t);const o=n(e);r.pop(),g(i,t,o)};if(s(i))Object.entries(i).forEach((([t,e])=>{a(t,e)}));else if(c(i)||u(i))i.forEach(((t,e)=>{a(e,t)}));else if(l(i)){const t=Array.from(i);i.clear(),t.forEach((t=>{a(t,t)}))}return i};return n(t)},b=t=>{n.proxyIsMuted=!0;const e=t();return n.proxyIsMuted=!1,e},w=(t,e)=>t.map((t=>t.toString())).join(e),x=t=>w(t,"."),_=t=>w(t,"~~~"),k=(t,e)=>{const r=t[o]||[];return void 0===e?r:r.concat(e)},E=(t,e)=>x(k(t,e)),A=(t,e)=>{t&&Object.defineProperty(t,o,{value:e,writable:!0})},S=t=>t[o]||[],L="undefined"!=typeof window&&!!window.localStorage,O=(t,e)=>{if(L)try{const r="string"==typeof e?e:JSON.stringify(e);return localStorage.setItem(t,r)}catch(t){return}},P="on",T="off";let C=(t=>{if(!L)return;const e=localStorage.getItem("RR_DEBUG");if(!e)return e;try{return JSON.parse(e)}catch(t){return e}})()||T;C===P&&console.info("Recollect debugging is enabled. Type __RR__.debugOff() to turn it off.");const M=t=>{C===P&&t()},j=(t,e,r)=>{M((()=>{console.groupCollapsed(`GET: ${E(t,e)}`),console.info(`Component: <${n.currentComponent._name}>`),void 0!==r&&console.info("Value:",r),console.groupEnd()}))},I=(t,e,r)=>{M((()=>{console.groupCollapsed(`SET: ${E(t,e)}`),console.info("From:",y(t,e)),console.info("To: ",r),console.groupEnd()}))},B={},z=t=>B.UpdateNextStore(t),D=t=>{if(!n.currentComponent)return;const e=_(t),r=n.listeners.get(e)||new Set;r.add(n.currentComponent),n.listeners.set(e,r)},N=t=>{return new Proxy(t,u(e=t)||l(e)?{get(t,e){if(e===i)return t;let r=Reflect.get(t,e);if(d(r)&&(r=r.bind(t)),n.proxyIsMuted||h(e))return r;if(!n.currentComponent&&n.redirectToNext){const r=n.nextVersionMap.get(t);if(r)return Reflect.get(r,e)}return"set"===e?new Proxy(r,{apply:(r,n,[o,i])=>n.get(o)===i||z({target:n,prop:o,value:i,updater:(r,n)=>(I(t,e,n),Reflect.apply(r[e],r,[o,n]))})}):"add"===e?new Proxy(r,{apply:(r,n,[o])=>!!n.has(o)||z({target:n,notifyTarget:!0,value:o,updater:(r,n)=>(I(t,e,n),Reflect.apply(r[e],r,[n]))})}):"clear"===e||"delete"===e?new Proxy(r,{apply:(r,n,[o])=>!(!n.size||"delete"===e&&!n.has(o))&&z({target:n,notifyTarget:!0,updater:r=>(I(t,e),Reflect.apply(r[e],r,[o]))})}):n.currentComponent&&u(t)&&"get"===e?new Proxy(r,{apply:(e,r,n)=>(D(k(t,n[0])),Reflect.apply(e,r,n))}):r}}:{get(t,e){if(e===i)return t;const r=Reflect.get(t,e);if(n.proxyIsMuted||h(e))return r;if(((t,e)=>c(t)&&["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"].includes(e))(t,e))return new Proxy(r,{apply:(r,n,o)=>z({target:n,notifyTarget:!0,value:o,updater:(r,n)=>{I(t,e,n);const o=Reflect.apply(r[e],r,n),i=S(t);return v(r,((t,e)=>{f(t)&&A(t,[...i,...e])})),o}})});if(d(t[e]))return r;if(n.currentComponent)c(t)&&"length"===e||(j(t,e,r),D(k(t,e)));else if(n.redirectToNext){const r=n.nextVersionMap.get(t);if(r)return Reflect.get(r,e)}return r},has(t,e){const r=Reflect.has(t,e);if(n.proxyIsMuted||h(e))return r;if(n.currentComponent)c(t)||(j(t,e),D(k(t,e)));else{const r=n.nextVersionMap.get(t);if(r)return Reflect.has(r,e)}return r},ownKeys(t){const e=Reflect.ownKeys(t);if(n.proxyIsMuted)return e;if(n.currentComponent)j(t),D(S(t));else{const e=n.nextVersionMap.get(t);if(e)return Reflect.ownKeys(e)}return e},set:(t,e,r)=>n.proxyIsMuted?Reflect.set(t,e,r):t[e]===r||z({target:t,prop:e,value:r,updater:(r,n)=>(I(t,e,n),Reflect.set(r,e,n))}),deleteProperty:(t,e)=>n.proxyIsMuted?Reflect.deleteProperty(t,e):z({target:t,prop:e,notifyTarget:!0,updater:r=>(((t,e)=>{M((()=>{console.groupCollapsed(`DELETE: ${E(t,e)}`),console.info("Property: ",E(t,e)),console.groupEnd()}))})(t,e),Reflect.deleteProperty(r,e))})});var e};var R=r(5156);const F=r.n(R)().unstable_batchedUpdates||(t=>{t()}),U={components:new Map,changedPaths:new Set};var G;n.store=N({}),G=({target:t,prop:e,value:r,notifyTarget:o=!1,updater:a})=>b((()=>{let s;const c=S(t),u=k(t,e);let l=!1;const h=m(t);let d=r;return f(d)&&(d=v(r,((t,e)=>{if(!f(t))return t;const r=p(t);return A(r,[...u,...e]),N(r)}))),c.length?c.reduce(((e,r,o)=>{const u=y(e,r);let f=p(u);return A(f,S(u)),f=N(f),g(e,r,f),o===c.length-1&&(s=a(f,d),l=m(f)!==h,n.nextVersionMap.set(t[i]||t,f)),f}),n.store):(s=a(n.store,d),l=m(n.store)!==h),(t=>{const e=_(t),r=x(t);U.changedPaths.add(r),n.listeners.forEach(((t,n)=>{""!==e&&e!==n||t.forEach((t=>{const e=U.components.get(t)||new Set;e.add(r),U.components.set(t,e)}))})),n.isBatchUpdating||(F((()=>{U.components.forEach(((t,e)=>{((t,e)=>{M((()=>{console.groupCollapsed(`UPDATE: <${t._name}>`),console.info("Changed properties:",e),console.groupEnd()}))})(e,Array.from(t)),e.update()}))})),n.manualListeners.forEach((t=>t({changedProps:Array.from(U.changedPaths),renderedComponents:Array.from(U.components.keys()),store:n.store}))),U.components.clear(),U.changedPaths.clear())})(o||l?c:u),s})),B.UpdateNextStore=G;var W=r(9787),V=r.n(W),Z=r(8679),$=r.n(Z);const Y=[],K=()=>{n.isInBrowser&&(M((()=>{console.groupEnd()})),Y.pop(),n.currentComponent=Y[Y.length-1]||null)},H=()=>b((()=>{const t=Object.assign({},n.store);return n.nextVersionMap.set(t,n.store),N(t)})),q=t=>{const e=t.displayName||t.name||"NamelessComponent";class r extends V().PureComponent{constructor(){super(...arguments),this.state={store:H()},this._isMounted=!1,this._isMounting=!0,this._isRendering=!1,this._name=e}componentDidMount(){this._isMounted=!0,this._isMounting=!1,K(),this._isRendering=!1}componentDidUpdate(){K(),this._isRendering=!1}componentWillUnmount(){var t;t=this,n.listeners.forEach(((e,r)=>{const o=Array.from(e).filter((e=>e!==t));o.length?n.listeners.set(r,new Set(o)):n.listeners.delete(r)})),this._isMounted=!1}update(){(this._isMounted||this._isMounting)&&this.setState({store:H()})}render(){var e;this._isRendering||(e=this,n.isInBrowser&&(M((()=>{console.groupCollapsed(`RENDER: <${e._name}>`)})),n.currentComponent=e,Y.push(n.currentComponent)),this._isRendering=!0);const r=Object.assign(Object.assign({},this.props),{store:this.state.store});return V().createElement(t,Object.assign({},r))}}return r.displayName=`Collected(${e})`,$()(r,t)};let X;X=r(5697);const{store:J}=n;"undefined"!=typeof window&&("Proxy"in window?window.__RR__={debugOn:()=>{C=P,O(a,P)},debugOff:()=>{C=T,O(a,T)},internals:n}:console.warn("This browser doesn't support the Proxy object, which react-recollect needs. See https://caniuse.com/#search=proxy to find out which browsers do support it"))},5565:(t,e,r)=>{t.exports=r(3872)},3379:t=>{"use strict";var e=[];function r(t){for(var r=-1,n=0;n<e.length;n++)if(e[n].identifier===t){r=n;break}return r}function n(t,n){for(var i={},a=[],s=0;s<t.length;s++){var c=t[s],u=n.base?c[0]+n.base:c[0],l=i[u]||0,f="".concat(u," ").concat(l);i[u]=l+1;var h=r(f),d={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)e[h].references++,e[h].updater(d);else{var p=o(d,n);n.byIndex=s,e.splice(s,0,{identifier:f,updater:p,references:1})}a.push(f)}return a}function o(t,e){var r=e.domAPI(e);return r.update(t),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;r.update(t=e)}else r.remove()}}t.exports=function(t,o){var i=n(t=t||[],o=o||{});return function(t){t=t||[];for(var a=0;a<i.length;a++){var s=r(i[a]);e[s].references--}for(var c=n(t,o),u=0;u<i.length;u++){var l=r(i[u]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}i=c}}},569:t=>{"use strict";var e={};t.exports=function(t,r){var n=function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(t){r=null}e[t]=r}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(r)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},6636:(t,e,r)=>{"use strict";t.exports=function(t){var e=r.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(r){!function(t,e,r){var n="";r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var o=void 0!==r.layer;o&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,o&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}");var i=r.sourceMap;i&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,r)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589: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))}}},4668:(t,e,r)=>{var n={"./animate.js":5019,"./changezone.js":4146,"./chat.js":6023,"./dance.js":3582,"./dialogue.js":3419,"./face.js":8463,"./greeting.js":3972,"./interact.js":1726,"./move.js":6481,"./patrol.js":955,"./prompt.js":5214,"./script.js":6027};function o(t){var e=i(t);return r(e)}function i(t){if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return n[t]}o.keys=function(){return Object.keys(n)},o.resolve=i,t.exports=o,o.id=4668},7996:(t,e,r)=>{var n={"./camera.js":8826,"./chat.js":3565,"./menu.js":48};function o(t){var e=i(t);return r(e)}function i(t){if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return n[t]}o.keys=function(){return Object.keys(n)},o.resolve=i,t.exports=o,o.id=7996},746:(t,e,r)=>{var n={"./cosmic/fs.js":7745,"./matrix/fs.js":5401,"./morning/fs.js":2628,"./neon/fs.js":471,"./sky/fs.js":8143,"./sunset/fs.js":8135};function o(t){return Promise.resolve().then((()=>{if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r(n[t])}))}o.keys=()=>Object.keys(n),o.id=746,t.exports=o},4970:(t,e,r)=>{var n={"./cosmic/vs.js":5564,"./matrix/vs.js":488,"./morning/vs.js":939,"./neon/vs.js":202,"./sky/vs.js":6568,"./sunset/vs.js":8299};function o(t){return Promise.resolve().then((()=>{if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r(n[t])}))}o.keys=()=>Object.keys(n),o.id=4970,t.exports=o},4016:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=4016,t.exports=e},9787:e=>{"use strict";e.exports=t},5156:t=>{"use strict";t.exports=e}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={id:t,loaded:!1,exports:{}};return r[t].call(i.exports,i,i.exports,o),i.loaded=!0,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 r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.e=()=>Promise.resolve(),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.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),o.nc=void 0;var i={};return(()=>{"use strict";o.d(i,{default:()=>se});var t=o(9787),e=o.n(t),r=o(5565),n=o(5697),a=o.n(n),s=o(9124),c=o(5490);function u(t){return u="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},u(t)}function l(){l=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h={};function d(){}function p(){}function y(){}var g={};s(g,o,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(S([])));v&&v!==e&&r.call(v,o)&&(g=v);var b=y.prototype=d.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,s){var c=f(t[o],t,i);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==u(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,s(b,"constructor",y),s(y,"constructor",p),p.displayName=s(y,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,a,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,a,"Generator"),s(b,o,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,h):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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function f(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function h(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){f(i,n,o,a,s,"next",t)}function s(t){f(i,n,o,a,s,"throw",t)}a(void 0)}))}}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(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 p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function g(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?y(Object(r),!0).forEach((function(e){m(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function m(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var v=function(r){var n=r.width,o=r.height,i=r.SpritzProvider,a=r.class,u=r.zipData,f=(0,t.useRef)(),p=(0,t.useRef)(),y=(0,t.useRef)(),m=(0,t.useRef)(),v=(0,t.useRef)(),b=((0,t.useRef)(),(0,t.useRef)(),(0,t.useRef)(),(0,t.useRef)()),w=((0,t.useRef)(),(0,t.useRef)(),function(t){try{i&&i.onKeyEvent&&i.onKeyEvent(t)}catch(t){}}),x=function(t){try{var e=p.current;if(e&&void 0!==t.clientX){var r=e.getBoundingClientRect(),n=e.width/r.width,o=e.height/r.height,a=g(g({},t),{},{clientX:t.clientX,clientY:t.clientY,_canvasRect:r,_scaleX:n,_scaleY:o});i&&i.onTouchEvent&&i.onTouchEvent(a)}else i&&i.onTouchEvent&&i.onTouchEvent(t)}catch(t){}},_=null,k=d((0,t.useState)(!1),2),E=(k[0],k[1],d((0,t.useState)(!1),2)),A=E[0],S=(E[1],d((0,t.useState)(),2)),L=(S[0],S[1],d((0,t.useState)(),2)),O=(L[0],L[1],d((0,t.useState)({dynamicWidth:window.innerWidth,dynamicHeight:window.innerHeight}),2)),P=O[0],T=O[1],C=function(){T({dynamicWidth:window.innerWidth,dynamicHeight:window.innerHeight})};function M(){return j.apply(this,arguments)}function j(){return(j=h(l().mark((function t(){return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.Ky.load();case 2:document.fonts.add(c.Ky);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function I(t){document.body.addEventListener("touchstart",(function(e){e.target==t&&e.preventDefault()}),{passive:!1}),document.body.addEventListener("touchend",(function(e){e.target==t&&e.preventDefault()}),{passive:!1}),document.body.addEventListener("touchmove",(function(e){e.target==t&&e.preventDefault()}),{passive:!1})}(0,t.useEffect)(h(l().mark((function t(){var e,r,a,c,u;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return window.addEventListener("resize",C),e=f.current,r=p.current,a=v.current,c=y.current,u=m.current,_=new s.Z(e,r,a,c,u,n,o),t.next=9,M();case 9:return t.next=11,_.init(i);case 11:return _.render(),t.abrupt("return",(function(){I(e),I(c),I(r),window.removeEventListener("resize",C),_.close()}));case 13:case"end":return t.stop()}}),t)}))),[i]);var B=3*P.dynamicWidth/4>1080?1080:P.dynamicHeight,z=3*P.dynamicWidth/4>1080?B:B-200,D=P.dynamicWidth>1920?1920:P.dynamicWidth,N=P.dynamicWidth<=900;return e().createElement("div",{style:{marginLeft:"auto",marginRight:"auto"}},e().createElement("div",{style:{position:"relative",padding:"none",background:"var(--color-bg, #0a0a0f)",height:z+"px",width:D+"px"},onKeyDownCapture:function(t){return w(t.nativeEvent)},onKeyUpCapture:function(t){return w(t.nativeEvent)},tabIndex:0},e().createElement("div",{style:{display:A?"none":"block"}},e().createElement("canvas",{style:{position:"absolute",zIndex:1,top:0,left:0,width:"100%",height:"100%"},ref:f,width:D,height:z,className:a}),e().createElement("canvas",{style:{position:"absolute",zIndex:2,top:0,left:0,background:"none",width:"100%",height:"100%"},ref:p,width:D,height:z,className:a,onMouseUp:function(t){return x(t.nativeEvent)},onMouseDown:function(t){return x(t.nativeEvent)},onMouseMove:function(t){return x(t.nativeEvent)}}),e().createElement("canvas",{style:{display:"none"},ref:v,width:256,height:256}),e().createElement("canvas",{width:D,height:z,ref:b,style:{display:"none"}}))),e().createElement("div",{style:{width:D+"px",height:N?"200px":"1px",marginTop:N?"10px":"0px",position:"relative",overflow:"hidden"}},e().createElement("canvas",{style:{position:"absolute",zIndex:5,top:0,left:0,background:"none",width:"100%",height:"100%",display:N?"block":"none"},ref:y,width:D,height:200,className:a,onMouseUp:function(t){return x(t.nativeEvent)},onMouseDown:function(t){return x(t.nativeEvent)},onMouseMove:function(t){return x(t.nativeEvent)},onTouchMoveCapture:function(t){return x(t.nativeEvent)},onTouchCancelCapture:function(t){return x(t.nativeEvent)},onTouchStartCapture:function(t){return x(t.nativeEvent)},onTouchEndCapture:function(t){return x(t.nativeEvent)}})),e().createElement("div",null,e().createElement("input",{type:"file",ref:m,src:null!=u?u:null,hidden:!0})))};v.propTypes={width:a().number.isRequired,height:a().number.isRequired,SpritzProvider:a().object.isRequired,class:a().string.isRequired};const b=v;var w=o(3162),x=o(5733),_=o.n(x),k=o(4395),E=o(5867),A=o(7974),S=o(9010),L=o(679),O=o(6083);function P(t){return P="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},P(t)}function T(){T=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==P(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function C(t,e,r){return C=M()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&j(o,r.prototype),o},C.apply(null,arguments)}function M(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function j(t,e){return j=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},j(t,e)}function I(t){return function(t){if(Array.isArray(t))return B(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 B(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?B(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 B(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function z(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function D(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){z(i,n,o,a,s,"next",t)}function s(t){z(i,n,o,a,s,"throw",t)}a(void 0)}))}}function N(t,e,r){return R.apply(this,arguments)}function R(){return R=D(T().mark((function t(e,r,n){var o,i,a,s,c,u=this,l=arguments;return T().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=l.length>3&&void 0!==l[3]?l[3]:null,console.log("loading map...."),o&&console.log("[loadMap] Using heights data:",o.length,"rows"),i="string"==typeof e.sprites?e.sprites:e.sprites.map((function(t){var e;return{id:t.id,type:t.type,pos:C(S.OW,I(t.pos)),facing:k.Nm[t.facing],zones:null!==(e=t.zones)&&void 0!==e?e:null}})),a=e.scenes.map((function(t){return{id:t.id,actions:t.actions.map((function(t){return t.trigger?{trigger:t.trigger,scope:u}:{sprite:t.sprite,action:t.action,args:t.args,scope:u}})),scope:u}})),t.next=7,Promise.all(e.scripts.map(function(){var t=D(T().mark((function t(e){var r,o,i;return T().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,(r=n.file("triggers/".concat(e.trigger,".lua")))||(r=n.file("triggers/".concat(e.trigger,".pxs"))),t.next=5,r.async("string");case 5:return o=t.sent,console.log({msg:"lua script",luaScript:o}),i=function(t){var r,n=new O.Z(t.engine);return n.setScope({_this:t,zone:u,subject:t}),n.initLibrary(),n.run('print("hello world lua - zone")'),{id:e.id,trigger:(r=D(T().mark((function t(){return T().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("running actual trigger"),t.abrupt("return",n.run(o));case 2:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})}}.bind(u)(u),console.log({msg:"zone trigger Lua eval response",result:i}),t.abrupt("return",i);case 12:t.prev=12,t.t0=t.catch(0),console.error(t.t0);case 15:case"end":return t.stop()}}),t,null,[[0,12]])})));return function(e){return t.apply(this,arguments)}}()));case 7:return s=t.sent,c=e.objects.map((function(t){return{id:t.id,type:t.type,mtl:t.mtl,useScale:t.useScale?C(S.OW,I(t.useScale)):null,pos:t.pos?C(S.OW,I(t.pos)):null,rotation:t.rotation?C(S.OW,I(t.rotation)):null}})),t.abrupt("return",{bounds:e.bounds,tileset:e.tileset,cells:r,heights:o,sprites:i,scenes:a,scripts:s,objects:c,lights:e.lights,selectTrigger:e.selectTrigger});case 10:case"end":return t.stop()}}),t)}))),R.apply(this,arguments)}function F(t,e){if("string"==typeof t)return t;var r=[];return t.forEach((function(t,n){var o=t.length;t.forEach((function(t,i){r[n*o+i]=e[t]}))})),r}function U(t){return U="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},U(t)}function G(t){return function(t){if(Array.isArray(t))return K(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Y(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 W(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function V(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?W(Object(r),!0).forEach((function(e){et(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):W(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Z(){Z=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==U(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function $(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Y(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function Y(t,e){if(t){if("string"==typeof t)return K(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?K(t,e):void 0}}function K(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function H(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function q(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){H(i,n,o,a,s,"next",t)}function s(t){H(i,n,o,a,s,"throw",t)}a(void 0)}))}}function X(t,e){return X=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},X(t,e)}function J(t,e){if(e&&("object"===U(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Q(t)}function Q(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tt(t){return tt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},tt(t)}function et(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var rt=function(t){!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&&X(t,e)}(a,t);var e,r,n,i=(r=a,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=tt(r);if(n){var o=tt(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return J(this,t)});function a(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),et(Q(r=i.call(this)),"getZoneData",(function(){return{id:r.id,objId:r.objId,scripts:r.scripts,data:r.data,objects:Object.keys(r.objectDict),sprites:Object.keys(r.spriteDict),selectedTiles:r.selectedTiles}})),et(Q(r),"afterTilesetAndActorsLoaded",(function(){var t;!r.loaded&&null!==(t=r.tileset)&&void 0!==t&&t.loaded&&r.spriteList.every((function(t){return t.loaded}))&&r.objectList.every((function(t){return t.loaded}))&&(r.loaded=!0,r.loadScripts(!0),r.onLoadActions.run())})),et(Q(r),"attachTilesetListeners",(function(){r.tileset.runWhenDefinitionLoaded(r.onTilesetDefinitionLoaded),r.tileset.runWhenLoaded(r.afterTilesetAndActorsLoaded)})),et(Q(r),"finalize",q(Z().mark((function t(){var e,n,o,i;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=$(r.spriteList);try{for(e.s();!(n=e.n()).done;)n.value.runWhenLoaded(r.afterTilesetAndActorsLoaded)}catch(t){e.e(t)}finally{e.f()}o=$(r.objectList);try{for(o.s();!(i=o.n()).done;)i.value.runWhenLoaded(r.afterTilesetAndActorsLoaded)}catch(t){o.e(t)}finally{o.f()}r.engine.networkManager.loadZone(r.id,Q(r));case 5:case"end":return t.stop()}}),t)})))),et(Q(r),"loadRemote",q(Z().mark((function t(){var e,n,o,i;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(E.Z.zoneRequestUrl(r.id));case 2:if((e=t.sent).ok){t.next=5;break}return t.abrupt("return");case 5:return t.prev=5,t.next=8,e.json();case 8:return i=t.sent,r.bounds=i.bounds,r.size=[i.bounds[2]-i.bounds[0],i.bounds[3]-i.bounds[1]],r.cells="function"==typeof i.cells?i.cells(r.bounds,Q(r)):i.cells,r.sprites="function"==typeof i.sprites?i.sprites(r.bounds,Q(r)):i.sprites||[],r.objects="function"==typeof i.objects?i.objects(r.bounds,Q(r)):i.objects||[],t.next=16,r.tsLoader.load(i.tileset,r.spritzName);case 16:return r.tileset=t.sent,r.attachTilesetListeners(),r.audioSrc&&(r.audio=r.engine.resourceManager.audioLoader.load(r.audioSrc,!0)),t.next=21,Promise.all([Promise.all(r.sprites.map(r.loadSprite)),Promise.all(r.objects.map(r.loadObject))]);case 21:if(!i.skyboxShader||null===(n=r.engine.renderManager)||void 0===n||null===(o=n.skyboxManager)||void 0===o||!o.setSkyboxShader){t.next=24;break}return t.next=24,r.engine.renderManager.skyboxManager.setSkyboxShader(i.skyboxShader);case 24:return t.next=26,r.finalize();case 26:if(t.prev=26,!i.mode){t.next=30;break}return t.next=30,r.loadMode(i.mode);case 30:t.next=35;break;case 32:t.prev=32,t.t0=t.catch(26),console.warn("zone mode load failed",t.t0);case 35:t.next=40;break;case 37:t.prev=37,t.t1=t.catch(5),console.error("Error parsing zone "+r.id,t.t1);case 40:case"end":return t.stop()}}),t,null,[[5,37],[26,32]])})))),et(Q(r),"load",q(Z().mark((function t(){var e,n,i;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=o(4016)("./"+r.spritzName+"/maps/"+r.id+"/map.js").default,Object.assign(Q(r),i),"function"==typeof r.cells&&(r.cells=r.cells(r.bounds,Q(r))),r.audioSrc&&(r.audio=r.engine.resourceManager.audioLoader.load(r.audioSrc,!0)),r.size=[r.bounds[2]-r.bounds[0],r.bounds[3]-r.bounds[1]],t.next=8,r.tsLoader.load(r.tileset,r.spritzName);case 8:return r.tileset=t.sent,r.attachTilesetListeners(),"function"==typeof r.sprites&&(r.sprites=r.sprites(r.bounds,Q(r))),r.sprites=r.sprites||[],r.objects=r.objects||[],t.next=15,Promise.all([Promise.all(r.sprites.map(r.loadSprite)),Promise.all(r.objects.map(r.loadObject))]);case 15:if(!i.skyboxShader||null===(e=r.engine.renderManager)||void 0===e||null===(n=e.skyboxManager)||void 0===n||!n.setSkyboxShader){t.next=18;break}return t.next=18,r.engine.renderManager.skyboxManager.setSkyboxShader(i.skyboxShader);case 18:return t.next=20,r.finalize();case 20:if(t.prev=20,!i.mode){t.next=24;break}return t.next=24,r.loadMode(i.mode);case 24:t.next=29;break;case 26:t.prev=26,t.t0=t.catch(20),console.warn("zone mode load failed",t.t0);case 29:try{r.engine.networkManager.joinZone(r.id)}catch(t){console.warn("Network Error :: could not send zone commend to server")}t.next=35;break;case 32:t.prev=32,t.t1=t.catch(0),console.error("Error parsing zone "+r.id,t.t1);case 35:case"end":return t.stop()}}),t,null,[[0,32],[20,26]])})))),et(Q(r),"loadTriggerFromZip",function(){var t=q(Z().mark((function t(e,n){var o,i,a,s,c,u,l,f,h,d;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,n.file("triggers/".concat(e,".lua"));case 3:if(!(o=t.sent)){t.next=9;break}return t.next=7,o.async("string");case 7:return i=t.sent,t.abrupt("return",(function(t,e){var n=new O.Z(t.engine);return n.setScope({_this:t,zone:Q(r),subject:e}),n.initLibrary(),n.run(i)}));case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),null!==(a=r.engine)&&void 0!==a&&a.debug&&console.warn("Lua trigger load failed",t.t0);case 14:return t.prev=14,t.next=17,n.file("triggers/".concat(e,".pxs"));case 17:if(!(s=t.sent)){t.next=23;break}return t.next=21,s.async("string");case 21:return c=t.sent,t.abrupt("return",(function(t,e){var n=new O.Z(t.engine);return n.setScope({_this:t,zone:Q(r),subject:e}),n.initLibrary(),n.run(c)}));case 23:t.next=28;break;case 25:t.prev=25,t.t1=t.catch(14),null!==(u=r.engine)&&void 0!==u&&u.debug&&console.warn("PixoScript trigger load failed",t.t1);case 28:return t.next=30,n.file("triggers/".concat(e,".js"));case 30:if(!(l=t.sent)){t.next=39;break}return t.next=34,l.async("string");case 34:if(f=t.sent,h=new Function("zone","engine","".concat(f,"; return (typeof module !== 'undefined' && module.exports) ? module.exports : (typeof exports !== 'undefined' ? exports : (typeof trigger === 'function' ? trigger : null));")),"function"!=typeof(d=h(Q(r),r.engine))){t.next=39;break}return t.abrupt("return",d.bind(Q(r),Q(r)));case 39:return t.abrupt("return",(function(){}));case 40:case"end":return t.stop()}}),t,null,[[0,11],[14,25]])})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"loadModeFromZip",function(){var t=q(Z().mark((function t(e,n){var o,i,a,s,c,u,l,f,h;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,console.log("Loading Game Mode From Zip"),o=n.file("modes/".concat(e,"/setup.lua")),i=n.file("modes/".concat(e,"/update.lua")),a=n.file("modes/".concat(e,"/teardown.lua")),s=r.world,(c=new O.Z(r.engine)).setScope({zone:Q(r),map:Q(r),_this:Q(r)}),c.initLibrary(),u={},!o){t.next=17;break}return t.next=13,o.async("string");case 13:return l=t.sent,console.log("Zone.loadModeFromZip: running setup.lua for mode",e),t.next=17,c.run(l);case 17:if(!i){t.next=22;break}return t.next=20,i.async("string");case 20:f=t.sent,u.update=function(){var t=q(Z().mark((function t(e,n){var o,i;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,(o=new O.Z(r.engine)).setScope({zone:Q(r),map:Q(r),_this:Q(r),time:e,params:n}),o.initLibrary(),t.next=6,o.run(f);case 6:"function"==typeof(i=t.sent)&&i(e,n),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),console.warn("mode update exec failed",t.t0);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,r){return t.apply(this,arguments)}}();case 22:if(!a){t.next=27;break}return t.next=25,a.async("string");case 25:h=t.sent,u.teardown=function(){var t=q(Z().mark((function t(e){var n,o;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,(n=new O.Z(r.engine)).setScope({zone:Q(r)}),n.initLibrary(),t.next=6,n.run(h);case 6:"function"==typeof(o=t.sent)&&o(e),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),console.warn("mode teardown failed",t.t0);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e){return t.apply(this,arguments)}}();case 27:s&&s.modeManager&&(s.modeManager.registered[e]||s.modeManager.register(e,u)),t.next=33;break;case 30:t.prev=30,t.t0=t.catch(0),console.warn("loadModeFromZip failed",e,t.t0);case 33:case"end":return t.stop()}}),t,null,[[0,30]])})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"loadMode",function(){var t=q(Z().mark((function t(e){var n;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=r.world,t.next=4,r.loadModeFromZip(e,n.spritz.zip);case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(0),console.warn("loadMode failed",e,t.t0);case 9:case"end":return t.stop()}}),t,null,[[0,6]])})));return function(e){return t.apply(this,arguments)}}()),et(Q(r),"loadZoneFromZip",function(){var t=q(Z().mark((function t(e,n,o){var i,a,s,c,u,l,f,h,d,p,y,g,m,v,b,w,x,_,E,A,S,L,O=arguments;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=O.length>3&&void 0!==O[3]&&O[3],t.prev=1,null===(a=e.extends)||void 0===a||!a.length){t.next=7;break}return c={},t.next=6,Promise.all(e.extends.map(function(){var t=q(Z().mark((function t(e){var r;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.file("maps/"+e+"/map.json").async("string");case 2:r=t.sent,c=(0,k.Ee)(c,JSON.parse(r));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:e=Object.assign(c,V(V({},e),{},{extends:null}));case 7:if(null===(s=n.extends)||void 0===s||!s.length){t.next=12;break}return u=[],t.next=11,Promise.all(n.extends.map(function(){var t=q(Z().mark((function t(e){var r,n;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.file("maps/"+e+"/cells.json").async("string");case 2:r=t.sent,n=JSON.parse(r),u=u.concat(n.cells?n.cells:n);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 11:n=u.concat(n.cells||[]);case 12:if(l=null,t.prev=13,!(f=o.file("maps/"+r.id+"/heights.json"))){t.next=25;break}return t.next=18,f.async("string");case 18:y=t.sent,l=JSON.parse(y),console.log("[Zone] Loaded heights.json for ".concat(r.id,":"),null===(h=l)||void 0===h?void 0:h.length,"rows"),console.log("[Zone] First row heights:",null===(d=l)||void 0===d?void 0:d[0]),console.log("[Zone] Heights data sample:",JSON.stringify(null===(p=l)||void 0===p?void 0:p.slice(0,3))),t.next=26;break;case 25:console.log("[Zone] No heights.json found for ".concat(r.id,", using default geometry heights"));case 26:t.next=31;break;case 28:t.prev=28,t.t0=t.catch(13),console.warn("[Zone] Failed to load heights.json for ".concat(r.id,":"),t.t0.message);case 31:if(!e.menu){t.next=37;break}return g={},t.next=35,Promise.all(Object.keys(e.menu).map(function(){var t=q(Z().mark((function t(n){var i;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=V(V({},e.menu[n]),{},{id:n})).onOpen){t.next=5;break}return t.next=4,r.loadTriggerFromZip(i.onOpen,o);case 4:i.onOpen=t.sent.bind(Q(r),Q(r));case 5:if(!i.trigger){t.next=9;break}return t.next=8,r.loadTriggerFromZip(i.trigger,o);case 8:i.trigger=t.sent.bind(Q(r),Q(r));case 9:g[n]=i;case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 35:r.menus=g,r.world.startMenu(r.menus);case 37:return t.next=39,r.tsLoader.loadFromZip(o,e.tileset,r.spritzName);case 39:return m=t.sent,v=F(n,m.tiles),t.next=43,N.call(Q(r),e,v,o,l);case 43:if(b=t.sent,Object.assign(Q(r),b),"string"==typeof r.cells)try{w=new Function("bounds","zone","return (".concat(r.cells,")(bounds, zone);")),r.cells=w.call(Q(r),r.bounds,Q(r))}catch(t){console.error("error loading cell function",t)}if(e.mode)try{r.mode=e.mode}catch(t){console.error("audio load",t)}if(!e.audioSrc){t.next=57;break}return t.prev=48,t.next=51,r.engine.resourceManager.audioLoader.loadFromZip(o,e.audioSrc,!0);case 51:r.audio=t.sent,t.next=57;break;case 54:t.prev=54,t.t1=t.catch(48),console.error("audio load",t.t1);case 57:try{r.lights=null!==(x=e.lights)&&void 0!==x?x:[],_=r.engine.renderManager.lightManager,E=$(r.lights);try{for(E.s();!(A=E.n()).done;)S=A.value,_.addLight(S.id,S.pos,S.color,S.attenuation,S.direction,S.density,S.scatteringCoefficients,S.enabled)}catch(t){E.e(t)}finally{E.f()}}catch(t){console.error("lights",t)}if(r.tileset=m,r.size=[r.bounds[2]-r.bounds[0],r.bounds[3]-r.bounds[1]],"string"==typeof r.sprites)try{L=new Function("bounds","zone","return (".concat(r.sprites,")(bounds, zone);")),r.sprites=L.call(Q(r),r.bounds,Q(r))}catch(t){console.error("sprite fn",t)}return r.sprites=r.sprites||[],r.objects=r.objects||[],t.next=65,Promise.all([Promise.all(r.sprites.map((function(t){return r.loadSpriteFromZip(t,o,i)}))),Promise.all(r.objects.map((function(t){return r.loadObjectFromZip(t,o)})))]);case 65:if(r.attachTilesetListeners(),t.prev=66,!r.mode){t.next=70;break}return t.next=70,r.loadMode(r.mode);case 70:t.next=75;break;case 72:t.prev=72,t.t2=t.catch(66),console.warn("zone mode load failed",t.t2);case 75:return t.next=77,r.finalize();case 77:t.next=82;break;case 79:t.prev=79,t.t3=t.catch(1),console.error("Error parsing json zone "+r.id,t.t3);case 82:case"end":return t.stop()}}),t,null,[[1,79],[13,28],[48,54],[66,72]])})));return function(e,r,n){return t.apply(this,arguments)}}()),et(Q(r),"runWhenDeleted",(function(){var t,e=$(r.lights);try{for(e.s();!(t=e.n()).done;){var n=t.value;r.engine.renderManager.lightManager.removeLight(n.id)}}catch(t){e.e(t)}finally{e.f()}})),et(Q(r),"onTilesetDefinitionLoaded",(function(){var t=r.size[0],e=r.size[1],n=r.engine.renderManager,o=r.engine.gl;r.cellVertexPosBuf=Array.from({length:e},(function(){return new Array(t)})),r.cellVertexTexBuf=Array.from({length:e},(function(){return new Array(t)})),r.cellPickingId=Array.from({length:e},(function(){return new Array(t)})),r.walkability=new Uint16Array(t*e);for(var i=0,a=0;a<e;a++)for(var s=0;s<t;s++,i++){var c=r.cells[i],u=Math.floor(c.length/3),l=[],f=[],h=k.Nm.All,d=r.heights&&r.heights[a]&&"number"==typeof r.heights[a][s]?r.heights[a][s]:null;i<5&&console.log("[Zone.finalize] Cell [".concat(a,",").concat(s,"] heightOverride:"),d);for(var p=0;p<u;p++){var y=c[3*p],g=c[3*p+1],m=c[3*p+2];"number"!=typeof m&&(m=0);var v=[r.bounds[0]+s,r.bounds[1]+a,m];h&=r.tileset.getWalkability(y),l=l.concat(r.tileset.getTileVertices(y,v,d)),f=f.concat(r.tileset.getTileTexCoords(y,g))}c.length===3*u+1&&(h=c[3*u]),r.walkability[i]=h;var b=n.createBuffer(new Float32Array(l),o.STATIC_DRAW,3),w=n.createBuffer(new Float32Array(f),o.STATIC_DRAW,2);r.cellVertexPosBuf[a][s]=b,r.cellVertexTexBuf[a][s]=w,r.cellPickingId[a][s]=[(255&r.objId)/255,(255&a)/255,(255&s)/255,255]}})),et(Q(r),"loadScripts",(function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(console.log("[Zone.loadScripts] ENTRY - zone:",r.id,"refresh:",t,"isPaused:",r.world.isPaused,"scripts:",r.scripts.length),!r.world.isPaused){var e,n=Q(r),o=$(r.scripts);try{for(o.s();!(e=o.n()).done;){var i=e.value;if(console.log("[Zone.loadScripts] Checking script:",i.id,"isLoadSpritz:","load-spritz"===i.id,"refresh:",t),"load-spritz"===i.id&&t){console.log("[Zone.loadScripts] Calling load-spritz trigger for zone:",r.id);try{i.trigger.call(n)}catch(t){console.error("[Zone.loadScripts] Error calling load-spritz trigger:",t)}}}}catch(t){o.e(t)}finally{o.f()}}})),et(Q(r),"loadObject",function(){var t=q(Z().mark((function t(e){var n;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.zone=Q(r),r.objectDict[e.id]){t.next=8;break}return t.next=4,r.objectLoader.load(e,(function(t){return t.onLoad(t)}));case 4:n=t.sent,r.world.objectDict[e.id]=r.objectDict[e.id]=n,r.objectList.push(n),r.world.objectList.push(n);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),et(Q(r),"loadObjectFromZip",function(){var t=q(Z().mark((function t(e,n){var o;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.zone=Q(r),r.objectDict[e.id]){t.next=8;break}return t.next=4,r.objectLoader.loadFromZip(n,e,function(){var t=q(Z().mark((function t(e){return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.onLoadFromZip(e,n));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 4:o=t.sent,r.world.objectDict[e.id]=r.objectDict[e.id]=o,r.objectList.push(o),r.world.objectList.push(o);case 8:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"loadSprite",function(){var t=q(Z().mark((function t(e){var n;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.zone=Q(r),r.spriteDict[e.id]){t.next=8;break}return t.next=4,r.spriteLoader.load(e.type,r.spritzName,(function(t){return t.onLoad(e)}));case 4:n=t.sent,r.world.spriteDict[e.id]=r.spriteDict[e.id]=n,r.spriteList.push(n),r.world.spriteList.push(n);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),et(Q(r),"loadSpriteFromZip",function(){var t=q(Z().mark((function t(e,n){var o;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.zone=Q(r),r.spriteDict[e.id]){t.next=8;break}return t.next=4,r.spriteLoader.loadFromZip(n,e.type,r.spritzName,function(){var t=q(Z().mark((function t(r){return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r.onLoadFromZip(e,n));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 4:o=t.sent,r.world.spriteDict[e.id]=r.spriteDict[e.id]=o,r.spriteList.push(o),r.world.spriteList.push(o);case 8:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"addSprite",(function(t){t.zone=Q(r),r.world.spriteDict[t.id]=r.spriteDict[t.id]=t,r.spriteList.push(t),r.world.spriteList.push(t)})),et(Q(r),"removeSprite",(function(t){var e=function(e){return e.id!==t||(e.removeAllActions(),!1)};r.spriteList=r.spriteList.filter(e),r.world.spriteList=r.world.spriteList.filter(e),delete r.spriteDict[t],delete r.world.spriteDict[t]})),et(Q(r),"removeAllSprites",(function(){var t,e=$(r.spriteList);try{for(e.s();!(t=e.n()).done;){var n=t.value;r.removeSprite(n.id)}}catch(t){e.e(t)}finally{e.f()}})),et(Q(r),"getSpriteById",(function(t){return r.spriteDict[t]})),et(Q(r),"addPortal",(function(t,e,n){var o;if(null===(o=r.portals)||void 0===o||!o.length)return t;var i=r.getHeight(e,n);if(0!==i)return t;var a;return r.portals.length>0&&((a=e*n%3==0?r.portals.shift():r.portals.pop()).pos=new S.OW(e,n,i),t.push(a)),t})),et(Q(r),"getHeight",(function(t,e){var n;if(!r.isInZone(t,e))return null!==(n=r.engine)&&void 0!==n&&n.debug&&console.error("Height out of bounds [".concat(t,", ").concat(e,"]")),0;for(var o=Math.floor(t),i=Math.floor(e),a=t-o,s=e-i,c=(i-r.bounds[1])*r.size[0]+(o-r.bounds[0]),u=r.cells[c],l=Math.floor(u.length/3),f=r.heights&&r.heights[i-r.bounds[1]]&&"number"==typeof r.heights[i-r.bounds[1]][o-r.bounds[0]]?r.heights[i-r.bounds[1]][o-r.bounds[0]]:null,h=function(t){var e=t[1][0]-t[0][0],r=t[1][1]-t[0][1],n=t[2][0]-t[0][0],o=t[2][1]-t[0][1],i=1/(e*o-r*n),c=i*o,u=-i*n,l=-i*r,f=i*e,h=a-t[0][0],d=s-t[0][1];return[h*c+d*u,h*l+d*f]},d=0;d<l;d++){var p=r.tileset.getTileWalkPoly(u[3*d]);if(p)for(var y="number"==typeof u[3*d+2]?u[3*d+2]:0,g=null!==f?f:0,m=0;m<p.length;m++){var v=h(p[m]),b=v[0]+v[1];if(v[0]>=0&&v[1]>=0&&b<=1){var w,x=p[m],_=y+g+(1-b)*x[0][2]+v[0]*x[1][2]+v[1]*x[2][2];return null!==(w=r.engine)&&void 0!==w&&w.debug&&(r.__getHeightLogCount=(r.__getHeightLogCount||0)+1,r.__getHeightLogCount<4&&console.log("[Zone.getHeight] sample (x=".concat(t,",y=").concat(e,") -> i=").concat(o,", j=").concat(i,", baseZ=").concat(y,", heightOffset=").concat(g,", uv=[").concat(v[0].toFixed(2),",").concat(v[1].toFixed(2),"], w=").concat(b.toFixed(2),", computed=").concat(_.toFixed(2)))),_}}}if(l>0){var k=r.tileset.getTileWalkPoly(u[0]);if(k&&k.length>0){var E,A="number"==typeof u[2]?u[2]:0,S=null!==f?f:0,L=k[0],O=A+S+(L[0][2]+L[1][2]+L[2][2])/3;return null!==(E=r.engine)&&void 0!==E&&E.debug&&console.log("[Zone.getHeight] walkPoly fallback for (".concat(t,",").concat(e,"), using avg of first tri = ").concat(O.toFixed(2))),O}}return("number"==typeof u[2]?u[2]:0)+(null!==f?f:0)})),et(Q(r),"drawRow",(function(t,e,n,o,i,a,s){r.tileset.texture.attach();for(var c=r.cellVertexPosBuf[t],u=r.cellVertexTexBuf[t],l=r.size[0],f=r.cellPickingId[t],h=0;h<l;h++){var d=c[h],p=u[h];o.bindBuffer(d,i.aVertexPosition),o.bindBuffer(p,i.aTextureCoord);var y=f[h];a.setMatrixUniforms({id:y}),i.setMatrixUniforms({id:y,isSelected:!!e&&e.has("".concat(t,",").concat(h)),sampler:1,colorMultiplier:n}),s.drawArrays(s.TRIANGLES,0,d.numItems),o.debug&&o.debug.tilesDrawn++}})),et(Q(r),"drawCell",(function(t,e){var n,o=r.engine.renderManager,i=r.engine.gl,a=o.shaderProgram,s=o.effectPrograms.picker,c=r.cellVertexPosBuf[t][e],u=r.cellVertexTexBuf[t][e];o.bindBuffer(c,a.aVertexPosition),o.bindBuffer(u,a.aTextureCoord);var l=r.cellPickingId[t][e];s.setMatrixUniforms({id:l}),a.setMatrixUniforms({id:l,isSelected:!(null===(n=r._selectedSet)||void 0===n||!n.has("".concat(t,",").concat(e))),sampler:1,colorMultiplier:r._highlight||[1,1,0,1]}),i.drawArrays(i.TRIANGLES,0,c.numItems)})),et(Q(r),"draw",(function(){if(r.loaded){var t=r.engine.renderManager,e=r.engine.gl,n=t.shaderProgram,o=t.effectPrograms.picker,i=r.selectedTiles;r.selectedSet=i&&i.length?new Set(i.map((function(t){return"".concat(t[0],",").concat(t[1])}))):null,r.highlight=8&r.engine.frameCount?[1,0,0,1]:[1,1,0,1];var a=function(t){for(var e=1;e<t.length;e++)if(t[e-1].pos.y>t[e].pos.y){t.sort((function(t,e){return t.pos.y-e.pos.y}));break}};a(r.spriteList),a(r.objectList),t.mvPushMatrix(),r.engine._freecamActive||t.camera.setCamera();var s=0,c=0;if("N"===r.engine.renderManager.camera.cameraDir||"NE"===r.engine.renderManager.camera.cameraDir||"NW"===r.engine.renderManager.camera.cameraDir||"E"===r.engine.renderManager.camera.cameraDir)for(var u=0;u<r.size[1];u++){for(r.drawRow(u,r.selectedSet,r.highlight,t,n,o,e);c<r.objectList.length&&r.objectList[c].pos.y-r.bounds[1]<=u;)r.objectList[c++].draw();for(;s<r.spriteList.length&&r.spriteList[s].pos.y-r.bounds[1]<=u;)r.spriteList[s++].draw(r.engine)}else for(var l=r.size[1]-1;l>=0;l--){for(r.drawRow(l,r.selectedSet,r.highlight,t,n,o,e);c<r.objectList.length&&r.bounds[1]-r.objectList[c].pos.y<=l;)r.objectList[c++].draw();for(;s<r.spriteList.length&&r.bounds[1]-r.spriteList[s].pos.y<=l;)r.spriteList[s++].draw(r.engine)}for(;c<r.objectList.length;)r.objectList[c++].draw();for(;s<r.spriteList.length;)r.spriteList[s++].draw(r.engine);t.mvPopMatrix()}})),et(Q(r),"tick",(function(t,e){if(r.loaded&&!e){r.checkInput(t);var n,o=$(r.spriteList);try{for(o.s();!(n=o.n()).done;)n.value.tickOuter(t)}catch(t){o.e(t)}finally{o.f()}}})),et(Q(r),"checkInput",function(){var t=q(Z().mark((function t(e){return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<=r.lastKey+200)){t.next=2;break}return t.abrupt("return");case 2:r.engine.gamepad.checkInput(),r.lastKey=e;case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),et(Q(r),"isInZone",(function(t,e){return t>=r.bounds[0]&&e>=r.bounds[1]&&t<r.bounds[2]&&e<r.bounds[3]})),et(Q(r),"onSelect",function(){var t=q(Z().mark((function t(e,n){var o,i,a,s,c,u;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,null===(o=r.world)||void 0===o||!o.modeManager||!r.world.modeManager.handleSelect){t.next=8;break}return console.log("Running Custom Select Handler"),t.next=5,r.world.modeManager.handleSelect(Q(r),e,n,"tile");case 5:if(!t.sent){t.next=8;break}return t.abrupt("return");case 8:t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),console.warn("mode selection handler error",t.t0);case 13:if(i=!1,r.selectedTiles=r.selectedTiles.filter((function(t){var r=!(t[0]===e&&t[1]===n);return r||(i=!0),r})),!i){t.next=17;break}return t.abrupt("return");case 17:if(r.selectedTiles.push([e,n]),r.selectTrigger){t.next=20;break}return t.abrupt("return");case 20:if(t.prev=20,(a=r.engine.spritz.zip.file("triggers/".concat(r.selectTrigger,".lua")))||(a=r.engine.spritz.zip.file("triggers/".concat(r.selectTrigger,".pxs"))),a){t.next=25;break}throw new Error("No Lua Script Found");case 25:return t.next=27,a.async("string");case 27:return s=t.sent,(c=new O.Z(r.engine)).setScope({_this:Q(r),zone:Q(r),subject:new c.lua.Table([e,n])}),c.initLibrary(),t.next=33,c.run(s);case 33:return t.abrupt("return",t.sent);case 36:t.prev=36,t.t1=t.catch(20),null!==(u=r.engine)&&void 0!==u&&u.debug&&console.warn("select trigger missing",t.t1);case 39:case"end":return t.stop()}}),t,null,[[0,10],[20,36]])})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"isWalkable",(function(t,e,n){if(!r.isInZone(t,e))return null;for(var o in r.spriteDict){var i=r.spriteDict[o];if(i.pos.x===t&&i.pos.y===e){if(!i.walkable&&!i.blocking&&i.override)return!0;if(!i.walkable&&i.blocking)return!1}}for(var a in r.objectDict){var s=r.objectDict[a],c=s.pos.x-s.scale.x*(s.size.x/2),u=s.pos.y-s.scale.y*(s.size.y/2),l=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return n?t>=e&&t<=r:t>e&&t<r},f=l(t,c,s.pos.x,!0),h=l(e,u,s.pos.y,!0);if(!s.walkable&&f&&h&&!s.blocking&&s.override)return!0;if(!s.walkable&&(s.pos.x===t&&s.pos.y===e||f&&h)&&s.blocking)return!1}return 0!=(r.walkability[(e-r.bounds[1])*r.size[0]+(t-r.bounds[0])]&n)})),et(Q(r),"within",(function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return n?t>=e&&t<=r:t>e&&t<r})),et(Q(r),"triggerScript",(function(t){var e,n=$(r.scripts);try{for(n.s();!(e=n.n()).done;){var o=e.value;o.id===t&&r.runWhenLoaded(o.trigger.bind(Q(r)))}}catch(t){n.e(t)}finally{n.f()}})),et(Q(r),"moveSprite",function(){var t=q(Z().mark((function t(e,n){var o,i=arguments;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=i.length>2&&void 0!==i[2]&&i[2],t.abrupt("return",new Promise(function(){var t=q(Z().mark((function t(i){var a;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=r.getSpriteById(e),t.next=3,a.addAction(new L.aW(r.engine,"patrol",[a.pos.toArray(),n,o?200:600,Q(r)],a,i));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"spriteDialogue",function(){var t=q(Z().mark((function t(e,n){var o,i=arguments;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=i.length>2&&void 0!==i[2]?i[2]:{autoclose:!0},t.abrupt("return",new Promise(function(){var t=q(Z().mark((function t(i){var a;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=r.getSpriteById(e),t.next=3,a.addAction(new L.aW(r.engine,"dialogue",[n,!1,o],a,i));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),et(Q(r),"runActions",function(){var t=q(Z().mark((function t(e){var n,o,i,a,s;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Q(r),o=Promise.resolve(),i=$(e);try{for(s=function(){var t=a.value;o=o.then(q(Z().mark((function e(){var r,o,i,a;return Z().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,t.scope=t.scope||n,!t.sprite){e.next=11;break}if(!(r=t.scope.getSpriteById(t.sprite))||!t.action){e.next=11;break}return o=G(t.args),i=o.pop(),e.next=11,r.addAction(new L.aW(n.engine,t.action,[].concat(G(o),[V({},i)]),r,(function(){})));case 11:if(!t.trigger){e.next=16;break}if(!(a=t.scope.getSpriteById("avatar"))){e.next=16;break}return e.next=16,a.addAction(new L.aW(n.engine,"script",[t.trigger,t.scope,function(){}],a));case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(2),console.warn("runActions error",(null===e.t0||void 0===e.t0?void 0:e.t0.message)||e.t0);case 21:case"end":return e.stop()}}),e,null,[[2,18]])}))))},i.s();!(a=i.n()).done;)s()}catch(t){i.e(t)}finally{i.f()}return t.abrupt("return",o.catch((function(t){var e;null!==(e=r.engine)&&void 0!==e&&e.debug&&console.warn("runActions chain",t)})));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),et(Q(r),"playCutScene",function(){var t=q(Z().mark((function t(e){var n,o,i,a,s,c=arguments;return Z().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=c.length>1&&void 0!==c[1]?c[1]:null,o=n||r.spritz,i=$(o),t.prev=3,i.s();case 5:if((a=i.n()).done){t.next=21;break}if(s=a.value,t.prev=7,s.currentStep=s.currentStep||0,!(s.currentStep>o.length)){t.next=11;break}return t.abrupt("continue",19);case 11:if(s.id!==e){t.next=14;break}return t.next=14,r.runActions(s.actions);case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(7),console.error(t.t0);case 19:t.next=5;break;case 21:t.next=26;break;case 23:t.prev=23,t.t1=t.catch(3),i.e(t.t1);case 26:return t.prev=26,i.f(),t.finish(26);case 29:case"end":return t.stop()}}),t,null,[[3,23,26,29],[7,16]])})));return function(e){return t.apply(this,arguments)}}()),r.spritzName=e.id,r.id=t,r.objId=Math.round(100*Math.random()),r.world=e,r.data={},r.spriteDict=Object.create(null),r.spriteList=[],r.objectDict=Object.create(null),r.objectList=[],r.selectedTiles=[],r.lights=[],r.spritz=[],r.scripts=r.scripts||[],r.lastKey=0,r.engine=e.engine,r.onLoadActions=new A.Z,r.spriteLoader=new L.jf(e.engine),r.objectLoader=new L.Gq(e.engine),r.EventLoader=L.q1,r.tsLoader=new L.e5(e.engine),r.audio=null,r._selectedSet=null,r._highlight=null,r}return e=a,Object.defineProperty(e,"prototype",{writable:!1}),e}(o(5849).Z),nt=o(1248),ot=o(2737);function it(t){return it="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},it(t)}function at(t){return function(t){if(Array.isArray(t))return st(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 st(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?st(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 st(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ct(){ct=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==it(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ut(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function lt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ut(i,n,o,a,s,"next",t)}function s(t){ut(i,n,o,a,s,"throw",t)}a(void 0)}))}}function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ht(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var pt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),dt(this,"createAvatar",(function(t){var e=n.zoneContaining(t.x,t.y);if(e){var r=new ot.Z(n.engine);return r.onLoad(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ft(Object(r),!0).forEach((function(e){dt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ft(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({zone:e,id:t.id,pos:new S.OW(t.x,t.y)},t)),e.addSprite(r),r}return null})),dt(this,"removeAvatar",(function(t){var e=t.zone;e&&e.removeSprite(t)})),dt(this,"getAvatar",(function(){return n.spriteDict.avatar})),dt(this,"runAfterTick",(function(t){n.afterTickActions.add(t)})),dt(this,"sortZones",(function(){n.zoneList.sort((function(t,e){return t.bounds[1]-e.bounds[1]}))})),dt(this,"loadZoneFromZip",function(){var t=lt(ct().mark((function t(e,r){var o,i,a,s,c,u,l,f,h,d,p,y,g,m,v,b,w,x,_=arguments;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=_.length>2&&void 0!==_[2]&&_[2],i=_.length>3&&void 0!==_[3]?_[3]:{effect:"cross",duration:500},o||!n.zoneDict[e]){t.next=4;break}return t.abrupt("return",n.zoneDict[e]);case 4:if(a=n.engine,s=!1,i&&null!=a&&a.renderManager&&(c=a.renderManager,u="undefined"!=typeof performance?performance.now():Date.now(),l=u-(c.transitionStartTime+c.transitionDuration),!c.isTransitioning&&l>100&&(s=!0)),!s){t.next=11;break}return f=i.effect,h=void 0===f?"cross":f,d=i.duration,p=void 0===d?500:d,t.next=11,a.renderManager.startTransition({effect:h,direction:"out",duration:p});case 11:return console.log("Loading Zone from Zip:",e),t.t0=JSON,t.next=15,r.file("maps/"+e+"/map.json").async("string");case 15:return t.t1=t.sent,y=t.t0.parse.call(t.t0,t.t1),t.t2=JSON,t.next=20,r.file("maps/"+e+"/cells.json").async("string");case 20:return t.t3=t.sent,g=t.t2.parse.call(t.t2,t.t3),m=new rt(e,n),t.next=25,m.loadZoneFromZip(y,g,r);case 25:if(n.zoneList.map((function(t){t.audio&&t.audio.pauseAudio()})),m.audio&&m.audio.playAudio(),n.zoneDict[e]=m,n.zoneList.push(m),m.runWhenLoaded(n.sortZones),!s){t.next=34;break}return v=i.effect,b=void 0===v?"cross":v,w=i.duration,x=void 0===w?500:w,t.next=34,a.renderManager.startTransition({effect:b,direction:"in",duration:x});case 34:return t.abrupt("return",m);case 35:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),dt(this,"loadZone",function(){var t=lt(ct().mark((function t(e){var r,o,i,a,s,c,u,l,f,h,d,p,y,g,m,v,b,w=arguments;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=w.length>1&&void 0!==w[1]&&w[1],o=w.length>2&&void 0!==w[2]&&w[2],i=w.length>3&&void 0!==w[3]?w[3]:{effect:"cross",duration:500},o||!n.zoneDict[e]){t.next=5;break}return t.abrupt("return",n.zoneDict[e]);case 5:if(a=n.engine,s=!1,i&&null!=a&&a.renderManager&&(c=a.renderManager,u="undefined"!=typeof performance?performance.now():Date.now(),l=u-(c.transitionStartTime+c.transitionDuration),!c.isTransitioning&&l>100&&(s=!0)),!s){t.next=12;break}return f=i.effect,h=void 0===f?"cross":f,d=i.duration,p=void 0===d?500:d,t.next=12,a.renderManager.startTransition({effect:h,direction:"out",duration:p});case 12:if(y=new rt(e,n),!r){t.next=18;break}return t.next=16,y.loadRemote();case 16:t.next=20;break;case 18:return t.next=20,y.load();case 20:if(n.zoneList.map((function(t){t.audio&&t.audio.pauseAudio()})),y.audio&&(console.log(y.audio),y.audio.playAudio()),n.zoneDict[e]=y,n.zoneList.push(y),y.runWhenLoaded(n.sortZones),!s){t.next=29;break}return g=i.effect,m=void 0===g?"cross":g,v=i.duration,b=void 0===v?500:v,t.next=29,a.renderManager.startTransition({effect:m,direction:"in",duration:b});case 29:return t.abrupt("return",y);case 30:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),dt(this,"removeZone",(function(t){n.zoneList=n.zoneList.filter((function(e){if(e.id!==t)return!0;e.audio&&e.audio.pauseAudio(),e.removeAllSprites(),e.runWhenDeleted()})),delete n.zoneDict[t]})),dt(this,"removeAllZones",(function(){n.zoneList.map((function(t){t.audio&&t.audio.pauseAudio(),t.removeAllSprites(),t.runWhenDeleted()})),n.zoneList=[],n.zoneDict={}})),dt(this,"tick",(function(t){for(var e in n.zoneDict){var r;null===(r=n.zoneDict[e])||void 0===r||r.tick(t,n.isPaused)}n.afterTickActions.run(t)})),dt(this,"checkInput",(function(t){if(t>n.lastKey+200){if(n.lastKey=t,n.modeManager&&n.modeManager.handleInput)try{if(n.modeManager.handleInput(t))return}catch(t){console.warn("mode input handler error",t)}var e=n.engine.gamepad.checkInput();n.engine.gamepad.keyPressed("start")&&(e.start=0),n.engine.gamepad.keyPressed("select")&&(e.select=0,n.engine.toggleFullscreen())}})),dt(this,"startMenu",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["start"];n.addEvent(new L.q1(n.engine,"menu",[null!=t?t:n.menuConfig,e,!1,{autoclose:!1,closeOnEnter:!0}],n))})),dt(this,"addEvent",(function(t){n.eventDict[t.id]&&n.removeAction(t.id),n.eventDict[t.id]=t,n.eventList.push(t)})),dt(this,"removeAction",(function(t){n.eventList=n.eventList.filter((function(e){return e.id!==t})),delete n.eventDict[t]})),dt(this,"removeAllActions",(function(){n.eventList=[],n.eventDict={}})),dt(this,"tickOuter",(function(t){n.checkInput(t),n.eventList.sort((function(t,e){var r=t.startTime-e.startTime;return r?t.id>e.id?1:-1:r}));var e=[];if(n.eventList.forEach((function(r){!r.loaded||r.startTime>t||r.pausable&&n.isPaused||r.tick(t)&&(e.push(r),r.onComplete())})),e.forEach((function(t){return n.removeAction(t.id)})),n.tick&&!n.isPaused&&n.tick(t),!n.isPaused&&n.modeManager&&n.modeManager.update)try{n.modeManager.update(t)}catch(t){console.warn("mode update error",t)}})),dt(this,"draw",(function(){for(var t in n.zoneDict)n.zoneDict[t].draw(n.engine)})),dt(this,"zoneContaining",(function(t,e){for(var r in n.zoneDict){var o=n.zoneDict[r];if(o.loaded&&o.isInZone(t,e))return o}return null})),dt(this,"pathFind",(function(t,e){var r=[],o=!1,i=n,a=t[0],s=t[1];function c(t,n){var a=JSON.stringify([t[0],t[1]]);return!o&&(t[0]==e[0]&&t[1]==e[1]?(o=!0,i.canWalk(t,a,r)?[o,[].concat(at(n),[e])]:[o,at(n)]):!!i.canWalk(t,a,r)&&(r.push(a),i.getNeighbours.apply(i,at(t)).sort((function(t,r){return Math.min(Math.abs(e[0]-t[0])-Math.abs(e[0]-r[0]),Math.abs(e[1]-t[1])-Math.abs(e[1]-r[1]))})).map((function(e){return c(e,[].concat(at(n),[[t[0],t[1],600]]))})).filter((function(t){return t})).flat()))}return i.getNeighbours(a,s).sort((function(t,r){return Math.min(Math.abs(e[0]-t[0])-Math.abs(e[0]-r[0]),Math.abs(e[1]-t[1])-Math.abs(e[1]-r[1]))})).map((function(e){return c(e,[[t[0],t[1],600]])})).filter((function(t){return t[0]})).flat()})),dt(this,"getZoneById",(function(t){return n.zoneDict[t]})),dt(this,"getNeighbours",(function(t,e){var r=[t,e+1,k.Nm.Up],n=[t,e-1,k.Nm.Down];return[r,[t-1,e,k.Nm.Left],[t+1,e,k.Nm.Right],n]})),dt(this,"canWalk",(function(t,e,r){var o=n.zoneContaining.apply(n,at(t));return!(r.indexOf(e)>=0||!o||!o.isWalkable.apply(o,at(t))||!o.isWalkable(t[0],t[1],k.Nm.reverse(t[2])))})),this.id=r,this.spritz=e,this.objId=Math.round(1e3*Math.random())+1,this.engine=e.engine,this.zoneDict={},this.zoneList=[],this.remoteAvatars=new Map,this.spriteDict={},this.spriteList=[],this.objectDict={},this.objectList=[],this.tilesetDict={},this.tilesetList=[],this.eventList=[],this.eventDict={},this.lastKey=(new Date).getTime(),this.lastZoneTransitionTime=0,this.isPaused=!0,this.modeManager=new nt.Z(this),this.afterTickActions=new A.Z,this.menuConfig={start:{onOpen:function(t){t.completed=!0}}}}var e,r;return e=t,(r=[{key:"addRemoteAvatar",value:function(t,e){try{var r,n,o,i,a,s,c,u;if(this.remoteAvatars.has(t)){var l=this.remoteAvatars.get(t);try{console.log("Remote avatar for ".concat(t," already exists, updating instead"))}catch(t){}return null!=e.x&&(l.pos.x=e.x),null!=e.y&&(l.pos.y=e.y),null!=e.z&&(l.pos.z=e.z),null!=e.facing&&(l.facing=e.facing),l}var f=new ot.Z(this.engine),h=this.getAvatar();h?(f.src=h.src,f.portraitSrc=h.portraitSrc,f.sheetSize=h.sheetSize,f.tileSize=h.tileSize,f.frames=h.frames,f.hotspotOffset=h.hotspotOffset,f.drawOffset=h.drawOffset,f.enableSpeech=h.enableSpeech,f.bindCamera=!1,h.texture&&(f.texture=h.texture),h.vertexTexBuf&&(f.vertexTexBuf=h.vertexTexBuf),h.vertexPosBuf&&(f.vertexPosBuf=h.vertexPosBuf),h.speech&&h.speechTexBuf&&(f.speech=h.speech,f.speechTexBuf=h.speechTexBuf),f.loaded=!0,f.templateLoaded=!0):console.warn("No local avatar template found; remote avatar may not render correctly");var d=e.id||"player",p="".concat(d,"-").concat(t),y=this.getZoneById(e.zone||e.zoneId)||this.zoneContaining(e.x||0,e.y||0);f.zone=y,f.id=p;var g=null!==(r=null!==(n=e.x)&&void 0!==n?n:e.pos&&e.pos.x)&&void 0!==r?r:0,m=null!==(o=null!==(i=e.y)&&void 0!==i?i:e.pos&&e.pos.y)&&void 0!==o?o:0,v=g+(null!==(a=null===(s=f.hotspotOffset)||void 0===s?void 0:s.x)&&void 0!==a?a:0),b=m+(null!==(c=null===(u=f.hotspotOffset)||void 0===u?void 0:u.y)&&void 0!==c?c:0),w="number"==typeof e.z?e.z:e.pos&&"number"==typeof e.pos.z?e.pos.z:y?y.getHeight(v,b):0;f.pos=new S.OW(g,m,w),f.facing=e.facing||0,f.isSelected=!1;var x=y&&y.tileset&&y.tileset.tileSize?y.tileset.tileSize:32,_=[f.tileSize[0]/x,f.tileSize[1]/x],k=[[0,0,0],[_[0],0,0],[_[0],0,_[1]],[0,0,_[1]]],E=[[k[2],k[3],k[0]],[k[2],k[0],k[1]]].flat(3);f.vertexPosBuf=this.engine.renderManager.createBuffer(E,this.engine.gl.STATIC_DRAW,3);var A=f.getTexCoords();f.vertexTexBuf=this.engine.renderManager.createBuffer(A,this.engine.gl.DYNAMIC_DRAW,2),f.enableSpeech&&(f.speechVerBuf=this.engine.renderManager.createBuffer(f.getSpeechBubbleVertices(),this.engine.gl.STATIC_DRAW,3),f.speechTexBuf=this.engine.renderManager.createBuffer(f.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),y&&(y.spriteDict||(y.spriteDict={}),y.spriteList||(y.spriteList=[]),this.spriteDict[f.id]=f,y.spriteDict[f.id]=f,y.spriteList.includes(f)||y.spriteList.push(f),this.spriteList.includes(f)||this.spriteList.push(f),console.log("Added remote avatar for client ".concat(t," as sprite '").concat(f.id,"' to zone ").concat(y.id," at (").concat(f.pos.x,",").concat(f.pos.y,",").concat(f.pos.z,")"))),this.remoteAvatars.set(t,f);try{console.log("Remote avatar map now has ".concat(this.remoteAvatars.size," entries"))}catch(t){}return f}catch(t){return console.warn("Failed to add remote avatar",t),null}}},{key:"removeRemoteAvatar",value:function(t){var e=this.remoteAvatars.get(t);if(e){try{if(e.zone){var r=e.id||(e.objId?e.objId:null);r?e.zone.removeSprite(r):e.zone.removeSprite(e)}}catch(t){try{e.zone&&e.zone.removeSprite(e)}catch(t){}}this.remoteAvatars.delete(t)}}},{key:"updateRemoteAvatar",value:function(t,e){var r=this.remoteAvatars.get(t);if(r){try{var n,o,i,a;console.log("updateRemoteAvatar: client=".concat(t," pre pos=").concat(null===(n=r.pos)||void 0===n?void 0:n.x,",").concat(null===(o=r.pos)||void 0===o?void 0:o.y,",").concat(null===(i=r.pos)||void 0===i?void 0:i.z," loaded=").concat(r.loaded," id=").concat(r.id," zone=").concat(null===(a=r.zone)||void 0===a?void 0:a.id))}catch(t){}"function"==typeof r.setPosition?r.setPosition(e.x,e.y,e.z):r.pos&&(r.pos.x=e.x,r.pos.y=e.y,r.pos.z=e.z||r.pos.z),"function"==typeof r.updateState?r.updateState(e):(null!=e.facing&&(r.facing=e.facing),null!=e.animFrame&&(r.animFrame=e.animFrame)),r.loaded||(console.warn("Remote avatar ".concat(t," was not loaded; forcing loaded=true so renderer will attempt to draw.")),r.loaded=!0,r.templateLoaded=!0,r.texture&&"function"==typeof r.texture.attach||(r.texture={loaded:!0,attach:function(){}}));try{var s,c,u,l;console.log("updateRemoteAvatar: client=".concat(t," post pos=").concat(null===(s=r.pos)||void 0===s?void 0:s.x,",").concat(null===(c=r.pos)||void 0===c?void 0:c.y,",").concat(null===(u=r.pos)||void 0===u?void 0:u.z," loaded=").concat(r.loaded," id=").concat(r.id," zone=").concat(null===(l=r.zone)||void 0===l?void 0:l.id))}catch(t){}return r}return null}},{key:"applyRemoteAction",value:function(t,e,r,n){var o=this.remoteAvatars.get(t);o&&o.performAction(e,r)}}])&&ht(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function yt(t){return yt="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},yt(t)}function gt(){gt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==yt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function mt(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){mt(i,n,o,a,s,"next",t)}function s(t){mt(i,n,o,a,s,"throw",t)}a(void 0)}))}}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function wt(t,e,r){return e&&bt(t.prototype,e),r&&bt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function xt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t=wt((function t(){var e=this;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),xt(this,"init",function(){var r=vt(gt().mark((function r(n){var o;return gt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:t._instance.engine=n,(o=t._instance.world=new pt(t._instance,"spritz")).zoneList.forEach((function(t){return t.runWhenLoaded((function(){return console.log("loading...done")}))})),o.startMenu({start:{text:"Start Game",prompt:"Please press the button to start...",x:n.screenSize().width/2-75,y:n.screenSize().height/2-50,w:150,h:75,quittable:!1,colours:{top:"#333",bottom:"#777",background:"#999"},onOpen:function(t){e.isPaused=!0},trigger:function(t){t.world.isPaused=!1,t.completed=!0}}});case 4:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()),xt(this,"loadSpritzManifest",function(){var t=vt(gt().mark((function t(e){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),xt(this,"loadAvatar",function(){var t=vt(gt().mark((function t(e,r){return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),xt(this,"exportAvatar",vt(gt().mark((function t(){var e,r,n;return gt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new x,r={},e.folder("pixos").file("avatar.json",JSON.stringify(r)),t.next=5,e.generateAsync({type:"blob"});case 5:n=t.sent,(0,w.saveAs)(n,"avatar.zip");case 7:case"end":return t.stop()}}),t)})))),xt(this,"update",(function(e){t._instance.world.tickOuter(e)})),xt(this,"render",(function(e,r){t._instance.world.draw(e)})),xt(this,"onKeyEvent",(function(e){"keydown"===e.type?t._instance.engine.keyboard.onKeyDown(e):t._instance.engine.keyboard.onKeyUp(e)})),xt(this,"onTouchEvent",(function(e){if(e.type,t._instance&&t._instance.engine&&"function"==typeof t._instance.engine.touchHandler)try{t._instance.engine.touchHandler(e)}catch(t){console.warn("touchHandler error",t)}})),this.shaders={fs:"\n precision mediump int;\n precision mediump float;\n\n const float Near = 0.1;\n const float Far = 50.0;\n\n struct PointLight {\n float enabled;\n vec3 color;\n vec3 position;\n vec3 attenuation;\n vec3 direction;\n vec3 scatteringCoefficients;\n float density;\n };\n\n float unpack(vec4 color) {\n const vec4 bitShifts = vec4(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0), 1.0 / (255.0 * 255.0 * 255.0));\n return dot(color, bitShifts);\n }\n\n varying vec4 vWorldVertex;\n varying vec3 vWorldNormal;\n varying vec3 vTransformedNormal;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n varying vec3 vLighting;\n\n uniform PointLight uLights[32];\n uniform sampler2D uDepthMap;\n uniform vec4 u_id;\n\n uniform float runTransition;\n uniform float useSampler;\n uniform float useDiffuse;\n uniform float isSelected;\n uniform vec4 uColorMultiplier; \n uniform sampler2D uSampler;\n uniform sampler2D uDiffuseMap;\n\n uniform vec3 uDiffuse;\n uniform vec3 uSpecular;\n uniform float uSpecularExponent;\n\n uniform vec3 uLightColor;\n varying vec3 vFragPos;\n varying vec3 vLightDir;\n varying vec3 vViewDir;\n\n float getAttenuation(PointLight light) {\n float distance_from_light;\n vec3 to_light;\n\n to_light = light.position - vPosition.xyz;\n distance_from_light = length(to_light);\n \n float attenuation = 1.0 / (\n 1.0 + light.attenuation.x\n + light.attenuation.y * distance_from_light \n + light.attenuation.z * pow(distance_from_light, 2.0)\n );\n return attenuation;\n }\n\n vec3 getReflectedLightColor(vec3 color) {\n vec3 reflectedLightColor = vec3(0.0);\n \n for(int i = 0; i < 32; i++) {\n if(uLights[i].enabled <= 0.5) continue;\n \n vec3 specular_color;\n vec3 diffuse_color;\n vec3 to_light;\n vec3 reflection;\n vec3 to_camera;\n float cos_angle;\n float attenuation;\n vec3 normal;\n \n // Calculate a vector from the fragment location to the light source\n to_light = normalize(uLights[i].position - vFragPos);\n normal = normalize(vWorldNormal);\n \n // DIFFUSE calculations\n if (useSampler == 1.0) {\n cos_angle = 0.67; // billboard sprites\n cos_angle += dot(to_camera, to_light);\n } else {\n cos_angle = dot(normal, to_light);\n cos_angle = clamp(cos_angle, 0.0, 1.0);\n }\n \n // Scale the color of this fragment based on its angle to the light.\n diffuse_color = uLights[i].color * cos_angle;\n \n // SPECULAR calculations\n reflection = 2.0 * dot(normal, to_light) * normal - to_light;\n reflection = normalize(reflection);\n \n to_camera = normalize(vViewDir);\n \n cos_angle = dot(reflection, to_camera);\n cos_angle = clamp(cos_angle, 0.0, 1.0);\n specular_color = uLights[i].color * cos_angle;\n \n // ATTENUATION calculations\n attenuation = getAttenuation(uLights[i]);\n \n // Combine and attenuate the colors from this light source\n reflectedLightColor += attenuation * (diffuse_color + specular_color);\n }\n \n return clamp(0.5 * color + reflectedLightColor, 0.0, 1.0);\n }\n\n // Diffuse Colour Calculation\n vec3 calculateDiffuse() {\n vec4 texelColors = texture2D(uDiffuseMap, vTextureCoord);\n vec3 color = uDiffuse;\n if(useDiffuse == 1.0) {\n // If texture has valid data, use it multiplied by material diffuse color\n if(texelColors.a > 0.01) {\n color = texelColors.rgb * uDiffuse;\n }\n }\n return color;\n }\n\n // Sampler Texture Colour Calculation\n vec3 calculateSampler(vec4 texelColors) {\n vec3 color = texelColors.rgb;\n if(texelColors.a < 0.1) discard;\n return color;\n }\n\n // linearize depth\n float LinearizeDepth(float depth) {\n float z = depth * 2.0 - 1.0; // back to NDC \n return (2.0 * Near * Far) / (Far + Near - z * (Far - Near));\n }\n\n // fog effect based on depth\n vec4 fogEffect(vec4 color4) {\n float depth = LinearizeDepth(gl_FragCoord.z) / Far;\n vec4 depthVec4 = vec4(vec3(pow(depth, 1.4)), 1.0);\n return (color4 * (1.0 - depth)) + depthVec4;\n }\n\n // Volumetric Calculation\n vec4 volumetricCalculation(vec4 color4) {\n vec3 finalColor;\n\n for(int i = 0; i < 32; i++) {\n if(uLights[i].enabled <= 0.5) continue;\n \n // Calculate the distance from the fragment to the light\n float distance = length(uLights[i].position - vec3(vWorldVertex));\n\n // directional lighting - not working atm\n // if(length(uLights[i].direction) > 0.0){\n // // Calculate the angle between the light direction and the fragment\n // float cos_angle = dot(normalize(uLights[i].direction), normalize(vFragPos - uLights[i].position));\n // // If the fragment is not within the light cone, skip this light\n // if(cos_angle <= 0.0) continue;\n // }\n\n // Calculate the scattering effect\n float scattering = exp(-uLights[i].density * distance);\n vec3 scatteredLight = uLights[i].color * scattering * uLights[i].scatteringCoefficients;\n // Combine the scattered light with the existing lighting\n finalColor += scatteredLight;\n }\n\n return color4 * vec4(finalColor, 1.0);\n }\n\n void main(void) {\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n\n if(runTransition == 1.0) {\n finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n gl_FragColor = finalColor;\n return;\n }\n\n if(useSampler == 1.0) { // sampler\n vec4 texelColors = texture2D(uSampler, vTextureCoord);\n vec3 color = calculateSampler(texelColors);\n vec4 color4 = vec4(getReflectedLightColor(color), texelColors.a);\n finalColor = volumetricCalculation(vec4(color, texelColors.a)) * fogEffect(color4);\n } else { // diffuse\n vec3 color = calculateDiffuse();\n vec4 color4 = vec4((getReflectedLightColor(color)), 1.0);\n finalColor = volumetricCalculation(vec4(color,1.0)) * fogEffect(color4);\n }\n\n // flash on selection\n if(isSelected == 1.0) {\n finalColor = finalColor * uColorMultiplier;\n }\n\n // gl_FragColor = vec4(vec3(u_id),1.0);\n\n gl_FragColor = finalColor;\n }\n",vs:"\n precision mediump float;\n\n attribute vec3 aVertexPosition;\n attribute vec3 aVertexNormal;\n attribute vec2 aTextureCoord;\n \n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjectionMatrix;\n uniform mat3 uNormalMatrix;\n uniform mat3 uCamPos;\n\n uniform vec3 uLightDirection;\n uniform vec3 uCameraPosition;\n varying vec3 vFragPos;\n varying vec3 vLightDir;\n varying vec3 vViewDir;\n\n varying vec4 vWorldVertex;\n varying vec3 vWorldNormal;\n varying vec3 vTransformedNormal;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n uniform vec3 u_scale;\n\n void main(void) {\n vec3 scaledPosition = aVertexPosition * u_scale;\n\n vWorldVertex = uModelMatrix * vec4(aVertexPosition, 1.0);\n vPosition = uModelMatrix * vec4(scaledPosition, 1.0);\n vTextureCoord = aTextureCoord;\n vTransformedNormal = uNormalMatrix * aVertexNormal;\n vWorldNormal = normalize(mat3(uModelMatrix) * aVertexNormal);\n\n // Pass fragment position to fragment shader\n vFragPos = vec3(uModelMatrix * vec4(scaledPosition, 1.0));\n \n // Calculate view direction and pass to fragment shader\n vViewDir = normalize(uCameraPosition - vFragPos);\n\n gl_Position = uProjectionMatrix * uViewMatrix * vPosition;\n }\n"},this.effects={},this.effectPrograms={},t._instance||(t._instance=this),t._instance}));function kt(t){return kt="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},kt(t)}function Et(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return At(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?At(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function At(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function St(){St=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function d(){}var p={};s(p,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(E([])));g&&g!==e&&r.call(g,o)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==kt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(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 _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return h.prototype=d,s(m,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(b.prototype),s(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},v(m),s(m,a,"Generator"),s(m,o,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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,l):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),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Lt(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Ot(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Lt(i,n,o,a,s,"next",t)}function s(t){Lt(i,n,o,a,s,"throw",t)}a(void 0)}))}}function Pt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Tt(t,e){return Tt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Tt(t,e)}function Ct(t,e){if(e&&("object"===kt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Mt(t)}function Mt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function jt(t){return jt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},jt(t)}function It(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}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 zt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dt(t,e){return Dt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Dt(t,e)}function Nt(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)}function Rt(t){return Rt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(t)}var Ft=function(t){!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)}(i,t);var e,r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=Rt(r);if(n){var o=Rt(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return Nt(this,t)});function i(){return zt(this,i),o.apply(this,arguments)}return e=i,Object.defineProperty(e,"prototype",{writable:!1}),e}(function(t){!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&&Tt(t,e)}(i,t);var e,r,n,o=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=jt(r);if(n){var o=jt(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return Ct(this,t)});function i(){var t;Pt(this,i);for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return It(Mt(t=o.call.apply(o,[this].concat(r))),"init",function(){var e=Ot(St().mark((function e(r){var n,o,i,a;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e||0===r.fileUpload.files.length)return r.fileUpload.click(),void(r.fileUpload.onchange=function(e){return o(t)});o(null)},i=function(){return(i=Ot(St().mark((function t(e){var o,i,a,s,c,u;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,o=r.fileUpload.files[0],t.next=4,_().loadAsync(o);case 4:return i=t.sent,_t._instance.zip=i,t.t0=JSON,t.next=9,i.file("manifest.json").async("string");case 9:t.t1=t.sent,a=t.t0.parse.call(t.t0,t.t1),console.log(a),a.network&&a.network.url&&(console.log("Network connection found -- attempting connectiong to server"),r.networkManager.connect(a.network.url)),s=Et(a.initialZones),t.prev=14,s.s();case 16:if((c=s.n()).done){t.next=22;break}return u=c.value,t.next=20,n.loadZoneFromZip(u,i,!0,{effect:"cross",duration:500});case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t2=t.catch(14),s.e(t.t2);case 27:return t.prev=27,s.f(),t.finish(27);case 30:n.isPaused=!1,e.completed=!0,_t._instance.loaded=!0,t.next=39;break;case 35:return t.prev=35,t.t3=t.catch(0),console.error(t.t3),t.abrupt("return");case 39:case"end":return t.stop()}}),t,null,[[0,35],[14,24,27,30]])})))).apply(this,arguments)},o=function(t){return i.apply(this,arguments)},_t._instance.loaded=!1,_t._instance.engine=r,(n=_t._instance.world=new pt(_t._instance,"dynamic")).startMenu({start:{pausable:!1,text:"Load Game File",prompt:"Please select a file to load...",x:r.screenSize().width/2-75,y:r.screenSize().height/2-50,w:150,h:75,quittable:!1,colours:{top:"#333",bottom:"#777",background:"#999"},onEnter:!0,onOpen:function(e){t.isPaused=!0},trigger:function(){var t=Ot(St().mark((function t(e){return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a(e);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t}return e=i,Object.defineProperty(e,"prototype",{writable:!1}),e}(_t)),Ut=o(3379),Gt=o.n(Ut),Wt=o(7795),Vt=o.n(Wt),Zt=o(569),$t=o.n(Zt),Yt=o(6636),Kt=o.n(Yt),Ht=o(9216),qt=o.n(Ht),Xt=o(4589),Jt=o.n(Xt),Qt=o(1895),te={};function ee(t){return ee="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},ee(t)}function re(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ne(t,e){return ne=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ne(t,e)}function oe(t,e){if(e&&("object"===ee(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 ie(t){return ie=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ie(t)}te.styleTagTransform=Jt(),te.setAttributes=Kt(),te.insert=$t().bind(null,"head"),te.domAPI=Vt(),te.insertStyleElement=qt(),Gt()(Qt.Z,te),Qt.Z&&Qt.Z.locals&&Qt.Z.locals;var ae=function(t){!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&&ne(t,e)}(c,t);var r,n,o,i,a,s=(i=c,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=ie(i);if(a){var r=ie(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return oe(this,t)});function c(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(e=s.call(this,t)).state={spritz:new Ft,updated:Date.now(),zipData:t.zipData},e}return r=c,o=[{key:"getDerivedStateFromProps",value:function(t,e){return JSON.stringify(e.networkString)!==JSON.stringify(t.networkString)?{networkString:t.networkString,updated:Date.now()}:null}}],(n=[{key:"render",value:function(){var t=this.state,r=t.updated,n=t.spritz,o=t.zipData;return e().createElement("div",{style:{margin:0,minHeight:"480px",maxHeight:"1080px"}},e().createElement(b,{class:"pixos",key:"pixos-".concat(r),width:480,height:640,SpritzProvider:n,zipData:null!=o?o:""}))}}])&&re(r.prototype,n),o&&re(r,o),Object.defineProperty(r,"prototype",{writable:!1}),c}(t.Component);const se=(0,r.collect)(ae)})(),i.default})()));
|
|
3
|
-
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["pixospritz-core"]=t(e.React,e.ReactDOM)}(this,function(e,t){"use strict";var n=Object.defineProperty,i=(e,t,i)=>((e,t,i)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);function r(e,t){for(var n=0;n<t.length;n++){const i=t[n];if("string"!=typeof i&&!Array.isArray(i))for(const t in i)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(i,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}),n}var l={exports:{}},c={},h=e,u=Symbol.for("react.element"),d=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,p=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g={key:!0,ref:!0,__self:!0,__source:!0};function m(e,t,n){var i,r={},s=null,a=null;for(i in void 0!==n&&(s=""+n),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(a=t.ref),t)f.call(t,i)&&!g.hasOwnProperty(i)&&(r[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===r[i]&&(r[i]=t[i]);return{$$typeof:u,type:e,key:s,ref:a,props:r,_owner:p.current}}c.Fragment=d,c.jsx=m,c.jsxs=m,l.exports=c;var y=l.exports,b={exports:{}};const v={currentComponent:null,isBatchUpdating:!1,isInBrowser:"undefined"!=typeof window,listeners:new Map,manualListeners:[],nextVersionMap:new WeakMap,proxyIsMuted:!1,redirectToNext:!0,store:{}},w=Symbol("PATH"),x=Symbol("ORIGINAL"),_="RR_DEBUG",k=e=>!!e&&"object"==typeof e&&e.constructor===Object,S=e=>Array.isArray(e),M=e=>e instanceof Map,A=e=>e instanceof Set,T=e=>k(e)||S(e)||M(e)||A(e),E=e=>e===w||"constructor"===e||"toJSON"===e||"@@toStringTag"===e||e===Symbol.toStringTag,P=e=>"function"==typeof e,C=e=>k(e)?Object.assign({},e):S(e)?e.slice():M(e)?new Map(e):A(e)?new Set(e):e,z=(e,t)=>M(e)?e.get(t):A(e)?t:(S(e),e[t]),L=(e,t,n)=>{if(k(e))e[t]=n;else if(S(e))e[t]=n;else if(M(e))e.set(t,n);else{if(!A(e))throw Error("Unexpected type");e.add(n)}},I=e=>{if(k(e))return Object.keys(e).length;if(S(e))return e.length;if(M(e)||A(e))return e.size;throw Error("Unexpected type")},D=(e,t)=>{const n=[],i=e=>{const r=t(e,n.slice()),s=void 0!==r?r:e,a=(e,t)=>{n.push(e);const r=i(t);n.pop(),L(s,e,r)};if(k(s))Object.entries(s).forEach(([e,t])=>{a(e,t)});else if(S(s)||M(s))s.forEach((e,t)=>{a(t,e)});else if(A(s)){const e=Array.from(s);s.clear(),e.forEach(e=>{a(e,e)})}return s};return i(e)},R=e=>{v.proxyIsMuted=!0;const t=e();return v.proxyIsMuted=!1,t},O=(e,t)=>e.map(e=>e.toString()).join(t),B=e=>O(e,"."),F=e=>O(e,"~~~"),j=(e,t)=>{const n=e[w]||[];return void 0===t?n:n.concat(t)},N=(e,t)=>B(j(e,t)),U=(e,t)=>{e&&Object.defineProperty(e,w,{value:t,writable:!0})},$=e=>e[w]||[],V="undefined"!=typeof window&&!!window.localStorage,W=(e,t)=>{if(V)try{const n="string"==typeof t?t:JSON.stringify(t);return localStorage.setItem(e,n)}catch(n){return}},H="on",K="off";let Z=(e=>{if(!V)return;const t=localStorage.getItem(e);if(!t)return t;try{return JSON.parse(t)}catch(n){return t}})(_)||K;Z===H&&console.info("Recollect debugging is enabled. Type __RR__.debugOff() to turn it off.");const G=()=>{Z=H,W(_,H)},X=()=>{Z=K,W(_,K)},Y=e=>{Z===H&&e()},q=(e,t,n)=>{Y(()=>{console.groupCollapsed(`GET: ${N(e,t)}`),console.info(`Component: <${v.currentComponent._name}>`),void 0!==n&&console.info("Value:",n),console.groupEnd()})},J=(e,t,n)=>{Y(()=>{console.groupCollapsed(`SET: ${N(e,t)}`),console.info("From:",z(e,t)),console.info("To: ",n),console.groupEnd()})},Q={},ee=e=>Q.UpdateNextStore(e),te=e=>{if(!v.currentComponent)return;const t=F(e),n=v.listeners.get(t)||new Set;n.add(v.currentComponent),v.listeners.set(t,n)},ne=e=>M(e)||A(e)?{get(e,t){if(t===x)return e;let n=Reflect.get(e,t);if(P(n)&&(n=n.bind(e)),v.proxyIsMuted||E(t))return n;if(!v.currentComponent&&v.redirectToNext){const n=v.nextVersionMap.get(e);if(n)return Reflect.get(n,t)}if("set"===t){return new Proxy(n,{apply:(n,i,[r,s])=>i.get(r)===s||ee({target:i,prop:r,value:s,updater:(n,i)=>(J(e,t,i),Reflect.apply(n[t],n,[r,i]))})})}if("add"===t){return new Proxy(n,{apply:(n,i,[r])=>!!i.has(r)||ee({target:i,notifyTarget:!0,value:r,updater:(n,i)=>(J(e,t,i),Reflect.apply(n[t],n,[i]))})})}if("clear"===t||"delete"===t){return new Proxy(n,{apply:(n,i,[r])=>!(!i.size||"delete"===t&&!i.has(r))&&ee({target:i,notifyTarget:!0,updater:n=>(J(e,t),Reflect.apply(n[t],n,[r]))})})}if(!v.currentComponent)return n;if(M(e)&&"get"===t){return new Proxy(n,{apply:(t,n,i)=>(te(j(e,i[0])),Reflect.apply(t,n,i))})}return n}}:{get(e,t){if(t===x)return e;const n=Reflect.get(e,t);if(v.proxyIsMuted||E(t))return n;if(((e,t)=>S(e)&&["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"].includes(t))(e,t)){return new Proxy(n,{apply:(n,i,r)=>ee({target:i,notifyTarget:!0,value:r,updater:(n,i)=>{J(e,t,i);const r=Reflect.apply(n[t],n,i),s=$(e);return D(n,(e,t)=>{T(e)&&U(e,[...s,...t])}),r}})})}if(P(e[t]))return n;if(v.currentComponent)S(e)&&"length"===t||(q(e,t,n),te(j(e,t)));else if(v.redirectToNext){const n=v.nextVersionMap.get(e);if(n)return Reflect.get(n,t)}return n},has(e,t){const n=Reflect.has(e,t);if(v.proxyIsMuted||E(t))return n;if(v.currentComponent)S(e)||(q(e,t),te(j(e,t)));else{const n=v.nextVersionMap.get(e);if(n)return Reflect.has(n,t)}return n},ownKeys(e){const t=Reflect.ownKeys(e);if(v.proxyIsMuted)return t;if(v.currentComponent)q(e),te($(e));else{const t=v.nextVersionMap.get(e);if(t)return Reflect.ownKeys(t)}return t},set:(e,t,n)=>v.proxyIsMuted?Reflect.set(e,t,n):e[t]===n||ee({target:e,prop:t,value:n,updater:(n,i)=>(J(e,t,i),Reflect.set(n,t,i))}),deleteProperty:(e,t)=>v.proxyIsMuted?Reflect.deleteProperty(e,t):ee({target:e,prop:t,notifyTarget:!0,updater:n=>(((e,t)=>{Y(()=>{console.groupCollapsed(`DELETE: ${N(e,t)}`),console.info("Property: ",N(e,t)),console.groupEnd()})})(e,t),Reflect.deleteProperty(n,t))})},ie=e=>new Proxy(e,ne(e));var re=t.unstable_batchedUpdates||(e=>{e()});const se={components:new Map,changedPaths:new Set},ae=()=>{re(()=>{se.components.forEach((e,t)=>{((e,t)=>{Y(()=>{console.groupCollapsed(`UPDATE: <${e._name}>`),console.info("Changed properties:",t),console.groupEnd()})})(t,Array.from(e)),t.update()})}),v.manualListeners.forEach(e=>e({changedProps:Array.from(se.changedPaths),renderedComponents:Array.from(se.components.keys()),store:v.store})),se.components.clear(),se.changedPaths.clear()};v.store=ie({});var oe;oe=({target:e,prop:t,value:n,notifyTarget:i=!1,updater:r})=>R(()=>{let s;const a=$(e),o=j(e,t);let l=!1;const c=I(e);let h=n;return T(h)&&(h=D(n,(e,t)=>{if(!T(e))return e;const n=C(e);return U(n,[...o,...t]),ie(n)})),a.length?a.reduce((t,n,i)=>{const o=z(t,n);let u=C(o);return U(u,$(o)),u=ie(u),L(t,n,u),i===a.length-1&&(s=r(u,h),l=I(u)!==c,v.nextVersionMap.set(e[x]||e,u)),u},v.store):(s=r(v.store,h),l=I(v.store)!==c),(e=>{const t=F(e),n=B(e);se.changedPaths.add(n),v.listeners.forEach((e,i)=>{""!==t&&t!==i||e.forEach(e=>{const t=se.components.get(e)||new Set;t.add(n),se.components.set(e,t)})}),v.isBatchUpdating||ae()})(i||l?a:o),s}),Q.UpdateNextStore=oe;const le=e=>{v.isBatchUpdating=!0,e(),v.isBatchUpdating=!1,ae()};var ce={exports:{}},he={},ue="function"==typeof Symbol&&Symbol.for,de=ue?Symbol.for("react.element"):60103,fe=ue?Symbol.for("react.portal"):60106,pe=ue?Symbol.for("react.fragment"):60107,ge=ue?Symbol.for("react.strict_mode"):60108,me=ue?Symbol.for("react.profiler"):60114,ye=ue?Symbol.for("react.provider"):60109,be=ue?Symbol.for("react.context"):60110,ve=ue?Symbol.for("react.async_mode"):60111,we=ue?Symbol.for("react.concurrent_mode"):60111,xe=ue?Symbol.for("react.forward_ref"):60112,_e=ue?Symbol.for("react.suspense"):60113,ke=ue?Symbol.for("react.suspense_list"):60120,Se=ue?Symbol.for("react.memo"):60115,Me=ue?Symbol.for("react.lazy"):60116,Ae=ue?Symbol.for("react.block"):60121,Te=ue?Symbol.for("react.fundamental"):60117,Ee=ue?Symbol.for("react.responder"):60118,Pe=ue?Symbol.for("react.scope"):60119;function Ce(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case de:switch(e=e.type){case ve:case we:case pe:case me:case ge:case _e:return e;default:switch(e=e&&e.$$typeof){case be:case xe:case Me:case Se:case ye:return e;default:return t}}case fe:return t}}}function ze(e){return Ce(e)===we}he.AsyncMode=ve,he.ConcurrentMode=we,he.ContextConsumer=be,he.ContextProvider=ye,he.Element=de,he.ForwardRef=xe,he.Fragment=pe,he.Lazy=Me,he.Memo=Se,he.Portal=fe,he.Profiler=me,he.StrictMode=ge,he.Suspense=_e,he.isAsyncMode=function(e){return ze(e)||Ce(e)===ve},he.isConcurrentMode=ze,he.isContextConsumer=function(e){return Ce(e)===be},he.isContextProvider=function(e){return Ce(e)===ye},he.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===de},he.isForwardRef=function(e){return Ce(e)===xe},he.isFragment=function(e){return Ce(e)===pe},he.isLazy=function(e){return Ce(e)===Me},he.isMemo=function(e){return Ce(e)===Se},he.isPortal=function(e){return Ce(e)===fe},he.isProfiler=function(e){return Ce(e)===me},he.isStrictMode=function(e){return Ce(e)===ge},he.isSuspense=function(e){return Ce(e)===_e},he.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===pe||e===we||e===me||e===ge||e===_e||e===ke||"object"==typeof e&&null!==e&&(e.$$typeof===Me||e.$$typeof===Se||e.$$typeof===ye||e.$$typeof===be||e.$$typeof===xe||e.$$typeof===Te||e.$$typeof===Ee||e.$$typeof===Pe||e.$$typeof===Ae)},he.typeOf=Ce,ce.exports=he;var Le=ce.exports,Ie={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},De={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Re={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Oe={};function Be(e){return Le.isMemo(e)?Re:Oe[e.$$typeof]||Ie}Oe[Le.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Oe[Le.Memo]=Re;var Fe=Object.defineProperty,je=Object.getOwnPropertyNames,Ne=Object.getOwnPropertySymbols,Ue=Object.getOwnPropertyDescriptor,$e=Object.getPrototypeOf,Ve=Object.prototype;var We=function e(t,n,i){if("string"!=typeof n){if(Ve){var r=$e(n);r&&r!==Ve&&e(t,r,i)}var s=je(n);Ne&&(s=s.concat(Ne(n)));for(var a=Be(t),o=Be(n),l=0;l<s.length;++l){var c=s[l];if(!(De[c]||i&&i[c]||o&&o[c]||a&&a[c])){var h=Ue(n,c);try{Fe(t,c,h)}catch(u){}}}}return t};const He=a(We),Ke=[],Ze=()=>{v.isInBrowser&&(Y(()=>{console.groupEnd()}),Ke.pop(),v.currentComponent=Ke[Ke.length-1]||null)},Ge=()=>R(()=>{const e=Object.assign({},v.store);return v.nextVersionMap.set(e,v.store),ie(e)});var Xe={exports:{}};function Ye(){}function qe(){}qe.resetWarningCache=Ye;Xe.exports=function(){function e(e,t,n,i,r,s){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==s){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:qe,resetWarningCache:Ye};return n.PropTypes=n,n}();var Je=Xe.exports;const Qe=a(Je);let et;et=r({__proto__:null,default:Qe},[Je]);const tt=et,{store:nt}=v,it=v;"undefined"!=typeof window&&("Proxy"in window?window.__RR__={debugOn:G,debugOff:X,internals:v}:console.warn("This browser doesn't support the Proxy object, which react-recollect needs. See https://caniuse.com/#search=proxy to find out which browsers do support it"));const rt=Object.freeze(Object.defineProperty({__proto__:null,PropTypes:tt,afterChange:e=>{v.manualListeners.push(e)},batch:le,collect:t=>{const n=t.displayName||t.name||"NamelessComponent";class i extends e.PureComponent{constructor(){super(...arguments),this.state={store:Ge()},this._isMounted=!1,this._isMounting=!0,this._isRendering=!1,this._name=n}componentDidMount(){this._isMounted=!0,this._isMounting=!1,Ze(),this._isRendering=!1}componentDidUpdate(){Ze(),this._isRendering=!1}componentWillUnmount(){var e;e=this,v.listeners.forEach((t,n)=>{const i=Array.from(t).filter(t=>t!==e);i.length?v.listeners.set(n,new Set(i)):v.listeners.delete(n)}),this._isMounted=!1}update(){(this._isMounted||this._isMounting)&&this.setState({store:Ge()})}render(){var n;this._isRendering||(n=this,v.isInBrowser&&(Y(()=>{console.groupCollapsed(`RENDER: <${n._name}>`)}),v.currentComponent=n,Ke.push(v.currentComponent)),this._isRendering=!0);const i=Object.assign(Object.assign({},this.props),{store:this.state.store});return e.createElement(t,Object.assign({},i))}}return i.displayName=`Collected(${n})`,He(i,t)},initStore:e=>{le(()=>{var t,n;t=v.store,(n=e)?(Object.entries(n).forEach(([e,n])=>{t[e]!==n&&(t[e]=n)}),Object.keys(t).forEach(e=>{e in n||delete t[e]})):Object.keys(t).forEach(e=>{delete t[e]})})},internals:it,store:nt,useProps:e=>{e.includes(0)}},Symbol.toStringTag,{value:"Module"})),st=o(rt);b.exports=st;var at=b.exports;class ot{constructor(e,t,n){this.x=e,this.y=t,this.z=n}add(e){return new ot(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new ot(this.x-e.x,this.y-e.y,this.z-e.z)}mul(e){return new ot(this.x*e,this.y*e,this.z*e)}mul3(e){return new ot(this.x*e.x,this.y*e.y,this.z*e.z)}cross(e){return new ot(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}distance(e){return this.sub(e).length()}normal(){if(0===this.x&&0===this.y&&0===this.z)return new ot(0,0,0);const e=this.length();return new ot(this.x/e,this.y/e,this.z/e)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}toArray(){return[this.x,this.y,this.z]}toString(){return`( ${this.x}, ${this.y}, ${this.z} )`}negate(){return new ot(-1*this.x,-1*this.y,-1*this.z)}}class lt{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}add(e){return new lt(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)}sub(e){return new lt(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}mul(e){return new lt(this.x*e,this.y*e,this.z*e,this.w*e)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}distance(e){return this.sub(e).length()}normal(){if(0===this.x&&0===this.y&&0===this.z&&0===this.w)return new lt(0,0,0,0);const e=this.length();return new lt(this.x/e,this.y/e,this.z/e,this.w/e)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}toArray(){return[this.x,this.y,this.z,this.w]}toString(){return`( ${this.x}, ${this.y}, ${this.z}, ${this.w} )`}negate(){return new ot(-1*this.x,-1*this.y,-1*this.z,-1*this.w)}}function ct(e){return e*Math.PI/180}const ht={Vector:ot,Vector4:lt,clamp:(e,t,n)=>Math.max(t,Math.min(e,n))},ut="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,dt=Object.keys,ft=Array.isArray;function pt(e,t){return"object"!=typeof t||dt(t).forEach(function(n){e[n]=t[n]}),e}"undefined"==typeof Promise||ut.Promise||(ut.Promise=Promise);const gt=Object.getPrototypeOf,mt={}.hasOwnProperty;function yt(e,t){return mt.call(e,t)}function bt(e,t){"function"==typeof t&&(t=t(gt(e))),("undefined"==typeof Reflect?dt:Reflect.ownKeys)(t).forEach(n=>{wt(e,n,t[n])})}const vt=Object.defineProperty;function wt(e,t,n,i){vt(e,t,pt(n&&yt(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},i))}function xt(e){return{from:function(t){return e.prototype=Object.create(t.prototype),wt(e.prototype,"constructor",e),{extend:bt.bind(null,e.prototype)}}}}const _t=Object.getOwnPropertyDescriptor;function kt(e,t){let n;return _t(e,t)||(n=gt(e))&&kt(n,t)}const St=[].slice;function Mt(e,t,n){return St.call(e,t,n)}function At(e,t){return t(e)}function Tt(e){if(!e)throw new Error("Assertion Failed")}function Et(e){ut.setImmediate?setImmediate(e):setTimeout(e,0)}function Pt(e,t){return e.reduce((e,n,i)=>{var r=t(n,i);return r&&(e[r[0]]=r[1]),e},{})}function Ct(e,t){if("string"==typeof t&&yt(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],i=0,r=t.length;i<r;++i){var s=Ct(e,t[i]);n.push(s)}return n}var a=t.indexOf(".");if(-1!==a){var o=e[t.substr(0,a)];return null==o?void 0:Ct(o,t.substr(a+1))}}function zt(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){Tt("string"!=typeof n&&"length"in n);for(var i=0,r=t.length;i<r;++i)zt(e,t[i],n[i])}else{var s=t.indexOf(".");if(-1!==s){var a=t.substr(0,s),o=t.substr(s+1);if(""===o)void 0===n?ft(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var l=e[a];l&&yt(e,a)||(l=e[a]={}),zt(l,o,n)}}else void 0===n?ft(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Lt(e){var t={};for(var n in e)yt(e,n)&&(t[n]=e[n]);return t}const It=[].concat;function Dt(e){return It.apply([],e)}const Rt="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Dt([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>ut[e]),Ot=Rt.map(e=>ut[e]);Pt(Rt,e=>[e,!0]);let Bt=null;function Ft(e){Bt="undefined"!=typeof WeakMap&&new WeakMap;const t=jt(e);return Bt=null,t}function jt(e){if(!e||"object"!=typeof e)return e;let t=Bt&&Bt.get(e);if(t)return t;if(ft(e)){t=[],Bt&&Bt.set(e,t);for(var n=0,i=e.length;n<i;++n)t.push(jt(e[n]))}else if(Ot.indexOf(e.constructor)>=0)t=e;else{const n=gt(e);for(var r in t=n===Object.prototype?{}:Object.create(n),Bt&&Bt.set(e,t),e)yt(e,r)&&(t[r]=jt(e[r]))}return t}const{toString:Nt}={};function Ut(e){return Nt.call(e).slice(8,-1)}const $t="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",Vt="symbol"==typeof $t?function(e){var t;return null!=e&&(t=e[$t])&&t.apply(e)}:function(){return null},Wt={};function Ht(e){var t,n,i,r;if(1===arguments.length){if(ft(e))return e.slice();if(this===Wt&&"string"==typeof e)return[e];if(r=Vt(e)){for(n=[];!(i=r.next()).done;)n.push(i.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const Kt="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var Zt="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Gt(e,t){Zt=e,Xt=t}var Xt=()=>!0;const Yt=!new Error("").stack;function qt(){if(Yt)try{throw qt.arguments,new Error}catch(e){return e}return new Error}function Jt(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(Xt).map(e=>"\n"+e).join("")):""}var Qt=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],en=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Qt),tn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function nn(e,t){this._e=qt(),this.name=e,this.message=t}function rn(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,n)=>n.indexOf(e)===t).join("\n")}function sn(e,t,n,i){this._e=qt(),this.failures=t,this.failedKeys=i,this.successCount=n,this.message=rn(e,t)}function an(e,t){this._e=qt(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=rn(e,t)}xt(nn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Jt(this._e,2))}},toString:function(){return this.name+": "+this.message}}),xt(sn).from(nn),xt(an).from(nn);var on=en.reduce((e,t)=>(e[t]=t+"Error",e),{});const ln=nn;var cn=en.reduce((e,t)=>{var n=t+"Error";function i(e,i){this._e=qt(),this.name=n,e?"string"==typeof e?(this.message=`${e}${i?"\n "+i:""}`,this.inner=i||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=tn[t]||n,this.inner=null)}return xt(i).from(ln),e[t]=i,e},{});cn.Syntax=SyntaxError,cn.Type=TypeError,cn.Range=RangeError;var hn=Qt.reduce((e,t)=>(e[t+"Error"]=cn[t],e),{}),un=en.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=cn[t]),e),{});function dn(){}function fn(e){return e}function pn(e,t){return null==e||e===fn?t:function(n){return t(e(n))}}function gn(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function mn(e,t){return e===dn?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var i=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?gn(i,this.onsuccess):i),r&&(this.onerror=this.onerror?gn(r,this.onerror):r),void 0!==s?s:n}}function yn(e,t){return e===dn?t:function(){e.apply(this,arguments);var n=this.onsuccess,i=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?gn(n,this.onsuccess):n),i&&(this.onerror=this.onerror?gn(i,this.onerror):i)}}function bn(e,t){return e===dn?t:function(n){var i=e.apply(this,arguments);pt(n,i);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?gn(r,this.onsuccess):r),s&&(this.onerror=this.onerror?gn(s,this.onerror):s),void 0===i?void 0===a?void 0:a:pt(i,a)}}function vn(e,t){return e===dn?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function wn(e,t){return e===dn?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var i=this,r=arguments.length,s=new Array(r);r--;)s[r]=arguments[r];return n.then(function(){return t.apply(i,s)})}return t.apply(this,arguments)}}un.ModifyError=sn,un.DexieError=nn,un.BulkError=an;var xn={};const[_n,kn,Sn]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,gt(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,gt(t),e]})(),Mn=kn&&kn.then,An=_n&&_n.constructor,Tn=!!Sn;var En=!1,Pn=Sn?()=>{Sn.then(Jn)}:ut.setImmediate?setImmediate.bind(null,Jn):ut.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{Jn(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Jn,0)},Cn=function(e,t){jn.push([e,t]),Ln&&(Pn(),Ln=!1)},zn=!0,Ln=!0,In=[],Dn=[],Rn=null,On=fn,Bn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ki,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{ki(e[0],e[1])}catch(t){}})}},Fn=Bn,jn=[],Nn=0,Un=[];function $n(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=dn,this._lib=!1;var t=this._PSD=Fn;if(Zt&&(this._stackHolder=qt(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==xn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Kn(this,this._value))}this._state=null,this._value=null,++t.ref,Hn(this,e)}const Vn={get:function(){var e=Fn,t=li;function n(n,i){var r=!e.global&&(e!==Fn||t!==li);const s=r&&!di();var a=new $n((t,a)=>{Gn(this,new Wn(wi(n,e,r,s),wi(i,e,r,s),t,a,e))});return Zt&&qn(a,this),a}return n.prototype=xn,n},set:function(e){wt(this,"then",e&&e.prototype===xn?Vn:{get:function(){return e},set:Vn.set})}};function Wn(e,t,n,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i,this.psd=r}function Hn(e,t){try{t(t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Qn();t&&"function"==typeof t.then?Hn(e,(e,n)=>{t instanceof $n?t._then(e,n):t.then(e,n)}):(e._state=!0,e._value=t,Zn(e)),n&&ei()}},Kn.bind(null,e))}catch(n){Kn(e,n)}}function Kn(e,t){if(Dn.push(t),null===e._state){var n=e._lib&&Qn();t=On(t),e._state=!1,e._value=t,Zt&&null!==t&&"object"==typeof t&&!t._promise&&function(){try{(()=>{var n=kt(t,"stack");t._promise=e,wt(t,"stack",{get:()=>En?n&&(n.get?n.get.apply(t):n.value):e.stack})}).apply(null,void 0)}catch(n){}}(),i=e,In.some(e=>e._value===i._value)||In.push(i),Zn(e),n&&ei()}var i}function Zn(e){var t=e._listeners;e._listeners=[];for(var n=0,i=t.length;n<i;++n)Gn(e,t[n]);var r=e._PSD;--r.ref||r.finalize(),0===Nn&&(++Nn,Cn(()=>{0==--Nn&&ti()},[]))}function Gn(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Nn,Cn(Xn,[n,e,t])}else e._listeners.push(t)}function Xn(e,t,n){try{Rn=t;var i,r=t._value;t._state?i=e(r):(Dn.length&&(Dn=[]),i=e(r),-1===Dn.indexOf(r)&&function(e){for(var t=In.length;t;)if(In[--t]._value===e._value)return void In.splice(t,1)}(t)),n.resolve(i)}catch(s){n.reject(s)}finally{Rn=null,0==--Nn&&ti(),--n.psd.ref||n.psd.finalize()}}function Yn(e,t,n){if(t.length===n)return t;var i="";if(!1===e._state){var r,s,a=e._value;null!=a?(r=a.name||"Error",s=a.message||a,i=Jt(a,0)):(r=a,s=""),t.push(r+(s?": "+s:"")+i)}return Zt&&((i=Jt(e._stackHolder,2))&&-1===t.indexOf(i)&&t.push(i),e._prev&&Yn(e._prev,t,n)),t}function qn(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function Jn(){Qn()&&ei()}function Qn(){var e=zn;return zn=!1,Ln=!1,e}function ei(){var e,t,n;do{for(;jn.length>0;)for(e=jn,jn=[],n=e.length,t=0;t<n;++t){var i=e[t];i[0].apply(null,i[1])}}while(jn.length>0);zn=!0,Ln=!0}function ti(){var e=In;In=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=Un.slice(0),n=t.length;n;)t[--n]()}function ni(e){return new $n(xn,!1,e)}function ii(e,t){var n=Fn;return function(){var i=Qn(),r=Fn;try{return mi(n,!0),e.apply(this,arguments)}catch(s){t&&t(s)}finally{mi(r,!1),i&&ei()}}}bt($n.prototype,{then:Vn,_then:function(e,t){Gn(this,new Wn(null,null,e,t,Fn))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):ni(e)):this.then(null,e=>e&&e.name===t?n(e):ni(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),ni(t)))},stack:{get:function(){if(this._stack)return this._stack;try{En=!0;var e=Yn(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{En=!1}}},timeout:function(e,t){return e<1/0?new $n((n,i)=>{var r=setTimeout(()=>i(new cn.Timeout(t)),e);this.then(n,i).finally(clearTimeout.bind(null,r))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&wt($n.prototype,Symbol.toStringTag,"Dexie.Promise"),Bn.env=yi(),bt($n,{all:function(){var e=Ht.apply(null,arguments).map(fi);return new $n(function(t,n){0===e.length&&t([]);var i=e.length;e.forEach((r,s)=>$n.resolve(r).then(n=>{e[s]=n,--i||t(e)},n))})},resolve:e=>{if(e instanceof $n)return e;if(e&&"function"==typeof e.then)return new $n((t,n)=>{e.then(t,n)});var t=new $n(xn,!0,e);return qn(t,Rn),t},reject:ni,race:function(){var e=Ht.apply(null,arguments).map(fi);return new $n((t,n)=>{e.map(e=>$n.resolve(e).then(t,n))})},PSD:{get:()=>Fn,set:e=>Fn=e},totalEchoes:{get:()=>li},newPSD:hi,usePSD:bi,scheduler:{get:()=>Cn,set:e=>{Cn=e}},rejectionMapper:{get:()=>On,set:e=>{On=e}},follow:(e,t)=>new $n((n,i)=>hi((t,n)=>{var i=Fn;i.unhandleds=[],i.onunhandled=n,i.finalize=gn(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},Un.push(function t(){e(),Un.splice(Un.indexOf(t),1)}),++Nn,Cn(()=>{0==--Nn&&ti()},[])},i.finalize),e()},t,n,i))}),An&&(An.allSettled&&wt($n,"allSettled",function(){const e=Ht.apply(null,arguments).map(fi);return new $n(t=>{0===e.length&&t([]);let n=e.length;const i=new Array(n);e.forEach((e,r)=>$n.resolve(e).then(e=>i[r]={status:"fulfilled",value:e},e=>i[r]={status:"rejected",reason:e}).then(()=>--n||t(i)))})}),An.any&&"undefined"!=typeof AggregateError&&wt($n,"any",function(){const e=Ht.apply(null,arguments).map(fi);return new $n((t,n)=>{0===e.length&&n(new AggregateError([]));let i=e.length;const r=new Array(i);e.forEach((e,s)=>$n.resolve(e).then(e=>t(e),e=>{r[s]=e,--i||n(new AggregateError(r))}))})}));const ri={awaits:0,echoes:0,id:0};var si=0,ai=[],oi=0,li=0,ci=0;function hi(e,t,n,i){var r=Fn,s=Object.create(r);s.parent=r,s.ref=0,s.global=!1,s.id=++ci;var a=Bn.env;s.env=Tn?{Promise:$n,PromiseProp:{value:$n,configurable:!0,writable:!0},all:$n.all,race:$n.race,allSettled:$n.allSettled,any:$n.any,resolve:$n.resolve,reject:$n.reject,nthen:xi(a.nthen,s),gthen:xi(a.gthen,s)}:{},t&&pt(s,t),++r.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var o=bi(s,e,n,i);return 0===s.ref&&s.finalize(),o}function ui(){return ri.id||(ri.id=++si),++ri.awaits,ri.echoes+=100,ri.id}function di(){return!!ri.awaits&&(0==--ri.awaits&&(ri.id=0),ri.echoes=100*ri.awaits,!0)}function fi(e){return ri.echoes&&e&&e.constructor===An?(ui(),e.then(e=>(di(),e),e=>(di(),Si(e)))):e}function pi(e){++li,ri.echoes&&0!=--ri.echoes||(ri.echoes=ri.id=0),ai.push(Fn),mi(e,!0)}function gi(){var e=ai[ai.length-1];ai.pop(),mi(e,!1)}function mi(e,t){var n=Fn;if((t?!ri.echoes||oi++&&e===Fn:!oi||--oi&&e===Fn)||vi(t?pi.bind(null,e):gi),e!==Fn&&(Fn=e,n===Bn&&(Bn.env=yi()),Tn)){var i=Bn.env.Promise,r=e.env;kn.then=r.nthen,i.prototype.then=r.gthen,(n.global||e.global)&&(Object.defineProperty(ut,"Promise",r.PromiseProp),i.all=r.all,i.race=r.race,i.resolve=r.resolve,i.reject=r.reject,r.allSettled&&(i.allSettled=r.allSettled),r.any&&(i.any=r.any))}}function yi(){var e=ut.Promise;return Tn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(ut,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:kn.then,gthen:e.prototype.then}:{}}function bi(e,t,n,i,r){var s=Fn;try{return mi(e,!0),t(n,i,r)}finally{mi(s,!1)}}function vi(e){Mn.call(_n,e)}function wi(e,t,n,i){return"function"!=typeof e?e:function(){var r=Fn;n&&ui(),mi(t,!0);try{return e.apply(this,arguments)}finally{mi(r,!1),i&&vi(di)}}}function xi(e,t){return function(n,i){return e.call(this,wi(n,t),wi(i,t))}}-1===(""+Mn).indexOf("[native code]")&&(ui=di=dn);const _i="unhandledrejection";function ki(e,t){var n;try{n=t.onuncatched(e)}catch(s){}if(!1!==n)try{var i,r={promise:t,reason:e};if(ut.document&&document.createEvent?((i=document.createEvent("Event")).initEvent(_i,!0,!0),pt(i,r)):ut.CustomEvent&&pt(i=new CustomEvent(_i,{detail:r}),r),i&&ut.dispatchEvent&&(dispatchEvent(i),!ut.PromiseRejectionEvent&&ut.onunhandledrejection))try{ut.onunhandledrejection(i)}catch(s){}Zt&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(s){}}var Si=$n.reject;function Mi(e,t,n,i){if(e.idbdb&&(e._state.openComplete||Fn.letThrough||e._vip)){var r=e._createTransaction(t,n,e._dbSchema);try{r.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===on.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Mi(e,t,n,i))):Si(s)}return r._promise(t,(e,t)=>hi(()=>(Fn.trans=r,i(e,t,r)))).then(e=>r._completion.then(()=>e))}if(e._state.openComplete)return Si(new cn.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return Si(new cn.DatabaseClosed);e.open().catch(dn)}return e._state.dbReadyPromise.then(()=>Mi(e,t,n,i))}const Ai="3.2.7",Ti=String.fromCharCode(65535),Ei=-1/0,Pi="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ci="String expected.",zi=[],Li="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Ii=Li,Di=Li,Ri=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),Oi="__dbnames",Bi="readonly",Fi="readwrite";function ji(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const Ni={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ui(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=Ft(t))[e],t)}class $i{_trans(e,t,n){const i=this._tx||Fn.trans,r=this.name;function s(e,n,i){if(!i.schema[r])throw new cn.NotFound("Table "+r+" not part of transaction");return t(i.idbtrans,i)}const a=Qn();try{return i&&i.db===this.db?i===Fn.trans?i._promise(e,s,n):hi(()=>i._promise(e,s,n),{trans:i,transless:Fn.transless||Fn}):Mi(this.db,e,[this.name],s)}finally{a&&ei()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(ft(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const t=dt(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);const n=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)){for(let n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1}).sort((e,t)=>e.keyPath.length-t.keyPath.length)[0];if(n&&this.db._maxKey!==Ti){const i=n.keyPath.slice(0,t.length);return this.where(i).equals(i.map(t=>e[t]))}!n&&Zt&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);const{idxByName:i}=this.schema,r=this.db._deps.indexedDB;function s(e,t){try{return 0===r.cmp(e,t)}catch(n){return!1}}const[a,o]=t.reduce(([t,n],r)=>{const a=i[r],o=e[r];return[t||a,t||!a?ji(n,a&&a.multi?e=>{const t=Ct(e,r);return ft(t)&&t.some(e=>s(o,e))}:e=>s(o,Ct(e,r))):n]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(o):n?this.filter(o):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ft(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const t=t=>{if(!t)return t;const n=Object.create(e.prototype);for(var i in t)if(yt(t,i))try{n[i]=t[i]}catch(r){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){pt(this,e)})}add(e,t){const{auto:n,keyPath:i}=this.schema.primKey;let r=e;return i&&n&&(r=Ui(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[r]})).then(e=>e.numFailures?$n.reject(e.failures[0]):e.lastResult).then(t=>{if(i)try{zt(e,i,t)}catch(n){}return t})}update(e,t){if("object"!=typeof e||ft(e))return this.where(":id").equals(e).modify(t);{const i=Ct(e,this.schema.primKey.keyPath);if(void 0===i)return Si(new cn.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?dt(t).forEach(n=>{zt(e,n,t[n])}):t(e,{value:e,primKey:i})}catch(n){}return this.where(":id").equals(i).modify(t)}}put(e,t){const{auto:n,keyPath:i}=this.schema.primKey;let r=e;return i&&n&&(r=Ui(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=t?[t]:null})).then(e=>e.numFailures?$n.reject(e.failures[0]):e.lastResult).then(t=>{if(i)try{zt(e,i,t)}catch(n){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?$n.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Ni})).then(e=>e.numFailures?$n.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,n){const i=Array.isArray(t)?t:void 0,r=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{const{auto:n,keyPath:s}=this.schema.primKey;if(s&&i)throw new cn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new cn.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=s&&n?e.map(Ui(s)):e;return this.core.mutate({trans:t,type:"add",keys:i,values:o,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:i})=>{if(0===e)return r?t:n;throw new an(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,i)})})}bulkPut(e,t,n){const i=Array.isArray(t)?t:void 0,r=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{const{auto:n,keyPath:s}=this.schema.primKey;if(s&&i)throw new cn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new cn.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=s&&n?e.map(Ui(s)):e;return this.core.mutate({trans:t,type:"put",keys:i,values:o,wantResults:r}).then(({numFailures:e,results:t,lastResult:n,failures:i})=>{if(0===e)return r?t:n;throw new an(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,i)})})}bulkDelete(e){const t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:i})=>{if(0===e)return n;throw new an(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,i)})}}function Vi(e){var t={},n=function(n,i){if(i){for(var r=arguments.length,s=new Array(r-1);--r;)s[r-1]=arguments[r];return t[n].subscribe.apply(null,s),e}if("string"==typeof n)return t[n]};n.addEventType=s;for(var i=1,r=arguments.length;i<r;++i)s(arguments[i]);return n;function s(e,i,r){if("object"!=typeof e){var a;i||(i=vn),r||(r=dn);var o={subscribers:[],fire:r,subscribe:function(e){-1===o.subscribers.indexOf(e)&&(o.subscribers.push(e),o.fire=i(o.fire,e))},unsubscribe:function(e){o.subscribers=o.subscribers.filter(function(t){return t!==e}),o.fire=o.subscribers.reduce(i,r)}};return t[e]=n[e]=o,o}dt(a=e).forEach(function(e){var t=a[e];if(ft(t))s(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new cn.InvalidArgument("Invalid event config");var n=s(e,fn,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){Et(function(){e.apply(null,t)})})})}})}}function Wi(e,t){return xt(t).from({prototype:e}),t}function Hi(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Ki(e,t){e.filter=ji(e.filter,t)}function Zi(e,t,n){var i=e.replayFilter;e.replayFilter=i?()=>ji(i(),t()):t,e.justLimit=n&&!i}function Gi(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new cn.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Xi(e,t,n){const i=Gi(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:i,range:e.range}})}function Yi(e,t,n,i){const r=e.replayFilter?ji(e.filter,e.replayFilter()):e.filter;if(e.or){const s={},a=(e,n,i)=>{if(!r||r(n,i,e=>n.stop(e),e=>n.fail(e))){var a=n.primaryKey,o=""+a;"[object ArrayBuffer]"===o&&(o=""+new Uint8Array(a)),yt(s,o)||(s[o]=!0,t(e,n,i))}};return Promise.all([e.or._iterate(a,n),qi(Xi(e,i,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return qi(Xi(e,i,n),ji(e.algorithm,r),t,!e.keysOnly&&e.valueMapper)}function qi(e,t,n,i){var r=ii(i?(e,t,r)=>n(i(e),t,r):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=dn},t=>{e.fail(t),n=dn})||r(e.value,e,e=>n=e),n()})})}function Ji(e,t){try{const n=Qi(e),i=Qi(t);if(n!==i)return"Array"===n?1:"Array"===i?-1:"binary"===n?1:"binary"===i?-1:"string"===n?1:"string"===i?-1:"Date"===n?1:"Date"!==i?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,i=t.length,r=n<i?n:i;for(let s=0;s<r;++s)if(e[s]!==t[s])return e[s]<t[s]?-1:1;return n===i?0:n<i?-1:1}(er(e),er(t));case"Array":return function(e,t){const n=e.length,i=t.length,r=n<i?n:i;for(let s=0;s<r;++s){const n=Ji(e[s],t[s]);if(0!==n)return n}return n===i?0:n<i?-1:1}(e,t)}}catch(n){}return NaN}function Qi(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=Ut(e);return"ArrayBuffer"===n?"binary":n}function er(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class tr{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,Si.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,Si.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=ji(t.algorithm,e)}_iterate(e,t){return Yi(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&pt(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>Yi(t,e,n,t.table.core))}count(e){return this._read(e=>{const t=this._ctx,n=t.table.core;if(Hi(t,!0))return n.count({trans:e,query:{index:Gi(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var i=0;return Yi(t,()=>(++i,!1),e,n).then(()=>i)}).then(e)}sortBy(e,t){const n=e.split(".").reverse(),i=n[0],r=n.length-1;function s(e,t){return t?s(e[n[t]],t-1):e[i]}var a="next"===this._ctx.dir?1:-1;function o(e,t){var n=s(e,r),i=s(t,r);return n<i?-a:n>i?a:0}return this.toArray(function(e){return e.sort(o)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&Hi(t,!0)&&t.limit>0){const{valueMapper:n}=t,i=Gi(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:i,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{const n=[];return Yi(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,Hi(t)?Zi(t,()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n(()=>{e.advance(t),t=0}),!1))}):Zi(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Zi(this._ctx,()=>{var t=e;return function(e,n,i){return--t<=0&&n(i),t>=0}},!0),this}until(e,t){return Ki(this._ctx,function(n,i,r){return!e(n.value)||(i(r),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return Ki(this._ctx,function(t){return e(t.value)}),t=this._ctx,n=e,t.isMatch=ji(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&Hi(t,!0)&&t.limit>0)return this._read(e=>{var n=Gi(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return Ki(this._ctx,function(e){var t=e.primaryKey.toString(),i=yt(n,t);return n[t]=!0,!i}),this}modify(e){var t=this._ctx;return this._write(n=>{var i;if("function"==typeof e)i=e;else{var r=dt(e),s=r.length;i=function(t){for(var n=!1,i=0;i<s;++i){var a=r[i],o=e[a];Ct(t,a)!==o&&(zt(t,a,o),n=!0)}return n}}const a=t.table.core,{outbound:o,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,h=[];let u=0;const d=[],f=(e,t)=>{const{failures:n,numFailures:i}=t;u+=e-i;for(let r of dt(n))h.push(n[r])};return this.clone().primaryKeys().then(r=>{const s=h=>{const u=Math.min(c,r.length-h);return a.getMany({trans:n,keys:r.slice(h,h+u),cache:"immutable"}).then(d=>{const p=[],g=[],m=o?[]:null,y=[];for(let e=0;e<u;++e){const t=d[e],n={value:Ft(t),primKey:r[h+e]};!1!==i.call(n,n.value,n)&&(null==n.value?y.push(r[h+e]):o||0===Ji(l(t),l(n.value))?(g.push(n.value),o&&m.push(r[h+e])):(y.push(r[h+e]),p.push(n.value)))}const b=Hi(t)&&t.limit===1/0&&("function"!=typeof e||e===nr)&&{index:t.index,range:t.range};return Promise.resolve(p.length>0&&a.mutate({trans:n,type:"add",values:p}).then(e=>{for(let t in e.failures)y.splice(parseInt(t),1);f(p.length,e)})).then(()=>(g.length>0||b&&"object"==typeof e)&&a.mutate({trans:n,type:"put",keys:m,values:g,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(g.length,e))).then(()=>(y.length>0||b&&e===nr)&&a.mutate({trans:n,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>r.length>h+u&&s(h+c))})};return s(0).then(()=>{if(h.length>0)throw new sn("Error modifying one or more objects",h,u,d);return r.length})})})}delete(){var e=this._ctx,t=e.range;return Hi(e)&&(e.isPrimKey&&!Di||3===t.type)?this._write(n=>{const{primaryKey:i}=e.table.core.schema,r=t;return e.table.core.count({trans:n,query:{index:i,range:r}}).then(t=>e.table.core.mutate({trans:n,type:"deleteRange",range:r}).then(({failures:e,lastResult:n,results:i,numFailures:r})=>{if(r)throw new sn("Could not delete some values",Object.keys(e).map(t=>e[t]),t-r);return t-r}))}):this.modify(nr)}}const nr=(e,t)=>t.value=null;function ir(e,t){return e<t?-1:e===t?0:1}function rr(e,t){return e>t?-1:e===t?0:1}function sr(e,t,n){var i=e instanceof ur?new e.Collection(e):e;return i._ctx.error=n?new n(t):new TypeError(t),i}function ar(e){return new e.Collection(e,()=>hr("")).limit(0)}function or(e,t,n,i,r,s){for(var a=Math.min(e.length,i.length),o=-1,l=0;l<a;++l){var c=t[l];if(c!==i[l])return r(e[l],n[l])<0?e.substr(0,l)+n[l]+n.substr(l+1):r(e[l],i[l])<0?e.substr(0,l)+i[l]+n.substr(l+1):o>=0?e.substr(0,o)+t[o]+n.substr(o+1):null;r(e[l],c)<0&&(o=l)}return a<i.length&&"next"===s?e+n.substr(e.length):a<e.length&&"prev"===s?e.substr(0,n.length):o<0?null:e.substr(0,o)+i[o]+n.substr(o+1)}function lr(e,t,n,i){var r,s,a,o,l,c,h,u=n.length;if(!n.every(e=>"string"==typeof e))return sr(e,Ci);function d(e){r=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),s=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),a="next"===e?ir:rr;var t=n.map(function(e){return{lower:s(e),upper:r(e)}}).sort(function(e,t){return a(e.lower,t.lower)});o=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),c=e,h="next"===e?"":i}d("next");var f=new e.Collection(e,()=>cr(o[0],l[u-1]+i));f._ondirectionchange=function(e){d(e)};var p=0;return f._addAlgorithm(function(e,n,i){var r=e.key;if("string"!=typeof r)return!1;var d=s(r);if(t(d,l,p))return!0;for(var f=null,g=p;g<u;++g){var m=or(r,d,o[g],l[g],a,c);null===m&&null===f?p=g+1:(null===f||a(f,m)>0)&&(f=m)}return n(null!==f?function(){e.continue(f+h)}:i),!1}),f}function cr(e,t,n,i){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:i}}function hr(e){return{type:1,lower:e,upper:e}}class ur{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,i){n=!1!==n,i=!0===i;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||i)&&(!n||!i)?ar(this):new this.Collection(this,()=>cr(e,t,!n,!i))}catch(r){return sr(this,Pi)}}equals(e){return null==e?sr(this,Pi):new this.Collection(this,()=>hr(e))}above(e){return null==e?sr(this,Pi):new this.Collection(this,()=>cr(e,void 0,!0))}aboveOrEqual(e){return null==e?sr(this,Pi):new this.Collection(this,()=>cr(e,void 0,!1))}below(e){return null==e?sr(this,Pi):new this.Collection(this,()=>cr(void 0,e,!1,!0))}belowOrEqual(e){return null==e?sr(this,Pi):new this.Collection(this,()=>cr(void 0,e))}startsWith(e){return"string"!=typeof e?sr(this,Ci):this.between(e,e+Ti,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):lr(this,(e,t)=>0===e.indexOf(t[0]),[e],Ti)}equalsIgnoreCase(e){return lr(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=Ht.apply(Wt,arguments);return 0===e.length?ar(this):lr(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=Ht.apply(Wt,arguments);return 0===e.length?ar(this):lr(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,Ti)}anyOf(){const e=Ht.apply(Wt,arguments);let t=this._cmp;try{e.sort(t)}catch(r){return sr(this,Pi)}if(0===e.length)return ar(this);const n=new this.Collection(this,()=>cr(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let i=0;return n._addAlgorithm((n,r,s)=>{const a=n.key;for(;t(a,e[i])>0;)if(++i,i===e.length)return r(s),!1;return 0===t(a,e[i])||(r(()=>{n.continue(e[i])}),!1)}),n}notEqual(e){return this.inAnyRange([[Ei,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=Ht.apply(Wt,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(n){return sr(this,Pi)}const t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[Ei,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,i=this._ascending,r=this._descending,s=this._min,a=this._max;if(0===e.length)return ar(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0))return sr(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",cn.InvalidArgument);const o=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers;let c,h=i;function u(e,t){return h(e[0],t[0])}try{c=e.reduce(function(e,t){let i=0,r=e.length;for(;i<r;++i){const r=e[i];if(n(t[0],r[1])<0&&n(t[1],r[0])>0){r[0]=s(r[0],t[0]),r[1]=a(r[1],t[1]);break}}return i===r&&e.push(t),e},[]),c.sort(u)}catch(y){return sr(this,Pi)}let d=0;const f=l?e=>i(e,c[d][1])>0:e=>i(e,c[d][1])>=0,p=o?e=>r(e,c[d][0])>0:e=>r(e,c[d][0])>=0;let g=f;const m=new this.Collection(this,()=>cr(c[0][0],c[c.length-1][1],!o,!l));return m._ondirectionchange=e=>{"next"===e?(g=f,h=i):(g=p,h=r),c.sort(u)},m._addAlgorithm((e,t,n)=>{for(var r=e.key;g(r);)if(++d,d===c.length)return t(n),!1;return!(s=r,(f(s)||p(s))&&(0===this._cmp(r,c[d][1])||0===this._cmp(r,c[d][0])||t(()=>{h===i?e.continue(c[d][0]):e.continue(c[d][1])}),1));var s}),m}startsWithAnyOf(){const e=Ht.apply(Wt,arguments);return e.every(e=>"string"==typeof e)?0===e.length?ar(this):this.inAnyRange(e.map(e=>[e,e+Ti])):sr(this,"startsWithAnyOf() only works with strings")}}function dr(e){return ii(function(t){return fr(t),e(t.target.error),!1})}function fr(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const pr="storagemutated",gr="x-storagemutated-1",mr=Vi(null,pr);class yr{_lock(){return Tt(!Fn.global),++this._reculock,1!==this._reculock||Fn.global||(Fn.lockOwnerFor=this),this}_unlock(){if(Tt(!Fn.global),0==--this._reculock)for(Fn.global||(Fn.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{bi(e[1],e[0])}catch(t){}}return this}_locked(){return this._reculock&&Fn.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(Tt(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new cn.DatabaseClosed(n);case"MissingAPIError":throw new cn.MissingAPI(n.message,n);default:throw new cn.OpenFailed(n)}if(!this.active)throw new cn.TransactionInactive;return Tt(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=ii(t=>{fr(t),this._reject(e.error)}),e.onabort=ii(t=>{fr(t),this.active&&this._reject(new cn.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=ii(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&mr.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return Si(new cn.ReadOnly("Transaction is readonly"));if(!this.active)return Si(new cn.TransactionInactive);if(this._locked())return new $n((i,r)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(i,r)},Fn])});if(n)return hi(()=>{var e=new $n((e,n)=>{this._lock();const i=t(e,n,this);i&&i.then&&i.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var i=new $n((e,n)=>{var i=t(e,n,this);i&&i.then&&i.then(e,n)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=$n.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var i=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(i.get(-1/0).onsuccess=e)}()}var r=t._waitingFor;return new $n((e,i)=>{n.then(n=>t._waitingQueue.push(ii(e.bind(null,n))),e=>t._waitingQueue.push(ii(i.bind(null,e)))).finally(()=>{t._waitingFor===r&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new cn.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(yt(t,e))return t[e];const n=this.schema[e];if(!n)throw new cn.NotFound("Table "+e+" not part of transaction");const i=new this.db.Table(e,n,this);return i.core=this.db.core.table(e),t[e]=i,i}}function br(e,t,n,i,r,s,a){return{name:e,keyPath:t,unique:n,multi:i,auto:r,compound:s,src:(n&&!a?"&":"")+(i?"*":"")+(r?"++":"")+vr(t)}}function vr(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function wr(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:Pt(n,e=>[e.name,e])}}let xr=e=>{try{return e.only([[]]),xr=()=>[[]],[[]]}catch(t){return xr=()=>Ti,Ti}};function _r(e){return null==e?()=>{}:"string"==typeof e?1===(t=e).split(".").length?e=>e[t]:e=>Ct(e,t):t=>Ct(t,e);var t}function kr(e){return[].slice.call(e)}let Sr=0;function Mr(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function Ar({_novip:e},t){const n=t.db,i=function(e,t,{IDBKeyRange:n,indexedDB:i},r){const s=(a=function(e,t,n){function i(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:i,lowerOpen:r,upperOpen:s}=e;return void 0===n?void 0===i?null:t.upperBound(i,!!s):void 0===i?t.lowerBound(n,!!r):t.bound(n,i,!!r,!!s)}const{schema:r,hasGetAll:s}=function(e,t){const n=kr(e.objectStoreNames);return{schema:{name:e.name,tables:n.map(e=>t.objectStore(e)).map(e=>{const{keyPath:t,autoIncrement:n}=e,i=ft(t),r=null==t,s={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:i,keyPath:t,autoIncrement:n,unique:!0,extractKey:_r(t)},indexes:kr(e.indexNames).map(t=>e.index(t)).map(e=>{const{name:t,unique:n,multiEntry:i,keyPath:r}=e,a={name:t,compound:ft(r),keyPath:r,unique:n,multiEntry:i,extractKey:_r(r)};return s[Mr(r)]=a,a}),getIndexByKeyPath:e=>s[Mr(e)]};return s[":id"]=a.primaryKey,null!=t&&(s[Mr(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in t.objectStore(n[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),a=r.tables.map(e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:r,values:s,range:a}){return new Promise((o,l)=>{o=ii(o);const c=e.objectStore(t),h=null==c.keyPath,u="put"===n||"add"===n;if(!u&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:d}=r||s||{length:1};if(r&&s&&r.length!==s.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return o({numFailures:0,failures:{},results:[],lastResult:void 0});let f;const p=[],g=[];let m=0;const y=e=>{++m,fr(e)};if("deleteRange"===n){if(4===a.type)return o({numFailures:m,failures:g,results:[],lastResult:void 0});3===a.type?p.push(f=c.clear()):p.push(f=c.delete(i(a)))}else{const[e,t]=u?h?[s,r]:[s,null]:[r,null];if(u)for(let i=0;i<d;++i)p.push(f=t&&void 0!==t[i]?c[n](e[i],t[i]):c[n](e[i])),f.onerror=y;else for(let i=0;i<d;++i)p.push(f=c[n](e[i])),f.onerror=y}const b=e=>{const t=e.target.result;p.forEach((e,t)=>null!=e.error&&(g[t]=e.error)),o({numFailures:m,failures:g,results:"delete"===n?r:p.map(e=>e.result),lastResult:t})};f.onerror=e=>{y(e),b(e)},f.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((i,r)=>{i=ii(i);const s=e.objectStore(t),a=n.length,o=new Array(a);let l,c=0,h=0;const u=e=>{const t=e.target;o[t._pos]=t.result,++h===c&&i(o)},d=dr(r);for(let e=0;e<a;++e)null!=n[e]&&(l=s.get(n[e]),l._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&i(o)}),get:({trans:e,key:n})=>new Promise((i,r)=>{i=ii(i);const s=e.objectStore(t).get(n);s.onsuccess=e=>i(e.target.result),s.onerror=dr(r)}),query:function(e){return n=>new Promise((r,s)=>{r=ii(r);const{trans:a,values:o,limit:l,query:c}=n,h=l===1/0?void 0:l,{index:u,range:d}=c,f=a.objectStore(t),p=u.isPrimaryKey?f:f.index(u.name),g=i(d);if(0===l)return r({result:[]});if(e){const e=o?p.getAll(g,h):p.getAllKeys(g,h);e.onsuccess=e=>r({result:e.target.result}),e.onerror=dr(s)}else{let e=0;const t=o||!("openKeyCursor"in p)?p.openCursor(g):p.openKeyCursor(g),n=[];t.onsuccess=i=>{const s=t.result;return s?(n.push(o?s.value:s.primaryKey),++e===l?r({result:n}):void s.continue()):r({result:n})},t.onerror=dr(s)}})}(s),openCursor:function({trans:e,values:n,query:r,reverse:s,unique:a}){return new Promise((o,l)=>{o=ii(o);const{index:c,range:h}=r,u=e.objectStore(t),d=c.isPrimaryKey?u:u.index(c.name),f=s?a?"prevunique":"prev":a?"nextunique":"next",p=n||!("openKeyCursor"in d)?d.openCursor(i(h),f):d.openKeyCursor(i(h),f);p.onerror=dr(l),p.onsuccess=ii(t=>{const n=p.result;if(!n)return void o(null);n.___id=++Sr,n.done=!1;const i=n.continue.bind(n);let r=n.continuePrimaryKey;r&&(r=r.bind(n));const s=n.advance.bind(n),a=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=ii(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{const t=new Promise((e,t)=>{e=ii(e),p.onerror=dr(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}}),o=()=>{if(p.result)try{e()}catch(t){n.fail(t)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return p.onsuccess=ii(e=>{p.onsuccess=o,o()}),n.continue=i,n.continuePrimaryKey=r,n.advance=s,o(),t},o(n)},l)})},count({query:e,trans:n}){const{index:r,range:s}=e;return new Promise((e,a)=>{const o=n.objectStore(t),l=r.isPrimaryKey?o:o.index(r.name),c=i(s),h=c?l.count(c):l.count();h.onsuccess=ii(t=>e(t.target.result)),h.onerror=dr(a)})}}}(e)),o={};return a.forEach(e=>o[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!o[e])throw new Error(`Table '${e}' not found`);return o[e]},MIN_KEY:-1/0,MAX_KEY:xr(t),schema:r}}(t,n,r),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),a));var a;return{dbcore:s}}(e._middlewares,n,e._deps,t);e.core=i.dbcore,e.tables.forEach(t=>{const n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function Tr({_novip:e},t,n,i){n.forEach(n=>{const r=i[n];t.forEach(t=>{const i=kt(t,n);(!i||"value"in i&&void 0===i.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?wt(t,n,{get(){return this.table(n)},set(e){vt(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,r))})})}function Er({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function Pr(e,t){return e._cfg.version-t._cfg.version}function Cr(e,t){const n={del:[],add:[],change:[]};let i;for(i in e)t[i]||n.del.push(i);for(i in t){const r=e[i],s=t[i];if(r){const e={name:i,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||r.primKey.auto!==s.primKey.auto&&!Li)e.recreate=!0,n.change.push(e);else{const t=r.idxByName,i=s.idxByName;let a;for(a in t)i[a]||e.del.push(a);for(a in i){const n=t[a],r=i[a];n?n.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([i,s])}return n}function zr(e,t,n,i){const r=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return i.forEach(e=>Lr(r,e)),r}function Lr(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Ir(e,t,n){const i={};return Mt(t.objectStoreNames,0).forEach(e=>{const t=n.objectStore(e);let r=t.keyPath;const s=br(vr(r),r||"",!1,!1,!!t.autoIncrement,r&&"string"!=typeof r,!0),a=[];for(let n=0;n<t.indexNames.length;++n){const e=t.index(t.indexNames[n]);r=e.keyPath;var o=br(e.name,r,!!e.unique,!!e.multiEntry,!1,r&&"string"!=typeof r,!1);a.push(o)}i[e]=wr(e,s,a)}),i}function Dr({_novip:e},t,n){const i=n.db.objectStoreNames;for(let r=0;r<i.length;++r){const s=i[r],a=n.objectStore(s);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){const n=a.indexNames[e],i=a.index(n).keyPath,r="string"==typeof i?i:"["+Mt(i).join("+")+"]";if(t[s]){const e=t[s].idxByName[r];e&&(e.name=n,delete t[s].idxByName[r],t[s].idxByName[n]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&ut.WorkerGlobalScope&&ut instanceof ut.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class Rr{_parseStoresSpec(e,t){dt(e).forEach(n=>{if(null!==e[n]){var i=e[n].split(",").map((e,t)=>{const n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return br(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),ft(i),0===t)}),r=i.shift();if(r.multi)throw new cn.Schema("Primary key cannot be multi-valued");i.forEach(e=>{if(e.auto)throw new cn.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new cn.Schema("Index must have a name and cannot be an empty string")}),t[n]=wr(n,r,i)}})}stores(e){const t=this.db;this._cfg.storesSource=this._cfg.storesSource?pt(this._cfg.storesSource,e):e;const n=t._versions,i={};let r={};return n.forEach(e=>{pt(i,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(i,r)}),t._dbSchema=r,Er(t,[t._allTables,t,t.Transaction.prototype]),Tr(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],dt(r),r),t._storeNames=dt(r),this}upgrade(e){return this._cfg.contentUpgrade=wn(this._cfg.contentUpgrade||dn,e),this}}function Or(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new rs(Oi,{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Br(e){return e&&"function"==typeof e.databases}function Fr(e){return hi(function(){return Fn.letThrough=!0,e()})}function jr(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function Nr(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?Si(t.dbOpenError):e);Zt&&(t.openCanceller._stackHolder=qt()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const i=t.openCanceller;function r(){if(t.openCanceller!==i)throw new cn.DatabaseClosed("db.open() was cancelled")}let s=t.dbReadyResolve,a=null,o=!1;const l=()=>new $n((i,s)=>{if(r(),!n)throw new cn.MissingAPI;const l=e.name,c=t.autoSchema?n.open(l):n.open(l,Math.round(10*e.verno));if(!c)throw new cn.MissingAPI;c.onerror=dr(s),c.onblocked=ii(e._fireOnBlocked),c.onupgradeneeded=ii(i=>{if(a=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=fr,a.abort(),c.result.close();const e=n.deleteDatabase(l);e.onsuccess=e.onerror=ii(()=>{s(new cn.NoSuchDatabase(`Database ${l} doesnt exist`))})}else{a.onerror=dr(s);var r=i.oldVersion>Math.pow(2,62)?0:i.oldVersion;o=r<1,e._novip.idbdb=c.result,function(e,t,n,i){const r=e._dbSchema,s=e._createTransaction("readwrite",e._storeNames,r);s.create(n),s._completion.catch(i);const a=s._reject.bind(s),o=Fn.transless||Fn;hi(()=>{Fn.trans=s,Fn.transless=o,0===t?(dt(r).forEach(e=>{zr(n,e,r[e].primKey,r[e].indexes)}),Ar(e,n),$n.follow(()=>e.on.populate.fire(s)).catch(a)):function({_novip:e},t,n,i){const r=[],s=e._versions;let a=e._dbSchema=Ir(0,e.idbdb,i),o=!1;return s.filter(e=>e._cfg.version>=t).forEach(s=>{r.push(()=>{const r=a,l=s._cfg.dbschema;Dr(e,r,i),Dr(e,l,i),a=e._dbSchema=l;const c=Cr(r,l);c.add.forEach(e=>{zr(i,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new cn.Upgrade("Not yet support for changing primary key");{const t=i.objectStore(e.name);e.add.forEach(e=>Lr(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),Lr(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});const h=s._cfg.contentUpgrade;if(h&&s._cfg.version>t){Ar(e,i),n._memoizedTables={},o=!0;let t=Lt(l);c.del.forEach(e=>{t[e]=r[e]}),Er(e,[e.Transaction.prototype]),Tr(e,[e.Transaction.prototype],dt(t),t),n.schema=t;const s=Kt(h);let a;s&&ui();const u=$n.follow(()=>{if(a=h(n),a&&s){var e=di.bind(null,null);a.then(e,e)}});return a&&"function"==typeof a.then?$n.resolve(a):u.then(()=>a)}}),r.push(t=>{var i,r;o&&Ii||(i=s._cfg.dbschema,r=t,[].slice.call(r.db.objectStoreNames).forEach(e=>null==i[e]&&r.db.deleteObjectStore(e))),Er(e,[e.Transaction.prototype]),Tr(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),function e(){return r.length?$n.resolve(r.shift()(n.idbtrans)).then(e):$n.resolve()}().then(()=>{var e,t;t=i,dt(e=a).forEach(n=>{t.db.objectStoreNames.contains(n)||zr(t,n,e[n].primKey,e[n].indexes)})})}(e,t,s,n).catch(a)})}(e,r/10,a,s)}},s),c.onsuccess=ii(()=>{a=null;const n=e._novip.idbdb=c.result,r=Mt(n.objectStoreNames);if(r.length>0)try{const i=n.transaction(1===(s=r).length?s[0]:s,"readonly");t.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;const i=e._dbSchema=Ir(0,t,n);e._storeNames=Mt(t.objectStoreNames,0),Tr(e,[e._allTables],dt(i),i)}(e,n,i):(Dr(e,e._dbSchema,i),function(e,t){const n=Cr(Ir(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some(e=>e.add.length||e.change.length))}(e,i)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ar(e,i)}catch(h){}var s;zi.push(e),n.onversionchange=ii(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),n.onclose=ii(t=>{e.on("close").fire(t)}),o&&function({indexedDB:e,IDBKeyRange:t},n){!Br(e)&&n!==Oi&&Or(e,t).put({name:n}).catch(dn)}(e._deps,l),i()},s)}).catch(e=>e&&"UnknownError"===e.name&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),l()):$n.reject(e));return $n.race([i,("undefined"==typeof navigator?$n.resolve():jr()).then(l)]).then(()=>(r(),t.onReadyBeingFired=[],$n.resolve(Fr(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let i=t.onReadyBeingFired.reduce(wn,dn);return t.onReadyBeingFired=[],$n.resolve(Fr(()=>i(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{a&&a.abort()}catch(r){}return i===t.openCanceller&&e._close(),Si(n)}).finally(()=>{t.openComplete=!0,s()})}function Ur(e){var t=t=>e.next(t),n=r(t),i=r(t=>e.throw(t));function r(e){return t=>{var r=e(t),s=r.value;return r.done?s:s&&"function"==typeof s.then?s.then(n,i):ft(s)?Promise.all(s).then(n,i):n(s)}}return r(t)()}function $r(e,t,n){var i=arguments.length;if(i<2)throw new cn.InvalidArgument("Too few arguments");for(var r=new Array(i-1);--i;)r[i-1]=arguments[i];return n=r.pop(),[e,Dt(r),n]}function Vr(e,t,n,i,r){return $n.resolve().then(()=>{const s=Fn.transless||Fn,a=e._createTransaction(t,n,e._dbSchema,i),o={trans:a,transless:s};if(i)a.idbtrans=i.idbtrans;else try{a.create(),e._state.PR1398_maxLoop=3}catch(u){return u.name===on.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Vr(e,t,n,null,r))):Si(u)}const l=Kt(r);let c;l&&ui();const h=$n.follow(()=>{if(c=r.call(a,a),c)if(l){var e=di.bind(null,null);c.then(e,e)}else"function"==typeof c.next&&"function"==typeof c.throw&&(c=Ur(c))},o);return(c&&"function"==typeof c.then?$n.resolve(c).then(e=>a.active?e:Si(new cn.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>c)).then(e=>(i&&a._resolve(),a._completion.then(()=>e))).catch(e=>(a._reject(e),Si(e)))})}function Wr(e,t,n){const i=ft(e)?e.slice():[e];for(let r=0;r<n;++r)i.push(t);return i}const Hr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:i}=n,r={},s=[];function a(e,t,n){const i=Mr(e),o=r[i]=r[i]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,h={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:_r(e),unique:!c&&n.unique};return o.push(h),h.isPrimaryKey||s.push(h),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),o.sort((e,t)=>e.keyTail-t.keyTail),h}const o=a(i.primaryKey.keyPath,0,i.primaryKey);r[":id"]=[o];for(const e of i.indexes)a(e.keyPath,0,e);function l(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(i=t.query.range,r=n.keyTail,{type:1===i.type?2:i.type,lower:Wr(i.lower,i.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:Wr(i.upper,i.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:t;var i,r}return{...n,schema:{...i,primaryKey:o,indexes:s,getIndexByKeyPath:function(e){const t=r[Mr(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){const{keyTail:i,isVirtual:r,keyLength:s}=t.query.index;return r?n.openCursor(l(t)).then(n=>{return n&&(r=n,Object.create(r,{continue:{value:function(n){null!=n?r.continue(Wr(n,t.reverse?e.MAX_KEY:e.MIN_KEY,i)):t.unique?r.continue(r.key.slice(0,s).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,i)):r.continue()}},continuePrimaryKey:{value(t,n){r.continuePrimaryKey(Wr(t,e.MAX_KEY,i),n)}},primaryKey:{get:()=>r.primaryKey},key:{get(){const e=r.key;return 1===s?e[0]:e.slice(0,s)}},value:{get:()=>r.value}}));var r}):n.openCursor(t)}}}}}};function Kr(e,t,n,i){return n=n||{},i=i||"",dt(e).forEach(r=>{if(yt(t,r)){var s=e[r],a=t[r];if("object"==typeof s&&"object"==typeof a&&s&&a){const e=Ut(s);e!==Ut(a)?n[i+r]=t[r]:"Object"===e?Kr(s,a,n,i+r+"."):s!==a&&(n[i+r]=t[r])}else s!==a&&(n[i+r]=t[r])}else n[i+r]=void 0}),dt(t).forEach(r=>{yt(e,r)||(n[i+r]=t[r])}),n}const Zr={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:i}=n.schema;return{...n,mutate(e){const r=Fn.trans,{deleting:s,creating:a,updating:o}=r.table(t).hook;switch(e.type){case"add":if(a.fire===dn)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===dn&&o.fire===dn)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(s.fire===dn)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(s.fire===dn)break;return r._promise("readwrite",()=>{return c((t=e).trans,t.range,1e4);var t},!0)}return n.mutate(e);function l(e){const t=Fn.trans,r=e.keys||(l=i,"delete"===(c=e).type?c.keys:c.keys||c.values.map(l.extractKey));var l,c;if(!r)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:r}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,r).then(l=>{const c=r.map((n,r)=>{const c=l[r],h={onerror:null,onsuccess:null};if("delete"===e.type)s.fire.call(h,n,c,t);else if("add"===e.type||void 0===c){const s=a.fire.call(h,n,e.values[r],t);null==n&&null!=s&&(n=s,e.keys[r]=n,i.outbound||zt(e.values[r],i.keyPath,n))}else{const i=Kr(c,e.values[r]),s=o.fire.call(h,i,n,c,t);if(s){const t=e.values[r];Object.keys(s).forEach(e=>{yt(t,e)?t[e]=s[e]:zt(t,e,s[e])})}}return h});return n.mutate(e).then(({failures:t,results:n,numFailures:i,lastResult:s})=>{for(let a=0;a<r.length;++a){const i=n?n[a]:r[a],s=c[a];null==i?s.onerror&&s.onerror(t[a]):s.onsuccess&&s.onsuccess("put"===e.type&&l[a]?e.values[a]:i)}return{failures:t,results:n,numFailures:i,lastResult:s}}).catch(e=>(c.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}function c(e,t,r){return n.query({trans:e,values:!1,query:{index:i,range:t},limit:r}).then(({result:n})=>l({type:"delete",keys:n,trans:e}).then(i=>i.numFailures>0?Promise.reject(i.failures[0]):n.length<r?{failures:[],numFailures:0,lastResult:void 0}:c(e,{...t,lower:n[n.length-1],lowerOpen:!0},r)))}}}}})};function Gr(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const i=[];for(let r=0,s=0;r<t.keys.length&&s<e.length;++r)0===Ji(t.keys[r],e[s])&&(i.push(n?Ft(t.values[r]):t.values[r]),++s);return i.length===e.length?i:null}catch(i){return null}}const Xr={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=Gr(e.keys,e.trans._cache,"clone"===e.cache);return t?$n.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?Ft(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function Yr(e){return!("from"in e)}const qr=function(e,t){if(!this){const t=new qr;return e&&"d"in e&&pt(t,e),t}pt(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function Jr(e,t,n){const i=Ji(t,n);if(isNaN(i))return;if(i>0)throw RangeError();if(Yr(e))return pt(e,{from:t,to:n,d:1});const r=e.l,s=e.r;if(Ji(n,e.from)<0)return r?Jr(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},ts(e);if(Ji(t,e.to)>0)return s?Jr(s,t,n):e.r={from:t,to:n,d:1,l:null,r:null},ts(e);Ji(t,e.from)<0&&(e.from=t,e.l=null,e.d=s?s.d+1:1),Ji(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const a=!e.r;r&&!e.l&&Qr(e,r),s&&a&&Qr(e,s)}function Qr(e,t){Yr(t)||function e(t,{from:n,to:i,l:r,r:s}){Jr(t,n,i),r&&e(t,r),s&&e(t,s)}(e,t)}function es(e){let t=Yr(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Ji(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Ji(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function ts(e){var t,n;const i=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),r=i>1?"r":i<-1?"l":"";if(r){const t="r"===r?"l":"r",n={...e},i=e[r];e.from=i.from,e.to=i.to,e[r]=i[r],n[r]=i[t],e[t]=n,n.d=ns(n)}e.d=ns(e)}function ns({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}bt(qr.prototype,{add(e){return Qr(this,e),this},addKey(e){return Jr(this,e,e),this},addKeys(e){return e.forEach(e=>Jr(this,e,e)),this},[$t](){return es(this)}});const is={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new qr(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{const r=e.table(i),{schema:s}=r,{primaryKey:a}=s,{extractKey:o,outbound:l}=a,c={...r,mutate:e=>{const a=e.trans,o=a.mutatedParts||(a.mutatedParts={}),l=e=>{const n=`idb://${t}/${i}/${e}`;return o[n]||(o[n]=new qr)},c=l(""),h=l(":dels"),{type:u}=e;let[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const p=e.trans._cache;return r.mutate(e).then(e=>{if(ft(d)){"delete"!==u&&(d=e.results),c.addKeys(d);const n=Gr(d,p);n||"add"===u||h.addKeys(d),(n||f)&&(t=l,i=n,r=f,s.indexes.forEach(function(e){const n=t(e.name||"");function s(t){return null!=t?e.extractKey(t):null}const a=t=>e.multiEntry&&ft(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(i||r).forEach((e,t)=>{const n=i&&s(i[t]),o=r&&s(r[t]);0!==Ji(n,o)&&(null!=n&&a(n),null!=o&&a(o))})}))}else if(d){const e={from:d.lower,to:d.upper};h.add(e),c.add(e)}else c.add(n),h.add(n),s.indexes.forEach(e=>l(e.name).add(n));var t,i,r;return e})}},h=({query:{index:t,range:n}})=>{var i,r;return[t,new qr(null!==(i=n.lower)&&void 0!==i?i:e.MIN_KEY,null!==(r=n.upper)&&void 0!==r?r:e.MAX_KEY)]},u={get:e=>[a,new qr(e.key)],getMany:e=>[a,(new qr).addKeys(e.keys)],count:h,query:h,openCursor:h};return dt(u).forEach(e=>{c[e]=function(s){const{subscr:a}=Fn;if(a){const c=e=>{const n=`idb://${t}/${i}/${e}`;return a[n]||(a[n]=new qr)},h=c(""),d=c(":dels"),[f,p]=u[e](s);if(c(f.name||"").add(p),!f.isPrimaryKey){if("count"!==e){const t="query"===e&&l&&s.values&&r.query({...s,values:!1});return r[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&s.values)return t.then(({result:e})=>(h.addKeys(e),n));const e=s.values?n.result.map(o):n.result;s.values?h.addKeys(e):d.addKeys(e)}else if("openCursor"===e){const e=n,t=s.values;return e&&Object.create(e,{key:{get:()=>(d.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return d.addKey(t),t}},value:{get:()=>(t&&h.addKey(e.primaryKey),e.value)}})}return n})}d.add(n)}}return r[e].apply(this,arguments)}}),c}}}};class rs{constructor(e,t){this._middlewares={},this.verno=0;const n=rs.dependencies;this._options=t={addons:rs.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:i}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const r={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:dn,dbReadyPromise:null,cancelOpen:dn,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var s,a;r.dbReadyPromise=new $n(e=>{r.dbReadyResolve=e}),r.openCanceller=new $n((e,t)=>{r.cancelOpen=t}),this._state=r,this.name=e,this.on=Vi(this,"populate","blocked","versionchange","close",{ready:[wn,dn]}),this.on.ready.subscribe=At(this.on.ready.subscribe,e=>(t,n)=>{rs.vip(()=>{const i=this._state;if(i.openComplete)i.dbOpenError||$n.resolve().then(t),n&&e(t);else if(i.onReadyBeingFired)i.onReadyBeingFired.push(t),n&&e(t);else{e(t);const i=this;n||e(function e(){i.on.ready.unsubscribe(t),i.on.ready.unsubscribe(e)})}})}),this.Collection=(s=this,Wi(tr.prototype,function(e,t){this.db=s;let n=Ni,i=null;if(t)try{n=t()}catch(l){i=l}const r=e._ctx,a=r.table,o=a.hook.reading.fire;this._ctx={table:a,index:r.index,isPrimKey:!r.index||a.schema.primKey.keyPath&&r.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:i,or:r.or,valueMapper:o!==fn?o:null}})),this.Table=(a=this,Wi($i.prototype,function(e,t,n){this.db=a,this._tx=n,this.name=e,this.schema=t,this.hook=a._allTables[e]?a._allTables[e].hook:Vi(null,{creating:[mn,dn],reading:[pn,fn],updating:[bn,dn],deleting:[yn,dn]})})),this.Transaction=function(e){return Wi(yr.prototype,function(t,n,i,r,s){this.db=e,this.mode=t,this.storeNames=n,this.schema=i,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=Vi(this,"complete","error","abort"),this.parent=s||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new $n((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),Si(e)})})}(this),this.Version=function(e){return Wi(Rr.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return Wi(ur.prototype,function(t,n,i){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:i};const r=e._deps.indexedDB;if(!r)throw new cn.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,t)=>r.cmp(t,e),this._max=(e,t)=>r.cmp(e,t)>0?e:t,this._min=(e,t)=>r.cmp(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=xr(t.IDBKeyRange),this._createTransaction=(e,t,n,i)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,i),this._fireOnBlocked=e=>{this.on("blocked").fire(e),zi.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(Hr),this.use(Zr),this.use(is),this.use(Xr),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new cn.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new cn.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(Pr),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||Fn.letThrough||this._vip)?e():new $n((e,t)=>{if(this._state.openComplete)return t(new cn.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new cn.DatabaseClosed);this.open().catch(dn)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:n,name:i}){i&&this.unuse({stack:e,name:i});const r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:t,level:null==n?10:n,name:i}),r.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return Nr(this)}_close(){const e=this._state,t=zi.indexOf(this);if(t>=0&&zi.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(n){}this._novip.idbdb=null}e.dbReadyPromise=new $n(t=>{e.dbReadyResolve=t}),e.openCanceller=new $n((t,n)=>{e.cancelOpen=n})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new cn.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new $n((n,i)=>{const r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=ii(()=>{!function({indexedDB:e,IDBKeyRange:t},n){!Br(e)&&n!==Oi&&Or(e,t).delete(n).catch(dn)}(this._deps,this.name),n()}),e.onerror=dr(i),e.onblocked=this._fireOnBlocked};if(e)throw new cn.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(r):r()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return dt(this._allTables).map(e=>this._allTables[e])}transaction(){const e=$r.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let i=Fn.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);const r=-1!==e.indexOf("?");let s,a;e=e.replace("!","").replace("?","");try{if(a=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===Bi)s=Bi;else{if("rw"!=e&&e!=Fi)throw new cn.InvalidArgument("Invalid transaction mode: "+e);s=Fi}if(i){if(i.mode===Bi&&s===Fi){if(!r)throw new cn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!r)throw new cn.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),r&&i&&!i.active&&(i=null)}}catch(l){return i?i._promise(null,(e,t)=>{t(l)}):Si(l)}const o=Vr.bind(null,this,s,a,i,n);return i?i._promise(s,o,"lock"):Fn.trans?bi(Fn.transless,()=>this._whenReady(o)):this._whenReady(o)}table(e){if(!yt(this._allTables,e))throw new cn.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const ss="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class as{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[ss](){return this}}function os(e,t){return dt(t).forEach(n=>{Qr(e[n]||(e[n]=new qr),t[n])}),e}let ls;try{ls={indexedDB:ut.indexedDB||ut.mozIndexedDB||ut.webkitIndexedDB||ut.msIndexedDB,IDBKeyRange:ut.IDBKeyRange||ut.webkitIDBKeyRange}}catch(Yc){ls={indexedDB:null,IDBKeyRange:null}}const cs=rs;function hs(e){let t=us;try{us=!0,mr.storagemutated.fire(e)}finally{us=t}}bt(cs,{...un,delete:e=>new cs(e,{addons:[]}).delete(),exists:e=>new cs(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return Br(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==Oi)):Or(e,t).toCollection().primaryKeys()}(cs.dependencies).then(e)}catch(t){return Si(new cn.MissingAPI)}},defineClass:()=>function(e){pt(this,e)},ignoreTransaction:e=>Fn.trans?bi(Fn.transless,e):e(),vip:Fr,async:function(e){return function(){try{var t=Ur(e.apply(this,arguments));return t&&"function"==typeof t.then?t:$n.resolve(t)}catch(n){return Si(n)}}},spawn:function(e,t,n){try{var i=Ur(e.apply(n,t||[]));return i&&"function"==typeof i.then?i:$n.resolve(i)}catch(r){return Si(r)}},currentTransaction:{get:()=>Fn.trans||null},waitFor:function(e,t){const n=$n.resolve("function"==typeof e?cs.ignoreTransaction(e):e).timeout(t||6e4);return Fn.trans?Fn.trans.waitFor(n):n},Promise:$n,debug:{get:()=>Zt,set:e=>{Gt(e,"dexie"===e?()=>!0:Ri)}},derive:xt,extend:pt,props:bt,override:At,Events:Vi,on:mr,liveQuery:function(e){let t,n=!1;const i=new as(i=>{const r=Kt(e);let s=!1,a={},o={};const l={get closed(){return s},unsubscribe:()=>{s=!0,mr.storagemutated.unsubscribe(d)}};i.start&&i.start(l);let c=!1,h=!1;function u(){return dt(o).some(e=>a[e]&&function(e,t){const n=es(t);let i=n.next();if(i.done)return!1;let r=i.value;const s=es(e);let a=s.next(r.from),o=a.value;for(;!i.done&&!a.done;){if(Ji(o.from,r.to)<=0&&Ji(o.to,r.from)>=0)return!0;Ji(r.from,o.from)<0?r=(i=n.next(o.from)).value:o=(a=s.next(r.from)).value}return!1}(a[e],o[e]))}const d=e=>{os(a,e),u()&&f()},f=()=>{if(c||s)return;a={};const p={},g=function(t){r&&ui();const n=()=>hi(e,{subscr:t,trans:null}),i=Fn.trans?bi(Fn.transless,n):n();return r&&i.then(di,di),i}(p);h||(mr(pr,d),h=!0),c=!0,Promise.resolve(g).then(e=>{n=!0,t=e,c=!1,s||(u()?f():(a={},o=p,i.next&&i.next(e)))},e=>{c=!1,n=!1,i.error&&i.error(e),l.unsubscribe()})};return f(),l});return i.hasValue=()=>n,i.getValue=()=>t,i},extendObservabilitySet:os,getByKeyPath:Ct,setByKeyPath:zt,delByKeyPath:function(e,t){"string"==typeof t?zt(e,t,void 0):"length"in t&&[].map.call(t,function(t){zt(e,t,void 0)})},shallowClone:Lt,deepClone:Ft,getObjectDiff:Kr,cmp:Ji,asap:Et,minKey:Ei,addons:[],connections:zi,errnames:on,dependencies:ls,semVer:Ai,version:Ai.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),cs.maxKey=xr(cs.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(mr(pr,e=>{if(!us){let t;Li?(t=document.createEvent("CustomEvent"),t.initCustomEvent(gr,!0,!0,e)):t=new CustomEvent(gr,{detail:e}),us=!0,dispatchEvent(t),us=!1}}),addEventListener(gr,({detail:e})=>{us||hs(e)}));let us=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel(gr);"function"==typeof e.unref&&e.unref(),mr(pr,t=>{us||e.postMessage(t)}),e.onmessage=e=>{e.data&&hs(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){mr(pr,e=>{try{us||("undefined"!=typeof localStorage&&localStorage.setItem(gr,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:gr,changedParts:e})))}catch(t){}}),"undefined"!=typeof addEventListener&&addEventListener("storage",e=>{if(e.key===gr){const t=JSON.parse(e.newValue);t&&hs(t.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===gr&&hs(e.changedParts)})}$n.rejectionMapper=function(e,t){if(!e||e instanceof nn||e instanceof TypeError||e instanceof SyntaxError||!e.name||!hn[e.name])return e;var n=new hn[e.name](t||e.message,e);return"stack"in e&&wt(n,"stack",{get:function(){return this.inner.stack}}),n},Gt(Zt,Ri);class ds{constructor(){i(this,"dbGet",async(e,t)=>await this.db[e].get(t)),i(this,"dbAdd",async(e,t)=>await this.db[e].add({...t})),i(this,"dbUpdate",async(e,t,n)=>await this.db[e].update(t,{...n})),i(this,"dbRemove",async(e,t)=>await this.db[e].delete(t)),this.db=new rs("hyperspace"),this.db.version(1).stores({tileset:"++id, name, creator, type, checksum, signature, timestamp",inventory:"++id, name, creator, type, checksum, signature, timestamp",spirits:"++id, name, creator, type, checksum, signature, timestamp",abilities:"++id, name, creator, type checksum, signature, timestamp",models:"++id, name, creator, type, checksum, signature, timestamp",accounts:"++id, name, type, checksum, signature, timestamp",dht:"++id, name, type, ip, checksum, signature, timestamp",msg:"++id, name, type, ip, checksum, signature, timestamp",tmp:"++id, key, value, timestamp"})}}class fs{constructor(){return i(this,"all",()=>Object.assign({},this.store)),i(this,"keys",()=>Object.keys(this.store)),i(this,"values",()=>Object.keys(this.store).map(e=>this.store[e])),i(this,"size",()=>Object.keys(this.store).length),i(this,"get",e=>{if(!this.store[e])throw"no key set";return this.store[e]}),i(this,"add",(e,t)=>{if(this.store[e])throw"key already exists";return this.store[e]={...t}}),i(this,"set",(e,t)=>this.store[e]={...t}),i(this,"delete",e=>this.store[e]=null),fs._instance||(this.store={},fs._instance=this),fs._instance}}const ps=new FontFace("minecraftia","url(/pixospritz/font/minecraftia.ttf)");class gs{constructor(e){return i(this,"init",()=>{this.ctx=this.engine.ctx}),i(this,"drawButton",(e,t,n,i,r,s)=>{const{ctx:a}=this;this.applyStyle({font:"20px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:s.background,globalAlpha:1}),a.fillStyle=s.background,a.beginPath(),a.rect(t,n,i,r),a.fill();var o=a.createLinearGradient(t,n,t,n+r/2);o.addColorStop(0,"rgba(255, 255, 255, 0.8)"),o.addColorStop(1,"rgba(0, 0, 0, 0.3)"),a.fillStyle=o,a.globalAlpha=.7,a.fillRect(t,n,i,r/2),a.fillStyle=s.text,a.fillText(e,t+i/2,n+r/2),a.beginPath(),a.strokeStyle="#fff",a.rect(t,n,i,r),a.stroke()}),i(this,"clearHud",()=>{this.ctx.clearRect(0,0,this.engine.ctx.canvas.width,this.engine.ctx.canvas.height)}),i(this,"handleResize",(e,t)=>{this.ctx=this.engine.ctx}),i(this,"setBackdrop",e=>{this.backdropImage=e}),i(this,"setCutouts",e=>{this.cutoutImages=e}),i(this,"applyStyle",e=>{Object.assign(this.ctx,{font:"20px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:"#ffffff",globalAlpha:1},e)}),i(this,"writeText",(e,t,n,i=null)=>{this.applyStyle({font:"24px invasion2000",textAlign:"center",textBaseline:"middle",fillStyle:"#ffffff"}),i?(this.ctx.drawImage(i,t??this.ctx.canvas.clientWidth/2,n??this.ctx.canvas.clientHeight/2,76,76),this.ctx.fillText(e,t??this.ctx.canvas.clientWidth/2+80,n??this.ctx.canvas.clientHeight/2)):this.ctx.fillText(e,t??this.ctx.canvas.clientWidth/2,n??this.ctx.canvas.clientHeight/2)}),i(this,"drawModeLabel",()=>{var e,t,n,i;try{const r=null==(i=null==(n=null==(t=null==(e=this.engine)?void 0:e.spritz)?void 0:t.world)?void 0:n.modeManager)?void 0:i.getMode();if(!r)return;this.applyStyle({font:"18px invasion2000",textAlign:"left",textBaseline:"top",fillStyle:"#ff0"}),this.ctx.fillText(`MODE: ${r}`,12,12)}catch(Yc){}}),i(this,"drawHeightDebugOverlay",()=>{var e,t,n,i,r;if(null==(e=this.engine)?void 0:e.debugHeightOverlay)try{const e=null==(n=null==(t=this.engine)?void 0:t.spritz)?void 0:n.world;if(!e)return;const{ctx:s}=this,a=null==(r=null==(i=this.engine)?void 0:i.renderManager)?void 0:r.camera;if(!a)return;const o=(e,t,n)=>{const i=this.engine.gl,r=this.engine.renderManager,s=r.uModelMat,o=a.uViewMat,l=r.uProjMat,c=[e,t,n,1];let h=s[0]*c[0]+s[4]*c[1]+s[8]*c[2]+s[12],u=s[1]*c[0]+s[5]*c[1]+s[9]*c[2]+s[13],d=s[2]*c[0]+s[6]*c[1]+s[10]*c[2]+s[14],f=s[3]*c[0]+s[7]*c[1]+s[11]*c[2]+s[15];const p=o[0]*h+o[4]*u+o[8]*d+o[12]*f,g=o[1]*h+o[5]*u+o[9]*d+o[13]*f,m=o[2]*h+o[6]*u+o[10]*d+o[14]*f,y=o[3]*h+o[7]*u+o[11]*d+o[15]*f,b=l[0]*p+l[4]*g+l[8]*m+l[12]*y,v=l[1]*p+l[5]*g+l[9]*m+l[13]*y,w=l[3]*p+l[7]*g+l[11]*m+l[15]*y;if(Math.abs(w)<1e-4)return null;const x=v/w;return{x:(.5*(b/w)+.5)*i.canvas.width,y:(1-(.5*x+.5))*i.canvas.height,behind:w<0}};this.applyStyle({font:"12px monospace",textAlign:"center",textBaseline:"middle",fillStyle:"#0f0"}),e.zoneList.forEach(e=>{var t;if(!e.loaded||!(null==(t=e.zoneData)?void 0:t.cells))return;const n=e.zoneData.cells;for(let i=0;i<n.length;i++)for(let t=0;t<n[i].length;t++)try{const n=e.getHeight(t+.5,i+.5),r=o(t+.5,i+.5,n);r&&!r.behind&&(s.fillStyle="#0ff",s.fillText(`${n.toFixed(2)}`,r.x,r.y))}catch(Yc){}}),this.applyStyle({font:"14px monospace",textAlign:"center",textBaseline:"bottom",fillStyle:"#ff0"}),e.spriteList.forEach(e=>{if(e.pos)try{const t=o(e.pos.x,e.pos.y,e.pos.z+.5);t&&!t.behind&&(s.fillStyle="#ff0",s.fillText(`${e.id}: z=${e.pos.z.toFixed(2)}`,t.x,t.y))}catch(Yc){}}),this.applyStyle({font:"14px monospace",textAlign:"center",textBaseline:"bottom",fillStyle:"#f0f"}),e.objectList.forEach(e=>{if(e.pos)try{const t=o(e.pos.x,e.pos.y,e.pos.z+.5);t&&!t.behind&&(s.fillStyle="#f0f",s.fillText(`${e.id}: z=${e.pos.z.toFixed(2)}`,t.x,t.y))}catch(Yc){}})}catch(Yc){console.warn("drawHeightDebugOverlay error:",Yc)}}),i(this,"drawCutsceneElements",()=>{const{ctx:e}=this,t=e.canvas.width,n=e.canvas.height;this.backdropImage&&e.drawImage(this.backdropImage,0,0,t,n),this.cutoutImages.forEach(({image:i,position:r})=>{if(i){const s="left"===r?50:t-250,a=n/2-100,o=200,l=200;"right"===r?(e.save(),e.scale(-1,1),e.drawImage(i,-s-o,a,o,l),e.restore()):e.drawImage(i,s,a,o,l)}})}),i(this,"scrollText",(e,t=!1,n={})=>{this.drawCutsceneElements();const i=e+JSON.stringify(n);this._cachedTextbox&&this._cachedTextboxKey===i||(this._cachedTextbox=new ms(this.engine.ctx),this._cachedTextbox.init(e,10,2*this.engine.ctx.canvas.height/3,this.engine.ctx.canvas.width-20,this.engine.ctx.canvas.height/3-20,n),this._cachedTextbox.setOptions(n),this._cachedTextboxKey=i);let r=this._cachedTextbox;return t&&r.scroll((Math.sin((new Date).getTime()/3e3)+1)*r.maxScroll*.5),r.render(),r}),i(this,"clearTextboxCache",()=>{this._cachedTextbox=null,this._cachedTextboxKey=null}),gs._instance||(this.engine=e,this.backdropImage=null,this.cutoutImages=[],gs._instance=this),gs._instance}}class ms{constructor(e){i(this,"init",(e,t,n,i,r,s={})=>{this.text=e||"",this.x=t,this.y=n,this.width=i,this.height=r,this.portrait=s.portrait??null,this.speaker=s.speaker??null,this.typewriterStartTime=Date.now(),this.typewriterIndex=0,this.typewriterComplete=!1,this.totalChars=0,this.lines=[],this.dirty=!0,this.setOptions(s),this.cleanit()}),i(this,"cleanit",e=>{this.dirty&&(this.setFont(),this.getTextPos(),this.dirty=!1,e||this.fitText())}),i(this,"setOptions",e=>{Object.keys(this).forEach(t=>{void 0!==e[t]&&(this[t]=e[t],this.dirty=!0)})}),i(this,"setFont",()=>{this.fontStr=this.fontSize+"px "+this.font,this.textHeight=this.fontSize+Math.ceil(.25*this.fontSize)}),i(this,"getTextPos",()=>{"left"===this.align?this.textPos=8:"right"===this.align?this.textPos=Math.floor(this.width-this.scrollBox.width-this.fontSize/4):this.textPos=Math.floor((this.width- -this.scrollBox.width)/2)}),i(this,"fitText",()=>{let{ctx:e}=this;this.cleanit(!0),e.font=this.fontStr,e.textAlign=this.align,e.textBaseline="top";let t=this.text.split(" ");this.lines.length=0;let n="",i="";const r=this.width-this.scrollBox.width-16-(this.portrait?84:0);for(;t.length>0;){let s=t.shift();e.measureText(n+i+s).width<r?(n+=i+s,i=" "):(""===i?n+=s:t.unshift(s),this.lines.push(n),i="",n="")}""!==n&&this.lines.push(n),this.maxScroll=(this.lines.length+.5)*this.textHeight-this.height,this.totalChars=this.lines.reduce((e,t)=>e+t.length,0)}),i(this,"drawBorder",(e=!1)=>{let{ctx:t}=this,n=this.border.lineWidth/2;t.lineJoin=this.border.corner,t.lineWidth=this.border.lineWidth;const i=e?this.x+84:this.x,r=e?this.width-84:this.width;if(this.border.glow){const e=.003*Date.now();t.shadowColor=this.border.style,t.shadowBlur=10+3*Math.sin(2*e),t.shadowOffsetX=0,t.shadowOffsetY=0}t.strokeStyle=this.border.style,t.strokeRect(i-n,this.y-n,r+2*n,this.height+2*n),t.shadowBlur=0}),i(this,"drawScrollBox",()=>{let{ctx:e}=this,t=this.height/(this.lines.length*this.textHeight);e.fillStyle=this.scrollBox.background,e.fillRect(this.x+this.width-this.scrollBox.width,this.y,this.scrollBox.width,this.height),e.fillStyle=this.scrollBox.color;let n=this.height*t;n>this.height&&(n=this.height);const i=this.y-this.scrollY*t,r=this.x+this.width-this.scrollBox.width;e.beginPath(),e.roundRect(r,i,this.scrollBox.width,n,3),e.fill()}),i(this,"drawPortrait",()=>{let{ctx:e}=this;e.strokeStyle=this.border.style,e.lineWidth=2,e.strokeRect(this.x-2,this.y+36,80,80),e.drawImage(this.portrait.image,this.x,this.y+38,76,76)}),i(this,"drawSpeakerName",()=>{if(!this.speaker)return;let{ctx:e}=this;e.save();const t=this.portrait?this.x+90:this.x+10,n=this.y-28;e.font="bold 18px "+this.font;const i=e.measureText(this.speaker).width+20;e.fillStyle="rgba(20, 30, 50, 0.95)",e.beginPath(),e.roundRect(t-10,n-6,i,26,6),e.fill(),e.strokeStyle=this.speakerColor,e.lineWidth=2,e.stroke(),e.fillStyle=this.speakerColor,e.textAlign="left",e.textBaseline="top",e.fillText(this.speaker,t,n),e.restore()}),i(this,"scroll",e=>{this.cleanit(),this.scrollY=-e,this.scrollY>0?this.scrollY=0:this.scrollY<-this.maxScroll&&(this.scrollY=-this.maxScroll)}),i(this,"scrollLines",e=>{this.cleanit(),this.scrollY=-this.textHeight*e,this.scrollY>0?this.scrollY=0:this.scrollY<-this.maxScroll&&(this.scrollY=-this.maxScroll)}),i(this,"skipTypewriter",()=>{this.typewriterComplete=!0,this.typewriterIndex=this.totalChars||0}),i(this,"isTypewriterComplete",()=>this.typewriterComplete||!this.typewriterEnabled),i(this,"render",()=>{let{ctx:e}=this;if(this.cleanit(),e.font=this.fontStr,e.textAlign=this.align,e.textBaseline="top",this.speaker&&this.drawSpeakerName(),this.portrait?(this.drawBorder(!0),this.drawPortrait(),e.save(),e.fillStyle=this.background,e.fillRect(this.x+84,this.y,this.width-84,this.height)):(this.drawBorder(),e.save(),e.fillStyle=this.background,e.fillRect(this.x,this.y,this.width,this.height)),this.drawScrollBox(),this.portrait?(e.beginPath(),e.rect(this.x+84,this.y,this.width-this.scrollBox.width-84,this.height),e.clip(),e.setTransform(1,0,0,1,this.x+84,Math.floor(this.y+this.scrollY))):(e.beginPath(),e.rect(this.x,this.y,this.width-this.scrollBox.width,this.height),e.clip(),e.setTransform(1,0,0,1,this.x,Math.floor(this.y+this.scrollY))),e.fillStyle=this.fontStyle,this.typewriterEnabled&&!this.typewriterComplete){const t=Date.now()-this.typewriterStartTime,n=Math.floor(t/this.typewriterSpeed);n>=this.totalChars&&(this.typewriterComplete=!0);let i=0;for(let r=0;r<this.lines.length;r++){const t=this.lines[r],s=i,a=i+t.length;if(n<=s)break;if(n>=a)e.fillText(t,this.textPos,Math.floor(r*this.textHeight)+2);else{const i=n-s,a=t.substring(0,i);e.fillText(a,this.textPos,Math.floor(r*this.textHeight)+2);const o=this.textPos+e.measureText(a).width,l=Math.floor(r*this.textHeight)+2;e.fillStyle=this.speakerColor||"#7dd3fc",e.fillRect(o+2,l,2,this.fontSize),e.fillStyle=this.fontStyle}i=a+1}}else for(let t=0;t<this.lines.length;t++)e.fillText(this.lines[t],this.textPos,Math.floor(t*this.textHeight)+2);e.restore()}),this.ctx=e,this.dirty=!0,this.scrollY=0,this.fontSize=24,this.font="minecraftia",this.align="left",this.background="rgba(20, 30, 50, 0.92)",this.border={lineWidth:3,style:"#7dd3fc",corner:"round",glow:!0},this.scrollBox={width:6,background:"rgba(100, 150, 200, 0.3)",color:"#7dd3fc"},this.fontStyle="#ffffff",this.lines=[],this.x=0,this.y=0,this.typewriterEnabled=!0,this.typewriterSpeed=30,this.typewriterIndex=0,this.typewriterStartTime=0,this.typewriterComplete=!1,this.totalChars=0,this.speaker=null,this.speakerColor="#7dd3fc",this.animationTime=0}}const ys=1e-6,bs=()=>{let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},vs=()=>{let e=new Float32Array(9);return e[0]=1,e[4]=1,e[8]=1,e},ws=(e,t,n,i)=>{let r=new Float32Array(16),s=1/Math.tan(e/2);if(r[0]=s/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=s,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=-1,r[11]=-1,r[12]=0,r[13]=0,r[14]=-2*n,r[15]=0,i!==1/0&&i!==n){const e=1/(n-i);r[10]=(i+n)*e,r[14]=2*i*n*e}return r},xs=(e,t,n)=>{let i=e,[r,s,a]=n,[o,l,c,h,u,d,f,p,g,m,y,b]=t;return e!==t&&(i[0]=o,i[1]=l,i[2]=c,i[3]=h,i[4]=u,i[5]=d,i[6]=f,i[7]=p,i[8]=g,i[9]=m,i[10]=y,i[11]=b),i[12]=o*r+u*s+g*a+t[12],i[13]=l*r+d*s+m*a+t[13],i[14]=c*r+f*s+y*a+t[14],i[15]=h*r+p*s+b*a+t[15],i},_s=(e,t,n,i)=>{let r=e,[s,a,o]=i,l=Math.hypot(s,a,o);if(l<ys)throw new Error("Matrix4*4 rotate has wrong axis");l=1/l,s*=l,a*=l,o*=l;let c=Math.sin(n),h=Math.cos(n),u=1-h,[d,f,p,g,m,y,b,v,w,x,_,k]=t,S=s*s*u+h,M=a*s*u+o*c,A=o*s*u-a*c,T=s*a*u-o*c,E=a*a*u+h,P=o*a*u+s*c,C=s*o*u+a*c,z=a*o*u-s*c,L=o*o*u+h;return r[0]=d*S+m*M+w*A,r[1]=f*S+y*M+x*A,r[2]=p*S+b*M+_*A,r[3]=g*S+v*M+k*A,r[4]=d*T+m*E+w*P,r[5]=f*T+y*E+x*P,r[6]=p*T+b*E+_*P,r[7]=g*T+v*E+k*P,r[8]=d*C+m*z+w*L,r[9]=f*C+y*z+x*L,r[10]=p*C+b*z+_*L,r[11]=g*C+v*z+k*L,t!==e&&(r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r};function ks(e,t){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}var Ss,Ms;(Ms=Ss||(Ss={})).BYTE="BYTE",Ms.UNSIGNED_BYTE="UNSIGNED_BYTE",Ms.SHORT="SHORT",Ms.UNSIGNED_SHORT="UNSIGNED_SHORT",Ms.FLOAT="FLOAT";class As extends Error{constructor(e){super(`found duplicate attribute: ${e.key}`)}}class Ts{constructor(e,t,n,i=!1){switch(this.key=e,this.size=t,this.type=n,this.normalized=i,n){case"BYTE":case"UNSIGNED_BYTE":this.sizeOfType=1;break;case"SHORT":case"UNSIGNED_SHORT":this.sizeOfType=2;break;case"FLOAT":this.sizeOfType=4;break;default:throw new Error(`Unknown gl type: ${n}`)}this.sizeInBytes=this.sizeOfType*t}}class Es{constructor(...e){this.attributes=e,this.attributeMap={};let t=0,n=0;for(const i of e){if(this.attributeMap[i.key])throw new As(i);t%i.sizeOfType!==0&&(t+=i.sizeOfType-t%i.sizeOfType,console.warn("Layout requires padding before "+i.key+" attribute")),this.attributeMap[i.key]={attribute:i,size:i.size,type:i.type,normalized:i.normalized,offset:t},t+=i.sizeInBytes,n=Math.max(n,i.sizeOfType)}t%n!==0&&(t+=n-t%n,console.warn("Layout requires padding at the back")),this.stride=t;for(const i of e)this.attributeMap[i.key].stride=this.stride}}Es.POSITION=new Ts("position",3,Ss.FLOAT),Es.NORMAL=new Ts("normal",3,Ss.FLOAT),Es.TANGENT=new Ts("tangent",3,Ss.FLOAT),Es.BITANGENT=new Ts("bitangent",3,Ss.FLOAT),Es.UV=new Ts("uv",2,Ss.FLOAT),Es.MATERIAL_INDEX=new Ts("materialIndex",1,Ss.SHORT),Es.MATERIAL_ENABLED=new Ts("materialEnabled",1,Ss.UNSIGNED_SHORT),Es.AMBIENT=new Ts("ambient",3,Ss.FLOAT),Es.DIFFUSE=new Ts("diffuse",3,Ss.FLOAT),Es.SPECULAR=new Ts("specular",3,Ss.FLOAT),Es.SPECULAR_EXPONENT=new Ts("specularExponent",3,Ss.FLOAT),Es.EMISSIVE=new Ts("emissive",3,Ss.FLOAT),Es.TRANSMISSION_FILTER=new Ts("transmissionFilter",3,Ss.FLOAT),Es.DISSOLVE=new Ts("dissolve",1,Ss.FLOAT),Es.ILLUMINATION=new Ts("illumination",1,Ss.UNSIGNED_SHORT),Es.REFRACTION_INDEX=new Ts("refractionIndex",1,Ss.FLOAT),Es.SHARPNESS=new Ts("sharpness",1,Ss.FLOAT),Es.MAP_DIFFUSE=new Ts("mapDiffuse",1,Ss.SHORT),Es.MAP_AMBIENT=new Ts("mapAmbient",1,Ss.SHORT),Es.MAP_SPECULAR=new Ts("mapSpecular",1,Ss.SHORT),Es.MAP_SPECULAR_EXPONENT=new Ts("mapSpecularExponent",1,Ss.SHORT),Es.MAP_DISSOLVE=new Ts("mapDissolve",1,Ss.SHORT),Es.ANTI_ALIASING=new Ts("antiAliasing",1,Ss.UNSIGNED_SHORT),Es.MAP_BUMP=new Ts("mapBump",1,Ss.SHORT),Es.MAP_DISPLACEMENT=new Ts("mapDisplacement",1,Ss.SHORT),Es.MAP_DECAL=new Ts("mapDecal",1,Ss.SHORT),Es.MAP_EMISSIVE=new Ts("mapEmissive",1,Ss.SHORT);class Ps{constructor(e,t){this.name="",this.indicesPerMaterial=[],this.materialsByIndex={},this.tangents=[],this.bitangents=[],(t=t||{}).materials=t.materials||{},t.enableWTextureCoord=!!t.enableWTextureCoord,this.vertexNormals=[],this.textures=[],this.indices=[],this.textureStride=t.enableWTextureCoord?3:2;const n=[],i=[],r=[],s=[],a={};let o=-1,l=0;const c={verts:[],norms:[],textures:[],hashindices:{},indices:[[]],materialIndices:[],index:0},h=/^v\s/,u=/^vn\s/,d=/^vt\s/,f=/^f\s/,p=/\s+/,g=/^usemtl/,m=e.split("\n");for(let y of m){if(y=y.trim(),!y||y.startsWith("#"))continue;const e=y.split(p);if(e.shift(),h.test(y))n.push(...e);else if(u.test(y))i.push(...e);else if(d.test(y)){const n=parseFloat(e[0]),i=e.length>1?1-parseFloat(e[1]):0;if(t.enableWTextureCoord){const t=e.length>2?parseFloat(e[2]):0;r.push(n.toString(),i.toString(),t.toString())}else r.push(n.toString(),i.toString())}else if(g.test(y)){const t=e[0];t in a||(s.push(t),a[t]=s.length-1,a[t]>0&&c.indices.push([])),o=a[t],l=o}else if(f.test(y)){const s=Cs(e);for(const e of s)for(let s=0,a=e.length;s<a;s++){const a=e[s]+","+o;if(a in c.hashindices)c.indices[l].push(c.hashindices[a]);else{const h=e[s].split("/"),u=h.length-1;if(c.verts.push(+n[3*(+h[0]-1)+0]),c.verts.push(+n[3*(+h[0]-1)+1]),c.verts.push(+n[3*(+h[0]-1)+2]),r.length&&h[1]&&""!==h[1]){const e=t.enableWTextureCoord?3:2,n=+h[1]-1;if(n>=0&&n<r.length/e){const i=Math.max(0,Math.min(1,+r[n*e+0])),s=Math.max(0,Math.min(1,+r[n*e+1]));c.textures.push(i),c.textures.push(s),t.enableWTextureCoord&&c.textures.push(+r[n*e+2])}else c.textures.push(0),c.textures.push(0),t.enableWTextureCoord&&c.textures.push(0)}else r.length&&(c.textures.push(0),c.textures.push(0),t.enableWTextureCoord&&c.textures.push(0));c.norms.push(+i[3*(+h[u]-1)+0]),c.norms.push(+i[3*(+h[u]-1)+1]),c.norms.push(+i[3*(+h[u]-1)+2]),c.materialIndices.push(o),c.hashindices[a]=c.index,c.indices[l].push(c.hashindices[a]),c.index+=1}}}}this.vertices=c.verts,this.vertexNormals=c.norms,this.textures=c.textures,this.vertexMaterialIndices=c.materialIndices,this.indices=c.indices[l],this.indicesPerMaterial=c.indices,this.materialNames=s,this.materialIndices=a,this.materialsByIndex={},t.calcTangentsAndBitangents&&this.calculateTangentsAndBitangents()}calculateTangentsAndBitangents(){console.assert(!!(this.vertices&&this.vertices.length&&this.vertexNormals&&this.vertexNormals.length&&this.textures&&this.textures.length),"Missing attributes for calculating tangents and bitangents");const e={tangents:[...new Array(this.vertices.length)].map(e=>0),bitangents:[...new Array(this.vertices.length)].map(e=>0)},t=this.indices,n=this.vertices,i=this.vertexNormals,r=this.textures;for(let s=0;s<t.length;s+=3){const a=t[s+0],o=t[s+1],l=t[s+2],c=n[3*a+0],h=n[3*a+1],u=n[3*a+2],d=r[2*a+0],f=r[2*a+1],p=n[3*o+0],g=n[3*o+1],m=n[3*o+2],y=r[2*o+0],b=r[2*o+1],v=p-c,w=g-h,x=m-u,_=n[3*l+0]-c,k=n[3*l+1]-h,S=n[3*l+2]-u,M=y-d,A=b-f,T=r[2*l+0]-d,E=r[2*l+1]-f,P=M*E-A*T,C=1/Math.abs(P<1e-4?1:P),z=(v*E-_*A)*C,L=(w*E-k*A)*C,I=(x*E-S*A)*C,D=(_*M-v*T)*C,R=(k*M-w*T)*C,O=(S*M-x*T)*C,B=i[3*a+0],F=i[3*a+1],j=i[3*a+2],N=i[3*o+0],U=i[3*o+1],$=i[3*o+2],V=i[3*l+0],W=i[3*l+1],H=i[3*l+2],K=z*B+L*F+I*j,Z=z*N+L*U+I*$,G=z*V+L*W+I*H,X=z-B*K,Y=L-F*K,q=I-j*K,J=z-N*Z,Q=L-U*Z,ee=I-$*Z,te=z-V*G,ne=L-W*G,ie=I-H*G,re=Math.sqrt(X*X+Y*Y+q*q),se=Math.sqrt(J*J+Q*Q+ee*ee),ae=Math.sqrt(te*te+ne*ne+ie*ie),oe=D*B+R*F+O*j,le=D*N+R*U+O*$,ce=D*V+R*W+O*H,he=D-B*oe,ue=R-F*oe,de=O-j*oe,fe=D-N*le,pe=R-U*le,ge=O-$*le,me=D-V*ce,ye=R-W*ce,be=O-H*ce,ve=Math.sqrt(he*he+ue*ue+de*de),we=Math.sqrt(fe*fe+pe*pe+ge*ge),xe=Math.sqrt(me*me+ye*ye+be*be);e.tangents[3*a+0]+=X/re,e.tangents[3*a+1]+=Y/re,e.tangents[3*a+2]+=q/re,e.tangents[3*o+0]+=J/se,e.tangents[3*o+1]+=Q/se,e.tangents[3*o+2]+=ee/se,e.tangents[3*l+0]+=te/ae,e.tangents[3*l+1]+=ne/ae,e.tangents[3*l+2]+=ie/ae,e.bitangents[3*a+0]+=he/ve,e.bitangents[3*a+1]+=ue/ve,e.bitangents[3*a+2]+=de/ve,e.bitangents[3*o+0]+=fe/we,e.bitangents[3*o+1]+=pe/we,e.bitangents[3*o+2]+=ge/we,e.bitangents[3*l+0]+=me/xe,e.bitangents[3*l+1]+=ye/xe,e.bitangents[3*l+2]+=be/xe}this.tangents=e.tangents,this.bitangents=e.bitangents}makeBufferData(e){const t=this.vertices.length/3,n=new ArrayBuffer(e.stride*t);n.numItems=t;const i=new DataView(n);for(let r=0,s=0;r<t;r++){s=r*e.stride;for(const t of e.attributes){const n=s+e.attributeMap[t.key].offset;switch(t.key){case Es.POSITION.key:i.setFloat32(n,this.vertices[3*r],!0),i.setFloat32(n+4,this.vertices[3*r+1],!0),i.setFloat32(n+8,this.vertices[3*r+2],!0);break;case Es.UV.key:i.setFloat32(n,this.textures[2*r],!0),i.setFloat32(n+4,this.textures[2*r+1],!0);break;case Es.NORMAL.key:i.setFloat32(n,this.vertexNormals[3*r],!0),i.setFloat32(n+4,this.vertexNormals[3*r+1],!0),i.setFloat32(n+8,this.vertexNormals[3*r+2],!0);break;case Es.MATERIAL_INDEX.key:i.setInt16(n,this.vertexMaterialIndices[r],!0);break;case Es.AMBIENT.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.ambient[0],!0),i.setFloat32(n+4,t.ambient[1],!0),i.setFloat32(n+8,t.ambient[2],!0);break}case Es.DIFFUSE.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.diffuse[0],!0),i.setFloat32(n+4,t.diffuse[1],!0),i.setFloat32(n+8,t.diffuse[2],!0);break}case Es.SPECULAR.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.specular[0],!0),i.setFloat32(n+4,t.specular[1],!0),i.setFloat32(n+8,t.specular[2],!0);break}case Es.SPECULAR_EXPONENT.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.specularExponent,!0);break}case Es.EMISSIVE.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.emissive[0],!0),i.setFloat32(n+4,t.emissive[1],!0),i.setFloat32(n+8,t.emissive[2],!0);break}case Es.TRANSMISSION_FILTER.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.transmissionFilter[0],!0),i.setFloat32(n+4,t.transmissionFilter[1],!0),i.setFloat32(n+8,t.transmissionFilter[2],!0);break}case Es.DISSOLVE.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.dissolve,!0);break}case Es.ILLUMINATION.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setInt16(n,t.illumination,!0);break}case Es.REFRACTION_INDEX.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.refractionIndex,!0);break}case Es.SHARPNESS.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setFloat32(n,t.sharpness,!0);break}case Es.ANTI_ALIASING.key:{const e=this.vertexMaterialIndices[r],t=this.materialsByIndex[e];if(!t){console.warn('Material "'+this.materialNames[e]+'" not found in mesh. Did you forget to call addMaterialLibrary(...)?"');break}i.setInt16(n,t.antiAliasing?1:0,!0);break}}}}return n}makeIndexBufferData(){const e=new Uint16Array(this.indices);return e.numItems=this.indices.length,e}makeIndexBufferDataForMaterials(...e){const t=(new Array).concat(...e.map(e=>this.indicesPerMaterial[e])),n=new Uint16Array(t);return n.numItems=t.length,n}addMaterialLibrary(e){for(const t in e.materials){if(!(t in this.materialIndices))continue;const n=e.materials[t],i=this.materialIndices[n.name];this.materialsByIndex[i]=n}}}function*Cs(e){if(e.length<=3)yield e;else if(4===e.length)yield[e[0],e[1],e[2]],yield[e[2],e[3],e[0]];else for(let t=1;t<e.length-1;t++)yield[e[0],e[t],e[t+1]]}class zs{constructor(e){this.name=e,this.ambient=[0,0,0],this.diffuse=[0,0,0],this.specular=[0,0,0],this.emissive=[0,0,0],this.transmissionFilter=[0,0,0],this.dissolve=0,this.specularExponent=0,this.transparency=0,this.illumination=0,this.refractionIndex=1,this.sharpness=0,this.mapDiffuse={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapAmbient={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapSpecular={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapSpecularExponent={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDissolve={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.antiAliasing=!1,this.mapBump={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDisplacement={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapDecal={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapEmissive={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""},this.mapReflections=[]}}const Ls=new zs("sentinel");class Is{constructor(e){this.data=e,this.currentMaterial=Ls,this.materials={},this.parse()}parse_newmtl(e){const t=e[0];this.currentMaterial=new zs(t),this.materials[t]=this.currentMaterial}parseColor(e){if("spectral"==e[0])throw new Error("The MTL parser does not support spectral curve files. You will need to convert the MTL colors to either RGB or CIEXYZ.");if("xyz"==e[0])throw new Error("The MTL parser does not currently support XYZ colors. Either convert the XYZ values to RGB or create an issue to add support for XYZ");if(3==e.length){const[t,n,i]=e;return[parseFloat(t),parseFloat(n),parseFloat(i)]}const t=parseFloat(e[0]);return[t,t,t]}parse_Ka(e){this.currentMaterial.ambient=this.parseColor(e)}parse_Kd(e){this.currentMaterial.diffuse=this.parseColor(e)}parse_Ks(e){this.currentMaterial.specular=this.parseColor(e)}parse_Ke(e){this.currentMaterial.emissive=this.parseColor(e)}parse_Tf(e){this.currentMaterial.transmissionFilter=this.parseColor(e)}parse_d(e){this.currentMaterial.dissolve=parseFloat(e.pop()||"0")}parse_illum(e){this.currentMaterial.illumination=parseInt(e[0])}parse_Ni(e){this.currentMaterial.refractionIndex=parseFloat(e[0])}parse_Ns(e){this.currentMaterial.specularExponent=parseInt(e[0])}parse_sharpness(e){this.currentMaterial.sharpness=parseInt(e[0])}parse_cc(e,t){t.colorCorrection="on"==e[0]}parse_blendu(e,t){t.horizontalBlending="on"==e[0]}parse_blendv(e,t){t.verticalBlending="on"==e[0]}parse_boost(e,t){t.boostMipMapSharpness=parseFloat(e[0])}parse_mm(e,t){t.modifyTextureMap.brightness=parseFloat(e[0]),t.modifyTextureMap.contrast=parseFloat(e[1])}parse_ost(e,t,n){for(;e.length<3;)e.push(n.toString());t.u=parseFloat(e[0]),t.v=parseFloat(e[1]),t.w=parseFloat(e[2])}parse_o(e,t){this.parse_ost(e,t.offset,0)}parse_s(e,t){this.parse_ost(e,t.scale,1)}parse_t(e,t){this.parse_ost(e,t.turbulence,0)}parse_texres(e,t){t.textureResolution=parseFloat(e[0])}parse_clamp(e,t){t.clamp="on"==e[0]}parse_bm(e,t){t.bumpMultiplier=parseFloat(e[0])}parse_imfchan(e,t){t.imfChan=e[0]}parse_type(e,t){t.reflectionType=e[0]}parseOptions(e){const t={colorCorrection:!1,horizontalBlending:!0,verticalBlending:!0,boostMipMapSharpness:0,modifyTextureMap:{brightness:0,contrast:1},offset:{u:0,v:0,w:0},scale:{u:1,v:1,w:1},turbulence:{u:0,v:0,w:0},clamp:!1,textureResolution:null,bumpMultiplier:1,imfChan:null,filename:""};let n,i;const r={};for(e.reverse();e.length;){const t=e.pop();t.startsWith("-")?(n=t.substr(1),r[n]=[]):n&&r[n].push(t)}for(n in r){if(!r.hasOwnProperty(n))continue;i=r[n];const e=this[`parse_${n}`];e&&e.bind(this)(i,t)}return t}parseMap(e){let t,n="";e[0].startsWith("-")?(n=e.pop(),t=e):[n,...t]=e;const i=this.parseOptions(t);return i.filename=n.replace(/\\/g,"/"),i}parse_map_Ka(e){this.currentMaterial.mapAmbient=this.parseMap(e)}parse_map_Kd(e){this.currentMaterial.mapDiffuse=this.parseMap(e)}parse_map_Ks(e){this.currentMaterial.mapSpecular=this.parseMap(e)}parse_map_Ke(e){this.currentMaterial.mapEmissive=this.parseMap(e)}parse_map_Ns(e){this.currentMaterial.mapSpecularExponent=this.parseMap(e)}parse_map_d(e){this.currentMaterial.mapDissolve=this.parseMap(e)}parse_map_aat(e){this.currentMaterial.antiAliasing="on"==e[0]}parse_map_bump(e){this.currentMaterial.mapBump=this.parseMap(e)}parse_bump(e){this.parse_map_bump(e)}parse_disp(e){this.currentMaterial.mapDisplacement=this.parseMap(e)}parse_decal(e){this.currentMaterial.mapDecal=this.parseMap(e)}parse_refl(e){this.currentMaterial.mapReflections.push(this.parseMap(e))}parse(){const e=this.data.split(/\r?\n/);for(let t of e){if(t=t.trim(),!t||t.startsWith("#"))continue;const[e,...n]=t.split(/\s/),i=this[`parse_${e}`];i?i.bind(this)(n):console.warn(`Don't know how to parse the directive: "${e}"`)}delete this.data,this.currentMaterial=Ls}}function Ds(e,t){const n=e.createTexture();return e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(t)),n}function Rs(e,t,n){const i=["mapDiffuse","mapAmbient","mapSpecular","mapDissolve","mapBump","mapDisplacement","mapDecal","mapEmissive"];n.endsWith("/")||(n+="/");const r=[];for(const s in t.materials){if(!t.materials.hasOwnProperty(s))continue;const a=t.materials[s];for(const t of i){const i=a[t];if(!i||!i.filename)continue;const s=n+i.filename;r.push(fetch(s).then(e=>{if(!e.ok)throw new Error;return e.blob()}).then(function(t){const n=new Image;n.src=URL.createObjectURL(t),i.texture=n;var r=Ds(e,[128,192,86,255]);return i.glTexture=r,e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.bindTexture(e.TEXTURE_2D,i.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i.texture),n.onload=()=>{e.bindTexture(e.TEXTURE_2D,i.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i.texture)},new Promise(e=>n.onload=()=>e(i))}).catch(()=>{console.error(`Unable to download texture: ${s}`)}))}}return Promise.all(r)}function Os(e,t,n,i){const r=["mapDiffuse","mapAmbient","mapSpecular","mapDissolve","mapBump","mapDisplacement","mapDecal","mapEmissive"];n.endsWith("/")||(n+="/");const s=[];for(const a in t.materials){if(!t.materials.hasOwnProperty(a))continue;const o=t.materials[a];for(const t of r){const r=o[t];if(!r||!r.filename)continue;const a=n+r.filename;s.push(i.file(`textures/${r.filename}`).async("arrayBuffer").then(e=>{let t=new Uint8Array(e);return new Blob([t.buffer])}).then(function(t){const n=new Image;n.src=URL.createObjectURL(t),r.texture=n;var i=Ds(e,[128,192,86,255]);return r.glTexture=i,e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.bindTexture(e.TEXTURE_2D,r.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r.texture),n.onload=()=>{e.bindTexture(e.TEXTURE_2D,r.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r.texture)},new Promise(e=>n.onload=()=>e(r))}).catch(()=>{console.error(`Unable to download texture: ${a}`)}))}}return Promise.all(s)}function Bs(e){return"string"!=typeof e.mtl?e.obj.replace(/\.obj$/,".mtl"):e.mtl}function Fs(e,t,n,i){const r=e.createBuffer(),s=t===e.ARRAY_BUFFER?Float32Array:Uint16Array;return e.bindBuffer(t,r),e.bufferData(t,new s(n),e.STATIC_DRAW),r.itemSize=i,r.numItems=n.length/i,r}const js={Attribute:Ts,DuplicateAttributeException:As,Layout:Es,Material:zs,MaterialLibrary:Is,Mesh:Ps,TYPES:Ss,downloadModels:function(e,t){const n=[];for(const i of t){if(!i.obj)throw new Error('"obj" attribute of model object not set. The .obj file is required to be set in order to use downloadModels()');const t={indicesPerMaterial:!!i.indicesPerMaterial,calcTangentsAndBitangents:!!i.calcTangentsAndBitangents};let r=i.name;if(!r){const e=i.obj.split("/");r=e[e.length-1].replace(".obj","")}const s=Promise.resolve(r),a=fetch(i.obj).then(e=>e.text()).then(e=>new Ps(e,t));let o;if(i.mtl){const t=Bs(i);o=fetch(t).then(e=>e.text()).then(n=>{const r=new Is(n);if(!1!==i.downloadMtlTextures){let n=i.mtlTextureRoot;return n||(n=t.substr(0,t.lastIndexOf("/"))),Promise.all([Promise.resolve(r),Rs(e,r,n)])}return Promise.all([Promise.resolve(r),void 0])}).then(e=>e)}const l=[s,a,o];n.push(Promise.all(l))}return Promise.all(n).then(e=>{const t={};for(const n of e){const[e,i,r]=n;i.name=e,r&&i.addMaterialLibrary(r[0]),t[e]=i}return t})},downloadModelsFromZip:function(e,t,n){const i=[];for(const r of t){if(!r.obj)throw new Error('"obj" attribute of model object not set. The .obj file is required to be set in order to use downloadModels()');const t={indicesPerMaterial:!!r.indicesPerMaterial,calcTangentsAndBitangents:!!r.calcTangentsAndBitangents},s=r.obj.split("/");let a=s[s.length-1].replace(".obj","");const o=Promise.resolve(a),l=n.file(`models/${a}.obj`).async("string").then(e=>new Ps(e,t));let c;if(r.mtl){const t=Bs(r);c=n.file(`models/${t}`).async("string").then(i=>{const s=new Is(i);if(!1!==r.downloadMtlTextures){let i=r.mtlTextureRoot;return i||(i=t.substr(0,t.lastIndexOf("/"))),Promise.all([Promise.resolve(s),Os(e,s,i,n)])}return Promise.all([Promise.resolve(s),void 0])}).then(e=>e)}const h=[o,l,c];i.push(Promise.all(h))}return Promise.all(i).then(e=>{const t={};for(const n of e){const[e,i,r]=n;i.name=e,r&&i.addMaterialLibrary(r[0]),t[e]=i}return t})},downloadMeshes:function(e,t,n){void 0===n&&(n={});const i=[];for(const r in e){if(!e.hasOwnProperty(r))continue;const t=e[r];i.push(fetch(t).then(e=>e.text()).then(e=>[r,new Ps(e)]))}Promise.all(i).then(e=>{for(const[t,i]of e)n[t]=i;return t(n)})},initMeshBuffers:function(e,t){return t.normalBuffer=Fs(e,e.ARRAY_BUFFER,t.vertexNormals,3),t.textureBuffer=Fs(e,e.ARRAY_BUFFER,t.textures,t.textureStride),t.vertexBuffer=Fs(e,e.ARRAY_BUFFER,t.vertices,3),t.indexBuffer=Fs(e,e.ELEMENT_ARRAY_BUFFER,t.indices,1),t},deleteMeshBuffers:function(e,t){e.deleteBuffer(t.normalBuffer),e.deleteBuffer(t.textureBuffer),e.deleteBuffer(t.vertexBuffer),e.deleteBuffer(t.indexBuffer)},version:"2.0.3"};function Ns(e){return e*Math.PI/180}const Us={None:0,Right:1,Up:2,Left:4,Down:8,All:15,fromOffset:e=>e[0]>0?Us.Right:e[0]<0?Us.Left:e[1]>0?Us.Down:e[1]<0?Us.Up:0,toOffset(e){switch(e){case Us.Right:return[1,0];case Us.Up:return[0,-1];case Us.Left:return[-1,0];case Us.Down:return[0,1]}return[0,0]},reverse(e){switch(e){case Us.Right:return Us.Left;case Us.Up:return Us.Down;case Us.Left:return Us.Right;case Us.Down:return Us.Up}return Us.None},rotate(e,t=!1){switch(e){case Us.Right:return t?Us.Up:Us.Down;case Us.Up:return t?Us.Left:Us.Right;case Us.Left:return t?Us.Down:Us.Up;case Us.Down:return t?Us.Right:Us.Left}return Us.None},adjustCameraDirection(e){switch(e.z%8){case 0:return"N";case 1:case-7:return"NW";case 2:case-6:return"W";case 3:case-5:return"SW";case 4:case-4:return"S";case 5:case-3:return"SE";case 6:case-2:return"E";case 7:case-1:return"NE"}},getCameraRelativeDirection(e,t){const n={N:{forward:Us.Up,backward:Us.Down,left:Us.Left,right:Us.Right},NE:{forward:Us.Up,backward:Us.Down,left:Us.Up,right:Us.Down},E:{forward:Us.Right,backward:Us.Left,left:Us.Up,right:Us.Down},SE:{forward:Us.Right,backward:Us.Left,left:Us.Up,right:Us.Down},S:{forward:Us.Down,backward:Us.Up,left:Us.Right,right:Us.Left},SW:{forward:Us.Down,backward:Us.Up,left:Us.Right,right:Us.Left},W:{forward:Us.Left,backward:Us.Right,left:Us.Down,right:Us.Up},NW:{forward:Us.Left,backward:Us.Right,left:Us.Down,right:Us.Up}};return(n[t]||n.N)[e]||Us.None},spriteSequence(e,t="N"){switch(t){case"N":switch(e){case Us.Up:return"N";case Us.Right:return"E";case Us.Down:return"S";case Us.Left:return"W"}case"E":switch(e){case Us.Up:return"W";case Us.Right:return"N";case Us.Down:return"E";case Us.Left:return"S"}case"S":switch(e){case Us.Up:return"S";case Us.Right:return"W";case Us.Down:return"N";case Us.Left:return"E"}case"W":switch(e){case Us.Up:return"E";case Us.Right:return"S";case Us.Down:return"W";case Us.Left:return"N"}case"NE":switch(e){case Us.Up:return"NW";case Us.Right:return"SE";case Us.Down:return"NE";case Us.Left:return"SW"}case"SE":switch(e){case Us.Up:return"SW";case Us.Right:return"NW";case Us.Down:return"SE";case Us.Left:return"NE"}case"SW":switch(e){case Us.Up:return"NE";case Us.Right:return"SW";case Us.Down:return"NW";case Us.Left:return"SE"}case"NW":switch(e){case Us.Up:return"SE";case Us.Right:return"NE";case Us.Down:return"SW";case Us.Left:return"NW"}}return"S"},drawOffset(e,t="N"){switch(t){case"NE":return e.cross(new ot(Math.sin(Ns(315)),2*Math.cos(Ns(315)),0));case"NW":return e.cross(new ot(-2*Math.sin(Ns(315)),-Math.cos(Ns(315)),0));case"SE":return e.cross(new ot(Math.sin(Ns(225)),Math.cos(Ns(225)),0));case"SW":return e.cross(new ot(Math.sin(Ns(135)),Math.cos(Ns(135)),0));case"E":return e.cross(new ot(Math.sin(Ns(270)),Math.cos(Ns(270)),0));case"W":return e.cross(new ot(Math.sin(Ns(90)),Math.cos(Ns(90)),0));case"S":return e.cross(new ot(Math.sin(Ns(180)),Math.cos(Ns(180)),0));case"N":return e.cross(new ot(Math.sin(Ns(0)),Math.cos(Ns(0)),0));default:return e}},objectSequence(e){switch(e){case Us.Right:return[0,90,0];case Us.Up:return[0,0,0];case Us.Left:return[0,-90,0];case Us.Down:return[0,180,0]}return[0,0,0]}},$s=e=>e&&"object"==typeof e&&!Array.isArray(e),Vs=(e,...t)=>{if(!t.length)return e;const n=t.shift();if($s(e)&&$s(n))for(const i in n)$s(n[i])?(e[i]||Object.assign(e,{[i]:{}}),Vs(e[i],n[i])):Object.assign(e,{[i]:n[i]&&Array.isArray(n[i])?[].concat(e[i]??[],n[i]):n[i]});return Vs(e,...t)};class Ws{constructor(e){i(this,"setTarget",e=>{this.cameraTarget=e,this.updateViewFromAngles()}),i(this,"setCamera",()=>{var e,t;ks(bs(),this.uViewMat),xs(this.uViewMat,this.uViewMat,[0,0,-15]),_s(this.uViewMat,this.uViewMat,ct(this.cameraAngle*this.cameraVector.x),[1,0,0]),_s(this.uViewMat,this.uViewMat,ct(this.cameraAngle*this.cameraVector.y),[0,1,0]),_s(this.uViewMat,this.uViewMat,ct(this.cameraAngle*this.cameraVector.z),[0,0,1]),e=this.cameraPosition,(t=this.cameraOffset)||(t=new ot(-e.x,-e.y,-e.z)),t.x=-e.x,t.y=-e.y,t.z=-e.z,xs(this.uViewMat,this.uViewMat,this.cameraOffset.toArray()),this.cameraDir=Us.adjustCameraDirection(this.cameraVector)}),i(this,"changeAngle",e=>{this.lookAt(this.cameraPosition.toArray(),this.cameraOffset.toArray(),e)}),i(this,"lookAt",(e,t,n)=>{let i=(e=>{let t=Math.hypot(...e);return!t||Math.abs(t)<ys?[0,0,1]:[e[0]/t,e[1]/t,e[2]/t]})((s=t,[(r=e)[0]-s[0],r[1]-s[1],r[2]-s[2]]));var r,s;Number.isFinite(i[0])&&Number.isFinite(i[1])&&Number.isFinite(i[2])||(i=[0,0,1]);let a=new ot(...i);0===a.length()&&(a=new ot(0,0,1));let o=n.cross(a).normal();0===o.length()&&(o=new ot(1,0,0));const l=a.cross(o).normal(),c=[o.x,o.y,o.z,0,l.x,l.y,l.z,0,a.x,a.y,a.z,0,e.x,e.y,e.z,1];this.uViewMat=ks(c,this.uViewMat)}),i(this,"setFromViewMatrix",e=>{if(e)try{this.cameraPosition=new ot(e[12],e[13],e[14]);const t=e[8],n=e[9],i=e[10],r=-t,s=-n,a=-i;this.yaw=Math.atan2(s,r),this.pitch=Math.asin(a/Math.max(1e-6,Math.hypot(r,s,a)));const o=Math.hypot(r,s,a),l=new ot(r/(o||1),s/(o||1),a/(o||1));this.cameraDistance=this.cameraDistance||15,this.cameraTarget=this.cameraPosition.add(l.mul(-1*this.cameraDistance))}catch(t){}}),i(this,"updateViewFromAngles",()=>{Number.isFinite(this.yaw)||(this.yaw=0),Number.isFinite(this.pitch)||(this.pitch=0),(!Number.isFinite(this.cameraDistance)||this.cameraDistance<=0)&&(this.cameraDistance=Math.max(.1,Math.abs(this.cameraDistance)||15));const e=this.cameraTarget.x+this.cameraDistance*Math.cos(this.pitch)*Math.cos(this.yaw),t=this.cameraTarget.y+this.cameraDistance*Math.cos(this.pitch)*Math.sin(this.yaw),n=this.cameraTarget.z+this.cameraDistance*Math.sin(this.pitch),i=new ot(e,t,n);this.cameraPosition=new ot(i.x,i.y,i.z);const r=new ot(this.cameraTarget.x,this.cameraTarget.y,this.cameraTarget.z),s=new ot(0,0,1);this.lookAt(i,r,s);let a=180*this.yaw/Math.PI%360;a<0&&(a+=360);let o=(90-a+360)%360,l=Math.round(o/45)%8;this.cameraDir=["N","NE","E","SE","S","SW","W","NW"][l],this.cameraVector.z=l}),i(this,"translateCam",e=>{const t=.5,n=new ot(Math.cos(this.pitch)*Math.cos(this.yaw),Math.cos(this.pitch)*Math.sin(this.yaw),Math.sin(this.pitch)).normal(),i=new ot(-Math.sin(this.yaw),Math.cos(this.yaw),0).normal();switch(e){case"UP":this.cameraTarget=this.cameraTarget.add(n.mul(t));break;case"DOWN":this.cameraTarget=this.cameraTarget.add(n.mul(-.5));break;case"LEFT":this.cameraTarget=this.cameraTarget.add(i.mul(-.5));break;case"RIGHT":this.cameraTarget=this.cameraTarget.add(i.mul(t))}this.updateViewFromAngles()}),i(this,"rotateCam",e=>{const t=.05;switch(e){case"LEFT":this.yaw-=t;break;case"RIGHT":this.yaw+=t;break;case"UP":this.pitch=Math.max(-Math.PI/2+.01,this.pitch-t);break;case"DOWN":this.pitch=Math.min(Math.PI/2-.01,this.pitch+t)}this.updateViewFromAngles()}),i(this,"zoom",e=>{this.cameraDistance=Math.max(.1,this.cameraDistance+e),this.updateViewFromAngles()}),i(this,"panCW",(e=Math.PI/4)=>{this.yaw-=e,this.updateViewFromAngles()}),i(this,"panCCW",(e=Math.PI/4)=>{this.yaw+=e,this.updateViewFromAngles()}),i(this,"pitchCW",(e=Math.PI/4)=>{this.pitch-=e,this.updateViewFromAngles()}),i(this,"pitchCCW",(e=Math.PI/4)=>{this.pitch+=e,this.updateViewFromAngles()}),i(this,"tiltCW",(e=Math.PI/4)=>{this.pitch-=.1*e,this.updateViewFromAngles()}),i(this,"tiltCCW",(e=Math.PI/4)=>{this.pitch+=.1*e,this.updateViewFromAngles()}),Number.prototype.clamp=function(e,t){return this<e?e:this>t?t:this},this.renderingManager=e,this.uViewMat=bs(),this.fov=45,this.thetaLimits=new ot(...[1.5*Math.PI,1.8*Math.PI,0]),this.cameraAngle=45,this.cameraVector=new ot(...[1,0,0]),this.cameraDir="N",this.cameraPosition=new ot(8,8,-1),this.yaw=0,this.pitch=0,this.cameraDistance=15,this.cameraTarget=new ot(8,8,-1),this.cameraOffset=new ot(0,0,0)}}class Hs{constructor(e){return Hs.instance||(this.camera=new Ws(e),Hs.instance=this),Hs.instance}}class Ks{constructor(e){return i(this,"addLight",(e,t,n,i=[.8,.8,.8],r=[1,1,1],s=1,a=[1,1,1],o=!0)=>{const{shaderProgram:l}=this.renderManager;if(this.lights.length>=l.maxLights)return;let c=new Zs(this.renderManager.engine,e,n,t,i,r,s,a,o);return this.lights[e]=c,e}),i(this,"updateLight",(e,t,n,i,r,s,a,o)=>{let l=this.lights[e];l&&(t&&(l.pos=t),n&&(l.color=n),i&&(l.attenuation=i),r&&(l.direction=r),s&&(l.density=s),a&&(l.scatteringCoefficients=a),o&&(l.enabled=o),this.lights[e]=l)}),i(this,"removeLight",e=>{delete this.lights[e]}),i(this,"tick",()=>{let e=Object.keys(this.lights);for(let t=0;t<e.length;t++)this.lights[e[t]].tick()}),i(this,"render",()=>{const{shaderProgram:e}=this.renderManager;let t=e.uLights;if(t)for(let n=0;n<e.maxLights;n++){let e=Object.keys(this.lights);this.lights[e[n]]&&(this.lights[e[n]].enabled&&this.lights[e[n]].draw(t[n]))}}),i(this,"setMatrixUniforms",()=>{this.tick(),this.render()}),Ks.instance||(this.lights={},this.renderManager=e,this.engine=e.engine,Ks.instance=this),Ks.instance}}class Zs{constructor(e,t,n,r,s,a,o,l,c){i(this,"tick",()=>{this.frame++}),i(this,"draw",e=>{const{gl:t}=this.engine;t.uniform1f(e.enabled,this.enabled),t.uniform3fv(e.position,this.pos),t.uniform3fv(e.color,this.color),t.uniform3fv(e.attenuation,this.attenuation),t.uniform3fv(e.direction,this.direction),t.uniform3fv(e.scatteringCoefficients,this.scatteringCoefficients),t.uniform1f(e.density,this.density)}),this.engine=e,this.id=t??"light",this.color=n??[1,1,1],this.pos=r??[0,0,0],this.attenuation=s??[.5,.1,0],this.density=o??.8,this.scatteringCoefficients=l??[.5,.5,.5],this.direction=a??[1,1,1],this.enabled=c??!0,this.frame=0}}const Gs=(e,t,n)=>{const i=e[t];return i?"function"==typeof i?i():Promise.resolve(i):new Promise((e,i)=>{("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})};class Xs{constructor(){this.actions=[]}add(e){this.actions.push(e)}run(){let e=arguments;this.actions=this.actions.filter(t=>t(e))}}class Ys{runWhenLoaded(e){this.loaded?e():this.onLoadActions.add(e)}update(e){Object.assign(this,e)}}class qs extends Ys{constructor(e,t){super(),this.engine=t,this.src=e,this.glTexture=t.gl.createTexture(),this.image=new Image,this.image.onload=this._onImageLoaded.bind(this),this.image.src=e,this.loaded=!1,this.onLoadActions=new Xs}_onImageLoaded(){let{gl:e}=this.engine;e.bindTexture(e.TEXTURE_2D,this.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.bindTexture(e.TEXTURE_2D,null),this.loaded=!0,this.onLoadActions.run()}attach(){let{gl:e}=this.engine;e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.glTexture),e.uniform1i(this.engine.renderManager.shaderProgram.samplerUniform,0)}}const Js=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const Qs=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uTime;\n \n varying vec4 vPosition;\n \n // Hash function for clouds\n float hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n \n // Value noise\n float noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n \n float a = hash(i);\n float b = hash(i + vec2(1.0, 0.0));\n float c = hash(i + vec2(0.0, 1.0));\n float d = hash(i + vec2(1.0, 1.0));\n \n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n }\n \n // Fractal brownian motion for fluffy clouds\n float fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < 5; i++) {\n value += amplitude * noise(p);\n amplitude *= 0.5;\n p *= 2.0;\n }\n return value;\n }\n \n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n \n // Height-based gradient\n float y = dir.y * 0.5 + 0.5;\n \n // Sun position (rising from the east)\n vec3 sunDir = normalize(vec3(1.0, 0.3, 0.0));\n float sunDot = dot(dir, sunDir);\n \n // Morning color palette - soft and fresh\n vec3 horizonColor = vec3(1.0, 0.85, 0.7); // Warm peachy horizon\n vec3 skyColor = vec3(0.5, 0.7, 0.95); // Soft blue sky\n vec3 sunColor = vec3(1.0, 1.0, 0.9); // Bright morning sun\n vec3 glowColor = vec3(1.0, 0.9, 0.7); // Warm glow\n \n // Base sky gradient - softer transition\n vec3 color = mix(horizonColor, skyColor, pow(y, 0.6));\n \n // Morning sun glow\n float glow = pow(max(0.0, sunDot), 8.0);\n color = mix(color, glowColor, glow * 0.6);\n \n // Bright sun disc\n float sun = pow(max(0.0, sunDot), 512.0) * 2.0;\n color = mix(color, sunColor, min(1.0, sun));\n \n // Fluffy morning clouds\n float time = uTime * 0.015;\n vec2 cloudUV = dir.xz / (abs(dir.y) + 0.3) * 1.5 + vec2(time, 0.0);\n float clouds = fbm(cloudUV * 2.0);\n \n // Shape clouds nicely\n clouds = smoothstep(0.35, 0.65, clouds);\n \n // Clouds are bright white in morning light\n vec3 cloudColor = mix(vec3(0.95, 0.95, 1.0), vec3(1.0, 0.98, 0.9), glow);\n \n // Apply clouds more in the upper sky\n float cloudMask = smoothstep(0.1, 0.6, y) * (1.0 - smoothstep(0.7, 1.0, y));\n color = mix(color, cloudColor, clouds * cloudMask * 0.7);\n \n // Soft atmospheric haze near horizon\n float haze = exp(-y * 4.0);\n color = mix(color, horizonColor * 1.1, haze * 0.25);\n \n // Add subtle light rays\n float rays = pow(max(0.0, sunDot), 2.0) * noise(dir.xz * 10.0 + time * 0.5) * 0.15;\n color += vec3(rays) * (1.0 - y);\n \n gl_FragColor = vec4(color, 1.0);\n }\n"}},Symbol.toStringTag,{value:"Module"}));const ea=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const ta=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uTime;\n \n varying vec4 vPosition;\n \n // Hash function\n float hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n \n // Value noise\n float noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n \n float a = hash(i);\n float b = hash(i + vec2(1.0, 0.0));\n float c = hash(i + vec2(0.0, 1.0));\n float d = hash(i + vec2(1.0, 1.0));\n \n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n }\n \n // FBM for clouds\n float fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < 5; i++) {\n value += amplitude * noise(p);\n amplitude *= 0.5;\n p *= 2.0;\n }\n return value;\n }\n \n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n float time = uTime;\n \n // Height-based gradient for daytime sky\n float y = dir.y * 0.5 + 0.5;\n \n // Sun position (high in sky)\n vec3 sunDir = normalize(vec3(0.3, 0.8, 0.5));\n float sunDot = dot(dir, sunDir);\n \n // Daytime sky colors\n vec3 zenithColor = vec3(0.2, 0.4, 0.85); // Deep blue at top\n vec3 horizonColor = vec3(0.6, 0.75, 0.95); // Light blue at horizon\n vec3 sunColor = vec3(1.0, 1.0, 0.95); // Bright white sun\n \n // Sky gradient using realistic Rayleigh scattering approximation\n vec3 color = mix(horizonColor, zenithColor, pow(y, 0.5));\n \n // Sun atmospheric scattering\n float scatter = pow(max(0.0, sunDot), 2.0);\n color = mix(color, vec3(0.9, 0.95, 1.0), scatter * 0.2);\n \n // Bright sun disc with soft edge\n float sun = smoothstep(0.9995, 1.0, sunDot);\n color = mix(color, sunColor, sun);\n \n // Sun glare\n float glare = pow(max(0.0, sunDot), 32.0) * 0.5;\n color += sunColor * glare;\n \n // Animated cumulus clouds\n vec2 cloudUV = dir.xz / (abs(dir.y) + 0.2) + time * 0.01;\n \n // Multiple cloud layers\n float clouds1 = fbm(cloudUV * 1.5);\n float clouds2 = fbm(cloudUV * 3.0 + vec2(100.0, 0.0));\n \n // Shape clouds\n clouds1 = smoothstep(0.4, 0.7, clouds1);\n clouds2 = smoothstep(0.5, 0.75, clouds2) * 0.5;\n float clouds = max(clouds1, clouds2);\n \n // Cloud color with some shading\n vec3 cloudLight = vec3(1.0, 1.0, 1.0);\n vec3 cloudShadow = vec3(0.7, 0.75, 0.85);\n vec3 cloudColor = mix(cloudShadow, cloudLight, fbm(cloudUV * 4.0));\n \n // Apply clouds more in middle sky\n float cloudMask = smoothstep(0.15, 0.5, y) * smoothstep(1.0, 0.6, y);\n color = mix(color, cloudColor, clouds * cloudMask * 0.85);\n \n // Atmospheric perspective (haze near horizon)\n float haze = exp(-y * 5.0);\n color = mix(color, horizonColor * 1.1, haze * 0.3);\n \n gl_FragColor = vec4(color, 1.0);\n }\n"}},Symbol.toStringTag,{value:"Module"}));const na=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const ia=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n precision mediump float;\n \n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uTime;\n \n varying vec4 vPosition;\n \n // Hash function for clouds\n float hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n \n // Value noise for clouds\n float noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n \n float a = hash(i);\n float b = hash(i + vec2(1.0, 0.0));\n float c = hash(i + vec2(0.0, 1.0));\n float d = hash(i + vec2(1.0, 1.0));\n \n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n }\n \n // Fractal brownian motion for realistic clouds\n float fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n for (int i = 0; i < 4; i++) {\n value += amplitude * noise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n return value;\n }\n \n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n \n // Height-based gradient for sunset colors\n float y = dir.y * 0.5 + 0.5; // Normalize to 0-1\n \n // Sun position (just above horizon)\n vec3 sunDir = normalize(vec3(0.0, 0.1, -1.0));\n float sunDot = dot(dir, sunDir);\n \n // Sunset color palette\n vec3 horizonColor = vec3(1.0, 0.3, 0.1); // Orange-red at horizon\n vec3 skyColor = vec3(0.2, 0.1, 0.4); // Deep purple up high\n vec3 sunColor = vec3(1.0, 0.9, 0.5); // Bright yellow-white sun\n vec3 glowColor = vec3(1.0, 0.5, 0.2); // Orange glow\n \n // Base sky gradient\n vec3 color = mix(horizonColor, skyColor, pow(y, 0.8));\n \n // Sun glow (larger soft glow)\n float glow = pow(max(0.0, sunDot), 4.0) * 1.5;\n color = mix(color, glowColor, glow);\n \n // Bright sun disc\n float sun = pow(max(0.0, sunDot), 256.0) * 2.0;\n color = mix(color, sunColor, min(1.0, sun));\n \n // Animated clouds (move slowly)\n float time = uTime * 0.02;\n vec2 cloudUV = dir.xz / (dir.y + 0.5) * 2.0 + time;\n float clouds = fbm(cloudUV * 3.0);\n clouds = smoothstep(0.4, 0.7, clouds);\n \n // Cloud color based on sun angle\n vec3 cloudColor = mix(vec3(0.3, 0.1, 0.15), vec3(1.0, 0.6, 0.3), glow + y * 0.5);\n color = mix(color, cloudColor, clouds * (1.0 - y) * 0.6);\n \n // Add atmospheric scattering near horizon\n float scatter = exp(-y * 3.0);\n color = mix(color, horizonColor, scatter * 0.3);\n \n gl_FragColor = vec4(color, 1.0);\n }\n"}},Symbol.toStringTag,{value:"Module"}));const ra=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const sa=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return'\n precision highp float;\n uniform mat4 uViewDirectionProjectionInverse;\n varying vec4 vPosition;\n uniform float uTime;\n uniform vec2 uResolution;\n\n const float PI = 3.141592653589793;\n\n // simple float hash from vec2\n float hash12(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n }\n\n // value noise (cheap)\n float noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n float a = hash12(i + vec2(0.0, 0.0));\n float b = hash12(i + vec2(1.0, 0.0));\n float c = hash12(i + vec2(0.0, 1.0));\n float d = hash12(i + vec2(1.0, 1.0));\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;\n }\n\n // smooth pulse shape\n float pulse(float x, float wid) {\n return smoothstep(0.0, wid, x) * (1.0 - smoothstep(1.0 - wid, 1.0, x));\n }\n\n void main() {\n // Reconstruct view direction from interpolated clip-space position\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n\n // convert direction -> equirectangular-like UV so "columns" wrap horizontally\n float u = atan(dir.z, dir.x) / (2.0 * PI) + 0.5;\n float v = asin(clamp(dir.y, -1.0, 1.0)) / PI + 0.5;\n vec2 uv = vec2(u, v);\n\n // Column layout\n float colsBase = mix(120.0, 240.0, clamp(uResolution.x / 1600.0, 0.0, 1.0));\n float horizonBias = 1.0 - abs(v - 0.5) * 2.0;\n float cols = max(32.0, colsBase * (0.6 + 0.8 * horizonBias));\n\n float colIndexF = floor(uv.x * cols);\n float colX = (colIndexF + 0.5) / cols;\n\n // per-column seed & speed variety\n float seed = hash12(vec2(colIndexF, floor(uTime * 10.0)));\n float speed = 0.8 + hash12(vec2(colIndexF, 9.0)) * 2.2;\n\n // vertical tiling for character cells\n float charSize = mix(0.018, 0.035, clamp(uResolution.y/900.0, 0.0, 1.0));\n float rows = 1.0 / charSize;\n\n float yScaled = uv.y * rows;\n float yCell = floor(yScaled);\n float yFrac = fract(yScaled);\n\n // falling offset based on time and column seed\n float fall = fract((uTime * speed * 0.25) + seed * 10.0);\n\n float dropPos = fract(seed * 7.3 + uTime * 0.25 * speed);\n float drop2 = fract(seed * 3.1 + uTime * 0.57 * speed * 0.7);\n\n float d1 = abs(yCell / rows - dropPos);\n float d2 = abs(yCell / rows - drop2);\n\n float head = exp(-pow((yFrac + fract(yCell*0.9183) * 0.35), 2.0) * 40.0);\n float tail = exp(-d1 * 8.0) + 0.5 * exp(-d2 * 12.0);\n\n float glyphSeed = hash12(vec2(colIndexF, yCell));\n float glyphPulse = pulse(fract(yScaled - (seed*3.0 + uTime*0.9*speed)), 0.12);\n float glyph = smoothstep(0.35, 0.55, glyphSeed + 0.2 * noise2(vec2(colIndexF * 0.13, yCell * 0.07 + uTime * 0.1)));\n\n float brightness = clamp( 1.6 * head + 0.9 * tail * glyph + 0.35 * glyph * glyphPulse, 0.0, 1.6);\n\n float colWidth = 1.0 / cols * 0.9;\n float colMask = smoothstep(0.0, 1.0, 1.0 - abs(uv.x - colX) / (colWidth * 0.6));\n\n float jitter = noise2(vec2(colIndexF * 0.7, yCell * 0.9 + uTime * 0.2)) * 0.5;\n float charV = smoothstep(0.0, 1.0, 1.0 - abs(yFrac - (0.5 + jitter*0.2)) * 2.0);\n\n float intensity = brightness * colMask * charV;\n\n vec3 baseGreen = vec3(0.1, 0.95, 0.15);\n vec3 headColor = mix(baseGreen * 0.6, vec3(1.0, 1.0, 0.9), clamp(head * 2.0, 0.0, 1.0));\n vec3 tailColor = baseGreen * (0.6 + 0.8 * glyph);\n\n float headFactor = clamp(head * 2.0, 0.0, 1.0);\n vec3 col = mix(tailColor, headColor, headFactor) * intensity;\n\n float bgNoise = 0.04 * (noise2(uv * 400.0 + uTime * 0.03));\n float verticalVignette = pow(1.0 - abs(v - 0.5) * 1.6, 1.8);\n vec3 bg = vec3(0.01, 0.03, 0.01) * verticalVignette + bgNoise;\n\n float stars = smoothstep(0.9996, 1.0, noise2(uv * 2000.0 + uTime * 0.1));\n vec3 starCol = vec3(0.6, 1.0, 0.6) * stars * 1.2;\n\n vec3 final = col + bg + starCol;\n\n float glow = pow(intensity, 1.6) * 0.9;\n final += vec3(glow * 0.14, glow * 0.22, glow * 0.06);\n\n final = 1.0 - exp(-final * 1.6);\n final = pow(final, vec3(0.9));\n\n gl_FragColor = vec4(final, 1.0);\n }\n'}},Symbol.toStringTag,{value:"Module"}));const aa=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const oa=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n precision mediump float;\n uniform samplerCube uSkybox;\n varying vec4 vPosition;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uTime;\n\n // Hash function\n float hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n \n float hash3(vec3 p) {\n return fract(sin(dot(p, vec3(12.9898, 78.233, 45.164))) * 43758.5453);\n }\n\n // Value noise\n float noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n \n float a = hash(i);\n float b = hash(i + vec2(1.0, 0.0));\n float c = hash(i + vec2(0.0, 1.0));\n float d = hash(i + vec2(1.0, 1.0));\n \n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n }\n \n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n float time = uTime;\n \n // Dark base with subtle color\n vec3 color = vec3(0.02, 0.01, 0.05);\n \n // Animated grid lines (synthwave style)\n vec2 gridUV = dir.xz / (dir.y + 0.3);\n \n // Perspective grid\n float gridX = abs(sin(gridUV.x * 8.0 + time * 0.5));\n float gridZ = abs(sin(gridUV.y * 4.0 - time * 2.0));\n \n // Grid lines with glow\n float lineX = pow(gridX, 20.0);\n float lineZ = pow(gridZ, 20.0);\n float grid = max(lineX, lineZ);\n \n // Only show grid below horizon\n float belowHorizon = smoothstep(0.1, -0.3, dir.y);\n grid *= belowHorizon;\n \n // Neon pink/cyan colors\n vec3 neonPink = vec3(1.0, 0.1, 0.5);\n vec3 neonCyan = vec3(0.1, 1.0, 0.8);\n vec3 neonPurple = vec3(0.6, 0.1, 1.0);\n \n // Alternate line colors\n vec3 gridColor = mix(neonPink, neonCyan, sin(time * 0.3) * 0.5 + 0.5);\n color += gridColor * grid * 0.8;\n \n // Add horizon glow\n float horizonGlow = exp(-abs(dir.y) * 5.0);\n vec3 horizonColor = mix(neonPink, neonPurple, sin(time * 0.2) * 0.5 + 0.5);\n color += horizonColor * horizonGlow * 0.6;\n \n // Animated neon sun\n vec3 sunDir = normalize(vec3(sin(time * 0.1), 0.1, -1.0));\n float sunDot = dot(dir, sunDir);\n \n // Segmented retro sun\n float sunMask = step(0.9, sunDot);\n float sunStripes = step(0.5, sin(dir.y * 40.0 - time * 2.0));\n vec3 sunColor = mix(neonPink, vec3(1.0, 0.5, 0.0), (1.0 - dir.y) * 2.0);\n color = mix(color, sunColor * (0.5 + sunStripes * 0.5), sunMask);\n \n // Sun glow\n float sunGlow = pow(max(0.0, sunDot), 4.0) * (1.0 - sunMask);\n color += sunColor * sunGlow * 0.5;\n \n // Scattered stars with chromatic aberration\n float starDensity = 0.003;\n vec3 starPos = dir * 50.0;\n float star = step(1.0 - starDensity, hash3(floor(starPos)));\n if (star > 0.0 && dir.y > 0.0) {\n float twinkle = sin(time * 5.0 + hash3(floor(starPos)) * 6.28) * 0.3 + 0.7;\n vec3 starColor = mix(neonCyan, neonPink, hash3(floor(starPos) + 1.0));\n color += starColor * twinkle * 0.8;\n }\n \n // Scanlines effect\n float scanline = sin(gl_FragCoord.y * 2.0) * 0.03;\n color *= 1.0 - scanline;\n \n // Vignette\n vec2 uv = gl_FragCoord.xy / vec2(800.0, 600.0); // Approximate\n float vignette = 1.0 - length(uv - 0.5) * 0.5;\n color *= vignette;\n \n gl_FragColor = vec4(color, 1.0);\n }\n"}},Symbol.toStringTag,{value:"Module"}));const la=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n attribute vec4 aPosition;\n varying vec4 vPosition;\n void main() {\n vPosition = aPosition;\n gl_Position = aPosition;\n }\n"}},Symbol.toStringTag,{value:"Module"}));const ca=Object.freeze(Object.defineProperty({__proto__:null,default:function(){return"\n precision mediump float;\n uniform samplerCube uSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uTime;\n varying vec4 vPosition;\n\n // Hash functions\n float hash(vec3 p) {\n return fract(sin(dot(p, vec3(12.9898, 78.233, 45.164))) * 43758.5453);\n }\n \n float hash2(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n // Value noise\n float noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n \n float a = hash2(i);\n float b = hash2(i + vec2(1.0, 0.0));\n float c = hash2(i + vec2(0.0, 1.0));\n float d = hash2(i + vec2(1.0, 1.0));\n \n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n }\n\n // Fractal brownian motion for nebulae\n float fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < 6; i++) {\n value += amplitude * noise(p);\n amplitude *= 0.5;\n p *= 2.0;\n }\n return value;\n }\n\n void main() {\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n vec3 dir = normalize(t.xyz / t.w);\n float time = uTime * 0.05;\n\n // Deep space black base\n vec3 color = vec3(0.01, 0.01, 0.02);\n \n // Multiple star layers with different densities\n // Close bright stars\n float starDensity1 = 0.0015;\n vec3 starPos1 = dir * 80.0;\n float star1 = step(1.0 - starDensity1, hash(floor(starPos1)));\n if (star1 > 0.0) {\n float twinkle = sin(time * 20.0 + hash(floor(starPos1)) * 6.28) * 0.2 + 0.8;\n float brightness = (0.7 + 0.3 * hash(floor(starPos1) + 1.0)) * twinkle;\n vec3 starColor = mix(vec3(1.0, 0.9, 0.8), vec3(0.8, 0.9, 1.0), hash(floor(starPos1) + 2.0));\n color += starColor * brightness;\n }\n \n // Medium distant stars\n float starDensity2 = 0.003;\n vec3 starPos2 = dir * 150.0;\n float star2 = step(1.0 - starDensity2, hash(floor(starPos2)));\n if (star2 > 0.0) {\n float brightness = 0.4 + 0.3 * hash(floor(starPos2) + 1.0);\n color += vec3(brightness);\n }\n \n // Far dim stars (star dust)\n float starDensity3 = 0.008;\n vec3 starPos3 = dir * 300.0;\n float star3 = step(1.0 - starDensity3, hash(floor(starPos3)));\n if (star3 > 0.0) {\n color += vec3(0.15 + 0.1 * hash(floor(starPos3)));\n }\n\n // Nebula layer 1 - Blue/purple\n vec2 nebulaUV1 = dir.xy + dir.z * 0.5;\n float nebula1 = fbm(nebulaUV1 * 2.0 + time * 0.1);\n nebula1 = smoothstep(0.3, 0.8, nebula1);\n vec3 nebulaColor1 = mix(vec3(0.1, 0.05, 0.2), vec3(0.2, 0.1, 0.4), nebula1);\n color += nebulaColor1 * nebula1 * 0.4;\n \n // Nebula layer 2 - Pink/red (different orientation)\n vec2 nebulaUV2 = dir.xz + dir.y * 0.5 + vec2(100.0);\n float nebula2 = fbm(nebulaUV2 * 1.5 + time * 0.08);\n nebula2 = smoothstep(0.4, 0.85, nebula2);\n vec3 nebulaColor2 = mix(vec3(0.15, 0.02, 0.05), vec3(0.3, 0.05, 0.15), nebula2);\n color += nebulaColor2 * nebula2 * 0.3;\n \n // Nebula layer 3 - Teal emission nebula\n vec2 nebulaUV3 = dir.yz + dir.x * 0.5 + vec2(50.0, 200.0);\n float nebula3 = fbm(nebulaUV3 * 2.5 + time * 0.12);\n nebula3 = smoothstep(0.5, 0.9, nebula3);\n vec3 nebulaColor3 = vec3(0.05, 0.15, 0.2) * nebula3;\n color += nebulaColor3 * 0.25;\n\n // Milky Way band (follows a curved path)\n float milkyWay = abs(dir.y - sin(dir.x * 0.5) * 0.3);\n milkyWay = 1.0 - smoothstep(0.0, 0.4, milkyWay);\n float milkyNoise = fbm(dir.xz * 8.0 + time * 0.05);\n color += vec3(0.1, 0.1, 0.12) * milkyWay * milkyNoise;\n \n // Add some extra star density in milky way\n float milkyStars = step(0.97, noise(dir.xz * 500.0)) * milkyWay;\n color += vec3(0.5, 0.5, 0.6) * milkyStars;\n\n // Distant galaxies (rare, bright spots)\n float galaxyDensity = 0.0002;\n vec3 galaxyPos = dir * 20.0;\n float galaxy = step(1.0 - galaxyDensity, hash(floor(galaxyPos)));\n if (galaxy > 0.0) {\n vec2 galaxyUV = fract(galaxyPos.xy) - 0.5;\n float galaxyDist = length(galaxyUV);\n float galaxyBright = exp(-galaxyDist * 15.0);\n // Spiral arm effect\n float angle = atan(galaxyUV.y, galaxyUV.x);\n float spiral = sin(angle * 2.0 + galaxyDist * 10.0 + time) * 0.3 + 0.7;\n vec3 galaxyColor = mix(vec3(1.0, 0.9, 0.7), vec3(0.7, 0.8, 1.0), hash(floor(galaxyPos) + 3.0));\n color += galaxyColor * galaxyBright * spiral * 0.5;\n }\n\n // Subtle animated shimmer\n float shimmer = noise(dir.xy * 100.0 + time * 2.0) * 0.02;\n color += vec3(shimmer);\n\n gl_FragColor = vec4(color, 1.0);\n }\n"}},Symbol.toStringTag,{value:"Module"}));class ha{constructor(e){return i(this,"loadShader",(e,t)=>{const{gl:n}=this.engine,i=n.createShader(e);if(n.shaderSource(i,t),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){const e=n.getShaderInfoLog(i);throw n.deleteShader(i),new Error(`An error occurred compiling the shaders: ${e}`)}return i}),i(this,"initTextureShaderProgram",({vs:e,fs:t})=>{const{gl:n}=this.engine,i=this,r=this.loadShader(n.VERTEX_SHADER,e),s=this.loadShader(n.FRAGMENT_SHADER,t);let a=n.createProgram();if(n.attachShader(a,r),n.attachShader(a,s),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS))throw new Error(`WebGL unable to initialize the shader program: ${a}`);return a.aVertexPosition=n.getAttribLocation(a,"aVertexPosition"),n.enableVertexAttribArray(a.aVertexPosition),a.uSkyboxTexture=n.getUniformLocation(a,"uSkyboxTexture"),a.uSkyboxCenter=n.getUniformLocation(a,"uSkyboxCenter"),a.uProjectionMatrix=n.getUniformLocation(a,"uProjectionMatrix"),a.uModelMatrix=n.getUniformLocation(a,"uModelMatrix"),a.uViewMatrix=n.getUniformLocation(a,"uViewMatrix"),a.setMatrixUniforms=function(){const e=i.uModelMat,t=i.camera.uViewMat,r=i.uProjMat;n.uniformMatrix4fv(this.uProjectionMatrix,!1,r),n.uniformMatrix4fv(this.uModelMatrix,!1,e),n.uniformMatrix4fv(this.uViewMatrix,!1,t)},this.shaderProgram=a,a}),ha.instance||(this.renderManager=e,this.engine=e.engine,ha.instance=this),ha.instance}async setSkyboxShader(e){if(!this.engine.gl)return;this.gl=this.engine.gl;const t=(await Gs(Object.assign({"../../shaders/skybox/cosmic/vs.js":()=>Promise.resolve().then(()=>la),"../../shaders/skybox/matrix/vs.js":()=>Promise.resolve().then(()=>ra),"../../shaders/skybox/morning/vs.js":()=>Promise.resolve().then(()=>Js),"../../shaders/skybox/neon/vs.js":()=>Promise.resolve().then(()=>aa),"../../shaders/skybox/sky/vs.js":()=>Promise.resolve().then(()=>ea),"../../shaders/skybox/sunset/vs.js":()=>Promise.resolve().then(()=>na)}),`../../shaders/skybox/${e}/vs.js`,6)).default(),n=(await Gs(Object.assign({"../../shaders/skybox/cosmic/fs.js":()=>Promise.resolve().then(()=>ca),"../../shaders/skybox/matrix/fs.js":()=>Promise.resolve().then(()=>sa),"../../shaders/skybox/morning/fs.js":()=>Promise.resolve().then(()=>Qs),"../../shaders/skybox/neon/fs.js":()=>Promise.resolve().then(()=>oa),"../../shaders/skybox/sky/fs.js":()=>Promise.resolve().then(()=>ta),"../../shaders/skybox/sunset/fs.js":()=>Promise.resolve().then(()=>ia)}),`../../shaders/skybox/${e}/fs.js`,6)).default();this.shaderProgram=this.initSkyboxShaderProgram(t,n)}async init(e=null,t="cosmic",n=[0,0,0]){if(this.engine.gl){if(this.gl=this.engine.gl,e)this.texture=await this.engine.resourceManager.loadTextureFromZip(e,this.engine.spritz.zip),this.texture.runWhenLoaded(this.createTextureSkyboxProgram);else{const e=(await import("../../shaders/skybox/"+t+"/vs.js")).default(),n=(await import("../../shaders/skybox/"+t+"/fs.js")).default();this.shaderProgram=this.initSkyboxShaderProgram(e,n)}this.cubeMap=this.createDefaultCubeMap(),this.skyboxCenter=n,this.buffer=this.createSkyboxBuffer(),this.initialized=!0}}createDefaultCubeMap(){const e=this.gl,t=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,t);return[{target:e.TEXTURE_CUBE_MAP_POSITIVE_X,color:[255,0,0,255]},{target:e.TEXTURE_CUBE_MAP_NEGATIVE_X,color:[0,255,0,255]},{target:e.TEXTURE_CUBE_MAP_POSITIVE_Y,color:[0,0,255,255]},{target:e.TEXTURE_CUBE_MAP_NEGATIVE_Y,color:[255,255,0,255]},{target:e.TEXTURE_CUBE_MAP_POSITIVE_Z,color:[0,255,255,255]},{target:e.TEXTURE_CUBE_MAP_NEGATIVE_Z,color:[255,0,255,255]}].forEach(t=>{const{target:n,color:i}=t,r=new Uint8Array(i);e.texImage2D(n,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r)}),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}createSkyboxBuffer(){this.vertices=[-1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1],this.numVertices=this.vertices.length/3;const e=this.gl.createBuffer();return this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.vertices),this.gl.STATIC_DRAW),e}initSkyboxShaderProgram(e,t){const{gl:n}=this.engine,i=this.loadShader(n.VERTEX_SHADER,e),r=this.loadShader(n.FRAGMENT_SHADER,t);let s=n.createProgram();if(n.attachShader(s,i),n.attachShader(s,r),n.linkProgram(s),!n.getProgramParameter(s,n.LINK_STATUS))throw new Error("WebGL unable to initialize the skybox shader program");return s.aPosition=n.getAttribLocation(s,"aPosition"),s.pMatrixUniform=n.getUniformLocation(s,"uProjectionMatrix"),s.uSkybox=n.getUniformLocation(s,"uSkybox"),s.uViewDirectionProjectionInverse=n.getUniformLocation(s,"uViewDirectionProjectionInverse"),s.uTime=n.getUniformLocation(s,"uTime"),s.uResolution=n.getUniformLocation(s,"uResolution"),s}renderSkybox(e){if(!this.initialized||!this.shaderProgram)return;const{gl:t}=this.engine;for(let i=0;i<8;i++)t.disableVertexAttribArray(i);t.useProgram(this.shaderProgram),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.enableVertexAttribArray(this.shaderProgram.aPosition),t.vertexAttribPointer(this.shaderProgram.aPosition,3,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_CUBE_MAP,this.cubeMap),t.uniform1i(this.shaderProgram.uSkybox,0),t.uniformMatrix4fv(this.shaderProgram.uViewDirectionProjectionInverse,!1,e);const n=.001*Date.now();if(-1!==this.shaderProgram.uTime&&null!==this.shaderProgram.uTime&&t.uniform1f(this.shaderProgram.uTime,n),void 0!==this.shaderProgram.uResolution){const e=t.drawingBufferWidth||this.engine.canvas.width||800,n=t.drawingBufferHeight||this.engine.canvas.height||600;t.uniform2f(this.shaderProgram.uResolution,e,n)}t.drawArrays(t.TRIANGLE_STRIP,0,this.numVertices),t.disableVertexAttribArray(this.shaderProgram.aPosition),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}createTextureSkyboxProgram(){return this.initShaderProgram({vs:"#version 300 es\n in vec3 aVertexPosition;\n uniform mat4 uProjectionMatrix;\n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n void main() {\n gl_Position = uProjectionMatrix * uModelMatrix * uViewMatrix * vec4(aVertexPosition, 1.0);\n }\n ",fs:"#version 300 es\n precision highp float;\n uniform sampler2D uSkyboxTexture;\n uniform vec3 uSkyboxCenter;\n out vec4 outColor;\n void main() {\n vec3 direction = normalize(gl_FragCoord.xyz - uSkyboxCenter);\n vec4 skyboxColor = texture(uSkyboxTexture, direction.xy);\n float dotProduct = dot(direction, skyboxColor.rgb);\n if (dotProduct < 0.01) {\n discard;\n } else {\n outColor = vec4(dotProduct, dotProduct, dotProduct, 1.0);\n }\n }\n "})}}class ua{constructor(e){i(this,"init",()=>{const e=this.engine.gl;if(!e)return;this.vertexPosBuf=this.renderManager.createBuffer([-.5,-.5,0,-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,.5,0,.5,-.5,0],e.STATIC_DRAW,3),this.vertexTexBuf=this.renderManager.createBuffer([0,0,0,1,1,1,0,0,1,1,1,0],e.STATIC_DRAW,2),this.initInstancedBuffers(),this.initialized=!0}),i(this,"initInstancedBuffers",()=>{const e=this.engine.gl;e&&(this.instancePositions=new Float32Array(3*this.maxInstances),this.instanceColors=new Float32Array(4*this.maxInstances),this.instanceSizes=new Float32Array(this.maxInstances),this.instancePositionBuf=e.createBuffer(),this.instanceColorBuf=e.createBuffer(),this.instanceSizeBuf=e.createBuffer())}),i(this,"updateInstanceBuffers",()=>{const e=this.engine.gl;if(!e||!this.particles.length)return 0;const t=Math.min(this.particles.length,this.maxInstances),n=this.renderManager.camera.cameraPosition,i=[...this.particles].sort((e,t)=>{const i=Math.pow(e.pos[0]-n.x,2)+Math.pow(e.pos[1]-n.y,2)+Math.pow(e.pos[2]-n.z,2);return Math.pow(t.pos[0]-n.x,2)+Math.pow(t.pos[1]-n.y,2)+Math.pow(t.pos[2]-n.z,2)-i});for(let r=0;r<t;r++){const e=i[r],t=e.age/e.life,n=Math.max(0,1-t*t);this.instancePositions[3*r]=e.pos[0],this.instancePositions[3*r+1]=e.pos[1],this.instancePositions[3*r+2]=e.pos[2],this.instanceColors[4*r]=e.color[0],this.instanceColors[4*r+1]=e.color[1],this.instanceColors[4*r+2]=e.color[2],this.instanceColors[4*r+3]=n,this.instanceSizes[r]=e.size}return e.bindBuffer(e.ARRAY_BUFFER,this.instancePositionBuf),e.bufferData(e.ARRAY_BUFFER,this.instancePositions.subarray(0,3*t),e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.instanceColorBuf),e.bufferData(e.ARRAY_BUFFER,this.instanceColors.subarray(0,4*t),e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.instanceSizeBuf),e.bufferData(e.ARRAY_BUFFER,this.instanceSizes.subarray(0,t),e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null),t}),i(this,"emit",(e=[0,0,0],t={})=>{let n=Array.isArray(e)?e:e.toArray?e.toArray():[0,0,0],i=n[0],r=n[1],s=n[2]||0,a=this.engine.spritz.world.zoneContaining(i,r),o=s;a&&(o+=a.getHeight(i,r)),n=[i,r,o];const l=Object.assign({count:8,life:1e3,speed:.02,spread:.5,size:.5,color:[1,.7,.2],gravity:[0,-98e-5,0],drag:.995},t);for(let c=0;c<l.count;c++){const e=(2*Math.random()-1)*l.spread,t=(2*Math.random()-1)*l.spread,i=(2*Math.random()-1)*l.spread,r=e*l.speed*(.5+1.5*Math.random()),s=t*l.speed*(.5+1.5*Math.random()),a=i*l.speed*(.5+1.5*Math.random()),o={pos:[n[0],n[1],n[2]],vel:[r,s,a],life:l.life,age:0,size:l.size*(.8+.8*Math.random()),color:l.color,gravity:l.gravity,drag:l.drag};this.particles.push(o)}}),i(this,"preset",e=>{switch((e||"").toLowerCase()){case"sparks":return{count:12,life:700,speed:.06,spread:1.2,size:.15,color:[1,.8,.2],gravity:[0,-.002,0]};case"flame":return{count:200,life:2e3,speed:.02,spread:.8,size:.06,color:[1,.5,.1],gravity:[0,-3e-4,0],drag:.995};case"water":return{count:20,life:800,speed:.05,spread:1.5,size:.12,color:[.6,.7,1],gravity:[0,-.003,0],drag:.996};case"weapon":return{count:6,life:600,speed:.08,spread:.3,size:.18,color:[1,1,.6],gravity:[0,-.001,0]};default:return null}}),i(this,"update",e=>{this.lastUpdateTime||(this.lastUpdateTime=e);const t=e-this.lastUpdateTime;if(this.lastUpdateTime=e,t)for(let n=this.particles.length-1;n>=0;n--){const e=this.particles[n];e.vel[0]+=(e.gravity[0]||0)*t,e.vel[1]+=(e.gravity[1]||0)*t,e.vel[2]+=(e.gravity[2]||0)*t,e.vel[0]*=Math.pow(e.drag||1,t/16.6667),e.vel[1]*=Math.pow(e.drag||1,t/16.6667),e.vel[2]*=Math.pow(e.drag||1,t/16.6667),e.pos[0]+=e.vel[0]*t,e.pos[1]+=e.vel[1]*t,e.pos[2]+=e.vel[2]*t,e.age+=t,e.age>=e.life&&this.particles.splice(n,1)}}),i(this,"render",()=>{if(this.initialized||this.init(),!this.initialized)return;if(!this.particles.length)return;const e=this.renderManager,t=this.engine.gl,n=e.particleShaderProgram;if(!n)return;"function"==typeof t.drawArraysInstanced&&this.useInstancing&&void 0!==n.aInstancePosition?this.renderInstanced():this.renderNonInstanced()}),i(this,"renderInstanced",()=>{const e=this.renderManager,t=this.engine.gl,n=e.particleShaderProgram,i=this.updateInstanceBuffers();if(0!==i){for(let e=0;e<8;e++)t.disableVertexAttribArray(e);t.useProgram(n),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE),t.depthMask(!1),t.enableVertexAttribArray(n.aVertexPosition),e.bindBuffer(this.vertexPosBuf,n.aVertexPosition),t.enableVertexAttribArray(n.aTextureCoord),e.bindBuffer(this.vertexTexBuf,n.aTextureCoord),void 0!==n.aInstancePosition&&(t.enableVertexAttribArray(n.aInstancePosition),t.bindBuffer(t.ARRAY_BUFFER,this.instancePositionBuf),t.vertexAttribPointer(n.aInstancePosition,3,t.FLOAT,!1,0,0),t.vertexAttribDivisor(n.aInstancePosition,1)),void 0!==n.aInstanceColor&&(t.enableVertexAttribArray(n.aInstanceColor),t.bindBuffer(t.ARRAY_BUFFER,this.instanceColorBuf),t.vertexAttribPointer(n.aInstanceColor,4,t.FLOAT,!1,0,0),t.vertexAttribDivisor(n.aInstanceColor,1)),void 0!==n.aInstanceSize&&(t.enableVertexAttribArray(n.aInstanceSize),t.bindBuffer(t.ARRAY_BUFFER,this.instanceSizeBuf),t.vertexAttribPointer(n.aInstanceSize,1,t.FLOAT,!1,0,0),t.vertexAttribDivisor(n.aInstanceSize,1)),n.setMatrixUniforms&&n.setMatrixUniforms({}),t.drawArraysInstanced(t.TRIANGLES,0,6,i),void 0!==n.aInstancePosition&&(t.vertexAttribDivisor(n.aInstancePosition,0),t.disableVertexAttribArray(n.aInstancePosition)),void 0!==n.aInstanceColor&&(t.vertexAttribDivisor(n.aInstanceColor,0),t.disableVertexAttribArray(n.aInstanceColor)),void 0!==n.aInstanceSize&&(t.vertexAttribDivisor(n.aInstanceSize,0),t.disableVertexAttribArray(n.aInstanceSize)),t.depthMask(!0),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.disableVertexAttribArray(n.aVertexPosition),t.disableVertexAttribArray(n.aTextureCoord),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}}),i(this,"renderNonInstanced",()=>{const e=this.renderManager,t=this.engine.gl,n=e.particleShaderProgram;for(let s=0;s<8;s++)t.disableVertexAttribArray(s);t.useProgram(n),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE),t.depthMask(!1),t.enableVertexAttribArray(n.aVertexPosition),t.enableVertexAttribArray(n.aTextureCoord);const i=e.camera.cameraPosition,r=[...this.particles].sort((e,t)=>{const n=Math.pow(e.pos[0]-i.x,2)+Math.pow(e.pos[1]-i.y,2)+Math.pow(e.pos[2]-i.z,2);return Math.pow(t.pos[0]-i.x,2)+Math.pow(t.pos[1]-i.y,2)+Math.pow(t.pos[2]-i.z,2)-n});for(const s of r){e.mvPushMatrix();const i=e.uModelMat;for(let e=0;e<16;e++)i[e]=e%5==0?1:0;i[12]=s.pos[0],i[13]=s.pos[1],i[14]=s.pos[2];const r=s.age/s.life,a=Math.max(0,1-r*r),o=new ot(s.size,s.size,s.size);n.setMatrixUniforms({scale:o,color:s.color,alpha:a}),e.bindBuffer(this.vertexPosBuf,n.aVertexPosition),e.bindBuffer(this.vertexTexBuf,n.aTextureCoord),t.drawArrays(t.TRIANGLES,0,this.vertexPosBuf.numItems),e.mvPopMatrix()}t.depthMask(!0),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.disableVertexAttribArray(n.aVertexPosition),t.disableVertexAttribArray(n.aTextureCoord),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}),i(this,"getParticleCount",()=>this.particles.length),i(this,"clear",()=>{this.particles=[]}),i(this,"setInstancingEnabled",e=>{this.useInstancing=e}),this.renderManager=e,this.engine=e.engine,this.particles=[],this.initialized=!1,this.vertexPosBuf=null,this.vertexTexBuf=null,this.lastUpdateTime=null,this.instancePositionBuf=null,this.instanceColorBuf=null,this.instanceSizeBuf=null,this.useInstancing=!0,this.maxInstances=1e4,this.instancePositions=null,this.instanceColors=null,this.instanceSizes=null}}class da{constructor(e=0,t=0,n=0,i=0){this.a=e,this.b=t,this.c=n,this.d=i}normalize(){const e=Math.sqrt(this.a*this.a+this.b*this.b+this.c*this.c);return e>0&&(this.a/=e,this.b/=e,this.c/=e,this.d/=e),this}distanceToPoint(e){return this.a*e.x+this.b*e.y+this.c*e.z+this.d}}class fa{constructor(e=new ot(0,0,0),t=new ot(0,0,0)){this.min=e,this.max=t}getCenter(){return new ot((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,(this.min.z+this.max.z)/2)}getHalfExtents(){return new ot((this.max.x-this.min.x)/2,(this.max.y-this.min.y)/2,(this.max.z-this.min.z)/2)}static fromCenterSize(e,t){const n=new ot(t.x/2,t.y/2,t.z/2);return new fa(new ot(e.x-n.x,e.y-n.y,e.z-n.z),new ot(e.x+n.x,e.y+n.y,e.z+n.z))}}class pa{constructor(e=new ot(0,0,0),t=0){this.center=e,this.radius=t}static fromAABB(e){const t=e.getCenter(),n=e.getHalfExtents(),i=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);return new pa(t,i)}}class ga{constructor(){this.planes=[new da,new da,new da,new da,new da,new da]}setFromMatrix(e){const t=e;this.planes[0].a=t[3]+t[0],this.planes[0].b=t[7]+t[4],this.planes[0].c=t[11]+t[8],this.planes[0].d=t[15]+t[12],this.planes[0].normalize(),this.planes[1].a=t[3]-t[0],this.planes[1].b=t[7]-t[4],this.planes[1].c=t[11]-t[8],this.planes[1].d=t[15]-t[12],this.planes[1].normalize(),this.planes[2].a=t[3]+t[1],this.planes[2].b=t[7]+t[5],this.planes[2].c=t[11]+t[9],this.planes[2].d=t[15]+t[13],this.planes[2].normalize(),this.planes[3].a=t[3]-t[1],this.planes[3].b=t[7]-t[5],this.planes[3].c=t[11]-t[9],this.planes[3].d=t[15]-t[13],this.planes[3].normalize(),this.planes[4].a=t[3]+t[2],this.planes[4].b=t[7]+t[6],this.planes[4].c=t[11]+t[10],this.planes[4].d=t[15]+t[14],this.planes[4].normalize(),this.planes[5].a=t[3]-t[2],this.planes[5].b=t[7]-t[6],this.planes[5].c=t[11]-t[10],this.planes[5].d=t[15]-t[14],this.planes[5].normalize()}containsPoint(e){for(const t of this.planes)if(t.distanceToPoint(e)<0)return!1;return!0}testSphere(e){let t=!0;for(const n of this.planes){const i=n.distanceToPoint(e.center);if(i<-e.radius)return"outside";i<e.radius&&(t=!1)}return t?"inside":"intersect"}testAABB(e){let t=!0;for(const n of this.planes){const i=n.a>=0?e.max.x:e.min.x,r=n.b>=0?e.max.y:e.min.y,s=n.c>=0?e.max.z:e.min.z,a=n.a>=0?e.min.x:e.max.x,o=n.b>=0?e.min.y:e.max.y,l=n.c>=0?e.min.z:e.max.z;if(n.a*i+n.b*r+n.c*s+n.d<0)return"outside";n.a*a+n.b*o+n.c*l+n.d<0&&(t=!1)}return t?"inside":"intersect"}}class ma{constructor(e){this.renderManager=e,this.frustum=new ga,this.enabled=!0,this.debug={totalObjects:0,culledObjects:0,visibleObjects:0}}update(e,t){if(!this.enabled)return;const n=this._multiplyMatrices(e,t);this.frustum.setFromMatrix(n)}cull(e,t){if(!this.enabled)return this.debug.totalObjects=e.length,this.debug.visibleObjects=e.length,this.debug.culledObjects=0,e;const n=[];this.debug.totalObjects=e.length;for(const i of e){const e=t(i);if(!e){n.push(i);continue}let r;if(e instanceof pa)r=this.frustum.testSphere(e);else{if(!(e instanceof fa)){n.push(i);continue}r=this.frustum.testAABB(e)}"outside"!==r&&n.push(i)}return this.debug.visibleObjects=n.length,this.debug.culledObjects=e.length-n.length,n}isPointVisible(e){return!this.enabled||this.frustum.containsPoint(e)}isSphereVisible(e,t){if(!this.enabled)return!0;const n=new pa(e,t);return"outside"!==this.frustum.testSphere(n)}isAABBVisible(e,t){if(!this.enabled)return!0;const n=new fa(e,t);return"outside"!==this.frustum.testAABB(n)}setEnabled(e){this.enabled=e}getStats(){const e=this.debug.totalObjects>0?(this.debug.culledObjects/this.debug.totalObjects*100).toFixed(1):0;return{...this.debug,cullRate:`${e}%`}}_multiplyMatrices(e,t){const n=new Float32Array(16);for(let i=0;i<4;i++)for(let r=0;r<4;r++)n[4*r+i]=e[i]*t[4*r]+e[i+4]*t[4*r+1]+e[i+8]*t[4*r+2]+e[i+12]*t[4*r+3];return n}}const ya={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeOutElastic:e=>Math.pow(2,-10*e)*Math.sin((e-.075)*(2*Math.PI)/.3)+1,easeOutBounce:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375};class ba{constructor(e){this.camera=e,this.shake={active:!1,intensity:0,decay:.9,duration:0,elapsed:0,offset:new ot(0,0,0),type:"random",frequency:1},this.follow={active:!1,target:null,offset:new ot(0,0,0),smoothness:.1,deadzone:new ot(0,0,0),bounds:null},this.zoom={active:!1,targetZoom:1,currentZoom:1,speed:.1},this.flash={active:!1,color:[1,1,1,1],duration:0,elapsed:0},this.fade={active:!1,color:[0,0,0,1],targetAlpha:0,currentAlpha:0,duration:0,elapsed:0,easing:"easeInOutQuad",onComplete:null},this.punch={active:!1,direction:new ot(0,0,0),intensity:0,duration:0,elapsed:0}}update(e){this._updateShake(e),this._updateFollow(e),this._updateZoom(e),this._updateFlash(e),this._updateFade(e),this._updatePunch(e)}startShake(e){this.shake.active=!0,this.shake.intensity=e.intensity||1,this.shake.duration=e.duration||.5,this.shake.elapsed=0,this.shake.decay=e.decay??.9,this.shake.type=e.type||"random",this.shake.frequency=e.frequency||1}stopShake(){this.shake.active=!1,this.shake.offset=new ot(0,0,0)}getShakeOffset(){return this.shake.offset}_updateShake(e){if(!this.shake.active)return;if(this.shake.elapsed+=e,this.shake.elapsed>=this.shake.duration)return void this.stopShake();const t=this.shake.elapsed/this.shake.duration,n=this.shake.intensity*(1-t)*this.shake.decay,i=this.shake.elapsed*this.shake.frequency*10;switch(this.shake.type){case"horizontal":this.shake.offset=new ot((2*Math.sin(i)-1)*n,0,0);break;case"vertical":this.shake.offset=new ot(0,(2*Math.sin(i)-1)*n,0);break;case"rotational":this.shake.offset=new ot(0,0,(2*Math.sin(i)-1)*n*.1);break;default:this.shake.offset=new ot((2*Math.random()-1)*n,(2*Math.random()-1)*n,0)}}startFollow(e,t={}){this.follow.active=!0,this.follow.target=e,this.follow.offset=t.offset||new ot(0,0,0),this.follow.smoothness=t.smoothness??.1,this.follow.deadzone=t.deadzone||new ot(0,0,0),this.follow.bounds=t.bounds||null}stopFollow(){this.follow.active=!1,this.follow.target=null}getFollowTarget(){if(!this.follow.active||!this.follow.target)return null;const e=this.follow.target.position||this.follow.target;return e.add?e.add(this.follow.offset):new ot(e.x+this.follow.offset.x,e.y+this.follow.offset.y,e.z+this.follow.offset.z)}_updateFollow(e){if(!this.follow.active||!this.follow.target)return;const t=this.getFollowTarget();if(!t)return;const n=this.camera.cameraTarget||this.camera.cameraPosition;let i=t.x-n.x,r=t.y-n.y,s=t.z-n.z;Math.abs(i)<this.follow.deadzone.x&&(i=0),Math.abs(r)<this.follow.deadzone.y&&(r=0),Math.abs(s)<this.follow.deadzone.z&&(s=0);const a=1-Math.pow(1-this.follow.smoothness,60*e);let o=n.x+i*a,l=n.y+r*a,c=n.z+s*a;this.follow.bounds&&(o=Math.max(this.follow.bounds.min.x,Math.min(this.follow.bounds.max.x,o)),l=Math.max(this.follow.bounds.min.y,Math.min(this.follow.bounds.max.y,l)),c=Math.max(this.follow.bounds.min.z,Math.min(this.follow.bounds.max.z,c))),this.camera.setTarget?this.camera.setTarget(new ot(o,l,c)):this.camera.cameraTarget=new ot(o,l,c)}zoomTo(e,t=.1){this.zoom.active=!0,this.zoom.targetZoom=e,this.zoom.speed=t}_updateZoom(e){var t,n;if(!this.zoom.active)return;const i=this.zoom.targetZoom-this.zoom.currentZoom;if(Math.abs(i)<.001)return this.zoom.currentZoom=this.zoom.targetZoom,void(this.zoom.active=!1);this.zoom.currentZoom+=i*this.zoom.speed*e*60,this.camera.zoom&&(this.camera.cameraDistance=15/this.zoom.currentZoom,null==(n=(t=this.camera).updateViewFromAngles)||n.call(t))}flash(e={}){this.flash.active=!0,this.flash.color=e.color||[1,1,1,1],this.flash.duration=e.duration||.1,this.flash.elapsed=0}getFlashColor(){if(!this.flash.active)return null;const e=this.flash.elapsed/this.flash.duration,t=this.flash.color[3]*(1-e);return[this.flash.color[0],this.flash.color[1],this.flash.color[2],t]}_updateFlash(e){this.flash.active&&(this.flash.elapsed+=e,this.flash.elapsed>=this.flash.duration&&(this.flash.active=!1))}fadeTo(e){this.fade.active=!0,this.fade.targetAlpha=e.targetAlpha,this.fade.duration=e.duration||1,this.fade.elapsed=0,this.fade.color=e.color||[0,0,0,1],this.fade.easing=e.easing||"easeInOutQuad",this.fade.onComplete=e.onComplete||null,this.fade.startAlpha=this.fade.currentAlpha}fadeToBlack(e=1,t=null){this.fadeTo({targetAlpha:1,duration:e,color:[0,0,0,1],onComplete:t})}fadeFromBlack(e=1,t=null){this.fade.currentAlpha=1,this.fadeTo({targetAlpha:0,duration:e,color:[0,0,0,1],onComplete:t})}getFadeColor(){return this.fade.currentAlpha<=0?null:[this.fade.color[0],this.fade.color[1],this.fade.color[2],this.fade.currentAlpha]}_updateFade(e){if(!this.fade.active)return;if(this.fade.elapsed+=e,this.fade.elapsed>=this.fade.duration)return this.fade.currentAlpha=this.fade.targetAlpha,this.fade.active=!1,void(this.fade.onComplete&&this.fade.onComplete());const t=this.fade.elapsed/this.fade.duration,n=(ya[this.fade.easing]||ya.linear)(t),i=this.fade.startAlpha??0;this.fade.currentAlpha=i+(this.fade.targetAlpha-i)*n}punch(e,t=1,n=.2){this.punch.active=!0,this.punch.direction=e.normal?e.normal():e,this.punch.intensity=t,this.punch.duration=n,this.punch.elapsed=0}getPunchOffset(){if(!this.punch.active)return new ot(0,0,0);const e=this.punch.elapsed/this.punch.duration,t=ya.easeOutElastic(e),n=this.punch.intensity*(1-t);return new ot(this.punch.direction.x*n,this.punch.direction.y*n,this.punch.direction.z*n)}_updatePunch(e){this.punch.active&&(this.punch.elapsed+=e,this.punch.elapsed>=this.punch.duration&&(this.punch.active=!1))}getTotalOffset(){const e=this.getShakeOffset(),t=this.getPunchOffset();return new ot(e.x+t.x,e.y+t.y,e.z+t.z)}}class va{constructor(e){this.renderManager=e,this.lodConfigs=new Map,this.currentLOD=new Map,this.lastUpdateTime=0,this.updateInterval=100,this.defaultLevels=[{distance:10,detail:1},{distance:25,detail:.75},{distance:50,detail:.5},{distance:100,detail:.25},{distance:1/0,detail:.1}],this.enabled=!0,this.debug=!1}register(e,t){const n=[...t.levels].sort((e,t)=>e.distance-t.distance);this.lodConfigs.set(e,{levels:n,hysteresis:t.hysteresis??.1,updateInterval:t.updateInterval??this.updateInterval}),this.currentLOD.set(e,0)}unregister(e){this.lodConfigs.delete(e),this.currentLOD.delete(e)}getConfig(e){return this.lodConfigs.get(e)||null}calculateLODLevel(e,t,n,i){const r=t*(1+i);for(let s=0;s<e.length;s++){if((s<n?t:r)<=e[s].distance)return s}return e.length-1}getLOD(e,t){if(!this.enabled)return{distance:0,detail:1};const n=this.renderManager.camera.cameraPosition,i=t instanceof ot?t:new ot(...t),r=i.x-n.x,s=i.y-n.y,a=i.z-n.z,o=Math.sqrt(r*r+s*s+a*a),l=this.lodConfigs.get(e),c=(null==l?void 0:l.levels)||this.defaultLevels,h=(null==l?void 0:l.hysteresis)??.1,u=this.currentLOD.get(e)??0,d=this.calculateLODLevel(c,o,u,h);return this.currentLOD.set(e,d),this.debug&&d!==u&&console.log(`[LOD] ${e}: Level ${u} -> ${d} (distance: ${o.toFixed(1)})`),c[d]}getDetailFactor(e,t){return this.getLOD(e,t).detail}shouldUseHighDetail(e,t,n=.5){return this.getDetailFactor(e,t)>=n}batchUpdate(e){const t=new Map;for(const n of e)t.set(n.id,this.getLOD(n.id,n.position));return t}getRenderSettings(e){return{castShadow:e>=.5,receiveShadow:e>=.25,animationQuality:e>=.75?"full":e>=.5?"reduced":"minimal",useSecondaryEffects:e>=.75,textureFiltering:e>=.5?"trilinear":"bilinear",useNormalMap:e>=.5,particleCountMultiplier:Math.max(.1,e)}}setBias(e){this.defaultLevels=this.defaultLevels.map((t,n)=>({...t,distance:t.distance===1/0?1/0:this.defaultLevels[n].distance*e}))}setEnabled(e){this.enabled=e}reset(){this.currentLOD.clear()}getStats(){const e={totalEntities:this.currentLOD.size,byLevel:new Map};for(const[,t]of this.currentLOD){const n=e.byLevel.get(t)||0;e.byLevel.set(t,n+1)}return e}}class wa{constructor(e){this.renderManager=e,this.atlasTextures=new Map,this.atlasEntries=new Map,this.atlasDimensions=new Map,this.batchQueue=[],this.compiledBatches=new Map,this.maxAtlasSize=4096,this.padding=2,this.enabled=!0,this.drawCallsThisFrame=0,this.drawCallsSaved=0,this.batchVertexBuffer=null,this.batchTexCoordBuffer=null,this.batchIndexBuffer=null,this.maxSpritesPerBatch=1e4,this.sharedVertices=new Float32Array(12*this.maxSpritesPerBatch),this.sharedTexCoords=new Float32Array(8*this.maxSpritesPerBatch),this.sharedIndices=new Uint16Array(6*this.maxSpritesPerBatch)}init(){const e=this.renderManager.engine.gl;if(e){this.batchVertexBuffer=e.createBuffer(),this.batchTexCoordBuffer=e.createBuffer(),this.batchIndexBuffer=e.createBuffer();for(let e=0;e<this.maxSpritesPerBatch;e++){const t=6*e,n=4*e;this.sharedIndices[t+0]=n+0,this.sharedIndices[t+1]=n+1,this.sharedIndices[t+2]=n+2,this.sharedIndices[t+3]=n+0,this.sharedIndices[t+4]=n+2,this.sharedIndices[t+5]=n+3}}}createAtlas(e,t){const n=this.renderManager.engine.gl;if(!n)return new Map;const i=[...t].sort((e,t)=>{const n=e.image.height||e.image.naturalHeight;return(t.image.height||t.image.naturalHeight)-n});let r=0;for(const f of i){r+=((f.image.width||f.image.naturalWidth)+this.padding)*((f.image.height||f.image.naturalHeight)+this.padding)}let s=64;for(;s*s<1.2*r&&s<this.maxAtlasSize;)s*=2;const a=document.createElement("canvas");a.width=s,a.height=s;const o=a.getContext("2d"),l=new Map;let c=0,h=0,u=0;for(const f of i){const t=f.image.width||f.image.naturalWidth,n=f.image.height||f.image.naturalHeight;if(u+t+this.padding>s&&(c+=h+this.padding,h=0,u=0),c+n+this.padding>s){console.warn(`TextureAtlas: Image ${f.id} doesn't fit in atlas ${e}`);continue}o.drawImage(f.image,u,c);const i={id:f.id,x:u,y:c,width:t,height:n,u0:u/s,v0:c/s,u1:(u+t)/s,v1:(c+n)/s};l.set(f.id,i),u+=t+this.padding,h=Math.max(h,n)}const d=n.createTexture();return n.bindTexture(n.TEXTURE_2D,d),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,a),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),this.atlasTextures.set(e,d),this.atlasEntries.set(e,l),this.atlasDimensions.set(e,{width:s,height:s}),l}getEntry(e,t){const n=this.atlasEntries.get(e);return n&&n.get(t)||null}queueSprite(e,t,n,i,r,s,a,o="sprite",l=0){const c=this.getEntry(e,t);if(!c)return;const h=s/2,u=a/2,d=new Float32Array([n-h,i-u,r,n+h,i-u,r,n+h,i+u,r,n-h,i+u,r]),f=new Float32Array([c.u0,c.v1,c.u1,c.v1,c.u1,c.v0,c.u0,c.v0]),p=new Uint16Array([0,1,2,0,2,3]);this.batchQueue.push({vertices:d,texCoords:f,indices:p,textureId:e,shaderId:o,priority:l})}compileBatches(){if(0===this.batchQueue.length)return;this.batchQueue.sort((e,t)=>e.priority!==t.priority?e.priority-t.priority:e.textureId!==t.textureId?e.textureId.localeCompare(t.textureId):e.shaderId.localeCompare(t.shaderId)),this.compiledBatches.clear();let e="",t=null,n=0,i=0,r=0;for(const s of this.batchQueue){const a=`${s.textureId}|${s.shaderId}`;(a!==e||r+4>65535)&&(t&&this.finalizeBatch(t,n,i),e=a,t={texture:this.atlasTextures.get(s.textureId),shaderId:s.shaderId,vertices:this.sharedVertices,texCoords:this.sharedTexCoords,indices:this.sharedIndices,count:0},n=0,i=0,r=0);for(let e=0;e<s.vertices.length;e++)this.sharedVertices[3*n+e]=s.vertices[e];for(let e=0;e<s.texCoords.length;e++)this.sharedTexCoords[2*n+e]=s.texCoords[e];for(let e=0;e<s.indices.length;e++)this.sharedIndices[i+e]=s.indices[e]+r;n+=4,i+=6,r+=4,t.count+=6}t&&(this.finalizeBatch(t,n,i),this.compiledBatches.set(e,t)),this.drawCallsSaved=this.batchQueue.length-this.compiledBatches.size}finalizeBatch(e,t,n){e.vertices=new Float32Array(this.sharedVertices.buffer,0,3*t),e.texCoords=new Float32Array(this.sharedTexCoords.buffer,0,2*t),e.indices=new Uint16Array(this.sharedIndices.buffer,0,n)}renderBatches(e){const t=this.renderManager.engine.gl;if(t&&0!==this.compiledBatches.size){this.drawCallsThisFrame=0;for(const[n,i]of this.compiledBatches){if(!i.texture||0===i.count)continue;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,i.texture),t.bindBuffer(t.ARRAY_BUFFER,this.batchVertexBuffer),t.bufferData(t.ARRAY_BUFFER,i.vertices,t.DYNAMIC_DRAW);const n=t.getAttribLocation(e,"aVertexPosition");n>=0&&(t.enableVertexAttribArray(n),t.vertexAttribPointer(n,3,t.FLOAT,!1,0,0)),t.bindBuffer(t.ARRAY_BUFFER,this.batchTexCoordBuffer),t.bufferData(t.ARRAY_BUFFER,i.texCoords,t.DYNAMIC_DRAW);const r=t.getAttribLocation(e,"aTextureCoord");r>=0&&(t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0)),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.batchIndexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i.indices,t.DYNAMIC_DRAW),t.drawElements(t.TRIANGLES,i.count,t.UNSIGNED_SHORT,0),this.drawCallsThisFrame++}}}clearQueue(){this.batchQueue.length=0,this.compiledBatches.clear()}getStats(){return{drawCalls:this.drawCallsThisFrame,saved:this.drawCallsSaved,batches:this.compiledBatches.size,sprites:this.batchQueue.length}}dispose(){const e=this.renderManager.engine.gl;if(e){for(const t of this.atlasTextures.values())e.deleteTexture(t);this.atlasTextures.clear(),this.atlasEntries.clear(),this.atlasDimensions.clear(),this.clearQueue(),this.batchVertexBuffer&&e.deleteBuffer(this.batchVertexBuffer),this.batchTexCoordBuffer&&e.deleteBuffer(this.batchTexCoordBuffer),this.batchIndexBuffer&&e.deleteBuffer(this.batchIndexBuffer)}}}function xa(e){const{gl:t}=this.engine,n=this;return e.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),e.aVertexPosition>=0&&t.enableVertexAttribArray(e.aVertexPosition),e.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),e.aTextureCoord>=0&&t.enableVertexAttribArray(e.aTextureCoord),e.aVertexNormal=t.getAttribLocation(e,"aVertexNormal"),e.aVertexNormal>=0&&t.enableVertexAttribArray(e.aVertexNormal),e.pMatrixUniform=t.getUniformLocation(e,"uProjectionMatrix"),e.mMatrixUniform=t.getUniformLocation(e,"uModelMatrix"),e.vMatrixUniform=t.getUniformLocation(e,"uViewMatrix"),e.samplerUniform=t.getUniformLocation(e,"uSampler"),e.useSampler=t.getUniformLocation(e,"useSampler"),e.scale=t.getUniformLocation(e,"u_scale"),e.id=t.getUniformLocation(e,"u_id"),e.setMatrixUniforms=({scale:i=null,id:r=null,sampler:s=1})=>{t.uniformMatrix4fv(e.pMatrixUniform,!1,n.uProjMat),t.uniformMatrix4fv(e.mMatrixUniform,!1,n.uModelMat),t.uniformMatrix4fv(e.vMatrixUniform,!1,n.camera.uViewMat),t.uniform3fv(e.scale,i?i.toArray():n.scale.toArray()),t.uniform4fv(e.id,r||[1,0,0,0]),t.uniform1f(e.useSampler,s),t.uniform1i(e.samplerUniform,0)},e}class _a{constructor(e){return i(this,"init",()=>{const{spritz:e,gl:t}=this.engine;if(t.clearColor(0,1,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),this.framebuffer=t.createFramebuffer(),this.initShaderProgram(e.shaders),this.initParticleShaderProgram(),this.initShaderEffects({id:"picker",vs:"\n attribute vec3 aVertexPosition;\n attribute vec2 aTextureCoord;\n \n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjectionMatrix;\n \n varying vec4 vWorldVertex;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n uniform vec3 u_scale;\n \n void main() {\n // Multiply the position by the matrix.\n vec3 scaledPosition = aVertexPosition * u_scale;\n vTextureCoord = aTextureCoord;\n \n vWorldVertex = uModelMatrix * vec4(aVertexPosition, 1.0);\n vPosition = uModelMatrix * vec4(scaledPosition, 1.0);\n\n gl_Position = uProjectionMatrix * uViewMatrix * vPosition;\n }\n ",fs:"\n precision highp float;\n \n uniform vec4 u_id;\n uniform float useSampler;\n uniform sampler2D uSampler;\n\n varying vec2 vTextureCoord;\n\n void main() {\n if(useSampler == 1.0) { // sampler\n vec4 texelColors = texture2D(uSampler, vTextureCoord);\n gl_FragColor= vec4(vec3(u_id),texelColors.a);\n } else {\n gl_FragColor = vec4(vec3(u_id),1.0);\n }\n }\n ",init:xa}),e.effects)for(let n in e.effects);this.initProjection(),this.skyboxManager.init(),this.textureAtlas.init(),this.initializedWebGl=!0}),i(this,"loadShader",(e,t)=>{const{gl:n}=this.engine,i=n.createShader(e);if(n.shaderSource(i,t),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){const e=n.getShaderInfoLog(i);throw n.deleteShader(i),new Error(`An error occurred compiling the shaders: ${e}`)}return i}),i(this,"initShaderProgram",({vs:e,fs:t})=>{const{gl:n}=this.engine,i=this,r=this.loadShader(n.VERTEX_SHADER,e),s=this.loadShader(n.FRAGMENT_SHADER,t);let a=n.createProgram();if(n.attachShader(a,r),n.attachShader(a,s),n.bindAttribLocation(a,0,"aVertexPosition"),n.bindAttribLocation(a,1,"aTextureCoord"),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS))throw new Error(`WebGL unable to initialize the shader program: ${n.getProgramInfoLog(a)}`);a.aVertexNormal=n.getAttribLocation(a,"aVertexNormal"),a.aVertexPosition=n.getAttribLocation(a,"aVertexPosition"),a.aTextureCoord=n.getAttribLocation(a,"aTextureCoord"),a.uDiffuse=n.getUniformLocation(a,"uDiffuse"),a.uSpecular=n.getUniformLocation(a,"uSpecular"),a.uSpecularExponent=n.getUniformLocation(a,"uSpecularExponent"),a.pMatrixUniform=n.getUniformLocation(a,"uProjectionMatrix"),a.mMatrixUniform=n.getUniformLocation(a,"uModelMatrix"),a.vMatrixUniform=n.getUniformLocation(a,"uViewMatrix"),a.nMatrixUniform=n.getUniformLocation(a,"uNormalMatrix"),a.samplerUniform=n.getUniformLocation(a,"uSampler"),a.diffuseMapUniform=n.getUniformLocation(a,"uDiffuseMap"),a.cameraPosition=n.getUniformLocation(a,"uCameraPosition"),a.runTransition=n.getUniformLocation(a,"runTransition"),a.useSampler=n.getUniformLocation(a,"useSampler"),a.useDiffuse=n.getUniformLocation(a,"useDiffuse"),a.isSelected=n.getUniformLocation(a,"isSelected"),a.colorMultiplier=n.getUniformLocation(a,"uColorMultiplier"),a.scale=n.getUniformLocation(a,"u_scale"),a.id=n.getUniformLocation(a,"u_id"),a.maxLights=32,a.uLights=[];for(let l=0;l<a.maxLights;l++)a.uLights[l]={enabled:n.getUniformLocation(a,`uLights[${l}].enabled`),color:n.getUniformLocation(a,`uLights[${l}].color`),position:n.getUniformLocation(a,`uLights[${l}].position`),attenuation:n.getUniformLocation(a,`uLights[${l}].attenuation`),direction:n.getUniformLocation(a,`uLights[${l}].direction`),scatteringCoefficients:n.getUniformLocation(a,`uLights[${l}].scatteringCoefficients`),density:n.getUniformLocation(a,`uLights[${l}].density`)};a.setMatrixUniforms=function({id:e=null,scale:t=null,sampler:r=1,isSelected:s=!1,colorMultiplier:o=null}){var l,c,h,u,d,f,p,g,m,y,b,v,w,x,_,k,S,M,A,T,E,P,C,z,L,I,D,R,O,B,F;n.useProgram(a),n.uniformMatrix4fv(this.pMatrixUniform,!1,i.uProjMat),n.uniformMatrix4fv(this.mMatrixUniform,!1,i.uModelMat),n.uniformMatrix4fv(this.vMatrixUniform,!1,i.camera.uViewMat),i.normalMatrix=vs(),l=i.normalMatrix,c=i.uModelMat,h=c[0],u=c[1],d=c[2],f=c[3],p=c[4],g=c[5],m=c[6],y=c[7],b=c[8],v=c[9],w=c[10],x=c[11],_=c[12],k=c[13],S=c[14],M=c[15],(F=(A=h*g-u*p)*(B=w*M-x*S)-(T=h*m-d*p)*(O=v*M-x*k)+(E=h*y-f*p)*(R=v*S-w*k)+(P=u*m-d*g)*(D=b*M-x*_)-(C=u*y-f*g)*(I=b*S-w*_)+(z=d*y-f*m)*(L=b*k-v*_))&&(F=1/F,l[0]=(g*B-m*O+y*R)*F,l[1]=(m*D-p*B-y*I)*F,l[2]=(p*O-g*D+y*L)*F,l[3]=(d*O-u*B-f*R)*F,l[4]=(h*B-d*D+f*I)*F,l[5]=(u*D-h*O-f*L)*F,l[6]=(k*z-S*C+M*P)*F,l[7]=(S*E-_*z-M*T)*F,l[8]=(_*C-k*E+M*A)*F),n.uniformMatrix3fv(this.nMatrixUniform,!1,i.normalMatrix),n.uniform3fv(this.scale,t?t.toArray():i.scale.toArray()),n.uniform4fv(this.id,e||[1,0,0,0]),n.uniform1f(this.isSelected,s?1:0),n.uniform4fv(this.colorMultiplier,o||[1,1,1,1]),n.uniform1f(this.useSampler,r),n.uniform1f(this.runTransition,i.isTransitioning?1:0),n.uniform3fv(this.cameraPosition,i.camera.cameraPosition.toArray()),i.lightManager.setMatrixUniforms()};const o={aVertexPosition:js.Layout.POSITION.key,aVertexNormal:js.Layout.NORMAL.key,aTextureCoord:js.Layout.UV.key};return a.applyAttributePointers=function(e){const t=e.vertexBuffer.layout;for(const i in o){if(!o.hasOwnProperty(i)||-1===a[i])continue;const e=o[i];if(-1!==a[i]){const r=t.attributeMap[e];n.vertexAttribPointer(a[i],r.size,n[r.type],r.normalized,r.stride,r.offset)}}},this.shaderProgram=a,a}),i(this,"initParticleShaderProgram",()=>{const{gl:e}=this.engine,t=this,n=this.loadShader(e.VERTEX_SHADER,"\n attribute vec3 aVertexPosition;\n attribute vec2 aTextureCoord;\n\n uniform mat4 uProjectionMatrix;\n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform vec3 uScale;\n uniform vec3 uParticleColor;\n uniform float uAlpha;\n\n varying vec2 vTextureCoord;\n varying vec3 vColor;\n varying float vAlpha;\n\n void main(void) {\n // Extract world position from model matrix (translation component)\n vec3 particleWorldPos = vec3(uModelMatrix[3][0], uModelMatrix[3][1], uModelMatrix[3][2]);\n \n // Transform particle center to view space\n vec4 viewPosition = uViewMatrix * vec4(particleWorldPos, 1.0);\n \n // Apply billboarding in view space - offset by scaled vertex position\n // This keeps the quad always facing the camera\n vec3 billboardOffset = vec3(\n aVertexPosition.x * uScale.x,\n aVertexPosition.y * uScale.y,\n 0.0 // No z offset - quad stays flat to camera\n );\n viewPosition.xyz += billboardOffset;\n\n // Output position\n gl_Position = uProjectionMatrix * viewPosition;\n\n // Pass texture coordinates, color, and alpha to fragment shader\n vTextureCoord = aTextureCoord;\n vColor = uParticleColor;\n vAlpha = uAlpha;\n }\n "),i=this.loadShader(e.FRAGMENT_SHADER,"\n precision mediump float;\n\n varying vec2 vTextureCoord;\n varying vec3 vColor;\n varying float vAlpha;\n\n void main(void) {\n // Calculate distance from center for soft circular particles\n vec2 center = vTextureCoord - vec2(0.5);\n float dist = length(center) * 2.0;\n \n // Soft falloff from center - creates a glowing effect\n float softEdge = 1.0 - smoothstep(0.0, 1.0, dist);\n \n // Apply color with soft edge and alpha fade\n float alpha = softEdge * vAlpha;\n \n // Discard fully transparent pixels for performance\n if (alpha < 0.01) discard;\n \n // Output with glow effect - slightly brighter in center\n vec3 glowColor = vColor * (1.0 + (1.0 - dist) * 0.5);\n gl_FragColor = vec4(glowColor, alpha);\n }\n ");let r=e.createProgram();if(e.attachShader(r,n),e.attachShader(r,i),e.bindAttribLocation(r,0,"aVertexPosition"),e.bindAttribLocation(r,1,"aTextureCoord"),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw new Error(`WebGL unable to initialize the particle shader program: ${e.getProgramInfoLog(r)}`);return r.aVertexPosition=e.getAttribLocation(r,"aVertexPosition"),r.aTextureCoord=e.getAttribLocation(r,"aTextureCoord"),r.pMatrixUniform=e.getUniformLocation(r,"uProjectionMatrix"),r.mMatrixUniform=e.getUniformLocation(r,"uModelMatrix"),r.vMatrixUniform=e.getUniformLocation(r,"uViewMatrix"),r.scaleUniform=e.getUniformLocation(r,"uScale"),r.particleColorUniform=e.getUniformLocation(r,"uParticleColor"),r.alphaUniform=e.getUniformLocation(r,"uAlpha"),r.setMatrixUniforms=function({color:n=null,scale:i=null,alpha:s=1}){e.useProgram(r),e.uniformMatrix4fv(this.pMatrixUniform,!1,t.uProjMat),e.uniformMatrix4fv(this.mMatrixUniform,!1,t.uModelMat),e.uniformMatrix4fv(this.vMatrixUniform,!1,t.camera.uViewMat),e.uniform3fv(this.scaleUniform,i?i.toArray():t.scale.toArray()),e.uniform3fv(this.particleColorUniform,n||[1,1,1]),e.uniform1f(this.alphaUniform,s)},this.particleShaderProgram=r,r}),i(this,"updateParticles",e=>{this.particleManager&&"function"==typeof this.particleManager.update&&this.particleManager.update(e)}),i(this,"renderParticles",()=>{this.particleManager&&"function"==typeof this.particleManager.render&&this.particleManager.render()}),i(this,"resetVertexAttribArrays",()=>{const{gl:e}=this.engine;for(let t=0;t<8;t++)e.disableVertexAttribArray(t)}),i(this,"activateShaderProgram",()=>{const{gl:e}=this.engine;this.isPickerPass=!1,this.resetVertexAttribArrays(),e.useProgram(this.shaderProgram),e.bindFramebuffer(e.FRAMEBUFFER,null),this.initProjection()}),i(this,"activatePickerShaderProgram",e=>{const{gl:t}=this.engine;this.isPickerPass=!0,t.useProgram(this.effectPrograms.picker),e?(t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer),this.initProjection(),this.applyPixelFrustum()):(t.bindFramebuffer(t.FRAMEBUFFER,null),this.initProjection())}),i(this,"activateShaderEffectProgram",e=>{const{gl:t}=this.engine;t.useProgram(this.effectPrograms[e])}),i(this,"initShaderEffects",({vs:e,fs:t,id:n,init:i})=>{const{gl:r}=this.engine,s=this.loadShader(r.VERTEX_SHADER,e),a=this.loadShader(r.FRAGMENT_SHADER,t);let o=r.createProgram();if(r.attachShader(o,s),r.attachShader(o,a),r.bindAttribLocation(o,0,"aVertexPosition"),r.bindAttribLocation(o,1,"aTextureCoord"),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw new Error(`WebGL unable to initialize the shader effect program: ${r.getProgramInfoLog(o)}`);return this.effectPrograms[n]=i.call(this,o),this.effects.push(n),r.deleteShader(s),r.deleteShader(a),this.effectPrograms[n]}),i(this,"initProjection",()=>{const{gl:e}=this.engine,t=ct(this.camera.fov),n=e.canvas.clientWidth/e.canvas.clientHeight;e.enable(e.DEPTH_TEST),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.enable(e.BLEND),e.viewport(0,0,e.canvas.width,e.canvas.height),this.uProjMat=ws(t,n,.1,100),this.camera.uViewMat||(this.camera.uViewMat=bs()),this.uProjMat[5]*=-1}),i(this,"enableCulling",()=>{const{gl:e}=this.engine;e.enable(e.CULL_FACE),e.cullFace(e.BACK)}),i(this,"disableCulling",()=>{const{gl:e}=this.engine;e.disable(e.CULL_FACE)}),i(this,"enableBlending",()=>{const{gl:e}=this.engine;e.enable(e.BLEND)}),i(this,"disableBlending",()=>{const{gl:e}=this.engine;e.disable(e.BLEND)}),i(this,"clearScreen",()=>{const{gl:e}=this.engine;e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}),i(this,"applyPixelFrustum",()=>{const{gl:e}=this.engine,t=e.canvas.clientWidth/e.canvas.clientHeight,n=.1*Math.tan(.5*ct(this.camera.fov)),i=-n,r=t*i,s=t*n,a=Math.abs(s-r),o=Math.abs(n-i),l=this.engine.gamepad.x||0,c=this.engine.gamepad.y||0,h=l*e.canvas.width/e.canvas.clientWidth,u=e.canvas.height-c*e.canvas.height/e.canvas.clientHeight-1,d=r+h*a/e.canvas.width,f=i+u*o/e.canvas.height,p=a/e.canvas.width,g=o/e.canvas.height;e.enable(e.DEPTH_TEST),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.enable(e.BLEND),e.viewport(0,0,1,1),this.uProjMat=((e,t,n,i,r,s)=>{let a=new Float32Array(16);return a[0]=2*r/(t-e),a[1]=0,a[2]=(t+e)/(t-e),a[3]=0,a[4]=0,a[5]=2*r/(i-n),a[6]=(i+n)/(i-n),a[7]=0,a[8]=0,a[9]=0,a[10]=-100.1/(s-r),a[11]=-2*s*r/(s-r),a[12]=0,a[13]=0,a[14]=-1,a[15]=0,a})(d,d+p,f,f+g,.1,100),this.uProjMat[5]*=-1}),i(this,"toggleFullscreen",()=>{if(this.fullscreen){try{document.exitFullscreen()}catch(Yc){}this.fullscreen=!1}else try{this.engine.gamepadcanvas.parentElement.requestFullscreen(),this.fullscreen=!0}catch(Yc){}}),i(this,"mvPushMatrix",()=>{let e=bs();ks(this.uModelMat,e);let t=bs();ks(this.camera.uViewMat,t),this.modelViewMatrixStack.push([e,t])}),i(this,"mvPopMatrix",()=>{if(0===this.modelViewMatrixStack.length)throw new Error("Invalid popMatrix! Matrix stack is empty.");[this.uModelMat,this.camera.uViewMat]=this.modelViewMatrixStack.pop()}),i(this,"transition",()=>{(new Date).getMilliseconds()>=this.transitionTime&&(this.isTransitioning=!1)}),i(this,"createBuffer",(e,t,n)=>{let{gl:i}=this.engine,r=i.createBuffer();return r.itemSize=n,r.numItems=e.length/n,i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,new Float32Array(e),t),i.bindBuffer(i.ARRAY_BUFFER,null),r}),i(this,"updateBuffer",(e,t)=>{let{gl:n}=this.engine;n.bindBuffer(n.ARRAY_BUFFER,e),n.bufferSubData(n.ARRAY_BUFFER,0,new Float32Array(t)),n.bindBuffer(n.ARRAY_BUFFER,null)}),i(this,"bindBuffer",(e,t)=>{let{gl:n}=this.engine;n.bindBuffer(n.ARRAY_BUFFER,e),n.enableVertexAttribArray(t),n.vertexAttribPointer(t,e.itemSize,n.FLOAT,!1,0,0)}),i(this,"startTransition",(e={})=>{const{effect:t="fade",direction:n="out",duration:i=1e3}=e,r=()=>(this.isTransitioning=!0,this.transitionEffect=t,this.transitionDirection=n,this.transitionDuration=i,this.transitionStartTime=performance.now(),new Promise(e=>{this.transitionCallback=e}));if(this.isTransitioning){const e=this.transitionCallback;return new Promise(t=>{this.transitionCallback=()=>{null==e||e(),r().then(t)}})}return r()}),i(this,"updateTransition",()=>{if(!this.isTransitioning)return;let e=(performance.now()-this.transitionStartTime)/this.transitionDuration;if(e>=1&&(e=1),this.renderTransition(e),e>=1){this.isTransitioning=!1;const e=this.transitionCallback;this.transitionCallback=null,e&&e()}}),i(this,"initTransitionProgram",e=>{const{gl:t}=this.engine;if(this.transitionGL[e])return;let n=e;n.startsWith("fade")&&(n="fade");let[i,r]=function(e){let t=null,n=null;const i=(e||"").toLowerCase();return"cross"===i?(t="\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n ",n="\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n float mask;\n // When uDirection == 1.0 (transition in), the black area shrinks\n // from right to left. Otherwise, it grows from left to right.\n if (uDirection > 0.5) {\n mask = step(1.0 - uProgress, vUV.x);\n } else {\n mask = step(vUV.x, uProgress);\n }\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "):"crossblur"===i||"cross-blur"===i?(t="\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n ",n="\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n\n void main() {\n // Determine wipe center position depending on direction\n float pos = (uDirection > 0.5) ? (1.0 - uProgress) : uProgress;\n\n // Feather width in UV space\n float feather = 0.12;\n\n // Distance from the moving edge (vertical line at x=pos)\n float d = vUV.x - pos;\n\n // Soft mask around the edge using smoothstep\n float mask = smoothstep(-feather, feather, d);\n\n // Black overlay with soft edge\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "):"swirl"===i?(t="\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n ",n="\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUV, center);\n float mask;\n if (uDirection > 0.5) {\n // transition in: shrink the black disc\n mask = step(uProgress, dist);\n } else {\n // transition out: grow the black disc\n mask = step(dist, uProgress);\n }\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "):"blur"===i||"blur-in"===i||"blur-out"===i?(t="\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n ",n="\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n\n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUV, center);\n\n // Radius grows [0..1] for OUT, shrinks for IN\n float radius = (uDirection > 0.5) ? (1.0 - uProgress) : uProgress;\n\n // Blur width relative to screen; tweak for softer/harder edge\n float feather = 0.20; // 20% of radius as feather\n float edge0 = radius - feather * 0.5;\n float edge1 = radius + feather * 0.5;\n\n float mask = smoothstep(edge0, edge1, dist);\n\n // Black overlay with soft edge\n gl_FragColor = vec4(0.0, 0.0, 0.0, mask);\n }\n "):(t="\n attribute vec2 aPosition;\n varying vec2 vUV;\n void main() {\n vUV = (aPosition + 1.0) * 0.5;\n gl_Position = vec4(aPosition, 0.0, 1.0);\n }\n ",n="\n precision mediump float;\n varying vec2 vUV;\n uniform float uProgress;\n uniform float uDirection;\n void main() {\n float alpha = uDirection > 0.5 ? (1.0 - uProgress) : uProgress;\n gl_FragColor = vec4(0.0, 0.0, 0.0, alpha);\n }\n "),[t,n]}(n);const s=this.loadShader(t.VERTEX_SHADER,i),a=this.loadShader(t.FRAGMENT_SHADER,r),o=t.createProgram();if(t.attachShader(o,s),t.attachShader(o,a),t.bindAttribLocation(o,0,"aPosition"),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new Error(`Could not link transition shader program for effect "${e}": ${t.getProgramInfoLog(o)}`);const l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l);const c=new Float32Array([-1,-1,-1,1,1,-1,1,1]);t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const h=t.getUniformLocation(o,"uProgress"),u=t.getUniformLocation(o,"uDirection");this.transitionGL[e]={program:o,buffer:l,uProgress:h,uDirection:u},t.deleteShader(s),t.deleteShader(a)}),i(this,"renderTransition",e=>{if(!this.engine.spritz.loaded)return;const{gl:t}=this.engine,n=this.transitionEffect||"fade";this.initTransitionProgram(n);const i=this.transitionGL[n];if(!i)return;const r=t.isEnabled(t.DEPTH_TEST),s=t.isEnabled(t.BLEND),a=t.getParameter(t.BLEND_SRC_RGB),o=t.getParameter(t.BLEND_DST_RGB);t.useProgram(i.program),t.bindBuffer(t.ARRAY_BUFFER,i.buffer),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,0),t.uniform1f(i.uProgress,e);const l="in"===this.transitionDirection?1:0;t.uniform1f(i.uDirection,l),t.disable(t.DEPTH_TEST),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.drawArrays(t.TRIANGLE_STRIP,0,4),r?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),s||t.disable(t.BLEND),t.blendFunc(a,o),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}),i(this,"renderSkybox",()=>{this.engine.spritz.loaded&&this.skyboxManager.renderSkybox(this.uProjMat)}),i(this,"handleResize",(e,t)=>{const{gl:n}=this.engine;n.viewport(0,0,e,t);const i=ct(this.camera.fov),r=e/t;this.uProjMat=ws(i,r,.1,100),this.uProjMat[5]*=-1}),i(this,"resetDebugCounters",()=>{this.debug&&(this.debug.tilesDrawn=0,this.debug.spritesDrawn=0,this.debug.objectsDrawn=0)}),_a._instance||(this.engine=e,this.fullscreen=e.fullscreen,this.uProjMat=bs(),this.uModelMat=bs(),this.normalMatrix=vs(),this.modelViewMatrixStack=[],this.scale=new ot(1,1,1),this.initializedWebGl=!1,this.effects=[],this.effectPrograms={},this.framebuffer=null,this.isPickerPass=!1,this.isTransitioning=!1,this.transitionEffect=null,this.transitionDirection="out",this.transitionDuration=0,this.transitionStartTime=0,this.transitionCallback=null,this.transitionGL={},this.debug={tilesDrawn:0,spritesDrawn:0,objectsDrawn:0},this.cameraManager=new Hs(this),this.camera=this.cameraManager.camera,this.cameraEffects=new ba(this.camera),this.lightManager=new Ks(this),this.skyboxManager=new ha(this),this.particleManager=new ua(this),this.frustumCuller=new ma(this),this.lodManager=new va(this),this.textureAtlas=new wa(this),this.cameraEffects=null,this.particleShaderProgram=null,this.shaderProgram=null,_a._instance=this),_a._instance}}let ka="undefined"!=typeof window?!0===window.PIXOS_DEBUG||"undefined"!=typeof localStorage&&"true"===localStorage.getItem("pixos_debug"):"undefined"!=typeof process&&process.env&&!1;function Sa(e){ka=e,"undefined"!=typeof window&&(window.PIXOS_DEBUG=e,"undefined"!=typeof localStorage&&(e?localStorage.setItem("pixos_debug","true"):localStorage.removeItem("pixos_debug")))}function Ma(e,...t){ka&&console.log(`[${e}]`,...t)}"undefined"!=typeof window&&(window.pixosDebug={enable:()=>Sa(!0),disable:()=>Sa(!1),isEnabled:function(){return ka}});const Aa=new class{loopOnThresolds(e,t,n){let i=.95;"function"!=typeof t&&"boolean"!=typeof t||(n=t||n,t=.3),void 0===t&&(t=.3),"function"!=typeof n&&(n=this.noop);const r=t,s={};do{let t=!1;if(i-=.05,e(s,i,e=>{t=e}),t)break}while(i>r);return n(s)}generateObjectModel(e,t){return this.loopOnThresolds((t,n)=>{t[n.toString()]=JSON.parse(JSON.stringify(e))},e=>t?t(JSON.parse(JSON.stringify(e))):e)}noop(){}};const Ta=new class{getLowPassSource(e,t){const{numberOfChannels:n,length:i,sampleRate:r}=e,s=new t(n,i,r),a=s.createBufferSource();a.buffer=e;const o=s.createBiquadFilter();return o.type="lowpass",a.connect(o),o.connect(s.destination),a}findPeaksAtThresold(e,t,n){let i=[];const{length:r}=e;for(let s=n;s<r;s+=1)e[s]>t&&(i.push(s),s+=1e4);return 0===i.length&&(i=void 0),{peaks:i,thresold:t}}computeBPM(e,t,n){let i=!1;Aa.loopOnThresolds((r,s,a)=>i?a(!0):e[s].length>15?(i=!0,n(null,[this.identifyIntervals,this.groupByTempo(t),this.getTopCandidates].reduce((e,t)=>t(e),e[s]),s)):void 0,()=>(i||n(new Error("Could not find enough samples for a reliable detection.")),!1))}getTopCandidates(e){return e.sort((e,t)=>t.count-e.count).splice(0,5)}identifyIntervals(e){const t=[];for(const[n,i]of e.entries())for(let r=0;r<10;r+=1){const s=e[n+r]-i;t.some(e=>e.interval===s&&(e.count+=1,e.count))||t.push({interval:s,count:1})}return t}groupByTempo(e){return t=>{const n=[];for(const i of t)if(0!==i.interval){i.interval=Math.abs(i.interval);let t=60/(i.interval/e);for(;t<90;)t*=2;for(;t>180;)t/=2;t=Math.round(t);n.some(e=>e.tempo===t&&(e.count+=i.count,e.count))||n.push({tempo:t,count:i.count})}return n}}};class Ea{constructor(e={}){this.options={debug:!1,scriptNode:{bufferSize:4096},continuousAnalysis:!1,stabilizedBpmCount:2e3,computeBPMDelay:1e4,stabilizationTime:2e4,pushTime:2e3,pushCallback:(e,t)=>{if(e)throw new Error(e)},onBpmStabilized:e=>{this.clearValidPeaks(e)},OfflineAudioContext:"object"==typeof window&&(window.OfflineAudioContext||window.webkitOfflineAudioContext)},this.logger=(...e)=>{this.options.debug&&console.log(...e)},Object.assign(this.options,e),this.minValidThresold=.3,this.cumulatedPushTime=0,this.timeoutPushTime=null,this.timeoutStabilization=null,this.validPeaks=Aa.generateObjectModel([]),this.nextIndexPeaks=Aa.generateObjectModel(0),this.chunkCoeff=1}reset(){this.minValidThresold=.3,this.cumulatedPushTime=0,this.timeoutPushTime=null,this.timeoutStabilization=null,this.validPeaks=Aa.generateObjectModel([]),this.nextIndexPeaks=Aa.generateObjectModel(0),this.chunkCoeff=1}clearValidPeaks(e){this.logger(`[clearValidPeaks] function: under ${e}`),this.minValidThresold=e.toFixed(2),Aa.loopOnThresolds((t,n)=>{n<e&&(delete this.validPeaks[n],delete this.nextIndexPeaks[n])})}analyze(e){const t=this.options.scriptNode.bufferSize*this.chunkCoeff,n=t-this.options.scriptNode.bufferSize,i=Ta.getLowPassSource(e.inputBuffer,this.options.OfflineAudioContext);i.start(0),Aa.loopOnThresolds((e,r)=>{if(this.nextIndexPeaks[r]>=t)return;const s=this.nextIndexPeaks[r]%this.options.scriptNode.bufferSize,{peaks:a,thresold:o}=Ta.findPeaksAtThresold(i.buffer.getChannelData(0),r,s);if(void 0!==a)for(const t of Object.keys(a)){const e=a[t];void 0!==e&&(this.nextIndexPeaks[o]=n+e+1e4,this.validPeaks[o].push(n+e))}},this.minValidThresold,()=>{this.chunkCoeff++,null===this.timeoutPushTime&&(this.timeoutPushTime=setTimeout(()=>{this.cumulatedPushTime+=this.options.pushTime,this.timeoutPushTime=null,Ta.computeBPM(this.validPeaks,e.inputBuffer.sampleRate,(e,t,n)=>{this.options.pushCallback(e,t,n),!e&&t&&t[0].count>=this.options.stabilizedBpmCount&&(this.logger("[freezePushBack]"),this.timeoutPushTime="never",this.minValidThresold=1),this.cumulatedPushTime>=this.options.computeBPMDelay&&this.minValidThresold<n&&(this.logger("[onBpmStabilized] function: Fired !"),this.options.onBpmStabilized(n),this.options.continuousAnalysis&&(clearTimeout(this.timeoutStabilization),this.timeoutStabilization=setTimeout(()=>{this.logger("[timeoutStabilization] setTimeout: Fired !"),this.options.computeBPMDelay=0,this.reset()},this.options.stabilizationTime)))})},this.options.pushTime))})}}"undefined"!=typeof window&&(window.RealTimeBPMAnalyzer=Ea);class Pa{constructor(e){this.engine=e,this.definitions=[],this.instances={}}load(e,t=!1){if(this.instances[e])return this.instances[e];let n=new Ca(e,t);this.instances[e]=n;let i=this;return t&&Object.keys(i.instances).filter(t=>e!==t).forEach(function(e){i.instances[e]&&i.instances[e].pauseAudio()}),n.loaded=!0,n}async loadFromZip(e,t,n=!1){if(this.instances[t])return this.instances[t];Ma("Loader",{msg:"let the beat roll in!"});let i=await e.file(`audio/${t}`).async("arrayBuffer").then(e=>{let t=new Uint8Array(e);return new Blob([t.buffer])}),r=URL.createObjectURL(i);Ma("Loader",{msg:"loading audio track...",url:r});let s=new Ca(r,n);this.instances[t]=s;let a=this;return n&&Object.keys(a.instances).filter(e=>t!==e).forEach(function(e){a.instances[e]&&a.instances[e].pauseAudio()}),s.loaded=!0,s}}class Ca{constructor(e,t=!1){this.src=e,this.playing=!1,this.audio=new Audio(e),this.audioContext=new AudioContext,this.bpm=0,this.analyser=this.audioContext.createAnalyser(),this.audioSource=this.audioContext.createMediaElementSource(this.audio),this.audioSource.connect(this.analyser),this.audioNode=this.audioContext.createScriptProcessor(4096,1,1),this.audioNode.connect(this.audioContext.destination),this.audioSource.connect(this.audioNode),this.audioSource.connect(this.audioContext.destination);const n=new Ea({scriptNode:{bufferSize:4096},pushTime:2e3,pushCallback:(e,t)=>{this.bpm=t}});this.audioNode.onaudioprocess=e=>{n.analyze(e)},t&&this.audio.addEventListener("ended",function(){this.currentTime=0,this.play()},!1),this.audio.load()}isPlaying(){return this.playing}playAudio(){const e=this.audio.play();this.playing=!0,void 0!==e&&e.then(e=>{}).catch(e=>{console.info(e)})}pauseAudio(){const e=this.audio.pause();this.playing=!1,void 0!==e&&e.then(e=>{}).catch(e=>{console.info(e)})}}class za{constructor(e,t,n){i(this,"runWhenLoaded",e=>{this.loaded?e():this.onLoadActions.add(e)}),i(this,"loadImage",()=>{let{gl:e}=this.engine;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,this.glTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.canvas),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.loaded=!0,this.onLoadActions.run()}),i(this,"attach",()=>{let{gl:e}=this.engine;e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.glTexture),e.uniform1i(this.engine.renderManager.shaderProgram.samplerUniform,0)}),i(this,"clearHud",()=>{const{ctx:e}=this;e.clearRect(0,0,e.canvas.width,e.canvas.height),this.loadImage()}),i(this,"writeText",(e,t,n)=>{const{ctx:i}=this;i.save(),i.font="32px minecraftia",i.textAlign="center",i.textBaseline="middle",i.fillStyle="white",i.fillText(e,t??i.canvas.width/2,n??i.canvas.height/2),i.restore()}),i(this,"scrollText",(e,t=!1,n={})=>{let i=new ms(this.ctx);return n.portrait?i.init(e,10,10,this.canvas.width-20-84,2*this.canvas.height/3-20,n):i.init(e,10,10,this.canvas.width-20,2*this.canvas.height/3-20,n),i.setOptions(n),t&&i.scroll((Math.sin((new Date).getTime()/3e3)+1)*i.maxScroll*.5),i.render(),i}),this.id=n,this.engine=t,this.canvas=e,this.ctx=e.getContext("2d"),this.glTexture=t.gl.createTexture(),this.loaded=!1,this.onLoadActions=new Xs,this.loadImage()}}const La={sub:(e,t,n=[0,0,0])=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n),cross:(e,t,n=[0,0,0])=>{const i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2];return n[0]=r*l-s*o,n[1]=s*a-i*l,n[2]=i*o-r*a,n},length:e=>Math.hypot(e[0],e[1],e[2]),normalize:(e,t=[0,0,0])=>{const n=La.length(e);return 0===n||(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n),t}};class Ia{constructor(e){this.gl=e}parseOBJ(e){const t=e.split(/\r?\n/),n=[],i=[],r=[],s=[];let a={positions:[],uvs:[],normals:[],material:"default"},o="default";for(let l of t){if(l=l.trim(),!l||"#"===l[0])continue;const e=l.split(/\s+/);switch(e[0]){case"v":n.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case"vt":i.push(parseFloat(e[1]),1-parseFloat(e[2]));break;case"vn":r.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case"f":const t=e.slice(1).map(e=>{const t=e.split("/");return{v:t[0]?parseInt(t[0]):null,vt:t[1]&&""!==t[1]?parseInt(t[1]):null,vn:t[2]&&""!==t[2]?parseInt(t[2]):null}});for(let e=1;e<t.length-1;e++){const s=[t[0],t[e],t[e+1]],o=s.map(e=>{if(!e.v)return[0,0,0];const t=3*(e.v>0?e.v-1:n.length/3+e.v);return[n[t],n[t+1],n[t+2]]}),l=s.map(e=>{if(!e.vt)return[0,0];const t=2*(e.vt>0?e.vt-1:i.length/2+e.vt);return[i[t],i[t+1]]});let c=[0,0,0];if(null==s[0].vn&&null==s[1].vn&&null==s[2].vn){const e=La.sub(o[1],o[0]),t=La.sub(o[2],o[0]);La.cross(e,t,c),La.normalize(c,c)}for(let e=0;e<3;e++)if(a.positions.push(o[e][0],o[e][1],o[e][2]),a.uvs.push(l[e][0],l[e][1]),null!=s[e].vn){const t=3*(s[e].vn>0?s[e].vn-1:r.length/3+s[e].vn);a.normals.push(r[t],r[t+1],r[t+2])}else a.normals.push(c[0],c[1],c[2])}break;case"usemtl":a.positions.length>0&&s.push(a),o=e[1],a={positions:[],uvs:[],normals:[],material:o}}}return a.positions.length>0&&s.push(a),s}parseMTL(e){const t={};let n=null;const i=e.split(/\r?\n/);for(let r of i){if(r=r.trim(),!r||r.startsWith("#"))continue;const e=r.split(/\s+/);switch(e[0]){case"newmtl":n=e[1],t[n]={Ka:[1,1,1],Kd:[.8,.8,.8],Ks:[1,1,1],Ns:50};break;case"Ka":case"Kd":case"Ks":if(n){const i=e.slice(1).map(parseFloat);t[n][e[0]]=1===i.length?[i[0],i[0],i[0]]:i}break;case"Ns":n&&(t[n].Ns=parseFloat(e[1]));break;case"map_Kd":n&&(t[n].map_Kd=e.slice(1).join(" "))}}return t}assignMaterials(e,t,n={}){const i={Ka:[.25,.25,.3],Kd:[.75,.75,.75],Ks:[1,1,1],Ns:50};e.forEach(e=>{e.materialProps=t[e.material]||i;let r=null;if(e.materialProps.map_Kd){const t=e.materialProps.map_Kd.split("/").pop();r=n[t]||null}e.texture=r,e.hasTexture=!!r})}async loadTexture(e){const t=this.gl;return new Promise((n,i)=>{const r=new Image;r.onload=()=>{const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r),r.width&r.width-1||r.height&r.height-1?t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR):(t.generateMipmap(t.TEXTURE_2D),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),"string"==typeof e||e instanceof HTMLImageElement||URL.revokeObjectURL(r.src),n(i)},r.onerror=()=>{"string"==typeof e||e instanceof HTMLImageElement||URL.revokeObjectURL(r.src),i(new Error("Failed to load texture"))},"string"==typeof e?r.src=e:e instanceof HTMLImageElement?r.src=e.src:e instanceof Blob&&(r.src=URL.createObjectURL(e))})}createPlaceholderTexture(e=[128,128,128,255]){const t=this.gl,n=t.createTexture();return t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(e)),n}initBuffers(e){const t=this.gl;e.forEach(e=>{const n=t.createVertexArray();t.bindVertexArray(n);const i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.positions),t.STATIC_DRAW),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,0,0);const r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.normals),t.STATIC_DRAW),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,3,t.FLOAT,!1,0,0);const s=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,s),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.uvs),t.STATIC_DRAW),t.enableVertexAttribArray(2),t.vertexAttribPointer(2,2,t.FLOAT,!1,0,0),e.vao=n,e.count=e.positions.length/3,e.vertexBuffer=i,e.vertexBuffer.numItems=e.count,e.normalBuffer=r,e.normalBuffer.numItems=e.count,e.textureBuffer=s,e.textureBuffer.numItems=e.count,t.bindVertexArray(null)})}initLegacyBuffers(e){const t=this.gl;return e.vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,e.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.vertices),t.STATIC_DRAW),e.vertexBuffer.itemSize=3,e.vertexBuffer.numItems=e.vertices.length/3,e.vertexNormals&&e.vertexNormals.length>0&&(e.normalBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,e.normalBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.vertexNormals),t.STATIC_DRAW),e.normalBuffer.itemSize=3,e.normalBuffer.numItems=e.vertexNormals.length/3),e.textures&&e.textures.length>0&&(e.textureBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,e.textureBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e.textures),t.STATIC_DRAW),e.textureBuffer.itemSize=2,e.textureBuffer.numItems=e.textures.length/2),e.indices&&e.indices.length>0&&(e.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array(e.indices),t.STATIC_DRAW),e.indexBuffer.itemSize=1,e.indexBuffer.numItems=e.indices.length),e}calculateBounds(e){const t=e.positions||e.vertices;if(!t||0===t.length)return{min:[0,0,0],max:[0,0,0],size:[0,0,0],center:[0,0,0]};let n=1/0,i=-1/0,r=1/0,s=-1/0,a=1/0,o=-1/0;for(let l=0;l<t.length;l+=3){const e=t[l],c=t[l+1],h=t[l+2];e<n&&(n=e),e>i&&(i=e),c<r&&(r=c),c>s&&(s=c),h<a&&(a=h),h>o&&(o=h)}return{min:[n,r,a],max:[i,s,o],size:[i-n,s-r,o-a],center:[(n+i)/2,(r+s)/2,(a+o)/2]}}deleteMeshBuffers(e){const t=this.gl;e.forEach(e=>{e.vao&&t.deleteVertexArray(e.vao),e.vertexBuffer&&t.deleteBuffer(e.vertexBuffer),e.normalBuffer&&t.deleteBuffer(e.normalBuffer),e.textureBuffer&&t.deleteBuffer(e.textureBuffer),e.texture&&t.deleteTexture(e.texture)})}}class Da{constructor(e){return i(this,"loadTexture",e=>(this.textures[e]||(this.textures[e]=new qs(e,this.engine)),this.textures[e])),i(this,"loadTextureFromZip",async(e,t)=>{if(this.textures[e])return this.textures[e];let n=await t.file(`textures/${e}`).async("arrayBuffer"),i=new Uint8Array(n),r=new Blob([i.buffer]),s=URL.createObjectURL(r);return this.textures[e]=new qs(s,this.engine),this.textures[e]}),i(this,"loadSpeech",(e,t)=>(this.speeches[e]||(this.speeches[e]=new za(t,this.engine,e)),this.speeches[e])),Da._instance||(this.engine=e,this.objLoader=js,this.objHelper=new Ia(e.gl),this.audioLoader=new Pa(this),this.textures={},this.colors={},this.speeches={},Da._instance=this),Da._instance}async loadModel(e,t=null,n=null){const i=this.objHelper.parseOBJ(e);let r={};return t&&(r=this.objHelper.parseMTL(t),this.objHelper.assignMaterials(i,r)),n&&await this.objHelper.loadTextures(i,n),this.objHelper.initBuffers(i),i}deleteModelBuffers(e){this.objHelper.deleteMeshBuffers(e)}}class Ra{constructor(e){i(this,"register",(e,t)=>{this.scenes[e]=Array.isArray(t)?t.slice():[]}),i(this,"isRegistered",e=>e in this.scenes),i(this,"start",e=>{const t=this.scenes[e];t?(this.queue=t.slice(),this.active=!0,this._currentPromise=null,this.currentBackdrop=null,this.currentCutouts=[]):console.warn("Cutscene not found:",e)}),i(this,"skip",()=>{this.queue=[],this.active=!1}),i(this,"isRunning",()=>this.active),i(this,"update",()=>{if(!this.active)return;if(this._currentPromise)return;const e=this.queue.shift();if(!e)return void(this.active=!1);let t;switch(e.type){case"action":t=this.runAction(e);break;case"wait":t=this.wait(e.ms||0);break;case"transition":t=this.transition(e);break;case"load_zone":t=this.loadZone(e);break;case"set_backdrop":t=this.setBackdrop(e);break;case"show_cutout":t=this.showCutout(e);break;default:console.warn("Unknown cutscene step:",e.type),t=Promise.resolve()}this._currentPromise=t,t.then(()=>{this._currentPromise=null,this.update()})}),i(this,"wait",e=>new Promise(t=>setTimeout(t,e))),i(this,"transition",e=>{const t=this.engine.renderManager;if(!t)return Promise.resolve();const n=e.effect||"fade",i=e.direction||"out",r=e.duration||500;return t.startTransition({effect:n,direction:i,duration:r})}),i(this,"runAction",e=>{const t=e.action;return t?t():Promise.resolve()}),i(this,"loadZone",e=>{const{zone:t,remotely:n=!1,zip:i}=e;return t&&this.engine.spritz&&this.engine.spritz.world?(e.effect,e.duration,i?this.engine.spritz.world.loadZoneFromZip(t,i,!1,null):this.engine.spritz.world.loadZone(t,n,!1,null)):Promise.resolve()}),i(this,"setBackdrop",e=>(this.currentBackdrop=e.backdrop||null,Promise.resolve())),i(this,"showCutout",e=>{const{sprite:t,cutout:n,position:i="left"}=e;return t&&n&&(this.currentCutouts=this.currentCutouts.filter(e=>e.sprite!==t),this.currentCutouts.push({sprite:t,cutout:n,position:i})),Promise.resolve()}),this.engine=e,this.scenes={},this.queue=[],this.active=!1,this._currentPromise=null,this.currentBackdrop=null,this.currentCutouts=[]}}class Oa{constructor(e){this.engine=e,this.currentMode=null,this.registered=Object.create(null)}register(e,t){if(this.registered[e]=t,this.currentMode&&this.currentMode.name===e){const t=this.currentMode.params||{};(async()=>{try{const n=this.registered[e];if(this.currentMode.handlers=n,n&&n.setup){const i=await n.setup(t);i&&"object"==typeof i&&(Object.assign(n,i),this.registered[e]=n,this.currentMode.handlers=n)}}catch(Yc){console.warn(`Mode late-register setup failed for mode "${e}":`,Yc)}})()}}async set(e,t={}){var n;if(!e)return;if(this.currentMode&&(null==(n=this.currentMode.handlers)?void 0:n.teardown))try{await this.currentMode.handlers.teardown(t)}catch(Yc){console.warn(`Mode teardown failed for mode "${this.currentMode.name}":`,Yc)}this.registered[e]||console.warn(`Warning: Mode "${e}" has not been registered.`);const i=this.registered[e]||{};if(this.currentMode={name:e,handlers:i,params:t},i.setup)try{const n=await i.setup(t);n&&"object"==typeof n&&(Object.assign(i,n),this.registered[e]=i,this.currentMode.handlers=i)}catch(Yc){console.warn(`Mode setup failed for mode "${e}":`,Yc)}}async update(e){if(!this.currentMode)return;const t=this.currentMode.handlers;if(t&&t.update)try{await t.update(e,this.currentMode.params)}catch(Yc){console.warn(`Mode update failed for mode "${this.currentMode.name}":`,Yc)}}handleInput(e){if(!this.currentMode)return!1;const t=this.currentMode.handlers;try{if(t&&t.checkInput)return!!t.checkInput(e,this.currentMode.params)}catch(Yc){console.warn(`Mode input handler failed for mode "${this.currentMode.name}":`,Yc)}return!1}handleSelect(e,t,n,i){if(!this.currentMode)return!1;const r=this.currentMode.handlers;try{if(r&&r.onSelect)return!!r.onSelect(e,t,n,i,this.currentMode.params)}catch(Yc){console.warn(`Mode onSelect handler failed for mode "${this.currentMode.name}":`,Yc)}return!1}getMode(){var e;return(null==(e=this.currentMode)?void 0:e.name)||null}hasPicker(){var e,t;return!0===(null==(t=null==(e=this.currentMode)?void 0:e.handlers)?void 0:t.picker)}}class Ba{constructor(e){return Ba._instance||(this.activeKeys=[],this.activeCodes=[],this.hooks=[],this.shift=!1,this.engine=e,Ba._instance=this),Ba._instance}init(){window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}onKeyDown(e){e.preventDefault();const t=String.fromCharCode(e.keyCode).toLowerCase();Ba._instance.activeKeys.indexOf(t)<0&&Ba._instance.activeKeys.push(t),Ba._instance.activeCodes.indexOf(e.key)<0&&Ba._instance.activeCodes.push(e.key),Ba._instance.shift=e.shiftKey;try{(Ba._instance.hooks||[]).forEach(t=>t(e,"down"))}catch(n){}}onKeyUp(e){const t=String.fromCharCode(e.keyCode).toLowerCase();let n=Ba._instance.activeKeys.indexOf(t);n>-1&&Ba._instance.activeKeys.splice(n,1),n=Ba._instance.activeCodes.indexOf(e.key),n>-1&&Ba._instance.activeCodes.splice(n,1),Ba._instance.shift=e.shiftKey;try{(Ba._instance.hooks||[]).forEach(t=>t(e,"up"))}catch(i){}}addHook(e){e&&(this.hooks=this.hooks||[],this.hooks.push(e))}removeHook(e){if(!e||!this.hooks)return;const t=this.hooks.indexOf(e);t>=0&&this.hooks.splice(t,1)}isKeyPressed(e){return this.activeKeys.includes(e.toLowerCase())}isCodePressed(e){return this.activeCodes.includes(e)}lastPressed(e){const t=e.toLowerCase();let n=null,i=-1;for(let r=0;r<t.length;r++){const e=t[r],s=Ba._instance.activeKeys.indexOf(e);s>i&&(n=e,i=s)}return n}lastPressedCode(e=""){let t=null;const n=e.toLowerCase();for(;Ba._instance.activeCodes.length>0;)if(t=Ba._instance.activeCodes.pop(),-1===n.indexOf(t.toLowerCase()))return t;return null}lastPressedKey(){return Ba._instance.activeKeys[Ba._instance.activeKeys.length-1]||null}}class Fa{constructor(e){return Fa._instance||(this.engine=e,this.buttons=[!1,!1,!1],this.position={x:0,y:0},this.movement={x:0,y:0},this._hooks=[],Fa._instance=this),Fa._instance}init(){const e=this.engine.canvas;e.addEventListener("mousedown",this.onMouseDown.bind(this)),e.addEventListener("mouseup",this.onMouseUp.bind(this)),e.addEventListener("mousemove",this.onMouseMove.bind(this)),e.addEventListener("contextmenu",e=>e.preventDefault())}onMouseDown(e){e.preventDefault();const t=e.target,n=t.getBoundingClientRect(),i=t.width/n.width,r=t.height/n.height;this.position.x=(e.clientX-n.left)*i,this.position.y=(e.clientY-n.top)*r,e.button>=0&&e.button<3&&(this.buttons[e.button]=!0),this._notifyHooks(e,"down")}onMouseUp(e){e.preventDefault();const t=e.target,n=t.getBoundingClientRect(),i=t.width/n.width,r=t.height/n.height;this.position.x=(e.clientX-n.left)*i,this.position.y=(e.clientY-n.top)*r,e.button>=0&&e.button<3&&(this.buttons[e.button]=!1),this._notifyHooks(e,"up")}onMouseMove(e){const t=e.target,n=t.getBoundingClientRect(),i=t.width/n.width,r=t.height/n.height,s=(e.clientX-n.left)*i,a=(e.clientY-n.top)*r;this.movement.x=s-this.position.x,this.movement.y=a-this.position.y,this.position.x=s,this.position.y=a,this._notifyHooks(e,"move")}_notifyHooks(e,t){try{this._hooks.forEach(n=>{try{n(e,t)}catch(i){0}})}catch(n){}}isButtonPressed(e){return"string"==typeof e&&(e={left:0,middle:1,right:2}[e]),this.buttons[e]||!1}getPosition(){return this.position}getMovement(){return this.movement}addHook(e){"function"==typeof e&&this._hooks.push(e)}removeHook(e){const t=this._hooks.indexOf(e);t>=0&&this._hooks.splice(t,1)}}class ja{constructor(e,t,n,r,s,a){i(this,"init",()=>{let{layout:e,width:t}=this;this.x=t-e.x,this.y=e.y+3*this.radius/8,this.dx=this.x,this.dy=this.y,this.gamepad.map["x-dir"]=0,this.gamepad.map["y-dir"]=0,this.gamepad.map["x-axis"]=0,this.gamepad.map["y-axis"]=0}),i(this,"draw",()=>{let{ctx:e}=this;e.fillStyle=this.colours.joystick.base,e.beginPath(),e.arc(this.x,this.y,this.radius,0,2*Math.PI,!1),e.fill(),e.closePath(),e.fillStyle=this.colours.joystick.dust,e.beginPath(),e.arc(this.x,this.y,this.radius-5,0,2*Math.PI,!1),e.fill(),e.closePath(),e.fillStyle=this.colours.joystick.stick,e.beginPath(),e.arc(this.x,this.y,10,0,2*Math.PI,!1),e.fill(),e.closePath(),e.fillStyle=this.colours.joystick.ball,e.beginPath(),e.arc(this.dx,this.dy,this.radius-10,0,2*Math.PI,!1),e.fill(),e.closePath()}),i(this,"state",(e,t)=>{let{gamepad:n}=this,{touches:i,map:r,checkInput:s}=n;var a=i[e].x,o=i[e].y,l=parseInt(a-this.x),c=parseInt(o-this.y),h=parseInt(Math.sqrt(l*l+c*c));if(h<1.2*this.radius)if(t){if("mousedown"===t)i[e].id="stick"}else i[e].id="stick";if(h<2.5*this.radius)if(t){if("stick"==i[e].id&&"mouseup"===t)delete i[e].id,this.reset()}else i[e].id="stick";"stick"==i[e].id&&(Math.abs(parseInt(l))<this.radius/2&&(this.dx=this.x+l),Math.abs(parseInt(c))<this.radius/2&&(this.dy=this.y+c),r["x-axis"]=(this.dx-this.x)/(this.radius/2),r["y-axis"]=(this.dy-this.y)/(this.radius/2),r["x-dir"]=Math.round(r["x-axis"]),r["y-dir"]=Math.round(r["y-axis"]),h>2.5*this.radius&&(this.reset(),delete i[e].id),"function"==typeof s&&this.gamepad.checkInput())}),i(this,"reset",()=>{let{map:e}=this.gamepad;this.dx=this.x,this.dy=this.y,e["x-dir"]=0,e["y-dir"]=0,e["x-axis"]=0,e["y-axis"]=0}),this.ctx=e,this.gamepad=a,this.width=e.canvas.width,this.height=e.canvas.height,this.layout=t,this.touches=n,this.radius=s,this.x=0,this.y=0,this.dx=0,this.dy=0,this.gamepad.map["x-dir"]=0,this.gamepad.map["y-dir"]=0,this.gamepad.map["x-axis"]=0,this.gamepad.map["y-axis"]=0,this.colours=r}}CanvasRenderingContext2D.prototype.roundRect=function(e,t,n,i,r){return n<2*r&&(r=n/2),i<2*r&&(r=i/2),this.beginPath(),this.moveTo(e+r,t),this.arcTo(e+n,t,e+n,t+i,r),this.arcTo(e+n,t+i,e,t+i,r),this.arcTo(e,t+i,e,t,r),this.arcTo(e,t,e+n,t,r),this.closePath(),this};class Na{constructor(e,t,n,i,r,s,a,o){this.ctx=e,this.gamepad=o,this.layout=t,this.radius=a,this.touches=n,this.start=i,this.select=r,this.colours=s}init(){let{layout:e,ctx:t}=this,{buttonsLayout:n}=this.gamepad,i=t.canvas.width;for(var r=0;r<n.length;r++){var s=n[r],a=e.x-s.x,o=e.y-s.y;if(s.r){var l=s.r;n[r].hit={x:[a-l,a+2*l],y:[o-l,o+2*l],active:!1}}else{if(s.x=i/3-s.w,this.start&&this.select)switch(s.name){case"select":s.x=i/2-s.w-2*s.h;break;case"start":s.x=i/2}a=s.x,o=e.y-s.y;n[r].hit={x:[a,a+s.w],y:[o,o+s.h],active:!1}}this.gamepad.map[s.name]=0}}draw(){let{ctx:e,layout:t}=this;for(var n=0;n<this.gamepad.buttonsLayout.length;n++){var i=this.gamepad.buttonsLayout[n],r=i.color,s=t.x-i.x,a=t.y-i.y;if(i.dx=s,i.dy=a,i.r){var o=i.r;i.hit&&i.hit.active&&(e.fillStyle=r,e.beginPath(),e.arc(s,a,o+5,0,2*Math.PI,!1),e.fill(),e.closePath()),e.fillStyle=r,e.beginPath(),e.arc(s,a,o,0,2*Math.PI,!1),e.fill(),e.closePath(),e.strokeStyle=r,e.lineWidth=2,e.stroke(),e.fillStyle="rgba(255,255,255,1)",e.textAlign="center",e.textBaseline="middle",e.font="minecraftia 12px",e.fillText(i.name,s,a)}else{var l=i.w,c=i.h;s=isNaN(i.x)?e.canvas.width/2:i.x,o=10;e.fillStyle=r,i.hit&&i.hit.active&&e.roundRect(s-5,a-5,l+10,c+10,2*o).fill(),e.roundRect(s,a,l,c,o).fill(),e.strokeStyle=r,e.lineWidth=2,e.stroke(),e.fillStyle="rgba(0,0,0,0.5)",e.textAlign="center",e.textBaseline="middle",e.font="minecraftia 12px",e.fillText(i.name,s+l/2,a+2*c)}i.key&&(e.fillStyle="rgba(0,0,0,0.25)",e.textAlign="center",e.textBaseline="middle",e.font="minecraftia 12px","start"!=i.name&&"select"!=i.name||(s+=l/2),e.fillText(i.key,s,a-1.5*o))}}state(e,t,n){let{gamepad:i}=this,{touches:r,checkInput:s,width:a}=i;if("stick"!=r[e].id){var o={x:r[e].x,y:r[e].y},l=this.gamepad.buttonsLayout[t],c=l.name,h=parseInt(o.x-l.dx),u=parseInt(o.y-l.dy),d=a;if(l.r?d=parseInt(Math.sqrt(h*h+u*u)):o.x>l.hit.x[0]&&o.x<l.hit.x[1]&&o.y>l.hit.y[0]&&o.y<l.hit.y[1]&&(d=0),d<this.radius&&"stick"!=r[e].id)if(n)switch(n){case"mousedown":r[e].id=c;break;case"mouseup":delete r[e].id,this.reset(t)}else r[e].id=c;r[e].id==c&&(this.gamepad.map[c]=1,l.hit.active=!0,d>this.radius&&(l.hit.active=!1,this.gamepad.map[c]=0,delete r[e].id),"function"==typeof s&&this.gamepad.checkInput())}}reset(e){this.gamepad.buttonsLayout[e].hit.active=!1,this.gamepad.map[this.gamepad.buttonsLayout[e].name]=0}}class Ua{constructor(e,t,n,i,r,s,a){this.ctx=e,this.gamepad=a,this.width=e.canvas.width,this.height=e.canvas.height,this.radius=e.canvas.width/10,this.touches=n,this.start=i,this.select=r,this.buttonOffset=t,this.colours=s,this.layout={x:this.width-this.buttonOffset.x,y:this.height-this.buttonOffset.y},this.stick=new ja(this.ctx,this.layout,this.touches,this.colours,this.radius,this.gamepad),this.buttons=new Na(this.ctx,this.layout,this.touches,this.start,this.select,this.colours,this.radius,this.gamepad)}init(){this.stick.init(),this.buttons.init()}draw(){this.stick.draw(),this.buttons.draw()}}class $a{constructor(e){return $a._instance||(this.engine=e,this.dirty=!0,this.showTrace=!0,this.showDebug=!0,this.opacity=.4,this.font="minecraftia",this.start=!1,this.select=!1,this.touches={},this.lastKey=(new Date).getTime(),this.listeners=[],this.map={},this.x=0,this.y=0,this.colours={red:`rgba(255,0,0,${this.opacity})`,green:`rgba(5,220,30,${this.opacity})`,blue:`rgba(5,30,220,${this.opacity})`,purple:`rgba(240,5,240,${this.opacity})`,yellow:`rgba(240,240,5,${this.opacity})`,cyan:`rgba(5,240,240,${this.opacity})`,black:`rgba(5,5,5,${this.opacity})`,white:`rgba(250,250,250,${this.opacity})`,joystick:{base:`rgba(0,0,0,${this.opacity})`,dust:`rgba(0,0,0,${this.opacity})`,stick:"rgba(214,214,214,1)",ball:"rgba(245,245,245,1)"}},$a._instance=this),$a._instance}init(){this.fontSize=this.engine.gp.canvas.width/12,this.radius=this.engine.gp.canvas.width/12,this.buttonOffset={x:2.5*this.radius,y:105};let e=[{x:-this.radius-this.radius/2+this.radius/4,y:-this.radius/4,r:3/4*this.radius,color:this.colours.red,name:"b"},{x:this.radius-this.radius/2,y:-(this.radius+this.radius/2),r:3/4*this.radius,color:this.colours.green,name:"a"},{x:this.radius-this.radius/2,y:this.radius,r:3/4*this.radius,color:this.colours.blue,name:"x"},{x:3*this.radius-this.radius/2-this.radius/4,y:0-this.radius/4,r:3/4*this.radius,color:this.colours.yellow,name:"y"}];this.start&&e.push({color:this.colours.black,y:-55,w:50,h:15,name:"start"}),this.select&&e.push({y:-55,w:50,h:15,color:this.colours.black,name:"select"}),this.buttonsLayout=e,this.controller=new Ua(this.engine.gp,this.buttonOffset,this.touches,this.start,this.select,this.colours,this),this.initOptions()}initOptions(e={}){this.setOptions(e),this.resize(),this.loadCanvas()}attachListener(e){return this.listeners.push(e)}removeListener(e){this.listeners.splice(e-1,1)}checkInput(){return this.map}resize(){this.width=this.engine.gp.canvas.width,this.height=this.engine.gp.canvas.height,this.controller.init()}loadCanvas(){let{controller:e,width:t,height:n}=this;this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="center",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 14px",this.engine.gp.fillText("loading",t/2,n/2),e.stick.draw(),e.buttons.draw(),window.addEventListener("resize",()=>this.resize()),setTimeout(function(){this.ready=!0},250)}setOptions(e){Object.keys(this).forEach(t=>{void 0!==e[t]&&(this[t]=e[t],this.dirty=!0)})}debounce(){let{controller:e,buttonsLayout:t}=this,n=this.lastKey;this.lastKey=(new Date).getTime()+100;for(var i=0;i<t.length;i++)e.buttons.reset(i);return n<this.lastKey}keyPressed(e){return 1===this.map[e]&&this.debounce()}listen(e){var t;let{touches:n,controller:i,buttonsLayout:r}=this;if(e.type){var s=e.type;let h;if(-1!==e.type.indexOf("mouse")||"click"===e.type)h=[{identifier:"desktop",clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,canvasX:e.canvasX,canvasY:e.canvasY}];else if(e.touches&&e.touches.length>0)h=Array.from(e.touches).map(t=>({identifier:t.identifier,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,canvasX:e.canvasX,canvasY:e.canvasY}));else if(e.changedTouches&&e.changedTouches.length>0)h=Array.from(e.changedTouches).map(t=>({identifier:t.identifier,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,canvasX:e.canvasX,canvasY:e.canvasY}));else{if(void 0===e.canvasX)return;h=[{identifier:"desktop",clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,canvasX:e.canvasX,canvasY:e.canvasY}]}const u=this.engine.gp.canvas,d=u.getBoundingClientRect(),f=u.width/d.width,p=u.height/d.height;this.listeners.map(t=>{if(t[s])return t[s](e)});const g=Math.min(h.length,5);for(var a=0;a<g;a++){var o=h[a].identifier;let e,t;if(void 0!==h[a].canvasX)e=h[a].canvasX,t=h[a].canvasY;else{const n=h[a].clientX??h[a].pageX,i=h[a].clientY??h[a].pageY;e=(n-d.left)*f,t=(i-d.top)*p}n[o]?(n[o].x=e,n[o].y=t):n[o]={x:e,y:t,leftClick:!1,rightClick:!1}}for(var o in n)switch(s){case"touchstart":case"touchmove":if(this.disableScroll(),i.stick.state(o),(new Date).getTime()>this.lastKey+150){for(a=0;a<r.length;a++)i.buttons.state(o,a);this.lastKey=(new Date).getTime()}break;case"touchend":for(a=0;a<r.length;a++)i.buttons.reset(a);break;case"mousemove":n[o].leftClick,this.x=n[o].x,this.y=n[o].y;break;case"mousedown":e.touches&&(null==(t=e.touches[0])?void 0:t.which)?(n[o].leftClick=1===e.touches[0].which,n[o].rightClick=3===e.touches[0].which):"button"in e&&(n[o].leftClick=1==e.button,n[o].rightClick=2==e.button),i.stick.state(o,s);for(a=0;a<r.length;a++)i.buttons.state(o,a,s);break;case"mouseup":i.stick.state(o,s);for(a=0;a<r.length;a++)i.buttons.state(o,a,s);n[o].leftClick=0,n[o].rightClick=0}if("touchend"==e.type){if(e.changedTouches&&e.changedTouches.length>0){n[o=e.changedTouches[0].identifier]&&"stick"==n[o].id&&i.stick.reset();for(a=0;a<r.length;a++)n[o]&&n[o].id==r[a].name&&i.buttons.reset(a);n[o]&&delete n[o]}if(e.changedTouches&&e.touches&&e.changedTouches.length>e.touches.length){var l=0,c=e.changedTouches.length-e.touches.length;for(var o in n)l>=c&&delete n[o],l++}if(0==e.touches.length){n={};for(a=0;a<r.length;a++)i.buttons.reset(a);i.stick.reset()}this.enableScroll()}}else{var h=e,u=0;for(var d in h){switch(d){case"%":h[d]&&(u+=1);break;case"&":h[d]&&(u+=2);break;case"'":h[d]&&(u+=4);break;case"(":h[d]&&(u+=8);break;default:if(h[d])for(a=0;a<r.length;a++)r[a].key&&r[a].key==d&&(n[r[a].name]={id:r[a].name,x:r[a].hit.x[0]+r[a].w/2,y:r[a].hit.y[0]+r[a].h/2},i.buttons.state(r[a].name,a,"mousedown"));else if(!h[d]){for(a=0;a<r.length;a++)r[a].key&&r[a].key==d&&(i.buttons.reset(a),delete n[r[a].name]);delete h[d]}}switch(i.stick.dx=i.stick.x,i.stick.dy=i.stick.y,u){case 1:i.stick.dx=i.stick.x-i.stick.radius/2;break;case 2:i.stick.dy=i.stick.y-i.stick.radius/2;break;case 3:i.stick.dx=i.stick.x-i.stick.radius/2,i.stick.dy=i.stick.y-i.stick.radius/2;break;case 4:i.stick.dx=i.stick.x+i.stick.radius/2;break;case 6:i.stick.dx=i.stick.x+i.stick.radius/2,i.stick.dy=i.stick.y-i.stick.radius/2;break;case 8:i.stick.dy=i.stick.y+i.stick.radius/2;break;case 9:i.stick.dx=i.stick.x-i.stick.radius/2,i.stick.dy=i.stick.y+i.stick.radius/2;break;case 12:i.stick.dx=i.stick.x+i.stick.radius/2,i.stick.dy=i.stick.y+i.stick.radius/2;break;default:i.stick.dx=i.stick.x,i.stick.dy=i.stick.y}0!=u?(n.stick={id:"stick"},i.stick.state("stick","mousemove")):(i.stick.reset(),delete n.stick)}}return this.map}render(){this.engine.gp.clearRect(0,0,this.engine.gp.canvas.width,this.engine.gp.canvas.height),this.showDebug&&this.debug(),this.showTrace&&this.trace(),this.controller.stick.draw(),this.controller.buttons.draw()}debug(){let{gp:e,map:t,touches:n}=this;for(var i in this.dy=30,this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="left",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 20px",this.engine.gp.fillText("debug",10,this.dy),this.engine.gp.font="minecraftia 14px",this.dy+=5,n){this.dy+=10;let e=i+" : "+JSON.stringify(n[i]).slice(1,-1);this.engine.gp.fillText(e,10,this.dy)}}trace(){let{map:e}=this;for(var t in this.dy=30,this.engine.gp.fillStyle="rgba(70,70,70,0.5)",this.engine.gp.textAlign="right",this.engine.gp.textBaseline="middle",this.engine.gp.font="minecraftia 20px",this.engine.gp.fillText("trace",this.width-10,this.dy),this.engine.gp.font="minecraftia 14px",this.dy+=5,e){this.dy+=10;let n=t+" : "+e[t];this.engine.gp.fillText(n,this.width-10,this.dy)}}getPosition(e){for(var t=0,n=0;e;)t+=e.offsetLeft-e.scrollLeft+e.clientLeft,n+=e.offsetTop-e.scrollTop+e.clientTop,e=e.offsetParent;return{x:t,y:n}}enableScroll(){document.body.removeEventListener("touchmove",this.preventDefault)}disableScroll(){document.body.addEventListener("touchmove",this.preventDefault,{passive:!1})}preventDefault(e){e.preventDefault(),e.stopPropagation()}}class Va{constructor(e){return Va._instance||(this.engine=e,this.touches=[],this.gestures={},this.hooks=[],this.startTime=0,this.startPos={x:0,y:0},Va._instance=this),Va._instance}init(){const e=this.engine.canvas;e.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),e.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),e.addEventListener("touchend",this.onTouchEnd.bind(this),{passive:!1})}onTouchStart(e){if(e.preventDefault(),this.touches=Array.from(e.touches),1===this.touches.length){const e=this.touches[0];this.startTime=Date.now(),this.startPos={x:e.clientX,y:e.clientY}}this._notifyHooks(e,"start")}onTouchMove(e){e.preventDefault(),this.touches=Array.from(e.touches),this._notifyHooks(e,"move")}onTouchEnd(e){if(e.preventDefault(),this.touches=Array.from(e.touches),0===this.touches.length&&this.startTime>0){const t=Date.now()-this.startTime,n=e.changedTouches[0],i={x:n.clientX,y:n.clientY},r=i.x-this.startPos.x,s=i.y-this.startPos.y,a=Math.sqrt(r*r+s*s);t<300&&a<10?(this.gestures.tap=!0,setTimeout(()=>delete this.gestures.tap,100)):Math.abs(r)>Math.abs(s)&&Math.abs(r)>50?r>0?(this.gestures.swipe_right=!0,setTimeout(()=>delete this.gestures.swipe_right,100)):(this.gestures.swipe_left=!0,setTimeout(()=>delete this.gestures.swipe_left,100)):Math.abs(s)>Math.abs(r)&&Math.abs(s)>50&&(s>0?(this.gestures.swipe_down=!0,setTimeout(()=>delete this.gestures.swipe_down,100)):(this.gestures.swipe_up=!0,setTimeout(()=>delete this.gestures.swipe_up,100)))}this._notifyHooks(e,"end")}_notifyHooks(e,t){try{this.hooks.forEach(n=>n(e,t))}catch(n){}}isGestureActive(e){return!!this.gestures[e]}getTouches(){return this.touches}addHook(e){e&&this.hooks.push(e)}removeHook(e){const t=this.hooks.indexOf(e);t>=0&&this.hooks.splice(t,1)}}class Wa extends Ys{constructor(e){super(),i(this,"onJsonLoaded",e=>{Object.keys(e).map(t=>{this[t]=e[t]}),this.definitionLoaded=!0,this.onDefinitionLoadActions.run(),this.texture=this.engine.resourceManager.loadTexture(this.src),this.texture.runWhenLoaded(this._onTextureLoaded),this.bgColor&&this.engine.gl.clearColor(this.bgColor[0]/255,this.bgColor[1]/255,this.bgColor[2]/255,1)}),i(this,"onJsonLoadedFromZip",async(e,t)=>{Object.keys(e).map(t=>{this[t]=e[t]}),this.definitionLoaded=!0,this.onDefinitionLoadActions.run(),this.texture=await this.engine.resourceManager.loadTextureFromZip(this.src,t),this.texture.runWhenLoaded(this._onTextureLoaded),this.bgColor&&this.engine.gl.clearColor(this.bgColor[0]/255,this.bgColor[1]/255,this.bgColor[2]/255,1)}),i(this,"_onTextureLoaded",()=>{this.loaded=!0,this.onLoadActions.run()}),i(this,"runWhenDefinitionLoaded",e=>{this.definitionLoaded?e():this.onDefinitionLoadActions.add(e)}),i(this,"getTileVertices",(e,t,n=null)=>{const i=t[0],r=t[1],s=null!==n?n:t[2];if(null!==n&&console.log(`[Tileset.getTileVertices] tile=${e}, offset=[${t}], heightOverride=${n}, zOffset=${s}`),!this.geometry[e]||!this.geometry[e].vertices){if(console.warn(`[Tileset.getTileVertices] Missing geometry for tile id ${e}. Attempting fallback.`),!this.geometry[0]||!this.geometry[0].vertices){return[[[0,0,0],[1,0,0],[1,0,1]],[[0,0,0],[1,0,1],[0,0,1]]].map(e=>e.map(e=>[e[0]+t[0],e[1]+r,e[2]+s])).flat(3)}e=0}return this.geometry[e].vertices.map(e=>e.map(e=>[e[0]+i,e[1]+r,e[2]+s])).flat(3)}),i(this,"getTileTexCoords",(e,t)=>{let n=this.textures[t],i=[this.tileSize/this.sheetSize[0],this.tileSize/this.sheetSize[1]];return this.geometry[e].surfaces.map(e=>e.map(e=>[(e[0]+n[0])*i[0],(e[1]+n[1])*i[1]])).flat(3)}),i(this,"getWalkability",e=>this.geometry[e].type),i(this,"getTileWalkPoly",e=>this.geometry[e].walkPoly),i(this,"getTileMetadata",e=>this.tileMetadata[e]||{}),this.engine=e,this.src=null,this.sheetSize=[0,0],this.tileSize=0,this.tiles={},this.tileMetadata={},this.loaded=!1,this.onLoadActions=new Xs,this.onDefinitionLoadActions=new Xs}}class Ha{constructor(e){this.engine=e,this.tilesets={}}async loadFromZip(e,t,n){Ma("Loader","loading tileset from zip: "+t+" for "+n);let i=this.tilesets[t];if(i)return i;let r=new Wa(this.engine);this.tilesets[t]=r,r.name=t;let s=JSON.parse(await e.file(`tilesets/${t}/tileset.json`).async("string")),a=await this.loadTilesetData(s,e);return await r.onJsonLoadedFromZip(a,e),r}async loadTilesetData(e,t){const n=e.name||"common";if(e.extends&&(await Promise.all(e.extends.map(async n=>{let i=JSON.parse(await t.file("tilesets/"+n+"/tileset.json").async("string"));e=Vs(e,i)})),e.extends=null),!e.tiles)try{const i=t.file(`tilesets/${n}/tiles.json`);i&&(e.tiles=JSON.parse(await i.async("string")),Ma("Loader",`[TilesetLoader] Loaded separate tiles.json for ${n}`))}catch(Yc){console.warn(`[TilesetLoader] No tiles.json found for ${n}`)}if(!e.geometry)try{const i=t.file(`tilesets/${n}/geometry.json`);i&&(e.geometry=JSON.parse(await i.async("string")),Ma("Loader",`[TilesetLoader] Loaded separate geometry.json for ${n}`))}catch(Yc){console.warn(`[TilesetLoader] No geometry.json found for ${n}`)}return Ma("Loader",{tilesetJson:e}),{name:e.name,src:e.src,sheetSize:e.sheetSize,sheetOffsetX:e.sheetOffsetX,sheetOffsetY:e.sheetOffsetY,tileSize:e.tileSize,bgColor:e.bgColor,textures:e.textures,geometry:e.geometry,tiles:e.tiles}}}class Ka extends Ys{constructor(e){super(),i(this,"onLoad",e=>{var t,n;if(!this.loaded)if(this.src&&this.sheetSize&&this.tileSize&&this.frames){if(console.log({msg:"sprite load",instanceData:e,objId:this.objId}),this.zone=e.zone,e.id&&(this.id=e.id),e.pos&&(this.pos=e.pos,this.pos&&(null===this.pos.z||void 0===this.pos.z)))try{const e=this.pos.x+((null==(t=this.hotspotOffset)?void 0:t.x)??0),i=this.pos.y+((null==(n=this.hotspotOffset)?void 0:n.y)??0),r=this.zone.getHeight(e,i);this.pos.z="number"==typeof r?r:0}catch(i){console.warn("Error computing sprite height from zone",i),this.pos.z=0}if(e.isLit&&(this.isLit=e.isLit),e.attenuation&&(this.attenuation=e.attenuation),e.direction&&(this.direction=e.direction),e.lightColor&&(this.lightColor=e.lightColor),e.density&&(this.density=e.density),e.scatteringCoefficients&&(this.scatteringCoefficients=e.scatteringCoefficients),e.rotation&&(this.rotation=e.rotation),e.facing&&0!==e.facing&&(this.facing=e.facing),e.zones&&null!==e.zones&&(this.zones=e.zones),e.onStep&&"function"==typeof e.onStep){let t=this.onStep;this.onStep=async()=>{await e.onStep(this,this),await t(this,this)}}if(e.onSelect&&"function"==typeof e.onSelect){let t=this.onSelect;this.onSelect=async()=>{await e.onSelect(this,this),await t(this,this)}}this.texture=this.engine.resourceManager.loadTexture(this.src),this.texture.runWhenLoaded(this.onTilesetOrTextureLoaded),this.vertexTexBuf=this.engine.renderManager.createBuffer(this.getTexCoords(),this.engine.gl.DYNAMIC_DRAW,2),this.enableSpeech&&(this.speech=this.engine.resourceManager.loadSpeech(this.id,this.engine.mipmap),this.speech.runWhenLoaded(this.onTilesetOrTextureLoaded),this.speechTexBuf=this.engine.renderManager.createBuffer(this.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),this.portraitSrc&&(this.portrait=this.engine.resourceManager.loadTexture(this.portraitSrc),this.portrait.runWhenLoaded(this.onTilesetOrTextureLoaded)),this.isLit&&(console.log({msg:"Adding Light Loaded",id:this.id,pos:this.pos.toArray()}),this.lightIndex=this.engine.renderManager.lightManager.addLight(this.id,this.pos.toArray(),this.lightColor,this.attenuation??[.01,.01,.01],this.direction,this.density,this.scatteringCoefficients,!0)),this.zone.tileset.runWhenDefinitionLoaded(this.onTilesetDefinitionLoaded)}else console.error("Invalid sprite definition")}),i(this,"onLoadFromZip",async(e,t)=>{var n,i;if(!this.loaded)if(this.src&&this.sheetSize&&this.tileSize&&this.frames){if(console.log({msg:"sprite load from zip",instanceData:e}),this.update(e),this.zone=e.zone,e.id&&(this.id=e.id),e.isLit&&(this.isLit=e.isLit),e.lightColor&&(this.lightColor=e.lightColor),e.density&&(this.density=e.density),e.attenuation&&(this.attenuation=e.attenuation),e.direction&&(this.direction=e.direction),e.scatteringCoefficients&&(this.scatteringCoefficients=e.scatteringCoefficients),e.fixed&&(this.fixed=e.fixed),e.pos&&(this.pos=e.pos,this.pos&&(null===this.pos.z||void 0===this.pos.z)))try{const e=this.pos.x+((null==(n=this.hotspotOffset)?void 0:n.x)??0),t=this.pos.y+((null==(i=this.hotspotOffset)?void 0:i.y)??0),r=this.zone.getHeight(e,t);this.pos.z="number"==typeof r?r:0}catch(r){console.warn("Error computing sprite height from zone",r),this.pos.z=0}if(e.facing&&0!==e.facing&&(this.facing=e.facing),e.zones&&null!==e.zones&&(this.zones=e.zones),e.onStep&&"function"==typeof e.onStep){let t=this.onStep;this.onStep=async()=>{await e.onStep(this,this),await t(this,this)}}this.texture=await this.engine.resourceManager.loadTextureFromZip(this.src,t),this.texture.runWhenLoaded(this.onTilesetOrTextureLoaded),this.vertexTexBuf=this.engine.renderManager.createBuffer(this.getTexCoords(),this.engine.gl.DYNAMIC_DRAW,2),this.enableSpeech&&(this.speech=this.engine.resourceManager.loadSpeech(this.id,this.engine.mipmap),this.speech.runWhenLoaded(this.onTilesetOrTextureLoaded),this.speechTexBuf=this.engine.renderManager.createBuffer(this.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),this.portraitSrc&&(this.portrait=await this.engine.resourceManager.loadTextureFromZip(this.portraitSrc,t),this.portrait.runWhenLoaded(this.onTilesetOrTextureLoaded)),this.isLit&&(this.lightIndex=this.engine.renderManager.lightManager.addLight(this.id,this.pos.toArray(),this.lightColor,this.attenuation??[.01,.01,.01],this.direction,this.density,this.scatteringCoefficients,!0)),this.zone.tileset.runWhenDefinitionLoaded(this.onTilesetDefinitionLoaded)}else console.error("Invalid sprite definition")}),i(this,"onTilesetDefinitionLoaded",()=>{let e=this.zone.tileset.tileSize,t=[this.tileSize[0]/e,this.tileSize[1]/e],n=[[0,0,0],[t[0],0,0],[t[0],0,t[1]],[0,0,t[1]]],i=[[n[2],n[3],n[0]],[n[2],n[0],n[1]]].flat(3);this.vertexPosBuf=this.engine.renderManager.createBuffer(i,this.engine.gl.STATIC_DRAW,3),this.enableSpeech&&(this.speechVerBuf=this.engine.renderManager.createBuffer(this.getSpeechBubbleVertices(),this.engine.gl.STATIC_DRAW,3)),this.zone.tileset.runWhenLoaded(this.onTilesetOrTextureLoaded)}),i(this,"onTilesetOrTextureLoaded",()=>{!this||this.loaded||!this.zone.tileset.loaded||!this.texture.loaded||this.enableSpeech&&this.speech&&!this.speech.loaded||this.portrait&&!this.portrait.loaded||(this.init(),this.enableSpeech&&this.speech&&this.speech.clearHud&&(this.speech.clearHud(),this.speech.writeText(this.id),this.speech.loadImage()),this.loaded=!0,this.onLoadActions.run())}),i(this,"getTexCoords",()=>{let e=Us.spriteSequence(this.facing,this.engine.renderManager.camera.cameraDir),t=this.frames[e]??this.frames.N,n=t.length,i=t[this.animFrame%n],r=this.sheetSize,s=this.tileSize,a=[(i[0]+s[0])/r[0],i[1]/r[1]],o=[i[0]/r[0],(i[1]+s[1])/r[1]],l=[a,[o[0],a[1]],o,[a[0],o[1]]];return[[l[0],l[1],l[2]],[l[0],l[2],l[3]]].flat(3)}),i(this,"getSpeechBubbleTexture",()=>[[1,1],[0,1],[0,0],[1,1],[0,0],[1,0]].flat(3)),i(this,"getSpeechBubbleVertices",()=>[new ot(...[2,0,4]).toArray(),new ot(...[0,0,4]).toArray(),new ot(...[0,0,2]).toArray(),new ot(...[2,0,4]).toArray(),new ot(...[0,0,2]).toArray(),new ot(...[2,0,2]).toArray()].flat(3)),i(this,"draw",()=>{if(!this.loaded)return;this.engine&&this.engine.renderManager&&this.engine.renderManager.debug&&this.engine.renderManager.debug.spritesDrawn++;const e=this.engine.renderManager,t=e.isPickerPass;if(this.isLit){let t=this.pos.toArray();e.lightManager.updateLight(this.lightIndex,t)}let n;e.mvPushMatrix(),n=this.drawOffset&&"object"==typeof this.drawOffset?this.drawOffset.toArray?this.drawOffset:this.drawOffset[e.camera.cameraDir]??this.drawOffset.N??new ot(0,0,0):new ot(0,0,0);const i=n.toArray?n.toArray():[0,0,0];xs(e.uModelMat,e.uModelMat,this.pos.toArray()),this.fixed||(t||e.shaderProgram.setMatrixUniforms({id:this.getPickingId(),scale:new ot(1,Math.cos(e.camera.cameraAngle/180),1)}),xs(e.uModelMat,e.uModelMat,[.5*e.camera.cameraVector.x,.5*e.camera.cameraVector.y,0]),_s(e.uModelMat,e.uModelMat,ct(e.camera.cameraAngle*e.camera.cameraVector.z),[0,0,-1]),xs(e.uModelMat,e.uModelMat,[-.5*e.camera.cameraVector.x,-.5*e.camera.cameraVector.y,0])),xs(e.uModelMat,e.uModelMat,i),e.bindBuffer(this.vertexPosBuf,e.shaderProgram.aVertexPosition),e.bindBuffer(this.vertexTexBuf,e.shaderProgram.aTextureCoord),this.texture.attach(),t?e.effectPrograms.picker.setMatrixUniforms({sampler:1,id:this.getPickingId(),scale:new ot(1,Math.cos(e.camera.cameraAngle/180),1)}):this.isSelected?e.shaderProgram.setMatrixUniforms({id:this.getPickingId(),isSelected:!0,sampler:1,colorMultiplier:8&this.engine.frameCount?[1,0,0,1]:[1,1,0,1]}):e.shaderProgram.setMatrixUniforms({id:this.getPickingId(),sampler:1}),this.engine.gl.depthFunc(this.engine.gl.ALWAYS),this.engine.gl.drawArrays(this.engine.gl.TRIANGLES,0,this.vertexPosBuf.numItems),this.engine.gl.depthFunc(this.engine.gl.LESS),e.mvPopMatrix(),this.enableSpeech&&!t&&(e.mvPushMatrix(),xs(e.uModelMat,e.uModelMat,i),xs(e.uModelMat,e.uModelMat,this.pos.toArray()),_s(e.uModelMat,e.uModelMat,ct(e.camera.cameraAngle*e.camera.cameraVector.z),[0,0,-1]),e.bindBuffer(this.speechVerBuf,e.shaderProgram.aVertexPosition),e.bindBuffer(this.speechTexBuf,e.shaderProgram.aTextureCoord),this.speech.attach(),e.shaderProgram.setMatrixUniforms({id:this.getPickingId()}),this.engine.gl.depthFunc(this.engine.gl.ALWAYS),this.engine.gl.drawArrays(this.engine.gl.TRIANGLES,0,this.speechVerBuf.numItems),this.engine.gl.depthFunc(this.engine.gl.LESS),e.mvPopMatrix())}),i(this,"getPickingId",()=>[(255&this.objId)/255,(this.objId>>8&255)/255,(this.objId>>16&255)/255,255]),i(this,"setFrame",e=>{this.animFrame=e,this.engine.renderManager.updateBuffer(this.vertexTexBuf,this.getTexCoords())}),i(this,"setFacing",e=>{e&&(this.facing=e),this.setFrame(this.animFrame)}),i(this,"addAction",async e=>{e=await Promise.resolve(e),this.actionDict[e.id]&&this.removeAction(e.id),this.actionDict[e.id]=e,this.actionList.push(e)}),i(this,"removeAction",e=>{this.actionList=this.actionList.filter(t=>t.id!==e),delete this.actionDict[e]}),i(this,"removeAllActions",()=>{this.actionList=[],this.actionDict={}}),i(this,"tickOuter",e=>{if(!this.loaded)return;this.actionList.sort((e,t)=>{let n=e.startTime-t.startTime;return n?e.id>t.id?1:-1:n});let t=[];this.actionList.forEach(n=>{if(n.loaded&&!(n.startTime>e))try{n.tick(e)&&(t.push(n),n.onComplete())}catch(Yc){console.error(Yc),t.push(n)}}),t.forEach(e=>this.removeAction(e.id)),this.tick&&this.tick(e)}),i(this,"init",()=>{}),i(this,"loadRemote",async e=>{let t=await fetch(e);if(!t.ok)throw new Error;this.update(t.json())}),i(this,"speak",(e,t=!1,n={})=>{!e&&this.speech.clearHud?this.speech.clearHud():(n.speechOutput&&(this.speechSynthesis(e),n.speechOutput=!1),this.textbox=this.engine.hud.scrollText(this.id+":> "+e,!0,{portrait:this.portrait??!1}),t&&this.speech&&(this.speech.scrollText(e,!1,{portrait:this.portrait??!1}),this.speech.loadImage()))}),i(this,"speechSynthesis",(e,t=null,n="en",i=null,r=null,s=null)=>{let a=this.voice,o=window.speechSynthesis.getVoices()??[];a.voice=this.gender?"male"==this.gender?o[7]:o[28]:o[0],i&&(a.rate=i),r&&(a.volume=r),s&&(a.pitch=s),a.text=e,a.lang=n,window.speechSynthesis.speak(a)}),i(this,"interact",async(e,t)=>(this.state,t&&t(!0),null)),i(this,"faceDir",(e,t=!1)=>!t&&this.facing==e||e===Us.None?null:new Ac(this.engine,"face",[e],this)),i(this,"setGreeting",e=>(this.speech.clearHud&&this.speech.clearHud(),this.speech.writeText(e),this.speech.loadImage(),new Ac(this.engine,"greeting",[e,{autoclose:!0}],this))),this.objId=Math.round(100*Math.random())+11,this.engine=e,this.templateLoaded=!1,this.drawOffset=new ot(0,0,0),this.hotspotOffset=new ot(0,0,0),this.animFrame=0,this.fixed=!1,this.pos=new ot(0,0,0),this.scale=new ot(1,1,1),this.facing=Us.Right,this.actionDict={},this.actionList=[],this.gender=null,this.speech={},this.portrait=null,this.onLoadActions=new Xs,this.inventory=[],this.blocking=!0,this.override=!1,this.isLit=!0,this.lightIndex=null,this.lightColor=[.1,1,.1],this.density=1,this.voice=new SpeechSynthesisUtterance,this.isSelected=!1}}class Za extends Ka{constructor(e){super(e),i(this,"getAvatarData",()=>({id:this.objId,templateLoaded:this.templateLoaded,drawOffset:this.drawOffset,hotspotOffset:this.hotspotOffset,animFrame:this.animFrame,fixed:this.fixed,pos:this.pos,scale:this.scale,facing:this.facing,actionDict:this.actionDict,actionList:this.actionList,gender:this.gender,speech:this.speech,portrait:this.portrait,inventory:this.inventory,blocking:this.blocking,override:this.override,isLit:this.isLit,lightIndex:this.lightIndex,lightColor:this.lightColor,density:this.density,isSelected:this.isSelected})),i(this,"init",()=>{console.log({msg:"- avatar hook",id:this.id,pos:this.pos,avatar:this})}),i(this,"tick",e=>{if(!this.actionList.length){let e=this.checkInput();e&&this.addAction(e).then(()=>{this.engine.networkManager&&this.engine.networkManager.ws&&this.engine.networkManager.ws.readyState===WebSocket.OPEN&&this.engine.networkManager.sendAction(e,this)})}var t,n;this.engine.networkManager&&this.engine.networkManager.ws&&this.engine.networkManager.ws.readyState===WebSocket.OPEN&&this.engine.networkManager.updateAvatarPosition(this),this.bindCamera&&(t=this.pos,(n=this.engine.renderManager.camera.cameraPosition).x=t.x,n.y=t.y,n.z=t.z)}),i(this,"checkInput",()=>this.engine.inputManager.getAvatarAction(this)),i(this,"openMenu",(e={},t=[])=>new Ac(this.engine,"prompt",[e,t,!1,{autoclose:!1}],this)),i(this,"handleWalk",(e,t,n=null)=>{let i=600,r=null!==n?n:Us.None;if(null===n)switch(e){case"w":r=Us.Up;break;case"s":r=Us.Down;break;case"a":r=Us.Left;break;case"d":r=Us.Right;break;case"p":return new Ac(this.engine,"patrol",[this.pos.toArray(),new ot(8,13,this.pos.z).toArray(),600,this.zone],this);case"r":return new Ac(this.engine,"patrol",[this.pos.toArray(),new ot(8,13,this.pos.z).toArray(),200,this.zone],this)}if(1===t["x-dir"]&&(r=Us.Right),-1===t["x-dir"]&&(r=Us.Left),1===t["y-dir"]&&(r=Us.Down),-1===t["y-dir"]&&(r=Us.Up),i=this.engine.keyboard.shift||this.engine.gamepad.keyPressed("y")?200:600,this.facing!==r)return this.faceDir(r);let s=this.pos,a=Us.toOffset(r),o=new ot(...[Math.round(s.x+a[0]),Math.round(s.y+a[1]),0]);if(!this.zone.isInZone(o.x,o.y)){let e=this.zone.world.zoneContaining(o.x,o.y);return e&&e.loaded&&e.isWalkable(o.x,o.y,Us.reverse(r))?new Ac(this.engine,"changezone",[this.zone.id,this.pos.toArray(),e.id,o.toArray(),i],this):this.faceDir(r)}return this.zone.isWalkable(o.x,o.y,Us.reverse(r))?new Ac(this.engine,"move",[this.pos.toArray(),o.toArray(),i,this.zone],this):this.faceDir(r)}),this.isLit=!0,this.isSelected=!0}}class Ga{constructor(e,t={}){this.engine=e,this.callbacks={onDialogueShow:t.onDialogueShow||null,onDialogueHide:t.onDialogueHide||null,onBackdropChange:t.onBackdropChange||null,onCutsceneStart:t.onStart||t.onCutsceneStart||null,onCutsceneEnd:t.onEnd||t.onCutsceneEnd||null},this.characters={},this.currentBackdrop=null,this.backdropImage=null,this.portraitImage=null,this.cutinImage=null,this.currentSpeaker="",this.currentText="",this.displayedText="",this.isTyping=!1,this.isPlaying=!1,this.isPaused=!1,this.skipRequested=!1,this.typewriterSpeed=40,this.autoAdvance=!1,this.autoAdvanceDelay=1500,this.bgmAudio=null,this.sfxAudio=null,this.voiceAudio=null,this.resourceCache={},this.dialogueStyle={boxColor:"rgba(20, 30, 50, 0.9)",borderColor:"#4a9eff",textColor:"#ffffff",speakerColor:"#4af0ff",font:"20px minecraftia",speakerFont:"16px minecraftia",padding:20,portraitSize:100}}parseScript(e){const t=e.split("\n"),n=[];let i=null,r=!1,s=[];for(let a=0;a<t.length;a++){let e=t[a].trim();if(e&&!e.startsWith("#"))if(r&&e.includes('"""'))e=e.replace('"""',"").trim(),e&&s.push(e),i.text=s.join("\n"),n.push(i),i=null,r=!1,s=[];else if(r)s.push(e);else{if(e.startsWith("@")){const t=this.parseCommand(e);t&&n.push(t);continue}if(e.startsWith("wait "))n.push({type:"wait",duration:parseInt(e.replace("wait","").trim())});else if("waitInput"!==e&&"wait_input"!==e){if(e.includes(":")){const t=e.startsWith("*");t&&(e=e.substring(1).trim());const[a,...o]=e.split(":"),l=o.join(":").trim(),c=l.match(/^\[([^\]]+)\]/),h=c?this.parseBracket(c[1]):{};let u=c?l.substring(c[0].length).trim():l;if(u.startsWith('"""')){u=u.replace('"""',"").trim(),r=!0,s=u?[u]:[],i={type:"dialogue",actor:a.trim(),text:"",isCutin:t,meta:h};continue}n.push({type:"dialogue",actor:a.trim(),text:u.replace(/^["']|["']$/g,""),isCutin:t,meta:h})}}else n.push({type:"waitInput"})}}return n}parseCommand(e){const t=e.substring(1).trim().split(/\s+/),n=t[0],i=t.slice(1).join(" "),r=i.match(/\[([^\]]+)\]/),s=r?this.parseBracket(r[1]):{},a=r?i.replace(r[0],"").trim():i;switch(n){case"backdrop":return{type:"backdrop",url:a||s.url||s.file,options:s};case"char":const e=a.split(/\s+/),t=e[0],i={...s};return e.slice(1).forEach(e=>{if(e.includes("=")){const[t,n]=e.split(/=(.+)/);i[t]=n.replace(/^"|"$/g,"")}}),{type:"char",name:t,sprite:i.sprite,portrait:i.portrait,options:i};case"action":const r=a.match(/(?:[^\s\[]+|\[[^\]]*\])/g)||[];return{type:"action",actor:r[0],verb:r[1],args:s};case"do":return{type:"hook",action:a.split(/\s+/)[0],args:s};case"transition":return{type:"transition",effect:a||s.effect||"fade",direction:s.direction||"out",options:s};case"end":return{type:"end"};default:return console.warn("[PxcPlayer] Unknown command:",n),null}}parseBracket(e){const t={},n=e.split(",");for(const i of n){const e=i.trim();if(e.includes("=")){const[n,...i]=e.split("=");let r=i.join("=").trim().replace(/^"|"$/g,"");/^\d+$/.test(r)?r=parseInt(r,10):/^\d+\.\d+$/.test(r)?r=parseFloat(r):"true"===r?r=!0:"false"===r&&(r=!1),t[n.trim()]=r}else t[e]=!0}return t}async loadAsset(e,t=!1){var n,i,r;if(!e)return null;if(this.resourceCache[e])return this.resourceCache[e];if(e.startsWith("data:")){const n=e.replace("data:",""),i=this.generatePlaceholder(n,t);return this.resourceCache[e]=i,i}if(this.engine&&this.engine.resourceManager)try{const t=await this.engine.resourceManager.loadResource(e);if(t)return this.resourceCache[e]=t,t}catch(o){console.warn(`[PxcPlayer] Failed to load asset: ${e}`,o)}if(null==(r=null==(i=null==(n=this.engine)?void 0:n.spritz)?void 0:i.world)?void 0:r.zip)try{const t=this.engine.spritz.world.zip.getEntry(e);if(t){const n=await t.async("blob"),i=URL.createObjectURL(n);return this.resourceCache[e]=i,i}}catch(o){console.warn(`[PxcPlayer] Failed to load from zip: ${e}`,o)}const s=e.split("/").pop()||(t?"BACKDROP":"SPRITE"),a=this.generatePlaceholder(s,t);return this.resourceCache[e]=a,a}generatePlaceholder(e,t=!1){const n=(e||"UNKNOWN").toUpperCase();if(t){return"data:image/svg+xml;utf8,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900"><rect width="100%" height="100%" fill="#08202a"/><text x="50%" y="80%" font-size="64" fill="#aee6ff" text-anchor="middle" font-family="system-ui, sans-serif" font-weight="bold">${n}</text></svg>`)}return"data:image/svg+xml;utf8,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"><rect width="100%" height="100%" fill="#112430"/><text x="50%" y="50%" font-size="72" fill="#7dd3fc" text-anchor="middle" dominant-baseline="middle" font-family="system-ui, sans-serif" font-weight="bold">${n}</text></svg>`)}async loadImage(e){return new Promise((t,n)=>{const i=new Image;i.onload=()=>t(i),i.onerror=e=>n(e),i.src=e})}async playCutscene(e){if(this.isPlaying)return void console.warn("[PxcPlayer] Cutscene already playing");this.isPlaying=!0,this.skipRequested=!1;const t=this.parseScript(e);console.log("[PxcPlayer] Playing cutscene with",t.length,"events"),this.callbacks.onCutsceneStart&&this.callbacks.onCutsceneStart();for(const n of t){if(!this.isPlaying)break;if(this.skipRequested)break;await this.handleEvent(n)}this.isPlaying=!1,this.cleanup(),this.callbacks.onCutsceneEnd&&this.callbacks.onCutsceneEnd()}async playCutsceneFile(e){var t,n,i;try{let r=null;if(null==(i=null==(n=null==(t=this.engine)?void 0:t.spritz)?void 0:n.world)?void 0:i.zip){const t=this.engine.spritz.world.zip.getEntry(e);t&&(r=await t.async("string"))}if(!r){const t=await fetch(e);r=await t.text()}r?await this.playCutscene(r):console.error("[PxcPlayer] Could not load cutscene file:",e)}catch(r){console.error("[PxcPlayer] Error loading cutscene:",r)}}async handleEvent(e){switch(e.type){case"backdrop":await this.showBackdrop(e.url,e.options);break;case"char":await this.defineCharacter(e.name,e.sprite,e.portrait,e.options);break;case"dialogue":await this.showDialogue(e);break;case"action":await this.doAction(e.actor,e.verb,e.args);break;case"hook":await this.doHook(e.action,e.args);break;case"transition":await this.doTransition(e.effect,e.options);break;case"wait":await this.wait(e.duration);break;case"waitInput":await this.waitForInput();break;case"end":this.isPlaying=!1;break;default:console.warn("[PxcPlayer] Unknown event type:",e.type)}}async showBackdrop(e,t={}){var n;this.currentBackdrop=e,console.log("[PxcPlayer] Backdrop:",e,t);try{const t=await this.loadAsset(e,!0);this.backdropImage=await this.loadImage(t),(null==(n=this.engine)?void 0:n.hud)&&this.engine.hud.setBackdrop(this.backdropImage)}catch(i){console.warn("[PxcPlayer] Failed to load backdrop:",e,i)}this.callbacks.onBackdropChange&&this.callbacks.onBackdropChange(e,t),t.fadeIn&&await this.wait(parseInt(t.fadeIn))}async defineCharacter(e,t,n,i={}){this.characters[e]={sprite:t,portrait:n,options:i},console.log("[PxcPlayer] Defined character:",e,t,n);const r=n||t;if(r)try{const t=await this.loadAsset(r,!1);this.characters[e].portraitImage=await this.loadImage(t)}catch(s){console.warn("[PxcPlayer] Failed to load portrait for",e,s)}}async showDialogue(e){var t,n,i,r,s;const a=this.characters[e.actor],o=(null==a?void 0:a.sprite)||(null==(t=e.meta)?void 0:t.sprite),l=(null==a?void 0:a.portrait)||(null==(n=e.meta)?void 0:n.portrait);this.currentSpeaker=e.actor,this.currentText=e.text,this.displayedText="",this.isTyping=!0,console.log("[PxcPlayer] Dialogue:",e.actor,e.text);let c=(null==a?void 0:a.portraitImage)||null;if(!c&&(l||o))try{const e=await this.loadAsset(l||o,!1);c=await this.loadImage(e)}catch(u){console.warn("[PxcPlayer] Failed to load portrait:",l||o,u)}e.isCutin?(this.cutinImage=c,this.portraitImage=null):(this.portraitImage=c,this.cutinImage=null);let h=null;(null==(i=e.meta)?void 0:i.voice)&&(h=this.playVoiceBlocking(e.meta.voice)),await this.typeText(e.text),h&&await h,this.callbacks.onDialogueShow&&this.callbacks.onDialogueShow({actor:e.actor,text:e.text,sprite:o,portrait:c,expression:(null==(r=e.meta)?void 0:r.expression)||"neutral",position:(null==(s=e.meta)?void 0:s.position)||"center",isCutin:e.isCutin,meta:e.meta}),this.autoAdvance?await this.wait(this.autoAdvanceDelay):await this.waitForInput(),this.isTyping=!1,this.callbacks.onDialogueHide&&this.callbacks.onDialogueHide()}async typeText(e){const t=e.split("");this.displayedText="";for(let n=0;n<t.length;n++){if(!this.isPlaying||this.skipRequested){this.displayedText=e;break}this.displayedText+=t[n],this.renderDialogue();let i=this.typewriterSpeed;/[.,!?;:]/.test(t[n])&&(i+=1.5*this.typewriterSpeed),await this.wait(i)}this.renderDialogue()}renderDialogue(){var e,t;if(!(null==(t=null==(e=this.engine)?void 0:e.hud)?void 0:t.ctx))return;const n=this.engine.hud.ctx,i=n.canvas,r=this.dialogueStyle;if(this.engine.hud.scrollText){const e={portrait:this.portraitImage?{image:this.portraitImage}:null,fontStyle:r.textColor,background:r.boxColor,border:{lineWidth:2,style:r.borderColor,corner:"round"}};this.engine.hud.drawCutsceneElements&&this.engine.hud.drawCutsceneElements(),n.font=r.speakerFont,n.fillStyle=r.speakerColor,n.textAlign="left";const t=2*i.height/3;n.fillText(this.currentSpeaker,r.padding+(this.portraitImage?r.portraitSize+10:0),t-25),this.engine.hud.scrollText(this.displayedText,!1,e)}}async doAction(e,t,n={}){switch(console.log("[PxcPlayer] Action:",e,t,n),t){case"moveTo":await this.wait(n.duration||300);break;case"fadeIn":case"fadeOut":await this.wait(n.duration||500);break;case"shake":await this.wait(n.duration||200);break;default:console.warn("[PxcPlayer] Unknown action verb:",t)}}async doHook(e,t){var n,i,r;switch(console.log("[PxcPlayer] Hook:",e,t),e){case"playBgm":this.playBgm(t.name);break;case"playSfx":this.playSfx(t.name);break;case"playVoice":await this.playVoiceBlocking(t.name);break;case"stopBgm":this.stopBgm();break;case"stopAll":this.stopAll();break;case"setFlag":(null==(n=this.engine)?void 0:n.store)&&t.name&&this.engine.store.set(t.name,t.value??!0);break;case"runScript":if((null==(r=null==(i=this.engine)?void 0:i.spritz)?void 0:r.interpreter)&&t.name)try{await this.engine.spritz.interpreter.runScript(t.name)}catch(s){console.warn("[PxcPlayer] Script execution failed:",t.name,s)}break;default:console.warn("[PxcPlayer] Unknown hook action:",e)}}playBgm(e){this.stopBgm(),console.log("[PxcPlayer] Playing BGM:",e),this.loadAsset(e).then(e=>{e&&(this.bgmAudio=new Audio(e),this.bgmAudio.loop=!0,this.bgmAudio.volume=.7,this.bgmAudio.play().catch(e=>console.warn("[PxcPlayer] BGM autoplay blocked:",e)))}).catch(e=>console.error("[PxcPlayer] Failed to load BGM:",e))}playSfx(e){console.log("[PxcPlayer] Playing SFX:",e),this.loadAsset(e).then(e=>{if(!e)return;const t=new Audio(e);t.volume=.8,t.play().catch(e=>console.warn("[PxcPlayer] SFX autoplay blocked:",e))}).catch(e=>console.error("[PxcPlayer] Failed to load SFX:",e))}async playVoiceBlocking(e){return console.log("[PxcPlayer] Playing Voice:",e),new Promise(async t=>{try{const n=await this.loadAsset(e);if(!n)return void t();this.voiceAudio&&this.voiceAudio.pause(),this.voiceAudio=new Audio(n),this.voiceAudio.volume=1,this.voiceAudio.onended=()=>{this.voiceAudio=null,t()},this.voiceAudio.onerror=()=>{this.voiceAudio=null,t()},this.voiceAudio.play().catch(e=>{console.warn("[PxcPlayer] Voice autoplay blocked:",e),t()})}catch(n){console.error("[PxcPlayer] Failed to load voice:",n),t()}})}stopBgm(){this.bgmAudio&&(this.bgmAudio.pause(),this.bgmAudio=null)}stopAll(){this.stopBgm(),this.sfxAudio&&(this.sfxAudio.pause(),this.sfxAudio=null),this.voiceAudio&&(this.voiceAudio.pause(),this.voiceAudio=null)}async doTransition(e,t={}){var n;if(console.log("[PxcPlayer] Transition:",e,t),null==(n=this.engine)?void 0:n.renderManager){const n=t.duration||500,i=t.direction||"out";await this.engine.renderManager.startTransition({effect:e,direction:i,duration:n})}else await this.wait(t.duration||500)}wait(e){return new Promise(t=>setTimeout(t,e))}waitForInput(){return new Promise(e=>{const t=n=>{n.ctrlKey||n.altKey||n.metaKey||(document.removeEventListener("click",t),document.removeEventListener("keydown",t),document.removeEventListener("touchend",t),e())};document.addEventListener("click",t),document.addEventListener("keydown",t),document.addEventListener("touchend",t)})}skip(){this.skipRequested=!0}pause(){this.isPaused=!0}resume(){this.isPaused=!1}cleanup(){var e;this.stopAll(),this.characters={},this.currentBackdrop=null,this.backdropImage=null,this.portraitImage=null,this.cutinImage=null,this.currentSpeaker="",this.currentText="",this.displayedText="",(null==(e=this.engine)?void 0:e.hud)&&(this.engine.hud.setBackdrop(null),this.engine.hud.setCutouts([])),Object.values(this.resourceCache).forEach(e=>{e&&"string"==typeof e&&e.startsWith("blob:")&&URL.revokeObjectURL(e)}),this.resourceCache={}}stop(){this.isPlaying=!1,this.cleanup()}setSpeed(e){this.typewriterSpeed=e}setAutoAdvance(e,t=1500){this.autoAdvance=e,this.autoAdvanceDelay=t}setDialogueStyle(e){Object.assign(this.dialogueStyle,e)}}class Xa{constructor(e){i(this,"getLibrary",(e,t)=>(Ma("PixoScriptLibrary","creating library",{envScope:t}),new this.pixoscript.Table({...t,get_caller:()=>t._this,get_subject:()=>t.subject,get_map:()=>t.map||t.zone,get_zone:()=>t.map||t.zone,get_world:()=>e.spritz.world,send_action:(t=!1)=>{const{networkManager:n}=e;if(n&&n.ws){const e=n.sendAction(t.toObject());return t?()=>Promise.resolve(e):e}return!!t&&(()=>Promise.resolve(!1))},all_flags:(t=!1)=>{const n=e.store.all();return t?()=>Promise.resolve(n):n},has_flag:(t,n=!1)=>{Ma("PixoScript","checking flag via lua",t,n);const i=e.store.keys().includes(t);return n?()=>Promise.resolve(i):i},set_flag:(t,n,i=!1)=>{Ma("PixoScript","setting flag via lua",t,i);const r=e.store.set(t,n.toObject());return i?()=>Promise.resolve(r):r},add_flag:(t,n,i=!1)=>(Ma("PixoScript","adding flag via lua",t,i),e.store.add(t,n.toObject()),!i||(()=>Promise.resolve(!0))),get_flag:(t,n=!1)=>{Ma("PixoScript","getting flag via lua",t,n);const i=e.store.get(t);return n?()=>Promise.resolve(i):i},remove_all_zones:()=>(Ma("PixoScript","removing all zones via lua"),e.spritz.world.removeAllZones()),load_zone_from_zip:(t,n)=>(Ma("PixoScript","loading zone from zip via lua",{world:e.spritz.world,z:t,zip:n}),e.spritz.world.loadZoneFromZip(t,n,!1)),register_cutscene:(t,n)=>{try{const i=this.pixoscript.utils.ensureArray(n.toObject()).map(e=>e&&"function"==typeof e.toObject?e.toObject():e);e.cutsceneManager.register(t,i)}catch(Yc){console.warn("Failed to register cutscene from Lua",Yc)}},start_cutscene:t=>{try{e.cutsceneManager.start(t)}catch(Yc){console.warn("Failed to start cutscene",t,Yc)}},skip_cutscene:()=>{try{e.cutsceneManager.skip()}catch(Yc){console.warn("Failed to skip cutscene",Yc)}},set_backdrop:t=>{try{e.cutsceneManager.setBackdrop({backdrop:t})}catch(Yc){console.warn("Failed to set backdrop",Yc)}},show_cutout:(t,n,i="left")=>{try{e.cutsceneManager.showCutout({sprite:t,cutout:n,position:i})}catch(Yc){console.warn("Failed to show cutout",Yc)}},play_cutscene:n=>()=>new Promise(async i=>{var r,s,a;try{if("string"==typeof n&&n.endsWith(".pxc")){const t=await e.assetLoader.load(n);if(t){const n=new Ga(e,{onEnd:()=>i()});await n.playCutscene(t)}else console.warn("[play_cutscene] Failed to load cutscene file:",n),i()}else if(e.cutsceneManager&&(null==(s=(r=e.cutsceneManager).isRegistered)?void 0:s.call(r,n))){e.cutsceneManager.start(n);const t=()=>{e.cutsceneManager.isRunning()?setTimeout(t,30):i()};t()}else(null==(a=t.zone)?void 0:a.playCutscene)?(await t.zone.playCutscene(n),i()):(console.warn("[play_cutscene] Cutscene not found:",n),i())}catch(Yc){console.warn("[play_cutscene] Error playing cutscene:",Yc),i()}}),run_cutscene:t=>()=>new Promise(n=>{try{const i=this.pixoscript.utils.ensureArray(t.toObject()).map(e=>e&&"function"==typeof e.toObject?e.toObject():e),r="__lua_cutscene_"+Date.now()+"_"+Math.floor(1e4*Math.random());e.cutsceneManager.register(r,i),e.cutsceneManager.start(r);const s=()=>{e.cutsceneManager.isRunning()?setTimeout(s,30):n()};s()}catch(Yc){console.warn("Failed to run cutscene",Yc),n()}}),run_transition:(t="fade",n="out",i=500)=>()=>{new Promise(r=>{const s=e.renderManager;return s||r(),s.startTransition({effect:t,direction:n,duration:i}).then(()=>r())})},sprite_dialogue:(e,n,i={})=>()=>new Promise(r=>(Ma("PixoScript","playing dialogue via lua",{zone:t.zone,spriteId:e,dialogue:n}),i.onClose=()=>r(),t.zone.spriteDialogue(e,n,i).then(()=>{Ma("PixoScript","played dialogue via lua",{zone:t.zone,spriteId:e,dialogue:n})}))),move_sprite:(e,n,i)=>()=>new Promise(r=>(Ma("PixoScript","moving sprite via lua",{zone:t.zone,spriteId:e,location:n,running:i}),t.zone.moveSprite(e,this.pixoscript.utils.ensureArray(n.toObject()),i).then(()=>{Ma("PixoScript","moved sprite via lua",{zone:t.zone,spriteId:e,location:n,running:i}),r()}))),load_scripts:e=>(Ma("PixoScript","loading scripts via lua",{scripts:e,envScope:t}),t.zone.loadScripts(e)),play_pxc_cutscene:(t,n={})=>()=>new Promise(async i=>{try{const r=await e.assetLoader.load(t);if(!r)return console.error("[PixoScript] Failed to load cutscene:",t),void i();const s={onDialogueShow:n.onDialogueShow||(e=>{Ma("PxcPlayer","Dialogue:",e.actor,e.text)}),onBackdropChange:n.onBackdropChange||((e,t)=>{Ma("PxcPlayer","Backdrop:",e)}),onEnd:()=>{Ma("PxcPlayer","Cutscene ended"),n.onEnd&&n.onEnd(),i()}},a=new Ga(e,s);await a.playCutscene(r)}catch(Yc){console.error("[PixoScript] Error playing .pxc cutscene:",Yc),i()}}),play_pxc_script:(t,n={})=>()=>new Promise(async i=>{try{Ma("PixoScript","Playing inline .pxc script");const r={onDialogueShow:n.onDialogueShow||(e=>{Ma("PxcPlayer","Dialogue:",e.actor,e.text)}),onBackdropChange:n.onBackdropChange||((e,t)=>{Ma("PxcPlayer","Backdrop:",e)}),onEnd:()=>{Ma("PxcPlayer","Cutscene ended"),n.onEnd&&n.onEnd(),i()}},s=new Ga(e,r);await s.playCutscene(t)}catch(Yc){console.error("[PixoScript] Error playing inline .pxc script:",Yc),i()}}),set_camera:()=>{e.renderManager.camera.setCamera()},get_camera_vector:()=>e.renderManager.camera.cameraTarget,look_at:(t,n,i)=>{let r=this.pixoscript.utils.ensureArray(t.toObject()),s=this.pixoscript.utils.ensureArray(n.toObject()),a=this.pixoscript.utils.ensureArray(i.toObject());e.renderManager.camera.lookAt(r,s,a)},pan_camera:(t,n,i)=>(Ma("PixoScript","panning camera via lua",{from:t,to:n,duration:i}),()=>new Promise(r=>{e.spritz.world.addEvent(new Ec(e,"camera",["pan",{from:t,to:n,duration:i}],e.spritz.world,async()=>{r()}))})),_pan:(t,n=Math.PI/4)=>{"CCW"===t?e.renderManager.camera.panCCW(this.pixoscript.utils.coerceToNumber(n)):e.renderManager.camera.panCW(this.pixoscript.utils.coerceToNumber(n))},pitch:(t,n=Math.PI/4)=>{"CCW"===t?e.renderManager.camera.pitchCCW(this.pixoscript.utils.coerceToNumber(n)):e.renderManager.camera.pitchCW(this.pixoscript.utils.coerceToNumber(n))},tilt:(t,n=Math.PI/4)=>{"CCW"===t?e.renderManager.camera.tiltCCW(this.pixoscript.utils.coerceToNumber(n)):e.renderManager.camera.tiltCW(this.pixoscript.utils.coerceToNumber(n))},bind_action:(t,n,i)=>{try{e.inputManager&&e.inputManager.bindAction(t,n,i)}catch(Yc){console.warn("bind_action failed",Yc)}},unbind_action:(t,n)=>{try{e.inputManager&&e.inputManager.unbindAction(t,n)}catch(Yc){console.warn("unbind_action failed",Yc)}},register_action_hook:(t,n)=>{try{e.inputManager&&e.inputManager.registerActionHook(t,n)}catch(Yc){console.warn("register_action_hook failed",Yc)}},is_action_active:t=>{try{return!!e.inputManager&&e.inputManager.isActionActive(t)}catch(Yc){return console.warn("is_action_active failed",Yc),!1}},get_action_input:t=>{try{return e.inputManager?e.inputManager.getActionInput(t):null}catch(Yc){return console.warn("get_action_input failed",Yc),null}},vector:t=>{let[n,i,r]=this.pixoscript.utils.ensureArray(t.toObject());return new e.utils.Vector(n,i,r)},vec_sub:(e,t)=>e.sub(t),sync:async e=>{for(const t of e.toObject())await t()},as_obj:e=>e.toObject(),as_array:e=>this.pixoscript.utils.ensureArray(e.toObject()),as_table:e=>{const t=new this.pixoscript.Table;for(const[n,i]of Object.entries(e))t.set(n,i);return t},log:e=>{Ma("PixoScript",e)},to:(e,t)=>{for(const[n,i]of Object.entries(t.toObject()))e[n]=i},set_mode:(t,n)=>{try{Ma("PixoScript","pixos.set_mode called ->",t,n);const i=e.spritz.world;if(i&&i.modeManager){const e=n&&"function"==typeof n.toObject?n.toObject():n;i.modeManager.set(t,e)}}catch(Yc){console.warn("set_mode failed",Yc)}},get_mode:()=>{try{return e.spritz.world.modeManager.getMode()}catch(Yc){return null}},set_mode_mappings:(t,n)=>{try{if(Ma("PixoScript","pixos.set_mode_mappings called ->",t,n),e&&e.inputManager){const i=n&&"function"==typeof n.toObject?n.toObject():n;e.inputManager.setModeMappings(t,i)}}catch(Yc){console.warn("set_mode_mappings failed",Yc)}},register_mode:(t,n)=>{try{if(!t)return void console.warn("pixos.register_mode called with undefined name");Ma("PixoScript","pixos.register_mode called ->",t);const i=e.spritz.world;if(!i||!i.modeManager)return;const r={},s=n&&"function"==typeof n.toObject?n.toObject():n||{};s.setup&&(r.setup=s.setup),s.update&&(r.update=s.update),s.teardown&&(r.teardown=s.teardown),s.check_input&&(r.check_input=s.check_input),s.on_select&&(r.on_select=s.on_select),void 0!==s.picker&&(r.picker=s.picker),i.modeManager.register(t,r)}catch(Yc){console.warn("register_mode failed",Yc)}},from:(e,t)=>e[t],length:e=>e.length||0,callback_finish:e=>{Ma("PixoScript","callback finish",{success:e}),t.finish&&t.finish(e>0)},set_skybox_shader:async t=>{var n,i;(null==(i=null==(n=e.renderManager)?void 0:n.skyboxManager)?void 0:i.setSkyboxShader)&&await e.renderManager.skyboxManager.setSkyboxShader(t)},emit_particles:(t,n)=>{try{const i=t&&"function"==typeof t.toObject?t.toObject():t||[0,0,0],r=n&&"function"==typeof n.toObject?n.toObject():n||{};if(e.renderManager&&e.renderManager.particleManager){if(r.preset){const t=e.renderManager.particleManager.preset(r.preset);t&&Object.assign(r,t)}e.renderManager.particleManager.emit(i,r)}}catch(Yc){console.warn("emit_particles failed",Yc)}},create_particles:(t,n)=>{try{const i=t&&"function"==typeof t.toObject?t.toObject():t||[0,0,0],r=n||null;if(e.renderManager&&e.renderManager.particleManager){const t=r?e.renderManager.particleManager.preset(r):{};e.renderManager.particleManager.emit(i,t||{})}}catch(Yc){console.warn("create_particles failed",Yc)}},clear_particles:()=>{try{e.renderManager&&e.renderManager.particleManager&&(e.renderManager.particleManager.particles=[])}catch(Yc){console.warn("clear_particles failed",Yc)}},get_particle_count:()=>{try{return e.renderManager&&e.renderManager.particleManager?e.renderManager.particleManager.particles.length:0}catch(Yc){return console.warn("get_particle_count failed",Yc),0}}}))),this.pixoscript=e}}class Ya extends Error{constructor(e){super(),this.message=e}toString(){return`LuaError: ${this.message}`}}class qa{constructor(e){if(this.numValues=[void 0],this.strValues={},this.keys=[],this.values=[],this.metatable=null,void 0!==e)if("function"!=typeof e){if(Array.isArray(e))this.insert(...e);else for(const t in e)if(po(e,t)){let n=e[t];null===n&&(n=void 0),this.set(t,n)}}else e(this)}get(e){const t=this.rawget(e);if(void 0===t&&this.metatable){const t=this.metatable.get("__index");if(t instanceof qa)return t.get(e);if("function"==typeof t){const n=t.call(void 0,this,e);return n instanceof Array?n[0]:n}}return t}rawget(e){switch(typeof e){case"string":if(po(this.strValues,e))return this.strValues[e];break;case"number":if(e>0&&e%1==0)return this.numValues[e]}const t=this.keys.indexOf(to(e));return-1===t?void 0:this.values[t]}getMetaMethod(e){return this.metatable&&this.metatable.rawget(e)}set(e,t){const n=this.metatable&&this.metatable.get("__newindex");if(n){if(void 0===this.rawget(e)){if(n instanceof qa)return n.set(e,t);if("function"==typeof n)return n(this,e,t)}}this.rawset(e,t)}setFn(e){return t=>this.set(e,t)}rawset(e,t){switch(typeof e){case"string":return void(this.strValues[e]=t);case"number":if(e>0&&e%1==0)return void(this.numValues[e]=t)}const n=to(e),i=this.keys.indexOf(n);i>-1?this.values[i]=t:(this.values[this.keys.length]=t,this.keys.push(n))}insert(...e){this.numValues.push(...e)}toObject(){const e=0===Object.keys(this.strValues).length&&this.getn()>0,t=e?[]:{};for(let n=1;n<this.numValues.length;n++){const i=this.numValues[n],r=i instanceof qa?i.toObject():i;if(e){t[n-1]=r}else{t[String(n-1)]=r}}for(const n in this.strValues)if(po(this.strValues,n)){const e=this.strValues[n],i=e instanceof qa?e.toObject():e;t[n]=i}return t}getn(){const e=this.numValues,t=[];for(const i in e)po(e,i)&&(t[i]=!0);let n=0;for(;t[n+1];)n+=1;if(n>0&&void 0===e[n]){let t=0;for(;n-t>1;){const i=Math.floor((t+n)/2);void 0===e[i]?n=i:t=i}return t}return n}}const Ja=/^[-+]?[0-9]*\.?([0-9]+([eE][-+]?[0-9]+)?)?$/,Qa=/^(-)?0x([0-9a-fA-F]*)\.?([0-9a-fA-F]*)$/;function eo(e){const t=typeof e;switch(t){case"undefined":return"nil";case"number":case"string":case"boolean":case"function":return t;case"object":if(e instanceof qa)return"table";if(e instanceof Function)return"function"}}function to(e){if(e instanceof qa){const n=e.getMetaMethod("__tostring");return n?n(e)[0]:t(e,"table: 0x")}return e instanceof Function?t(e,"function: 0x"):ao(e);function t(e,t){const n=e.toString();if(n.indexOf(t)>-1)return n;const i=t+Math.floor(4294967295*Math.random()).toString(16);return e.toString=()=>i,i}}function no(e,t){return e>=0?e:-e>t?0:t+e+1}function io(e,t){if(t)throw new Ya(`${t}`.replace(/%type/gi,eo(e)))}function ro(e){return!(!1===e||void 0===e)}function so(e,t){if("number"==typeof e)return e;switch(e){case void 0:return;case"inf":return 1/0;case"-inf":return-1/0;case"nan":return NaN}const n=`${e}`;if(n.match(Ja))return parseFloat(n);const i=n.match(Qa);if(i){const[,e,t,n]=i;let r=parseInt(t,16)||0;return n&&(r+=parseInt(n,16)/Math.pow(16,n.length)),e&&(r*=-1),r}void 0!==t&&io(e,t)}function ao(e,t){if("string"==typeof e)return e;switch(e){case void 0:case null:return"nil";case 1/0:return"inf";case-1/0:return"-inf"}return"number"==typeof e?Number.isNaN(e)?"nan":`${e}`:"boolean"==typeof e?`${e}`:void 0===t?"nil":void io(e,t)}function oo(e,t,n,i,r){return t(e,`bad argument #${r} to '${i}' (${n} expected, got %type)`)}function lo(e,t,n){return oo(e,so,"number",t,n)}function co(e,t,n){return oo(e,ao,"string",t,n)}function ho(e,t,n){if(e instanceof qa)return e;{const i=eo(e);throw new Ya(`bad argument #${n} to '${t}' (table expected, got ${i})`)}}function uo(e,t,n){if(e instanceof Function)return e;{const i=eo(e);throw new Ya(`bad argument #${n} to '${t}' (function expected, got ${i})`)}}const fo=e=>e instanceof Array?e:[e],po=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),go=Object.freeze(Object.defineProperty({__proto__:null,coerceArgToFunction:uo,coerceArgToNumber:lo,coerceArgToString:co,coerceArgToTable:ho,coerceToBoolean:ro,coerceToNumber:so,coerceToString:ao,ensureArray:fo,hasOwnProperty:po,posrelat:no,tostring:to,type:eo},Symbol.toStringTag,{value:"Module"}));class mo{constructor(e={}){this._variables=e}get(e){return this._variables[e]}set(e,t){po(this._variables,e)||!this.parent?this.setLocal(e,t):this.parent.set(e,t)}setLocal(e,t){this._variables[e]=t}setVarargs(e){this._varargs=e}getVarargs(){return this._varargs||this.parent&&this.parent.getVarargs()||[]}extend(){const e=Object.create(this._variables),t=new mo(e);return t.parent=this,t}}var yo,bo,vo,wo,xo,_o,ko,So,Mo={exports:{}};yo=Mo,vo=s,wo=function(e){var t,n,i,r,s;e.version="0.3.1";var a=e.defaultOptions={wait:!1,comments:!0,scope:!1,locations:!1,ranges:!1,onCreateNode:null,onCreateScope:null,onDestroyScope:null,onLocalDeclaration:null,luaVersion:"5.1",encodingMode:"none"};function o(e,t){return t=t||0,e<128?String.fromCharCode(e):e<2048?String.fromCharCode(192|t|e>>6,128|t|63&e):e<65536?String.fromCharCode(224|t|e>>12,128|t|e>>6&63,128|t|63&e):e<1114112?String.fromCharCode(240|t|e>>18,128|t|e>>12&63,128|t|e>>6&63,128|t|63&e):null}function l(e){return function(t){var n=e.exec(t);if(!n)return t;I(null,p.invalidCodeUnit,function(e,t){for(var n=e.toString(16);n.length<t;)n="0"+n;return n}(n[0].charCodeAt(0),4).toUpperCase())}}var c={"pseudo-latin1":{fixup:l(/[^\x00-\xff]/),encodeByte:function(e){return null===e?"":String.fromCharCode(e)},encodeUTF8:function(e){return o(e)}},"x-user-defined":{fixup:l(/[^\x00-\x7f\uf780-\uf7ff]/),encodeByte:function(e){return null===e?"":e>=128?String.fromCharCode(63232|e):String.fromCharCode(e)},encodeUTF8:function(e){return o(e,63232)}},none:{discardStrings:!0,fixup:function(e){return e},encodeByte:function(e){return""},encodeUTF8:function(e){return""}}},h=32,u=64,d=128,f=256;e.tokenTypes={EOF:1,StringLiteral:2,Keyword:4,Identifier:8,NumericLiteral:16,Punctuator:h,BooleanLiteral:64,NilLiteral:d,VarargLiteral:f};var p=e.errors={unexpected:"unexpected %1 '%2' near '%3'",unexpectedEOF:"unexpected symbol near '<eof>'",expected:"'%1' expected near '%2'",expectedToken:"%1 expected near '%2'",unfinishedString:"unfinished string near '%1'",malformedNumber:"malformed number near '%1'",decimalEscapeTooLarge:"decimal escape too large near '%1'",invalidEscape:"invalid escape sequence near '%1'",hexadecimalDigitExpected:"hexadecimal digit expected near '%1'",braceExpected:"missing '%1' near '%2'",tooLargeCodepoint:"UTF-8 value too large near '%1'",unfinishedLongString:"unfinished long string (starting at line %1) near '%2'",unfinishedLongComment:"unfinished long comment (starting at line %1) near '%2'",ambiguousSyntax:"ambiguous syntax (function call x new statement) near '%1'",noLoopToBreak:"no loop to break near '%1'",labelAlreadyDefined:"label '%1' already defined on line %2",labelNotVisible:"no visible label '%1' for <goto>",gotoJumpInLocalScope:"<goto %1> jumps into the scope of local '%2'",cannotUseVararg:"cannot use '...' outside a vararg function near '%1'",invalidCodeUnit:"code unit U+%1 is not allowed in the current encoding mode"},g=e.ast={labelStatement:function(e){return{type:"LabelStatement",label:e}},breakStatement:function(){return{type:"BreakStatement"}},gotoStatement:function(e){return{type:"GotoStatement",label:e}},returnStatement:function(e){return{type:"ReturnStatement",arguments:e}},ifStatement:function(e){return{type:"IfStatement",clauses:e}},ifClause:function(e,t){return{type:"IfClause",condition:e,body:t}},elseifClause:function(e,t){return{type:"ElseifClause",condition:e,body:t}},elseClause:function(e){return{type:"ElseClause",body:e}},whileStatement:function(e,t){return{type:"WhileStatement",condition:e,body:t}},doStatement:function(e){return{type:"DoStatement",body:e}},repeatStatement:function(e,t){return{type:"RepeatStatement",condition:e,body:t}},localStatement:function(e,t){return{type:"LocalStatement",variables:e,init:t}},assignmentStatement:function(e,t){return{type:"AssignmentStatement",variables:e,init:t}},callStatement:function(e){return{type:"CallStatement",expression:e}},functionStatement:function(e,t,n,i){return{type:"FunctionDeclaration",identifier:e,isLocal:n,parameters:t,body:i}},forNumericStatement:function(e,t,n,i,r){return{type:"ForNumericStatement",variable:e,start:t,end:n,step:i,body:r}},forGenericStatement:function(e,t,n){return{type:"ForGenericStatement",variables:e,iterators:t,body:n}},chunk:function(e){return{type:"Chunk",body:e}},identifier:function(e){return{type:"Identifier",name:e}},literal:function(e,t,n){return{type:e=2===e?"StringLiteral":16===e?"NumericLiteral":64===e?"BooleanLiteral":e===d?"NilLiteral":"VarargLiteral",value:t,raw:n}},tableKey:function(e,t){return{type:"TableKey",key:e,value:t}},tableKeyString:function(e,t){return{type:"TableKeyString",key:e,value:t}},tableValue:function(e){return{type:"TableValue",value:e}},tableConstructorExpression:function(e){return{type:"TableConstructorExpression",fields:e}},binaryExpression:function(e,t,n){return{type:"and"===e||"or"===e?"LogicalExpression":"BinaryExpression",operator:e,left:t,right:n}},unaryExpression:function(e,t){return{type:"UnaryExpression",operator:e,argument:t}},memberExpression:function(e,t,n){return{type:"MemberExpression",indexer:t,identifier:n,base:e}},indexExpression:function(e,t){return{type:"IndexExpression",base:e,index:t}},callExpression:function(e,t){return{type:"CallExpression",base:e,arguments:t}},tableCallExpression:function(e,t){return{type:"TableCallExpression",base:e,arguments:t}},stringCallExpression:function(e,t){return{type:"StringCallExpression",base:e,argument:t}},comment:function(e,t){return{type:"Comment",value:e,raw:t}}};function m(e){if(ae){var t=oe.pop();t.complete(),t.bless(e)}return n.onCreateNode&&n.onCreateNode(e),e}var y=Array.prototype.slice,b=function(e,t){for(var n=0,i=e.length;n<i;++n)if(e[n]===t)return n;return-1};function v(e){var t=y.call(arguments,1);return e=e.replace(/%(\d)/g,function(e,n){return""+t[n-1]||""})}Array.prototype.indexOf&&(b=function(e,t){return e.indexOf(t)});var w,x,_,k,S,M,A,T,E,P,C,z=function(e){for(var t,n,i=y.call(arguments,1),r=0,s=i.length;r<s;++r)for(n in t=i[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};function L(e){return Object.create?Object.create(e,{line:{writable:!0,value:e.line},index:{writable:!0,value:e.index},column:{writable:!0,value:e.column}}):e}function I(e){var t,n,i=v.apply(null,y.call(arguments,1));throw null===e||void 0===e.line?(n=w-T+1,(t=L(new SyntaxError(v("[%1:%2] %3",A,n,i)))).index=w,t.line=A,t.column=n):(n=e.range[0]-e.lineStart,(t=L(new SyntaxError(v("[%1:%2] %3",e.line,n,i)))).line=e.line,t.index=e.range[0],t.column=n),t}function D(e){var n=t.slice(e.range[0],e.range[1]);return n||e.value}function R(e,t){I(t,p.expectedToken,e,D(t))}function O(e){var t=D(k);if(void 0!==e.type){var n;switch(e.type){case 2:n="string";break;case 4:n="keyword";break;case 8:n="identifier";break;case 16:n="number";break;case h:n="symbol";break;case 64:n="boolean";break;case d:return I(e,p.unexpected,"symbol","nil",t);case 1:return I(e,p.unexpectedEOF)}return I(e,p.unexpected,n,D(e),t)}return I(e,p.unexpected,"symbol",e,t)}function B(){for(j();45===t.charCodeAt(w)&&45===t.charCodeAt(w+1);)V(),j();if(w>=i)return{type:1,value:"<eof>",line:A,lineStart:T,range:[w,w]};var e,n,a,o=t.charCodeAt(w),l=t.charCodeAt(w+1);if(M=w,function(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||!!(r.extendedIdentifiers&&e>=128)}(o))return function(){for(var e,n;J(t.charCodeAt(++w)););return function(e){switch(e.length){case 2:return"do"===e||"if"===e||"in"===e||"or"===e;case 3:return"and"===e||"end"===e||"for"===e||"not"===e;case 4:return"else"===e||"then"===e||!(!r.labels||r.contextualGoto)&&"goto"===e;case 5:return"break"===e||"local"===e||"until"===e||"while"===e;case 6:return"elseif"===e||"repeat"===e||"return"===e;case 8:return"function"===e}return!1}(e=s.fixup(t.slice(M,w)))?n=4:"true"===e||"false"===e?(n=u,e="true"===e):"nil"===e?(n=d,e=null):n=8,{type:n,value:e,line:A,lineStart:T,range:[M,w]}}();switch(o){case 39:case 34:return function(){for(var e,n=t.charCodeAt(w++),r=A,a=T,o=w,l=s.discardStrings?null:"";n!==(e=t.charCodeAt(w++));)if((w>i||X(e))&&(l+=t.slice(o,w-1),I(null,p.unfinishedString,t.slice(M,w-1))),92===e){if(!s.discardStrings){var c=t.slice(o,w-1);l+=s.fixup(c)}var h=$();s.discardStrings||(l+=h),o=w}return s.discardStrings||(l+=s.encodeByte(null),l+=s.fixup(t.slice(o,w-1))),{type:2,value:l,line:r,lineStart:a,lastLine:A,lastLineStart:T,range:[M,w]}}();case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return U();case 46:return Y(l)?U():46===l?46===t.charCodeAt(w+2)?{type:f,value:"...",line:A,lineStart:T,range:[M,w+=3]}:N(".."):N(".");case 61:return N(61===l?"==":"=");case 62:return r.bitwiseOperators&&62===l?N(">>"):N(61===l?">=":">");case 60:return r.bitwiseOperators&&60===l?N("<<"):N(61===l?"<=":"<");case 126:if(61===l)return N("~=");if(!r.bitwiseOperators)break;return N("~");case 58:return r.labels&&58===l?N("::"):N(":");case 91:return 91===l||61===l?(e=A,n=T,!1===(a=W(!1))&&I(x,p.expected,"[",D(x)),{type:2,value:s.discardStrings?null:s.fixup(a),line:e,lineStart:n,lastLine:A,lastLineStart:T,range:[M,w]}):N("[");case 47:return r.integerDivision&&47===l?N("//"):N("/");case 38:case 124:if(!r.bitwiseOperators)break;case 42:case 94:case 37:case 44:case 123:case 125:case 93:case 40:case 41:case 59:case 35:case 45:case 43:return N(t.charAt(w))}return O(t.charAt(w))}function F(){var e=t.charCodeAt(w),n=t.charCodeAt(w+1);return!!X(e)&&(10===e&&13===n&&++w,13===e&&10===n&&++w,++A,T=++w,!0)}function j(){for(;w<i;)if(G(t.charCodeAt(w)))++w;else if(!F())break}function N(e){return w+=e.length,{type:h,value:e,line:A,lineStart:T,range:[M,w]}}function U(){var e=t.charAt(w),n=t.charAt(w+1),i="0"===e&&"xX".indexOf(n||null)>=0?function(){var e,n,i,r,s=0,a=1,o=1;for(r=w+=2,q(t.charCodeAt(w))||I(null,p.malformedNumber,t.slice(M,w));q(t.charCodeAt(w));)++w;e=parseInt(t.slice(r,w),16);var l=!1;if("."===t.charAt(w)){for(l=!0,n=++w;q(t.charCodeAt(w));)++w;s=t.slice(n,w),s=n===w?0:parseInt(s,16)/Math.pow(16,w-n)}var c=!1;if("pP".indexOf(t.charAt(w)||null)>=0){for(c=!0,++w,"+-".indexOf(t.charAt(w)||null)>=0&&(o="+"===t.charAt(w++)?1:-1),i=w,Y(t.charCodeAt(w))||I(null,p.malformedNumber,t.slice(M,w));Y(t.charCodeAt(w));)++w;a=t.slice(i,w),a=Math.pow(2,a*o)}return{value:(e+s)*a,hasFractionPart:l||c}}():function(){for(;Y(t.charCodeAt(w));)++w;var e=!1;if("."===t.charAt(w))for(e=!0,++w;Y(t.charCodeAt(w));)++w;var n=!1;if("eE".indexOf(t.charAt(w)||null)>=0)for(n=!0,++w,"+-".indexOf(t.charAt(w)||null)>=0&&++w,Y(t.charCodeAt(w))||I(null,p.malformedNumber,t.slice(M,w));Y(t.charCodeAt(w));)++w;return{value:parseFloat(t.slice(M,w)),hasFractionPart:e||n}}(),s=function(){if(r.imaginaryNumbers)return"iI".indexOf(t.charAt(w)||null)>=0&&(++w,!0)}();return function(){if(r.integerSuffixes)if("uU".indexOf(t.charAt(w)||null)>=0)if(++w,"lL".indexOf(t.charAt(w)||null)>=0){if(++w,"lL".indexOf(t.charAt(w)||null)>=0)return++w,"ULL";I(null,p.malformedNumber,t.slice(M,w))}else I(null,p.malformedNumber,t.slice(M,w));else if("lL".indexOf(t.charAt(w)||null)>=0){if(++w,"lL".indexOf(t.charAt(w)||null)>=0)return++w,"LL";I(null,p.malformedNumber,t.slice(M,w))}}()&&(s||i.hasFractionPart)&&I(null,p.malformedNumber,t.slice(M,w)),{type:16,value:i.value,line:A,lineStart:T,range:[M,w]}}function $(){var e=w;switch(t.charAt(w)){case"a":return++w,"";case"n":return++w,"\n";case"r":return++w,"\r";case"t":return++w,"\t";case"v":return++w,"\v";case"b":return++w,"\b";case"f":return++w,"\f";case"\r":case"\n":return F(),"\n";case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;Y(t.charCodeAt(w))&&w-e<3;)++w;var n=t.slice(e,w),i=parseInt(n,10);return i>255&&I(null,p.decimalEscapeTooLarge,"\\"+i),s.encodeByte(i,"\\"+n);case"z":if(r.skipWhitespaceEscape)return++w,j(),"";break;case"x":if(r.hexEscapes){if(q(t.charCodeAt(w+1))&&q(t.charCodeAt(w+2)))return w+=3,s.encodeByte(parseInt(t.slice(e+1,w),16),"\\"+t.slice(e,w));I(null,p.hexadecimalDigitExpected,"\\"+t.slice(e,w+2))}break;case"u":if(r.unicodeEscapes)return function(){var e=w++;for("{"!==t.charAt(w++)&&I(null,p.braceExpected,"{","\\"+t.slice(e,w)),q(t.charCodeAt(w))||I(null,p.hexadecimalDigitExpected,"\\"+t.slice(e,w));48===t.charCodeAt(w);)++w;for(var n=w;q(t.charCodeAt(w));)++w-n>6&&I(null,p.tooLargeCodepoint,"\\"+t.slice(e,w));var i=t.charAt(w++);"}"!==i&&('"'===i||"'"===i?I(null,p.braceExpected,"}","\\"+t.slice(e,w--)):I(null,p.hexadecimalDigitExpected,"\\"+t.slice(e,w)));var r=parseInt(t.slice(n,w-1)||"0",16),a="\\"+t.slice(e,w);return r>1114111&&I(null,p.tooLargeCodepoint,a),s.encodeUTF8(r,a)}();break;case"\\":case'"':case"'":return t.charAt(w++)}return r.strictEscapes&&I(null,p.invalidEscape,"\\"+t.slice(e,w+1)),t.charAt(w++)}function V(){M=w,w+=2;var e=t.charAt(w),r="",s=!1,a=w,o=T,l=A;if("["===e&&(!1===(r=W(!0))?r=e:s=!0),!s){for(;w<i&&!X(t.charCodeAt(w));)++w;n.comments&&(r=t.slice(a,w))}if(n.comments){var c=g.comment(r,t.slice(M,w));n.locations&&(c.loc={start:{line:l,column:M-o},end:{line:A,column:w-T}}),n.ranges&&(c.range=[M,w]),n.onCreateNode&&n.onCreateNode(c),S.push(c)}}function W(e){var n,r=0,s="",a=!1,o=A;for(++w;"="===t.charAt(w+r);)++r;if("["!==t.charAt(w+r))return!1;for(w+=r+1,X(t.charCodeAt(w))&&F(),n=w;w<i;){for(;X(t.charCodeAt(w));)F();if("]"===t.charAt(w++)){a=!0;for(var l=0;l<r;++l)"="!==t.charAt(w+l)&&(a=!1);"]"!==t.charAt(w+r)&&(a=!1)}if(a)return s+=t.slice(n,w-1),w+=r+1,s}I(null,e?p.unfinishedLongComment:p.unfinishedLongString,o,"<eof>")}function H(){_=x,x=k,k=B()}function K(e){return e===x.value&&(H(),!0)}function Z(e){e===x.value?H():I(x,p.expected,e,D(x))}function G(e){return 9===e||32===e||11===e||12===e}function X(e){return 10===e||13===e}function Y(e){return e>=48&&e<=57}function q(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function J(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||e>=48&&e<=57||!!(r.extendedIdentifiers&&e>=128)}function Q(e){if(1===e.type)return!0;if(4!==e.type)return!1;switch(e.value){case"else":case"elseif":case"end":case"until":return!0;default:return!1}}function ee(){var e=E[P++].slice();E.push(e),n.onCreateScope&&n.onCreateScope()}function te(){E.pop(),--P,n.onDestroyScope&&n.onDestroyScope()}function ne(e){n.onLocalDeclaration&&n.onLocalDeclaration(e),-1===b(E[P],e)&&E[P].push(e)}function ie(e){ne(e.name),re(e,!0)}function re(e,t){t||-1!==function(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i][t]===n)return i;return-1}(C,"name",e.name)||C.push(e),e.isLocal=t}function se(e){return-1!==b(E[P],e)}Object.assign&&(z=Object.assign),e.SyntaxError=SyntaxError,e.lex=B;var ae,oe=[];function le(){return new ce(x)}function ce(e){n.locations&&(this.loc={start:{line:e.line,column:e.range[0]-e.lineStart},end:{line:0,column:0}}),n.ranges&&(this.range=[e.range[0],0])}function he(){ae&&oe.push(le())}function ue(e){ae&&oe.push(e)}function de(){this.scopes=[],this.pendingGotos=[]}function fe(){this.level=0,this.loopLevels=[]}function pe(){return r.labels?new de:new fe}function ge(e){for(var t,n=[];!Q(x);){if("return"===x.value||!r.relaxedBreak&&"break"===x.value){n.push(me(e));break}t=me(e),K(";"),t&&n.push(t)}return n}function me(e){if(he(),h===x.type&&K("::"))return function(e){var t=x,i=be();return n.scope&&(ne("::"+t.value+"::"),re(i,!0)),Z("::"),e.addLabel(t.value,t),m(g.labelStatement(i))}(e);if(!r.emptyStatement||!K(";")){if(e.raiseDeferredErrors(),4===x.type)switch(x.value){case"local":return H(),function(e){var t,i=_;if(8===x.type){var r=[],s=[];do{t=be(),r.push(t),e.addLocal(t.name,i)}while(K(","));if(K("="))do{var a=_e(e);s.push(a)}while(K(","));if(n.scope)for(var o=0,l=r.length;o<l;++o)ie(r[o]);return m(g.localStatement(r,s))}if(K("function"))return t=be(),e.addLocal(t.name,i),n.scope&&(ie(t),ee()),ve(t,!0);R("<name>",x)}(e);case"if":return H(),function(e){var t,i,r,s=[];for(ae&&(r=oe[oe.length-1],oe.push(r)),t=_e(e),Z("then"),n.scope&&ee(),e.pushScope(),i=ge(e),e.popScope(),n.scope&&te(),s.push(m(g.ifClause(t,i))),ae&&(r=le());K("elseif");)ue(r),t=_e(e),Z("then"),n.scope&&ee(),e.pushScope(),i=ge(e),e.popScope(),n.scope&&te(),s.push(m(g.elseifClause(t,i))),ae&&(r=le());return K("else")&&(ae&&(r=new ce(_),oe.push(r)),n.scope&&ee(),e.pushScope(),i=ge(e),e.popScope(),n.scope&&te(),s.push(m(g.elseClause(i)))),Z("end"),m(g.ifStatement(s))}(e);case"return":return H(),function(e){var t=[];if("end"!==x.value){var n=xe(e);for(null!=n&&t.push(n);K(",");)n=_e(e),t.push(n);K(";")}return m(g.returnStatement(t))}(e);case"function":return H(),ve(function(){var e,t,i;for(ae&&(i=le()),e=be(),n.scope&&(re(e,se(e.name)),ee());K(".");)ue(i),t=be(),e=m(g.memberExpression(e,".",t));return K(":")&&(ue(i),t=be(),e=m(g.memberExpression(e,":",t)),n.scope&&ne("self")),e}());case"while":return H(),function(e){var t=_e(e);Z("do"),n.scope&&ee(),e.pushScope(!0);var i=ge(e);return e.popScope(),n.scope&&te(),Z("end"),m(g.whileStatement(t,i))}(e);case"for":return H(),function(e){var t,i=be();if(n.scope&&(ee(),ie(i)),K("=")){var r=_e(e);Z(",");var s=_e(e),a=K(",")?_e(e):null;return Z("do"),e.pushScope(!0),t=ge(e),e.popScope(),Z("end"),n.scope&&te(),m(g.forNumericStatement(i,r,s,a,t))}for(var o=[i];K(",");)i=be(),n.scope&&ie(i),o.push(i);Z("in");var l=[];do{var c=_e(e);l.push(c)}while(K(","));return Z("do"),e.pushScope(!0),t=ge(e),e.popScope(),Z("end"),n.scope&&te(),m(g.forGenericStatement(o,l,t))}(e);case"repeat":return H(),function(e){n.scope&&ee(),e.pushScope(!0);var t=ge(e);Z("until"),e.raiseDeferredErrors();var i=_e(e);return e.popScope(),n.scope&&te(),m(g.repeatStatement(i,t))}(e);case"break":return H(),e.isInLoop()||I(x,p.noLoopToBreak,x.value),m(g.breakStatement());case"do":return H(),function(e){n.scope&&ee(),e.pushScope();var t=ge(e);return e.popScope(),n.scope&&te(),Z("end"),m(g.doStatement(t))}(e);case"goto":return H(),ye(e)}return r.contextualGoto&&8===x.type&&"goto"===x.value&&8===k.type&&"goto"!==k.value?(H(),ye(e)):(ae&&oe.pop(),function(e){var t,i,r,s,a,o=[];for(ae&&(i=le());;){if(ae&&(t=le()),8===x.type)a=x.value,s=be(),n.scope&&re(s,se(a)),r=!0;else{if("("!==x.value)return O(x);H(),s=_e(e),Z(")"),r=!1}e:for(;;){switch(2===x.type?'"':x.value){case".":case"[":r=!0;break;case":":case"(":case"{":case'"':r=null;break;default:break e}s=Me(s,t,e)}if(o.push(s),","!==x.value)break;if(!r)return O(x);H()}if(1===o.length&&null===r)return ue(t),m(g.callStatement(o[0]));if(!r)return O(x);Z("=");var l=[];do{l.push(_e(e))}while(K(","));return ue(i),m(g.assignmentStatement(o,l))}(e))}ae&&oe.pop()}function ye(e){var t=x.value,n=_,i=be();return e.addGoto(t,n),m(g.gotoStatement(i))}function be(){he();var e=x.value;return 8!==x.type&&R("<name>",x),H(),m(g.identifier(e))}function ve(e,t){var i=pe();i.pushScope();var r=[];if(Z("("),!K(")"))for(;;){if(8===x.type){var s=be();if(n.scope&&ie(s),r.push(s),K(","))continue}else f===x.type?(i.allowVararg=!0,r.push(Te(i))):R("<name> or '...'",x);Z(")");break}var a=ge(i);return i.popScope(),Z("end"),n.scope&&te(),t=t||!1,m(g.functionStatement(e,r,t,a))}function we(e){for(var t,n,i=[];;){if(he(),h===x.type&&K("["))t=_e(e),Z("]"),Z("="),n=_e(e),i.push(m(g.tableKey(t,n)));else if(8===x.type)"="===k.value?(t=be(),H(),n=_e(e),i.push(m(g.tableKeyString(t,n)))):(n=_e(e),i.push(m(g.tableValue(n))));else{if(null==(n=xe(e))){oe.pop();break}i.push(m(g.tableValue(n)))}if(!(",;".indexOf(x.value)>=0))break;H()}return Z("}"),m(g.tableConstructorExpression(i))}function xe(e){return Se(0,e)}function _e(e){var t=xe(e);if(null!=t)return t;R("<expression>",x)}function ke(e){var t=e.charCodeAt(0),n=e.length;if(1===n)switch(t){case 94:return 12;case 42:case 47:case 37:return 10;case 43:case 45:return 9;case 38:return 6;case 126:return 5;case 124:return 4;case 60:case 62:return 3}else if(2===n)switch(t){case 47:return 10;case 46:return 8;case 60:case 62:return"<<"===e||">>"===e?7:3;case 61:case 126:return 3;case 111:return 1}else if(97===t&&"and"===e)return 2;return 0}function Se(e,t){var i,r,s,a,o=x.value;if(ae&&(r=le()),h===(s=x).type?"#-~".indexOf(s.value)>=0:4===s.type&&"not"===s.value){he(),H();var l=Se(10,t);null==l&&R("<expression>",x),i=m(g.unaryExpression(o,l))}if(null==i&&null==(i=Te(t))&&(i=function(e){var t,i,r;if(ae&&(r=le()),8===x.type)i=x.value,t=be(),n.scope&&re(t,se(i));else{if(!K("("))return null;t=_e(e),Z(")")}for(;;){var s=Me(t,r,e);if(null===s)break;t=s}return t}(t)),null==i)return null;for(;o=x.value,!(0===(a=h===x.type||4===x.type?ke(o):0)||a<=e);){"^"!==o&&".."!==o||--a,H();var c=Se(a,t);null==c&&R("<expression>",x),ae&&oe.push(r),i=m(g.binaryExpression(o,i,c))}return i}function Me(e,t,n){var i,r;if(h===x.type)switch(x.value){case"[":return ue(t),H(),i=_e(n),Z("]"),m(g.indexExpression(e,i));case".":return ue(t),H(),r=be(),m(g.memberExpression(e,".",r));case":":return ue(t),H(),r=be(),e=m(g.memberExpression(e,":",r)),ue(t),Ae(e,n);case"(":case"{":return ue(t),Ae(e,n)}else if(2===x.type)return ue(t),Ae(e,n);return null}function Ae(e,t){if(h===x.type)switch(x.value){case"(":r.emptyStatement||x.line!==_.line&&I(null,p.ambiguousSyntax,x.value),H();var n=[],i=xe(t);for(null!=i&&n.push(i);K(",");)i=_e(t),n.push(i);return Z(")"),m(g.callExpression(e,n));case"{":he(),H();var s=we(t);return m(g.tableCallExpression(e,s))}else if(2===x.type)return m(g.stringCallExpression(e,Te(t)));R("function arguments",x)}function Te(e){var i,r=x.value,s=x.type;if(ae&&(i=le()),s!==f||e.allowVararg||I(x,p.cannotUseVararg,x.value),466&s){ue(i);var a=t.slice(x.range[0],x.range[1]);return H(),m(g.literal(s,r,a))}return 4===s&&"function"===r?(ue(i),H(),n.scope&&ee(),ve(null)):K("{")?(ue(i),we(e)):void 0}ce.prototype.complete=function(){n.locations&&(this.loc.end.line=_.lastLine||_.line,this.loc.end.column=_.range[1]-(_.lastLineStart||_.lineStart)),n.ranges&&(this.range[1]=_.range[1])},ce.prototype.bless=function(e){if(this.loc){var t=this.loc;e.loc={start:{line:t.start.line,column:t.start.column},end:{line:t.end.line,column:t.end.column}}}this.range&&(e.range=[this.range[0],this.range[1]])},de.prototype.isInLoop=function(){for(var e=this.scopes.length;e-- >0;)if(this.scopes[e].isLoop)return!0;return!1},de.prototype.pushScope=function(e){var t={labels:{},locals:[],deferredGotos:[],isLoop:!!e};this.scopes.push(t)},de.prototype.popScope=function(){for(var e=0;e<this.pendingGotos.length;++e){var t=this.pendingGotos[e];t.maxDepth>=this.scopes.length&&--t.maxDepth<=0&&I(t.token,p.labelNotVisible,t.target)}this.scopes.pop()},de.prototype.addGoto=function(e,t){for(var n=[],i=0;i<this.scopes.length;++i){var r=this.scopes[i];if(n.push(r.locals.length),Object.prototype.hasOwnProperty.call(r.labels,e))return}this.pendingGotos.push({maxDepth:this.scopes.length,target:e,token:t,localCounts:n})},de.prototype.addLabel=function(e,t){var n=this.currentScope();if(Object.prototype.hasOwnProperty.call(n.labels,e))I(t,p.labelAlreadyDefined,e,n.labels[e].line);else{for(var i=[],r=0;r<this.pendingGotos.length;++r){var s=this.pendingGotos[r];s.maxDepth>=this.scopes.length&&s.target===e?s.localCounts[this.scopes.length-1]<n.locals.length&&n.deferredGotos.push(s):i.push(s)}this.pendingGotos=i}n.labels[e]={localCount:n.locals.length,line:t.line}},de.prototype.addLocal=function(e,t){this.currentScope().locals.push({name:e,token:t})},de.prototype.currentScope=function(){return this.scopes[this.scopes.length-1]},de.prototype.raiseDeferredErrors=function(){for(var e=this.currentScope(),t=e.deferredGotos,n=0;n<t.length;++n){var i=t[n];I(i.token,p.gotoJumpInLocalScope,i.target,e.locals[i.localCounts[this.scopes.length-1]].name)}},fe.prototype.isInLoop=function(){return!!this.loopLevels.length},fe.prototype.pushScope=function(e){++this.level,e&&this.loopLevels.push(this.level)},fe.prototype.popScope=function(){var e=this.loopLevels,t=e.length;t&&e[t-1]===this.level&&e.pop(),--this.level},fe.prototype.addGoto=fe.prototype.addLabel=function(){throw new Error("This should never happen")},fe.prototype.addLocal=fe.prototype.raiseDeferredErrors=function(){},e.parse=function(o,l){if(void 0===l&&"object"==typeof o&&(l=o,o=void 0),l||(l={}),t=o||"",n=z({},a,l),w=0,A=1,T=0,i=t.length,E=[[]],P=0,C=[],oe=[],!Object.prototype.hasOwnProperty.call(Ee,n.luaVersion))throw new Error(v("Lua version '%1' not supported",n.luaVersion));if(r=z({},Ee[n.luaVersion]),void 0!==n.extendedIdentifiers&&(r.extendedIdentifiers=!!n.extendedIdentifiers),!Object.prototype.hasOwnProperty.call(c,n.encodingMode))throw new Error(v("Encoding mode '%1' not supported",n.encodingMode));return s=c[n.encodingMode],n.comments&&(S=[]),n.wait?e:Ce()};var Ee={5.1:{},5.2:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,relaxedBreak:!0},5.3:{labels:!0,emptyStatement:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,bitwiseOperators:!0,integerDivision:!0,relaxedBreak:!0},LuaJIT:{labels:!0,contextualGoto:!0,hexEscapes:!0,skipWhitespaceEscape:!0,strictEscapes:!0,unicodeEscapes:!0,imaginaryNumbers:!0,integerSuffixes:!0}};function Pe(n){return t+=String(n),i=t.length,e}function Ce(e){void 0!==e&&Pe(e),t&&"#!"===t.substr(0,2)&&(t=t.replace(/^.*/,function(e){return e.replace(/./g," ")})),i=t.length,ae=n.locations||n.ranges,k=B();var r=function(){H(),he(),n.scope&&ee();var e=pe();e.allowVararg=!0,e.pushScope();var t=ge(e);return e.popScope(),n.scope&&te(),1!==x.type&&O(x),ae&&!t.length&&(_=x),m(g.chunk(t))}();if(n.comments&&(r.comments=S),n.scope&&(r.globals=C),oe.length>0)throw new Error("Location tracking failed. This is most likely a bug in luaparse");return r}e.write=Pe,e.end=Ce},xo=(bo=Mo.exports)&&!bo.nodeType&&bo,So=(_o=yo&&!yo.nodeType&&yo)&&_o.exports===xo&&xo,!(ko=xo&&_o&&"object"==typeof s&&s)||ko.global!==ko&&ko.window!==ko&&ko.self!==ko||(vo=ko),wo(xo&&_o?So?_o.exports:xo:vo.luaparse={});const Ao=a(Mo.exports),To=e=>"IfClause"===e.type||"ElseifClause"===e.type||"ElseClause"===e.type||"WhileStatement"===e.type||"DoStatement"===e.type||"RepeatStatement"===e.type||"FunctionDeclaration"===e.type||"ForNumericStatement"===e.type||"ForGenericStatement"===e.type||"Chunk"===e.type;class Eo extends String{constructor(e,t){super(),this.base=e,this.property=t}get(){return`__lua.get(${this.base}, ${this.property})`}set(e){return`${this.base}.set(${this.property}, ${e})`}setFn(){return`${this.base}.setFn(${this.property})`}toString(){return this.get()}valueOf(){return this.get()}}const Po={not:"not","-":"unm","~":"bnot","#":"len"},Co={"+":"add","-":"sub","*":"mul","%":"mod","^":"pow","/":"div","//":"idiv","&":"band","|":"bor","~":"bxor","<<":"shl",">>":"shr","..":"concat","~=":"neq","==":"eq","<":"lt","<=":"le",">":"gt",">=":"ge"},zo=e=>{switch(e.type){case"LabelStatement":return`case '${e.label.name}': label = undefined`;case"BreakStatement":return"break";case"GotoStatement":return`label = '${e.label.name}'; continue`;case"ReturnStatement":return`return ${Do(e.arguments)}`;case"IfStatement":return e.clauses.map(e=>zo(e)).join(" else ");case"IfClause":case"ElseifClause":return`if (__lua.bool(${Io(e.condition)})) {\n${Lo(e)}\n}`;case"ElseClause":return`{\n${Lo(e)}\n}`;case"WhileStatement":return`while(${Io(e.condition)}) {\n${Lo(e)}\n}`;case"DoStatement":return`\n${Lo(e)}\n`;case"RepeatStatement":{const t=Io(e.condition);return`do {\n${Lo(e)}\n} while (!(${t}))`}case"LocalStatement":case"AssignmentStatement":return Oo(e);case"CallStatement":return zo(e.expression);case"FunctionDeclaration":{const t=t=>{const n=t.join(";\n"),i=Lo(e,n);return`(${0===t.length?"":"...args"}) => {\n${i}${-1===e.body.findIndex(e=>"ReturnStatement"===e.type)?"\nreturn []":""}\n}`},n=e.parameters.map(e=>"VarargLiteral"===e.type?`$${$o.get(e)}.setVarargs(args)`:`$${$o.get(e)}.setLocal('${e.name}', args.shift())`);if(null===e.identifier)return t(n);if("Identifier"===e.identifier.type){return`$${$o.get(e.identifier)}.${e.isLocal?"setLocal":"set"}('${e.identifier.name}', ${t(n)})`}const i=zo(e.identifier);return":"===e.identifier.indexer&&n.unshift(`$${$o.get(e)}.setLocal('self', args.shift())`),i.set(t(n))}case"ForNumericStatement":{const t=e.variable.name,n=`let ${t} = ${Io(e.start)}, end = ${Io(e.end)}, step = ${null===e.step?1:Io(e.step)}`,i=`step > 0 ? ${t} <= end : ${t} >= end`,r=`${t} += step`,s=`$${$o.get(e.variable)}.setLocal('${t}', ${t});`;return`for (${n}; ${i}; ${r}) {\n${Lo(e,s)}\n}`}case"ForGenericStatement":{const t=Do(e.iterators),n=e.variables.map((e,t)=>`$${$o.get(e)}.setLocal('${e.name}', res[${t}])`).join(";\n");return`for (let [iterator, table, next] = ${t}, res = __lua.call(iterator, table, next); res[0] !== undefined; res = __lua.call(iterator, table, res[0])) {\n${Lo(e,n)}\n}`}case"Chunk":return`'use strict'\nconst $0 = __lua.globalScope\nlet vars\nlet vals\nlet label\n\n${Lo(e)}`;case"Identifier":return`$${$o.get(e)}.get('${e.name}')`;case"StringLiteral":return`\`${e.value.replace(/([^\\])?\\(\d{1,3})/g,(e,t,n)=>`${t||""}${String.fromCharCode(n)}`).replace(/\\/g,"\\\\").replace(/`/g,"\\`")}\``;case"NumericLiteral":return e.value.toString();case"BooleanLiteral":return e.value?"true":"false";case"NilLiteral":return"undefined";case"VarargLiteral":return`$${$o.get(e)}.getVarargs()`;case"TableConstructorExpression":if(0===e.fields.length)return"new __lua.Table()";return`new __lua.Table(t => {\n${e.fields.map((e,t,n)=>"TableKey"===e.type?`t.rawset(${zo(e.key)}, ${Io(e.value)})`:"TableKeyString"===e.type?`t.rawset('${e.key.name}', ${Io(e.value)})`:"TableValue"===e.type?t===n.length-1&&Fo(e.value)?`t.insert(...${zo(e.value)})`:`t.insert(${Io(e.value)})`:void 0).join(";\n")}\n})`;case"UnaryExpression":{const t=Po[e.operator],n=Io(e.argument);if(!t)throw new Error(`Unhandled unary operator: ${e.operator}`);return`__lua.${t}(${n})`}case"BinaryExpression":{const t=Io(e.left),n=Io(e.right),i=Co[e.operator];if(!i)throw new Error(`Unhandled binary operator: ${e.operator}`);return`__lua.${i}(${t}, ${n})`}case"LogicalExpression":{const t=Io(e.left),n=Io(e.right),i=e.operator;if("and"===i)return`__lua.and(${t},${n})`;if("or"===i)return`__lua.or(${t},${n})`;throw new Error(`Unhandled logical operator: ${e.operator}`)}case"MemberExpression":{const t=Io(e.base);return new Eo(t,`'${e.identifier.name}'`)}case"IndexExpression":{const t=Io(e.base),n=Io(e.index);return new Eo(t,n)}case"CallExpression":case"TableCallExpression":case"StringCallExpression":{const t=Io(e.base),n="CallExpression"===e.type?Ro(e.arguments).join(", "):Io("TableCallExpression"===e.type?e.arguments:e.argument);return t instanceof Eo&&"MemberExpression"===e.base.type&&":"===e.base.indexer?`__lua.call(${t}, ${t.base}, ${n})`:`__lua.call(${t}, ${n})`}default:throw new Error(`No generator found for: ${e.type}`)}},Lo=(e,t="")=>{const n=$o.get(e),i=void 0===n?"":`const $${n} = $${Uo.get(n)}.extend();`,r=e.body.map(e=>zo(e)).join(";\n"),s=Wo.get(e);if(void 0===s)return`${i}\n${t}\n${r}`;const a=`L${s}: do { switch(label) { case undefined:`,o=Vo.get(s);return`${i}\n${a}\n${t}\n${r}\n${`${void 0===o?"":`break; default: continue L${o}\n`}} } while (label)`}`},Io=e=>{const t=zo(e);return Fo(e)?`${t}[0]`:t},Do=e=>1===e.length&&Fo(e[0])?zo(e[0]):`[${Ro(e).join(", ")}]`,Ro=e=>e.map((e,t,n)=>{const i=zo(e);return Fo(e)?t===n.length-1?`...${i}`:`${i}[0]`:i}),Oo=e=>{const t=[],n=[],i=e.variables.length>1&&e.init.length>0&&!e.init.every(jo);for(let r=0;r<e.variables.length;r++){const s=e.variables[r],a=e.init[r],o=i?`vars[${r}]`:void 0===a?"undefined":Io(a);if("Identifier"===s.type){const n="LocalStatement"===e.type?"setLocal":"set";t.push(`$${$o.get(s)}.${n}('${s.name}', ${o})`)}else{const e=zo(s);i?(t.push(`vals[${n.length}](${o})`),n.push(e.setFn())):t.push(e.set(o))}}for(let r=e.variables.length;r<e.init.length;r++){const n=e.init[r];Bo(n)&&t.push(zo(n))}return i&&(t.unshift(`vars = ${Do(e.init)}`),n.length>0&&t.unshift(`vals = [${n.join(", ")}]`)),t.join(";\n")},Bo=e=>"CallExpression"===e.type||"StringCallExpression"===e.type||"TableCallExpression"===e.type,Fo=e=>Bo(e)||"VarargLiteral"===e.type,jo=e=>"StringLiteral"===e.type||"NumericLiteral"===e.type||"BooleanLiteral"===e.type||"NilLiteral"===e.type||"TableConstructorExpression"===e.type,No=e=>{const t=[];let n=0;const i=new Map,r=(()=>{let e=0;return()=>(e+=1,e)})(),s=e=>{if(To(e)){!function(){const e=n;n=r(),i.set(n,e)}();for(let i=0;i<e.body.length;i++){const r=e.body[i];switch(r.type){case"LocalStatement":t.push({type:"local",name:r.variables[0].name,scope:n});break;case"LabelStatement":if(t.find(e=>"label"===e.type&&e.name===r.label.name&&e.scope===n))throw new Error(`label '${r.label.name}' already defined`);t.push({type:"label",name:r.label.name,scope:n,last:"RepeatStatement"!==e.type&&e.body.slice(i).every(e=>"LabelStatement"===e.type)});break;case"GotoStatement":t.push({type:"goto",name:r.label.name,scope:n});break;case"IfStatement":r.clauses.forEach(e=>s(e));break;default:s(r)}}n=i.get(n)}};s(e);for(let a=0;a<t.length;a++){const e=t[a];if("goto"===e.type){const n=t.filter(t=>"label"===t.type&&t.name===e.name&&t.scope<=e.scope).sort((t,n)=>Math.abs(e.scope-t.scope)-Math.abs(e.scope-n.scope))[0];if(!n)throw new Error(`no visible label '${e.name}' for <goto>`);const i=t.findIndex(e=>e===n);if(i>a){const r=t.slice(a,i).filter(e=>"local"===e.type&&e.scope===n.scope);if(!n.last&&r.length>0)throw new Error(`<goto ${e.name}> jumps into the scope of local '${r[0].name}'`)}}}},Uo=new Map,$o=new Map,Vo=new Map,Wo=new Map,Ho=e=>{let t=0,n=0;const i=(e,r,s)=>{let a=r,o=s;To(e)?((-1!==e.body.findIndex(e=>"LocalStatement"===e.type||"FunctionDeclaration"===e.type&&e.isLocal)||"FunctionDeclaration"===e.type&&(e.parameters.length>0||e.identifier&&"MemberExpression"===e.identifier.type)||"ForNumericStatement"===e.type||"ForGenericStatement"===e.type)&&(t+=1,a=t,$o.set(e,t),Uo.set(t,r)),-1!==e.body.findIndex(e=>"LabelStatement"===e.type||"GotoStatement"===e.type)&&(o=n,Wo.set(e,n),"Chunk"!==e.type&&"FunctionDeclaration"!==e.type&&Vo.set(n,s),n+=1)):"Identifier"!==e.type&&"VarargLiteral"!==e.type||$o.set(e,r),((e,t,n,i,r)=>{const s=(e,s=!0)=>{if(!e)return;const a=!1===s&&i?Uo.get(n):n;Array.isArray(e)?e.forEach(e=>t(e,a,r)):t(e,a,r)};switch(e.type){case"LocalStatement":case"AssignmentStatement":s(e.variables),s(e.init);break;case"UnaryExpression":s(e.argument);break;case"BinaryExpression":case"LogicalExpression":s(e.left),s(e.right);break;case"FunctionDeclaration":s(e.identifier,!1),s(e.parameters),s(e.body);break;case"ForGenericStatement":s(e.variables),s(e.iterators,!1),s(e.body);break;case"IfClause":case"ElseifClause":case"WhileStatement":case"RepeatStatement":s(e.condition,!1);case"Chunk":case"ElseClause":case"DoStatement":s(e.body);break;case"ForNumericStatement":s(e.variable),s(e.start,!1),s(e.end,!1),s(e.step,!1),s(e.body);break;case"ReturnStatement":s(e.arguments);break;case"IfStatement":s(e.clauses);break;case"MemberExpression":s(e.base),s(e.identifier);break;case"IndexExpression":s(e.base),s(e.index);break;case"LabelStatement":s(e.label);break;case"CallStatement":s(e.expression);break;case"GotoStatement":s(e.label);break;case"TableConstructorExpression":s(e.fields);break;case"TableKey":case"TableKeyString":s(e.key);case"TableValue":s(e.value);break;case"CallExpression":case"TableCallExpression":s(e.base),s(e.arguments);break;case"StringCallExpression":s(e.base),s(e.argument)}})(e,i,a,r!==a,o)};i(e,t,n)},Ko=e=>{const t=Ao.parse(e.replace(/^#.*/,""),{scope:!1,comments:!1,luaVersion:"5.3",encodingMode:"x-user-defined"});return No(t),Ho(t),zo(t).toString()};var Zo={version:"1.3.1"};const Go=Zo.version;var Xo={};function Yo(e){if(Xo[e])return Xo[e];for(var t=[],n=0,i=0,r=!1,s="",a="",o="",l="",c="",h=0,u=e.length;i<u;++i)if(h=e.charCodeAt(i),r)if(h>=48&&h<58)l.length?l+=String.fromCharCode(h):48!=h||o.length?o+=String.fromCharCode(h):a+=String.fromCharCode(h);else switch(h){case 36:l.length?l+="$":"*"==o.charAt(0)?o+="$":(s=o+"$",o="");break;case 39:a+="'";break;case 45:a+="-";break;case 43:a+="+";break;case 32:a+=" ";break;case 35:a+="#";break;case 46:l=".";break;case 42:"."==l.charAt(0)?l+="*":o+="*";break;case 104:case 108:if(c.length>1)throw"bad length "+c+String(h);c+=String.fromCharCode(h);break;case 76:case 106:case 122:case 116:case 113:case 90:case 119:if(""!==c)throw"bad length "+c+String.fromCharCode(h);c=String.fromCharCode(h);break;case 73:if(""!==c)throw"bad length "+c+"I";c="I";break;case 100:case 105:case 111:case 117:case 120:case 88:case 102:case 70:case 101:case 69:case 103:case 71:case 97:case 65:case 99:case 67:case 115:case 83:case 112:case 110:case 68:case 85:case 79:case 109:case 98:case 66:case 121:case 89:case 74:case 86:case 84:case 37:r=!1,l.length>1&&(l=l.substr(1)),t.push([String.fromCharCode(h),e.substring(n,i+1),s,a,o,l,c]),n=i+1,c=l=o=a=s="";break;default:throw new Error("Invalid format string starting with |"+e.substring(n,i+1)+"|")}else{if(37!==h)continue;n<i&&t.push(["L",e.substring(n,i)]),n=i,r=!0}return n<e.length&&t.push(["L",e.substring(n)]),Xo[e]=t}var qo=JSON.stringify;function Jo(e,t){for(var n="",i=0,r=0,s=0,a="",o=0;o<e.length;++o){var l=e[o],c=l[0].charCodeAt(0);if(76!==c)if(37!==c){var h="",u=0,d=10,f=4,p=!1,g=l[3],m=g.indexOf("#")>-1;if(l[2])i=parseInt(l[2],10)-1;else if(109===c&&!m){n+="Success";continue}var y=0;l[4].length>0&&(y="*"!==l[4].charAt(0)?parseInt(l[4],10):1===l[4].length?t[r++]:t[parseInt(l[4].substr(1),10)-1]);var b=-1;l[5].length>0&&(b="*"!==l[5].charAt(0)?parseInt(l[5],10):1===l[5].length?t[r++]:t[parseInt(l[5].substr(1),10)-1]),l[2]||(i=r++);var v=t[i],w=l[6];switch(c){case 83:case 115:h=String(v),b>=0&&(h=h.substr(0,b)),(y>h.length||-y>h.length)&&((-1==g.indexOf("-")||y<0)&&-1!=g.indexOf("0")?h=(a=y-h.length>=0?"0".repeat(y-h.length):"")+h:(a=y-h.length>=0?" ".repeat(y-h.length):"",h=g.indexOf("-")>-1?h+a:a+h));break;case 67:case 99:switch(typeof v){case"number":var x=v;67==c||108===w.charCodeAt(0)?(x&=4294967295,h=String.fromCharCode(x)):(x&=255,h=String.fromCharCode(x));break;case"string":h=v.charAt(0);break;default:h=String(v).charAt(0)}(y>h.length||-y>h.length)&&((-1==g.indexOf("-")||y<0)&&-1!=g.indexOf("0")?h=(a=y-h.length>=0?"0".repeat(y-h.length):"")+h:(a=y-h.length>=0?" ".repeat(y-h.length):"",h=g.indexOf("-")>-1?h+a:a+h));break;case 68:f=8;case 100:case 105:u=-1,p=!0;break;case 85:f=8;case 117:u=-1;break;case 79:f=8;case 111:u=-1,d=8;break;case 120:u=-1,d=-16;break;case 88:u=-1,d=16;break;case 66:f=8;case 98:u=-1,d=2;break;case 70:case 102:u=1;break;case 69:case 101:u=2;break;case 71:case 103:u=3;break;case 65:case 97:u=4;break;case 112:s="number"==typeof v?v:v?Number(v.l):-1,isNaN(s)&&(s=-1),h=m?s.toString(10):"0x"+(s=Math.abs(s)).toString(16).toLowerCase();break;case 110:v&&(v.len=n.length);continue;case 109:h=v instanceof Error?v.message?v.message:v.errno?"Error number "+v.errno:"Error "+String(v):"Success";break;case 74:h=(m?qo:JSON.stringify)(v);break;case 86:h=null==v?"null":String(v.valueOf());break;case 84:h=m?(h=Object.prototype.toString.call(v).substr(8)).substr(0,h.length-1):typeof v;break;case 89:case 121:h=v?m?"yes":"true":m?"no":"false",89==c&&(h=h.toUpperCase()),b>=0&&(h=h.substr(0,b)),(y>h.length||-y>h.length)&&((-1==g.indexOf("-")||y<0)&&-1!=g.indexOf("0")?h=(a=y-h.length>=0?"0".repeat(y-h.length):"")+h:(a=y-h.length>=0?" ".repeat(y-h.length):"",h=g.indexOf("-")>-1?h+a:a+h))}if(y<0&&(y=-y,g+="-"),-1==u){switch(s=Number(v),w){case"hh":f=1;break;case"h":f=2;break;case"l":case"L":case"q":case"ll":case"j":case"t":case"z":case"Z":case"I":4==f&&(f=8)}switch(f){case 1:s&=255,p&&s>127&&(s-=256);break;case 2:s&=65535,p&&s>32767&&(s-=65536);break;case 4:s=p?0|s:s>>>0;break;default:s=isNaN(s)?0:Math.round(s)}if(f>4&&s<0&&!p)if(16==d||-16==d)h=(s>>>0).toString(16),h=(16-(h=((s=Math.floor((s-(s>>>0))/Math.pow(2,32)))>>>0).toString(16)+(8-h.length>=0?"0".repeat(8-h.length):"")+h).length>=0?"f".repeat(16-h.length):"")+h,16==d&&(h=h.toUpperCase());else if(8==d)h=(10-(h=(s>>>0).toString(8)).length>=0?"0".repeat(10-h.length):"")+h,h="1"+(21-(h=(h=((s=Math.floor((s-(s>>>0&1073741823))/Math.pow(2,30)))>>>0).toString(8)+h.substr(h.length-10)).substr(h.length-20)).length>=0?"7".repeat(21-h.length):"")+h;else{s=-s%1e16;for(var _=[1,8,4,4,6,7,4,4,0,7,3,7,0,9,5,5,1,6,1,6],k=_.length-1;s>0;)(_[k]-=s%10)<0&&(_[k]+=10,_[k-1]--),--k,s=Math.floor(s/10);h=_.join("")}else h=-16===d?s.toString(16).toLowerCase():16===d?s.toString(16).toUpperCase():s.toString(d);if(0!==b||"0"!=h||8==d&&m){if(h.length<b+("-"==h.substr(0,1)?1:0)&&(h="-"!=h.substr(0,1)?(b-h.length>=0?"0".repeat(b-h.length):"")+h:h.substr(0,1)+(b+1-h.length>=0?"0".repeat(b+1-h.length):"")+h.substr(1)),!p&&m&&0!==s)switch(d){case-16:h="0x"+h;break;case 16:h="0X"+h;break;case 8:"0"!=h.charAt(0)&&(h="0"+h);break;case 2:h="0b"+h}}else h="";p&&"-"!=h.charAt(0)&&(g.indexOf("+")>-1?h="+"+h:g.indexOf(" ")>-1&&(h=" "+h)),y>0&&h.length<y&&(g.indexOf("-")>-1?h+=y-h.length>=0?" ".repeat(y-h.length):"":g.indexOf("0")>-1&&b<0&&h.length>0?(b>h.length&&(h=(b-h.length>=0?"0".repeat(b-h.length):"")+h),a=y-h.length>=0?(b>0?" ":"0").repeat(y-h.length):"",h=h.charCodeAt(0)<48?"x"==h.charAt(2).toLowerCase()?h.substr(0,3)+a+h.substring(3):h.substr(0,1)+a+h.substring(1):"x"==h.charAt(1).toLowerCase()?h.substr(0,2)+a+h.substring(2):a+h):h=(y-h.length>=0?" ".repeat(y-h.length):"")+h)}else if(u>0){s=Number(v),null===v&&(s=NaN),"L"==w&&(f=12);var S=isFinite(s);if(S){var M=0;-1==b&&4!=u&&(b=6),3==u&&(0===b&&(b=1),b>(M=+(h=s.toExponential(1)).substr(h.indexOf("e")+1))&&M>=-4?(u=11,b-=M+1):(u=12,b-=1));var A=s<0||1/s==-1/0?"-":"";switch(s<0&&(s=-s),u){case 1:case 11:if(s<1e21){h=s.toFixed(b),1==u?0===b&&m&&-1==h.indexOf(".")&&(h+="."):m?-1==h.indexOf(".")&&(h+="."):h=h.replace(/(\.\d*[1-9])0*$/,"$1").replace(/\.0*$/,"");break}M=+(h=s.toExponential(20)).substr(h.indexOf("e")+1),h=h.charAt(0)+h.substr(2,h.indexOf("e")-2),h+=M-h.length+1>=0?"0".repeat(M-h.length+1):"",(m||b>0&&11!==u)&&(h=h+"."+(b>=0?"0".repeat(b):""));break;case 2:case 12:M=(h=s.toExponential(b)).indexOf("e"),h.length-M===3&&(h=h.substr(0,M+2)+"0"+h.substr(M+2)),m&&-1==h.indexOf(".")?h=h.substr(0,M)+"."+h.substr(M):m||12!=u||(h=h.replace(/\.0*e/,"e").replace(/\.(\d*[1-9])0*e/,".$1e"));break;case 4:if(0===s){h="0x0"+(m||b>0?"."+(b>=0?"0".repeat(b):""):"")+"p+0";break}var T=(h=s.toString(16)).charCodeAt(0);if(48==T){for(T=2,M=-4,s*=16;48==h.charCodeAt(T++);)M-=4,s*=16;T=(h=s.toString(16)).charCodeAt(0)}var E=h.indexOf(".");if(h.indexOf("(")>-1){var P=h.match(/\(e(.*)\)/),C=P?+P[1]:0;M+=4*C,s/=Math.pow(16,C)}else E>1?(M+=4*(E-1),s/=Math.pow(16,E-1)):-1==E&&(M+=4*(h.length-1),s/=Math.pow(16,h.length-1));if(f>8?T<50?(M-=3,s*=8):T<52?(M-=2,s*=4):T<56&&(M-=1,s*=2):T>=56?(M+=3,s/=8):T>=52?(M+=2,s/=4):T>=50&&(M+=1,s/=2),(h=s.toString(16)).length>1){if(h.length>b+2&&h.charCodeAt(b+2)>=56){var z=102==h.charCodeAt(0);h=(s+8*Math.pow(16,-b-1)).toString(16),z&&49==h.charCodeAt(0)&&(M+=4)}b>0?(h=h.substr(0,b+2)).length<b+2&&(h.charCodeAt(0)<48?h=h.charAt(0)+(b+2-h.length>=0?"0".repeat(b+2-h.length):"")+h.substr(1):h+=b+2-h.length>=0?"0".repeat(b+2-h.length):""):0===b&&(h=h.charAt(0)+(m?".":""))}else b>0?h=h+"."+(b>=0?"0".repeat(b):""):m&&(h+=".");h="0x"+h+"p"+(M>=0?"+"+M:M)}""===A&&(g.indexOf("+")>-1?A="+":g.indexOf(" ")>-1&&(A=" ")),h=A+h}else s<0?h="-":g.indexOf("+")>-1?h="+":g.indexOf(" ")>-1&&(h=" "),h+=isNaN(s)?"nan":"inf";y>h.length&&(g.indexOf("-")>-1?h+=y-h.length>=0?" ".repeat(y-h.length):"":g.indexOf("0")>-1&&h.length>0&&S?(a=y-h.length>=0?"0".repeat(y-h.length):"",h=h.charCodeAt(0)<48?"x"==h.charAt(2).toLowerCase()?h.substr(0,3)+a+h.substring(3):h.substr(0,1)+a+h.substring(1):"x"==h.charAt(1).toLowerCase()?h.substr(0,2)+a+h.substring(2):a+h):h=(y-h.length>=0?" ".repeat(y-h.length):"")+h),c<96&&(h=h.toUpperCase())}n+=h}else n+="%";else n+=l[1]}return n}const Qo=Object.freeze(Object.defineProperty({__proto__:null,sprintf:function(){for(var e=new Array(arguments.length-1),t=0;t<e.length;++t)e[t]=arguments[t+1];return Jo(Yo(arguments[0]),e)},version:Go,vsprintf:function(e,t){return Jo(Yo(e),t)}},Symbol.toStringTag,{value:"Module"})),{sprintf:el}=Qo,tl={"([^a-zA-Z0-9%(])-":"$1*?","([^%])-([^a-zA-Z0-9?])":"$1*?$2","([^%])\\.":"$1[\\s\\S]","(.)-$":"$1*?","%a":"[a-zA-Z]","%A":"[^a-zA-Z]","%c":"[\0-]","%C":"[^\0-]","%d":"\\d","%D":"[^d]","%l":"[a-z]","%L":"[^a-z]","%p":"[.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%P":"[^.,\"'?!;:#$%&()*+-/<>=@\\[\\]\\\\^_{}|~]","%s":"[ \\t\\n\\f\\v\\r]","%S":"[^ \t\n\f\v\r]","%u":"[A-Z]","%U":"[^A-Z]","%w":"[a-zA-Z0-9]","%W":"[^a-zA-Z0-9]","%x":"[a-fA-F0-9]","%X":"[^a-fA-F0-9]","%([^a-zA-Z])":"\\$1"};function nl(e){let t=e.replace(/\\/g,"\\\\");for(const i in tl)po(tl,i)&&(t=t.replace(new RegExp(i,"g"),tl[i]));let n=0;for(let i=0,r=t.length;i<r;i++){if(i&&"\\"===t.substr(i-1,1))continue;const e=t.substr(i,1);"["!==e&&"]"!==e||("]"===e&&(n-=1),n>0&&(t=t.substr(0,i)+t.substr(i+1),i-=1,r-=1),"["===e&&(n+=1))}return t}const il=new qa({byte:function(e,t,n){const i=co(e,"byte",1),r=void 0===t?1:lo(t,"byte",2),s=void 0===n?r:lo(n,"byte",3);return i.substring(r-1,s).split("").map(e=>e.charCodeAt(0))},char:function(...e){return e.map((e,t)=>{const n=lo(e,"char",t);return String.fromCharCode(n)}).join("")},find:function(e,t,n,i){const r=co(e,"find",1),s=co(t,"find",2),a=void 0===n?1:lo(n,"find",3);if(!(void 0!==i&&lo(i,"find",4))){const e=new RegExp(nl(s)),t=r.substr(a-1).search(e);if(t<0)return;const n=r.substr(a-1).match(e),i=[t+a,t+a+n[0].length-1];return n.shift(),[...i,...n]}const o=r.indexOf(s,a-1);return-1===o?void 0:[o+1,o+s.length]},format:function(e,...t){let n=-1;return e.replace(/%%|%([-+ #0]*)?(\d*)?(?:\.(\d*))?(.)/g,(e,i,r,s,a)=>{if("%%"===e)return"%";if(!a.match(/[AEGXacdefgioqsux]/))throw new Ya(`invalid option '%${e}' to 'format'`);if(i&&i.length>5)throw new Ya("invalid format (repeated flags)");if(r&&r.length>2)throw new Ya("invalid format (width too long)");if(s&&s.length>2)throw new Ya("invalid format (precision too long)");n+=1;const o=t[n];if(void 0===o)throw new Ya(`bad argument #${n} to 'format' (no value)`);return/A|a|E|e|f|G|g/.test(a)||/c|d|i|o|u|X|x/.test(a)?el(e,lo(o,"format",n)):"q"===a?`"${o.replace(/([\n"])/g,"\\$1")}"`:el(e,"s"===a?to(o):o)})},gmatch:function(e,t){const n=co(e,"gmatch",1),i=nl(co(t,"gmatch",2)),r=new RegExp(i,"g"),s=n.match(r);return()=>{const e=s.shift();if(void 0===e)return[];const t=new RegExp(i).exec(e);return t.shift(),t.length?t:[e]}},gsub:function(e,t,n,i){let r=co(e,"gsub",1);const s=void 0===i?1/0:lo(i,"gsub",3),a=nl(co(t,"gsub",2)),o="function"==typeof n?e=>{const t=n(e[0])[0];return void 0===t?e[0]:t}:n instanceof qa?e=>n.get(e[0]).toString():e=>`${n}`.replace(/%([0-9])/g,(t,n)=>e[n]);let l,c,h="",u=0;for(;u<s&&r&&(l=r.match(a));){const e=l[0].length>0?r.substr(0,l.index):void 0===c?"":r.substr(0,1);c=l[0],h+=`${e}${o(l)}`,r=r.substr(`${e}${c}`.length),u+=1}return`${h}${r}`},len:function(e){return co(e,"len",1).length},lower:function(e){return co(e,"lower",1).toLowerCase()},match:function(e,t,n=0){let i=co(e,"match",1);const r=co(t,"match",2),s=lo(n,"match",3);i=i.substr(s);const a=i.match(new RegExp(nl(r)));if(a)return a[1]?(a.shift(),a):a[0]},rep:function(e,t,n){const i=co(e,"rep",1),r=lo(t,"rep",2),s=void 0===n?"":co(n,"rep",3);return Array(r).fill(i).join(s)},reverse:function(e){return co(e,"reverse",1).split("").reverse().join("")},sub:function(e,t=1,n=-1){const i=co(e,"sub",1);let r=no(lo(t,"sub",2),i.length),s=no(lo(n,"sub",3),i.length);return r<1&&(r=1),s>i.length&&(s=i.length),r<=s?i.substr(r-1,s-r+1):""},upper:function(e){return co(e,"upper",1).toUpperCase()}}),rl=new qa({__index:il});function sl(e,t){if(void 0===t)throw new Ya("Bad argument #2 to ipairs() iterator");const n=t+1,i=e.numValues;if(i[n]&&void 0!==i[n])return[n,i[n]]}function al(e,t){if(ro(e))return[e,t];const n=void 0===t?"Assertion failed!":co(t,"assert",2);throw new Ya(n)}function ol(){return[]}function ll(e){const t=co(e,"error",1);throw new Ya(t)}function cl(e){if(e instanceof qa&&e.metatable){const t=e.metatable.rawget("__metatable");return t||e.metatable}if("string"==typeof e)return rl}function hl(e){const t=ho(e,"ipairs",1),n=t.getMetaMethod("__pairs")||t.getMetaMethod("__ipairs");return n?n(t).slice(0,3):[sl,t,0]}function ul(e,t){const n=ho(e,"next",1);let i=void 0===t;if(i||"number"==typeof t&&t>0){const e=n.numValues,r=Object.keys(e);let s=1;if(!i){const e=r.indexOf(`${t}`);e>=0&&(i=!0,s+=e)}if(i)for(;void 0!==r[s];s++){const t=Number(r[s]),n=e[t];if(void 0!==n)return[t,n]}}for(const r in n.strValues)if(po(n.strValues,r))if(i){if(void 0!==n.strValues[r])return[r,n.strValues[r]]}else r===t&&(i=!0);for(const r in n.keys)if(po(n.keys,r)){const e=n.keys[r];if(i){if(void 0!==n.values[r])return[e,n.values[r]]}else e===t&&(i=!0)}}function dl(e){const t=ho(e,"pairs",1),n=t.getMetaMethod("__pairs");return n?n(t).slice(0,3):[ul,t,void 0]}function fl(e,...t){if("function"!=typeof e)throw new Ya("Attempt to call non-function");try{return[!0,...e(...t)]}catch(Yc){return[!1,Yc&&Yc.toString()]}}function pl(e,t){return e===t}function gl(e,t){return ho(e,"rawget",1).rawget(t)}function ml(e){if(e instanceof qa)return e.getn();if("string"==typeof e)return e.length;throw new Ya("attempt to get length of an unsupported value")}function yl(e,t,n){const i=ho(e,"rawset",1);if(void 0===t)throw new Ya("table index is nil");return i.rawset(t,n),i}function bl(e,...t){if("#"===e)return t.length;if("number"==typeof e){const n=no(Math.trunc(e),t.length);return t.slice(n-1)}throw new Ya(`bad argument #1 to 'select' (number expected, got ${eo(e)})`)}function vl(e,t){const n=ho(e,"setmetatable",1);if(n.metatable&&n.metatable.rawget("__metatable"))throw new Ya("cannot change a protected metatable");return n.metatable=null==t?null:ho(t,"setmetatable",2),n}function wl(e,t){const n=ao(e).trim(),i=void 0===t?10:lo(t,"tonumber",2);if(10!==i&&"nil"===n)throw new Ya("bad argument #1 to 'tonumber' (string expected, got nil)");if(i<2||i>36)throw new Ya("bad argument #2 to 'tonumber' (base out of range)");if(""===n)return;if(10===i)return so(n);return new RegExp(`^${16===i?"(0x)?":""}[${"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".substr(0,i)}]*$`,"gi").test(n)?parseInt(n,i):void 0}function xl(e,t,...n){if("function"!=typeof e||"function"!=typeof t)throw new Ya("Attempt to call non-function");try{return[!0,...e(...n)]}catch(Yc){return[!1,t(Yc)[0]]}}const _l=(e,t,n,i)=>{const r=e instanceof qa&&e.getMetaMethod(n)||t instanceof qa&&t.getMetaMethod(n);if(r)return r(e,t)[0];return i(so(e,"attempt to perform arithmetic on a %type value"),so(t,"attempt to perform arithmetic on a %type value"))},kl=(e,t,n,i)=>"string"==typeof e&&"string"==typeof t||"number"==typeof e&&"number"==typeof t?i(e,t):_l(e,t,n,i),Sl=e=>ro(e),Ml=(e,t)=>{const n=t!==e&&e instanceof qa&&t instanceof qa&&e.metatable===t.metatable&&e.getMetaMethod("__eq");return n?!!n(e,t)[0]:e===t},Al=(e,t)=>kl(e,t,"__lt",(e,t)=>e<t),Tl=(e,t)=>kl(e,t,"__le",(e,t)=>e<=t),El={bool:Sl,and:(e,t)=>ro(e)?t:e,or:(e,t)=>ro(e)?e:t,not:e=>!Sl(e),unm:e=>{const t=e instanceof qa&&e.getMetaMethod("__unm");return t?t(e)[0]:-1*so(e,"attempt to perform arithmetic on a %type value")},bnot:e=>{const t=e instanceof qa&&e.getMetaMethod("__bnot");return t?t(e)[0]:~so(e,"attempt to perform arithmetic on a %type value")},len:e=>{if(e instanceof qa){const t=e.getMetaMethod("__len");return t?t(e)[0]:e.getn()}if("string"==typeof e)return e.length;throw new Ya("attempt to get length of an unsupported value")},add:(e,t)=>_l(e,t,"__add",(e,t)=>e+t),sub:(e,t)=>_l(e,t,"__sub",(e,t)=>e-t),mul:(e,t)=>_l(e,t,"__mul",(e,t)=>e*t),mod:(e,t)=>_l(e,t,"__mod",(e,t)=>{if(0===t||t===-1/0||t===1/0||isNaN(e)||isNaN(t))return NaN;const n=Math.abs(t);let i=Math.abs(e)%n;return e*t<0&&(i=n-i),t<0&&(i*=-1),i}),pow:(e,t)=>_l(e,t,"__pow",Math.pow),div:(e,t)=>_l(e,t,"__div",(e,t)=>{if(void 0===t)throw new Ya("attempt to perform arithmetic on a nil value");return e/t}),idiv:(e,t)=>_l(e,t,"__idiv",(e,t)=>{if(void 0===t)throw new Ya("attempt to perform arithmetic on a nil value");return Math.floor(e/t)}),band:(e,t)=>_l(e,t,"__band",(e,t)=>e&t),bor:(e,t)=>_l(e,t,"__bor",(e,t)=>e|t),bxor:(e,t)=>_l(e,t,"__bxor",(e,t)=>e^t),shl:(e,t)=>_l(e,t,"__shl",(e,t)=>e<<t),shr:(e,t)=>_l(e,t,"__shr",(e,t)=>e>>t),concat:(e,t)=>{const n=e instanceof qa&&e.getMetaMethod("__concat")||t instanceof qa&&t.getMetaMethod("__concat");if(n)return n(e,t)[0];return`${ao(e,"attempt to concatenate a %type value")}${ao(t,"attempt to concatenate a %type value")}`},neq:(e,t)=>!Ml(e,t),eq:Ml,lt:Al,le:Tl,gt:(e,t)=>!Tl(e,t),ge:(e,t)=>!Al(e,t)},Pl=Number.MAX_SAFE_INTEGER,Cl=Number.MIN_SAFE_INTEGER,zl=1/0,Ll=Math.PI;let Il=1;function Dl(){return Il=16807*Il%2147483647,Il/2147483647}function Rl(e,t){const n=lo(e,"atan",1),i=void 0===t?1:lo(t,"atan",2);return Math.atan2(n,i)}function Ol(e){const t=lo(e,"exp",1);return Math.exp(t)}function Bl(e){const t=so(e);if(void 0!==t)return Math.floor(t)}const Fl=new qa({abs:function(e){const t=lo(e,"abs",1);return Math.abs(t)},acos:function(e){const t=lo(e,"acos",1);return Math.acos(t)},asin:function(e){const t=lo(e,"asin",1);return Math.asin(t)},atan:Rl,atan2:function(e,t){return Rl(e,t)},ceil:function(e){const t=lo(e,"ceil",1);return Math.ceil(t)},cos:function(e){const t=lo(e,"cos",1);return Math.cos(t)},cosh:function(e){const t=lo(e,"cosh",1);return(Ol(t)+Ol(-t))/2},deg:function(e){return 180*lo(e,"deg",1)/Math.PI},exp:Ol,floor:function(e){const t=lo(e,"floor",1);return Math.floor(t)},fmod:function(e,t){return lo(e,"fmod",1)%lo(t,"fmod",2)},frexp:function(e){let t=lo(e,"frexp",1);if(0===t)return[0,0];const n=t>0?1:-1;t*=n;const i=Math.floor(Math.log(t)/Math.log(2))+1;return[t/Math.pow(2,i)*n,i]},huge:zl,ldexp:function(e,t){const n=lo(e,"ldexp",1),i=lo(t,"ldexp",2);return n*Math.pow(2,i)},log:function(e,t){const n=lo(e,"log",1);if(void 0===t)return Math.log(n);{const e=lo(t,"log",2);return Math.log(n)/Math.log(e)}},log10:function(e){const t=lo(e,"log10",1);return Math.log(t)/Math.log(10)},max:function(...e){const t=e.map((e,t)=>lo(e,"max",t+1));return Math.max(...t)},min:function(...e){const t=e.map((e,t)=>lo(e,"min",t+1));return Math.min(...t)},maxinteger:Pl,mininteger:Cl,modf:function(e){const t=lo(e,"modf",1),n=Math.floor(t);return[n,t-n]},pi:Ll,pow:function(e,t){const n=lo(e,"pow",1),i=lo(t,"pow",2);return Math.pow(n,i)},rad:function(e){const t=lo(e,"rad",1);return Math.PI/180*t},random:function(e,t){if(void 0===e&&void 0===t)return Dl();const n=lo(e,"random",1),i=void 0!==t?n:1,r=void 0!==t?lo(t,"random",2):n;if(i>r)throw new Error("bad argument #2 to 'random' (interval is empty)");return Math.floor(Dl()*(r-i+1)+i)},randomseed:function(e){Il=lo(e,"randomseed",1)},sin:function(e){const t=lo(e,"sin",1);return Math.sin(t)},sinh:function(e){const t=lo(e,"sinh",1);return(Ol(t)-Ol(-t))/2},sqrt:function(e){const t=lo(e,"sqrt",1);return Math.sqrt(t)},tan:function(e){const t=lo(e,"tan",1);return Math.tan(t)},tanh:function(e){const t=lo(e,"tanh",1);return(Ol(t)-Ol(-t))/(Ol(t)+Ol(-t))},tointeger:Bl,type:function(e){const t=so(e);if(void 0!==t)return Bl(t)===t?"integer":"float"},ult:function(e,t){const n=lo(e,"ult",1),i=lo(t,"ult",2),r=e=>e>>>0;return r(n)<r(i)}});function jl(e){return ho(e,"maxn",1).numValues.length-1}const Nl=new qa({getn:function(e){return ho(e,"getn",1).getn()},concat:function(e,t="",n=1,i){const r=ho(e,"concat",1),s=co(t,"concat",2),a=lo(n,"concat",3),o=void 0===i?jl(r):lo(i,"concat",4);return[].concat(r.numValues).splice(a,o-a+1).join(s)},insert:function(e,t,n){const i=ho(e,"insert",1),r=void 0===n?i.numValues.length:lo(t,"insert",2),s=void 0===n?t:n;i.numValues.splice(r,0,void 0),i.set(r,s)},maxn:jl,move:function(e,t,n,i,r){const s=ho(e,"move",1),a=lo(t,"move",2),o=lo(n,"move",3),l=lo(i,"move",4),c=void 0===r?s:ho(r,"move",5);if(o>=a){if(a<=0&&o>=Number.MAX_SAFE_INTEGER+a)throw new Ya("too many elements to move");const e=o-a+1;if(l>Number.MAX_SAFE_INTEGER-e+1)throw new Ya("destination wrap around");if(l>o||l<=a||c!==s)for(let t=0;t<e;t++){const e=s.get(a+t);c.set(l+t,e)}else for(let t=e-1;t>=0;t--){const e=s.get(a+t);c.set(l+t,e)}}return c},pack:function(...e){const t=new qa(e);return t.rawset("n",e.length),t},remove:function(e,t){const n=ho(e,"remove",1),i=n.getn(),r=void 0===t?i:lo(t,"remove",2);if(r>i||r<0)return;const s=n.numValues,a=s.splice(r,1)[0];let o=r;for(;o<i&&void 0===s[o];)delete s[o],o+=1;return a},sort:function(e,t){const n=ho(e,"sort",1);let i;if(t){const e=uo(t,"sort",2);i=(t,n)=>ro(e(t,n)[0])?-1:1}else i=(e,t)=>e<t?-1:1;const r=n.numValues;r.shift(),r.sort(i).unshift(void 0)},unpack:function(e,t,n){const i=ho(e,"unpack",1),r=void 0===t?1:lo(t,"unpack",2),s=void 0===n?i.getn():lo(n,"unpack",3);return i.numValues.slice(r,s+1)}}),Ul=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],$l=["January","February","March","April","May","June","July","August","September","October","November","December"],Vl=[31,28,31,30,31,30,31,31,30,31,30,31],Wl={"%":()=>"%",Y:(e,t)=>`${t?e.getUTCFullYear():e.getFullYear()}`,y:(e,t)=>Wl.Y(e,t).substr(-2),b:(e,t)=>Wl.B(e,t).substr(0,3),B:(e,t)=>$l[t?e.getUTCMonth():e.getMonth()],m:(e,t)=>`0${(t?e.getUTCMonth():e.getMonth())+1}`.substr(-2),U:(e,t)=>Kl(e,0,t),W:(e,t)=>Kl(e,1,t),j:(e,t)=>{let n=t?e.getUTCDate():e.getDate();const i=t?e.getUTCMonth():e.getMonth(),r=t?e.getUTCFullYear():e.getFullYear();return n+=Vl.slice(0,i).reduce((e,t)=>e+t,0),i>1&&r%4==0&&(n+=1),`00${n}`.substr(-3)},d:(e,t)=>`0${t?e.getUTCDate():e.getDate()}`.substr(-2),a:(e,t)=>Wl.A(e,t).substr(0,3),A:(e,t)=>Ul[t?e.getUTCDay():e.getDay()],w:(e,t)=>`${t?e.getUTCDay():e.getDay()}`,H:(e,t)=>`0${t?e.getUTCHours():e.getHours()}`.substr(-2),I:(e,t)=>`0${(t?e.getUTCHours():e.getHours())%12||12}`.substr(-2),M:(e,t)=>`0${t?e.getUTCMinutes():e.getMinutes()}`.substr(-2),S:(e,t)=>`0${t?e.getUTCSeconds():e.getSeconds()}`.substr(-2),c:(e,t)=>e.toLocaleString(void 0,t?{timeZone:"UTC"}:void 0),x:(e,t)=>`${Wl.m(e,t)}/${Wl.d(e,t)}/${Wl.y(e,t)}`,X:(e,t)=>`${Wl.H(e,t)}:${Wl.M(e,t)}:${Wl.S(e,t)}`,p:(e,t)=>(t?e.getUTCHours():e.getHours())<12?"AM":"PM",Z:(e,t)=>{if(t)return"UTC";const n=e.toString().match(/[A-Z][A-Z][A-Z]/);return n?n[0]:""}};function Hl(e){const t=e.getFullYear(),n=new Date(t,0);return e.getTimezoneOffset()!==n.getTimezoneOffset()}function Kl(e,t,n){const i=parseInt(Wl.j(e,n),10),r=new Date(e.getFullYear(),0,1,12),s=(8-(n?r.getUTCDay():r.getDay())+t)%7;return`0${Math.floor((i-s)/7)+1}`.substr(-2)}function Zl(e="%c",t){const n="!"===e.substr(0,1),i=n?e.substr(1):e,r=new Date;return t&&r.setTime(1e3*t),"*t"===i?new qa({year:parseInt(Wl.Y(r,n),10),month:parseInt(Wl.m(r,n),10),day:parseInt(Wl.d(r,n),10),hour:parseInt(Wl.H(r,n),10),min:parseInt(Wl.M(r,n),10),sec:parseInt(Wl.S(r,n),10),wday:parseInt(Wl.w(r,n),10)+1,yday:parseInt(Wl.j(r,n),10),isdst:Hl(r)}):i.replace(/%[%YybBmUWjdaAwHIMScxXpZ]/g,e=>Wl[e[1]](r,n))}function Gl(e="C"){if("C"===e)return"C"}function Xl(e){let t=Math.round(Date.now()/1e3);if(!e)return t;const n=e.rawget("year"),i=e.rawget("month"),r=e.rawget("day"),s=e.rawget("hour")||12,a=e.rawget("min"),o=e.rawget("sec");return n&&(t+=31557600*n),i&&(t+=2629800*i),r&&(t+=86400*r),t+=3600*s,a&&(t+=60*a),o&&(t+=o),t}function Yl(e,t){return lo(e,"difftime",1)-lo(t,"difftime",2)}class ql{constructor(e,t){this.id=t||`co_${Date.now()}_${Math.random().toString(36).substr(2,6)}`,this.status="suspended",this.generator=null,this.resumeValues=[],this.yieldValues=[],this.error=null,this.parent=null;const n=this;this.generatorFn=function*(...t){try{const n=yield[],i=e(...t.length>0?t:n);if(i&&"function"==typeof i[Symbol.iterator]&&"string"!=typeof i)for(const e of i){yield[e]}return Array.isArray(i)?i:[i]}catch(Yc){throw n.error=Yc instanceof Error?Yc:new Error(String(Yc)),Yc}}}static create(e){if("function"!=typeof e)throw new Ya("bad argument #1 to create (function expected)");return new ql(e)}static resume(e,...t){if(!(e instanceof ql))throw new Ya("bad argument #1 to resume (coroutine expected)");if("dead"===e.status)return[!1,"cannot resume dead coroutine"];if("running"===e.status)return[!1,"cannot resume running coroutine"];try{const n=ql.currentCoroutine;n&&(n.status="normal",e.parent=n),e.status="running",ql.currentCoroutine=e,e.generator||(e.generator=e.generatorFn(...t),e.generator.next());const i=e.generator.next(t);return i.done?(e.status="dead",ql.currentCoroutine=n,n&&(n.status="running"),[!0,...i.value||[]]):(e.status="suspended",ql.currentCoroutine=n,n&&(n.status="running"),[!0,...i.value||[]])}catch(Yc){e.status="dead";return[!1,Yc instanceof Error?Yc.message:String(Yc)]}}static yield(...e){throw new Ya("yield called outside of coroutine")}static status(e){if(!(e instanceof ql))throw new Ya("bad argument #1 to status (coroutine expected)");return e.status}static running(){return[ql.currentCoroutine,null===ql.currentCoroutine]}static isyieldable(){return null!==ql.currentCoroutine}static wrap(e){if("function"!=typeof e)throw new Ya("bad argument #1 to wrap (function expected)");const t=ql.create(e);return function(...e){const n=ql.resume(t,...e);if(!1===n[0])throw new Ya(String(n[1]));if(2===n.length)return n[1];const i=new qa;for(let t=1;t<n.length;t++)i.set(t,n[t]);return i}}static close(e){if(!(e instanceof ql))throw new Ya("bad argument #1 to close (coroutine expected)");return"running"===e.status?[!1,"cannot close running coroutine"]:(e.status="dead",e.generator=null,[!0])}}ql.currentCoroutine=null;const Jl=new qa;Jl.set("create",ql.create),Jl.set("resume",ql.resume),Jl.set("yield",ql.yield),Jl.set("status",ql.status),Jl.set("running",ql.running),Jl.set("isyieldable",ql.isyieldable),Jl.set("wrap",ql.wrap),Jl.set("close",ql.close);let Ql=null,ec="",tc=0;const nc=new qa;const ic=new qa;ic.set("getinfo",function(e,t){const n=new qa;return"function"==typeof e?(n.set("what","Lua"),n.set("source","[JavaScript]"),n.set("short_src","[JavaScript]"),n.set("linedefined",0),n.set("lastlinedefined",0),n.set("nups",0),n.set("nparams",e.length),n.set("isvararg",!0),n.set("name",e.name||"anonymous"),n.set("namewhat",e.name?"function":""),n.set("func",e)):"number"==typeof e&&(n.set("what","main"),n.set("source","[main]"),n.set("short_src","[main]"),n.set("currentline",-1)),n}),ic.set("getlocal",function(e,t){return lo(e,"getlocal",1),lo(t,"getlocal",2),[void 0,void 0]}),ic.set("setlocal",function(e,t,n){lo(e,"setlocal",1),lo(t,"setlocal",2)}),ic.set("getupvalue",function(e,t){if("function"!=typeof e)throw new Ya("bad argument #1 to getupvalue (function expected)");return lo(t,"getupvalue",2),[void 0,void 0]}),ic.set("setupvalue",function(e,t,n){if("function"!=typeof e)throw new Ya("bad argument #1 to setupvalue (function expected)")}),ic.set("sethook",function(e,t,n){if(null==e)return Ql=null,ec="",void(tc=0);if("function"!=typeof e)throw new Ya("bad argument #1 to sethook (function expected)");Ql=e,ec=t?co(t,"sethook",2):"",tc=n?lo(n,"sethook",3):0}),ic.set("gethook",function(){return[Ql||void 0,ec,tc]}),ic.set("traceback",function(e,t){const n=void 0!==e?co(e,"traceback",1):"",i=void 0!==t?lo(t,"traceback",2):1,r=((new Error).stack||"").split("\n").slice(i+2);let s=n?n+"\n":"";s+="stack traceback:\n";for(let a=0;a<r.length&&a<20;a++){const e=r[a].trim();e&&(s+="\t"+e+"\n")}return s.trim()}),ic.set("getmetatable",function(e){if(e instanceof qa)return e.metatable}),ic.set("setmetatable",function(e,t){if(!(e instanceof qa))throw new Ya("bad argument #1 to setmetatable (table expected)");if(null!=t&&!(t instanceof qa))throw new Ya("bad argument #2 to setmetatable (nil or table expected)");return e.metatable=t||void 0,e}),ic.set("getregistry",function(){return nc}),ic.set("getuservalue",function(e){}),ic.set("setuservalue",function(e,t){return e}),ic.set("inspect",function e(t,n=0){const i=" ".repeat(n);if(null==t)return"nil";if("boolean"==typeof t)return t.toString();if("number"==typeof t)return t.toString();if("string"==typeof t)return`"${t}"`;if("function"==typeof t)return`function: ${t.name||"anonymous"}`;if(t instanceof qa){if(n>3)return"{...}";const r=[];for(const i in t.numValues)void 0!==t.numValues[i]&&r.push(`[${i}] = ${e(t.numValues[i],n+1)}`);for(const i in t.strValues)void 0!==t.strValues[i]&&r.push(`${i} = ${e(t.strValues[i],n+1)}`);return 0===r.length?"{}":r.length<=3&&0===n?`{ ${r.join(", ")} }`:`{\n${i} ${r.join(",\n"+i+" ")}\n${i}}`}return t instanceof ql?`coroutine: ${t.status}`:"userdata: "+typeof t});const rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function sc(e){let t="",n=e<0?1+(-e<<1):e<<1;do{let e=31&n;n>>>=5,n>0&&(e|=32),t+=rc[e]}while(n>0);return t}function ac(e,t){let n,i=0,r=0,s=t;do{const t=e.charAt(s++),a=rc.indexOf(t);if(-1===a)throw new Error(`Invalid VLQ character: ${t}`);n=!!(32&a),i+=(31&a)<<r,r+=5}while(n);const a=!(1&~i);return i>>>=1,{value:a?-i:i,rest:s}}class oc{constructor(e={}){this.sources=[],this.sourcesContent=[],this.names=[],this.mappings=[],this.file=e.file||"",this.sourceRoot=e.sourceRoot||""}addSource(e,t=null){let n=this.sources.indexOf(e);return-1===n&&(n=this.sources.length,this.sources.push(e),this.sourcesContent.push(t)),n}addName(e){let t=this.names.indexOf(e);return-1===t&&(t=this.names.length,this.names.push(e)),t}addMapping(e){const t=this.addSource(e.source),n={generatedLine:e.generated.line,generatedColumn:e.generated.column,sourceLine:e.original.line,sourceColumn:e.original.column,sourceIndex:t};e.name&&(n.nameIndex=this.addName(e.name)),this.mappings.push(n)}encodeMappings(){const e=[...this.mappings].sort((e,t)=>e.generatedLine!==t.generatedLine?e.generatedLine-t.generatedLine:e.generatedColumn-t.generatedColumn);let t="",n=1,i=0,r=0,s=0,a=0,o=0;for(let l=0;l<e.length;l++){const c=e[l];for(;n<c.generatedLine;)t+=";",n++,i=0;l>0&&e[l-1].generatedLine===c.generatedLine&&(t+=","),t+=sc(c.generatedColumn-i),i=c.generatedColumn,t+=sc(c.sourceIndex-r),r=c.sourceIndex,t+=sc(c.sourceLine-s),s=c.sourceLine,t+=sc(c.sourceColumn-a),a=c.sourceColumn,void 0!==c.nameIndex&&(t+=sc(c.nameIndex-o),o=c.nameIndex)}return t}toJSON(){return{version:3,file:this.file,sourceRoot:this.sourceRoot,sources:this.sources,sourcesContent:this.sourcesContent,names:this.names,mappings:this.encodeMappings()}}toString(){return JSON.stringify(this.toJSON())}toDataURL(){const e=this.toString();return`data:application/json;charset=utf-8;base64,${"undefined"!=typeof btoa?btoa(e):Buffer.from(e).toString("base64")}`}toComment(){return"//# sourceMappingURL="+this.toDataURL()}}class lc{constructor(e){this.decodedMappings=[],this.sourceMap="string"==typeof e?JSON.parse(e):e,this.decodeMappings()}decodeMappings(){const{mappings:e}=this.sourceMap;let t=1,n=0,i=0,r=0,s=0,a=0;const o=e.split(";");for(const l of o){if(0===l.length){t++,n=0;continue}const e=l.split(",");for(const o of e){if(0===o.length)continue;let e=0;const{value:l,rest:c}=ac(o,e);if(e=c,n+=l,e<o.length){const{value:l,rest:c}=ac(o,e);e=c,i+=l;const{value:h,rest:u}=ac(o,e);e=u,r+=h;const{value:d,rest:f}=ac(o,e);e=f,s+=d;const p={generatedLine:t,generatedColumn:n,sourceIndex:i,sourceLine:r,sourceColumn:s};if(e<o.length){const{value:t}=ac(o,e);a+=t,p.nameIndex=a}this.decodedMappings.push(p)}}t++,n=0}}originalPositionFor(e){const t=this.decodedMappings.find(t=>t.generatedLine===e.line&&t.generatedColumn<=e.column);return t?{source:this.sourceMap.sources[t.sourceIndex]||null,line:t.sourceLine,column:t.sourceColumn,name:void 0!==t.nameIndex?this.sourceMap.names[t.nameIndex]:null}:{source:null,line:null,column:null,name:null}}generatedPositionFor(e){const t=this.sourceMap.sources.indexOf(e.source);if(-1===t)return{line:null,column:null};const n=this.decodedMappings.find(n=>n.sourceIndex===t&&n.sourceLine===e.line&&n.sourceColumn<=e.column);return n?{line:n.generatedLine,column:n.generatedColumn}:{line:null,column:null}}get sources(){return this.sourceMap.sources}sourceContentFor(e){const t=this.sourceMap.sources.indexOf(e);return-1===t?null:this.sourceMap.sourcesContent[t]||null}}const cc=new qa;cc.rawset("generator",(e,t)=>{const n=new oc({file:e,sourceRoot:t}),i=new qa;return i.rawset("addSource",(e,t)=>n.addSource(e,t||null)),i.rawset("addName",e=>n.addName(e)),i.rawset("addMapping",(e,t,i,r,s,a)=>{n.addMapping({generated:{line:e,column:t},source:i,original:{line:r,column:s},name:a})}),i.rawset("toJSON",()=>{const e=n.toJSON(),t=new qa;t.rawset("version",e.version),t.rawset("file",e.file),t.rawset("sourceRoot",e.sourceRoot),t.rawset("mappings",e.mappings);const i=new qa;e.sources.forEach((e,t)=>i.rawset(t+1,e)),t.rawset("sources",i);const r=new qa;return e.names.forEach((e,t)=>r.rawset(t+1,e)),t.rawset("names",r),t}),i.rawset("toString",()=>n.toString()),i.rawset("toDataURL",()=>n.toDataURL()),i.rawset("toComment",()=>n.toComment()),i}),cc.rawset("consumer",e=>{const t=new lc(e),n=new qa;n.rawset("originalPositionFor",(e,n)=>{const i=t.originalPositionFor({line:e,column:n}),r=new qa;return r.rawset("source",i.source),r.rawset("line",i.line),r.rawset("column",i.column),r.rawset("name",i.name),r}),n.rawset("generatedPositionFor",(e,n,i)=>{const r=t.generatedPositionFor({source:e,line:n,column:i}),s=new qa;return s.rawset("line",r.line),s.rawset("column",r.column),s}),n.rawset("sourceContentFor",e=>t.sourceContentFor(e));const i=new qa;return t.sources.forEach((e,t)=>i.rawset(t+1,e)),n.rawset("sources",i),n}),cc.rawset("encodeVLQ",sc),cc.rawset("decodeVLQ",(e,t)=>{const{value:n,rest:i}=ac(e,t||0),r=new qa;return r.rawset("value",n),r.rawset("rest",i),r});class hc{constructor(e,t,n="r"){this.name=e,this.content=t,this.mode=n,this.position=0,this.closed=!1,this.lineData=t.split("\n"),this.lineIndex=0}read(e="*l"){if(this.closed)throw new Ya("attempt to use a closed file");const t=ao(e);switch(t){case"*a":case"a":const e=this.content.slice(this.position);return this.position=this.content.length,e||void 0;case"*l":case"l":if(this.lineIndex>=this.lineData.length)return;const n=this.lineData[this.lineIndex++];return this.position+=n.length+1,n;case"*L":case"L":if(this.lineIndex>=this.lineData.length)return;const i=this.lineData[this.lineIndex++];return this.position+=i.length+1,i+"\n";case"*n":case"n":const r=this.content.slice(this.position).match(/^\s*[+-]?[\d.]+/);if(!r)return;return this.position+=r[0].length,parseFloat(r[0]);default:const s=parseInt(t);if(isNaN(s))throw new Ya(`bad argument #1 to 'read' (invalid format '${t}')`);if(s<=0)return"";const a=this.content.slice(this.position,this.position+s);return this.position+=a.length,a||void 0}}write(...e){if(this.closed)return[void 0,"attempt to use a closed file"];if(!this.mode.includes("w")&&!this.mode.includes("a"))return[void 0,"Bad file descriptor"];for(const t of e){const e=ao(t);if(this.mode.includes("a"))this.content+=e,this.position=this.content.length;else{const t=this.content.slice(0,this.position),n=this.content.slice(this.position+e.length);this.content=t+e+n,this.position+=e.length}}return this.lineData=this.content.split("\n"),[this]}seek(e="cur",t=0){if(this.closed)return[void 0,"attempt to use a closed file"];const n="number"==typeof t?t:0,i=ao(e);switch(i){case"set":this.position=n;break;case"cur":this.position+=n;break;case"end":this.position=this.content.length+n;break;default:return[void 0,`bad argument #1 to 'seek' (invalid option '${i}')`]}this.position=Math.max(0,Math.min(this.position,this.content.length));let r=0;this.lineIndex=0;for(const s of this.lineData){if(r>=this.position)break;r+=s.length+1,this.lineIndex++}return this.position}flush(){return!0}close(){return this.closed=!0,!0}isClosed(){return this.closed}getContent(){return this.content}getName(){return this.name}getLineIterator(){const e=this;return function(){return e.read("*l")}}}const uc=(e,...t)=>{if(e instanceof Function)return fo(e(...t));const n=e instanceof qa&&e.getMetaMethod("__call");if(n)return fo(n(e,...t));throw new Ya("attempt to call an uncallable type")},dc=new qa;dc.metatable=rl;const fc=(e,t)=>{if(e instanceof qa)return e.get(t);if("string"==typeof e)return dc.get(t);throw new Ya("no table or metatable found for given type")},pc=(e,t,n)=>{const i=new Function("__lua",t),r=new mo(e.strValues).extend();n&&r.setVarargs([n]);const s=i({globalScope:r,...El,Table:qa,call:uc,get:fc});return void 0===s?[void 0]:s};const gc=Object.freeze(Object.defineProperty({__proto__:null,LuaError:Ya,Table:qa,createEnv:function(e={}){const t={PIXOSCRIPT_PATH:"./?.pxs",stdin:"",stdout:console.log,...e},n=function(e,t){function n(e,n,i,s){let a,o="";if(e instanceof Function){let t=" ";for(;""!==t&&void 0!==t;)o+=t,t=e()[0]}else o=co(e,"load",1);try{a=Ko(o)}catch(Yc){return[void 0,Yc.message]}return()=>t(s||r,a)}function i(t,i,r){const s=void 0===t?e.stdin:co(t,"loadfile",1);if(!e.fileExists)throw new Ya("loadfile requires the config.fileExists function");if(!e.fileExists(s))return[void 0,"file not found"];if(!e.loadFile)throw new Ya("loadfile requires the config.loadFile function");return n(e.loadFile(s),0,0,r)}const r=new qa({_VERSION:"Lua 5.3",assert:al,dofile:function(e){const t=i(e);if(Array.isArray(t)&&void 0===t[0])throw new Ya(t[1]);return t()},collectgarbage:ol,error:ll,getmetatable:cl,ipairs:hl,load:n,loadfile:i,next:ul,pairs:dl,pcall:fl,print:function(...t){const n=t.map(e=>to(e)).join("\t");e.stdout(n)},rawequal:pl,rawget:gl,rawlen:ml,rawset:yl,select:bl,setmetatable:vl,tonumber:wl,tostring:to,type:eo,xpcall:xl});return r}(t,pc),{libPackage:i,_require:r}=((e,t)=>{const n=t.LUA_PATH,i=["/",";","?","!","-"].join("\n"),r=new qa,s=new qa,a=(e,n,i,r)=>{if(!t.fileExists)throw new Ya("package.searchpath requires the config.fileExists function");let s=co(e,"searchpath",1);const a=co(n,"searchpath",2),o=void 0===i?".":co(i,"searchpath",3),l=void 0===r?"/":co(r,"searchpath",4);s=s.replace(o,l);const c=a.split(";").map(e=>e.replace("?",s));for(const h of c)if(t.fileExists(h))return h;return[void 0,`The following files don't exist: ${c.join(" ")}`]},o=new qa([e=>{const t=s.rawget(e);return void 0===t?[void 0]:[t]},n=>{const i=a(n,l.rawget("path"));if(Array.isArray(i)&&void 0===i[0])return[i[1]];if(!t.loadFile)throw new Ya("package.searchers requires the config.loadFile function");return[(n,i)=>e(t.loadFile(i),n),i]}]),l=new qa({path:n,config:i,loaded:r,preload:s,searchers:o,searchpath:a});return{libPackage:l,_require:function(e){const t=co(e,"require",1),n=r.rawget(t);if(n)return n;const i=o.numValues.filter(e=>!!e);for(const s of i){const e=s(t);if(void 0!==e[0]&&"string"!=typeof e[0]){const n=(0,e[0])(t,e[1]),i=void 0===n||n;return r.rawset(t,i),i}}throw new Ya(`Module '${t}' not found!`)}}})((e,t)=>pc(n,Ko(e),t)[0],t),s=i.get("loaded"),a=(e,t)=>{n.rawset(e,t),s.rawset(e,t)};a("_G",n),a("package",i),a("math",Fl),a("table",Nl),a("string",il),a("os",(e=>new qa({date:Zl,exit:function(t){if(!e.osExit)throw new Ya("os.exit requires the config.osExit function");let n=0;"boolean"==typeof t&&!1===t?n=1:"number"==typeof t&&(n=t),e.osExit(n)},setlocale:Gl,time:Xl,difftime:Yl}))(t)),a("coroutine",Jl),a("debug",ic),a("sourcemap",cc),a("io",function(e){const t=new qa,n=new Map;let i=new hc("stdin",e.stdin||"","r"),r={write:(...t)=>{const n=t.map(e=>ao(e)).join("");e.stdout&&e.stdout(n)}};function s(t,i="r"){const r=co(t,"open",1),s=co(i,"open",2);let a="";if(n.has(r))a=n.get(r);else if(e.loadFile&&e.fileExists){if(e.fileExists(r))a=e.loadFile(r);else if(!s.includes("w")&&!s.includes("a"))return[void 0,`${r}: No such file or directory`,2]}else if(!s.includes("w")&&!s.includes("a"))return[void 0,`${r}: No such file or directory`,2];const o=new hc(r,a,s),l=new qa;return l.rawset("read",(...e)=>o.read(e[0])),l.rawset("write",(...e)=>o.write(...e)),l.rawset("seek",(e,t)=>o.seek(e,t)),l.rawset("flush",()=>o.flush()),l.rawset("close",()=>((s.includes("w")||s.includes("a"))&&n.set(r,o.getContent()),o.close())),l.rawset("lines",()=>o.getLineIterator()),[l]}return t.rawset("open",s),t.rawset("close",e=>{if(e){const t=e.get("close");if(t)return t()}return!0}),t.rawset("read",(...e)=>0===e.length?i.read("*l"):i.read(e[0])),t.rawset("write",(...e)=>(r.write(...e),!0)),t.rawset("input",e=>{if(void 0===e){const e=new qa;return e.rawset("read",(...e)=>i.read(e[0])),e.rawset("lines",()=>i.getLineIterator()),e}if("string"==typeof e){const[t,n]=s(e,"r");if(!t)throw new Ya(n||"cannot open file");i=new hc(e,"","r")}}),t.rawset("output",e=>{if(void 0===e){const e=new qa;return e.rawset("write",(...t)=>(r.write(...t),e)),e}if("string"==typeof e){const[t,n]=s(e,"w");if(!t)throw new Ya(n||"cannot open file")}}),t.rawset("flush",()=>!0),t.rawset("lines",(e,...t)=>{if(void 0===e)return i.getLineIterator();const n=co(e,"lines",1),[r,a]=s(n,"r");if(!r)throw new Ya(a||`cannot open file '${n}'`);const o=r.get("read"),l=r.get("close"),c=t.length>0?t[0]:"*l";return function(){const e=o(c);if(void 0!==e)return e;l()}}),t.rawset("type",e=>{if(e instanceof qa)return e.get("close")?"file":void 0}),t.rawset("tmpfile",()=>{const e=`tmp_${Date.now()}_${Math.random().toString(36).slice(2)}`;return n.set(e,""),s(e,"w+")[0]}),t.rawset("popen",()=>{throw new Ya("io.popen is not supported for security reasons")}),t}(t)),n.rawset("require",r);const o=e=>{const t=Ko(e);return{exec:()=>pc(n,t)[0]}};return{parse:o,parseFile:e=>{if(!t.fileExists)throw new Ya("parseFile requires the config.fileExists function");if(!t.loadFile)throw new Ya("parseFile requires the config.loadFile function");if(!t.fileExists(e))throw new Ya("file not found");return o(t.loadFile(e))},loadLib:a}},utils:go},Symbol.toStringTag,{value:"Module"}));class mc{constructor(e){i(this,"setScope",e=>{this.scope=e}),i(this,"getScope",()=>this.scope),i(this,"registerScript",(e,t)=>{this._scriptCache.set(e,t),this._scriptCache.set(e+".pxs",t)}),i(this,"createEnv",()=>{const e={PIXOSCRIPT_PATH:"./?.pxs;./?/init.pxs",fileExists:e=>{const t=e.replace(/^\.\//,"");return this._scriptCache.has(t)},loadFile:e=>{const t=e.replace(/^\.\//,""),n=this._scriptCache.get(t);if(!n)throw new Error(`Script not found: ${e}`);return n}};return this.env=this.pixoscript.createEnv(e),this.env}),i(this,"initLibrary",()=>{this.env||this.createEnv(),this.library=this.pixosLib.getLibrary(this.engine,this.scope),this.env.loadLib("pixos",this.library)}),i(this,"run",async e=>(this.env||this.createEnv(),this.library||this.initLibrary(),this.env.parse(e).exec())),this.engine=e,this.pixoscript=gc,this.pixosLib=new Xa(this.pixoscript),this.scope={},this.env=null,this.library=null,this._scriptCache=new Map}}class yc extends Za{constructor(e,t,n){super(e),i(this,"loadJson",async()=>{this.json.extends&&(await Promise.all(this.json.extends.map(async e=>{let t=JSON.parse(await this.zip.file("sprites/"+e+".json").async("string"));Object.assign(this.json,t)})),this.json.extends=null),this.update(this.json),this.src=this.json.src,this.portraitSrc=this.json.portraitSrc,this.sheetSize=this.json.sheetSize,this.tileSize=this.json.tileSize,this.state=this.json.state??"intro",this.frames=this.json.frames,this.hotspotOffset=new ot(...this.json.hotspotOffset),this.drawOffset={},Object.keys(this.json.drawOffset).forEach(e=>{this.drawOffset[e]=new ot(...this.json.drawOffset[e])}),this.bindCamera=this.json.bindCamera,this.enableSpeech=this.json.enableSpeech}),i(this,"onSelect",async(e,t)=>{if(this.selectTrigger){if("interact"===this.selectTrigger)return await this.interact(this);try{Ma("DynamicAvatar","onSelect trigger",this.selectTrigger);let n=this.zip.file(`triggers/${this.selectTrigger}.pxs`);if(n||(n=this.zip.file(`triggers/${this.selectTrigger}.pxs`)),!n)throw new Error("No Lua Script Found");let i=await n.async("string");Ma("DynamicAvatar","trigger lua statement",i);let r=new mc(this.engine);return r.setScope({_this:e,zone:t.zone,subject:t}),r.initLibrary(),r.run('print("hello world lua")'),await r.run(i)}catch(Yc){Ma("DynamicAvatar","no lua script found",Yc.message)}}}),this.json=t,this.zip=n}}class bc extends Ka{constructor(e,t,n){super(e),i(this,"loadJson",async()=>{this.json.extends&&(await Promise.all(this.json.extends.map(async e=>{let t=JSON.parse(await this.zip.file("sprites/"+e+".json").async("string"));Ma("DynamicSprite","extending",{old:this.json,new:t}),this.json=Vs(this.json,t)})),this.json.extends=null),this.update(this.json),this.src=this.json.src,this.portraitSrc=this.json.portraitSrc,this.sheetSize=this.json.sheetSize,this.tileSize=this.json.tileSize,this.isLit=this.json.isLit,this.direction=this.json.direction,this.attenuation=this.json.attenuation,this.density=this.json.density,this.lightColor=this.json.lightColor,this.state=this.json.state??"intro",this.frames=this.json.frames,this.drawOffset={},Object.keys(this.json.drawOffset).forEach(e=>{this.drawOffset[e]=new ot(...this.json.drawOffset[e])}),this.hotspotOffset=new ot(...this.json.hotspotOffset),this.bindCamera=this.json.bindCamera,this.enableSpeech=this.json.enableSpeech}),i(this,"interact",async(e,t=()=>{})=>{let n=null,i=this.json.states??[],r={};await Promise.all(i.map(async n=>{let i=await this.loadActionDynamically(n,e,t);for(const e of i)Ma("DynamicSprite","loading action",e);Ma("DynamicSprite","switching state",n.name),r[n.name]={next:n.next,actions:i}})),Ma("DynamicSprite","loading stateMachine",r),n=[];for(const s of r[this.state].actions)n.push(await s(this,e,t));return this.state=r[this.state].next,t&&t(!1),n}),i(this,"loadActionDynamically",async(e,t,n)=>(Ma("DynamicSprite","loadActionDynamically",{sprite:null==t?void 0:t.id,state:null==e?void 0:e.name}),await Promise.all(e.actions.map(async e=>{Ma("DynamicSprite","preping actions",e);let i=e.callback&&""!==e.callback?await this.zip.file("callbacks/"+e.callback+".pxs").async("string"):'print("no callback")',r=()=>{Ma("DynamicSprite","calling callback");let e=new mc(this.engine);return e.setScope({_this:this,zone:t.zone,subject:t,finish:n}),e.initLibrary(),e.run('print("hello world lua - sprite callback")'),e.run(i)};switch(e.type){case"dialogue":return Ma("DynamicSprite","preparing dialogue action"),async(t,n,i)=>{Ma("DynamicSprite","executing dialogue");let s=new t.ActionLoader(t.engine,"dialogue",[JSON.stringify(e.dialogue),!1,{autoclose:!0,onClose:()=>i(!0)}],t,r);Ma("DynamicSprite","action to load",s),t.addAction(s)};case"animate":return Ma("DynamicSprite","preparing animate action"),async(t,n,i)=>{Ma("DynamicSprite","executing animate",{action:e});let s=new t.ActionLoader(t.engine,"animate",[...e.animate,()=>i(!0)],t,r);Ma("DynamicSprite","action to load",s),t.addAction(s)};default:return async(t,n,i)=>{Ma("DynamicSprite","no action found for type",e.type)}}})))),i(this,"onSelect",async(e,t)=>{if(this.selectTrigger){if("interact"===this.selectTrigger)return await this.interact(t,()=>{});try{Ma("DynamicSprite","onSelect trigger",this.selectTrigger);let e=this.zip.file(`triggers/${this.selectTrigger}.pxs`);if(e||(e=this.zip.file(`triggers/${this.selectTrigger}.pxs`)),!e)throw new Error("No Lua Script Found");let n=await e.async("string");Ma("DynamicSprite","trigger lua statement",n);let i=new mc(this.engine);return i.setScope({_this:this,zone:t.zone,subject:t}),i.initLibrary(),i.run('print("hello world lua")'),await i.run(n)}catch(Yc){Ma("DynamicSprite","no lua script found",Yc.message)}}}),i(this,"onStep",async(e,t)=>{if(this.stepTrigger)try{Ma("DynamicSprite","onStep trigger",this.stepTrigger);let e=this.zip.file(`triggers/${this.stepTrigger}.pxs`);if(e||(e=this.zip.file(`triggers/${this.stepTrigger}.pxs`)),!e)throw new Error("No Lua Script Found");let n=await e.async("string");Ma("DynamicSprite","trigger lua statement",n);let i=new mc(this.engine);return i.setScope({_this:this,zone:t.zone,subject:t}),i.initLibrary(),i.run('print("hello world lua")'),await i.run(n)}catch(Yc){Ma("DynamicSprite","no lua script found",Yc.message)}}),this.engine=e,this.json=t,this.zip=n,this.ActionLoader=Ac}}class vc extends bc{constructor(e,t,n){super(e,t,n),i(this,"init",()=>{this.json.randomJitter?this.triggerTime=this.json.triggerTime+Math.floor(Math.random()*this.json.randomJitter):this.triggerTime=this.json.triggerTime}),i(this,"tick",e=>{0!=this.lastTime?(this.accumTime+=e-this.lastTime,this.accumTime<this.frameTime||0==this.animFrame&&this.accumTime<this.triggerTime||(5==this.animFrame?(this.setFrame(0),this.triggerTime=1e3+Math.floor(4e3*Math.random())):(this.setFrame(this.animFrame+1),this.accumTime=0,this.lastTime=e))):this.lastTime=e})}}class wc extends bc{constructor(e,t,n){super(e,t,n),i(this,"init",()=>{this.json.randomJitter?this.triggerTime=this.json.triggerTime+Math.floor(Math.random()*this.json.randomJitter):this.triggerTime=this.json.triggerTime}),i(this,"tick",e=>{0!=this.lastTime?(this.accumTime+=e-this.lastTime,this.accumTime<this.frameTime||0==this.animFrame&&this.accumTime<this.triggerTime||(4==this.animFrame?(this.setFrame(0),this.triggerTime=2e3+Math.floor(4e3*Math.random())):(this.setFrame(this.animFrame+1),this.accumTime=0,this.lastTime=e))):this.lastTime=e}),i(this,"draw",e=>{if(!this.loaded)return;const t=e.renderManager,n=t.isPickerPass;t.mvPushMatrix(),xs(t.uModelMat,t.uModelMat,this.pos.toArray()),xs(t.uModelMat,t.uModelMat,(this.drawOffset[t.camera.cameraDir]??this.drawOffset.N).toArray()),_s(t.uModelMat,t.uModelMat,ct(90),[1,0,0]),t.bindBuffer(this.vertexPosBuf,t.shaderProgram.aVertexPosition),t.bindBuffer(this.vertexTexBuf,t.shaderProgram.aTextureCoord),this.texture.attach(),n?t.effectPrograms.picker.setMatrixUniforms({id:this.getPickingId()}):t.shaderProgram.setMatrixUniforms({id:this.getPickingId()}),e.gl.drawArrays(e.gl.TRIANGLES,0,this.vertexPosBuf.numItems),t.mvPopMatrix()})}}class xc{constructor(e){this.engine=e,this.definitions=[],this.instances={}}async loadFromZip(e,t,n){Ma("Loader","loading sprite from zip: "+t+" for "+n);let i=arguments[3],r=arguments[4];this.instances[t]||(this.instances[t]=[]);let s="";try{s=JSON.parse(await e.file(`sprites/${t}.json`).async("string"))}catch(Yc){console.error(Yc)}let a={};switch(s.type){case"animated-sprite":a=new vc(this.engine,s,e),await a.loadJson();break;case"animated-tile":a=new wc(this.engine,s,e),await a.loadJson();break;case"avatar":a=new yc(this.engine,s,e),await a.loadJson();break;default:a=new bc(this.engine,s,e),await a.loadJson()}return a.templateLoaded=!0,this.instances[t].forEach(async function(e){e.afterLoad&&await e.afterLoad(e.instance)}),r&&await r(a),i&&(a.templateLoaded?await i(a):this.instances[t].push({instance:a,afterLoad:i})),a}}const _c=e=>"/pixospritz/maps/"+e+"/map.json";class kc extends Ys{constructor(e){super(),i(this,"onLoad",e=>{var t,n;if(this.loaded)return;if(this.zone=e.zone,e.id&&(this.id=e.id),e.pos&&(this.pos=e.pos,this.pos&&(null===this.pos.z||void 0===this.pos.z)))try{const e=this.pos.x+((null==(t=this.hotspotOffset)?void 0:t.x)??0),i=this.pos.y+((null==(n=this.hotspotOffset)?void 0:n.y)??0),r=this.zone.getHeight(e,i);this.pos.z="number"==typeof r?r:0}catch(u){console.warn("Error computing object height from zone",u),this.pos.z=0}e.isLit&&(this.isLit=e.isLit),e.lightColor&&(this.lightColor=e.lightColor),e.attenuation&&(this.attenuation=e.attenuation),e.direction&&(this.direction=e.direction),e.rotation&&(this.rotation=e.rotation),e.facing&&0!==e.facing&&(this.facing=e.facing),e.zones&&null!==e.zones&&(this.zones=e.zones);let i,r,s,a=e.mesh,o=null,l=null,c=null;for(let d=0;d<a.vertices.length;d+=3){let e=a.vertices.slice(d,d+3);(null==i||e[0]>i)&&(i=e[0]),(null==o||e[0]<o)&&(o=e[0]),(null==r||e[1]>r)&&(r=e[1]),(null==l||e[1]<l)&&(l=e[1]),(null==s||e[2]>s)&&(s=e[2]),(null==c||e[2]<c)&&(c=e[2])}let h=new ot(i-o,s-c,r-l);this.size=h,this.scale=new ot(1/Math.max(h.x,h.z),1/Math.max(h.x,h.z),1/Math.max(h.x,h.z)),e.useScale&&(this.scale=e.useScale),this.drawOffset=new ot(.5,.5,0),this.mesh=a,this.engine.resourceManager.objHelper.initLegacyBuffers(this.mesh),this.enableSpeech&&(this.speech=this.engine.resourceManager.loadSpeech(this.id,this.engine.mipmap),this.speech.runWhenLoaded(this.onTilesetOrTextureLoaded),this.speechTexBuf=this.engine.renderManager.createBuffer(this.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),this.portraitSrc&&(this.portrait=this.engine.resourceManager.loadTexture(this.portraitSrc),this.portrait.runWhenLoaded(this.onTilesetOrTextureLoaded)),this.isLit&&(this.lightIndex=this.engine.renderManager.lightManager.addLight(this.id,this.pos.toArray(),this.lightColor,[.01,.01,.01])),this.zone.tileset.runWhenDefinitionLoaded(this.onTilesetDefinitionLoaded)}),i(this,"onLoadFromZip",async(e,t)=>{var n,i;if(this.loaded)return;if(this.zone=e.zone,e.id&&(this.id=e.id),e.pos&&(this.pos=e.pos,this.pos&&(null===this.pos.z||void 0===this.pos.z)))try{const e=this.pos.x+((null==(n=this.hotspotOffset)?void 0:n.x)??0),t=this.pos.y+((null==(i=this.hotspotOffset)?void 0:i.y)??0),r=this.zone.getHeight(e,t);this.pos.z="number"==typeof r?r:0}catch(d){console.warn("Error computing object height from zone",d),this.pos.z=0}e.isLit&&(this.isLit=e.isLit),e.lightColor&&(this.lightColor=e.lightColor),e.attenuation&&(this.attenuation=e.attenuation),e.density&&(this.density=e.density),e.scatteringCoefficients&&(this.scatteringCoefficients=e.scatteringCoefficients),e.direction&&(this.direction=e.direction),e.rotation&&(this.rotation=e.rotation),e.facing&&0!==e.facing&&(this.facing=e.facing),e.zones&&null!==e.zones&&(this.zones=e.zones);let r,s,a,o=e.mesh,l=null,c=null,h=null;for(let f=0;f<o.vertices.length;f+=3){let e=o.vertices.slice(f,f+3);(null==r||e[0]>r)&&(r=e[0]),(null==l||e[0]<l)&&(l=e[0]),(null==s||e[1]>s)&&(s=e[1]),(null==c||e[1]<c)&&(c=e[1]),(null==a||e[2]>a)&&(a=e[2]),(null==h||e[2]<h)&&(h=e[2])}let u=new ot(r-l,a-h,s-c);this.size=u,this.scale=new ot(1/Math.max(u.x,u.z),1/Math.max(u.x,u.z),1/Math.max(u.x,u.z)),e.useScale&&(this.scale=e.useScale),this.drawOffset=new ot(.5,.5,0),this.mesh=o,this.engine.resourceManager.objHelper.initLegacyBuffers(this.mesh),this.enableSpeech&&(this.speech=this.engine.resourceManager.loadSpeech(this.id,this.engine.mipmap),this.speech.runWhenLoaded(this.onTilesetOrTextureLoaded),this.speechTexBuf=this.engine.renderManager.createBuffer(this.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),this.portraitSrc&&(this.portrait=await this.engine.resourceManager.loadTextureFromZip(this.portraitSrc,t),this.portrait.runWhenLoaded(this.onTilesetOrTextureLoaded)),this.isLit&&(this.lightIndex=this.engine.renderManager.lightManager.addLight(this.id,this.pos.toArray(),this.lightColor,this.attenuation,this.direction,this.density,this.scatteringCoefficients,!0)),this.zone.tileset.runWhenDefinitionLoaded(this.onTilesetDefinitionLoaded)}),i(this,"onTilesetDefinitionLoaded",()=>{this.zone.tileset.runWhenLoaded(this.onTilesetOrTextureLoaded)}),i(this,"onTilesetOrTextureLoaded",()=>{!this||this.loaded||this.enableSpeech&&this.speech&&!this.speech.loaded||this.portrait&&!this.portrait.loaded||(this.init(),this.enableSpeech&&this.speech&&this.speech.clearHud&&(this.speech.clearHud(),this.speech.writeText(this.id),this.speech.loadImage()),this.loaded=!0,this.onLoadActions.run())}),i(this,"getSpeechBubbleTexture",()=>[[1,1],[0,1],[0,0],[1,1],[0,0],[1,0]].flat(3)),i(this,"getSpeechBubbleVertices",()=>[new ot(...[2,0,4]).toArray(),new ot(...[0,0,4]).toArray(),new ot(...[0,0,2]).toArray(),new ot(...[2,0,4]).toArray(),new ot(...[0,0,2]).toArray(),new ot(...[2,0,2]).toArray()].flat(3)),i(this,"attach",e=>{let{gl:t}=this.engine;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.uniform1i(this.engine.renderManager.shaderProgram.diffuseMapUniform,0)}),i(this,"drawTexturedObj",()=>{let{engine:e,mesh:t}=this;const n=e.renderManager,i=n.isPickerPass;t.indicesPerMaterial.length>=1&&Object.keys(t.materialsByIndex).length>0?t.indicesPerMaterial.forEach((r,s)=>{var a,o;if(n.bindBuffer(t.vertexBuffer,n.shaderProgram.aVertexPosition),n.bindBuffer(t.textureBuffer,n.shaderProgram.aTextureCoord),n.bindBuffer(t.normalBuffer,n.shaderProgram.aVertexNormal),!i){e.gl.uniform3fv(n.shaderProgram.uDiffuse,t.materialsByIndex[s].diffuse),e.gl.uniform1f(n.shaderProgram.uSpecularExponent,t.materialsByIndex[s].specularExponent);(null==(o=null==(a=t.materialsByIndex[s])?void 0:a.mapDiffuse)?void 0:o.glTexture)?(this.attach(t.materialsByIndex[s].mapDiffuse.glTexture),e.gl.uniform1f(n.shaderProgram.useDiffuse,1)):e.gl.uniform1f(n.shaderProgram.useDiffuse,0),e.gl.uniform3fv(n.shaderProgram.uSpecular,t.materialsByIndex[s].specular),e.gl.uniform1f(n.shaderProgram.uSpecularExponent,t.materialsByIndex[s].specularExponent)}let l=Fs(e.gl,e.gl.ELEMENT_ARRAY_BUFFER,r,1);e.gl.bindBuffer(e.gl.ELEMENT_ARRAY_BUFFER,l),i?n.effectPrograms.picker.setMatrixUniforms({scale:this.scale,id:this.getPickingId(),sampler:0}):n.shaderProgram.setMatrixUniforms({isSelected:this.isSelected,colorMultiplier:8&this.engine.frameCount?[1,0,0,1]:[1,1,0,1],scale:this.scale,sampler:0}),e.gl.drawElements(e.gl.TRIANGLES,l.numItems,e.gl.UNSIGNED_SHORT,0)}):(n.bindBuffer(t.vertexBuffer,n.shaderProgram.aVertexPosition),n.bindBuffer(t.normalBuffer,n.shaderProgram.aVertexNormal),n.bindBuffer(t.textureBuffer,n.shaderProgram.aTextureCoord),e.gl.bindBuffer(e.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),i||(e.gl.uniform3fv(n.shaderProgram.uDiffuse,[.6,.3,.6]),e.gl.uniform3fv(n.shaderProgram.uSpecular,[.1,.1,.2]),e.gl.uniform1f(n.shaderProgram.uSpecularExponent,2)),i?n.effectPrograms.picker.setMatrixUniforms({scale:this.scale,id:this.getPickingId(),sampler:0}):n.shaderProgram.setMatrixUniforms({isSelected:this.isSelected,colorMultiplier:8&this.engine.frameCount?[1,0,0,1]:[1,1,0,1],scale:this.scale,sampler:0}),e.gl.drawElements(e.gl.TRIANGLES,t.indexBuffer.numItems,e.gl.UNSIGNED_SHORT,0))}),i(this,"getPickingId",()=>[(255&this.objId)/255,(this.objId>>8&255)/255,(this.objId>>16&255)/255,255]),i(this,"drawObj",()=>{let{engine:e,mesh:t}=this;const n=e.renderManager,i=n.isPickerPass;e.gl.disableVertexAttribArray(n.shaderProgram.aTextureCoord),n.bindBuffer(t.vertexBuffer,n.shaderProgram.aVertexPosition),n.bindBuffer(t.normalBuffer,n.shaderProgram.aVertexNormal),e.gl.bindBuffer(e.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),i?n.effectPrograms.picker.setMatrixUniforms({scale:this.scale,id:this.getPickingId(),sampler:1}):n.shaderProgram.setMatrixUniforms({scale:this.scale,sampler:1}),e.gl.drawElements(e.gl.TRIANGLES,t.indexBuffer.numItems,e.gl.UNSIGNED_SHORT,0)}),i(this,"draw",()=>{if(!this.loaded)return;this.engine&&this.engine.renderManager&&this.engine.renderManager.debug&&this.engine.renderManager.debug.objectsDrawn++;let{engine:e,mesh:t}=this;if(e.gl.enableVertexAttribArray(e.renderManager.shaderProgram.aVertexNormal),e.gl.enableVertexAttribArray(e.renderManager.shaderProgram.aTextureCoord),e.renderManager.mvPushMatrix(),xs(this.engine.renderManager.uModelMat,this.engine.renderManager.uModelMat,this.drawOffset.toArray()),xs(this.engine.renderManager.uModelMat,this.engine.renderManager.uModelMat,this.pos.toArray()),_s(this.engine.renderManager.uModelMat,this.engine.renderManager.uModelMat,ct(90),[1,0,0]),this.rotation&&this.rotation.toArray){let e=Math.max(...this.rotation.toArray());e>0&&_s(this.engine.renderManager.uModelMat,this.engine.renderManager.uModelMat,ct(e),[this.rotation.x/e,this.rotation.y/e,this.rotation.z/e])}t.textures.length?this.drawTexturedObj():this.drawObj(),e.renderManager.mvPopMatrix(),e.gl.enableVertexAttribArray(e.renderManager.shaderProgram.aTextureCoord),e.gl.disableVertexAttribArray(e.renderManager.shaderProgram.aVertexNormal)}),i(this,"setFacing",e=>{e&&(this.facing=e),this.rotation=Us.objectSequence(e)}),i(this,"removeAction",e=>{this.actionList=this.actionList.filter(t=>t.id!==e),delete this.actionDict[e]}),i(this,"removeAllActions",()=>{this.actionList=[],this.actionDict={}}),i(this,"tickOuter",e=>{if(!this.loaded)return;this.actionList.sort((e,t)=>{let n=e.startTime-t.startTime;return n?e.id>t.id?1:-1:n});let t=[];this.actionList.forEach(n=>{!n.loaded||n.startTime>e||n.tick(e)&&(t.push(n),n.onComplete())}),t.forEach(e=>this.removeAction(e.id)),this.tick&&this.tick(e)}),i(this,"init",()=>{console.log("- object hook",this.id,this.pos,this.objId)}),i(this,"speak",(e,t=!1)=>{e?(this.textbox=this.engine.hud.scrollText(this.id+":> "+e,!0,{portrait:this.portrait??!1}),t&&this.speech&&(this.speech.scrollText(e,!1,{portrait:this.portrait??!1}),this.speech.loadImage())):this.speech.clearHud()}),i(this,"interact",async(e,t)=>(this.state,t&&t(!0),null)),i(this,"setFacing",e=>{e&&(this.facing=e),this.rotation=Us.objectSequence(e)}),i(this,"faceDir",e=>this.facing==e||e===Us.None?null:new Ac(this.engine,"face",[e],this)),i(this,"setGreeting",e=>(this.speech.clearHud&&this.speech.clearHud(),this.speech.writeText(e),this.speech.loadImage(),new Ac(this.engine,"greeting",[e,{autoclose:!0}],this))),this.objId=Math.floor(100*Math.random()),this.engine=e,this.templateLoaded=!1,this.drawOffset=new ot(0,0,0),this.hotspotOffset=new ot(0,0,0),this.pos=new ot(0,0,0),this.size=new ot(1,1,1),this.scale=new ot(1,1,1),this.rotation=new ot(0,0,0),this.facing=Us.Right,this.actionDict={},this.actionList=[],this.speech={},this.portrait=null,this.isLit=!0,this.lightColor=[1,1,1],this.lightIndex=null,this.onLoadActions=new Xs,this.inventory=[],this.blocking=!0,this.override=!1,this.isSelected=!1}async addAction(e){e=await Promise.resolve(e),this.actionDict[e.id]&&this.removeAction(e.id),this.actionDict[e.id]=e,this.actionList.push(e)}}class Sc{constructor(e){this.engine=e,this.definitions=[],this.instances={}}async loadFromZip(e,t){let n=arguments[2],i=arguments[3];this.instances[t.id]||(this.instances[t.id]=[]);let r=new kc(this.engine);r.update(t);let s={obj:`${r.type}.obj`,mtl:t.mtl??!1,mtlTextureRoot:"textures",downloadMtlTextures:!0,enableWTextureCoord:!1,name:r.id},a=await this.engine.resourceManager.objLoader.downloadModelsFromZip(this.engine.gl,[s],e);return r.mesh=a[t.type],r.templateLoaded=!0,this.instances[r.id].forEach(function(e){e.afterLoad&&e.afterLoad(e.instance)}),i&&i(r),n&&(r.templateLoaded?n(r):this.instances[r.id].push({instance:r,afterLoad:n})),r.loaded=!0,r}}class Mc{constructor(e,t,n){this.type=e,this.sprite=t,this.callback=n,this.time=(new Date).getTime(),this.id=t.id+"-"+e+"-"+this.time}configure(e,t,n,i,r){this.sprite=t,this.id=n,this.type=e,this.startTime=i,this.creationArgs=r}async onLoad(e){await this.init.apply(this,e),this.loaded=!0}serialize(){return{id:this.id,time:this.startTime,zone:this.sprite.zone.id,sprite:this.sprite.id,type:this.type,args:this.creationArgs}}onComplete(){return this.callback?this.callback():null}}class Ac{constructor(e,t,n,i,r){this.engine=e,this.type=t,this.args=n,this.sprite=i,this.callback=r,this.instances={},this.definitions=[],this.assets={};let s=(new Date).getTime(),a=i.id+"-"+t+"-"+s;return this.load(t,async function(e){await e.onLoad(n)},function(e){e.configure(t,i,a,s,n)})}async load(e){Ma("Loader","Loading Action: "+e);let t=arguments[1],n=arguments[2];this.instances[e]||(this.instances[e]=[]),Ma("Loader",{afterLoad:t,runConfigure:n});let i=new Mc(this.type,this.sprite,this.callback);const r=await import("../../actions/"+e+".js");return Object.assign(i,r.default),i.templateLoaded=!0,Ma("Loader","Notifying in Action: "+e),await Promise.all(this.instances[e].map(async function(e){Ma("Loader",{instance:e}),e.afterLoad&&await e.afterLoad(e.instance)})),n&&n(i),t&&(i.templateLoaded?t(i):this.instances[e].push({instance:i,afterLoad:t})),Ma("Loader","Ending load Action: "+e),i}}class Tc{constructor(e,t,n){this.type=e,this.world=t,this.callback=n,this.time=(new Date).getTime(),this.id=t.id+"-"+e+"-"+this.time}configure(e,t,n,i,r){this.world=t,this.id=n,this.type=e,this.startTime=i,this.creationArgs=r}async onLoad(e){await this.init.apply(this,e),this.loaded=!0}serialize(){return{id:this.id,time:this.startTime,world:this.world.id,type:this.type,args:this.creationArgs}}onComplete(){return this.callback?this.callback():null}}class Ec{constructor(e,t,n,i,r){this.engine=e,this.type=t,this.args=n,this.world=i,this.callback=r,this.instances={},this.definitions=[],this.assets={};let s=(new Date).getTime(),a=i.id+"-"+t+"-"+s;return this.load(t,function(e){e.onLoad(n)},function(e){e.configure(t,i,a,s,n)})}async load(e){let t=arguments[1],n=arguments[2];this.instances[e]||(this.instances[e]=[]);let i=new Tc(this.type,this.world,this.callback);const r=await import("../../events/"+e+".js");return Object.assign(i,r.default),i.templateLoaded=!0,this.instances[e].forEach(function(e){e.afterLoad&&e.afterLoad(e.instance)}),n&&n(i),t&&(i.templateLoaded?await t(i):this.instances[e].push({instance:i,afterLoad:t})),i}}class Pc{constructor(e){return Pc._instance||(this.engine=e,this.keyboard=new Ba(e),this.mouse=new Fa(e),this.gamepad=new $a(e),this.touch=new Va(e),this.mappings={},this.hooks={},this.currentMode="default",this.actionStates={},this.lastActionTime={},this.actionPressed={},Pc._instance=this),Pc._instance}init(){this.keyboard.init(),this.mouse.init(),this.gamepad.init(),this.touch.init(),this.setModeMappings("default",{actions:{move_up:{keyboard:"w",gamepad:"up",touch:"swipe_up"},move_down:{keyboard:"s",gamepad:"down",touch:"swipe_down"},move_left:{keyboard:"a",gamepad:"left",touch:"swipe_left"},move_right:{keyboard:"d",gamepad:"right",touch:"swipe_right"},interact:{keyboard:"k",gamepad:"a",touch:"tap"},select:{mouse:"left",touch:"tap"},select_right:{mouse:"right"},camera_pan_left:{keyboard:"ArrowLeft"},camera_pan_right:{keyboard:"ArrowRight"},camera_pan_up:{keyboard:"ArrowUp"},camera_pan_down:{keyboard:"ArrowDown"},camera_zoom_in:{keyboard:"q"},camera_zoom_out:{keyboard:"e"},camera_rotate_left:{keyboard:"z"},camera_rotate_right:{keyboard:"x"},menu:{keyboard:"m",gamepad:"y"},run:{keyboard:"r",gamepad:"y"},bind_camera:{keyboard:"b"},fixed_camera:{keyboard:"c"},help:{keyboard:"h"},chat:{keyboard:" "},clear_speech:{keyboard:"Escape"},patrol:{keyboard:"p"},dance:{keyboard:"u"},height_up:{keyboard:"y"},height_down:{keyboard:"f"}}})}setModeMappings(e,t){this.mappings[e]=t}addActionHook(e,t){this.hooks[e]||(this.hooks[e]=[]),this.hooks[e].push(t)}registerActionHook(e,t){this.hooks[e]||(this.hooks[e]=[]),this.hooks[e].push(t)}removeActionHook(e,t){if(this.hooks[e]){const n=this.hooks[e].indexOf(t);n>-1&&this.hooks[e].splice(n,1)}}update(){const e=this.mappings[this.currentMode]||this.mappings.default,t={...this.mappings.default.actions,...e.actions};for(const n in t){const e=t[n];let i=!1;const r=e=>e.length>1?this.keyboard.isCodePressed(e):this.keyboard.isKeyPressed(e);e.keyboard&&r(e.keyboard)&&(i=!0),e.gamepad&&(this.gamepad.keyPressed(e.gamepad)||"up"===e.gamepad&&this.gamepad.map["y-axis"]<-.5||"down"===e.gamepad&&this.gamepad.map["y-axis"]>.5||"left"===e.gamepad&&this.gamepad.map["x-axis"]<-.5||"right"===e.gamepad&&this.gamepad.map["x-axis"]>.5)&&(i=!0),e.mouse&&this.mouse.isButtonPressed(e.mouse)&&(i=!0),e.touch&&this.touch.isGestureActive(e.touch)&&(i=!0);const s=this.actionStates[n];this.actionStates[n]=i,this.actionPressed[n]=i&&!s,i&&!s&&(this.lastActionTime[n]=Date.now(),this.hooks[n]&&this.hooks[n].forEach(e=>e(n,this.currentMode)))}}isActionActive(e){return!!this.actionStates[e]}isActionPressed(e){return!!this.actionPressed[e]}setMode(e){this.mappings[e]||"default"===e?(this.currentMode=e,this.engine&&this.engine.modeManager&&this.engine.modeManager.set(e)):console.warn(`Input mode "${e}" not found, staying in "${this.currentMode}"`)}handleInput(e){return!(!this.engine||!this.engine.modeManager)&&this.engine.modeManager.handleInput(e)}getActionInput(e){const t=(this.mappings[this.currentMode]||this.mappings.default).actions[e];if(!t)return null;if(t.keyboard&&this.keyboard.isKeyPressed(t.keyboard))return"keyboard:"+t.keyboard;if(t.gamepad){if(this.gamepad.keyPressed(t.gamepad))return"gamepad:"+t.gamepad;if("up"===t.gamepad&&this.gamepad.map["y-axis"]<-.5)return"gamepad:up";if("down"===t.gamepad&&this.gamepad.map["y-axis"]>.5)return"gamepad:down";if("left"===t.gamepad&&this.gamepad.map["x-axis"]<-.5)return"gamepad:left";if("right"===t.gamepad&&this.gamepad.map["x-axis"]>.5)return"gamepad:right"}return t.mouse&&this.mouse.isButtonPressed(t.mouse)?"mouse:"+t.mouse:t.touch&&this.touch.isGestureActive(t.touch)?"touch:"+t.touch:null}getMode(){return this.currentMode}getAvatarAction(e){const t=this.mappings[this.currentMode]||this.mappings.default,n={...this.mappings.default.actions,...t.actions};for(const i in n)if(this.isActionActive(i))switch(i){case"menu":return e.openMenu({main:{text:"Close Menu",x:100,y:100,w:150,h:75,colours:{top:"#333",bottom:"#777",background:"#999"},trigger:e=>{e.completed=!0}}},["main"]);case"chat":return new Ac(this.engine,"chat",[">:",!0,{autoclose:!1}],e);case"patrol":return new Ac(this.engine,"patrol",[e.pos.toArray(),new ot(8,13,e.pos.z).toArray(),600,e.zone],e);case"run":return new Ac(this.engine,"patrol",[e.pos.toArray(),new ot(8,13,e.pos.z).toArray(),200,e.zone],e);case"interact":return new Ac(this.engine,"interact",[e.pos.toArray(),e.facing,e.zone.world],e);case"help":return new Ac(this.engine,"dialogue",["Welcome! You pressed help! Press Escape to close",!1,{autoclose:!0}],e);case"clear_speech":return e.speech.clearHud();case"move_up":const t=Us.getCameraRelativeDirection("forward",this.engine.renderManager.camera.cameraDir);return e.handleWalk("w",{},t);case"move_down":const n=Us.getCameraRelativeDirection("backward",this.engine.renderManager.camera.cameraDir);return e.handleWalk("s",{},n);case"move_left":const r=Us.getCameraRelativeDirection("left",this.engine.renderManager.camera.cameraDir);return e.handleWalk("a",{},r);case"move_right":const s=Us.getCameraRelativeDirection("right",this.engine.renderManager.camera.cameraDir);return e.handleWalk("d",{},s);case"face_up":return e.faceDir("N");case"face_down":return e.faceDir("S");case"face_left":return e.faceDir("W");case"face_right":return e.faceDir("E");default:if(i.startsWith("camera_")){const t=this.engine.renderManager.camera.cameraVector;let n=this.engine.renderManager.camera.cameraVector,r=Us.adjustCameraDirection(n);switch(i){case"camera_rotate_left":n=t.sub(new ot(0,0,1)),n.z=Math.round(n.z%9),0===n.z&&8===t.z&&(t.z=0),0===n.z&&7===t.z&&(n.z=8),e.faceDir(Us.spriteSequence(r)),e.zone.world.addEvent(new Ec(this.engine,"camera",["pan",{from:t,to:n,duration:1}],e.zone.world));break;case"camera_rotate_right":n=t.add(new ot(0,0,1)),n.z=Math.round(n.z%9),0===n.z&&8===t.z&&(t.z=0),0===n.z&&7===t.z&&(n.z=8),e.faceDir(Us.spriteSequence(r)),e.zone.world.addEvent(new Ec(this.engine,"camera",["pan",{from:t,to:n,duration:1}],e.zone.world));break;case"camera_zoom_in":case"camera_zoom_out":case"camera_pan_left":case"camera_pan_right":case"camera_pan_up":case"camera_pan_down":break;case"camera_bind":e.bindCamera=!0;break;case"camera_unbind":e.bindCamera=!1}return null}return new Ac(this.engine,i,[],e)}return null}bindAction(e,t,n){this.mappings[this.currentMode]||(this.mappings[this.currentMode]={actions:{}}),this.mappings[this.currentMode].actions[e]||(this.mappings[this.currentMode].actions[e]={}),this.mappings[this.currentMode].actions[e][t]=n}unbindAction(e,t){this.mappings[this.currentMode]&&this.mappings[this.currentMode].actions[e]&&delete this.mappings[this.currentMode].actions[e][t]}}const Cc=class e{constructor(e){this.engine=e,this.ws=null,this.clientId=null,this.players=new Map,this.authority="server",this.zoneId=null,this.setAuthorityFromManifest()}async connect(e){this.ws&&this.disconnect();try{this.ws=new WebSocket(e)}catch(Yc){return void console.warn("[NetworkManager] WebSocket creation failed (server may be offline):",Yc.message)}return new Promise(e=>{this.ws.onopen=()=>{console.log("[NetworkManager] WebSocket connection established"),e()},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{console.log("[NetworkManager] WebSocket connection closed"),this.ws=null},this.ws.onerror=t=>{console.warn("[NetworkManager] WebSocket error (server may be offline):",t.type||"connection failed"),this.ws=null,e()}})}safeStringify(e){try{return JSON.stringify(e)}catch(Yc){try{const t={};return Object.keys(e||{}).forEach(n=>{const i=e[n];t[n]=i&&"object"==typeof i?Array.isArray(i)?`[Array(${i.length})]`:`{${i.constructor&&i.constructor.name}}`:i}),JSON.stringify(t)}catch(t){return String(e)}}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}send(e,t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:e,payload:t}))}handleMessage(e){try{const t=JSON.parse(e);switch(console.log("Received message from server:",t),t.type){case"connected":this.clientId=t.clientId,this.engine.store.set("clientId",this.clientId),console.log(`Connected to server with client ID: ${this.clientId}`);break;case"zone-loaded":this.handleZoneLoaded(t.payload);break;case"zone-change":this.handleZoneChange(t.payload);break;case"zone-joined":this.handleZoneJoined(t.payload);break;case"player-joined":this.handlePlayerJoined(t.payload);break;case"player-left":this.handlePlayerLeft(t.payload);break;case"players-update":this.handlePlayersUpdate(t.payload);break;case"zone-state":this.handleZoneState(t.payload);break;case"avatar-update":this.handleAvatarUpdate(t.payload);break;case"action":this.handleAction(t.payload);break;default:console.log(`Unknown message type: ${t.type}`)}}catch(t){const n="string"==typeof e?e.length>1e3?e.slice(0,1e3)+"... (truncated)":e:this.safeStringify(e);console.error("Failed to parse message from server. Parse error:",t),console.error("Raw message preview:",n)}}loadZone(e,t){const n=t.getZoneData?t.getZoneData():t;let i;try{i=JSON.parse(JSON.stringify(n))}catch(Yc){console.warn("Zone data contains circular refs, sending minimal zone info instead"),i={id:e,name:t&&t.name}}this.send("load-zone",{zoneId:e,zone:i})}joinZone(e){this.zoneId=e;const t=this.engine.spritz.world.getAvatar(),n=t.getAvatarData(),i={id:n.id||t.objId||t.id||"avatar",templateLoaded:!!n.templateLoaded,animFrame:n.animFrame||0,facing:n.facing||0,fixed:!!n.fixed,isSelected:!!n.isSelected,x:t&&t.pos?t.pos.x:n.pos&&n.pos.x||0,y:t&&t.pos?t.pos.y:n.pos&&n.pos.y||0,z:t&&t.pos?t.pos.z:n.pos&&n.pos.z||0,drawOffset:n.drawOffset?{x:n.drawOffset.x,y:n.drawOffset.y}:void 0,hotspotOffset:n.hotspotOffset?{x:n.hotspotOffset.x,y:n.hotspotOffset.y}:void 0,scale:n.scale?{x:n.scale.x,y:n.scale.y}:void 0};this.send("join-zone",{zoneId:e,avatar:i})}sendAction(e,t){if("server"===this.authority){const n={action:e.constructor.name.toLowerCase(),params:e.params,spriteId:t.id};this.send("action",n)}else this.handleAction({clientId:this.clientId,action:e.constructor.name.toLowerCase(),params:e.params,spriteId:t.id})}updateAvatarPosition(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){const t={avatar:{id:e.id,x:e.pos.x,y:e.pos.y,z:e.pos.z,facing:e.facing}},n=JSON.parse(JSON.stringify(t));this.send("update-avatar",n)}}handleZoneLoaded(e){console.log(`Loaded zone ${e.zoneId}`),this.joinZone(e.zoneId)}handleZoneJoined(e){console.log(`Joined zone ${e.zoneId} with players:`,e.players),e.players.forEach(e=>this.handlePlayerJoined({client:e})),this.send("zone-state-request",{zoneId:e.zoneId})}getZoneSprites(e){const t=this.engine.spritz.world;if(!t)return[];const n=t.getZoneById(e);return n?n.spriteList.map(e=>({id:e.id,objId:e.objId,x:e.pos.x,y:e.pos.y,z:e.pos.z,avatar:e.getAvatarData?e.getAvatarData():e})):[]}handleZoneChange(e){console.log(`Change zone ${e.zoneId}`)}handlePlayerJoined(e){if(e.client.clientId===this.clientId)return;console.log(`Player ${e.client.clientId} joined the zone`);try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText(`Player ${e.client.clientId} joined`,!0,{autoclose:!0,duration:3e3})}catch(Yc){}const t=this.engine.spritz.world;t&&(t.addRemoteAvatar(e.client.clientId,e.client.avatar),this.players.set(e.client.clientId,Object.assign({},e.client.avatar,{clientId:e.client.clientId})))}handlePlayerLeft(e){console.log(`Player ${e.clientId} left the zone`);try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText(`Player ${e.clientId} left`,!0,{autoclose:!0,duration:3e3})}catch(Yc){}const t=this.players.get(e.clientId);if(t){const n=this.engine.spritz.world;n&&n.removeAvatar(t),this.players.delete(e.clientId)}}handlePlayersUpdate(e){console.log("Players update:",e.players);try{this.engine&&this.engine.hud&&"function"==typeof this.engine.hud.scrollText&&this.engine.hud.scrollText(`Players in zone: ${e.players.map(e=>e.clientId).join(", ")}`,!0,{autoclose:!0,duration:3e3})}catch(Yc){}const t=new Set(this.players.keys()),n=new Set(e.players.map(e=>e.clientId));for(const i of t)if(!n.has(i)){const e=this.engine.spritz.world;e&&e.removeRemoteAvatar(i),this.players.delete(i)}e.players.forEach(e=>{if(e.clientId!==this.clientId){const t=this.engine.spritz.world;t&&(this.players.has(e.clientId)?(t.updateRemoteAvatar(e.clientId,e.avatar),this.players.set(e.clientId,e.avatar)):(t.addRemoteAvatar(e.clientId,e.avatar),this.players.set(e.clientId,e.avatar)))}})}handleAction(t){if(t.clientId===this.clientId)return;console.log(`Received action from ${t.clientId}:`,t);const n=this.engine.spritz.world.remoteAvatars.get(t.clientId);if(n)try{let i=null;const r=this.engine.spritz&&this.engine.spritz.world;if(r&&"function"==typeof r.actionFactory&&(i=r.actionFactory(t.action)),i){const e=new i(n,...Object.values(t.params||{}));n.addAction(e)}else{e._ActionLoader||(e._ActionLoader=Ac);const i=new e._ActionLoader(this.engine,t.action,t.params||{},n,()=>{});i&&null==i.instances&&console.warn("ActionLoader returned unexpected instance for action",t.action,i)}}catch(Yc){console.warn("Failed to handle action payload",t,Yc)}}handleZoneState(e){console.log(`Received zone state for ${e.zoneId}:`,e.sprites);const t=this.engine.spritz.world;if(!t)return;const n=t.getZoneById(e.zoneId);n&&e.sprites.forEach(e=>{if(e.clientId!==this.clientId)try{if(e.clientId&&t.remoteAvatars&&t.remoteAvatars.has(e.clientId))t.updateRemoteAvatar(e.clientId,{x:e.x,y:e.y,z:e.z||0,facing:e.avatar&&e.avatar.facing||e.facing,animFrame:e.avatar&&e.avatar.animFrame||e.animFrame,...e.avatar||{}});else{let i=n.spriteDict[e.id];if(i)i.pos.x=e.x,i.pos.y=e.y,i.pos.z=e.z||0,e.avatar&&(null!=e.avatar.facing&&(i.facing=e.avatar.facing),null!=e.avatar.animFrame&&(i.animFrame=e.avatar.animFrame));else{const n={id:e.id||`player-${e.clientId}`,x:e.x,y:e.y,z:e.z||0,facing:e.avatar&&e.avatar.facing||e.facing,animFrame:e.avatar&&e.avatar.animFrame||e.animFrame,...e.avatar||{}};e.clientId&&"function"==typeof t.addRemoteAvatar?t.addRemoteAvatar(e.clientId,n):"function"==typeof t.createAvatar&&t.createAvatar(n)}}}catch(Yc){console.warn("Error handling zone state sprite update:",Yc)}})}setAuthorityFromManifest(){this.engine&&this.engine.spritz&&this.engine.spritz.manifest&&this.engine.spritz.manifest.network&&(this.authority=this.engine.spritz.manifest.network.authority||"server")}handleAvatarUpdate(e){console.log(`Received avatar update for ${e.clientId}:`,e.avatar);const t=this.engine.spritz.world;if(t){t.updateRemoteAvatar(e.clientId,e.avatar)||t.addRemoteAvatar(e.clientId,{id:e.avatar.id||`player-${e.clientId}`,...e.avatar}),this.players.set(e.clientId,e.avatar)}}setAuthority(e){this.authority=e}};i(Cc,"_ActionLoader",null);let zc=Cc;const Lc=e=>{if(e.showWebglDebug&&e.webglDebugDiv){const t="undefined"!=typeof performance?performance.now():Date.now(),n=t-e.lastDebugTime,i=n>0?(1e3/n).toFixed(1):"0";e.lastDebugTime=t;const r=e.gl;let s="",a="",o="";if(r)try{s=r.getParameter(r.RENDERER),a=r.getParameter(r.VENDOR),o=r.getParameter(r.VERSION)}catch(Yc){}const l=e.renderManager.debug||{};e.webglDebugDiv.innerHTML="FPS: "+i+"<br>Tiles Drawn: "+(l.tilesDrawn||0)+"<br>Sprites Drawn: "+(l.spritesDrawn||0)+"<br>Objects Drawn: "+(l.objectsDrawn||0)+"<br>Renderer: "+s+"<br>Vendor: "+a+"<br>GL Version: "+o}},Ic=e=>{if(e.showFlagDebug&&e.flagDebugDiv){e.store.set("Debug::Flag::UpdateTime",Date.now());const t=e.store.all();console.log({self:e,keys:JSON.stringify(t),store:e.store.keys()});const n=Object.keys(t).map(e=>e+": "+JSON.stringify(t[e])+"<br>");e.flagDebugDiv.innerHTML="FLAGS:<br>"+n.join("")}};class Dc{constructor(e,t,n,i,r,s,a){this.canvas=e,this.hudCanvas=t,this.gamepadCanvas=i,this.mipmap=n,this.fileUpload=r,this.width=s,this.height=a,this.utils=ht,this.networkManager=new zc(this),this.resourceManager=null,this.renderManager=null,this.hud=new gs(this),this.inputManager=new Pc(this),this.voice=new SpeechSynthesisUtterance,this.database=new ds,this.store=new fs,this.cutsceneManager=new Ra(this),this.modeManager=new Oa(this),this.debug=!1,this.debugHeightOverlay=!1,this.running=!1,this.gl=null,this.ctx=null,this.gp=null,this.frameCount=0,this.spritz=null,this.fullscreen=!1,this.time=0,this.requestId=null,this.screenSize=this.screenSize.bind(this),this.render=this.render.bind(this),this.init=this.init.bind(this),this.close=this.close.bind(this)}async init(e){var t,n;const i=this.hudCanvas.getContext("2d"),r=this.canvas.getContext("webgl2",{antialias:!0,depth:!0,preserveDrawingBuffer:!1}),s=this.gamepadCanvas.getContext("2d");if(!r)throw new Error("WebGL: unable to initialize");if(!i)throw new Error("Canvas: unable to initialize HUD");if(!s)throw new Error("Gamepad: unable to initialize Mobile Canvas");i.canvas.width=r.canvas.clientWidth,i.canvas.height=r.canvas.clientHeight,this.gl=r,this.ctx=i,this.gp=s,this.frameCount=0,this.spritz=e,this.fullscreen=!1,this.time=(new Date).getTime(),this.inputManager.init(),this.hud.init(),this.resourceManager||(this.resourceManager=new Da(this)),this.renderManager||(this.renderManager=new _a(this)),this.renderManager.init(),this.gamepad=this.inputManager.gamepad,this.keyboard=this.inputManager.keyboard,this.mouse=this.inputManager.mouse,this.touch=this.inputManager.touch,this.touchHandler=this.gamepad.listen.bind(this.gamepad),(null==(n=null==(t=e.manifest)?void 0:t.network)?void 0:n.enabled)&&(await this.networkManager.connect(e.manifest.network.url),e.manifest.network.authority&&this.networkManager.setAuthority(e.manifest.network.authority)),await e.init(this),(e=>{const t=document.createElement("div");t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.background="rgba(0, 0, 0, 0.6)",t.style.color="#0f0",t.style.padding="4px",t.style.fontFamily="monospace",t.style.fontSize="12px",t.style.zIndex="10000",t.style.pointerEvents="none",t.style.display="none",e.webglDebugDiv=t,document.body.appendChild(t),window.addEventListener("keydown",t=>{"F3"===t.key&&(e.showWebglDebug=!e.showWebglDebug,e.store.set("Debug::Webgl::showDebug",e.showWebglDebug),e.webglDebugDiv.style.display=e.showWebglDebug?"block":"none")});try{const t=e.keyboard,n=(t,n)=>{if("down"!==n)return;if("F5"!==t.key)return;try{t.preventDefault(),t.stopPropagation()}catch(r){}e.showFreeCam=!e.showFreeCam,e.store.set("Debug::FreeCam::show",e.showFreeCam);const i=new CustomEvent("pixos:freecam:toggle");window.dispatchEvent(i)};t.addHook&&t.addHook(n),e._debugFreeCamHook=n}catch(n){}window.addEventListener("pixos:freecam:toggle",()=>{var t,i;const r=e.renderManager;if(!r||!r.camera)return;const s=e.canvas||document.body,a=e=>{try{e.preventDefault(),e.stopPropagation()}catch(n){}const t=.5*(e.deltaY>0?1:-1);try{r.camera.zoom&&r.camera.zoom(t),h++}catch(n){}},o=e=>{const t=.002*(e.movementX||0),i=.002*(e.movementY||0);try{const e=1.5*-t,n=1.5*-i;r.camera&&(r.camera.yaw+=e,r.camera.pitch=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,r.camera.pitch+n)),r.camera.updateViewFromAngles&&r.camera.updateViewFromAngles(),h++)}catch(n){}};let l=null,c=null,h=0,u=!0;const d=()=>{const t=(e.keyboard&&e.keyboard.activeCodes||[]).map(e=>(e||"").toString().toLowerCase());try{r.camera&&((t.indexOf("w")>=0||t.indexOf("arrowup")>=0)&&(r.camera.translateCam("UP"),h++),(t.indexOf("s")>=0||t.indexOf("arrowdown")>=0)&&(r.camera.translateCam("DOWN"),h++),(t.indexOf("a")>=0||t.indexOf("arrowleft")>=0)&&(r.camera.translateCam("LEFT"),h++),(t.indexOf("d")>=0||t.indexOf("arrowright")>=0)&&(r.camera.translateCam("RIGHT"),h++),t.indexOf("q")>=0&&(r.camera.yaw-=.03,r.camera.updateViewFromAngles(),h++),t.indexOf("e")>=0&&(r.camera.yaw+=.03,r.camera.updateViewFromAngles(),h++),t.indexOf("r")>=0&&(r.camera.pitch=Math.max(-Math.PI/2+.01,r.camera.pitch-.03),r.camera.updateViewFromAngles(),h++),t.indexOf("f")>=0&&(r.camera.pitch=Math.min(Math.PI/2-.01,r.camera.pitch+.03),r.camera.updateViewFromAngles(),h++))}catch(n){}l=requestAnimationFrame(d),c||(c=document.createElement("div"),c.id="pixos-freecam-status",c.style.position="absolute",c.style.top="8px",c.style.left="50%",c.style.transform="translateX(-50%)",c.style.background="rgba(0,0,0,0.6)",c.style.color="#fff",c.style.padding="6px 10px",c.style.fontFamily="monospace",c.style.fontSize="12px",c.style.zIndex="10002",document.body.appendChild(c));try{const e=r.camera||{};if(u){try{console.log("[FreeCam] FIRST TICK viewMat:",Array.from(r.camera.uViewMat))}catch(n){}u=!1}const i=e.cameraPosition?[e.cameraPosition.x,e.cameraPosition.y,e.cameraPosition.z]:["n/a"],a=void 0!==e.yaw?e.yaw.toFixed(3):"n/a",o=void 0!==e.pitch?e.pitch.toFixed(3):"n/a",l=r.camera&&r.camera.uViewMat?Array.from(r.camera.uViewMat).slice(0,8).map(e=>e.toFixed(3)):[];c.innerText="Keys: "+JSON.stringify(t)+"\npointerLock: "+(document.pointerLockElement===s?"yes":"no")+"\npos: "+JSON.stringify(i)+" yaw:"+a+" pitch:"+o+"\nuViewMat (trim): "+JSON.stringify(l)+"\nmoves: "+h}catch(n){}};if(e.showFreeCam){e._freeCamSaved=bs();try{console.log("[FreeCam] ENTER - current viewMat:",Array.from(r.camera.uViewMat))}catch(n){}ks(r.camera.uViewMat,e._freeCamSaved);try{e._freeCamSavedState={position:new ot(r.camera.cameraPosition.x,r.camera.cameraPosition.y,r.camera.cameraPosition.z),yaw:r.camera.yaw,pitch:r.camera.pitch,distance:r.camera.cameraDistance,target:r.camera.cameraTarget?new ot(r.camera.cameraTarget.x,r.camera.cameraTarget.y,r.camera.cameraTarget.z):null,viewMat:bs()},ks(r.camera.uViewMat,e._freeCamSavedState.viewMat);try{console.log("[FreeCam] ENTER - savedState.viewMat:",Array.from(e._freeCamSavedState.viewMat))}catch(n){}}catch(n){}(null==(t=e.spritz)?void 0:t.world)&&(e.spritz.world.isPaused=!0),e._freecamActive=!0;const i=document.createElement("div");i.style.position="absolute",i.style.bottom="8px",i.style.left="50%",i.style.transform="translateX(-50%)",i.style.background="rgba(0,0,0,0.6)",i.style.color="#fff",i.style.padding="6px 10px",i.style.fontFamily="monospace",i.style.fontSize="12px",i.style.zIndex="10001",i.id="pixos-freecam-info",i.innerHTML="FREE CAM (F5 to exit) WASD/Arrows: move & strafe Q/E: yaw R/F: pitch Wheel: zoom",document.body.appendChild(i);const c=()=>{const t=document.pointerLockElement===s||document.mozPointerLockElement===s;try{const i=document.getElementById("pixos-freecam-status");i&&(i.innerText="Keys: "+JSON.stringify(e.keyboard&&e.keyboard.activeCodes||[])+" | pointerLock: "+(t?"yes":"no"));try{console.log("[FreeCam] pointerLock change - locked:",t,"viewMat:",Array.from(r.camera.uViewMat))}catch(n){}}catch(n){}},h=e=>{e&&e.preventDefault();try{s&&s.parentElement&&s.parentElement.focus&&s.parentElement.focus()}catch(n){}try{s.requestPointerLock=s.requestPointerLock||s.mozRequestPointerLock,s.requestPointerLock()}catch(n){}};document.addEventListener("pointerlockchange",c),document.addEventListener("mozpointerlockchange",c);try{e._bodyOverflowSaved=document.body.style.overflow,document.body.style.overflow="hidden"}catch(n){}try{s.requestPointerLock=s.requestPointerLock||s.mozRequestPointerLock,s.requestPointerLock()}catch(n){}window.addEventListener("wheel",a,{passive:!1,capture:!0}),document.addEventListener("pointermove",o,{capture:!0}),document.addEventListener("mousemove",o,{capture:!0}),l=requestAnimationFrame(d),e._freecamHandlers={onWheel:a,onPointerMove:o,rafId:l,captureClick:h,onPointerLockChange:c}}else{if(e._freeCamSavedState){try{try{console.log("[FreeCam] EXIT - restoring savedState.viewMat:",Array.from(e._freeCamSavedState.viewMat))}catch(n){}ks(e._freeCamSavedState.viewMat,r.camera.uViewMat);try{r.camera&&(void 0!==e._freeCamSavedState.yaw&&(r.camera.yaw=e._freeCamSavedState.yaw),void 0!==e._freeCamSavedState.pitch&&(r.camera.pitch=e._freeCamSavedState.pitch),void 0!==e._freeCamSavedState.distance&&(r.camera.cameraDistance=e._freeCamSavedState.distance),e._freeCamSavedState.target&&(r.camera.cameraTarget=e._freeCamSavedState.target),r.camera.updateViewFromAngles&&r.camera.updateViewFromAngles())}catch(n){}}catch(n){}e._freeCamSavedState=null}else if(e._freeCamSaved)try{try{console.log("[FreeCam] EXIT - restoring _freeCamSaved:",Array.from(e._freeCamSaved))}catch(n){}ks(e._freeCamSaved,r.camera.uViewMat);try{r.camera.setFromViewMatrix(r.camera.uViewMat)}catch(n){}}catch(n){}(null==(i=e.spritz)?void 0:i.world)&&(e.spritz.world.isPaused=!1),e._freecamActive=!1;const t=document.getElementById("pixos-freecam-info");t&&document.body.removeChild(t);try{document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock,document.exitPointerLock()}catch(n){}if(e._freecamHandlers){window.removeEventListener("wheel",e._freecamHandlers.onWheel,{capture:!0}),document.removeEventListener("pointermove",e._freecamHandlers.onPointerMove,{capture:!0}),document.removeEventListener("mousemove",e._freecamHandlers.onPointerMove,{capture:!0});try{e._freecamHandlers.onPointerLockChange&&(document.removeEventListener("pointerlockchange",e._freecamHandlers.onPointerLockChange),document.removeEventListener("mozpointerlockchange",e._freecamHandlers.onPointerLockChange))}catch(n){}cancelAnimationFrame(e._freecamHandlers.rafId),e._freecamHandlers=null}try{document.body.style.overflow=e._bodyOverflowSaved??""}catch(n){}try{const e=document.getElementById("pixos-freecam-status");e&&document.body.removeChild(e)}catch(n){}}})})(this),(e=>{const t=document.createElement("div");t.style.position="absolute",t.style.top="0",t.style.right="0",t.style.background="rgba(0, 0, 0, 0.6)",t.style.color="#0f0",t.style.padding="4px",t.style.fontFamily="monospace",t.style.fontSize="12px",t.style.zIndex="10000",t.style.pointerEvents="none",t.style.display="none",e.flagDebugDiv=t,document.body.appendChild(t),window.addEventListener("keydown",t=>{"F4"===t.key&&(e.showFlagDebug=!e.showFlagDebug,e.store.set("Debug::Flag::showDebug",e.showFlagDebug),e.flagDebugDiv.style.display=e.showFlagDebug?"block":"none")})})(this)}render(){this.frameCount++,this.renderManager&&this.renderManager.resetDebugCounters&&this.renderManager.resetDebugCounters(),this.hud.clearHud(),this.hud.drawModeLabel&&this.hud.drawModeLabel(),this.renderManager.clearScreen();const e=(new Date).getTime();this.inputManager.update(),this.modeManager.hasPicker()&&(this.renderManager.activatePickerShaderProgram(!1),this.spritz.render(this,e),this.getSelectedObject("sprite|object|tile",!1)),this.inputManager.handleInput(e)||this.spritz.update(e);const t=this.modeManager.getMode();t&&this.inputManager.getMode()!==t&&this.inputManager.setMode(t);const n=this.renderManager.engine.gl;if(this.renderManager.clearScreen(),n.depthMask(!1),this.renderManager.renderSkybox(),n.depthMask(!0),this.renderManager.activateShaderProgram(),this.modeManager.update(e),this.renderManager&&this.renderManager.updateParticles)try{this.renderManager.updateParticles(e)}catch(Yc){console.warn("updateParticles failed",Yc)}if(this.spritz.render(this),this.cutsceneManager.update(),this.renderManager.updateTransition(),this.renderManager&&this.renderManager.renderParticles)try{this.renderManager.renderParticles()}catch(Yc){console.warn("renderParticles failed",Yc)}if(this.gamepad.render(),this.debugHeightOverlay&&this.hud.drawHeightDebugOverlay)try{this.hud.drawHeightDebugOverlay()}catch(Yc){console.warn("drawHeightDebugOverlay failed",Yc)}var i;Lc(i=this),Ic(i),this.requestId=requestAnimationFrame(this.render)}close(){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=null)}getSelectedObject(e="sprite|object|tile",t=!1){var n,i,r,s,a,o;if(this._freecamActive)return null;if((null==(i=null==(n=this.spritz.world)?void 0:n.spriteList)?void 0:i.length)<=0&&(null==(s=null==(r=this.spritz.world)?void 0:r.objectList)?void 0:s.length)<=0&&(null==(o=null==(a=this.spritz.world)?void 0:a.zoneList)?void 0:o.length)<=0)return null;const l=this.gl,c=new Uint8Array(4),h=this.gamepad.x||0,u=this.gamepad.y||0,d=t?0:h*l.canvas.width/l.canvas.clientWidth,f=t?0:l.canvas.height-u*l.canvas.height/l.canvas.clientHeight-1;l.readPixels(d,f,1,1,l.RGBA,l.UNSIGNED_BYTE,c);let p=c[0]+(c[1]<<8)+(c[2]<<16);return this.inputManager.isActionPressed("select")?(e.split("|").forEach(e=>{switch(e){case"sprite":this.spritz.world.spriteList=this.spritz.world.spriteList.map(e=>(e.objId===p?(e.isSelected=!0,this.spritz.world.spriteDict[e.id]&&(this.spritz.world.spriteDict[e.id].isSelected=!0,this.modeManager.handleSelect(e.zone,e,null,"sprite")||"function"==typeof this.spritz.world.spriteDict[e.id].onSelect&&this.spritz.world.spriteDict[e.id].onSelect(e.zone,e))):e.isSelected=!1,e));break;case"object":this.spritz.world.objectList=this.spritz.world.objectList.map(e=>(e.objId===p?(e.isSelected=!0,this.spritz.world.objectDict[e.id]&&(this.spritz.world.objectDict[e.id].isSelected=!0,this.modeManager.handleSelect(e.zone,e,null,"object")||"function"==typeof this.spritz.world.objectDict[e.id].onSelect&&this.spritz.world.objectDict[e.id].onSelect(e.zone,e))):e.isSelected=!1,e));break;case"tile":let e=c[0],t=c[1],n=c[2];this.spritz.world.zoneList.forEach(i=>{i.objId===e&&(this.modeManager.handleSelect(i,t,n,"tile")||"function"==typeof i.onSelect&&i.onSelect(t,n))}),0!==p&&console.log("TILE SELECTION:",{zoneObjId:e,row:t,cell:n,zones:this.spritz.world.zoneList})}}),p):p}setGreeting(e){this.globalStore?this.globalStore.greeting=e:console.warn("globalStore is not available to set greeting.")}speechSynthesis(e,t=null,n="en",i=null,r=null,s=null){let a=this.voice,o=window.speechSynthesis.getVoices()??[];a.voice=t||o[0],i&&(a.rate=i),r&&(a.volume=r),s&&(a.pitch=s),a.text=e,a.lang=n,window.speechSynthesis.speak(a)}screenSize(){return{width:this.canvas.clientWidth,height:this.canvas.clientHeight}}handleResize(){if(!this.gl||!this.ctx)return;const e=this.canvas.clientWidth,t=this.canvas.clientHeight;this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t,this.hudCanvas&&(this.hudCanvas.width=e,this.hudCanvas.height=t),this.width=e,this.height=t,this.gl.viewport(0,0,e,t),this.renderManager&&this.renderManager.handleResize&&this.renderManager.handleResize(e,t),this.inputManager&&this.inputManager.gamepad&&this.inputManager.gamepad.resize(),this.hud&&this.hud.handleResize&&this.hud.handleResize(e,t))}}const Rc=({width:t,height:n,SpritzProvider:i,class:r,zipData:s})=>{const a=e.useRef(),o=e.useRef(),l=e.useRef(),c=e.useRef(),h=e.useRef(),u=e=>{try{i&&i.onKeyEvent&&i.onKeyEvent(e)}catch(t){}},d=e=>{try{const t=o.current;if(!t)return void(i&&i.onTouchEvent&&i.onTouchEvent(e));const n=t.getBoundingClientRect();let r,s;e.touches&&e.touches.length>0?(r=e.touches[0].clientX,s=e.touches[0].clientY):e.changedTouches&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,s=e.changedTouches[0].clientY):(r=e.clientX,s=e.clientY);const a=t.width/n.width,l=t.height/n.height,c=(r-n.left)*a,h=(s-n.top)*l,u={...e,type:e.type,clientX:r,clientY:s,canvasX:c,canvasY:h,pageX:c+n.left,pageY:h+n.top,_canvasRect:n,_scaleX:a,_scaleY:l};i&&i.onTouchEvent&&i.onTouchEvent(u)}catch(t){console.warn("onTouchEvent error:",t)}};let f=null;const[p,g]=e.useState({dynamicWidth:window.innerWidth,dynamicHeight:window.innerHeight}),m=()=>{g({dynamicWidth:window.innerWidth,dynamicHeight:window.innerHeight})};function b(e){document.body.addEventListener("touchstart",function(t){t.target==e&&t.preventDefault()},{passive:!1}),document.body.addEventListener("touchend",function(t){t.target==e&&t.preventDefault()},{passive:!1}),document.body.addEventListener("touchmove",function(t){t.target==e&&t.preventDefault()},{passive:!1})}e.useEffect(async()=>{window.addEventListener("resize",m);const e=a.current,r=o.current,s=h.current,u=l.current,d=c.current;f=new Dc(e,r,s,u,d,t,n),await async function(){await ps.load(),document.fonts.add(ps)}(),await f.init(i);let p=null;return"undefined"!=typeof ResizeObserver&&(p=new ResizeObserver(t=>{for(const n of t)n.target!==e&&n.target!==r||f&&f.handleResize&&f.handleResize()}),p.observe(e),p.observe(r)),f.render(),()=>{b(e),b(u),b(r),window.removeEventListener("resize",m),p&&p.disconnect(),f.close()}},[i]);let v=3*p.dynamicWidth/4>1080?1080:p.dynamicHeight,w=3*p.dynamicWidth/4>1080?v:v-200,x=p.dynamicWidth>1920?1920:p.dynamicWidth,_=p.dynamicWidth<=900;return y.jsxs("div",{style:{marginLeft:"auto",marginRight:"auto"},children:[y.jsx("div",{style:{position:"relative",padding:"none",background:"var(--color-bg, #0a0a0f)",height:w+"px",width:x+"px"},onKeyDownCapture:e=>u(e.nativeEvent),onKeyUpCapture:e=>u(e.nativeEvent),tabIndex:0,children:y.jsxs("div",{children:[y.jsx("canvas",{style:{position:"absolute",zIndex:1,top:0,left:0,width:"100%",height:"100%"},ref:a,width:x,height:w,className:r}),y.jsx("canvas",{style:{position:"absolute",zIndex:2,top:0,left:0,background:"none",width:"100%",height:"100%",touchAction:"none",cursor:"pointer"},ref:o,width:x,height:w,className:r,onMouseUp:e=>{e.stopPropagation(),d(e.nativeEvent)},onMouseDown:e=>{e.stopPropagation(),d(e.nativeEvent)},onMouseMove:e=>{e.stopPropagation(),d(e.nativeEvent)},onClick:e=>{e.stopPropagation(),d(e.nativeEvent)},onTouchStart:e=>{e.stopPropagation(),d(e.nativeEvent)},onTouchEnd:e=>{e.stopPropagation(),d(e.nativeEvent)},onTouchMove:e=>{e.stopPropagation(),d(e.nativeEvent)},onTouchCancel:e=>{e.stopPropagation(),d(e.nativeEvent)}}),y.jsx("canvas",{style:{display:"none"},ref:h,width:256,height:256})]})}),y.jsx("div",{style:{width:x+"px",height:_?"200px":"1px",marginTop:_?"10px":"0px",position:"relative",overflow:"hidden"},children:y.jsx("canvas",{style:{position:"absolute",zIndex:5,top:0,left:0,background:"none",width:"100%",height:"100%",display:_?"block":"none"},ref:l,width:x,height:200,className:r,onMouseUp:e=>d(e.nativeEvent),onMouseDown:e=>d(e.nativeEvent),onMouseMove:e=>d(e.nativeEvent),onTouchMoveCapture:e=>d(e.nativeEvent),onTouchCancelCapture:e=>d(e.nativeEvent),onTouchStartCapture:e=>d(e.nativeEvent),onTouchEndCapture:e=>d(e.nativeEvent)})}),y.jsx("div",{children:y.jsx("input",{type:"file",ref:c,src:s??null,hidden:!0})})]})};Rc.propTypes={width:Qe.number.isRequired,height:Qe.number.isRequired,SpritzProvider:Qe.object.isRequired,class:Qe.string.isRequired};var Oc={exports:{}};!function(e){!function(){function t(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}function n(e,t,n){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){l(i.response,t,n)},i.onerror=function(){console.error("could not download file")},i.send()}function i(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(n){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof s&&s.global===s?s:void 0,o=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,t,s){var o=a.URL||a.webkitURL,l=document.createElement("a");t=t||e.name||"download",l.download=t,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):i(l.href)?n(e,t,s):r(l,l.target="_blank")):(l.href=o.createObjectURL(e),setTimeout(function(){o.revokeObjectURL(l.href)},4e4),setTimeout(function(){r(l)},0))}:"msSaveOrOpenBlob"in navigator?function(e,s,a){if(s=s||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(t(e,a),s);else if(i(e))n(e,s,a);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout(function(){r(o)})}}:function(e,t,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return n(e,t,i);var s="application/octet-stream"===e.type,l=/constructor/i.test(a.HTMLElement)||a.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&l||o)&&"undefined"!=typeof FileReader){var h=new FileReader;h.onloadend=function(){var e=h.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},h.readAsDataURL(e)}else{var u=a.URL||a.webkitURL,d=u.createObjectURL(e);r?r.location=d:location.href=d,r=null,setTimeout(function(){u.revokeObjectURL(d)},4e4)}});a.saveAs=l.saveAs=l,e.exports=l}()}(Oc);var Bc=Oc.exports;function Fc(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jc={exports:{}};
|
|
2
|
+
/*!
|
|
3
|
+
|
|
4
|
+
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
5
|
+
<http://stuartk.com/jszip>
|
|
6
|
+
|
|
7
|
+
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
|
8
|
+
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
|
9
|
+
|
|
10
|
+
JSZip uses the library pako released under the MIT license :
|
|
11
|
+
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
12
|
+
*/!function(e){e.exports=function e(t,n,i){function r(a,o){if(!n[a]){if(!t[a]){if(!o&&Fc)return Fc(a);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){return r(t[a][1][e]||e)},c,c.exports,e,t,n,i)}return n[a].exports}for(var s=Fc,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(e,t,n){var i=e("./utils"),r=e("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(e){for(var t,n,r,a,o,l,c,h=[],u=0,d=e.length,f=d,p="string"!==i.getTypeOf(e);u<e.length;)f=d-u,r=p?(t=e[u++],n=u<d?e[u++]:0,u<d?e[u++]:0):(t=e.charCodeAt(u++),n=u<d?e.charCodeAt(u++):0,u<d?e.charCodeAt(u++):0),a=t>>2,o=(3&t)<<4|n>>4,l=1<f?(15&n)<<2|r>>6:64,c=2<f?63&r:64,h.push(s.charAt(a)+s.charAt(o)+s.charAt(l)+s.charAt(c));return h.join("")},n.decode=function(e){var t,n,i,a,o,l,c=0,h=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var d,f=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===s.charAt(64)&&f--,e.charAt(e.length-2)===s.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=r.uint8array?new Uint8Array(0|f):new Array(0|f);c<e.length;)t=s.indexOf(e.charAt(c++))<<2|(a=s.indexOf(e.charAt(c++)))>>4,n=(15&a)<<4|(o=s.indexOf(e.charAt(c++)))>>2,i=(3&o)<<6|(l=s.indexOf(e.charAt(c++))),d[h++]=t,64!==o&&(d[h++]=n),64!==l&&(d[h++]=i);return d}},{"./support":30,"./utils":32}],2:[function(e,t,n){var i=e("./external"),r=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}o.prototype={getContentWorker:function(){var e=new r(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new r(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,n){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var i=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var i=e("./utils"),r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==i.getTypeOf(e)?function(e,t,n,i){var s=r,a=i+n;e^=-1;for(var o=i;o<a;o++)e=e>>>8^s[255&(e^t[o])];return-1^e}(0|t,e,e.length,0):function(e,t,n,i){var s=r,a=i+n;e^=-1;for(var o=i;o<a;o++)e=e>>>8^s[255&(e^t.charCodeAt(o))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){var i=null;i="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:i}},{lie:37}],7:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,r=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=i?"uint8array":"array";function l(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",s.inherits(l,a),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function i(e,t){var n,i="";for(n=0;n<t;n++)i+=String.fromCharCode(255&e),e>>>=8;return i}function r(e,t,n,r,a,h){var u,d,f=e.file,p=e.compression,g=h!==o.utf8encode,m=s.transformTo("string",h(f.name)),y=s.transformTo("string",o.utf8encode(f.name)),b=f.comment,v=s.transformTo("string",h(b)),w=s.transformTo("string",o.utf8encode(b)),x=y.length!==f.name.length,_=w.length!==b.length,k="",S="",M="",A=f.dir,T=f.date,E={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(E.crc32=e.crc32,E.compressedSize=e.compressedSize,E.uncompressedSize=e.uncompressedSize);var P=0;t&&(P|=8),g||!x&&!_||(P|=2048);var C,z,L,I=0,D=0;A&&(I|=16),"UNIX"===a?(D=798,I|=(C=f.unixPermissions,z=A,L=C,C||(L=z?16893:33204),(65535&L)<<16)):(D=20,I|=function(e){return 63&(e||0)}(f.dosPermissions)),u=T.getUTCHours(),u<<=6,u|=T.getUTCMinutes(),u<<=5,u|=T.getUTCSeconds()/2,d=T.getUTCFullYear()-1980,d<<=4,d|=T.getUTCMonth()+1,d<<=5,d|=T.getUTCDate(),x&&(S=i(1,1)+i(l(m),4)+y,k+="up"+i(S.length,2)+S),_&&(M=i(1,1)+i(l(v),4)+w,k+="uc"+i(M.length,2)+M);var R="";return R+="\n\0",R+=i(P,2),R+=p.magic,R+=i(u,2),R+=i(d,2),R+=i(E.crc32,4),R+=i(E.compressedSize,4),R+=i(E.uncompressedSize,4),R+=i(m.length,2),R+=i(k.length,2),{fileRecord:c.LOCAL_FILE_HEADER+R+m+k,dirRecord:c.CENTRAL_FILE_HEADER+i(D,2)+R+i(v.length,2)+"\0\0\0\0"+i(I,4)+i(r,4)+m+k+v}}var s=e("../utils"),a=e("../stream/GenericWorker"),o=e("../utf8"),l=e("../crc32"),c=e("../signature");function h(e,t,n,i){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,a),h.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,a.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=r(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t,n=this.streamFiles&&!e.file.dir,s=r(e,n,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(s.dirRecord),n)this.push({data:(t=e,c.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:s.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n,r,a,o,l,h,u=this.bytesWritten-e,d=(n=this.dirRecords.length,r=u,a=e,o=this.zipComment,l=this.encodeFileName,h=s.transformTo("string",l(o)),c.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(n,2)+i(n,2)+i(r,4)+i(a,4)+i(h.length,2)+h);this.push({data:d,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},h.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(e){var t=this._sources;if(!a.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch(i){}return!0},h.prototype.lock=function(){a.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,n){var i=e("../compressions"),r=e("./ZipFileWorker");n.generateWorker=function(e,t,n){var s=new r(t.streamFiles,n,t.platform,t.encodeFileName),a=0;try{e.forEach(function(e,n){a++;var r=function(e,t){var n=e||t,r=i[n];if(!r)throw new Error(n+" is not a valid compression method !");return r}(n.options.compression,t.compression),o=n.options.compressionOptions||t.compressionOptions||{},l=n.dir,c=n.date;n._compressWorker(r,o).withStreamInfo("file",{name:e,dir:l,date:c,comment:n.comment||"",unixPermissions:n.unixPermissions,dosPermissions:n.dosPermissions}).pipe(s)}),s.entriesCount=a}catch(o){s.error(o)}return s}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,n){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new i;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(e,t){return(new i).loadAsync(e,t)},i.external=e("./external"),t.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,n){var i=e("./utils"),r=e("./external"),s=e("./utf8"),a=e("./zipEntries"),o=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function c(e){return new r.Promise(function(t,n){var i=e.decompressed.getContentWorker().pipe(new o);i.on("error",function(e){n(e)}).on("end",function(){i.streamInfo.crc32!==e.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}t.exports=function(e,t){var n=this;return t=i.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),l.isNode&&l.isStream(e)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(e){var n=new a(t);return n.load(e),n}).then(function(e){var n=[r.Promise.resolve(e)],i=e.files;if(t.checkCRC32)for(var s=0;s<i.length;s++)n.push(c(i[s]));return r.Promise.all(n)}).then(function(e){for(var r=e.shift(),s=r.files,a=0;a<s.length;a++){var o=s[a],l=o.fileNameStr,c=i.resolve(o.fileNameStr);n.file(c,o.decompressed,{binary:!0,optimizedBinaryString:!0,date:o.date,dir:o.dir,comment:o.fileCommentStr.length?o.fileCommentStr:null,unixPermissions:o.unixPermissions,dosPermissions:o.dosPermissions,createFolders:t.createFolders}),o.dir||(n.file(c).unsafeOriginalName=l)}return r.zipComment.length&&(n.comment=r.zipComment),n})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,n){var i=e("../utils"),r=e("../stream/GenericWorker");function s(e,t){r.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}i.inherits(s,r),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,n){var i=e("readable-stream").Readable;function r(e,t,n){i.call(this,t),this._helper=e;var r=this;e.on("data",function(e,t){r.push(e)||r._helper.pause(),n&&n(t)}).on("error",function(e){r.emit("error",e)}).on("end",function(){r.push(null)})}e("../utils").inherits(r,i),r.prototype._read=function(){this._helper.resume()},t.exports=r},{"../utils":32,"readable-stream":16}],14:[function(e,t,n){t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,n){function i(e,t,n){var i,r=s.getTypeOf(t),o=s.extend(n||{},l);o.date=o.date||new Date,null!==o.compression&&(o.compression=o.compression.toUpperCase()),"string"==typeof o.unixPermissions&&(o.unixPermissions=parseInt(o.unixPermissions,8)),o.unixPermissions&&16384&o.unixPermissions&&(o.dir=!0),o.dosPermissions&&16&o.dosPermissions&&(o.dir=!0),o.dir&&(e=g(e)),o.createFolders&&(i=p(e))&&m.call(this,i,!0);var u="string"===r&&!1===o.binary&&!1===o.base64;n&&void 0!==n.binary||(o.binary=!u),(t instanceof c&&0===t.uncompressedSize||o.dir||!t||0===t.length)&&(o.base64=!1,o.binary=!0,t="",o.compression="STORE",r="string");var y=null;y=t instanceof c||t instanceof a?t:d.isNode&&d.isStream(t)?new f(e,t):s.prepareContent(e,t,o.binary,o.optimizedBinaryString,o.base64);var b=new h(e,y,o);this.files[e]=b}var r=e("./utf8"),s=e("./utils"),a=e("./stream/GenericWorker"),o=e("./stream/StreamHelper"),l=e("./defaults"),c=e("./compressedObject"),h=e("./zipObject"),u=e("./generate"),d=e("./nodejsUtils"),f=e("./nodejs/NodejsStreamInputAdapter"),p=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},m=function(e,t){return t=void 0!==t?t:l.createFolders,e=g(e),this.files[e]||i.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function y(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var b={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,i;for(t in this.files)i=this.files[t],(n=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(n,i)},filter:function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(i)}),t},file:function(e,t,n){if(1!==arguments.length)return e=this.root+e,i.call(this,e,t,n),this;if(y(e)){var r=e;return this.filter(function(e,t){return!t.dir&&r.test(e)})}var s=this.files[this.root+e];return s&&!s.dir?s:null},folder:function(e){if(!e)return this;if(y(e))return this.filter(function(t,n){return n.dir&&e.test(t)});var t=this.root+e,n=m.call(this,t),i=this.clone();return i.root=n.name,i},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter(function(t,n){return n.name.slice(0,e.length)===e}),i=0;i<n.length;i++)delete this.files[n[i].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,n={};try{if((n=s.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=n.type.toLowerCase(),n.compression=n.compression.toUpperCase(),"binarystring"===n.type&&(n.type="string"),!n.type)throw new Error("No output type specified.");s.checkSupport(n.type),"darwin"!==n.platform&&"freebsd"!==n.platform&&"linux"!==n.platform&&"sunos"!==n.platform||(n.platform="UNIX"),"win32"===n.platform&&(n.platform="DOS");var i=n.comment||this.comment||"";t=u.generateWorker(this,n,i)}catch(l){(t=new a("error")).error(l)}return new o(t,n.type||"string",n.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=b},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,n){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,n){var i=e("./DataReader");function r(e){i.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(r,i),r.prototype.byteAt=function(e){return this.data[this.zero+e]},r.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===n&&this.data[s+2]===i&&this.data[s+3]===r)return s-this.zero;return-1},r.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&n===s[1]&&i===s[2]&&r===s[3]},r.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./DataReader":18}],18:[function(e,t,n){var i=e("../utils");function r(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,n=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return i.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=r},{"../utils":32}],19:[function(e,t,n){var i=e("./Uint8ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var i=e("./DataReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},r.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},r.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var i=e("./ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var i=e("../utils"),r=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=i.getTypeOf(e);return i.checkSupport(t),"string"!==t||r.uint8array?"nodebuffer"===t?new o(e):r.uint8array?new l(i.transformTo("uint8array",e)):new s(i.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){var i=e("./GenericWorker"),r=e("../utils");function s(e){i.call(this,"ConvertWorker to "+e),this.destType=e}r.inherits(s,i),s.prototype.processChunk=function(e){this.push({data:r.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var i=e("./GenericWorker"),r=e("../crc32");function s(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,i),s.prototype.processChunk=function(e){this.streamInfo.crc32=r(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var i=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}i.inherits(s,r),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}r.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var i=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}i.inherits(s,r),s.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function i(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=i},{}],29:[function(e,t,n){var i=e("../utils"),r=e("./ConvertWorker"),s=e("./GenericWorker"),a=e("../base64"),o=e("../support"),l=e("../external"),c=null;if(o.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(d){}function h(e,t){return new l.Promise(function(n,r){var s=[],o=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",function(e,n){s.push(e),t&&t(n)}).on("error",function(e){s=[],r(e)}).on("end",function(){try{var e=function(e,t,n){switch(e){case"blob":return i.newBlob(i.transformTo("arraybuffer",t),n);case"base64":return a.encode(t);default:return i.transformTo(e,t)}}(l,function(e,t){var n,i=0,r=null,s=0;for(n=0;n<t.length;n++)s+=t[n].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(r=new Uint8Array(s),n=0;n<t.length;n++)r.set(t[n],i),i+=t[n].length;return r;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(o,s),c);n(e)}catch(t){r(t)}s=[]}).resume()})}function u(e,t,n){var a=t;switch(t){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=t,this._mimeType=n,i.checkSupport(a),this._worker=e.pipe(new r(a)),e.lock()}catch(o){this._worker=new s("error"),this._worker.error(o)}}u.prototype={accumulate:function(e){return h(this,e)},on:function(e,t){var n=this;return"data"===e?this._worker.on(e,function(e){t.call(n,e.data,e.meta)}):this._worker.on(e,function(){i.delay(t,arguments,n)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(i.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new c(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,n.nodebuffer="undefined"!=typeof Buffer,n.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)n.blob=!1;else{var i=new ArrayBuffer(0);try{n.blob=0===new Blob([i],{type:"application/zip"}).size}catch(s){try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(i),n.blob=0===r.getBlob("application/zip").size}catch(a){n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch(s){n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var i=e("./utils"),r=e("./support"),s=e("./nodejsUtils"),a=e("./stream/GenericWorker"),o=new Array(256),l=0;l<256;l++)o[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function c(){a.call(this,"utf-8 decode"),this.leftOver=null}function h(){a.call(this,"utf-8 encode")}o[254]=o[254]=1,n.utf8encode=function(e){return r.nodebuffer?s.newBufferFrom(e,"utf-8"):function(e){var t,n,i,s,a,o=e.length,l=0;for(s=0;s<o;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=r.uint8array?new Uint8Array(l):new Array(l),s=a=0;a<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),n<128?t[a++]=n:(n<2048?t[a++]=192|n>>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t}(e)},n.utf8decode=function(e){return r.nodebuffer?i.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,r,s,a=e.length,l=new Array(2*a);for(t=n=0;t<a;)if((r=e[t++])<128)l[n++]=r;else if(4<(s=o[r]))l[n++]=65533,t+=s-1;else{for(r&=2===s?31:3===s?15:7;1<s&&t<a;)r=r<<6|63&e[t++],s--;1<s?l[n++]=65533:r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|1023&r)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),i.applyFromCharCode(l)}(e=i.transformTo(r.uint8array?"uint8array":"array",e))},i.inherits(c,a),c.prototype.processChunk=function(e){var t=i.transformTo(r.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var a=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+o[e[n]]>t?n:t}(t),l=t;a!==t.length&&(r.uint8array?(l=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(l=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,i.inherits(h,a),h.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var i=e("./support"),r=e("./base64"),s=e("./nodejsUtils"),a=e("./external");function o(e){return e}function l(e,t){for(var n=0;n<e.length;++n)t[n]=255&e.charCodeAt(n);return t}e("setimmediate"),n.newBlob=function(e,t){n.checkSupport("blob");try{return new Blob([e],{type:t})}catch(r){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return i.append(e),i.getBlob(t)}catch(s){throw new Error("Bug : can't construct the Blob.")}}};var c={stringifyByChunk:function(e,t,n){var i=[],r=0,s=e.length;if(s<=n)return String.fromCharCode.apply(null,e);for(;r<s;)"array"===t||"nodebuffer"===t?i.push(String.fromCharCode.apply(null,e.slice(r,Math.min(r+n,s)))):i.push(String.fromCharCode.apply(null,e.subarray(r,Math.min(r+n,s)))),r+=n;return i.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&1===String.fromCharCode.apply(null,s.allocBuffer(1)).length}catch(e){return!1}}()}};function h(e){var t=65536,i=n.getTypeOf(e),r=!0;if("uint8array"===i?r=c.applyCanBeUsed.uint8array:"nodebuffer"===i&&(r=c.applyCanBeUsed.nodebuffer),r)for(;1<t;)try{return c.stringifyByChunk(e,i,t)}catch(s){t=Math.floor(t/2)}return c.stringifyByChar(e)}function u(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}n.applyFromCharCode=h;var d={};d.string={string:o,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return d.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,s.allocBuffer(e.length))}},d.array={string:h,array:o,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(e)}},d.arraybuffer={string:function(e){return h(new Uint8Array(e))},array:function(e){return u(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:o,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return s.newBufferFrom(new Uint8Array(e))}},d.uint8array={string:h,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:o,nodebuffer:function(e){return s.newBufferFrom(e)}},d.nodebuffer={string:h,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return d.nodebuffer.uint8array(e).buffer},uint8array:function(e){return u(e,new Uint8Array(e.length))},nodebuffer:o},n.transformTo=function(e,t){if(t=t||"",!e)return t;n.checkSupport(e);var i=n.getTypeOf(t);return d[i][e](t)},n.resolve=function(e){for(var t=e.split("/"),n=[],i=0;i<t.length;i++){var r=t[i];"."===r||""===r&&0!==i&&i!==t.length-1||(".."===r?n.pop():n.push(r))}return n.join("/")},n.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":i.nodebuffer&&s.isBuffer(e)?"nodebuffer":i.uint8array&&e instanceof Uint8Array?"uint8array":i.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(e){if(!i[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(e){var t,n,i="";for(n=0;n<(e||"").length;n++)i+="\\x"+((t=e.charCodeAt(n))<16?"0":"")+t.toString(16).toUpperCase();return i},n.delay=function(e,t,n){setImmediate(function(){e.apply(n||null,t||[])})},n.inherits=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},n.extend=function(){var e,t,n={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===n[t]&&(n[t]=arguments[e][t]);return n},n.prepareContent=function(e,t,s,o,c){return a.Promise.resolve(t).then(function(e){return i.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new a.Promise(function(t,n){var i=new FileReader;i.onload=function(e){t(e.target.result)},i.onerror=function(e){n(e.target.error)},i.readAsArrayBuffer(e)}):e}).then(function(t){var h,u=n.getTypeOf(t);return u?("arraybuffer"===u?t=n.transformTo("uint8array",t):"string"===u&&(c?t=r.decode(t):s&&!0!==o&&(t=l(h=t,i.uint8array?new Uint8Array(h.length):new Array(h.length)))),t):a.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,n){var i=e("./reader/readerFor"),r=e("./utils"),s=e("./signature"),a=e("./zipEntry"),o=e("./support");function l(e){this.files=[],this.loadOptions=e}l.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(t)+", expected "+r.pretty(e)+")")}},isSignature:function(e,t){var n=this.reader.index;this.reader.setIndex(e);var i=this.reader.readString(4)===t;return this.reader.setIndex(n),i},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=o.uint8array?"uint8array":"array",n=r.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,n,i=this.zip64EndOfCentralSize-44;0<i;)e=this.reader.readInt(2),t=this.reader.readInt(4),n=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:n}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var n=this.centralDirOffset+this.centralDirSize;this.zip64&&(n+=20,n+=12+this.zip64EndOfCentralSize);var i=t-n;if(0<i)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=i);else if(i<0)throw new Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},prepareReader:function(e){this.reader=i(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,n){var i=e("./reader/readerFor"),r=e("./utils"),s=e("./compressedObject"),a=e("./crc32"),o=e("./utf8"),l=e("./compressions"),c=e("./support");function h(e,t){this.options=e,this.loadOptions=t}h.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(Object.prototype.hasOwnProperty.call(l,t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=i(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,i,r=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<r;)t=e.readInt(2),n=e.readInt(2),i=e.readData(n),this.extraFields[t]={id:t,length:n,value:i};e.setIndex(r)},handleUTF8:function(){var e=c.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var n=r.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(n)}var i=this.findExtraFieldUnicodeComment();if(null!==i)this.fileCommentStr=i;else{var s=r.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(s)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=i(e.value);return 1!==t.readInt(1)||a(this.fileName)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=i(e.value);return 1!==t.readInt(1)||a(this.fileComment)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null}},t.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,n){function i(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}}var r=e("./stream/StreamHelper"),s=e("./stream/DataWorker"),a=e("./utf8"),o=e("./compressedObject"),l=e("./stream/GenericWorker");i.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");var i="string"===(n=e.toLowerCase())||"text"===n;"binarystring"!==n&&"text"!==n||(n="string"),t=this._decompressWorker();var s=!this._dataBinary;s&&!i&&(t=t.pipe(new a.Utf8EncodeWorker)),!s&&i&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(o){(t=new l("error")).error(o)}return new r(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof o&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(n,e,t)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof l?this._data:new s(this._data)}};for(var c=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<c.length;u++)i.prototype[c[u]]=h;t.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,n){(function(e){var n,i,r=e.MutationObserver||e.WebKitMutationObserver;if(r){var s=0,a=new r(h),o=e.document.createTextNode("");a.observe(o,{characterData:!0}),n=function(){o.data=s=++s%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){h(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(h,0)};else{var l=new e.MessageChannel;l.port1.onmessage=h,n=function(){l.port2.postMessage(0)}}var c=[];function h(){var e,t;i=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}i=!1}t.exports=function(e){1!==c.push(e)||i||n()}}).call(this,void 0!==s?s:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,n){var i=e("immediate");function r(){}var s={},a=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==r&&f(this,e)}function h(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(e,t,n){i(function(){var i;try{i=t(n)}catch(r){return s.reject(e,r)}i===e?s.reject(e,new TypeError("Cannot resolve promise with itself")):s.resolve(e,i)})}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var n=!1;function i(t){n||(n=!0,s.reject(e,t))}function r(t){n||(n=!0,s.resolve(e,t))}var a=p(function(){t(r,i)});"error"===a.status&&i(a.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(i){n.status="error",n.value=i}return n}(t.exports=c).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})},c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===o||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(r);return this.state!==l?u(n,this.state===o?e:t,this.outcome):this.queue.push(new h(n,e,t)),n},h.prototype.callFulfilled=function(e){s.resolve(this.promise,e)},h.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},h.prototype.callRejected=function(e){s.reject(this.promise,e)},h.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},s.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return s.reject(e,n.value);var i=n.value;if(i)f(e,i);else{e.state=o,e.outcome=t;for(var r=-1,a=e.queue.length;++r<a;)e.queue[r].callFulfilled(t)}return e},s.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},c.resolve=function(e){return e instanceof this?e:s.resolve(new this(r),e)},c.reject=function(e){var t=new this(r);return s.reject(t,e)},c.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a=new Array(n),o=0,l=-1,c=new this(r);++l<n;)h(e[l],l);return c;function h(e,r){t.resolve(e).then(function(e){a[r]=e,++o!==n||i||(i=!0,s.resolve(c,a))},function(e){i||(i=!0,s.reject(c,e))})}},c.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var a,o=-1,l=new this(r);++o<n;)a=e[o],t.resolve(a).then(function(e){i||(i=!0,s.resolve(l,e))},function(e){i||(i=!0,s.reject(l,e))});return l}},{immediate:36}],38:[function(e,t,n){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,n){var i=e("./zlib/deflate"),r=e("./utils/common"),s=e("./utils/strings"),a=e("./zlib/messages"),o=e("./zlib/zstream"),l=Object.prototype.toString,c=0,h=-1,u=0,d=8;function f(e){if(!(this instanceof f))return new f(e);this.options=r.assign({level:h,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var n=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==c)throw new Error(a[n]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(n=i.deflateSetDictionary(this.strm,p))!==c)throw new Error(a[n]);this._dict_set=!0}}function p(e,t){var n=new f(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}f.prototype.push=function(e,t){var n,a,o=this.strm,h=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?o.input=s.string2buf(e):"[object ArrayBuffer]"===l.call(e)?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new r.Buf8(h),o.next_out=0,o.avail_out=h),1!==(n=i.deflate(o,a))&&n!==c)return this.onEnd(n),!(this.ended=!0);0!==o.avail_out&&(0!==o.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(o.output,o.next_out))):this.onData(r.shrinkBuf(o.output,o.next_out)))}while((0<o.avail_in||0===o.avail_out)&&1!==n);return 4===a?(n=i.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===c):2!==a||(this.onEnd(c),!(o.avail_out=0))},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===c&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=f,n.deflate=p,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,n){var i=e("./zlib/inflate"),r=e("./utils/common"),s=e("./utils/strings"),a=e("./zlib/constants"),o=e("./zlib/messages"),l=e("./zlib/zstream"),c=e("./zlib/gzheader"),h=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var n=i.inflateInit2(this.strm,t.windowBits);if(n!==a.Z_OK)throw new Error(o[n]);this.header=new c,i.inflateGetHeader(this.strm,this.header)}function d(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}u.prototype.push=function(e,t){var n,o,l,c,u,d,f=this.strm,p=this.options.chunkSize,g=this.options.dictionary,m=!1;if(this.ended)return!1;o=t===~~t?t:!0===t?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof e?f.input=s.binstring2buf(e):"[object ArrayBuffer]"===h.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new r.Buf8(p),f.next_out=0,f.avail_out=p),(n=i.inflate(f,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&g&&(d="string"==typeof g?s.string2buf(g):"[object ArrayBuffer]"===h.call(g)?new Uint8Array(g):g,n=i.inflateSetDictionary(this.strm,d)),n===a.Z_BUF_ERROR&&!0===m&&(n=a.Z_OK,m=!1),n!==a.Z_STREAM_END&&n!==a.Z_OK)return this.onEnd(n),!(this.ended=!0);f.next_out&&(0!==f.avail_out&&n!==a.Z_STREAM_END&&(0!==f.avail_in||o!==a.Z_FINISH&&o!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(l=s.utf8border(f.output,f.next_out),c=f.next_out-l,u=s.buf2string(f.output,l),f.next_out=c,f.avail_out=p-c,c&&r.arraySet(f.output,f.output,l,c,0),this.onData(u)):this.onData(r.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(m=!0)}while((0<f.avail_in||0===f.avail_out)&&n!==a.Z_STREAM_END);return n===a.Z_STREAM_END&&(o=a.Z_FINISH),o===a.Z_FINISH?(n=i.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===a.Z_OK):o!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(f.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=u,n.inflate=d,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},n.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+i),r);else for(var s=0;s<i;s++)e[r+s]=t[n+s]},flattenChunks:function(e){var t,n,i,r,s,a;for(t=i=0,n=e.length;t<n;t++)i+=e[t].length;for(a=new Uint8Array(i),t=r=0,n=e.length;t<n;t++)s=e[t],a.set(s,r),r+=s.length;return a}},s={arraySet:function(e,t,n,i,r){for(var s=0;s<i;s++)e[r+s]=t[n+s]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,r)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(i)},{}],42:[function(e,t,n){var i=e("./common"),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(c){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(c){s=!1}for(var a=new i.Buf8(256),o=0;o<256;o++)a[o]=252<=o?6:248<=o?5:240<=o?4:224<=o?3:192<=o?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var n="",a=0;a<t;a++)n+=String.fromCharCode(e[a]);return n}a[254]=a[254]=1,n.string2buf=function(e){var t,n,r,s,a,o=e.length,l=0;for(s=0;s<o;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=new i.Buf8(l),s=a=0;a<l;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(r=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(r-56320),s++),n<128?t[a++]=n:(n<2048?t[a++]=192|n>>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new i.Buf8(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,i,r,s,o=t||e.length,c=new Array(2*o);for(n=i=0;n<o;)if((r=e[n++])<128)c[i++]=r;else if(4<(s=a[r]))c[i++]=65533,n+=s-1;else{for(r&=2===s?31:3===s?15:7;1<s&&n<o;)r=r<<6|63&e[n++],s--;1<s?c[i++]=65533:r<65536?c[i++]=r:(r-=65536,c[i++]=55296|r>>10&1023,c[i++]=56320|1023&r)}return l(c,i)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,i){for(var r=65535&e,s=e>>>16&65535,a=0;0!==n;){for(n-=a=2e3<n?2e3:n;s=s+(r=r+t[i++]|0)|0,--a;);r%=65521,s%=65521}return r|s<<16}},{}],44:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,n){var i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,r){var s=i,a=r+n;e^=-1;for(var o=r;o<a;o++)e=e>>>8^s[255&(e^t[o])];return-1^e}},{}],46:[function(e,t,n){var i,r=e("../utils/common"),s=e("./trees"),a=e("./adler32"),o=e("./crc32"),l=e("./messages"),c=0,h=4,u=0,d=-2,f=-1,p=4,g=2,m=8,y=9,b=286,v=30,w=19,x=2*b+1,_=15,k=3,S=258,M=S+k+1,A=42,T=113,E=1,P=2,C=3,z=4;function L(e,t){return e.msg=l[t],t}function I(e){return(e<<1)-(4<e?9:0)}function D(e){for(var t=e.length;0<=--t;)e[t]=0}function R(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(r.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function O(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,R(e.strm)}function B(e,t){e.pending_buf[e.pending++]=t}function F(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function j(e,t){var n,i,r=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-M?e.strstart-(e.w_size-M):0,c=e.window,h=e.w_mask,u=e.prev,d=e.strstart+S,f=c[s+a-1],p=c[s+a];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(n=t)+a]===p&&c[n+a-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<d);if(i=S-(d-s),s=d-S,a<i){if(e.match_start=t,o<=(a=i))break;f=c[s+a-1],p=c[s+a]}}}while((t=u[t&h])>l&&0!=--r);return a<=e.lookahead?a:e.lookahead}function N(e){var t,n,i,s,l,c,h,u,d,f,p=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-M)){for(r.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=n=e.hash_size;i=e.head[--t],e.head[t]=p<=i?i-p:0,--n;);for(t=n=p;i=e.prev[--t],e.prev[t]=p<=i?i-p:0,--n;);s+=p}if(0===e.strm.avail_in)break;if(c=e.strm,h=e.window,u=e.strstart+e.lookahead,f=void 0,(d=s)<(f=c.avail_in)&&(f=d),n=0===f?0:(c.avail_in-=f,r.arraySet(h,c.input,c.next_in,f,u),1===c.state.wrap?c.adler=a(c.adler,h,f,u):2===c.state.wrap&&(c.adler=o(c.adler,h,f,u)),c.next_in+=f,c.total_in+=f,f),e.lookahead+=n,e.lookahead+e.insert>=k)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+k-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<k)););}while(e.lookahead<M&&0!==e.strm.avail_in)}function U(e,t){for(var n,i;;){if(e.lookahead<M){if(N(e),e.lookahead<M&&t===c)return E;if(0===e.lookahead)break}if(n=0,e.lookahead>=k&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+k-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-M&&(e.match_length=j(e,n)),e.match_length>=k)if(i=s._tr_tally(e,e.strstart-e.match_start,e.match_length-k),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=k){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+k-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(O(e,!1),0===e.strm.avail_out))return E}return e.insert=e.strstart<k-1?e.strstart:k-1,t===h?(O(e,!0),0===e.strm.avail_out?C:z):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?E:P}function $(e,t){for(var n,i,r;;){if(e.lookahead<M){if(N(e),e.lookahead<M&&t===c)return E;if(0===e.lookahead)break}if(n=0,e.lookahead>=k&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+k-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=k-1,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-M&&(e.match_length=j(e,n),e.match_length<=5&&(1===e.strategy||e.match_length===k&&4096<e.strstart-e.match_start)&&(e.match_length=k-1)),e.prev_length>=k&&e.match_length<=e.prev_length){for(r=e.strstart+e.lookahead-k,i=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-k),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+k-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=k-1,e.strstart++,i&&(O(e,!1),0===e.strm.avail_out))return E}else if(e.match_available){if((i=s._tr_tally(e,0,e.window[e.strstart-1]))&&O(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return E}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=s._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<k-1?e.strstart:k-1,t===h?(O(e,!0),0===e.strm.avail_out?C:z):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?E:P}function V(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}function W(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=m,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(2*x),this.dyn_dtree=new r.Buf16(2*(2*v+1)),this.bl_tree=new r.Buf16(2*(2*w+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(_+1),this.heap=new r.Buf16(2*b+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*b+1),D(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function H(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=g,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?A:T,e.adler=2===t.wrap?0:1,t.last_flush=c,s._tr_init(t),u):L(e,d)}function K(e){var t,n=H(e);return n===u&&((t=e.state).window_size=2*t.w_size,D(t.head),t.max_lazy_match=i[t.level].max_lazy,t.good_match=i[t.level].good_length,t.nice_match=i[t.level].nice_length,t.max_chain_length=i[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=k-1,t.match_available=0,t.ins_h=0),n}function Z(e,t,n,i,s,a){if(!e)return d;var o=1;if(t===f&&(t=6),i<0?(o=0,i=-i):15<i&&(o=2,i-=16),s<1||y<s||n!==m||i<8||15<i||t<0||9<t||a<0||p<a)return L(e,d);8===i&&(i=9);var l=new W;return(e.state=l).strm=e,l.wrap=o,l.gzhead=null,l.w_bits=i,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=s+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+k-1)/k),l.window=new r.Buf8(2*l.w_size),l.head=new r.Buf16(l.hash_size),l.prev=new r.Buf16(l.w_size),l.lit_bufsize=1<<s+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new r.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=a,l.method=n,K(e)}i=[new V(0,0,0,0,function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(N(e),0===e.lookahead&&t===c)return E;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,O(e,!1),0===e.strm.avail_out))return E;if(e.strstart-e.block_start>=e.w_size-M&&(O(e,!1),0===e.strm.avail_out))return E}return e.insert=0,t===h?(O(e,!0),0===e.strm.avail_out?C:z):(e.strstart>e.block_start&&(O(e,!1),e.strm.avail_out),E)}),new V(4,4,8,4,U),new V(4,5,16,8,U),new V(4,6,32,32,U),new V(4,4,16,16,$),new V(8,16,32,32,$),new V(8,16,128,128,$),new V(8,32,128,256,$),new V(32,128,258,1024,$),new V(32,258,258,4096,$)],n.deflateInit=function(e,t){return Z(e,t,m,15,8,0)},n.deflateInit2=Z,n.deflateReset=K,n.deflateResetKeep=H,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?d:(e.state.gzhead=t,u):d},n.deflate=function(e,t){var n,r,a,l;if(!e||!e.state||5<t||t<0)return e?L(e,d):d;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||666===r.status&&t!==h)return L(e,0===e.avail_out?-5:d);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===A)if(2===r.wrap)e.adler=0,B(r,31),B(r,139),B(r,8),r.gzhead?(B(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),B(r,255&r.gzhead.time),B(r,r.gzhead.time>>8&255),B(r,r.gzhead.time>>16&255),B(r,r.gzhead.time>>24&255),B(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),B(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(B(r,255&r.gzhead.extra.length),B(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=o(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(B(r,0),B(r,0),B(r,0),B(r,0),B(r,0),B(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),B(r,3),r.status=T);else{var f=m+(r.w_bits-8<<4)<<8;f|=(2<=r.strategy||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(f|=32),f+=31-f%31,r.status=T,F(r,f),0!==r.strstart&&(F(r,e.adler>>>16),F(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),R(e),a=r.pending,r.pending!==r.pending_buf_size));)B(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),R(e),a=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,B(r,l)}while(0!==l);r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),0===l&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),R(e),a=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,B(r,l)}while(0!==l);r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),0===l&&(r.status=103)}else r.status=103;if(103===r.status&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&R(e),r.pending+2<=r.pending_buf_size&&(B(r,255&e.adler),B(r,e.adler>>8&255),e.adler=0,r.status=T)):r.status=T),0!==r.pending){if(R(e),0===e.avail_out)return r.last_flush=-1,u}else if(0===e.avail_in&&I(t)<=I(n)&&t!==h)return L(e,-5);if(666===r.status&&0!==e.avail_in)return L(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==c&&666!==r.status){var p=2===r.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(N(e),0===e.lookahead)){if(t===c)return E;break}if(e.match_length=0,n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(O(e,!1),0===e.strm.avail_out))return E}return e.insert=0,t===h?(O(e,!0),0===e.strm.avail_out?C:z):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?E:P}(r,t):3===r.strategy?function(e,t){for(var n,i,r,a,o=e.window;;){if(e.lookahead<=S){if(N(e),e.lookahead<=S&&t===c)return E;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=k&&0<e.strstart&&(i=o[r=e.strstart-1])===o[++r]&&i===o[++r]&&i===o[++r]){a=e.strstart+S;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<a);e.match_length=S-(a-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=k?(n=s._tr_tally(e,1,e.match_length-k),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(O(e,!1),0===e.strm.avail_out))return E}return e.insert=0,t===h?(O(e,!0),0===e.strm.avail_out?C:z):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?E:P}(r,t):i[r.level].func(r,t);if(p!==C&&p!==z||(r.status=666),p===E||p===C)return 0===e.avail_out&&(r.last_flush=-1),u;if(p===P&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(D(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),R(e),0===e.avail_out))return r.last_flush=-1,u}return t!==h?u:r.wrap<=0?1:(2===r.wrap?(B(r,255&e.adler),B(r,e.adler>>8&255),B(r,e.adler>>16&255),B(r,e.adler>>24&255),B(r,255&e.total_in),B(r,e.total_in>>8&255),B(r,e.total_in>>16&255),B(r,e.total_in>>24&255)):(F(r,e.adler>>>16),F(r,65535&e.adler)),R(e),0<r.wrap&&(r.wrap=-r.wrap),0!==r.pending?u:1)},n.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==A&&69!==t&&73!==t&&91!==t&&103!==t&&t!==T&&666!==t?L(e,d):(e.state=null,t===T?L(e,-3):u):d},n.deflateSetDictionary=function(e,t){var n,i,s,o,l,c,h,f,p=t.length;if(!e||!e.state)return d;if(2===(o=(n=e.state).wrap)||1===o&&n.status!==A||n.lookahead)return d;for(1===o&&(e.adler=a(e.adler,t,p,0)),n.wrap=0,p>=n.w_size&&(0===o&&(D(n.head),n.strstart=0,n.block_start=0,n.insert=0),f=new r.Buf8(n.w_size),r.arraySet(f,t,p-n.w_size,n.w_size,0),t=f,p=n.w_size),l=e.avail_in,c=e.next_in,h=e.input,e.avail_in=p,e.next_in=0,e.input=t,N(n);n.lookahead>=k;){for(i=n.strstart,s=n.lookahead-(k-1);n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+k-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,--s;);n.strstart=i,n.lookahead=k-1,N(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=k-1,n.match_available=0,e.next_in=c,e.input=h,e.avail_in=l,n.wrap=o,u},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,n){t.exports=function(e,t){var n,i,r,s,a,o,l,c,h,u,d,f,p,g,m,y,b,v,w,x,_,k,S,M,A;n=e.state,i=e.next_in,M=e.input,r=i+(e.avail_in-5),s=e.next_out,A=e.output,a=s-(t-e.avail_out),o=s+(e.avail_out-257),l=n.dmax,c=n.wsize,h=n.whave,u=n.wnext,d=n.window,f=n.hold,p=n.bits,g=n.lencode,m=n.distcode,y=(1<<n.lenbits)-1,b=(1<<n.distbits)-1;e:do{p<15&&(f+=M[i++]<<p,p+=8,f+=M[i++]<<p,p+=8),v=g[f&y];t:for(;;){if(f>>>=w=v>>>24,p-=w,0==(w=v>>>16&255))A[s++]=65535&v;else{if(!(16&w)){if(!(64&w)){v=g[(65535&v)+(f&(1<<w)-1)];continue t}if(32&w){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}x=65535&v,(w&=15)&&(p<w&&(f+=M[i++]<<p,p+=8),x+=f&(1<<w)-1,f>>>=w,p-=w),p<15&&(f+=M[i++]<<p,p+=8,f+=M[i++]<<p,p+=8),v=m[f&b];n:for(;;){if(f>>>=w=v>>>24,p-=w,!(16&(w=v>>>16&255))){if(!(64&w)){v=m[(65535&v)+(f&(1<<w)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(_=65535&v,p<(w&=15)&&(f+=M[i++]<<p,(p+=8)<w&&(f+=M[i++]<<p,p+=8)),l<(_+=f&(1<<w)-1)){e.msg="invalid distance too far back",n.mode=30;break e}if(f>>>=w,p-=w,(w=s-a)<_){if(h<(w=_-w)&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(S=d,(k=0)===u){if(k+=c-w,w<x){for(x-=w;A[s++]=d[k++],--w;);k=s-_,S=A}}else if(u<w){if(k+=c+u-w,(w-=u)<x){for(x-=w;A[s++]=d[k++],--w;);if(k=0,u<x){for(x-=w=u;A[s++]=d[k++],--w;);k=s-_,S=A}}}else if(k+=u-w,w<x){for(x-=w;A[s++]=d[k++],--w;);k=s-_,S=A}for(;2<x;)A[s++]=S[k++],A[s++]=S[k++],A[s++]=S[k++],x-=3;x&&(A[s++]=S[k++],1<x&&(A[s++]=S[k++]))}else{for(k=s-_;A[s++]=A[k++],A[s++]=A[k++],A[s++]=A[k++],2<(x-=3););x&&(A[s++]=A[k++],1<x&&(A[s++]=A[k++]))}break}}break}}while(i<r&&s<o);i-=x=p>>3,f&=(1<<(p-=x<<3))-1,e.next_in=i,e.next_out=s,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=s<o?o-s+257:257-(s-o),n.hold=f,n.bits=p}},{}],49:[function(e,t,n){var i=e("../utils/common"),r=e("./adler32"),s=e("./crc32"),a=e("./inffast"),o=e("./inftrees"),l=1,c=2,h=0,u=-2,d=1,f=852,p=592;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=d,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(f),t.distcode=t.distdyn=new i.Buf32(p),t.sane=1,t.back=-1,h):u}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,y(e)):u}function v(e,t){var n,i;return e&&e.state?(i=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?u:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,b(e))):u}function w(e,t){var n,i;return e?(i=new m,(e.state=i).window=null,(n=v(e,t))!==h&&(e.state=null),n):u}var x,_,k=!0;function S(e){if(k){var t;for(x=new i.Buf32(512),_=new i.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(o(l,e.lens,0,288,x,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;o(c,e.lens,0,32,_,0,e.work,{bits:5}),k=!1}e.lencode=x,e.lenbits=9,e.distcode=_,e.distbits=5}function M(e,t,n,r){var s,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new i.Buf8(a.wsize)),r>=a.wsize?(i.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(r<(s=a.wsize-a.wnext)&&(s=r),i.arraySet(a.window,t,n-r,s,a.wnext),(r-=s)?(i.arraySet(a.window,t,n-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=s))),0}n.inflateReset=b,n.inflateReset2=v,n.inflateResetKeep=y,n.inflateInit=function(e){return w(e,15)},n.inflateInit2=w,n.inflate=function(e,t){var n,f,p,m,y,b,v,w,x,_,k,A,T,E,P,C,z,L,I,D,R,O,B,F,j=0,N=new i.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return u;12===(n=e.state).mode&&(n.mode=13),y=e.next_out,p=e.output,v=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,w=n.hold,x=n.bits,_=b,k=v,O=h;e:for(;;)switch(n.mode){case d:if(0===n.wrap){n.mode=13;break}for(;x<16;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(2&n.wrap&&35615===w){N[n.check=0]=255&w,N[1]=w>>>8&255,n.check=s(n.check,N,2,0),x=w=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&w)<<8)+(w>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&w)){e.msg="unknown compression method",n.mode=30;break}if(x-=4,R=8+(15&(w>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<R,e.adler=n.check=1,n.mode=512&w?10:12,x=w=0;break;case 2:for(;x<16;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(n.flags=w,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=w>>8&1),512&n.flags&&(N[0]=255&w,N[1]=w>>>8&255,n.check=s(n.check,N,2,0)),x=w=0,n.mode=3;case 3:for(;x<32;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.head&&(n.head.time=w),512&n.flags&&(N[0]=255&w,N[1]=w>>>8&255,N[2]=w>>>16&255,N[3]=w>>>24&255,n.check=s(n.check,N,4,0)),x=w=0,n.mode=4;case 4:for(;x<16;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.head&&(n.head.xflags=255&w,n.head.os=w>>8),512&n.flags&&(N[0]=255&w,N[1]=w>>>8&255,n.check=s(n.check,N,2,0)),x=w=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.length=w,n.head&&(n.head.extra_len=w),512&n.flags&&(N[0]=255&w,N[1]=w>>>8&255,n.check=s(n.check,N,2,0)),x=w=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(b<(A=n.length)&&(A=b),A&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),i.arraySet(n.head.extra,f,m,A,R)),512&n.flags&&(n.check=s(n.check,f,A,m)),b-=A,m+=A,n.length-=A),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===b)break e;for(A=0;R=f[m+A++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R)),R&&A<b;);if(512&n.flags&&(n.check=s(n.check,f,A,m)),b-=A,m+=A,R)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===b)break e;for(A=0;R=f[m+A++],n.head&&R&&n.length<65536&&(n.head.comment+=String.fromCharCode(R)),R&&A<b;);if(512&n.flags&&(n.check=s(n.check,f,A,m)),b-=A,m+=A,R)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;x<16;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(w!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}x=w=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}e.adler=n.check=g(w),x=w=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=y,e.avail_out=v,e.next_in=m,e.avail_in=b,n.hold=w,n.bits=x,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){w>>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}switch(n.last=1&w,x-=1,3&(w>>>=1)){case 0:n.mode=14;break;case 1:if(S(n),n.mode=20,6!==t)break;w>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}w>>>=2,x-=2;break;case 14:for(w>>>=7&x,x-=7&x;x<32;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if((65535&w)!=(w>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&w,x=w=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(A=n.length){if(b<A&&(A=b),v<A&&(A=v),0===A)break e;i.arraySet(p,f,m,A,y),b-=A,m+=A,v-=A,y+=A,n.length-=A;break}n.mode=12;break;case 17:for(;x<14;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(n.nlen=257+(31&w),w>>>=5,x-=5,n.ndist=1+(31&w),w>>>=5,x-=5,n.ncode=4+(15&w),w>>>=4,x-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;x<3;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.lens[U[n.have++]]=7&w,w>>>=3,x-=3}for(;n.have<19;)n.lens[U[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,B={bits:n.lenbits},O=o(0,n.lens,0,19,n.lencode,0,n.work,B),n.lenbits=B.bits,O){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;C=(j=n.lencode[w&(1<<n.lenbits)-1])>>>16&255,z=65535&j,!((P=j>>>24)<=x);){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(z<16)w>>>=P,x-=P,n.lens[n.have++]=z;else{if(16===z){for(F=P+2;x<F;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(w>>>=P,x-=P,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],A=3+(3&w),w>>>=2,x-=2}else if(17===z){for(F=P+3;x<F;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}x-=P,R=0,A=3+(7&(w>>>=P)),w>>>=3,x-=3}else{for(F=P+7;x<F;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}x-=P,R=0,A=11+(127&(w>>>=P)),w>>>=7,x-=7}if(n.have+A>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;A--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,B={bits:n.lenbits},O=o(l,n.lens,0,n.nlen,n.lencode,0,n.work,B),n.lenbits=B.bits,O){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,B={bits:n.distbits},O=o(c,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,B),n.distbits=B.bits,O){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=b&&258<=v){e.next_out=y,e.avail_out=v,e.next_in=m,e.avail_in=b,n.hold=w,n.bits=x,a(e,k),y=e.next_out,p=e.output,v=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,w=n.hold,x=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;C=(j=n.lencode[w&(1<<n.lenbits)-1])>>>16&255,z=65535&j,!((P=j>>>24)<=x);){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(C&&!(240&C)){for(L=P,I=C,D=z;C=(j=n.lencode[D+((w&(1<<L+I)-1)>>L)])>>>16&255,z=65535&j,!(L+(P=j>>>24)<=x);){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}w>>>=L,x-=L,n.back+=L}if(w>>>=P,x-=P,n.back+=P,n.length=z,0===C){n.mode=26;break}if(32&C){n.back=-1,n.mode=12;break}if(64&C){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&C,n.mode=22;case 22:if(n.extra){for(F=n.extra;x<F;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.length+=w&(1<<n.extra)-1,w>>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;C=(j=n.distcode[w&(1<<n.distbits)-1])>>>16&255,z=65535&j,!((P=j>>>24)<=x);){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(!(240&C)){for(L=P,I=C,D=z;C=(j=n.distcode[D+((w&(1<<L+I)-1)>>L)])>>>16&255,z=65535&j,!(L+(P=j>>>24)<=x);){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}w>>>=L,x-=L,n.back+=L}if(w>>>=P,x-=P,n.back+=P,64&C){e.msg="invalid distance code",n.mode=30;break}n.offset=z,n.extra=15&C,n.mode=24;case 24:if(n.extra){for(F=n.extra;x<F;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}n.offset+=w&(1<<n.extra)-1,w>>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===v)break e;if(A=k-v,n.offset>A){if((A=n.offset-A)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}T=A>n.wnext?(A-=n.wnext,n.wsize-A):n.wnext-A,A>n.length&&(A=n.length),E=n.window}else E=p,T=y-n.offset,A=n.length;for(v<A&&(A=v),v-=A,n.length-=A;p[y++]=E[T++],--A;);0===n.length&&(n.mode=21);break;case 26:if(0===v)break e;p[y++]=n.length,v--,n.mode=21;break;case 27:if(n.wrap){for(;x<32;){if(0===b)break e;b--,w|=f[m++]<<x,x+=8}if(k-=v,e.total_out+=k,n.total+=k,k&&(e.adler=n.check=n.flags?s(n.check,p,k,y-k):r(n.check,p,k,y-k)),k=v,(n.flags?w:g(w))!==n.check){e.msg="incorrect data check",n.mode=30;break}x=w=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;x<32;){if(0===b)break e;b--,w+=f[m++]<<x,x+=8}if(w!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}x=w=0}n.mode=29;case 29:O=1;break e;case 30:O=-3;break e;case 31:return-4;default:return u}return e.next_out=y,e.avail_out=v,e.next_in=m,e.avail_in=b,n.hold=w,n.bits=x,(n.wsize||k!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&M(e,e.output,e.next_out,k-e.avail_out)?(n.mode=31,-4):(_-=e.avail_in,k-=e.avail_out,e.total_in+=_,e.total_out+=k,n.total+=k,n.wrap&&k&&(e.adler=n.check=n.flags?s(n.check,p,k,e.next_out-k):r(n.check,p,k,e.next_out-k)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==_&&0===k||4===t)&&O===h&&(O=-5),O)},n.inflateEnd=function(e){if(!e||!e.state)return u;var t=e.state;return t.window&&(t.window=null),e.state=null,h},n.inflateGetHeader=function(e,t){var n;return e&&e.state&&2&(n=e.state).wrap?((n.head=t).done=!1,h):u},n.inflateSetDictionary=function(e,t){var n,i=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?u:11===n.mode&&r(1,t,i,0)!==n.check?-3:M(e,t,i,i)?(n.mode=31,-4):(n.havedict=1,h):u},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,n){var i=e("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,l,c,h,u,d){var f,p,g,m,y,b,v,w,x,_=d.bits,k=0,S=0,M=0,A=0,T=0,E=0,P=0,C=0,z=0,L=0,I=null,D=0,R=new i.Buf16(16),O=new i.Buf16(16),B=null,F=0;for(k=0;k<=15;k++)R[k]=0;for(S=0;S<l;S++)R[t[n+S]]++;for(T=_,A=15;1<=A&&0===R[A];A--);if(A<T&&(T=A),0===A)return c[h++]=20971520,c[h++]=20971520,d.bits=1,0;for(M=1;M<A&&0===R[M];M++);for(T<M&&(T=M),k=C=1;k<=15;k++)if(C<<=1,(C-=R[k])<0)return-1;if(0<C&&(0===e||1!==A))return-1;for(O[1]=0,k=1;k<15;k++)O[k+1]=O[k]+R[k];for(S=0;S<l;S++)0!==t[n+S]&&(u[O[t[n+S]]++]=S);if(b=0===e?(I=B=u,19):1===e?(I=r,D-=257,B=s,F-=257,256):(I=a,B=o,-1),k=M,y=h,P=S=L=0,g=-1,m=(z=1<<(E=T))-1,1===e&&852<z||2===e&&592<z)return 1;for(;;){for(v=k-P,x=u[S]<b?(w=0,u[S]):u[S]>b?(w=B[F+u[S]],I[D+u[S]]):(w=96,0),f=1<<k-P,M=p=1<<E;c[y+(L>>P)+(p-=f)]=v<<24|w<<16|x,0!==p;);for(f=1<<k-1;L&f;)f>>=1;if(0!==f?(L&=f-1,L+=f):L=0,S++,0==--R[k]){if(k===A)break;k=t[n+u[S]]}if(T<k&&(L&m)!==g){for(0===P&&(P=T),y+=M,C=1<<(E=k-P);E+P<A&&!((C-=R[E+P])<=0);)E++,C<<=1;if(z+=1<<E,1===e&&852<z||2===e&&592<z)return 1;c[g=L&m]=T<<24|E<<16|y-h}}return 0!==L&&(c[y+L]=k-P<<24|64<<16),d.bits=T,0}},{"../utils/common":41}],51:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,n){var i=e("../utils/common"),r=0,s=1;function a(e){for(var t=e.length;0<=--t;)e[t]=0}var o=0,l=29,c=256,h=c+1+l,u=30,d=19,f=2*h+1,p=15,g=16,m=7,y=256,b=16,v=17,w=18,x=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],_=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=new Array(2*(h+2));a(M);var A=new Array(2*u);a(A);var T=new Array(512);a(T);var E=new Array(256);a(E);var P=new Array(l);a(P);var C,z,L,I=new Array(u);function D(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function R(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function O(e){return e<256?T[e]:T[256+(e>>>7)]}function B(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function F(e,t,n){e.bi_valid>g-n?(e.bi_buf|=t<<e.bi_valid&65535,B(e,e.bi_buf),e.bi_buf=t>>g-e.bi_valid,e.bi_valid+=n-g):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function j(e,t,n){F(e,n[2*t],n[2*t+1])}function N(e,t){for(var n=0;n|=1&e,e>>>=1,n<<=1,0<--t;);return n>>>1}function U(e,t,n){var i,r,s=new Array(p+1),a=0;for(i=1;i<=p;i++)s[i]=a=a+n[i-1]<<1;for(r=0;r<=t;r++){var o=e[2*r+1];0!==o&&(e[2*r]=N(s[o]++,o))}}function $(e){var t;for(t=0;t<h;t++)e.dyn_ltree[2*t]=0;for(t=0;t<u;t++)e.dyn_dtree[2*t]=0;for(t=0;t<d;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*y]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function V(e){8<e.bi_valid?B(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function W(e,t,n,i){var r=2*t,s=2*n;return e[r]<e[s]||e[r]===e[s]&&i[t]<=i[n]}function H(e,t,n){for(var i=e.heap[n],r=n<<1;r<=e.heap_len&&(r<e.heap_len&&W(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!W(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i}function K(e,t,n){var i,r,s,a,o=0;if(0!==e.last_lit)for(;i=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],r=e.pending_buf[e.l_buf+o],o++,0===i?j(e,r,t):(j(e,(s=E[r])+c+1,t),0!==(a=x[s])&&F(e,r-=P[s],a),j(e,s=O(--i),n),0!==(a=_[s])&&F(e,i-=I[s],a)),o<e.last_lit;);j(e,y,t)}function Z(e,t){var n,i,r,s=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,l=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=f,n=0;n<l;n++)0!==s[2*n]?(e.heap[++e.heap_len]=c=n,e.depth[n]=0):s[2*n+1]=0;for(;e.heap_len<2;)s[2*(r=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[r]=0,e.opt_len--,o&&(e.static_len-=a[2*r+1]);for(t.max_code=c,n=e.heap_len>>1;1<=n;n--)H(e,s,n);for(r=l;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],H(e,s,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,s[2*r]=s[2*n]+s[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,s[2*n+1]=s[2*i+1]=r,e.heap[1]=r++,H(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,i,r,s,a,o,l=t.dyn_tree,c=t.max_code,h=t.stat_desc.static_tree,u=t.stat_desc.has_stree,d=t.stat_desc.extra_bits,g=t.stat_desc.extra_base,m=t.stat_desc.max_length,y=0;for(s=0;s<=p;s++)e.bl_count[s]=0;for(l[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<f;n++)m<(s=l[2*l[2*(i=e.heap[n])+1]+1]+1)&&(s=m,y++),l[2*i+1]=s,c<i||(e.bl_count[s]++,a=0,g<=i&&(a=d[i-g]),o=l[2*i],e.opt_len+=o*(s+a),u&&(e.static_len+=o*(h[2*i+1]+a)));if(0!==y){do{for(s=m-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[m]--,y-=2}while(0<y);for(s=m;0!==s;s--)for(i=e.bl_count[s];0!==i;)c<(r=e.heap[--n])||(l[2*r+1]!==s&&(e.opt_len+=(s-l[2*r+1])*l[2*r],l[2*r+1]=s),i--)}}(e,t),U(s,c,e.bl_count)}function G(e,t,n){var i,r,s=-1,a=t[1],o=0,l=7,c=4;for(0===a&&(l=138,c=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=a,a=t[2*(i+1)+1],++o<l&&r===a||(o<c?e.bl_tree[2*r]+=o:0!==r?(r!==s&&e.bl_tree[2*r]++,e.bl_tree[2*b]++):o<=10?e.bl_tree[2*v]++:e.bl_tree[2*w]++,s=r,c=(o=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4))}function X(e,t,n){var i,r,s=-1,a=t[1],o=0,l=7,c=4;for(0===a&&(l=138,c=3),i=0;i<=n;i++)if(r=a,a=t[2*(i+1)+1],!(++o<l&&r===a)){if(o<c)for(;j(e,r,e.bl_tree),0!=--o;);else 0!==r?(r!==s&&(j(e,r,e.bl_tree),o--),j(e,b,e.bl_tree),F(e,o-3,2)):o<=10?(j(e,v,e.bl_tree),F(e,o-3,3)):(j(e,w,e.bl_tree),F(e,o-11,7));s=r,c=(o=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4)}}a(I);var Y=!1;function q(e,t,n,r){var s,a,l;F(e,(o<<1)+(r?1:0),3),a=t,l=n,V(s=e),B(s,l),B(s,~l),i.arraySet(s.pending_buf,s.window,a,l,s.pending),s.pending+=l}n._tr_init=function(e){Y||(function(){var e,t,n,i,r,s=new Array(p+1);for(i=n=0;i<l-1;i++)for(P[i]=n,e=0;e<1<<x[i];e++)E[n++]=i;for(E[n-1]=i,i=r=0;i<16;i++)for(I[i]=r,e=0;e<1<<_[i];e++)T[r++]=i;for(r>>=7;i<u;i++)for(I[i]=r<<7,e=0;e<1<<_[i]-7;e++)T[256+r++]=i;for(t=0;t<=p;t++)s[t]=0;for(e=0;e<=143;)M[2*e+1]=8,e++,s[8]++;for(;e<=255;)M[2*e+1]=9,e++,s[9]++;for(;e<=279;)M[2*e+1]=7,e++,s[7]++;for(;e<=287;)M[2*e+1]=8,e++,s[8]++;for(U(M,h+1,s),e=0;e<u;e++)A[2*e+1]=5,A[2*e]=N(e,5);C=new D(M,x,c+1,h,p),z=new D(A,_,0,u,p),L=new D(new Array(0),k,0,d,m)}(),Y=!0),e.l_desc=new R(e.dyn_ltree,C),e.d_desc=new R(e.dyn_dtree,z),e.bl_desc=new R(e.bl_tree,L),e.bi_buf=0,e.bi_valid=0,$(e)},n._tr_stored_block=q,n._tr_flush_block=function(e,t,n,i){var a,o,l=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return r;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return s;for(t=32;t<c;t++)if(0!==e.dyn_ltree[2*t])return s;return r}(e)),Z(e,e.l_desc),Z(e,e.d_desc),l=function(e){var t;for(G(e,e.dyn_ltree,e.l_desc.max_code),G(e,e.dyn_dtree,e.d_desc.max_code),Z(e,e.bl_desc),t=d-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),a=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=a&&(a=o)):a=o=n+5,n+4<=a&&-1!==t?q(e,t,n,i):4===e.strategy||o===a?(F(e,2+(i?1:0),3),K(e,M,A)):(F(e,4+(i?1:0),3),function(e,t,n,i){var r;for(F(e,t-257,5),F(e,n-1,5),F(e,i-4,4),r=0;r<i;r++)F(e,e.bl_tree[2*S[r]+1],3);X(e,e.dyn_ltree,t-1),X(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),K(e,e.dyn_ltree,e.dyn_dtree)),$(e),i&&V(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(E[n]+c+1)]++,e.dyn_dtree[2*O(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){var t;F(e,2,3),j(e,y,M),16===(t=e).bi_valid?(B(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){!function(e,t){if(!e.setImmediate){var n,i,r,s,a=1,o={},l=!1,c=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick(function(){d(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(s="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){r.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(i=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):function(e){setTimeout(d,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),i=0;i<t.length;i++)t[i]=arguments[i+1];var r={callback:e,args:t};return o[a]=r,n(a),a++},h.clearImmediate=u}function u(e){delete o[e]}function d(e){if(l)setTimeout(d,0,e);else{var n=o[e];if(n){l=!0;try{!function(e){var n=e.callback,i=e.args;switch(i.length){case 0:n();break;case 1:n(i[0]);break;case 2:n(i[0],i[1]);break;case 3:n(i[0],i[1],i[2]);break;default:n.apply(t,i)}}(n)}finally{u(e),l=!1}}}}function f(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&d(+t.data.slice(s.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,void 0!==s?s:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)}(jc);var Nc=jc.exports;const Uc=a(Nc),$c=r({__proto__:null,default:Uc},[Nc]);async function Vc(e,t,n,i=null){Ma("Map","loading map...."),i&&Ma("Map","Using heights data:",i.length,"rows");let r="string"==typeof e.sprites?e.sprites:e.sprites.map(e=>({id:e.id,type:e.type,pos:new ot(...e.pos),facing:Us[e.facing],zones:e.zones??null})),s=(e.scenes??[]).map(e=>({id:e.id,actions:e.actions.map(e=>e.trigger?{trigger:e.trigger,scope:this}:{sprite:e.sprite,action:e.action,args:e.args,scope:this}),scope:this})),a=await Promise.all((e.scripts??[]).map(async e=>{try{let t=n.file(`triggers/${e.trigger}.pxs`);t||(t=n.file(`triggers/${e.trigger}.pxs`));let i=await t.async("string");Ma("Map","lua script",i);let r=(t=>{let n=new mc(t.engine);return n.setScope({_this:t,zone:this,subject:t}),n.initLibrary(),n.run('print("hello world lua - zone")'),{id:e.id,trigger:async()=>(Ma("Map","running actual trigger"),n.run(i))}}).bind(this)(this);return Ma("Map","zone trigger Lua eval response",r),r}catch(Yc){console.error(Yc)}})),o=(e.objects??[]).map(e=>({id:e.id,type:e.type,mtl:e.mtl,useScale:e.useScale?new ot(...e.useScale):null,pos:e.pos?new ot(...e.pos):null,rotation:e.rotation?new ot(...e.rotation):null}));return{bounds:e.bounds,tileset:e.tileset,cells:t,heights:i,sprites:r,scenes:s,scripts:a,objects:o,lights:e.lights,selectTrigger:e.selectTrigger}}class Wc extends Ys{constructor(e,t){super(),i(this,"getZoneData",()=>({id:this.id,objId:this.objId,scripts:this.scripts,data:this.data,objects:Object.keys(this.objectDict),sprites:Object.keys(this.spriteDict),selectedTiles:this.selectedTiles})),i(this,"afterTilesetAndActorsLoaded",()=>{var e;!this.loaded&&(null==(e=this.tileset)?void 0:e.loaded)&&this.spriteList.every(e=>e.loaded)&&this.objectList.every(e=>e.loaded)&&(this.loaded=!0,this.loadScripts(!0),this.onLoadActions.run())}),i(this,"attachTilesetListeners",()=>{this.tileset.runWhenDefinitionLoaded(this.onTilesetDefinitionLoaded),this.tileset.runWhenLoaded(this.afterTilesetAndActorsLoaded)}),i(this,"finalize",async()=>{for(const e of this.spriteList)e.runWhenLoaded(this.afterTilesetAndActorsLoaded);for(const e of this.objectList)e.runWhenLoaded(this.afterTilesetAndActorsLoaded);this.engine.networkManager.loadZone(this.id,this)}),i(this,"loadRemote",async()=>{var e,t;const n=await fetch(_c(this.id));if(n.ok)try{const i=await n.json();this.bounds=i.bounds,this.size=[i.bounds[2]-i.bounds[0],i.bounds[3]-i.bounds[1]],this.cells="function"==typeof i.cells?i.cells(this.bounds,this):i.cells,this.sprites="function"==typeof i.sprites?i.sprites(this.bounds,this):i.sprites||[],this.objects="function"==typeof i.objects?i.objects(this.bounds,this):i.objects||[],this.tileset=await this.tsLoader.load(i.tileset,this.spritzName),this.attachTilesetListeners(),this.audioSrc&&(this.audio=this.engine.resourceManager.audioLoader.load(this.audioSrc,!0)),await Promise.all([Promise.all(this.sprites.map(this.loadSprite)),Promise.all(this.objects.map(this.loadObject))]),i.skyboxShader&&(null==(t=null==(e=this.engine.renderManager)?void 0:e.skyboxManager)?void 0:t.setSkyboxShader)&&await this.engine.renderManager.skyboxManager.setSkyboxShader(i.skyboxShader),await this.finalize();try{i.mode&&await this.loadMode(i.mode)}catch(Yc){console.warn("zone mode load failed",Yc)}}catch(Yc){console.error("Error parsing zone "+this.id,Yc)}}),i(this,"load",async()=>{var e,t;try{const n=(await import("../../../../spritz/"+this.spritzName+"/maps/"+this.id+"/map.js")).default;Object.assign(this,n),"function"==typeof this.cells&&(this.cells=this.cells(this.bounds,this)),this.audioSrc&&(this.audio=this.engine.resourceManager.audioLoader.load(this.audioSrc,!0)),this.size=[this.bounds[2]-this.bounds[0],this.bounds[3]-this.bounds[1]],this.tileset=await this.tsLoader.load(this.tileset,this.spritzName),this.attachTilesetListeners(),"function"==typeof this.sprites&&(this.sprites=this.sprites(this.bounds,this)),this.sprites=this.sprites||[],this.objects=this.objects||[],await Promise.all([Promise.all(this.sprites.map(this.loadSprite)),Promise.all(this.objects.map(this.loadObject))]),n.skyboxShader&&(null==(t=null==(e=this.engine.renderManager)?void 0:e.skyboxManager)?void 0:t.setSkyboxShader)&&await this.engine.renderManager.skyboxManager.setSkyboxShader(n.skyboxShader),await this.finalize();try{n.mode&&await this.loadMode(n.mode)}catch(Yc){console.warn("zone mode load failed",Yc)}try{this.engine.networkManager.joinZone(this.id)}catch(Yc){console.warn("Network Error :: could not send zone commend to server")}}catch(Yc){console.error("Error parsing zone "+this.id,Yc)}}),i(this,"loadTriggerFromZip",async(e,t)=>{var n,i;try{const n=await t.file(`triggers/${e}.pxs`);if(n){const e=await n.async("string");return(t,n)=>{const i=new mc(t.engine);return i.setScope({_this:t,zone:this,subject:n}),i.initLibrary(),i.run(e)}}}catch(Yc){(null==(n=this.engine)?void 0:n.debug)&&console.warn("Lua trigger load failed",Yc)}try{const n=await t.file(`triggers/${e}.pxs`);if(n){const e=await n.async("string");return(t,n)=>{const i=new mc(t.engine);return i.setScope({_this:t,zone:this,subject:n}),i.initLibrary(),i.run(e)}}}catch(Yc){(null==(i=this.engine)?void 0:i.debug)&&console.warn("PixoScript trigger load failed",Yc)}const r=await t.file(`triggers/${e}.js`);if(r){const e=await r.async("string"),t=new Function("zone","engine",`${e}; return (typeof module !== 'undefined' && module.exports) ? module.exports : (typeof exports !== 'undefined' ? exports : (typeof trigger === 'function' ? trigger : null));`)(this,this.engine);if("function"==typeof t)return t.bind(this,this)}return()=>{}}),i(this,"loadModeFromZip",async(e,t)=>{try{Ma("Zone","Loading Game Mode From Zip");const n=t.file(`modes/${e}/setup.pxs`),i=t.file(`modes/${e}/update.pxs`),r=t.file(`modes/${e}/teardown.pxs`),s=this.world,a=new mc(this.engine);a.setScope({zone:this,map:this,_this:this}),a.initLibrary();const o={};if(n){const t=await n.async("string");Ma("Zone","loadModeFromZip: running setup.pxs for mode",e),await a.run(t)}if(i){const e=await i.async("string");o.update=async(t,n)=>{try{const i=new mc(this.engine);i.setScope({zone:this,map:this,_this:this,time:t,params:n}),i.initLibrary();const r=await i.run(e);"function"==typeof r&&r(t,n)}catch(Yc){console.warn("mode update exec failed",Yc)}}}if(r){const e=await r.async("string");o.teardown=async t=>{try{const n=new mc(this.engine);n.setScope({zone:this}),n.initLibrary();const i=await n.run(e);"function"==typeof i&&i(t)}catch(Yc){console.warn("mode teardown failed",Yc)}}}if(s&&s.modeManager){s.modeManager.registered[e]||s.modeManager.register(e,o)}}catch(Yc){console.warn("loadModeFromZip failed",e,Yc)}}),i(this,"loadMode",async e=>{try{const t=this.world;await this.loadModeFromZip(e,t.spritz.zip)}catch(Yc){console.warn("loadMode failed",e,Yc)}}),i(this,"loadZoneFromZip",async(e,t,n,i=!1)=>{var r,s;try{if(null==(r=e.extends)?void 0:r.length){let t={};await Promise.all(e.extends.map(async e=>{const i=await n.file("maps/"+e+"/map.json").async("string");t=Vs(t,JSON.parse(i))})),e=Object.assign(t,{...e,extends:null})}if(null==(s=t.extends)?void 0:s.length){let e=[];await Promise.all(t.extends.map(async t=>{const i=await n.file("maps/"+t+"/cells.json").async("string"),r=JSON.parse(i);e=e.concat(r.cells?r.cells:r)})),t=e.concat(t.cells||[])}let a=null;try{const e=n.file("maps/"+this.id+"/heights.json");if(e){const t=await e.async("string");a=JSON.parse(t),Ma("Zone",`Loaded heights.json for ${this.id}:`,null==a?void 0:a.length,"rows"),Ma("Zone","First row heights:",null==a?void 0:a[0]),Ma("Zone","Heights data sample:",JSON.stringify(null==a?void 0:a.slice(0,3)))}else Ma("Zone",`No heights.json found for ${this.id}, using default geometry heights`)}catch(Yc){console.warn(`[Zone] Failed to load heights.json for ${this.id}:`,Yc.message)}if(e.menu){const t={};await Promise.all(Object.keys(e.menu).map(async i=>{const r={...e.menu[i],id:i};r.onOpen&&(r.onOpen=(await this.loadTriggerFromZip(r.onOpen,n)).bind(this,this)),r.trigger&&(r.trigger=(await this.loadTriggerFromZip(r.trigger,n)).bind(this,this)),t[i]=r})),this.menus=t,this.world.startMenu(this.menus)}const o=await this.tsLoader.loadFromZip(n,e.tileset,this.spritzName),l=function(e,t){if("string"==typeof e)return e;if(!t||"object"!=typeof t)return console.error("[dynamicCells] Tileset is undefined or invalid - tiles.json may be missing from tileset"),[];let n=[],i=new Set;return e.forEach((e,r)=>{let s=e.length;e.forEach((e,a)=>{const o=t[e];o?n[r*s+a]=o:(i.add(e),n[r*s+a]=["FLAT_ALL","FLOOR",0])})}),i.size>0&&console.warn("[dynamicCells] Missing tile definitions:",Array.from(i).join(", ")),n}(t,o.tiles),c=await Vc.call(this,e,l,n,a);if(Object.assign(this,c),"string"==typeof this.cells)try{const e=new Function("bounds","zone",`return (${this.cells})(bounds, zone);`);this.cells=e.call(this,this.bounds,this)}catch(Yc){console.error("error loading cell function",Yc)}if(e.mode)try{this.mode=e.mode}catch(Yc){console.error("audio load",Yc)}if(e.audioSrc)try{this.audio=await this.engine.resourceManager.audioLoader.loadFromZip(n,e.audioSrc,!0)}catch(Yc){console.error("audio load",Yc)}try{this.lights=e.lights??[];const t=this.engine.renderManager.lightManager;for(const e of this.lights)t.addLight(e.id,e.pos,e.color,e.attenuation,e.direction,e.density,e.scatteringCoefficients,e.enabled)}catch(Yc){console.error("lights",Yc)}if(this.tileset=o,this.size=[this.bounds[2]-this.bounds[0],this.bounds[3]-this.bounds[1]],"string"==typeof this.sprites)try{const e=new Function("bounds","zone",`return (${this.sprites})(bounds, zone);`);this.sprites=e.call(this,this.bounds,this)}catch(Yc){console.error("sprite fn",Yc)}this.sprites=this.sprites||[],this.objects=this.objects||[],await Promise.all([Promise.all(this.sprites.map(e=>this.loadSpriteFromZip(e,n,i))),Promise.all(this.objects.map(e=>this.loadObjectFromZip(e,n)))]),this.attachTilesetListeners();try{this.mode&&await this.loadMode(this.mode)}catch(Yc){console.warn("zone mode load failed",Yc)}await this.finalize()}catch(Yc){console.error("Error parsing json zone "+this.id,Yc)}}),i(this,"runWhenDeleted",()=>{for(const e of this.lights)this.engine.renderManager.lightManager.removeLight(e.id)}),i(this,"onTilesetDefinitionLoaded",()=>{const e=this.size[0],t=this.size[1],n=this.engine.renderManager,i=this.engine.gl;if(!this.cells||0===this.cells.length)return void console.error("[Zone.onTilesetDefinitionLoaded] No cells data - tileset may be missing tiles definition");this.cellVertexPosBuf=Array.from({length:t},()=>new Array(e)),this.cellVertexTexBuf=Array.from({length:t},()=>new Array(e)),this.cellPickingId=Array.from({length:t},()=>new Array(e)),this.walkability=new Uint16Array(e*t);let r=0;for(let s=0;s<t;s++)for(let t=0;t<e;t++,r++){const e=this.cells[r];if(!e||!Array.isArray(e)){console.warn(`[Zone] Cell [${s},${t}] is undefined - missing tile in tileset`),this.cellVertexPosBuf[s][t]=n.createBuffer(new Float32Array([]),i.STATIC_DRAW,3),this.cellVertexTexBuf[s][t]=n.createBuffer(new Float32Array([]),i.STATIC_DRAW,2),this.cellPickingId[s][t]=n.pickingManager.nextPickingId(),this.walkability[r]=0;continue}const a=Math.floor(e.length/3);let o=[],l=[],c=Us.All;const h=this.heights&&this.heights[s]&&"number"==typeof this.heights[s][t]?this.heights[s][t]:null;r<5&&console.log(`[Zone.finalize] Cell [${s},${t}] heightOverride:`,h);for(let n=0;n<a;n++){const i=e[3*n],r=e[3*n+1];let a=e[3*n+2];"number"!=typeof a&&(a=0);const u=[this.bounds[0]+t,this.bounds[1]+s,a];c&=this.tileset.getWalkability(i),o=o.concat(this.tileset.getTileVertices(i,u,h)),l=l.concat(this.tileset.getTileTexCoords(i,r))}e.length===3*a+1&&(c=e[3*a]),this.walkability[r]=c;const u=n.createBuffer(new Float32Array(o),i.STATIC_DRAW,3),d=n.createBuffer(new Float32Array(l),i.STATIC_DRAW,2);this.cellVertexPosBuf[s][t]=u,this.cellVertexTexBuf[s][t]=d,this.cellPickingId[s][t]=[(255&this.objId)/255,(255&s)/255,(255&t)/255,255]}}),i(this,"loadScripts",(e=!1)=>{if(this.world.isPaused)return;const t=this;for(const n of this.scripts)if("load-spritz"===n.id&&e)try{n.trigger.call(t)}catch(Yc){console.error("[Zone.loadScripts] Error calling load-spritz trigger:",Yc)}}),i(this,"loadObject",async e=>{if(e.zone=this,!this.objectDict[e.id]){const t=await this.objectLoader.load(e,e=>e.onLoad(e));this.world.objectDict[e.id]=this.objectDict[e.id]=t,this.objectList.push(t),this.world.objectList.push(t)}}),i(this,"loadObjectFromZip",async(e,t)=>{if(e.zone=this,!this.objectDict[e.id]){const n=await this.objectLoader.loadFromZip(t,e,async e=>e.onLoadFromZip(e,t));this.world.objectDict[e.id]=this.objectDict[e.id]=n,this.objectList.push(n),this.world.objectList.push(n)}}),i(this,"loadSprite",async e=>{if(e.zone=this,!this.spriteDict[e.id]){const t=await this.spriteLoader.load(e.type,this.spritzName,t=>t.onLoad(e));this.world.spriteDict[e.id]=this.spriteDict[e.id]=t,this.spriteList.push(t),this.world.spriteList.push(t)}}),i(this,"loadSpriteFromZip",async(e,t)=>{if(e.zone=this,!this.spriteDict[e.id]){const n=await this.spriteLoader.loadFromZip(t,e.type,this.spritzName,async n=>n.onLoadFromZip(e,t));this.world.spriteDict[e.id]=this.spriteDict[e.id]=n,this.spriteList.push(n),this.world.spriteList.push(n)}}),i(this,"addSprite",e=>{e.zone=this,this.world.spriteDict[e.id]=this.spriteDict[e.id]=e,this.spriteList.push(e),this.world.spriteList.push(e)}),i(this,"removeSprite",e=>{const t=t=>t.id!==e||(t.removeAllActions(),!1);this.spriteList=this.spriteList.filter(t),this.world.spriteList=this.world.spriteList.filter(t),delete this.spriteDict[e],delete this.world.spriteDict[e]}),i(this,"removeAllSprites",()=>{for(const e of this.spriteList)this.removeSprite(e.id)}),i(this,"getSpriteById",e=>this.spriteDict[e]),i(this,"addPortal",(e,t,n)=>{var i;if(!(null==(i=this.portals)?void 0:i.length))return e;const r=this.getHeight(t,n);if(0!==r)return e;const s=i=>{i.pos=new ot(t,n,r),e.push(i)};return this.portals.length>0&&s(t*n%3==0?this.portals.shift():this.portals.pop()),e}),i(this,"getHeight",(e,t)=>{var n,i,r;if(!this.isInZone(e,t))return(null==(n=this.engine)?void 0:n.debug)&&console.error(`Height out of bounds [${e}, ${t}]`),0;const s=Math.floor(e),a=Math.floor(t),o=e-s,l=t-a,c=(a-this.bounds[1])*this.size[0]+(s-this.bounds[0]),h=this.cells[c],u=Math.floor(h.length/3),d=this.heights&&this.heights[a-this.bounds[1]]&&"number"==typeof this.heights[a-this.bounds[1]][s-this.bounds[0]]?this.heights[a-this.bounds[1]][s-this.bounds[0]]:null,f=e=>{const t=e[1][0]-e[0][0],n=e[1][1]-e[0][1],i=e[2][0]-e[0][0],r=e[2][1]-e[0][1],s=1/(t*r-n*i),a=s*r,c=-s*i,h=-s*n,u=s*t,d=o-e[0][0],f=l-e[0][1];return[d*a+f*c,d*h+f*u]};for(let p=0;p<u;p++){const n=this.tileset.getTileWalkPoly(h[3*p]);if(!n)continue;const r="number"==typeof h[3*p+2]?h[3*p+2]:0,o=null!==d?d:0;for(let l=0;l<n.length;l++){const c=f(n[l]),h=c[0]+c[1];if(c[0]>=0&&c[1]>=0&&h<=1){const u=n[l],d=r+o+(1-h)*u[0][2]+c[0]*u[1][2]+c[1]*u[2][2];return(null==(i=this.engine)?void 0:i.debug)&&(this.__getHeightLogCount=(this.__getHeightLogCount||0)+1,this.__getHeightLogCount<4&&console.log(`[Zone.getHeight] sample (x=${e},y=${t}) -> i=${s}, j=${a}, baseZ=${r}, heightOffset=${o}, uv=[${c[0].toFixed(2)},${c[1].toFixed(2)}], w=${h.toFixed(2)}, computed=${d.toFixed(2)}`)),d}}}if(u>0){const n=this.tileset.getTileWalkPoly(h[0]);if(n&&n.length>0){const i="number"==typeof h[2]?h[2]:0,s=null!==d?d:0,a=n[0],o=i+s+(a[0][2]+a[1][2]+a[2][2])/3;return(null==(r=this.engine)?void 0:r.debug)&&console.log(`[Zone.getHeight] walkPoly fallback for (${e},${t}), using avg of first tri = ${o.toFixed(2)}`),o}}return("number"==typeof h[2]?h[2]:0)+(null!==d?d:0)}),i(this,"drawRow",(e,t,n,i,r,s,a)=>{if(!this.cellVertexPosBuf||!this.cellVertexPosBuf[e])return;this.tileset.texture.attach();const o=this.cellVertexPosBuf[e],l=this.cellVertexTexBuf[e],c=this.size[0],h=this.cellPickingId[e];for(let u=0;u<c;u++){const c=o[u],d=l[u];if(!c||!d||0===c.numItems)continue;i.bindBuffer(c,r.aVertexPosition),i.bindBuffer(d,r.aTextureCoord);const f=h[u];s.setMatrixUniforms({id:f}),r.setMatrixUniforms({id:f,isSelected:!!t&&t.has(`${e},${u}`),sampler:1,colorMultiplier:n}),a.drawArrays(a.TRIANGLES,0,c.numItems),i.debug&&i.debug.tilesDrawn++}}),i(this,"drawCell",(e,t)=>{var n;const i=this.engine.renderManager,r=this.engine.gl,s=i.shaderProgram,a=i.effectPrograms.picker,o=i.isPickerPass,l=this.cellVertexPosBuf[e][t],c=this.cellVertexTexBuf[e][t];i.bindBuffer(l,s.aVertexPosition),i.bindBuffer(c,s.aTextureCoord);const h=this.cellPickingId[e][t];o?a.setMatrixUniforms({id:h}):s.setMatrixUniforms({id:h,isSelected:!!(null==(n=this._selectedSet)?void 0:n.has(`${e},${t}`)),sampler:1,colorMultiplier:this._highlight||[1,1,0,1]}),r.drawArrays(r.TRIANGLES,0,l.numItems)}),i(this,"draw",()=>{if(!this.loaded)return;const e=this.engine.renderManager,t=this.engine.gl,n=e.shaderProgram,i=e.effectPrograms.picker,r=this.selectedTiles;this.selectedSet=r&&r.length?new Set(r.map(e=>`${e[0]},${e[1]}`)):null,this.highlight=8&this.engine.frameCount?[1,0,0,1]:[1,1,0,1];const s=e=>{for(let t=1;t<e.length;t++)if(e[t-1].pos.y>e[t].pos.y){e.sort((e,t)=>e.pos.y-t.pos.y);break}};s(this.spriteList),s(this.objectList),e.mvPushMatrix(),this.engine._freecamActive||e.camera.setCamera();let a=0,o=0;if("N"===this.engine.renderManager.camera.cameraDir||"NE"===this.engine.renderManager.camera.cameraDir||"NW"===this.engine.renderManager.camera.cameraDir||"E"===this.engine.renderManager.camera.cameraDir)for(let l=0;l<this.size[1];l++){for(this.drawRow(l,this.selectedSet,this.highlight,e,n,i,t);o<this.objectList.length&&this.objectList[o].pos.y-this.bounds[1]<=l;)this.objectList[o++].draw();for(;a<this.spriteList.length&&this.spriteList[a].pos.y-this.bounds[1]<=l;)this.spriteList[a++].draw(this.engine)}else for(let l=this.size[1]-1;l>=0;l--){for(this.drawRow(l,this.selectedSet,this.highlight,e,n,i,t);o<this.objectList.length&&this.bounds[1]-this.objectList[o].pos.y<=l;)this.objectList[o++].draw();for(;a<this.spriteList.length&&this.bounds[1]-this.spriteList[a].pos.y<=l;)this.spriteList[a++].draw(this.engine)}for(;o<this.objectList.length;)this.objectList[o++].draw();for(;a<this.spriteList.length;)this.spriteList[a++].draw(this.engine);e.mvPopMatrix()}),i(this,"tick",(e,t)=>{if(this.loaded&&!t){this.checkInput(e);for(const t of this.spriteList)t.tickOuter(e)}}),i(this,"checkInput",async e=>{e<=this.lastKey+200||(this.engine.gamepad.checkInput(),this.lastKey=e)}),i(this,"isInZone",(e,t)=>e>=this.bounds[0]&&t>=this.bounds[1]&&e<this.bounds[2]&&t<this.bounds[3]),i(this,"onSelect",async(e,t)=>{var n,i;try{if((null==(n=this.world)?void 0:n.modeManager)&&this.world.modeManager.handleSelect){Ma("Zone","Running Custom Select Handler");if(await this.world.modeManager.handleSelect(this,e,t,"tile"))return}}catch(Yc){console.warn("mode selection handler error",Yc)}let r=!1;if(this.selectedTiles=this.selectedTiles.filter(n=>{const i=!(n[0]===e&&n[1]===t);return i||(r=!0),i}),!r&&(this.selectedTiles.push([e,t]),this.selectTrigger))try{let n=this.engine.spritz.zip.file(`triggers/${this.selectTrigger}.pxs`);if(n||(n=this.engine.spritz.zip.file(`triggers/${this.selectTrigger}.pxs`)),!n)throw new Error("No Lua Script Found");const i=await n.async("string"),r=new mc(this.engine);return r.setScope({_this:this,zone:this,subject:new r.pxs.Table([e,t])}),r.initLibrary(),await r.run(i)}catch(Yc){(null==(i=this.engine)?void 0:i.debug)&&console.warn("select trigger missing",Yc)}}),i(this,"isWalkable",(e,t,n)=>{if(!this.isInZone(e,t))return null;for(const i in this.spriteDict){const n=this.spriteDict[i];if(n.pos.x===e&&n.pos.y===t){if(!n.walkable&&!n.blocking&&n.override)return!0;if(!n.walkable&&n.blocking)return!1}}for(const i in this.objectDict){const n=this.objectDict[i],r=n.pos.x-n.scale.x*(n.size.x/2),s=n.pos.y-n.scale.y*(n.size.y/2),a=(e,t,n,i=!1)=>i?e>=t&&e<=n:e>t&&e<n,o=a(e,r,n.pos.x,!0),l=a(t,s,n.pos.y,!0);if(!n.walkable&&o&&l&&!n.blocking&&n.override)return!0;if(!n.walkable&&(n.pos.x===e&&n.pos.y===t||o&&l)&&n.blocking)return!1}return 0!==(this.walkability[(t-this.bounds[1])*this.size[0]+(e-this.bounds[0])]&n)}),i(this,"within",(e,t,n,i=!1)=>i?e>=t&&e<=n:e>t&&e<n),i(this,"triggerScript",e=>{for(const t of this.scripts)t.id===e&&this.runWhenLoaded(t.trigger.bind(this))}),i(this,"moveSprite",async(e,t,n=!1)=>new Promise(async i=>{const r=this.getSpriteById(e);await r.addAction(new Ac(this.engine,"patrol",[r.pos.toArray(),t,n?200:600,this],r,i))})),i(this,"spriteDialogue",async(e,t,n={autoclose:!0})=>new Promise(async i=>{const r=this.getSpriteById(e);await r.addAction(new Ac(this.engine,"dialogue",[t,!1,n],r,i))})),i(this,"runActions",async e=>{const t=this;let n=Promise.resolve();for(const i of e)n=n.then(async()=>{if(i)try{if(i.scope=i.scope||t,i.sprite){const e=i.scope.getSpriteById(i.sprite);if(e&&i.action){const n=[...i.args],r=n.pop();await e.addAction(new Ac(t.engine,i.action,[...n,{...r}],e,()=>{}))}}if(i.trigger){const e=i.scope.getSpriteById("avatar");e&&await e.addAction(new Ac(t.engine,"script",[i.trigger,i.scope,()=>{}],e))}}catch(Yc){console.warn("runActions error",(null==Yc?void 0:Yc.message)||Yc)}});return n.catch(e=>{var t;(null==(t=this.engine)?void 0:t.debug)&&console.warn("runActions chain",e)})}),i(this,"playCutScene",async(e,t=null)=>{const n=t||this.spritz;for(const i of n)try{if(i.currentStep=i.currentStep||0,i.currentStep>n.length)continue;i.id===e&&await this.runActions(i.actions)}catch(Yc){console.error(Yc)}}),this.spritzName=t.id,this.id=e,this.objId=Math.round(100*Math.random()),this.world=t,this.data={},this.spriteDict=Object.create(null),this.spriteList=[],this.objectDict=Object.create(null),this.objectList=[],this.selectedTiles=[],this.lights=[],this.spritz=[],this.scripts=this.scripts||[],this.lastKey=0,this.engine=t.engine,this.onLoadActions=new Xs,this.spriteLoader=new xc(t.engine),this.objectLoader=new Sc(t.engine),this.EventLoader=Ec,this.tsLoader=new Ha(t.engine),this.audio=null,this._selectedSet=null,this._highlight=null}}class Hc{constructor(e,t){i(this,"createAvatar",e=>{const t=this.zoneContaining(e.x,e.y);if(t){const n=new Za(this.engine);return n.onLoad({zone:t,id:e.id,pos:new ot(e.x,e.y),...e}),t.addSprite(n),n}return null}),i(this,"removeAvatar",e=>{const t=e.zone;t&&t.removeSprite(e)}),i(this,"getAvatar",()=>this.spriteDict.avatar),i(this,"runAfterTick",e=>{this.afterTickActions.add(e)}),i(this,"sortZones",()=>{this.zoneList.sort((e,t)=>e.bounds[1]-t.bounds[1])}),i(this,"loadZoneFromZip",async(e,t,n=!1,i={effect:"cross",duration:500})=>{if(!n&&this.zoneDict[e])return this.zoneDict[e];const r=this.engine;let s=!1;if(i&&(null==r?void 0:r.renderManager)){const e=r.renderManager,t=("undefined"!=typeof performance?performance.now():Date.now())-(e.transitionStartTime+e.transitionDuration);!e.isTransitioning&&t>100&&(s=!0)}if(s){const{effect:e="cross",duration:t=500}=i;await r.renderManager.startTransition({effect:e,direction:"out",duration:t})}Ma("World","Loading Zone from Zip:",e);let a=JSON.parse(await t.file("maps/"+e+"/map.json").async("string")),o=JSON.parse(await t.file("maps/"+e+"/cells.json").async("string")),l=new Wc(e,this);if(await l.loadZoneFromZip(a,o,t),this.zoneList.map(e=>{e.audio&&e.audio.pauseAudio()}),l.audio&&l.audio.playAudio(),this.zoneDict[e]=l,this.zoneList.push(l),l.runWhenLoaded(this.sortZones),s){const{effect:e="cross",duration:t=500}=i;await r.renderManager.startTransition({effect:e,direction:"in",duration:t})}return l}),i(this,"loadZone",async(e,t=!1,n=!1,i={effect:"cross",duration:500})=>{if(!n&&this.zoneDict[e])return this.zoneDict[e];const r=this.engine;let s=!1;if(i&&(null==r?void 0:r.renderManager)){const e=r.renderManager,t=("undefined"!=typeof performance?performance.now():Date.now())-(e.transitionStartTime+e.transitionDuration);!e.isTransitioning&&t>100&&(s=!0)}if(s){const{effect:e="cross",duration:t=500}=i;await r.renderManager.startTransition({effect:e,direction:"out",duration:t})}let a=new Wc(e,this);if(t?await a.loadRemote():await a.load(),this.zoneList.map(e=>{e.audio&&e.audio.pauseAudio()}),a.audio&&(console.log(a.audio),a.audio.playAudio()),this.zoneDict[e]=a,this.zoneList.push(a),a.runWhenLoaded(this.sortZones),s){const{effect:e="cross",duration:t=500}=i;await r.renderManager.startTransition({effect:e,direction:"in",duration:t})}return a}),i(this,"removeZone",e=>{this.zoneList=this.zoneList.filter(t=>{if(t.id!==e)return!0;t.audio&&t.audio.pauseAudio(),t.removeAllSprites(),t.runWhenDeleted()}),delete this.zoneDict[e]}),i(this,"removeAllZones",()=>{this.zoneList.map(e=>{e.audio&&e.audio.pauseAudio(),e.removeAllSprites(),e.runWhenDeleted()}),this.zoneList=[],this.zoneDict={}}),i(this,"tick",e=>{var t;for(let n in this.zoneDict)null==(t=this.zoneDict[n])||t.tick(e,this.isPaused);this.afterTickActions.run(e)}),i(this,"checkInput",e=>{if(e>this.lastKey+200){if(this.lastKey=e,this.modeManager&&this.modeManager.handleInput)try{if(this.modeManager.handleInput(e))return}catch(Yc){console.warn("mode input handler error",Yc)}let t=this.engine.gamepad.checkInput();this.engine.gamepad.keyPressed("start")&&(t.start=0),this.engine.gamepad.keyPressed("select")&&(t.select=0,this.engine.toggleFullscreen())}}),i(this,"startMenu",(e,t=["start"])=>{this.addEvent(new Ec(this.engine,"menu",[e??this.menuConfig,t,!1,{autoclose:!1,closeOnEnter:!0}],this))}),i(this,"addEvent",e=>{this.eventDict[e.id]&&this.removeAction(e.id),this.eventDict[e.id]=e,this.eventList.push(e)}),i(this,"removeAction",e=>{this.eventList=this.eventList.filter(t=>t.id!==e),delete this.eventDict[e]}),i(this,"removeAllActions",()=>{this.eventList=[],this.eventDict={}}),i(this,"tickOuter",e=>{this.checkInput(e),this.eventList.sort((e,t)=>{let n=e.startTime-t.startTime;return n?e.id>t.id?1:-1:n});let t=[];if(this.eventList.forEach(n=>{!n.loaded||n.startTime>e||n.pausable&&this.isPaused||n.tick(e)&&(t.push(n),n.onComplete())}),t.forEach(e=>this.removeAction(e.id)),this.tick&&!this.isPaused&&this.tick(e),!this.isPaused&&this.modeManager&&this.modeManager.update)try{this.modeManager.update(e)}catch(Yc){console.warn("mode update error",Yc)}}),i(this,"draw",()=>{for(let e in this.zoneDict)this.zoneDict[e].draw(this.engine)}),i(this,"zoneContaining",(e,t)=>{for(let n in this.zoneDict){let i=this.zoneDict[n];if(i.loaded&&i.isInZone(e,t))return i}return null}),i(this,"pathFind",(e,t)=>{let n=[],i=[],r=!1,s=this,a=e[0],o=e[1];function l(e,n){let a=JSON.stringify([e[0],e[1]]);return!r&&(e[0]==t[0]&&e[1]==t[1]?(r=!0,s.canWalk(e,a,i)?[r,[...n,t]]:[r,[...n]]):!!s.canWalk(e,a,i)&&(i.push(a),s.getNeighbours(...e).sort((e,n)=>Math.min(Math.abs(t[0]-e[0])-Math.abs(t[0]-n[0]),Math.abs(t[1]-e[1])-Math.abs(t[1]-n[1]))).map(t=>l(t,[...n,[e[0],e[1],600]])).filter(e=>e).flat()))}return n=s.getNeighbours(a,o).sort((e,n)=>Math.min(Math.abs(t[0]-e[0])-Math.abs(t[0]-n[0]),Math.abs(t[1]-e[1])-Math.abs(t[1]-n[1]))).map(t=>l(t,[[e[0],e[1],600]])).filter(e=>e[0]),n.flat()}),i(this,"getZoneById",e=>this.zoneDict[e]),i(this,"getNeighbours",(e,t)=>{let n=[e,t+1,Us.Up],i=[e,t-1,Us.Down];return[n,[e-1,t,Us.Left],[e+1,t,Us.Right],i]}),i(this,"canWalk",(e,t,n)=>{let i=this.zoneContaining(...e);return!(!i||n.indexOf(t)>=0||!i.isWalkable(...e)||!i.isWalkable(e[0],e[1],Us.reverse(e[2])))}),this.id=t,this.spritz=e,this.objId=Math.round(1e3*Math.random())+1,this.engine=e.engine,this.zoneDict={},this.zoneList=[],this.remoteAvatars=new Map,this.spriteDict={},this.spriteList=[],this.objectDict={},this.objectList=[],this.tilesetDict={},this.tilesetList=[],this.eventList=[],this.eventDict={},this.lastKey=(new Date).getTime(),this.lastZoneTransitionTime=0,this.isPaused=!0,this.modeManager=new Oa(this),this.afterTickActions=new Xs,this.menuConfig={start:{onOpen:e=>{e.completed=!0}}}}addRemoteAvatar(e,t){var n,i;try{if(this.remoteAvatars.has(e)){const n=this.remoteAvatars.get(e);try{Ma("World",`Remote avatar for ${e} already exists, updating instead`)}catch(Yc){}return null!=t.x&&(n.pos.x=t.x),null!=t.y&&(n.pos.y=t.y),null!=t.z&&(n.pos.z=t.z),null!=t.facing&&(n.facing=t.facing),n}const r=new Za(this.engine),s=this.getAvatar();s?(r.src=s.src,r.portraitSrc=s.portraitSrc,r.sheetSize=s.sheetSize,r.tileSize=s.tileSize,r.frames=s.frames,r.hotspotOffset=s.hotspotOffset,r.drawOffset=s.drawOffset,r.enableSpeech=s.enableSpeech,r.bindCamera=!1,s.texture&&(r.texture=s.texture),s.vertexTexBuf&&(r.vertexTexBuf=s.vertexTexBuf),s.vertexPosBuf&&(r.vertexPosBuf=s.vertexPosBuf),s.speech&&s.speechTexBuf&&(r.speech=s.speech,r.speechTexBuf=s.speechTexBuf),r.loaded=!0,r.templateLoaded=!0):console.warn("No local avatar template found; remote avatar may not render correctly");const a=`${t.id||"player"}-${e}`,o=this.getZoneById(t.zone||t.zoneId)||this.zoneContaining(t.x||0,t.y||0);r.zone=o,r.id=a;const l=t.x??(t.pos&&t.pos.x)??0,c=t.y??(t.pos&&t.pos.y)??0,h=l+((null==(n=r.hotspotOffset)?void 0:n.x)??0),u=c+((null==(i=r.hotspotOffset)?void 0:i.y)??0),d="number"==typeof t.z?t.z:t.pos&&"number"==typeof t.pos.z?t.pos.z:o?o.getHeight(h,u):0;r.pos=new ot(l,c,d),r.facing=t.facing||0,r.isSelected=!1;let f=o&&o.tileset&&o.tileset.tileSize?o.tileset.tileSize:32,p=[r.tileSize[0]/f,r.tileSize[1]/f],g=[[0,0,0],[p[0],0,0],[p[0],0,p[1]],[0,0,p[1]]],m=[[g[2],g[3],g[0]],[g[2],g[0],g[1]]].flat(3);r.vertexPosBuf=this.engine.renderManager.createBuffer(m,this.engine.gl.STATIC_DRAW,3);let y=r.getTexCoords();r.vertexTexBuf=this.engine.renderManager.createBuffer(y,this.engine.gl.DYNAMIC_DRAW,2),r.enableSpeech&&(r.speechVerBuf=this.engine.renderManager.createBuffer(r.getSpeechBubbleVertices(),this.engine.gl.STATIC_DRAW,3),r.speechTexBuf=this.engine.renderManager.createBuffer(r.getSpeechBubbleTexture(),this.engine.gl.DYNAMIC_DRAW,2)),o&&(o.spriteDict||(o.spriteDict={}),o.spriteList||(o.spriteList=[]),this.spriteDict[r.id]=r,o.spriteDict[r.id]=r,o.spriteList.includes(r)||o.spriteList.push(r),this.spriteList.includes(r)||this.spriteList.push(r),Ma("World",`Added remote avatar for client ${e} as sprite '${r.id}' to zone ${o.id} at (${r.pos.x},${r.pos.y},${r.pos.z})`)),this.remoteAvatars.set(e,r);try{Ma("World",`Remote avatar map now has ${this.remoteAvatars.size} entries`)}catch(Yc){}return r}catch(Yc){return console.warn("Failed to add remote avatar",Yc),null}}removeRemoteAvatar(e){const t=this.remoteAvatars.get(e);if(t){try{if(t.zone){const e=t.id||(t.objId?t.objId:null);e?t.zone.removeSprite(e):t.zone.removeSprite(t)}}catch(Yc){try{t.zone&&t.zone.removeSprite(t)}catch(n){}}this.remoteAvatars.delete(e)}}updateRemoteAvatar(e,t){var n,i,r,s,a,o,l,c;const h=this.remoteAvatars.get(e);if(h){try{Ma("World",`updateRemoteAvatar: client=${e} pre pos=${null==(n=h.pos)?void 0:n.x},${null==(i=h.pos)?void 0:i.y},${null==(r=h.pos)?void 0:r.z} loaded=${h.loaded} id=${h.id} zone=${null==(s=h.zone)?void 0:s.id}`)}catch(Yc){}"function"==typeof h.setPosition?h.setPosition(t.x,t.y,t.z):h.pos&&(h.pos.x=t.x,h.pos.y=t.y,h.pos.z=t.z||h.pos.z),"function"==typeof h.updateState?h.updateState(t):(null!=t.facing&&(h.facing=t.facing),null!=t.animFrame&&(h.animFrame=t.animFrame)),h.loaded||(console.warn(`Remote avatar ${e} was not loaded; forcing loaded=true so renderer will attempt to draw.`),h.loaded=!0,h.templateLoaded=!0,h.texture&&"function"==typeof h.texture.attach||(h.texture={loaded:!0,attach:()=>{}}));try{Ma("World",`updateRemoteAvatar: client=${e} post pos=${null==(a=h.pos)?void 0:a.x},${null==(o=h.pos)?void 0:o.y},${null==(l=h.pos)?void 0:l.z} loaded=${h.loaded} id=${h.id} zone=${null==(c=h.zone)?void 0:c.id}`)}catch(Yc){}return h}return null}applyRemoteAction(e,t,n,i){const r=this.remoteAvatars.get(e);r&&r.performAction(t,n)}}class Kc{constructor(){return i(this,"init",async e=>{Kc._instance.engine=e;let t=Kc._instance.world=new Hc(Kc._instance,"spritz");t.zoneList.forEach(e=>e.runWhenLoaded(()=>console.log("loading...done"))),t.startMenu({start:{text:"Start Game",prompt:"Please press the button to start...",x:e.screenSize().width/2-75,y:e.screenSize().height/2-50,w:150,h:75,quittable:!1,colours:{top:"#333",bottom:"#777",background:"#999"},onOpen:e=>{this.isPaused=!0},trigger:e=>{e.world.isPaused=!1,e.completed=!0}}})}),i(this,"loadSpritzManifest",async e=>{}),i(this,"loadAvatar",async(e,t)=>{}),i(this,"exportAvatar",async()=>{let e=new $c;e.folder("pixos").file("avatar.json",JSON.stringify({}));let t=await e.generateAsync({type:"blob"});Bc.saveAs(t,"avatar.zip")}),i(this,"update",e=>{Kc._instance.world.tickOuter(e)}),i(this,"render",(e,t)=>{Kc._instance.world.draw(e)}),i(this,"onKeyEvent",e=>{"keydown"===e.type?Kc._instance.engine.keyboard.onKeyDown(e):Kc._instance.engine.keyboard.onKeyUp(e)}),i(this,"onTouchEvent",e=>{if(e.type,Kc._instance&&Kc._instance.engine&&"function"==typeof Kc._instance.engine.touchHandler)try{Kc._instance.engine.touchHandler(e)}catch(t){console.warn("touchHandler error",t)}}),this.shaders={fs:"\n precision mediump int;\n precision mediump float;\n\n const float Near = 0.1;\n const float Far = 50.0;\n\n struct PointLight {\n float enabled;\n vec3 color;\n vec3 position;\n vec3 attenuation;\n vec3 direction;\n vec3 scatteringCoefficients;\n float density;\n };\n\n float unpack(vec4 color) {\n const vec4 bitShifts = vec4(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0), 1.0 / (255.0 * 255.0 * 255.0));\n return dot(color, bitShifts);\n }\n\n varying vec4 vWorldVertex;\n varying vec3 vWorldNormal;\n varying vec3 vTransformedNormal;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n varying vec3 vLighting;\n\n uniform PointLight uLights[32];\n uniform sampler2D uDepthMap;\n uniform vec4 u_id;\n\n uniform float runTransition;\n uniform float useSampler;\n uniform float useDiffuse;\n uniform float isSelected;\n uniform vec4 uColorMultiplier; \n uniform sampler2D uSampler;\n uniform sampler2D uDiffuseMap;\n\n uniform vec3 uDiffuse;\n uniform vec3 uSpecular;\n uniform float uSpecularExponent;\n\n uniform vec3 uLightColor;\n varying vec3 vFragPos;\n varying vec3 vLightDir;\n varying vec3 vViewDir;\n\n float getAttenuation(PointLight light) {\n float distance_from_light;\n vec3 to_light;\n\n to_light = light.position - vPosition.xyz;\n distance_from_light = length(to_light);\n \n float attenuation = 1.0 / (\n 1.0 + light.attenuation.x\n + light.attenuation.y * distance_from_light \n + light.attenuation.z * pow(distance_from_light, 2.0)\n );\n return attenuation;\n }\n\n vec3 getReflectedLightColor(vec3 color) {\n vec3 reflectedLightColor = vec3(0.0);\n \n for(int i = 0; i < 32; i++) {\n if(uLights[i].enabled <= 0.5) continue;\n \n vec3 specular_color;\n vec3 diffuse_color;\n vec3 to_light;\n vec3 reflection;\n vec3 to_camera;\n float cos_angle;\n float attenuation;\n vec3 normal;\n \n // Calculate a vector from the fragment location to the light source\n to_light = normalize(uLights[i].position - vFragPos);\n normal = normalize(vWorldNormal);\n \n // DIFFUSE calculations\n if (useSampler == 1.0) {\n cos_angle = 0.67; // billboard sprites\n cos_angle += dot(to_camera, to_light);\n } else {\n cos_angle = dot(normal, to_light);\n cos_angle = clamp(cos_angle, 0.0, 1.0);\n }\n \n // Scale the color of this fragment based on its angle to the light.\n diffuse_color = uLights[i].color * cos_angle;\n \n // SPECULAR calculations\n reflection = 2.0 * dot(normal, to_light) * normal - to_light;\n reflection = normalize(reflection);\n \n to_camera = normalize(vViewDir);\n \n cos_angle = dot(reflection, to_camera);\n cos_angle = clamp(cos_angle, 0.0, 1.0);\n specular_color = uLights[i].color * cos_angle;\n \n // ATTENUATION calculations\n attenuation = getAttenuation(uLights[i]);\n \n // Combine and attenuate the colors from this light source\n reflectedLightColor += attenuation * (diffuse_color + specular_color);\n }\n \n return clamp(0.5 * color + reflectedLightColor, 0.0, 1.0);\n }\n\n // Diffuse Colour Calculation\n vec3 calculateDiffuse() {\n vec4 texelColors = texture2D(uDiffuseMap, vTextureCoord);\n vec3 color = uDiffuse;\n if(useDiffuse == 1.0) {\n // If texture has valid data, use it multiplied by material diffuse color\n if(texelColors.a > 0.01) {\n color = texelColors.rgb * uDiffuse;\n }\n }\n return color;\n }\n\n // Sampler Texture Colour Calculation\n vec3 calculateSampler(vec4 texelColors) {\n vec3 color = texelColors.rgb;\n if(texelColors.a < 0.1) discard;\n return color;\n }\n\n // linearize depth\n float LinearizeDepth(float depth) {\n float z = depth * 2.0 - 1.0; // back to NDC \n return (2.0 * Near * Far) / (Far + Near - z * (Far - Near));\n }\n\n // fog effect based on depth\n vec4 fogEffect(vec4 color4) {\n float depth = LinearizeDepth(gl_FragCoord.z) / Far;\n vec4 depthVec4 = vec4(vec3(pow(depth, 1.4)), 1.0);\n return (color4 * (1.0 - depth)) + depthVec4;\n }\n\n // Volumetric Calculation\n vec4 volumetricCalculation(vec4 color4) {\n vec3 finalColor;\n\n for(int i = 0; i < 32; i++) {\n if(uLights[i].enabled <= 0.5) continue;\n \n // Calculate the distance from the fragment to the light\n float distance = length(uLights[i].position - vec3(vWorldVertex));\n\n // directional lighting - not working atm\n // if(length(uLights[i].direction) > 0.0){\n // // Calculate the angle between the light direction and the fragment\n // float cos_angle = dot(normalize(uLights[i].direction), normalize(vFragPos - uLights[i].position));\n // // If the fragment is not within the light cone, skip this light\n // if(cos_angle <= 0.0) continue;\n // }\n\n // Calculate the scattering effect\n float scattering = exp(-uLights[i].density * distance);\n vec3 scatteredLight = uLights[i].color * scattering * uLights[i].scatteringCoefficients;\n // Combine the scattered light with the existing lighting\n finalColor += scatteredLight;\n }\n\n return color4 * vec4(finalColor, 1.0);\n }\n\n void main(void) {\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n\n if(runTransition == 1.0) {\n finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n gl_FragColor = finalColor;\n return;\n }\n\n if(useSampler == 1.0) { // sampler\n vec4 texelColors = texture2D(uSampler, vTextureCoord);\n vec3 color = calculateSampler(texelColors);\n vec4 color4 = vec4(getReflectedLightColor(color), texelColors.a);\n finalColor = volumetricCalculation(vec4(color, texelColors.a)) * fogEffect(color4);\n } else { // diffuse\n vec3 color = calculateDiffuse();\n vec4 color4 = vec4((getReflectedLightColor(color)), 1.0);\n finalColor = volumetricCalculation(vec4(color,1.0)) * fogEffect(color4);\n }\n\n // flash on selection\n if(isSelected == 1.0) {\n finalColor = finalColor * uColorMultiplier;\n }\n\n // gl_FragColor = vec4(vec3(u_id),1.0);\n\n gl_FragColor = finalColor;\n }\n",vs:"\n precision mediump float;\n\n attribute vec3 aVertexPosition;\n attribute vec3 aVertexNormal;\n attribute vec2 aTextureCoord;\n \n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjectionMatrix;\n uniform mat3 uNormalMatrix;\n uniform mat3 uCamPos;\n\n uniform vec3 uLightDirection;\n uniform vec3 uCameraPosition;\n varying vec3 vFragPos;\n varying vec3 vLightDir;\n varying vec3 vViewDir;\n\n varying vec4 vWorldVertex;\n varying vec3 vWorldNormal;\n varying vec3 vTransformedNormal;\n varying vec4 vPosition;\n varying vec2 vTextureCoord;\n\n uniform vec3 u_scale;\n\n void main(void) {\n vec3 scaledPosition = aVertexPosition * u_scale;\n\n vWorldVertex = uModelMatrix * vec4(aVertexPosition, 1.0);\n vPosition = uModelMatrix * vec4(scaledPosition, 1.0);\n vTextureCoord = aTextureCoord;\n vTransformedNormal = uNormalMatrix * aVertexNormal;\n vWorldNormal = normalize(mat3(uModelMatrix) * aVertexNormal);\n\n // Pass fragment position to fragment shader\n vFragPos = vec3(uModelMatrix * vec4(scaledPosition, 1.0));\n \n // Calculate view direction and pass to fragment shader\n vViewDir = normalize(uCameraPosition - vFragPos);\n\n gl_Position = uProjectionMatrix * uViewMatrix * vPosition;\n }\n"},this.effects={},this.effectPrograms={},Kc._instance||(Kc._instance=this),Kc._instance}}let Zc=class extends Kc{constructor(){super(...arguments),i(this,"init",async e=>{Kc._instance.loaded=!1,Kc._instance.engine=e;let t=Kc._instance.world=new Hc(Kc._instance,"dynamic");async function n(n){try{let i=e.fileUpload.files[0],r=await Uc.loadAsync(i);Kc._instance.zip=r;let s=JSON.parse(await r.file("manifest.json").async("string"));Ma("Spritz","loaded manifest",s),s.network&&s.network.url&&(Ma("Spritz","Network connection found -- attempting connection to server"),e.networkManager.connect(s.network.url));for(const e of s.initialZones)await t.loadZoneFromZip(e,r,!0,{effect:"cross",duration:500});t.isPaused=!1,n.completed=!0,Kc._instance.loaded=!0}catch(Yc){return void console.error(Yc)}}t.startMenu({start:{pausable:!1,text:"Load Game File",prompt:"Please select a file to load...",x:e.screenSize().width/2-75,y:e.screenSize().height/2-50,w:150,h:75,quittable:!1,colours:{top:"#333",bottom:"#777",background:"#999",text:"#fff"},onEnter:!0,onOpen:e=>{this.isPaused=!0},trigger:async t=>{!function(t,i=!1){if(!i||0===e.fileUpload.files.length)return e.fileUpload.click(),void(e.fileUpload.onchange=e=>n(t));n(null)}(t)}}})})}};class Gc extends Zc{}class Xc extends e.Component{constructor(e){super(e),this.state={spritz:new Gc,updated:Date.now(),zipData:e.zipData}}static getDerivedStateFromProps(e,t){return JSON.stringify(t.networkString)!==JSON.stringify(e.networkString)?{networkString:e.networkString,updated:Date.now()}:null}render(){const{updated:e,spritz:t,zipData:n}=this.state;return y.jsx("div",{style:{margin:0,minHeight:"480px",maxHeight:"1080px"},children:y.jsx(Rc,{class:"pixos",width:480,height:640,SpritzProvider:t,zipData:n??""},`pixos-${e}`)})}}return at.collect(Xc)});
|
|
13
|
+
//# sourceMappingURL=bundle.js.map
|