melonjs 10.9.0 → 10.12.0

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.
Files changed (96) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +32 -25
  3. package/dist/melonjs.js +1635 -2383
  4. package/dist/melonjs.min.js +4 -4
  5. package/dist/melonjs.module.d.ts +929 -1504
  6. package/dist/melonjs.module.js +1581 -2344
  7. package/package.json +18 -18
  8. package/src/audio/audio.js +0 -1
  9. package/src/camera/camera2d.js +1 -16
  10. package/src/entity/entity.js +6 -11
  11. package/src/game.js +2 -2
  12. package/src/geometries/ellipse.js +19 -28
  13. package/src/geometries/line.js +5 -8
  14. package/src/geometries/path2d.js +14 -24
  15. package/src/geometries/poly.js +29 -47
  16. package/src/geometries/rectangle.js +25 -37
  17. package/src/geometries/roundrect.js +8 -12
  18. package/src/index.js +7 -2
  19. package/src/input/gamepad.js +3 -14
  20. package/src/input/keyboard.js +1 -9
  21. package/src/input/pointer.js +0 -1
  22. package/src/input/pointerevent.js +14 -23
  23. package/src/lang/deprecated.js +9 -6
  24. package/src/level/level.js +0 -9
  25. package/src/level/tiled/TMXGroup.js +0 -4
  26. package/src/level/tiled/TMXLayer.js +0 -8
  27. package/src/level/tiled/TMXObject.js +0 -3
  28. package/src/level/tiled/TMXTile.js +4 -5
  29. package/src/level/tiled/TMXTileMap.js +1 -7
  30. package/src/level/tiled/TMXTileset.js +0 -5
  31. package/src/level/tiled/TMXTilesetGroup.js +1 -4
  32. package/src/level/tiled/TMXUtils.js +1 -4
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
  35. package/src/level/tiled/renderer/TMXRenderer.js +1 -7
  36. package/src/loader/loader.js +0 -11
  37. package/src/loader/loadingscreen.js +16 -5
  38. package/src/math/color.js +10 -30
  39. package/src/math/math.js +0 -10
  40. package/src/math/matrix2.js +12 -27
  41. package/src/math/matrix3.js +1 -22
  42. package/src/math/observable_vector2.js +0 -29
  43. package/src/math/observable_vector3.js +0 -29
  44. package/src/math/vector2.js +3 -40
  45. package/src/math/vector3.js +4 -41
  46. package/src/particles/emitter.js +11 -12
  47. package/src/physics/body.js +4 -5
  48. package/src/physics/bounds.js +5 -19
  49. package/src/physics/collision.js +1 -13
  50. package/src/physics/detector.js +6 -56
  51. package/src/physics/quadtree.js +0 -7
  52. package/src/physics/response.js +48 -0
  53. package/src/physics/sat.js +4 -4
  54. package/src/physics/world.js +0 -4
  55. package/src/plugin/plugin.js +0 -2
  56. package/src/polyfill/roundrect.js +4 -2
  57. package/src/renderable/GUI.js +11 -14
  58. package/src/renderable/collectable.js +1 -0
  59. package/src/renderable/colorlayer.js +9 -7
  60. package/src/renderable/container.js +38 -64
  61. package/src/renderable/dragndrop.js +1 -10
  62. package/src/renderable/imagelayer.js +8 -12
  63. package/src/renderable/light2d.js +118 -0
  64. package/src/renderable/renderable.js +27 -48
  65. package/src/renderable/sprite.js +17 -29
  66. package/src/renderable/trigger.js +10 -3
  67. package/src/state/stage.js +72 -6
  68. package/src/state/state.js +22 -23
  69. package/src/system/device.js +14 -53
  70. package/src/system/event.js +11 -0
  71. package/src/system/pooling.js +20 -9
  72. package/src/system/save.js +9 -11
  73. package/src/system/timer.js +239 -218
  74. package/src/text/bitmaptextdata.js +1 -4
  75. package/src/text/glyph.js +2 -2
  76. package/src/text/text.js +25 -24
  77. package/src/text/textmetrics.js +0 -2
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +2 -2
  80. package/src/tweens/tween.js +1 -13
  81. package/src/utils/agent.js +1 -3
  82. package/src/utils/array.js +0 -3
  83. package/src/utils/file.js +0 -2
  84. package/src/utils/function.js +0 -2
  85. package/src/utils/string.js +0 -6
  86. package/src/utils/utils.js +0 -3
  87. package/src/video/canvas/canvas_renderer.js +73 -90
  88. package/src/video/renderer.js +34 -49
  89. package/src/video/{texture.js → texture/atlas.js} +10 -8
  90. package/src/video/{texture_cache.js → texture/cache.js} +4 -5
  91. package/src/video/texture/canvas_texture.js +99 -0
  92. package/src/video/video.js +3 -3
  93. package/src/video/webgl/glshader.js +0 -5
  94. package/src/video/webgl/utils/uniforms.js +3 -6
  95. package/src/video/webgl/webgl_compositor.js +0 -14
  96. package/src/video/webgl/webgl_renderer.js +73 -97
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * melonJS Game Engine - v10.9.0
2
+ * melonJS Game Engine - v10.12.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
6
6
  * @copyright (C) 2011 - 2022 Olivier Biot
7
7
  */
8
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).me={})}(this,(function(exports){"use strict";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},check=function(t){return t&&t.Math==Math&&t},global$m=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||Function("return this")(),objectGetOwnPropertyDescriptor={},fails$8=function(t){try{return!!t()}catch(t){return!0}},fails$7=fails$8,descriptors=!fails$7((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),fails$6=fails$8,functionBindNative=!fails$6((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),NATIVE_BIND$1=functionBindNative,call$4=Function.prototype.call,functionCall=NATIVE_BIND$1?call$4.bind(call$4):function(){return call$4.apply(call$4,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable={}.propertyIsEnumerable,getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$1&&!$propertyIsEnumerable.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(t){var e=getOwnPropertyDescriptor$1(this,t);return!!e&&e.enumerable}:$propertyIsEnumerable;var createPropertyDescriptor$2=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},NATIVE_BIND=functionBindNative,FunctionPrototype$1=Function.prototype,bind=FunctionPrototype$1.bind,call$3=FunctionPrototype$1.call,uncurryThis$9=NATIVE_BIND&&bind.bind(call$3,call$3),functionUncurryThis=NATIVE_BIND?function(t){return t&&uncurryThis$9(t)}:function(t){return t&&function(){return call$3.apply(t,arguments)}},uncurryThis$8=functionUncurryThis,toString$2=uncurryThis$8({}.toString),stringSlice=uncurryThis$8("".slice),classofRaw=function(t){return stringSlice(toString$2(t),8,-1)},global$l=global$m,uncurryThis$7=functionUncurryThis,fails$5=fails$8,classof=classofRaw,Object$3=global$l.Object,split=uncurryThis$7("".split),indexedObject=fails$5((function(){return!Object$3("z").propertyIsEnumerable(0)}))?function(t){return"String"==classof(t)?split(t,""):Object$3(t)}:Object$3,global$k=global$m,TypeError$7=global$k.TypeError,requireObjectCoercible$2=function(t){if(null==t)throw TypeError$7("Can't call method on "+t);return t},IndexedObject=indexedObject,requireObjectCoercible$1=requireObjectCoercible$2,toIndexedObject$3=function(t){return IndexedObject(requireObjectCoercible$1(t))},isCallable$a=function(t){return"function"==typeof t},isCallable$9=isCallable$a,isObject$5=function(t){return"object"==typeof t?null!==t:isCallable$9(t)},global$j=global$m,isCallable$8=isCallable$a,aFunction=function(t){return isCallable$8(t)?t:void 0},getBuiltIn$3=function(t,e){return arguments.length<2?aFunction(global$j[t]):global$j[t]&&global$j[t][e]},uncurryThis$6=functionUncurryThis,objectIsPrototypeOf=uncurryThis$6({}.isPrototypeOf),getBuiltIn$2=getBuiltIn$3,engineUserAgent=getBuiltIn$2("navigator","userAgent")||"",global$i=global$m,userAgent=engineUserAgent,process$1=global$i.process,Deno=global$i.Deno,versions=process$1&&process$1.versions||Deno&&Deno.version,v8=versions&&versions.v8,match,version$1;v8&&(match=v8.split("."),version$1=match[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version$1&&userAgent&&(match=userAgent.match(/Edge\/(\d+)/),(!match||match[1]>=74)&&(match=userAgent.match(/Chrome\/(\d+)/),match&&(version$1=+match[1])));var engineV8Version=version$1,V8_VERSION=engineV8Version,fails$4=fails$8,nativeSymbol=!!Object.getOwnPropertySymbols&&!fails$4((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&V8_VERSION&&V8_VERSION<41})),NATIVE_SYMBOL$1=nativeSymbol,useSymbolAsUid=NATIVE_SYMBOL$1&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,global$h=global$m,getBuiltIn$1=getBuiltIn$3,isCallable$7=isCallable$a,isPrototypeOf=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,Object$2=global$h.Object,isSymbol$2=USE_SYMBOL_AS_UID$1?function(t){return"symbol"==typeof t}:function(t){var e=getBuiltIn$1("Symbol");return isCallable$7(e)&&isPrototypeOf(e.prototype,Object$2(t))},global$g=global$m,String$2=global$g.String,tryToString$1=function(t){try{return String$2(t)}catch(t){return"Object"}},global$f=global$m,isCallable$6=isCallable$a,tryToString=tryToString$1,TypeError$6=global$f.TypeError,aCallable$1=function(t){if(isCallable$6(t))return t;throw TypeError$6(tryToString(t)+" is not a function")},aCallable=aCallable$1,getMethod$1=function(t,e){var i=t[e];return null==i?void 0:aCallable(i)},global$e=global$m,call$2=functionCall,isCallable$5=isCallable$a,isObject$4=isObject$5,TypeError$5=global$e.TypeError,ordinaryToPrimitive$1=function(t,e){var i,o;if("string"===e&&isCallable$5(i=t.toString)&&!isObject$4(o=call$2(i,t)))return o;if(isCallable$5(i=t.valueOf)&&!isObject$4(o=call$2(i,t)))return o;if("string"!==e&&isCallable$5(i=t.toString)&&!isObject$4(o=call$2(i,t)))return o;throw TypeError$5("Can't convert object to primitive value")},shared$3={exports:{}},global$d=global$m,defineProperty$1=Object.defineProperty,setGlobal$3=function(t,e){try{defineProperty$1(global$d,t,{value:e,configurable:!0,writable:!0})}catch(i){global$d[t]=e}return e},global$c=global$m,setGlobal$2=setGlobal$3,SHARED="__core-js_shared__",store$3=global$c[SHARED]||setGlobal$2(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$3.exports=function(t,e){return store$2[t]||(store$2[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.22.5",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.22.5/LICENSE",source:"https://github.com/zloirock/core-js"});var global$b=global$m,requireObjectCoercible=requireObjectCoercible$2,Object$1=global$b.Object,toObject$1=function(t){return Object$1(requireObjectCoercible(t))},uncurryThis$5=functionUncurryThis,toObject=toObject$1,hasOwnProperty=uncurryThis$5({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(t,e){return hasOwnProperty(toObject(t),e)},uncurryThis$4=functionUncurryThis,id=0,postfix=Math.random(),toString$1=uncurryThis$4(1..toString),uid$2=function(t){return"Symbol("+(void 0===t?"":t)+")_"+toString$1(++id+postfix,36)},global$a=global$m,shared$2=shared$3.exports,hasOwn$6=hasOwnProperty_1,uid$1=uid$2,NATIVE_SYMBOL=nativeSymbol,USE_SYMBOL_AS_UID=useSymbolAsUid,WellKnownSymbolsStore=shared$2("wks"),Symbol$1=global$a.Symbol,symbolFor=Symbol$1&&Symbol$1.for,createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$1:Symbol$1&&Symbol$1.withoutSetter||uid$1,wellKnownSymbol$1=function(t){if(!hasOwn$6(WellKnownSymbolsStore,t)||!NATIVE_SYMBOL&&"string"!=typeof WellKnownSymbolsStore[t]){var e="Symbol."+t;NATIVE_SYMBOL&&hasOwn$6(Symbol$1,t)?WellKnownSymbolsStore[t]=Symbol$1[t]:WellKnownSymbolsStore[t]=USE_SYMBOL_AS_UID&&symbolFor?symbolFor(e):createWellKnownSymbol(e)}return WellKnownSymbolsStore[t]},global$9=global$m,call$1=functionCall,isObject$3=isObject$5,isSymbol$1=isSymbol$2,getMethod=getMethod$1,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol=wellKnownSymbol$1,TypeError$4=global$9.TypeError,TO_PRIMITIVE=wellKnownSymbol("toPrimitive"),toPrimitive$1=function(t,e){if(!isObject$3(t)||isSymbol$1(t))return t;var i,o=getMethod(t,TO_PRIMITIVE);if(o){if(void 0===e&&(e="default"),i=call$1(o,t,e),!isObject$3(i)||isSymbol$1(i))return i;throw TypeError$4("Can't convert object to primitive value")}return void 0===e&&(e="number"),ordinaryToPrimitive(t,e)},toPrimitive=toPrimitive$1,isSymbol=isSymbol$2,toPropertyKey$2=function(t){var e=toPrimitive(t,"string");return isSymbol(e)?e:e+""},global$8=global$m,isObject$2=isObject$5,document$1=global$8.document,EXISTS$1=isObject$2(document$1)&&isObject$2(document$1.createElement),documentCreateElement=function(t){return EXISTS$1?document$1.createElement(t):{}},DESCRIPTORS$6=descriptors,fails$3=fails$8,createElement=documentCreateElement,ie8DomDefine=!DESCRIPTORS$6&&!fails$3((function(){return 7!=Object.defineProperty(createElement("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$5=descriptors,call=functionCall,propertyIsEnumerableModule=objectPropertyIsEnumerable,createPropertyDescriptor$1=createPropertyDescriptor$2,toIndexedObject$2=toIndexedObject$3,toPropertyKey$1=toPropertyKey$2,hasOwn$5=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$5?$getOwnPropertyDescriptor$1:function(t,e){if(t=toIndexedObject$2(t),e=toPropertyKey$1(e),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$1(t,e)}catch(t){}if(hasOwn$5(t,e))return createPropertyDescriptor$1(!call(propertyIsEnumerableModule.f,t,e),t[e])};var objectDefineProperty={},DESCRIPTORS$4=descriptors,fails$2=fails$8,v8PrototypeDefineBug=DESCRIPTORS$4&&fails$2((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),global$7=global$m,isObject$1=isObject$5,String$1=global$7.String,TypeError$3=global$7.TypeError,anObject$2=function(t){if(isObject$1(t))return t;throw TypeError$3(String$1(t)+" is not an object")},global$6=global$m,DESCRIPTORS$3=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,anObject$1=anObject$2,toPropertyKey=toPropertyKey$2,TypeError$2=global$6.TypeError,$defineProperty=Object.defineProperty,$getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$3?V8_PROTOTYPE_DEFINE_BUG?function(t,e,i){if(anObject$1(t),e=toPropertyKey(e),anObject$1(i),"function"==typeof t&&"prototype"===e&&"value"in i&&WRITABLE in i&&!i[WRITABLE]){var o=$getOwnPropertyDescriptor(t,e);o&&o[WRITABLE]&&(t[e]=i.value,i={configurable:CONFIGURABLE$1 in i?i[CONFIGURABLE$1]:o[CONFIGURABLE$1],enumerable:ENUMERABLE in i?i[ENUMERABLE]:o[ENUMERABLE],writable:!1})}return $defineProperty(t,e,i)}:$defineProperty:function(t,e,i){if(anObject$1(t),e=toPropertyKey(e),anObject$1(i),IE8_DOM_DEFINE)try{return $defineProperty(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError$2("Accessors not supported");return"value"in i&&(t[e]=i.value),t};var DESCRIPTORS$2=descriptors,definePropertyModule$1=objectDefineProperty,createPropertyDescriptor=createPropertyDescriptor$2,createNonEnumerableProperty$3=DESCRIPTORS$2?function(t,e,i){return definePropertyModule$1.f(t,e,createPropertyDescriptor(1,i))}:function(t,e,i){return t[e]=i,t},makeBuiltIn$2={exports:{}},DESCRIPTORS$1=descriptors,hasOwn$4=hasOwnProperty_1,FunctionPrototype=Function.prototype,getDescriptor=DESCRIPTORS$1&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$4(FunctionPrototype,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$1||DESCRIPTORS$1&&getDescriptor(FunctionPrototype,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},uncurryThis$3=functionUncurryThis,isCallable$4=isCallable$a,store$1=sharedStore,functionToString=uncurryThis$3(Function.toString);isCallable$4(store$1.inspectSource)||(store$1.inspectSource=function(t){return functionToString(t)});var inspectSource$2=store$1.inspectSource,global$5=global$m,isCallable$3=isCallable$a,inspectSource$1=inspectSource$2,WeakMap$1=global$5.WeakMap,nativeWeakMap=isCallable$3(WeakMap$1)&&/native code/.test(inspectSource$1(WeakMap$1)),shared$1=shared$3.exports,uid=uid$2,keys=shared$1("keys"),sharedKey$1=function(t){return keys[t]||(keys[t]=uid(t))},hiddenKeys$3={},NATIVE_WEAK_MAP=nativeWeakMap,global$4=global$m,uncurryThis$2=functionUncurryThis,isObject=isObject$5,createNonEnumerableProperty$2=createNonEnumerableProperty$3,hasOwn$3=hasOwnProperty_1,shared=sharedStore,sharedKey=sharedKey$1,hiddenKeys$2=hiddenKeys$3,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$1=global$4.TypeError,WeakMap=global$4.WeakMap,set,get,has,enforce=function(t){return has(t)?get(t):set(t,{})},getterFor=function(t){return function(e){var i;if(!isObject(e)||(i=get(e)).type!==t)throw TypeError$1("Incompatible receiver, "+t+" required");return i}};if(NATIVE_WEAK_MAP||shared.state){var store=shared.state||(shared.state=new WeakMap),wmget=uncurryThis$2(store.get),wmhas=uncurryThis$2(store.has),wmset=uncurryThis$2(store.set);set=function(t,e){if(wmhas(store,t))throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);return e.facade=t,wmset(store,t,e),e},get=function(t){return wmget(store,t)||{}},has=function(t){return wmhas(store,t)}}else{var STATE=sharedKey("state");hiddenKeys$2[STATE]=!0,set=function(t,e){if(hasOwn$3(t,STATE))throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);return e.facade=t,createNonEnumerableProperty$2(t,STATE,e),e},get=function(t){return hasOwn$3(t,STATE)?t[STATE]:{}},has=function(t){return hasOwn$3(t,STATE)}}var internalState={set:set,get:get,has:has,enforce:enforce,getterFor:getterFor},fails$1=fails$8,isCallable$2=isCallable$a,hasOwn$2=hasOwnProperty_1,DESCRIPTORS=descriptors,CONFIGURABLE_FUNCTION_NAME=functionName.CONFIGURABLE,inspectSource=inspectSource$2,InternalStateModule=internalState,enforceInternalState=InternalStateModule.enforce,getInternalState=InternalStateModule.get,defineProperty=Object.defineProperty,CONFIGURABLE_LENGTH=DESCRIPTORS&&!fails$1((function(){return 8!==defineProperty((function(){}),"length",{value:8}).length})),TEMPLATE=String(String).split("String"),makeBuiltIn$1=makeBuiltIn$2.exports=function(t,e,i){if("Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!hasOwn$2(t,"name")||CONFIGURABLE_FUNCTION_NAME&&t.name!==e)&&defineProperty(t,"name",{value:e,configurable:!0}),CONFIGURABLE_LENGTH&&i&&hasOwn$2(i,"arity")&&t.length!==i.arity&&defineProperty(t,"length",{value:i.arity}),i&&hasOwn$2(i,"constructor")&&i.constructor){if(DESCRIPTORS)try{defineProperty(t,"prototype",{writable:!1})}catch(t){}}else t.prototype=void 0;var o=enforceInternalState(t);return hasOwn$2(o,"source")||(o.source=TEMPLATE.join("string"==typeof e?e:"")),t};Function.prototype.toString=makeBuiltIn$1((function(){return isCallable$2(this)&&getInternalState(this).source||inspectSource(this)}),"toString");var global$3=global$m,isCallable$1=isCallable$a,createNonEnumerableProperty$1=createNonEnumerableProperty$3,makeBuiltIn=makeBuiltIn$2.exports,setGlobal$1=setGlobal$3,defineBuiltIn$1=function(t,e,i,o){var r=!!o&&!!o.unsafe,n=!!o&&!!o.enumerable,s=!!o&&!!o.noTargetGet,a=o&&void 0!==o.name?o.name:e;return isCallable$1(i)&&makeBuiltIn(i,a,o),t===global$3?(n?t[e]=i:setGlobal$1(e,i),t):(r?!s&&t[e]&&(n=!0):delete t[e],n?t[e]=i:createNonEnumerableProperty$1(t,e,i),t)},objectGetOwnPropertyNames={},ceil=Math.ceil,floor=Math.floor,toIntegerOrInfinity$2=function(t){var e=+t;return e!=e||0===e?0:(e>0?floor:ceil)(e)},toIntegerOrInfinity$1=toIntegerOrInfinity$2,max=Math.max,min$1=Math.min,toAbsoluteIndex$1=function(t,e){var i=toIntegerOrInfinity$1(t);return i<0?max(i+e,0):min$1(i,e)},toIntegerOrInfinity=toIntegerOrInfinity$2,min=Math.min,toLength$1=function(t){return t>0?min(toIntegerOrInfinity(t),9007199254740991):0},toLength=toLength$1,lengthOfArrayLike$1=function(t){return toLength(t.length)},toIndexedObject$1=toIndexedObject$3,toAbsoluteIndex=toAbsoluteIndex$1,lengthOfArrayLike=lengthOfArrayLike$1,createMethod=function(t){return function(e,i,o){var r,n=toIndexedObject$1(e),s=lengthOfArrayLike(n),a=toAbsoluteIndex(o,s);if(t&&i!=i){for(;s>a;)if((r=n[a++])!=r)return!0}else for(;s>a;a++)if((t||a in n)&&n[a]===i)return t||a||0;return!t&&-1}},arrayIncludes={includes:createMethod(!0),indexOf:createMethod(!1)},uncurryThis$1=functionUncurryThis,hasOwn$1=hasOwnProperty_1,toIndexedObject=toIndexedObject$3,indexOf=arrayIncludes.indexOf,hiddenKeys$1=hiddenKeys$3,push=uncurryThis$1([].push),objectKeysInternal=function(t,e){var i,o=toIndexedObject(t),r=0,n=[];for(i in o)!hasOwn$1(hiddenKeys$1,i)&&hasOwn$1(o,i)&&push(n,i);for(;e.length>r;)hasOwn$1(o,i=e[r++])&&(~indexOf(n,i)||push(n,i));return n},enumBugKeys$1=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys=objectKeysInternal,enumBugKeys=enumBugKeys$1,hiddenKeys=enumBugKeys.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(t){return internalObjectKeys(t,hiddenKeys)};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var getBuiltIn=getBuiltIn$3,uncurryThis=functionUncurryThis,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,anObject=anObject$2,concat=uncurryThis([].concat),ownKeys$1=getBuiltIn("Reflect","ownKeys")||function(t){var e=getOwnPropertyNamesModule.f(anObject(t)),i=getOwnPropertySymbolsModule.f;return i?concat(e,i(t)):e},hasOwn=hasOwnProperty_1,ownKeys=ownKeys$1,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,definePropertyModule=objectDefineProperty,copyConstructorProperties$1=function(t,e,i){for(var o=ownKeys(e),r=definePropertyModule.f,n=getOwnPropertyDescriptorModule.f,s=0;s<o.length;s++){var a=o[s];hasOwn(t,a)||i&&hasOwn(i,a)||r(t,a,n(e,a))}},fails=fails$8,isCallable=isCallable$a,replacement=/#|\.prototype\./,isForced$1=function(t,e){var i=data$1[normalize$1(t)];return i==POLYFILL||i!=NATIVE&&(isCallable(e)?fails(e):!!e)},normalize$1=isForced$1.normalize=function(t){return String(t).replace(replacement,".").toLowerCase()},data$1=isForced$1.data={},NATIVE=isForced$1.NATIVE="N",POLYFILL=isForced$1.POLYFILL="P",isForced_1=isForced$1,global$2=global$m,getOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,createNonEnumerableProperty=createNonEnumerableProperty$3,defineBuiltIn=defineBuiltIn$1,setGlobal=setGlobal$3,copyConstructorProperties=copyConstructorProperties$1,isForced=isForced_1,_export=function(t,e){var i,o,r,n,s,a=t.target,l=t.global,h=t.stat;if(i=l?global$2:h?global$2[a]||setGlobal(a,{}):(global$2[a]||{}).prototype)for(o in e){if(n=e[o],r=t.noTargetGet?(s=getOwnPropertyDescriptor(i,o))&&s.value:i[o],!isForced(l?o:a+(h?".":"#")+o,t.forced)&&void 0!==r){if(typeof n==typeof r)continue;copyConstructorProperties(n,r)}(t.sham||r&&r.sham)&&createNonEnumerableProperty(n,"sham",!0),defineBuiltIn(i,o,n,t)}},$=_export,global$1=global$m;if($({global:!0},{globalThis:global$1}),"undefined"!=typeof globalThis&&void 0===globalThis.console&&(globalThis.console={},globalThis.console.log=function(){},globalThis.console.assert=function(){},globalThis.console.warn=function(){},globalThis.console.error=function(){alert(Array.prototype.slice.call(arguments).join(", "))}),"performance"in globalThis==!1&&(globalThis.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in globalThis.performance==!1){var nowOffset=Date.now();performance.timing&&performance.timing.navigationStart&&(nowOffset=performance.timing.navigationStart),globalThis.performance.now=function(){return Date.now()-nowOffset}}function capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}function trimLeft(t){return t.replace(/^\s+/,"")}function trimRight(t){return t.replace(/\s+$/,"")}function isNumeric(t){return"string"==typeof t&&(t=t.trim()),!isNaN(t)&&/[+-]?([0-9]*[.])?[0-9]+/.test(t)}function isBoolean(t){var e=t.trim();return"true"===e||"false"===e}function toHex$1(t){for(var e="",i=0;i<t.length;)e+=t.charCodeAt(i++).toString(16);return e}var stringUtils=Object.freeze({__proto__:null,capitalize:capitalize,trimLeft:trimLeft,trimRight:trimRight,isNumeric:isNumeric,isBoolean:isBoolean,toHex:toHex$1}),vendors$1=["ms","MS","moz","webkit","o"];function prefixed(t,e){if(t in(e=e||globalThis))return e[t];var i,o=capitalize(t);return vendors$1.some((function(t){var r=t+o;return i=r in e?e[r]:void 0})),i}function setPrefixed(t,e,i){if(!(t in(i=i||globalThis))){var o=capitalize(t);return vendors$1.some((function(t){var r=t+o;if(r in i)return i[r]=e,!0})),!1}i[t]=e}var agentUtils=Object.freeze({__proto__:null,prefixed:prefixed,setPrefixed:setPrefixed}),DEG_TO_RAD=Math.PI/180,RAD_TO_DEG=180/Math.PI,TAU=2*Math.PI,ETA=.5*Math.PI,EPSILON=1e-6;function isPowerOfTwo(t){return 0==(t&t-1)}function nextPowerOfTwo(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function degToRad(t){return t*DEG_TO_RAD}function radToDeg(t){return t*RAD_TO_DEG}function clamp(t,e,i){return t<e?e:t>i?i:+t}function random$1(t,e){return~~(Math.random()*(e-t))+t}function randomFloat(t,e){return Math.random()*(e-t)+t}function weightedRandom$1(t,e){return~~(Math.pow(Math.random(),2)*(e-t))+t}function round(t,e){void 0===e&&(e=0);var i=Math.pow(10,e);return~~(.5+t*i)/i}function toBeCloseTo(t,e,i){return void 0===i&&(i=2),Math.abs(t-e)<Math.pow(10,-i)/2}var math=Object.freeze({__proto__:null,DEG_TO_RAD:DEG_TO_RAD,RAD_TO_DEG:RAD_TO_DEG,TAU:TAU,ETA:ETA,EPSILON:EPSILON,isPowerOfTwo:isPowerOfTwo,nextPowerOfTwo:nextPowerOfTwo,degToRad:degToRad,radToDeg:radToDeg,clamp:clamp,random:random$1,randomFloat:randomFloat,weightedRandom:weightedRandom$1,round:round,toBeCloseTo:toBeCloseTo});function remove(t,e){var i=Array.prototype.indexOf.call(t,e);return-1!==i&&Array.prototype.splice.call(t,i,1),t}function random(t){return t[random$1(0,t.length)]}function weightedRandom(t){return t[weightedRandom$1(0,t.length)]}var arrayUtils=Object.freeze({__proto__:null,remove:remove,random:random,weightedRandom:weightedRandom}),REMOVE_PATH=/^.*(\\|\/|\:)/,REMOVE_EXT=/\.[^\.]*$/;function getBasename(t){return t.replace(REMOVE_PATH,"").replace(REMOVE_EXT,"")}function getExtension(t){return t.substring(t.lastIndexOf(".")+1,t.length)}var fileUtils=Object.freeze({__proto__:null,getBasename:getBasename,getExtension:getExtension});function defer(t,e){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];return setTimeout.apply(void 0,[t.bind(e),.01].concat(i))}function throttle(t,e,i){var o,r=globalThis.performance.now();return"boolean"!=typeof i&&(i=!1),function(){var n=globalThis.performance.now(),s=n-r,a=arguments;if(!(s<e))return r=n,t.apply(null,a);!1===i&&(clearTimeout(o),o=setTimeout((function(){return r=n,t.apply(null,a)}),s))}}var fnUtils=Object.freeze({__proto__:null,defer:defer,throttle:throttle}),ObjectPool=function(){this.objectClass={},this.instance_counter=0};ObjectPool.prototype.register=function(t,e,i){if(void 0===i&&(i=!1),void 0===e)throw new Error("Cannot register object '"+t+"', invalid class");this.objectClass[t]={class:e,pool:i?[]:void 0}},ObjectPool.prototype.pull=function(t){for(var e=arguments,i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=e[o];var r=this.objectClass[t];if(r){var n,s=r.class,a=r.pool;return a&&(n=a.pop())?(i.shift(),"function"==typeof n.onResetEvent&&n.onResetEvent.apply(n,i),this.instance_counter--):(i[0]=s,n=new(s.bind.apply(s,i)),a&&(n.className=t)),n}throw new Error("Cannot instantiate object of type '"+t+"'")},ObjectPool.prototype.purge=function(){for(var t in this.objectClass)this.objectClass[t]&&(this.objectClass[t].pool=[]);this.instance_counter=0},ObjectPool.prototype.push=function(t,e){if(void 0===e&&(e=!0),!this.poolable(t)){if(!0===e)throw new Error("me.pool: object "+t+" cannot be recycled");return!1}return this.objectClass[t.className].pool.push(t),this.instance_counter++,!0},ObjectPool.prototype.exists=function(t){return t in this.objectClass},ObjectPool.prototype.poolable=function(t){var e=t.className;return void 0!==e&&"function"==typeof t.onResetEvent&&e in this.objectClass&&"undefined"!==this.objectClass[e].pool},ObjectPool.prototype.getInstanceCount=function(){return this.instance_counter};var pool$1=new ObjectPool,Vector2d=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.onResetEvent(t,e)};Vector2d.prototype.onResetEvent=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},Vector2d.prototype._set=function(t,e){return this.x=t,this.y=e,this},Vector2d.prototype.set=function(t,e){if(t!==+t||e!==+e)throw new Error("invalid x,y parameters (not a number)");return this._set(t,e)},Vector2d.prototype.setZero=function(){return this.set(0,0)},Vector2d.prototype.setV=function(t){return this._set(t.x,t.y)},Vector2d.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y)},Vector2d.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y)},Vector2d.prototype.scale=function(t,e){return this._set(this.x*t,this.y*(void 0!==e?e:t))},Vector2d.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y))},Vector2d.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2)},Vector2d.prototype.scaleV=function(t){return this._set(this.x*t.x,this.y*t.y)},Vector2d.prototype.div=function(t){return this._set(this.x/t,this.y/t)},Vector2d.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y)},Vector2d.prototype.clamp=function(t,e){return new Vector2d(clamp(this.x,t,e),clamp(this.y,t,e))},Vector2d.prototype.clampSelf=function(t,e){return this._set(clamp(this.x,t,e),clamp(this.y,t,e))},Vector2d.prototype.minV=function(t){return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y)},Vector2d.prototype.maxV=function(t){return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y)},Vector2d.prototype.floor=function(){return new Vector2d(Math.floor(this.x),Math.floor(this.y))},Vector2d.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y))},Vector2d.prototype.ceil=function(){return new Vector2d(Math.ceil(this.x),Math.ceil(this.y))},Vector2d.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},Vector2d.prototype.negate=function(){return new Vector2d(-this.x,-this.y)},Vector2d.prototype.negateSelf=function(){return this._set(-this.x,-this.y)},Vector2d.prototype.copy=function(t){return this._set(t.x,t.y)},Vector2d.prototype.equals=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.x===t&&this.y===e},Vector2d.prototype.normalize=function(){return this.div(this.length()||1)},Vector2d.prototype.perp=function(){return this._set(this.y,-this.x)},Vector2d.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var r=this.x-i,n=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(r*s-n*a+i,r*a+n*s+o)},Vector2d.prototype.dot=function(t){return this.x*t.x+this.y*t.y},Vector2d.prototype.cross=function(t){return this.x*t.y-this.y*t.x},Vector2d.prototype.length2=function(){return this.dot(this)},Vector2d.prototype.length=function(){return Math.sqrt(this.length2())},Vector2d.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},Vector2d.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},Vector2d.prototype.angle=function(t){return Math.acos(clamp(this.dot(t)/(this.length()*t.length()),-1,1))},Vector2d.prototype.project=function(t){return this.scale(this.dot(t)/t.length2())},Vector2d.prototype.projectN=function(t){return this.scale(this.dot(t))},Vector2d.prototype.clone=function(){return pool$1.pull("Vector2d",this.x,this.y)},Vector2d.prototype.toString=function(){return"x:"+this.x+",y:"+this.y};var toHex=function(t){return"0123456789ABCDEF".charAt(t-t%16>>4)+"0123456789ABCDEF".charAt(t%16)},rgbaRx=/^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/,hex3Rx=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,hex4Rx=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,hex6Rx=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,hex8Rx=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,cssToRGB=new Map;[["black",[0,0,0]],["silver",[192,192,129]],["gray",[128,128,128]],["white",[255,255,255]],["maroon",[128,0,0]],["red",[255,0,0]],["purple",[128,0,128]],["fuchsia",[255,0,255]],["green",[0,128,0]],["lime",[0,255,0]],["olive",[128,128,0]],["yellow",[255,255,0]],["navy",[0,0,128]],["blue",[0,0,255]],["teal",[0,128,128]],["aqua",[0,255,255]],["orange",[255,165,0]],["aliceblue",[240,248,245]],["antiquewhite",[250,235,215]],["aquamarine",[127,255,212]],["azure",[240,255,255]],["beige",[245,245,220]],["bisque",[255,228,196]],["blanchedalmond",[255,235,205]],["blueviolet",[138,43,226]],["brown",[165,42,42]],["burlywood",[222,184,35]],["cadetblue",[95,158,160]],["chartreuse",[127,255,0]],["chocolate",[210,105,30]],["coral",[255,127,80]],["cornflowerblue",[100,149,237]],["cornsilk",[255,248,220]],["crimson",[220,20,60]],["darkblue",[0,0,139]],["darkcyan",[0,139,139]],["darkgoldenrod",[184,134,11]],["darkgray[*]",[169,169,169]],["darkgreen",[0,100,0]],["darkgrey[*]",[169,169,169]],["darkkhaki",[189,183,107]],["darkmagenta",[139,0,139]],["darkolivegreen",[85,107,47]],["darkorange",[255,140,0]],["darkorchid",[153,50,204]],["darkred",[139,0,0]],["darksalmon",[233,150,122]],["darkseagreen",[143,188,143]],["darkslateblue",[72,61,139]],["darkslategray",[47,79,79]],["darkslategrey",[47,79,79]],["darkturquoise",[0,206,209]],["darkviolet",[148,0,211]],["deeppink",[255,20,147]],["deepskyblue",[0,191,255]],["dimgray",[105,105,105]],["dimgrey",[105,105,105]],["dodgerblue",[30,144,255]],["firebrick",[178,34,34]],["floralwhite",[255,250,240]],["forestgreen",[34,139,34]],["gainsboro",[220,220,220]],["ghostwhite",[248,248,255]],["gold",[255,215,0]],["goldenrod",[218,165,32]],["greenyellow",[173,255,47]],["grey",[128,128,128]],["honeydew",[240,255,240]],["hotpink",[255,105,180]],["indianred",[205,92,92]],["indigo",[75,0,130]],["ivory",[255,255,240]],["khaki",[240,230,140]],["lavender",[230,230,250]],["lavenderblush",[255,240,245]],["lawngreen",[124,252,0]],["lemonchiffon",[255,250,205]],["lightblue",[173,216,230]],["lightcoral",[240,128,128]],["lightcyan",[224,255,255]],["lightgoldenrodyellow",[250,250,210]],["lightgray",[211,211,211]],["lightgreen",[144,238,144]],["lightgrey",[211,211,211]],["lightpink",[255,182,193]],["lightsalmon",[255,160,122]],["lightseagreen",[32,178,170]],["lightskyblue",[135,206,250]],["lightslategray",[119,136,153]],["lightslategrey",[119,136,153]],["lightsteelblue",[176,196,222]],["lightyellow",[255,255,224]],["limegreen",[50,205,50]],["linen",[250,240,230]],["mediumaquamarine",[102,205,170]],["mediumblue",[0,0,205]],["mediumorchid",[186,85,211]],["mediumpurple",[147,112,219]],["mediumseagreen",[60,179,113]],["mediumslateblue",[123,104,238]],["mediumspringgreen",[0,250,154]],["mediumturquoise",[72,209,204]],["mediumvioletred",[199,21,133]],["midnightblue",[25,25,112]],["mintcream",[245,255,250]],["mistyrose",[255,228,225]],["moccasin",[255,228,181]],["navajowhite",[255,222,173]],["oldlace",[253,245,230]],["olivedrab",[107,142,35]],["orangered",[255,69,0]],["orchid",[218,112,214]],["palegoldenrod",[238,232,170]],["palegreen",[152,251,152]],["paleturquoise",[175,238,238]],["palevioletred",[219,112,147]],["papayawhip",[255,239,213]],["peachpuff",[255,218,185]],["peru",[205,133,63]],["pink",[255,192,203]],["plum",[221,160,221]],["powderblue",[176,224,230]],["rosybrown",[188,143,143]],["royalblue",[65,105,225]],["saddlebrown",[139,69,19]],["salmon",[250,128,114]],["sandybrown",[244,164,96]],["seagreen",[46,139,87]],["seashell",[255,245,238]],["sienna",[160,82,45]],["skyblue",[135,206,235]],["slateblue",[106,90,205]],["slategray",[112,128,144]],["slategrey",[112,128,144]],["snow",[255,250,250]],["springgreen",[0,255,127]],["steelblue",[70,130,180]],["tan",[210,180,140]],["thistle",[216,191,216]],["tomato",[255,99,71]],["turquoise",[64,224,208]],["violet",[238,130,238]],["wheat",[245,222,179]],["whitesmoke",[245,245,245]],["yellowgreen",[154,205,50]]].forEach((function(t){cssToRGB.set(t[0],t[1])}));var Color=function(t,e,i,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),this.onResetEvent(t,e,i,o)},prototypeAccessors$4={r:{configurable:!0},g:{configurable:!0},b:{configurable:!0},alpha:{configurable:!0}};Color.prototype.onResetEvent=function(t,e,i,o){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),void 0===this.glArray&&(this.glArray=new Float32Array([0,0,0,1])),this.setColor(t,e,i,o)},prototypeAccessors$4.r.get=function(){return~~(255*this.glArray[0])},prototypeAccessors$4.r.set=function(t){this.glArray[0]=clamp(~~t||0,0,255)/255},prototypeAccessors$4.g.get=function(){return~~(255*this.glArray[1])},prototypeAccessors$4.g.set=function(t){this.glArray[1]=clamp(~~t||0,0,255)/255},prototypeAccessors$4.b.get=function(){return~~(255*this.glArray[2])},prototypeAccessors$4.b.set=function(t){this.glArray[2]=clamp(~~t||0,0,255)/255},prototypeAccessors$4.alpha.get=function(){return this.glArray[3]},prototypeAccessors$4.alpha.set=function(t){this.glArray[3]=void 0===t?1:clamp(+t,0,1)},Color.prototype.setColor=function(t,e,i,o){return void 0===o&&(o=1),this.r=t,this.g=e,this.b=i,this.alpha=o,this},Color.prototype.clone=function(){return pool$1.pull("Color").copy(this)},Color.prototype.copy=function(t){return t instanceof Color?(this.glArray.set(t.glArray),this):this.parseCSS(t)},Color.prototype.add=function(t){return this.glArray[0]=clamp(this.glArray[0]+t.glArray[0],0,1),this.glArray[1]=clamp(this.glArray[1]+t.glArray[1],0,1),this.glArray[2]=clamp(this.glArray[2]+t.glArray[2],0,1),this.glArray[3]=(this.glArray[3]+t.glArray[3])/2,this},Color.prototype.darken=function(t){return t=clamp(t,0,1),this.glArray[0]*=t,this.glArray[1]*=t,this.glArray[2]*=t,this},Color.prototype.lerp=function(t,e){return e=clamp(e,0,1),this.glArray[0]+=(t.glArray[0]-this.glArray[0])*e,this.glArray[1]+=(t.glArray[1]-this.glArray[1])*e,this.glArray[2]+=(t.glArray[2]-this.glArray[2])*e,this},Color.prototype.lighten=function(t){return t=clamp(t,0,1),this.glArray[0]=clamp(this.glArray[0]+(1-this.glArray[0])*t,0,1),this.glArray[1]=clamp(this.glArray[1]+(1-this.glArray[1])*t,0,1),this.glArray[2]=clamp(this.glArray[2]+(1-this.glArray[2])*t,0,1),this},Color.prototype.random=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),t<0&&(t=0),e>255&&(e=255),this.setColor(random$1(t,e),random$1(t,e),random$1(t,e),this.alpha)},Color.prototype.equals=function(t){return this.glArray[0]===t.glArray[0]&&this.glArray[1]===t.glArray[1]&&this.glArray[2]===t.glArray[2]&&this.glArray[3]===t.glArray[3]},Color.prototype.parseCSS=function(t){return cssToRGB.has(t)?this.setColor.apply(this,cssToRGB.get(t)):this.parseRGB(t)},Color.prototype.parseRGB=function(t){var e=rgbaRx.exec(t);return e?this.setColor(+e[1],+e[2],+e[3],+e[5]):this.parseHex(t)},Color.prototype.parseHex=function(t,e){var i;if(void 0===e&&(e=!1),i=hex8Rx.exec(t))return this.setColor(parseInt(i[!1===e?1:2],16),parseInt(i[!1===e?2:3],16),parseInt(i[!1===e?3:4],16),(clamp(parseInt(i[!1===e?4:1],16),0,255)/255).toFixed(1));if(i=hex6Rx.exec(t))return this.setColor(parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16));if(i=hex4Rx.exec(t)){var o=i[!1===e?1:2],r=i[!1===e?2:3],n=i[!1===e?3:4],s=i[!1===e?4:1];return this.setColor(parseInt(o+o,16),parseInt(r+r,16),parseInt(n+n,16),(clamp(parseInt(s+s,16),0,255)/255).toFixed(1))}if(i=hex3Rx.exec(t))return this.setColor(parseInt(i[1]+i[1],16),parseInt(i[2]+i[2],16),parseInt(i[3]+i[3],16));throw new Error("invalid parameter: "+t)},Color.prototype.toUint32=function(t){return void 0===t&&(t=this.alpha),((255*t&255)<<24)+((255&this.r)<<16)+((255&this.g)<<8)+(255&this.b)},Color.prototype.toArray=function(){return this.glArray},Color.prototype.toHex=function(){return"#"+toHex(this.r)+toHex(this.g)+toHex(this.b)},Color.prototype.toHex8=function(){return"#"+toHex(this.r)+toHex(this.g)+toHex(this.b)+toHex(255*this.alpha)},Color.prototype.toRGB=function(){return"rgb("+this.r+","+this.g+","+this.b+")"},Color.prototype.toRGBA=function(){return"rgba("+this.r+","+this.g+","+this.b+","+this.alpha+")"},Object.defineProperties(Color.prototype,prototypeAccessors$4);var Matrix3d=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},prototypeAccessors$3={tx:{configurable:!0},ty:{configurable:!0},tz:{configurable:!0}};Matrix3d.prototype.onResetEvent=function(){void 0===this.val&&(this.val=new Float32Array(16)),arguments.length&&arguments[0]instanceof Matrix3d?this.copy(arguments[0]):16===arguments.length?this.setTransform.apply(this,arguments):this.identity()},prototypeAccessors$3.tx.get=function(){return this.val[12]},prototypeAccessors$3.ty.get=function(){return this.val[13]},prototypeAccessors$3.tz.get=function(){return this.val[14]},Matrix3d.prototype.identity=function(){return this.setTransform(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},Matrix3d.prototype.setTransform=function(t,e,i,o,r,n,s,a,l,h,c,u,p,d,f,y){var g=this.val;return g[0]=t,g[1]=e,g[2]=i,g[3]=o,g[4]=r,g[5]=n,g[6]=s,g[7]=a,g[8]=l,g[9]=h,g[10]=c,g[11]=u,g[12]=p,g[13]=d,g[14]=f,g[15]=y,this},Matrix3d.prototype.copy=function(t){return this.val.set(t.val),this},Matrix3d.prototype.fromMat2d=function(t){var e=t.val;return this.setTransform(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1)},Matrix3d.prototype.multiply=function(t){var e=this.val,i=t.val,o=e[0],r=e[1],n=e[2],s=e[3],a=e[4],l=e[5],h=e[6],c=e[7],u=e[8],p=e[9],d=e[10],f=e[11],y=e[12],g=e[13],v=e[14],m=e[15],_=i[0],x=i[1],b=i[2],T=i[3];return e[0]=_*o+x*a+b*u+T*y,e[1]=_*r+x*l+b*p+T*g,e[2]=_*n+x*h+b*d+T*v,e[3]=_*s+x*c+b*f+T*m,_=i[4],x=i[5],b=i[6],T=i[7],e[4]=_*o+x*a+b*u+T*y,e[5]=_*r+x*l+b*p+T*g,e[6]=_*n+x*h+b*d+T*v,e[7]=_*s+x*c+b*f+T*m,_=i[8],x=i[9],b=i[10],T=i[11],e[8]=_*o+x*a+b*u+T*y,e[9]=_*r+x*l+b*p+T*g,e[10]=_*n+x*h+b*d+T*v,e[11]=_*s+x*c+b*f+T*m,_=i[12],x=i[13],b=i[14],T=i[15],e[12]=_*o+x*a+b*u+T*y,e[13]=_*r+x*l+b*p+T*g,e[14]=_*n+x*h+b*d+T*v,e[15]=_*s+x*c+b*f+T*m,this},Matrix3d.prototype.transpose=function(){var t=this.val,e=t[1],i=t[2],o=t[3],r=t[6],n=t[7],s=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=r,t[11]=t[14],t[12]=o,t[13]=n,t[14]=s,this},Matrix3d.prototype.invert=function(){var t=this.val,e=t[0],i=t[1],o=t[2],r=t[3],n=t[4],s=t[5],a=t[6],l=t[7],h=t[8],c=t[9],u=t[10],p=t[11],d=t[12],f=t[13],y=t[14],g=t[15],v=e*s-i*n,m=e*a-o*n,_=e*l-r*n,x=i*a-o*s,b=i*l-r*s,T=o*l-r*a,w=h*f-c*d,E=h*y-u*d,A=h*g-p*d,S=c*y-u*f,O=c*g-p*f,P=u*g-p*y,C=v*P-m*O+_*S+x*A-b*E+T*w;return C?(C=1/C,t[0]=(s*P-a*O+l*S)*C,t[1]=(o*O-i*P-r*S)*C,t[2]=(f*T-y*b+g*x)*C,t[3]=(u*b-c*T-p*x)*C,t[4]=(a*A-n*P-l*E)*C,t[5]=(e*P-o*A+r*E)*C,t[6]=(y*_-d*T-g*m)*C,t[7]=(h*T-u*_+p*m)*C,t[8]=(n*O-s*A+l*w)*C,t[9]=(i*A-e*O-r*w)*C,t[10]=(d*b-f*_+g*v)*C,t[11]=(c*_-h*b-p*v)*C,t[12]=(s*E-n*S-a*w)*C,t[13]=(e*S-i*E+o*w)*C,t[14]=(f*m-d*x-y*v)*C,t[15]=(h*x-c*m+u*v)*C,this):null},Matrix3d.prototype.apply=function(t){var e=this.val,i=t.x,o=t.y,r=void 0!==t.z?t.z:1,n=e[3]*i+e[7]*o+e[11]*r+e[15]||1;return t.x=(e[0]*i+e[4]*o+e[8]*r+e[12])/n,t.y=(e[1]*i+e[5]*o+e[9]*r+e[13])/n,void 0!==t.z&&(t.z=(e[2]*i+e[6]*o+e[10]*r+e[14])/n),t},Matrix3d.prototype.applyInverse=function(t){var e=pool$1.pull("Matrix3d",this).invert();return e.apply(t),pool$1.push(e),t},Matrix3d.prototype.ortho=function(t,e,i,o,r,n){var s=this.val,a=1/(t-e),l=1/(i-o),h=1/(r-n);return s[0]=-2*a,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*l,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*h,s[11]=0,s[12]=(t+e)*a,s[13]=(o+i)*l,s[14]=(n+r)*h,s[15]=1,this},Matrix3d.prototype.scale=function(t,e,i){var o=this.val,r=t,n=void 0===e?r:e,s=void 0===i?0:i;return o[0]=o[0]*r,o[1]=o[1]*r,o[2]=o[2]*r,o[3]=o[3]*r,o[4]=o[4]*n,o[5]=o[5]*n,o[6]=o[6]*n,o[7]=o[7]*n,o[8]=o[8]*s,o[9]=o[9]*s,o[10]=o[10]*s,o[11]=o[11]*s,this},Matrix3d.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},Matrix3d.prototype.scaleX=function(t){return this.scale(t,1)},Matrix3d.prototype.scaleY=function(t){return this.scale(1,t)},Matrix3d.prototype.rotate=function(t,e){if(0!==t){var i,o,r,n,s,a,l,h,c,u,p,d,f,y,g,v,m,_,x,b,T,w,E,A,S=this.val,O=e.x,P=e.y,C=e.z,R=Math.sqrt(O*O+P*P+C*C);if(R<EPSILON)return null;O*=R=1/R,P*=R,C*=R,i=Math.sin(t),r=1-(o=Math.cos(t)),n=S[0],s=S[1],a=S[2],l=S[3],h=S[4],c=S[5],u=S[6],p=S[7],d=S[8],f=S[9],y=S[10],g=S[11],v=O*O*r+o,m=P*O*r+C*i,_=C*O*r-P*i,x=O*P*r-C*i,b=P*P*r+o,T=C*P*r+O*i,w=O*C*r+P*i,E=P*C*r-O*i,A=C*C*r+o,S[0]=n*v+h*m+d*_,S[1]=s*v+c*m+f*_,S[2]=a*v+u*m+y*_,S[3]=l*v+p*m+g*_,S[4]=n*x+h*b+d*T,S[5]=s*x+c*b+f*T,S[6]=a*x+u*b+y*T,S[7]=l*x+p*b+g*T,S[8]=n*w+h*E+d*A,S[9]=s*w+c*E+f*A,S[10]=a*w+u*E+y*A,S[11]=l*w+p*E+g*A}return this},Matrix3d.prototype.translate=function(){var t,e,i,o=this.val;return arguments.length>1?(t=arguments[0],e=arguments[1],i=void 0===arguments[2]?0:arguments[2]):(t=arguments[0].x,e=arguments[0].y,i=void 0===arguments[0].z?0:arguments[0].z),o[12]=o[0]*t+o[4]*e+o[8]*i+o[12],o[13]=o[1]*t+o[5]*e+o[9]*i+o[13],o[14]=o[2]*t+o[6]*e+o[10]*i+o[14],o[15]=o[3]*t+o[7]*e+o[11]*i+o[15],this},Matrix3d.prototype.isIdentity=function(){var t=this.val;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},Matrix3d.prototype.equals=function(t){var e=t.val,i=this.val;return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]&&i[9]===e[9]&&i[10]===e[10]&&i[11]===e[11]&&i[12]===e[12]&&i[13]===e[13]&&i[14]===e[14]&&i[15]===e[15]},Matrix3d.prototype.clone=function(){return pool$1.pull("Matrix3d",this)},Matrix3d.prototype.toArray=function(){return this.val},Matrix3d.prototype.toString=function(){var t=this.val;return"me.Matrix3d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},Object.defineProperties(Matrix3d.prototype,prototypeAccessors$3);var Matrix2d=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},prototypeAccessors$2={tx:{configurable:!0},ty:{configurable:!0}};Matrix2d.prototype.onResetEvent=function(){return void 0===this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof Matrix2d?this.copy(arguments[0]):arguments.length&&arguments[0]instanceof Matrix3d?this.fromMat3d(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.identity(),this},prototypeAccessors$2.tx.get=function(){return this.val[6]},prototypeAccessors$2.ty.get=function(){return this.val[7]},Matrix2d.prototype.identity=function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},Matrix2d.prototype.setTransform=function(){var t=this.val;return 9===arguments.length?(t[0]=arguments[0],t[1]=arguments[1],t[2]=arguments[2],t[3]=arguments[3],t[4]=arguments[4],t[5]=arguments[5],t[6]=arguments[6],t[7]=arguments[7],t[8]=arguments[8]):6===arguments.length&&(t[0]=arguments[0],t[1]=arguments[2],t[2]=arguments[4],t[3]=arguments[1],t[4]=arguments[3],t[5]=arguments[5],t[6]=0,t[7]=0,t[8]=1),this},Matrix2d.prototype.copy=function(t){return this.val.set(t.val),this},Matrix2d.prototype.fromMat3d=function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},Matrix2d.prototype.multiply=function(t){var e=t.val,i=this.val,o=i[0],r=i[1],n=i[3],s=i[4],a=e[0],l=e[1],h=e[3],c=e[4],u=e[6],p=e[7];return i[0]=o*a+n*l,i[1]=r*a+s*l,i[3]=o*h+n*c,i[4]=r*h+s*c,i[6]+=o*u+n*p,i[7]+=r*u+s*p,this},Matrix2d.prototype.transpose=function(){var t=this.val,e=t[1],i=t[2],o=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=o,this},Matrix2d.prototype.invert=function(){var t=this.val,e=t[0],i=t[1],o=t[2],r=t[3],n=t[4],s=t[5],a=t[6],l=t[7],h=t[8],c=h*n-s*l,u=s*a-h*r,p=l*r-n*a,d=e*c+i*u+o*p;return t[0]=c/d,t[1]=(o*l-h*i)/d,t[2]=(s*i-o*n)/d,t[3]=u/d,t[4]=(h*e-o*a)/d,t[5]=(o*r-s*e)/d,t[6]=p/d,t[7]=(i*a-l*e)/d,t[8]=(n*e-i*r)/d,this},Matrix2d.prototype.apply=function(t){var e=this.val,i=t.x,o=t.y;return t.x=i*e[0]+o*e[3]+e[6],t.y=i*e[1]+o*e[4]+e[7],t},Matrix2d.prototype.applyInverse=function(t){var e=this.val,i=t.x,o=t.y,r=1/(e[0]*e[4]+e[3]*-e[1]);return t.x=e[4]*r*i+-e[3]*r*o+(e[7]*e[3]-e[6]*e[4])*r,t.y=e[0]*r*o+-e[1]*r*i+(-e[7]*e[0]+e[6]*e[1])*r,t},Matrix2d.prototype.scale=function(t,e){var i=this.val,o=t,r=void 0===e?o:e;return i[0]*=o,i[1]*=o,i[3]*=r,i[4]*=r,this},Matrix2d.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Matrix2d.prototype.scaleX=function(t){return this.scale(t,1)},Matrix2d.prototype.scaleY=function(t){return this.scale(1,t)},Matrix2d.prototype.rotate=function(t){if(0!==t){var e=this.val,i=e[0],o=e[1],r=e[2],n=e[3],s=e[4],a=e[5],l=Math.sin(t),h=Math.cos(t);e[0]=h*i+l*n,e[1]=h*o+l*s,e[2]=h*r+l*a,e[3]=h*n-l*i,e[4]=h*s-l*o,e[5]=h*a-l*r}return this},Matrix2d.prototype.translate=function(){var t,e,i=this.val;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),i[6]+=i[0]*t+i[3]*e,i[7]+=i[1]*t+i[4]*e,this},Matrix2d.prototype.isIdentity=function(){var t=this.val;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},Matrix2d.prototype.equals=function(t){var e=t.val,i=this.val;return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]},Matrix2d.prototype.clone=function(){return pool$1.pull("Matrix2d",this)},Matrix2d.prototype.toArray=function(){return this.val},Matrix2d.prototype.toString=function(){var t=this.val;return"me.Matrix2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},Object.defineProperties(Matrix2d.prototype,prototypeAccessors$2);var eventemitter3={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function o(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,o,n,s){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new r(o,n||t,s),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,o,r=[];if(0===this._eventsCount)return r;for(o in t=this._events)e.call(t,o)&&r.push(i?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=i?i+t:t,o=this._events[e];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,n=o.length,s=new Array(n);r<n;r++)s[r]=o[r].fn;return s},a.prototype.listenerCount=function(t){var e=i?i+t:t,o=this._events[e];return o?o.fn?1:o.length:0},a.prototype.emit=function(t,e,o,r,n,s){var a=arguments,l=i?i+t:t;if(!this._events[l])return!1;var h,c,u=this._events[l],p=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),p){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,o),!0;case 4:return u.fn.call(u.context,e,o,r),!0;case 5:return u.fn.call(u.context,e,o,r,n),!0;case 6:return u.fn.call(u.context,e,o,r,n,s),!0}for(c=1,h=new Array(p-1);c<p;c++)h[c-1]=a[c];u.fn.apply(u.context,h)}else{var d,f=u.length;for(c=0;c<f;c++)switch(u[c].once&&this.removeListener(t,u[c].fn,void 0,!0),p){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,e);break;case 3:u[c].fn.call(u[c].context,e,o);break;case 4:u[c].fn.call(u[c].context,e,o,r);break;default:if(!h)for(d=1,h=new Array(p-1);d<p;d++)h[d-1]=a[d];u[c].fn.apply(u[c].context,h)}}return!0},a.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,o,r){var n=i?i+t:t;if(!this._events[n])return this;if(!e)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn!==e||r&&!a.once||o&&a.context!==o||s(this,n);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==e||r&&!a[l].once||o&&a[l].context!==o)&&h.push(a[l]);h.length?this._events[n]=1===h.length?h[0]:h:s(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&s(this,e)):(this._events=new o,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(eventemitter3);var EventEmitter=eventemitter3.exports,eventEmitter=new EventEmitter,BOOT="me.boot",STATE_PAUSE="me.state.onPause",STATE_RESUME="me.state.onResume",STATE_STOP="me.state.onStop",STATE_RESTART="me.state.onRestart",VIDEO_INIT="me.video.onInit",GAME_INIT="me.game.onInit",GAME_RESET="me.game.onReset",GAME_BEFORE_UPDATE="me.game.beforeUpdate",GAME_AFTER_UPDATE="me.game.afterUpdate",GAME_UPDATE="me.game.onUpdate",GAME_BEFORE_DRAW="me.game.beforeDraw",GAME_AFTER_DRAW="me.game.afterDraw",LEVEL_LOADED="me.game.onLevelLoaded",LOADER_COMPLETE="me.loader.onload",LOADER_PROGRESS="me.loader.onProgress",KEYDOWN="me.input.keydown",KEYUP="me.input.keyup",GAMEPAD_CONNECTED="gamepad.connected",GAMEPAD_DISCONNECTED="gamepad.disconnected",GAMEPAD_UPDATE="gamepad.update",POINTERMOVE="me.event.pointermove",POINTERLOCKCHANGE="me.event.pointerlockChange",DRAGSTART="me.game.dragstart",DRAGEND="me.game.dragend",WINDOW_ONRESIZE="globalThis.onresize",CANVAS_ONRESIZE="canvas.onresize",VIEWPORT_ONRESIZE="viewport.onresize",WINDOW_ONORIENTATION_CHANGE="globalThis.orientationchange",WINDOW_ONSCROLL="globalThis.onscroll",VIEWPORT_ONCHANGE="viewport.onchange",ONCONTEXT_LOST="renderer.contextlost",ONCONTEXT_RESTORED="renderer.contextrestored";function emit(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];return eventEmitter.emit.apply(eventEmitter,[t].concat(e))}function on(t,e,i){return eventEmitter.on(t,e,i)}function once(t,e,i){return eventEmitter.once(t,e,i)}function off(t,e){return eventEmitter.off(t,e)}var event$1=Object.freeze({__proto__:null,BOOT:BOOT,STATE_PAUSE:STATE_PAUSE,STATE_RESUME:STATE_RESUME,STATE_STOP:STATE_STOP,STATE_RESTART:STATE_RESTART,VIDEO_INIT:VIDEO_INIT,GAME_INIT:GAME_INIT,GAME_RESET:GAME_RESET,GAME_BEFORE_UPDATE:GAME_BEFORE_UPDATE,GAME_AFTER_UPDATE:GAME_AFTER_UPDATE,GAME_UPDATE:GAME_UPDATE,GAME_BEFORE_DRAW:GAME_BEFORE_DRAW,GAME_AFTER_DRAW:GAME_AFTER_DRAW,LEVEL_LOADED:LEVEL_LOADED,LOADER_COMPLETE:LOADER_COMPLETE,LOADER_PROGRESS:LOADER_PROGRESS,KEYDOWN:KEYDOWN,KEYUP:KEYUP,GAMEPAD_CONNECTED:GAMEPAD_CONNECTED,GAMEPAD_DISCONNECTED:GAMEPAD_DISCONNECTED,GAMEPAD_UPDATE:GAMEPAD_UPDATE,POINTERMOVE:POINTERMOVE,POINTERLOCKCHANGE:POINTERLOCKCHANGE,DRAGSTART:DRAGSTART,DRAGEND:DRAGEND,WINDOW_ONRESIZE:WINDOW_ONRESIZE,CANVAS_ONRESIZE:CANVAS_ONRESIZE,VIEWPORT_ONRESIZE:VIEWPORT_ONRESIZE,WINDOW_ONORIENTATION_CHANGE:WINDOW_ONORIENTATION_CHANGE,WINDOW_ONSCROLL:WINDOW_ONSCROLL,VIEWPORT_ONCHANGE:VIEWPORT_ONCHANGE,ONCONTEXT_LOST:ONCONTEXT_LOST,ONCONTEXT_RESTORED:ONCONTEXT_RESTORED,emit:emit,on:on,once:once,off:off}),howler={};
8
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).me={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=function(t){return t&&t.Math==Math&&t},o=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||function(){return this}()||Function("return this")(),n={},r=function(t){try{return!!t()}catch(t){return!0}},s=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=!r((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),h=a,l=Function.prototype.call,u=h?l.bind(l):function(){return l.apply(l,arguments)},c={},p={}.propertyIsEnumerable,d=Object.getOwnPropertyDescriptor,f=d&&!p.call({1:2},1);c.f=f?function(t){var e=d(this,t);return!!e&&e.enumerable}:p;var y,g,v=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},m=a,_=Function.prototype,x=_.bind,b=_.call,w=m&&x.bind(b,b),T=m?function(t){return t&&w(t)}:function(t){return t&&function(){return b.apply(t,arguments)}},A=T,S=A({}.toString),E=A("".slice),C=r,M=function(t){return E(S(t),8,-1)},P=Object,O=T("".split),k=C((function(){return!P("z").propertyIsEnumerable(0)}))?function(t){return"String"==M(t)?O(t,""):P(t)}:P,I=TypeError,R=function(t){if(null==t)throw I("Can't call method on "+t);return t},B=k,D=R,L=function(t){return B(D(t))},z=function(t){return"function"==typeof t},F=z,V=function(t){return"object"==typeof t?null!==t:F(t)},j=o,N=z,U=function(t){return N(t)?t:void 0},G=function(t,e){return arguments.length<2?U(j[t]):j[t]&&j[t][e]},X=T({}.isPrototypeOf),H=o,W=G("navigator","userAgent")||"",Y=H.process,q=H.Deno,Z=Y&&Y.versions||q&&q.version,K=Z&&Z.v8;K&&(g=(y=K.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!g&&W&&(!(y=W.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=W.match(/Chrome\/(\d+)/))&&(g=+y[1]);var J=g,$=r,Q=!!Object.getOwnPropertySymbols&&!$((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&J&&J<41})),tt=Q&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,et=G,it=z,ot=X,nt=Object,rt=tt?function(t){return"symbol"==typeof t}:function(t){var e=et("Symbol");return it(e)&&ot(e.prototype,nt(t))},st=String,at=z,ht=function(t){try{return st(t)}catch(t){return"Object"}},lt=TypeError,ut=function(t){if(at(t))return t;throw lt(ht(t)+" is not a function")},ct=u,pt=z,dt=V,ft=TypeError,yt={exports:{}},gt=o,vt=Object.defineProperty,mt=function(t,e){try{vt(gt,t,{value:e,configurable:!0,writable:!0})}catch(i){gt[t]=e}return e},_t=mt,xt="__core-js_shared__",bt=o[xt]||_t(xt,{}),wt=bt;(yt.exports=function(t,e){return wt[t]||(wt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.23.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.23.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Tt=R,At=Object,St=function(t){return At(Tt(t))},Et=T({}.hasOwnProperty),Ct=Object.hasOwn||function(t,e){return Et(St(t),e)},Mt=T,Pt=0,Ot=Math.random(),kt=Mt(1..toString),It=function(t){return"Symbol("+(void 0===t?"":t)+")_"+kt(++Pt+Ot,36)},Rt=o,Bt=yt.exports,Dt=Ct,Lt=It,zt=Q,Ft=tt,Vt=Bt("wks"),jt=Rt.Symbol,Nt=jt&&jt.for,Ut=Ft?jt:jt&&jt.withoutSetter||Lt,Gt=u,Xt=V,Ht=rt,Wt=function(t,e){var i=t[e];return null==i?void 0:ut(i)},Yt=function(t,e){var i,o;if("string"===e&&pt(i=t.toString)&&!dt(o=ct(i,t)))return o;if(pt(i=t.valueOf)&&!dt(o=ct(i,t)))return o;if("string"!==e&&pt(i=t.toString)&&!dt(o=ct(i,t)))return o;throw ft("Can't convert object to primitive value")},qt=TypeError,Zt=function(t){if(!Dt(Vt,t)||!zt&&"string"!=typeof Vt[t]){var e="Symbol."+t;zt&&Dt(jt,t)?Vt[t]=jt[t]:Vt[t]=Ft&&Nt?Nt(e):Ut(e)}return Vt[t]}("toPrimitive"),Kt=function(t,e){if(!Xt(t)||Ht(t))return t;var i,o=Wt(t,Zt);if(o){if(void 0===e&&(e="default"),i=Gt(o,t,e),!Xt(i)||Ht(i))return i;throw qt("Can't convert object to primitive value")}return void 0===e&&(e="number"),Yt(t,e)},Jt=rt,$t=function(t){var e=Kt(t,"string");return Jt(e)?e:e+""},Qt=V,te=o.document,ee=Qt(te)&&Qt(te.createElement),ie=function(t){return ee?te.createElement(t):{}},oe=!s&&!r((function(){return 7!=Object.defineProperty(ie("div"),"a",{get:function(){return 7}}).a})),ne=s,re=u,se=c,ae=v,he=L,le=$t,ue=Ct,ce=oe,pe=Object.getOwnPropertyDescriptor;n.f=ne?pe:function(t,e){if(t=he(t),e=le(e),ce)try{return pe(t,e)}catch(t){}if(ue(t,e))return ae(!re(se.f,t,e),t[e])};var de={},fe=s&&r((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),ye=V,ge=String,ve=TypeError,me=function(t){if(ye(t))return t;throw ve(ge(t)+" is not an object")},_e=s,xe=oe,be=fe,we=me,Te=$t,Ae=TypeError,Se=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Ce="enumerable",Me="configurable",Pe="writable";de.f=_e?be?function(t,e,i){if(we(t),e=Te(e),we(i),"function"==typeof t&&"prototype"===e&&"value"in i&&Pe in i&&!i.writable){var o=Ee(t,e);o&&o.writable&&(t[e]=i.value,i={configurable:Me in i?i.configurable:o.configurable,enumerable:Ce in i?i.enumerable:o.enumerable,writable:!1})}return Se(t,e,i)}:Se:function(t,e,i){if(we(t),e=Te(e),we(i),xe)try{return Se(t,e,i)}catch(t){}if("get"in i||"set"in i)throw Ae("Accessors not supported");return"value"in i&&(t[e]=i.value),t};var Oe=de,ke=v,Ie=s?function(t,e,i){return Oe.f(t,e,ke(1,i))}:function(t,e,i){return t[e]=i,t},Re={exports:{}},Be=s,De=Ct,Le=Function.prototype,ze=Be&&Object.getOwnPropertyDescriptor,Fe=De(Le,"name"),Ve={EXISTS:Fe,PROPER:Fe&&"something"===function(){}.name,CONFIGURABLE:Fe&&(!Be||Be&&ze(Le,"name").configurable)},je=z,Ne=bt,Ue=T(Function.toString);je(Ne.inspectSource)||(Ne.inspectSource=function(t){return Ue(t)});var Ge,Xe,He,We=Ne.inspectSource,Ye=z,qe=We,Ze=o.WeakMap,Ke=Ye(Ze)&&/native code/.test(qe(Ze)),Je=yt.exports,$e=It,Qe=Je("keys"),ti={},ei=Ke,ii=o,oi=T,ni=V,ri=Ie,si=Ct,ai=bt,hi=function(t){return Qe[t]||(Qe[t]=$e(t))},li=ti,ui="Object already initialized",ci=ii.TypeError,pi=ii.WeakMap;if(ei||ai.state){var di=ai.state||(ai.state=new pi),fi=oi(di.get),yi=oi(di.has),gi=oi(di.set);Ge=function(t,e){if(yi(di,t))throw new ci(ui);return e.facade=t,gi(di,t,e),e},Xe=function(t){return fi(di,t)||{}},He=function(t){return yi(di,t)}}else{var vi=hi("state");li[vi]=!0,Ge=function(t,e){if(si(t,vi))throw new ci(ui);return e.facade=t,ri(t,vi,e),e},Xe=function(t){return si(t,vi)?t[vi]:{}},He=function(t){return si(t,vi)}}var mi={set:Ge,get:Xe,has:He,enforce:function(t){return He(t)?Xe(t):Ge(t,{})},getterFor:function(t){return function(e){var i;if(!ni(e)||(i=Xe(e)).type!==t)throw ci("Incompatible receiver, "+t+" required");return i}}},_i=r,xi=z,bi=Ct,wi=s,Ti=Ve.CONFIGURABLE,Ai=We,Si=mi.enforce,Ei=mi.get,Ci=Object.defineProperty,Mi=wi&&!_i((function(){return 8!==Ci((function(){}),"length",{value:8}).length})),Pi=String(String).split("String"),Oi=Re.exports=function(t,e,i){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!bi(t,"name")||Ti&&t.name!==e)&&Ci(t,"name",{value:e,configurable:!0}),Mi&&i&&bi(i,"arity")&&t.length!==i.arity&&Ci(t,"length",{value:i.arity});try{i&&bi(i,"constructor")&&i.constructor?wi&&Ci(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=Si(t);return bi(o,"source")||(o.source=Pi.join("string"==typeof e?e:"")),t};Function.prototype.toString=Oi((function(){return xi(this)&&Ei(this).source||Ai(this)}),"toString");var ki=z,Ii=de,Ri=Re.exports,Bi=mt,Di={},Li=Math.ceil,zi=Math.floor,Fi=Math.trunc||function(t){var e=+t;return(e>0?zi:Li)(e)},Vi=Fi,ji=function(t){var e=+t;return e!=e||0===e?0:Vi(e)},Ni=ji,Ui=Math.max,Gi=Math.min,Xi=ji,Hi=Math.min,Wi=function(t){return t>0?Hi(Xi(t),9007199254740991):0},Yi=L,qi=function(t,e){var i=Ni(t);return i<0?Ui(i+e,0):Gi(i,e)},Zi=function(t){return Wi(t.length)},Ki=function(t){return function(e,i,o){var n,r=Yi(e),s=Zi(r),a=qi(o,s);if(t&&i!=i){for(;s>a;)if((n=r[a++])!=n)return!0}else for(;s>a;a++)if((t||a in r)&&r[a]===i)return t||a||0;return!t&&-1}},Ji={includes:Ki(!0),indexOf:Ki(!1)},$i=Ct,Qi=L,to=Ji.indexOf,eo=ti,io=T([].push),oo=function(t,e){var i,o=Qi(t),n=0,r=[];for(i in o)!$i(eo,i)&&$i(o,i)&&io(r,i);for(;e.length>n;)$i(o,i=e[n++])&&(~to(r,i)||io(r,i));return r},no=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Di.f=Object.getOwnPropertyNames||function(t){return oo(t,no)};var ro={};ro.f=Object.getOwnPropertySymbols;var so=G,ao=Di,ho=ro,lo=me,uo=T([].concat),co=so("Reflect","ownKeys")||function(t){var e=ao.f(lo(t)),i=ho.f;return i?uo(e,i(t)):e},po=Ct,fo=co,yo=n,go=de,vo=r,mo=z,_o=/#|\.prototype\./,xo=function(t,e){var i=wo[bo(t)];return i==Ao||i!=To&&(mo(e)?vo(e):!!e)},bo=xo.normalize=function(t){return String(t).replace(_o,".").toLowerCase()},wo=xo.data={},To=xo.NATIVE="N",Ao=xo.POLYFILL="P",So=xo,Eo=o,Co=n.f,Mo=Ie,Po=function(t,e,i,o){o||(o={});var n=o.enumerable,r=void 0!==o.name?o.name:e;return ki(i)&&Ri(i,r,o),o.global?n?t[e]=i:Bi(e,i):(o.unsafe?t[e]&&(n=!0):delete t[e],n?t[e]=i:Ii.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})),t},Oo=mt,ko=function(t,e,i){for(var o=fo(e),n=go.f,r=yo.f,s=0;s<o.length;s++){var a=o[s];po(t,a)||i&&po(i,a)||n(t,a,r(e,a))}},Io=So;if(function(t,e){var i,o,n,r,s,a=t.target,h=t.global,l=t.stat;if(i=h?Eo:l?Eo[a]||Oo(a,{}):(Eo[a]||{}).prototype)for(o in e){if(r=e[o],n=t.dontCallGetSet?(s=Co(i,o))&&s.value:i[o],!Io(h?o:a+(l?".":"#")+o,t.forced)&&void 0!==n){if(typeof r==typeof n)continue;ko(r,n)}(t.sham||n&&n.sham)&&Mo(r,"sham",!0),Po(i,o,r,t)}}({global:!0},{globalThis:o}),"undefined"!=typeof globalThis&&void 0===globalThis.console&&(globalThis.console={},globalThis.console.log=function(){},globalThis.console.assert=function(){},globalThis.console.warn=function(){},globalThis.console.error=function(){alert(Array.prototype.slice.call(arguments).join(", "))}),"performance"in globalThis==!1&&(globalThis.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in globalThis.performance==!1){var Ro=Date.now();performance.timing&&performance.timing.navigationStart&&(Ro=performance.timing.navigationStart),globalThis.performance.now=function(){return Date.now()-Ro}}function Bo(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Do(t){return t.replace(/\s+$/,"")}function Lo(t){return"string"==typeof t&&(t=t.trim()),!isNaN(t)&&/[+-]?([0-9]*[.])?[0-9]+/.test(t)}function zo(t){var e=t.trim();return"true"===e||"false"===e}function Fo(t){for(var e="",i=0;i<t.length;)e+=t.charCodeAt(i++).toString(16);return e}var Vo=Object.freeze({__proto__:null,capitalize:Bo,trimLeft:function(t){return t.replace(/^\s+/,"")},trimRight:Do,isNumeric:Lo,isBoolean:zo,toHex:Fo}),jo=["ms","MS","moz","webkit","o"];function No(t,e){if(t in(e=e||globalThis))return e[t];var i,o=Bo(t);return jo.some((function(t){var n=t+o;return i=n in e?e[n]:void 0})),i}function Uo(t,e,i){if(!(t in(i=i||globalThis))){var o=Bo(t);return jo.some((function(t){var n=t+o;if(n in i)return i[n]=e,!0})),!1}i[t]=e}var Go=Object.freeze({__proto__:null,prefixed:No,setPrefixed:Uo}),Xo=Math.PI/180,Ho=180/Math.PI,Wo=2*Math.PI,Yo=.5*Math.PI,qo=1e-6;function Zo(t){return 0==(t&t-1)}function Ko(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function Jo(t){return t*Xo}function $o(t,e,i){return t<e?e:t>i?i:+t}function Qo(t,e){return~~(Math.random()*(e-t))+t}function tn(t,e){return Math.random()*(e-t)+t}function en(t,e){return~~(Math.pow(Math.random(),2)*(e-t))+t}function on(t,e,i){return void 0===i&&(i=2),Math.abs(t-e)<Math.pow(10,-i)/2}var nn=Object.freeze({__proto__:null,DEG_TO_RAD:Xo,RAD_TO_DEG:Ho,TAU:Wo,ETA:Yo,EPSILON:qo,isPowerOfTwo:Zo,nextPowerOfTwo:Ko,degToRad:Jo,radToDeg:function(t){return t*Ho},clamp:$o,random:Qo,randomFloat:tn,weightedRandom:en,round:function(t,e){void 0===e&&(e=0);var i=Math.pow(10,e);return~~(.5+t*i)/i},toBeCloseTo:on});function rn(t,e){var i=Array.prototype.indexOf.call(t,e);return-1!==i&&Array.prototype.splice.call(t,i,1),t}var sn=Object.freeze({__proto__:null,remove:rn,random:function(t){return t[Qo(0,t.length)]},weightedRandom:function(t){return t[en(0,t.length)]}}),an=/^.*(\\|\/|\:)/,hn=/\.[^\.]*$/;function ln(t){return t.replace(an,"").replace(hn,"")}function un(t){return t.substring(t.lastIndexOf(".")+1,t.length)}var cn=Object.freeze({__proto__:null,getBasename:ln,getExtension:un});function pn(t,e){for(var i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];return setTimeout.apply(void 0,[t.bind(e),.01].concat(i))}function dn(t,e,i){var o,n=globalThis.performance.now();return"boolean"!=typeof i&&(i=!1),function(){var r=globalThis.performance.now(),s=r-n,a=arguments;if(!(s<e))return n=r,t.apply(null,a);!1===i&&(clearTimeout(o),o=setTimeout((function(){return n=r,t.apply(null,a)}),s))}}var fn=Object.freeze({__proto__:null,defer:pn,throttle:dn}),yn=function(){this.objectClass={},this.instance_counter=0};yn.prototype.register=function(t,e,i){if(void 0===i&&(i=!1),void 0===e)throw new Error("Cannot register object '"+t+"', invalid class");this.objectClass[t]={class:e,pool:i?[]:void 0}},yn.prototype.pull=function(t){for(var e=arguments,i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=e[o];var n=this.objectClass[t];if(n){var r,s=n.class,a=n.pool;return a&&(r=a.pop())?(i.shift(),"function"==typeof r.onResetEvent&&r.onResetEvent.apply(r,i),this.instance_counter--):(i[0]=s,r=new(s.bind.apply(s,i)),a&&(r.className=t)),r}throw new Error("Cannot instantiate object of type '"+t+"'")},yn.prototype.purge=function(){for(var t in this.objectClass)this.objectClass[t]&&(this.objectClass[t].pool=[]);this.instance_counter=0},yn.prototype.push=function(t,e){if(void 0===e&&(e=!0),!this.poolable(t)){if(!0===e)throw new Error("me.pool: object "+t+" cannot be recycled");return!1}return this.objectClass[t.className].pool.push(t),this.instance_counter++,!0},yn.prototype.exists=function(t){return t in this.objectClass},yn.prototype.poolable=function(t){var e=t.className;return void 0!==e&&"function"==typeof t.onResetEvent&&e in this.objectClass&&void 0!==this.objectClass[e].pool},yn.prototype.getInstanceCount=function(){return this.instance_counter};var gn=new yn,vn=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.onResetEvent(t,e)};vn.prototype.onResetEvent=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},vn.prototype._set=function(t,e){return this.x=t,this.y=e,this},vn.prototype.set=function(t,e){if(t!==+t||e!==+e)throw new Error("invalid x,y parameters (not a number)");return this._set(t,e)},vn.prototype.setZero=function(){return this.set(0,0)},vn.prototype.setV=function(t){return this._set(t.x,t.y)},vn.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y)},vn.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y)},vn.prototype.scale=function(t,e){return this._set(this.x*t,this.y*(void 0!==e?e:t))},vn.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y))},vn.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2)},vn.prototype.scaleV=function(t){return this._set(this.x*t.x,this.y*t.y)},vn.prototype.div=function(t){return this._set(this.x/t,this.y/t)},vn.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y)},vn.prototype.clamp=function(t,e){return new vn($o(this.x,t,e),$o(this.y,t,e))},vn.prototype.clampSelf=function(t,e){return this._set($o(this.x,t,e),$o(this.y,t,e))},vn.prototype.minV=function(t){return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y)},vn.prototype.maxV=function(t){return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y)},vn.prototype.floor=function(){return new vn(Math.floor(this.x),Math.floor(this.y))},vn.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y))},vn.prototype.ceil=function(){return new vn(Math.ceil(this.x),Math.ceil(this.y))},vn.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},vn.prototype.negate=function(){return new vn(-this.x,-this.y)},vn.prototype.negateSelf=function(){return this._set(-this.x,-this.y)},vn.prototype.copy=function(t){return this._set(t.x,t.y)},vn.prototype.equals=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.x===t&&this.y===e},vn.prototype.normalize=function(){return this.div(this.length()||1)},vn.prototype.perp=function(){return this._set(this.y,-this.x)},vn.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var n=this.x-i,r=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(n*s-r*a+i,n*a+r*s+o)},vn.prototype.dot=function(t){return this.x*t.x+this.y*t.y},vn.prototype.cross=function(t){return this.x*t.y-this.y*t.x},vn.prototype.length2=function(){return this.dot(this)},vn.prototype.length=function(){return Math.sqrt(this.length2())},vn.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},vn.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},vn.prototype.angle=function(t){return Math.acos($o(this.dot(t)/(this.length()*t.length()),-1,1))},vn.prototype.project=function(t){return this.scale(this.dot(t)/t.length2())},vn.prototype.projectN=function(t){return this.scale(this.dot(t))},vn.prototype.clone=function(){return gn.pull("Vector2d",this.x,this.y)},vn.prototype.toString=function(){return"x:"+this.x+",y:"+this.y};var mn=function(t){return"0123456789ABCDEF".charAt(t-t%16>>4)+"0123456789ABCDEF".charAt(t%16)},_n=/^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/,xn=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,bn=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,wn=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,Tn=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,An=new Map;[["black",[0,0,0]],["silver",[192,192,129]],["gray",[128,128,128]],["white",[255,255,255]],["maroon",[128,0,0]],["red",[255,0,0]],["purple",[128,0,128]],["fuchsia",[255,0,255]],["green",[0,128,0]],["lime",[0,255,0]],["olive",[128,128,0]],["yellow",[255,255,0]],["navy",[0,0,128]],["blue",[0,0,255]],["teal",[0,128,128]],["aqua",[0,255,255]],["orange",[255,165,0]],["aliceblue",[240,248,245]],["antiquewhite",[250,235,215]],["aquamarine",[127,255,212]],["azure",[240,255,255]],["beige",[245,245,220]],["bisque",[255,228,196]],["blanchedalmond",[255,235,205]],["blueviolet",[138,43,226]],["brown",[165,42,42]],["burlywood",[222,184,35]],["cadetblue",[95,158,160]],["chartreuse",[127,255,0]],["chocolate",[210,105,30]],["coral",[255,127,80]],["cornflowerblue",[100,149,237]],["cornsilk",[255,248,220]],["crimson",[220,20,60]],["darkblue",[0,0,139]],["darkcyan",[0,139,139]],["darkgoldenrod",[184,134,11]],["darkgray[*]",[169,169,169]],["darkgreen",[0,100,0]],["darkgrey[*]",[169,169,169]],["darkkhaki",[189,183,107]],["darkmagenta",[139,0,139]],["darkolivegreen",[85,107,47]],["darkorange",[255,140,0]],["darkorchid",[153,50,204]],["darkred",[139,0,0]],["darksalmon",[233,150,122]],["darkseagreen",[143,188,143]],["darkslateblue",[72,61,139]],["darkslategray",[47,79,79]],["darkslategrey",[47,79,79]],["darkturquoise",[0,206,209]],["darkviolet",[148,0,211]],["deeppink",[255,20,147]],["deepskyblue",[0,191,255]],["dimgray",[105,105,105]],["dimgrey",[105,105,105]],["dodgerblue",[30,144,255]],["firebrick",[178,34,34]],["floralwhite",[255,250,240]],["forestgreen",[34,139,34]],["gainsboro",[220,220,220]],["ghostwhite",[248,248,255]],["gold",[255,215,0]],["goldenrod",[218,165,32]],["greenyellow",[173,255,47]],["grey",[128,128,128]],["honeydew",[240,255,240]],["hotpink",[255,105,180]],["indianred",[205,92,92]],["indigo",[75,0,130]],["ivory",[255,255,240]],["khaki",[240,230,140]],["lavender",[230,230,250]],["lavenderblush",[255,240,245]],["lawngreen",[124,252,0]],["lemonchiffon",[255,250,205]],["lightblue",[173,216,230]],["lightcoral",[240,128,128]],["lightcyan",[224,255,255]],["lightgoldenrodyellow",[250,250,210]],["lightgray",[211,211,211]],["lightgreen",[144,238,144]],["lightgrey",[211,211,211]],["lightpink",[255,182,193]],["lightsalmon",[255,160,122]],["lightseagreen",[32,178,170]],["lightskyblue",[135,206,250]],["lightslategray",[119,136,153]],["lightslategrey",[119,136,153]],["lightsteelblue",[176,196,222]],["lightyellow",[255,255,224]],["limegreen",[50,205,50]],["linen",[250,240,230]],["mediumaquamarine",[102,205,170]],["mediumblue",[0,0,205]],["mediumorchid",[186,85,211]],["mediumpurple",[147,112,219]],["mediumseagreen",[60,179,113]],["mediumslateblue",[123,104,238]],["mediumspringgreen",[0,250,154]],["mediumturquoise",[72,209,204]],["mediumvioletred",[199,21,133]],["midnightblue",[25,25,112]],["mintcream",[245,255,250]],["mistyrose",[255,228,225]],["moccasin",[255,228,181]],["navajowhite",[255,222,173]],["oldlace",[253,245,230]],["olivedrab",[107,142,35]],["orangered",[255,69,0]],["orchid",[218,112,214]],["palegoldenrod",[238,232,170]],["palegreen",[152,251,152]],["paleturquoise",[175,238,238]],["palevioletred",[219,112,147]],["papayawhip",[255,239,213]],["peachpuff",[255,218,185]],["peru",[205,133,63]],["pink",[255,192,203]],["plum",[221,160,221]],["powderblue",[176,224,230]],["rosybrown",[188,143,143]],["royalblue",[65,105,225]],["saddlebrown",[139,69,19]],["salmon",[250,128,114]],["sandybrown",[244,164,96]],["seagreen",[46,139,87]],["seashell",[255,245,238]],["sienna",[160,82,45]],["skyblue",[135,206,235]],["slateblue",[106,90,205]],["slategray",[112,128,144]],["slategrey",[112,128,144]],["snow",[255,250,250]],["springgreen",[0,255,127]],["steelblue",[70,130,180]],["tan",[210,180,140]],["thistle",[216,191,216]],["tomato",[255,99,71]],["turquoise",[64,224,208]],["violet",[238,130,238]],["wheat",[245,222,179]],["whitesmoke",[245,245,245]],["yellowgreen",[154,205,50]]].forEach((function(t){An.set(t[0],t[1])}));var Sn=function(t,e,i,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),this.onResetEvent(t,e,i,o)},En={r:{configurable:!0},g:{configurable:!0},b:{configurable:!0},alpha:{configurable:!0}};Sn.prototype.onResetEvent=function(t,e,i,o){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),void 0===this.glArray&&(this.glArray=new Float32Array([0,0,0,1])),this.setColor(t,e,i,o)},En.r.get=function(){return~~(255*this.glArray[0])},En.r.set=function(t){this.glArray[0]=$o(~~t||0,0,255)/255},En.g.get=function(){return~~(255*this.glArray[1])},En.g.set=function(t){this.glArray[1]=$o(~~t||0,0,255)/255},En.b.get=function(){return~~(255*this.glArray[2])},En.b.set=function(t){this.glArray[2]=$o(~~t||0,0,255)/255},En.alpha.get=function(){return this.glArray[3]},En.alpha.set=function(t){this.glArray[3]=void 0===t?1:$o(+t,0,1)},Sn.prototype.setColor=function(t,e,i,o){return void 0===o&&(o=1),this.r=t,this.g=e,this.b=i,this.alpha=o,this},Sn.prototype.clone=function(){return gn.pull("Color").copy(this)},Sn.prototype.copy=function(t){return t instanceof Sn?(this.glArray.set(t.glArray),this):this.parseCSS(t)},Sn.prototype.add=function(t){return this.glArray[0]=$o(this.glArray[0]+t.glArray[0],0,1),this.glArray[1]=$o(this.glArray[1]+t.glArray[1],0,1),this.glArray[2]=$o(this.glArray[2]+t.glArray[2],0,1),this.glArray[3]=(this.glArray[3]+t.glArray[3])/2,this},Sn.prototype.darken=function(t){return t=$o(t,0,1),this.glArray[0]*=t,this.glArray[1]*=t,this.glArray[2]*=t,this},Sn.prototype.lerp=function(t,e){return e=$o(e,0,1),this.glArray[0]+=(t.glArray[0]-this.glArray[0])*e,this.glArray[1]+=(t.glArray[1]-this.glArray[1])*e,this.glArray[2]+=(t.glArray[2]-this.glArray[2])*e,this},Sn.prototype.lighten=function(t){return t=$o(t,0,1),this.glArray[0]=$o(this.glArray[0]+(1-this.glArray[0])*t,0,1),this.glArray[1]=$o(this.glArray[1]+(1-this.glArray[1])*t,0,1),this.glArray[2]=$o(this.glArray[2]+(1-this.glArray[2])*t,0,1),this},Sn.prototype.random=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),t<0&&(t=0),e>255&&(e=255),this.setColor(Qo(t,e),Qo(t,e),Qo(t,e),this.alpha)},Sn.prototype.equals=function(t){return this.glArray[0]===t.glArray[0]&&this.glArray[1]===t.glArray[1]&&this.glArray[2]===t.glArray[2]&&this.glArray[3]===t.glArray[3]},Sn.prototype.parseCSS=function(t){return An.has(t)?this.setColor.apply(this,An.get(t)):this.parseRGB(t)},Sn.prototype.parseRGB=function(t){var e=_n.exec(t);return e?this.setColor(+e[1],+e[2],+e[3],+e[5]):this.parseHex(t)},Sn.prototype.parseHex=function(t,e){var i;if(void 0===e&&(e=!1),i=Tn.exec(t))return this.setColor(parseInt(i[!1===e?1:2],16),parseInt(i[!1===e?2:3],16),parseInt(i[!1===e?3:4],16),($o(parseInt(i[!1===e?4:1],16),0,255)/255).toFixed(1));if(i=wn.exec(t))return this.setColor(parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16));if(i=bn.exec(t)){var o=i[!1===e?1:2],n=i[!1===e?2:3],r=i[!1===e?3:4],s=i[!1===e?4:1];return this.setColor(parseInt(o+o,16),parseInt(n+n,16),parseInt(r+r,16),($o(parseInt(s+s,16),0,255)/255).toFixed(1))}if(i=xn.exec(t))return this.setColor(parseInt(i[1]+i[1],16),parseInt(i[2]+i[2],16),parseInt(i[3]+i[3],16));throw new Error("invalid parameter: "+t)},Sn.prototype.toUint32=function(t){return void 0===t&&(t=this.alpha),((255*t&255)<<24)+((255&this.r)<<16)+((255&this.g)<<8)+(255&this.b)},Sn.prototype.toArray=function(){return this.glArray},Sn.prototype.toHex=function(){return"#"+mn(this.r)+mn(this.g)+mn(this.b)},Sn.prototype.toHex8=function(t){return void 0===t&&(t=this.alpha),"#"+mn(this.r)+mn(this.g)+mn(this.b)+mn(255*t)},Sn.prototype.toRGB=function(){return"rgb("+this.r+","+this.g+","+this.b+")"},Sn.prototype.toRGBA=function(t){return void 0===t&&(t=this.alpha),"rgba("+this.r+","+this.g+","+this.b+","+t+")"},Object.defineProperties(Sn.prototype,En);var Cn=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},Mn={tx:{configurable:!0},ty:{configurable:!0},tz:{configurable:!0}};Cn.prototype.onResetEvent=function(){void 0===this.val&&(this.val=new Float32Array(16)),arguments.length&&arguments[0]instanceof Cn?this.copy(arguments[0]):16===arguments.length?this.setTransform.apply(this,arguments):this.identity()},Mn.tx.get=function(){return this.val[12]},Mn.ty.get=function(){return this.val[13]},Mn.tz.get=function(){return this.val[14]},Cn.prototype.identity=function(){return this.setTransform(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},Cn.prototype.setTransform=function(t,e,i,o,n,r,s,a,h,l,u,c,p,d,f,y){var g=this.val;return g[0]=t,g[1]=e,g[2]=i,g[3]=o,g[4]=n,g[5]=r,g[6]=s,g[7]=a,g[8]=h,g[9]=l,g[10]=u,g[11]=c,g[12]=p,g[13]=d,g[14]=f,g[15]=y,this},Cn.prototype.copy=function(t){return this.val.set(t.val),this},Cn.prototype.fromMat2d=function(t){var e=t.val;return this.setTransform(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1)},Cn.prototype.multiply=function(t){var e=this.val,i=t.val,o=e[0],n=e[1],r=e[2],s=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],p=e[9],d=e[10],f=e[11],y=e[12],g=e[13],v=e[14],m=e[15],_=i[0],x=i[1],b=i[2],w=i[3];return e[0]=_*o+x*a+b*c+w*y,e[1]=_*n+x*h+b*p+w*g,e[2]=_*r+x*l+b*d+w*v,e[3]=_*s+x*u+b*f+w*m,_=i[4],x=i[5],b=i[6],w=i[7],e[4]=_*o+x*a+b*c+w*y,e[5]=_*n+x*h+b*p+w*g,e[6]=_*r+x*l+b*d+w*v,e[7]=_*s+x*u+b*f+w*m,_=i[8],x=i[9],b=i[10],w=i[11],e[8]=_*o+x*a+b*c+w*y,e[9]=_*n+x*h+b*p+w*g,e[10]=_*r+x*l+b*d+w*v,e[11]=_*s+x*u+b*f+w*m,_=i[12],x=i[13],b=i[14],w=i[15],e[12]=_*o+x*a+b*c+w*y,e[13]=_*n+x*h+b*p+w*g,e[14]=_*r+x*l+b*d+w*v,e[15]=_*s+x*u+b*f+w*m,this},Cn.prototype.transpose=function(){var t=this.val,e=t[1],i=t[2],o=t[3],n=t[6],r=t[7],s=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=n,t[11]=t[14],t[12]=o,t[13]=r,t[14]=s,this},Cn.prototype.invert=function(){var t=this.val,e=t[0],i=t[1],o=t[2],n=t[3],r=t[4],s=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],p=t[11],d=t[12],f=t[13],y=t[14],g=t[15],v=e*s-i*r,m=e*a-o*r,_=e*h-n*r,x=i*a-o*s,b=i*h-n*s,w=o*h-n*a,T=l*f-u*d,A=l*y-c*d,S=l*g-p*d,E=u*y-c*f,C=u*g-p*f,M=c*g-p*y,P=v*M-m*C+_*E+x*S-b*A+w*T;return P?(P=1/P,t[0]=(s*M-a*C+h*E)*P,t[1]=(o*C-i*M-n*E)*P,t[2]=(f*w-y*b+g*x)*P,t[3]=(c*b-u*w-p*x)*P,t[4]=(a*S-r*M-h*A)*P,t[5]=(e*M-o*S+n*A)*P,t[6]=(y*_-d*w-g*m)*P,t[7]=(l*w-c*_+p*m)*P,t[8]=(r*C-s*S+h*T)*P,t[9]=(i*S-e*C-n*T)*P,t[10]=(d*b-f*_+g*v)*P,t[11]=(u*_-l*b-p*v)*P,t[12]=(s*A-r*E-a*T)*P,t[13]=(e*E-i*A+o*T)*P,t[14]=(f*m-d*x-y*v)*P,t[15]=(l*x-u*m+c*v)*P,this):null},Cn.prototype.apply=function(t){var e=this.val,i=t.x,o=t.y,n=void 0!==t.z?t.z:1,r=e[3]*i+e[7]*o+e[11]*n+e[15]||1;return t.x=(e[0]*i+e[4]*o+e[8]*n+e[12])/r,t.y=(e[1]*i+e[5]*o+e[9]*n+e[13])/r,void 0!==t.z&&(t.z=(e[2]*i+e[6]*o+e[10]*n+e[14])/r),t},Cn.prototype.applyInverse=function(t){var e=gn.pull("Matrix3d",this).invert();return e.apply(t),gn.push(e),t},Cn.prototype.ortho=function(t,e,i,o,n,r){var s=this.val,a=1/(t-e),h=1/(i-o),l=1/(n-r);return s[0]=-2*a,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*h,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*l,s[11]=0,s[12]=(t+e)*a,s[13]=(o+i)*h,s[14]=(r+n)*l,s[15]=1,this},Cn.prototype.scale=function(t,e,i){var o=this.val,n=t,r=void 0===e?n:e,s=void 0===i?0:i;return o[0]=o[0]*n,o[1]=o[1]*n,o[2]=o[2]*n,o[3]=o[3]*n,o[4]=o[4]*r,o[5]=o[5]*r,o[6]=o[6]*r,o[7]=o[7]*r,o[8]=o[8]*s,o[9]=o[9]*s,o[10]=o[10]*s,o[11]=o[11]*s,this},Cn.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},Cn.prototype.scaleX=function(t){return this.scale(t,1)},Cn.prototype.scaleY=function(t){return this.scale(1,t)},Cn.prototype.rotate=function(t,e){if(0!==t){var i,o,n,r,s,a,h,l,u,c,p,d,f,y,g,v,m,_,x,b,w,T,A,S,E=this.val,C=e.x,M=e.y,P=e.z,O=Math.sqrt(C*C+M*M+P*P);if(O<qo)return null;C*=O=1/O,M*=O,P*=O,i=Math.sin(t),n=1-(o=Math.cos(t)),r=E[0],s=E[1],a=E[2],h=E[3],l=E[4],u=E[5],c=E[6],p=E[7],d=E[8],f=E[9],y=E[10],g=E[11],v=C*C*n+o,m=M*C*n+P*i,_=P*C*n-M*i,x=C*M*n-P*i,b=M*M*n+o,w=P*M*n+C*i,T=C*P*n+M*i,A=M*P*n-C*i,S=P*P*n+o,E[0]=r*v+l*m+d*_,E[1]=s*v+u*m+f*_,E[2]=a*v+c*m+y*_,E[3]=h*v+p*m+g*_,E[4]=r*x+l*b+d*w,E[5]=s*x+u*b+f*w,E[6]=a*x+c*b+y*w,E[7]=h*x+p*b+g*w,E[8]=r*T+l*A+d*S,E[9]=s*T+u*A+f*S,E[10]=a*T+c*A+y*S,E[11]=h*T+p*A+g*S}return this},Cn.prototype.translate=function(){var t,e,i,o=this.val;return arguments.length>1?(t=arguments[0],e=arguments[1],i=void 0===arguments[2]?0:arguments[2]):(t=arguments[0].x,e=arguments[0].y,i=void 0===arguments[0].z?0:arguments[0].z),o[12]=o[0]*t+o[4]*e+o[8]*i+o[12],o[13]=o[1]*t+o[5]*e+o[9]*i+o[13],o[14]=o[2]*t+o[6]*e+o[10]*i+o[14],o[15]=o[3]*t+o[7]*e+o[11]*i+o[15],this},Cn.prototype.isIdentity=function(){var t=this.val;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},Cn.prototype.equals=function(t){var e=t.val,i=this.val;return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]&&i[9]===e[9]&&i[10]===e[10]&&i[11]===e[11]&&i[12]===e[12]&&i[13]===e[13]&&i[14]===e[14]&&i[15]===e[15]},Cn.prototype.clone=function(){return gn.pull("Matrix3d",this)},Cn.prototype.toArray=function(){return this.val},Cn.prototype.toString=function(){var t=this.val;return"me.Matrix3d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},Object.defineProperties(Cn.prototype,Mn);var Pn=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},On={tx:{configurable:!0},ty:{configurable:!0}};Pn.prototype.onResetEvent=function(){return void 0===this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof Pn?this.copy(arguments[0]):arguments.length&&arguments[0]instanceof Cn?this.fromMat3d(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.identity(),this},On.tx.get=function(){return this.val[6]},On.ty.get=function(){return this.val[7]},Pn.prototype.identity=function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},Pn.prototype.setTransform=function(){var t=this.val;return 9===arguments.length?(t[0]=arguments[0],t[1]=arguments[1],t[2]=arguments[2],t[3]=arguments[3],t[4]=arguments[4],t[5]=arguments[5],t[6]=arguments[6],t[7]=arguments[7],t[8]=arguments[8]):6===arguments.length&&(t[0]=arguments[0],t[1]=arguments[2],t[2]=arguments[4],t[3]=arguments[1],t[4]=arguments[3],t[5]=arguments[5],t[6]=0,t[7]=0,t[8]=1),this},Pn.prototype.copy=function(t){return this.val.set(t.val),this},Pn.prototype.fromMat3d=function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},Pn.prototype.multiply=function(t){var e=t.val,i=this.val,o=i[0],n=i[1],r=i[3],s=i[4],a=e[0],h=e[1],l=e[3],u=e[4],c=e[6],p=e[7];return i[0]=o*a+r*h,i[1]=n*a+s*h,i[3]=o*l+r*u,i[4]=n*l+s*u,i[6]+=o*c+r*p,i[7]+=n*c+s*p,this},Pn.prototype.transpose=function(){var t=this.val,e=t[1],i=t[2],o=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=o,this},Pn.prototype.invert=function(){var t=this.val,e=t[0],i=t[1],o=t[2],n=t[3],r=t[4],s=t[5],a=t[6],h=t[7],l=t[8],u=l*r-s*h,c=s*a-l*n,p=h*n-r*a,d=e*u+i*c+o*p;return t[0]=u/d,t[1]=(o*h-l*i)/d,t[2]=(s*i-o*r)/d,t[3]=c/d,t[4]=(l*e-o*a)/d,t[5]=(o*n-s*e)/d,t[6]=p/d,t[7]=(i*a-h*e)/d,t[8]=(r*e-i*n)/d,this},Pn.prototype.apply=function(t){var e=this.val,i=t.x,o=t.y,n=void 0!==t.z?t.z:1;return t.x=i*e[0]+o*e[3]+n*e[6],t.y=i*e[1]+o*e[4]+n*e[7],void 0!==t.z&&(t.z=i*e[2]+o*e[5]+n*e[8]),t},Pn.prototype.applyInverse=function(t){var e=this.val,i=t.x,o=t.y,n=1/(e[0]*e[4]+e[3]*-e[1]);return t.x=e[4]*n*i+-e[3]*n*o+(e[7]*e[3]-e[6]*e[4])*n,t.y=e[0]*n*o+-e[1]*n*i+(-e[7]*e[0]+e[6]*e[1])*n,t},Pn.prototype.scale=function(t,e){var i=this.val,o=t,n=void 0===e?o:e;return i[0]*=o,i[1]*=o,i[3]*=n,i[4]*=n,this},Pn.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Pn.prototype.scaleX=function(t){return this.scale(t,1)},Pn.prototype.scaleY=function(t){return this.scale(1,t)},Pn.prototype.rotate=function(t){if(0!==t){var e=this.val,i=e[0],o=e[1],n=e[2],r=e[3],s=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);e[0]=l*i+h*r,e[1]=l*o+h*s,e[2]=l*n+h*a,e[3]=l*r-h*i,e[4]=l*s-h*o,e[5]=l*a-h*n}return this},Pn.prototype.translate=function(){var t,e,i=this.val;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),i[6]+=i[0]*t+i[3]*e,i[7]+=i[1]*t+i[4]*e,this},Pn.prototype.isIdentity=function(){var t=this.val;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},Pn.prototype.equals=function(t){var e=t.val,i=this.val;return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]},Pn.prototype.clone=function(){return gn.pull("Matrix2d",this)},Pn.prototype.toArray=function(){return this.val},Pn.prototype.toString=function(){var t=this.val;return"me.Matrix2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},Object.defineProperties(Pn.prototype,On);var kn={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function o(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function r(t,e,o,r,s){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new n(o,r||t,s),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,o,n=[];if(0===this._eventsCount)return n;for(o in t=this._events)e.call(t,o)&&n.push(i?o.slice(1):o);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},a.prototype.listeners=function(t){var e=i?i+t:t,o=this._events[e];if(!o)return[];if(o.fn)return[o.fn];for(var n=0,r=o.length,s=new Array(r);n<r;n++)s[n]=o[n].fn;return s},a.prototype.listenerCount=function(t){var e=i?i+t:t,o=this._events[e];return o?o.fn?1:o.length:0},a.prototype.emit=function(t,e,o,n,r,s){var a=arguments,h=i?i+t:t;if(!this._events[h])return!1;var l,u,c=this._events[h],p=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,o),!0;case 4:return c.fn.call(c.context,e,o,n),!0;case 5:return c.fn.call(c.context,e,o,n,r),!0;case 6:return c.fn.call(c.context,e,o,n,r,s),!0}for(u=1,l=new Array(p-1);u<p;u++)l[u-1]=a[u];c.fn.apply(c.context,l)}else{var d,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),p){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,e);break;case 3:c[u].fn.call(c[u].context,e,o);break;case 4:c[u].fn.call(c[u].context,e,o,n);break;default:if(!l)for(d=1,l=new Array(p-1);d<p;d++)l[d-1]=a[d];c[u].fn.apply(c[u].context,l)}}return!0},a.prototype.on=function(t,e,i){return r(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return r(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,o,n){var r=i?i+t:t;if(!this._events[r])return this;if(!e)return s(this,r),this;var a=this._events[r];if(a.fn)a.fn!==e||n&&!a.once||o&&a.context!==o||s(this,r);else{for(var h=0,l=[],u=a.length;h<u;h++)(a[h].fn!==e||n&&!a[h].once||o&&a[h].context!==o)&&l.push(a[h]);l.length?this._events[r]=1===l.length?l[0]:l:s(this,r)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&s(this,e)):(this._events=new o,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(kn);var In=new(0,kn.exports),Rn="me.boot",Bn="me.state.onPause",Dn="me.state.onResume",Ln="me.state.onStop",zn="me.state.onRestart",Fn="me.state.onChange",Vn="me.video.onInit",jn="me.game.onInit",Nn="me.game.onReset",Un="me.game.beforeUpdate",Gn="me.game.afterUpdate",Xn="me.game.onUpdate",Hn="me.game.beforeDraw",Wn="me.game.afterDraw",Yn="me.game.onLevelLoaded",qn="me.loader.onload",Zn="me.loader.onProgress",Kn="me.input.keydown",Jn="me.input.keyup",$n="gamepad.connected",Qn="gamepad.disconnected",tr="gamepad.update",er="me.event.pointermove",ir="me.event.pointerlockChange",or="me.game.dragstart",nr="me.game.dragend",rr="globalThis.onresize",sr="canvas.onresize",ar="viewport.onresize",hr="globalThis.orientationchange",lr="globalThis.onscroll",ur="viewport.onchange",cr="renderer.contextlost",pr="renderer.contextrestored";function dr(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];return In.emit.apply(In,[t].concat(e))}function fr(t,e,i){return In.on(t,e,i)}function yr(t,e,i){return In.once(t,e,i)}function gr(t,e){return In.off(t,e)}var vr=Object.freeze({__proto__:null,BOOT:Rn,STATE_PAUSE:Bn,STATE_RESUME:Dn,STATE_STOP:Ln,STATE_RESTART:zn,STATE_CHANGE:Fn,VIDEO_INIT:Vn,GAME_INIT:jn,GAME_RESET:Nn,GAME_BEFORE_UPDATE:Un,GAME_AFTER_UPDATE:Gn,GAME_UPDATE:Xn,GAME_BEFORE_DRAW:Hn,GAME_AFTER_DRAW:Wn,LEVEL_LOADED:Yn,LOADER_COMPLETE:qn,LOADER_PROGRESS:Zn,KEYDOWN:Kn,KEYUP:Jn,GAMEPAD_CONNECTED:$n,GAMEPAD_DISCONNECTED:Qn,GAMEPAD_UPDATE:tr,POINTERMOVE:er,POINTERLOCKCHANGE:ir,DRAGSTART:or,DRAGEND:nr,WINDOW_ONRESIZE:rr,CANVAS_ONRESIZE:sr,VIEWPORT_ONRESIZE:ar,WINDOW_ONORIENTATION_CHANGE:hr,WINDOW_ONSCROLL:lr,VIEWPORT_ONCHANGE:ur,ONCONTEXT_LOST:cr,ONCONTEXT_RESTORED:pr,emit:dr,on:fr,once:yr,off:gr}),mr={};
9
9
  /*!
10
10
  * howler.js v2.2.3
11
11
  * howlerjs.com
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * MIT License
17
17
  */
18
- !function(t){!function(){var e=function(){this.init()};e.prototype={init:function(){var t=this||i;return t._counter=1e3,t._html5AudioPool=[],t.html5PoolSize=10,t._codecs={},t._howls=[],t._muted=!1,t._volume=1,t._canPlayEvent="canplaythrough",t._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,t.masterGain=null,t.noAudio=!1,t.usingWebAudio=!0,t.autoSuspend=!0,t.ctx=null,t.autoUnlock=!0,t._setup(),t},volume:function(t){var e=this||i;if(t=parseFloat(t),e.ctx||c(),void 0!==t&&t>=0&&t<=1){if(e._volume=t,e._muted)return e;e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t,i.ctx.currentTime);for(var o=0;o<e._howls.length;o++)if(!e._howls[o]._webAudio)for(var r=e._howls[o]._getSoundIds(),n=0;n<r.length;n++){var s=e._howls[o]._soundById(r[n]);s&&s._node&&(s._node.volume=s._volume*t)}return e}return e._volume},mute:function(t){var e=this||i;e.ctx||c(),e._muted=t,e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t?0:e._volume,i.ctx.currentTime);for(var o=0;o<e._howls.length;o++)if(!e._howls[o]._webAudio)for(var r=e._howls[o]._getSoundIds(),n=0;n<r.length;n++){var s=e._howls[o]._soundById(r[n]);s&&s._node&&(s._node.muted=!!t||s._muted)}return e},stop:function(){for(var t=this||i,e=0;e<t._howls.length;e++)t._howls[e].stop();return t},unload:function(){for(var t=this||i,e=t._howls.length-1;e>=0;e--)t._howls[e].unload();return t.usingWebAudio&&t.ctx&&void 0!==t.ctx.close&&(t.ctx.close(),t.ctx=null,c()),t},codecs:function(t){return(this||i)._codecs[t.replace(/^x-/,"")]},_setup:function(){var t=this||i;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(t){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||i,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(e){return t}if(!e||"function"!=typeof e.canPlayType)return t;var o=e.canPlayType("audio/mpeg;").replace(/^no$/,""),r=t._navigator?t._navigator.userAgent:"",n=r.match(/OPR\/([0-6].)/g),s=n&&parseInt(n[0].split("/")[1],10)<33,a=-1!==r.indexOf("Safari")&&-1===r.indexOf("Chrome"),l=r.match(/Version\/(.*?) /),h=a&&l&&parseInt(l[1],10)<15;return t._codecs={mp3:!(s||!o&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!o,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(h||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(h||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var t=this||i;if(!t._audioUnlocked&&t.ctx){t._audioUnlocked=!1,t.autoUnlock=!1,t._mobileUnloaded||44100===t.ctx.sampleRate||(t._mobileUnloaded=!0,t.unload()),t._scratchBuffer=t.ctx.createBuffer(1,1,22050);var e=function(i){for(;t._html5AudioPool.length<t.html5PoolSize;)try{var o=new Audio;o._unlocked=!0,t._releaseHtml5Audio(o)}catch(e){t.noAudio=!0;break}for(var r=0;r<t._howls.length;r++)if(!t._howls[r]._webAudio)for(var n=t._howls[r]._getSoundIds(),s=0;s<n.length;s++){var a=t._howls[r]._soundById(n[s]);a&&a._node&&!a._node._unlocked&&(a._node._unlocked=!0,a._node.load())}t._autoResume();var l=t.ctx.createBufferSource();l.buffer=t._scratchBuffer,l.connect(t.ctx.destination),void 0===l.start?l.noteOn(0):l.start(0),"function"==typeof t.ctx.resume&&t.ctx.resume(),l.onended=function(){l.disconnect(0),t._audioUnlocked=!0,document.removeEventListener("touchstart",e,!0),document.removeEventListener("touchend",e,!0),document.removeEventListener("click",e,!0),document.removeEventListener("keydown",e,!0);for(var i=0;i<t._howls.length;i++)t._howls[i]._emit("unlock")}};return document.addEventListener("touchstart",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("click",e,!0),document.addEventListener("keydown",e,!0),t}},_obtainHtml5Audio:function(){var t=this||i;if(t._html5AudioPool.length)return t._html5AudioPool.pop();var e=(new Audio).play();return e&&"undefined"!=typeof Promise&&(e instanceof Promise||"function"==typeof e.then)&&e.catch((function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")})),new Audio},_releaseHtml5Audio:function(t){var e=this||i;return t._unlocked&&e._html5AudioPool.push(t),e},_autoSuspend:function(){var t=this;if(t.autoSuspend&&t.ctx&&void 0!==t.ctx.suspend&&i.usingWebAudio){for(var e=0;e<t._howls.length;e++)if(t._howls[e]._webAudio)for(var o=0;o<t._howls[e]._sounds.length;o++)if(!t._howls[e]._sounds[o]._paused)return t;return t._suspendTimer&&clearTimeout(t._suspendTimer),t._suspendTimer=setTimeout((function(){if(t.autoSuspend){t._suspendTimer=null,t.state="suspending";var e=function(){t.state="suspended",t._resumeAfterSuspend&&(delete t._resumeAfterSuspend,t._autoResume())};t.ctx.suspend().then(e,e)}}),3e4),t}},_autoResume:function(){var t=this;if(t.ctx&&void 0!==t.ctx.resume&&i.usingWebAudio)return"running"===t.state&&"interrupted"!==t.ctx.state&&t._suspendTimer?(clearTimeout(t._suspendTimer),t._suspendTimer=null):"suspended"===t.state||"running"===t.state&&"interrupted"===t.ctx.state?(t.ctx.resume().then((function(){t.state="running";for(var e=0;e<t._howls.length;e++)t._howls[e]._emit("resume")})),t._suspendTimer&&(clearTimeout(t._suspendTimer),t._suspendTimer=null)):"suspending"===t.state&&(t._resumeAfterSuspend=!0),t}};var i=new e,o=function(t){t.src&&0!==t.src.length?this.init(t):console.error("An array of source files must be passed with any new Howl.")};o.prototype={init:function(t){var e=this;return i.ctx||c(),e._autoplay=t.autoplay||!1,e._format="string"!=typeof t.format?t.format:[t.format],e._html5=t.html5||!1,e._muted=t.mute||!1,e._loop=t.loop||!1,e._pool=t.pool||5,e._preload="boolean"!=typeof t.preload&&"metadata"!==t.preload||t.preload,e._rate=t.rate||1,e._sprite=t.sprite||{},e._src="string"!=typeof t.src?t.src:[t.src],e._volume=void 0!==t.volume?t.volume:1,e._xhr={method:t.xhr&&t.xhr.method?t.xhr.method:"GET",headers:t.xhr&&t.xhr.headers?t.xhr.headers:null,withCredentials:!(!t.xhr||!t.xhr.withCredentials)&&t.xhr.withCredentials},e._duration=0,e._state="unloaded",e._sounds=[],e._endTimers={},e._queue=[],e._playLock=!1,e._onend=t.onend?[{fn:t.onend}]:[],e._onfade=t.onfade?[{fn:t.onfade}]:[],e._onload=t.onload?[{fn:t.onload}]:[],e._onloaderror=t.onloaderror?[{fn:t.onloaderror}]:[],e._onplayerror=t.onplayerror?[{fn:t.onplayerror}]:[],e._onpause=t.onpause?[{fn:t.onpause}]:[],e._onplay=t.onplay?[{fn:t.onplay}]:[],e._onstop=t.onstop?[{fn:t.onstop}]:[],e._onmute=t.onmute?[{fn:t.onmute}]:[],e._onvolume=t.onvolume?[{fn:t.onvolume}]:[],e._onrate=t.onrate?[{fn:t.onrate}]:[],e._onseek=t.onseek?[{fn:t.onseek}]:[],e._onunlock=t.onunlock?[{fn:t.onunlock}]:[],e._onresume=[],e._webAudio=i.usingWebAudio&&!e._html5,void 0!==i.ctx&&i.ctx&&i.autoUnlock&&i._unlockAudio(),i._howls.push(e),e._autoplay&&e._queue.push({event:"play",action:function(){e.play()}}),e._preload&&"none"!==e._preload&&e.load(),e},load:function(){var t=this,e=null;if(i.noAudio)t._emit("loaderror",null,"No audio support.");else{"string"==typeof t._src&&(t._src=[t._src]);for(var o=0;o<t._src.length;o++){var n,a;if(t._format&&t._format[o])n=t._format[o];else{if("string"!=typeof(a=t._src[o])){t._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}(n=/^data:audio\/([^;,]+);/i.exec(a))||(n=/\.([^.]+)$/.exec(a.split("?",1)[0])),n&&(n=n[1].toLowerCase())}if(n||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),n&&i.codecs(n)){e=t._src[o];break}}if(e)return t._src=e,t._state="loading","https:"===window.location.protocol&&"http:"===e.slice(0,5)&&(t._html5=!0,t._webAudio=!1),new r(t),t._webAudio&&s(t),t;t._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(t,e){var o=this,r=null;if("number"==typeof t)r=t,t=null;else{if("string"==typeof t&&"loaded"===o._state&&!o._sprite[t])return null;if(void 0===t&&(t="__default",!o._playLock)){for(var n=0,s=0;s<o._sounds.length;s++)o._sounds[s]._paused&&!o._sounds[s]._ended&&(n++,r=o._sounds[s]._id);1===n?t=null:r=null}}var a=r?o._soundById(r):o._inactiveSound();if(!a)return null;if(r&&!t&&(t=a._sprite||"__default"),"loaded"!==o._state){a._sprite=t,a._ended=!1;var l=a._id;return o._queue.push({event:"play",action:function(){o.play(l)}}),l}if(r&&!a._paused)return e||o._loadQueue("play"),a._id;o._webAudio&&i._autoResume();var h=Math.max(0,a._seek>0?a._seek:o._sprite[t][0]/1e3),c=Math.max(0,(o._sprite[t][0]+o._sprite[t][1])/1e3-h),u=1e3*c/Math.abs(a._rate),p=o._sprite[t][0]/1e3,d=(o._sprite[t][0]+o._sprite[t][1])/1e3;a._sprite=t,a._ended=!1;var f=function(){a._paused=!1,a._seek=h,a._start=p,a._stop=d,a._loop=!(!a._loop&&!o._sprite[t][2])};if(!(h>=d)){var y=a._node;if(o._webAudio){var g=function(){o._playLock=!1,f(),o._refreshBuffer(a);var t=a._muted||o._muted?0:a._volume;y.gain.setValueAtTime(t,i.ctx.currentTime),a._playStart=i.ctx.currentTime,void 0===y.bufferSource.start?a._loop?y.bufferSource.noteGrainOn(0,h,86400):y.bufferSource.noteGrainOn(0,h,c):a._loop?y.bufferSource.start(0,h,86400):y.bufferSource.start(0,h,c),u!==1/0&&(o._endTimers[a._id]=setTimeout(o._ended.bind(o,a),u)),e||setTimeout((function(){o._emit("play",a._id),o._loadQueue()}),0)};"running"===i.state&&"interrupted"!==i.ctx.state?g():(o._playLock=!0,o.once("resume",g),o._clearTimer(a._id))}else{var v=function(){y.currentTime=h,y.muted=a._muted||o._muted||i._muted||y.muted,y.volume=a._volume*i.volume(),y.playbackRate=a._rate;try{var r=y.play();if(r&&"undefined"!=typeof Promise&&(r instanceof Promise||"function"==typeof r.then)?(o._playLock=!0,f(),r.then((function(){o._playLock=!1,y._unlocked=!0,e?o._loadQueue():o._emit("play",a._id)})).catch((function(){o._playLock=!1,o._emit("playerror",a._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),a._ended=!0,a._paused=!0}))):e||(o._playLock=!1,f(),o._emit("play",a._id)),y.playbackRate=a._rate,y.paused)return void o._emit("playerror",a._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==t||a._loop?o._endTimers[a._id]=setTimeout(o._ended.bind(o,a),u):(o._endTimers[a._id]=function(){o._ended(a),y.removeEventListener("ended",o._endTimers[a._id],!1)},y.addEventListener("ended",o._endTimers[a._id],!1))}catch(t){o._emit("playerror",a._id,t)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===y.src&&(y.src=o._src,y.load());var m=window&&window.ejecta||!y.readyState&&i._navigator.isCocoonJS;if(y.readyState>=3||m)v();else{o._playLock=!0,o._state="loading";var _=function(){o._state="loaded",v(),y.removeEventListener(i._canPlayEvent,_,!1)};y.addEventListener(i._canPlayEvent,_,!1),o._clearTimer(a._id)}}return a._id}o._ended(a)},pause:function(t){var e=arguments,i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"pause",action:function(){i.pause(t)}}),i;for(var o=i._getSoundIds(t),r=0;r<o.length;r++){i._clearTimer(o[r]);var n=i._soundById(o[r]);if(n&&!n._paused&&(n._seek=i.seek(o[r]),n._rateSeek=0,n._paused=!0,i._stopFade(o[r]),n._node))if(i._webAudio){if(!n._node.bufferSource)continue;void 0===n._node.bufferSource.stop?n._node.bufferSource.noteOff(0):n._node.bufferSource.stop(0),i._cleanBuffer(n._node)}else isNaN(n._node.duration)&&n._node.duration!==1/0||n._node.pause();e[1]||i._emit("pause",n?n._id:null)}return i},stop:function(t,e){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"stop",action:function(){i.stop(t)}}),i;for(var o=i._getSoundIds(t),r=0;r<o.length;r++){i._clearTimer(o[r]);var n=i._soundById(o[r]);n&&(n._seek=n._start||0,n._rateSeek=0,n._paused=!0,n._ended=!0,i._stopFade(o[r]),n._node&&(i._webAudio?n._node.bufferSource&&(void 0===n._node.bufferSource.stop?n._node.bufferSource.noteOff(0):n._node.bufferSource.stop(0),i._cleanBuffer(n._node)):isNaN(n._node.duration)&&n._node.duration!==1/0||(n._node.currentTime=n._start||0,n._node.pause(),n._node.duration===1/0&&i._clearSound(n._node))),e||i._emit("stop",n._id))}return i},mute:function(t,e){var o=this;if("loaded"!==o._state||o._playLock)return o._queue.push({event:"mute",action:function(){o.mute(t,e)}}),o;if(void 0===e){if("boolean"!=typeof t)return o._muted;o._muted=t}for(var r=o._getSoundIds(e),n=0;n<r.length;n++){var s=o._soundById(r[n]);s&&(s._muted=t,s._interval&&o._stopFade(s._id),o._webAudio&&s._node?s._node.gain.setValueAtTime(t?0:s._volume,i.ctx.currentTime):s._node&&(s._node.muted=!!i._muted||t),o._emit("mute",s._id))}return o},volume:function(){var t,e,o,r=this,n=arguments;if(0===n.length)return r._volume;if(1===n.length||2===n.length&&void 0===n[1]){var s=r._getSoundIds(),a=s.indexOf(n[0]);a>=0?e=parseInt(n[0],10):t=parseFloat(n[0])}else n.length>=2&&(t=parseFloat(n[0]),e=parseInt(n[1],10));if(!(void 0!==t&&t>=0&&t<=1))return(o=e?r._soundById(e):r._sounds[0])?o._volume:0;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,n)}}),r;void 0===e&&(r._volume=t),e=r._getSoundIds(e);for(var l=0;l<e.length;l++)(o=r._soundById(e[l]))&&(o._volume=t,n[2]||r._stopFade(e[l]),r._webAudio&&o._node&&!o._muted?o._node.gain.setValueAtTime(t,i.ctx.currentTime):o._node&&!o._muted&&(o._node.volume=t*i.volume()),r._emit("volume",o._id));return r},fade:function(t,e,o,r){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"fade",action:function(){n.fade(t,e,o,r)}}),n;t=Math.min(Math.max(0,parseFloat(t)),1),e=Math.min(Math.max(0,parseFloat(e)),1),o=parseFloat(o),n.volume(t,r);for(var s=n._getSoundIds(r),a=0;a<s.length;a++){var l=n._soundById(s[a]);if(l){if(r||n._stopFade(s[a]),n._webAudio&&!l._muted){var h=i.ctx.currentTime,c=h+o/1e3;l._volume=t,l._node.gain.setValueAtTime(t,h),l._node.gain.linearRampToValueAtTime(e,c)}n._startFadeInterval(l,t,e,o,s[a],void 0===r)}}return n},_startFadeInterval:function(t,e,i,o,r,n){var s=this,a=e,l=i-e,h=Math.abs(l/.01),c=Math.max(4,h>0?o/h:o),u=Date.now();t._fadeTo=i,t._interval=setInterval((function(){var r=(Date.now()-u)/o;u=Date.now(),a+=l*r,a=Math.round(100*a)/100,a=l<0?Math.max(i,a):Math.min(i,a),s._webAudio?t._volume=a:s.volume(a,t._id,!0),n&&(s._volume=a),(i<e&&a<=i||i>e&&a>=i)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,s.volume(i,t._id),s._emit("fade",t._id))}),c)},_stopFade:function(t){var e=this,o=e._soundById(t);return o&&o._interval&&(e._webAudio&&o._node.gain.cancelScheduledValues(i.ctx.currentTime),clearInterval(o._interval),o._interval=null,e.volume(o._fadeTo,t),o._fadeTo=null,e._emit("fade",t)),e},loop:function(){var t,e,i,o=this,r=arguments;if(0===r.length)return o._loop;if(1===r.length){if("boolean"!=typeof r[0])return!!(i=o._soundById(parseInt(r[0],10)))&&i._loop;t=r[0],o._loop=t}else 2===r.length&&(t=r[0],e=parseInt(r[1],10));for(var n=o._getSoundIds(e),s=0;s<n.length;s++)(i=o._soundById(n[s]))&&(i._loop=t,o._webAudio&&i._node&&i._node.bufferSource&&(i._node.bufferSource.loop=t,t&&(i._node.bufferSource.loopStart=i._start||0,i._node.bufferSource.loopEnd=i._stop,o.playing(n[s])&&(o.pause(n[s],!0),o.play(n[s],!0)))));return o},rate:function(){var t,e,o,r=this,n=arguments;if(0===n.length)e=r._sounds[0]._id;else if(1===n.length){var s=r._getSoundIds(),a=s.indexOf(n[0]);a>=0?e=parseInt(n[0],10):t=parseFloat(n[0])}else 2===n.length&&(t=parseFloat(n[0]),e=parseInt(n[1],10));if("number"!=typeof t)return(o=r._soundById(e))?o._rate:r._rate;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,n)}}),r;void 0===e&&(r._rate=t),e=r._getSoundIds(e);for(var l=0;l<e.length;l++)if(o=r._soundById(e[l])){r.playing(e[l])&&(o._rateSeek=r.seek(e[l]),o._playStart=r._webAudio?i.ctx.currentTime:o._playStart),o._rate=t,r._webAudio&&o._node&&o._node.bufferSource?o._node.bufferSource.playbackRate.setValueAtTime(t,i.ctx.currentTime):o._node&&(o._node.playbackRate=t);var h=r.seek(e[l]),c=(r._sprite[o._sprite][0]+r._sprite[o._sprite][1])/1e3-h,u=1e3*c/Math.abs(o._rate);!r._endTimers[e[l]]&&o._paused||(r._clearTimer(e[l]),r._endTimers[e[l]]=setTimeout(r._ended.bind(r,o),u)),r._emit("rate",o._id)}return r},seek:function(){var t,e,o=this,r=arguments;if(0===r.length)o._sounds.length&&(e=o._sounds[0]._id);else if(1===r.length){var n=o._getSoundIds(),s=n.indexOf(r[0]);s>=0?e=parseInt(r[0],10):o._sounds.length&&(e=o._sounds[0]._id,t=parseFloat(r[0]))}else 2===r.length&&(t=parseFloat(r[0]),e=parseInt(r[1],10));if(void 0===e)return 0;if("number"==typeof t&&("loaded"!==o._state||o._playLock))return o._queue.push({event:"seek",action:function(){o.seek.apply(o,r)}}),o;var a=o._soundById(e);if(a){if(!("number"==typeof t&&t>=0)){if(o._webAudio){var l=o.playing(e)?i.ctx.currentTime-a._playStart:0,h=a._rateSeek?a._rateSeek-a._seek:0;return a._seek+(h+l*Math.abs(a._rate))}return a._node.currentTime}var c=o.playing(e);c&&o.pause(e,!0),a._seek=t,a._ended=!1,o._clearTimer(e),o._webAudio||!a._node||isNaN(a._node.duration)||(a._node.currentTime=t);var u=function(){c&&o.play(e,!0),o._emit("seek",e)};if(c&&!o._webAudio){var p=function(){o._playLock?setTimeout(p,0):u()};setTimeout(p,0)}else u()}return o},playing:function(t){var e=this;if("number"==typeof t){var i=e._soundById(t);return!!i&&!i._paused}for(var o=0;o<e._sounds.length;o++)if(!e._sounds[o]._paused)return!0;return!1},duration:function(t){var e=this,i=e._duration,o=e._soundById(t);return o&&(i=e._sprite[o._sprite][1]/1e3),i},state:function(){return this._state},unload:function(){for(var t=this,e=t._sounds,o=0;o<e.length;o++)e[o]._paused||t.stop(e[o]._id),t._webAudio||(t._clearSound(e[o]._node),e[o]._node.removeEventListener("error",e[o]._errorFn,!1),e[o]._node.removeEventListener(i._canPlayEvent,e[o]._loadFn,!1),e[o]._node.removeEventListener("ended",e[o]._endFn,!1),i._releaseHtml5Audio(e[o]._node)),delete e[o]._node,t._clearTimer(e[o]._id);var r=i._howls.indexOf(t);r>=0&&i._howls.splice(r,1);var s=!0;for(o=0;o<i._howls.length;o++)if(i._howls[o]._src===t._src||t._src.indexOf(i._howls[o]._src)>=0){s=!1;break}return n&&s&&delete n[t._src],i.noAudio=!1,t._state="unloaded",t._sounds=[],t=null,null},on:function(t,e,i,o){var r=this["_on"+t];return"function"==typeof e&&r.push(o?{id:i,fn:e,once:o}:{id:i,fn:e}),this},off:function(t,e,i){var o=this,r=o["_on"+t],n=0;if("number"==typeof e&&(i=e,e=null),e||i)for(n=0;n<r.length;n++){var s=i===r[n].id;if(e===r[n].fn&&s||!e&&s){r.splice(n,1);break}}else if(t)o["_on"+t]=[];else{var a=Object.keys(o);for(n=0;n<a.length;n++)0===a[n].indexOf("_on")&&Array.isArray(o[a[n]])&&(o[a[n]]=[])}return o},once:function(t,e,i){return this.on(t,e,i,1),this},_emit:function(t,e,i){for(var o=this,r=o["_on"+t],n=r.length-1;n>=0;n--)r[n].id&&r[n].id!==e&&"load"!==t||(setTimeout(function(t){t.call(this,e,i)}.bind(o,r[n].fn),0),r[n].once&&o.off(t,r[n].fn,r[n].id));return o._loadQueue(t),o},_loadQueue:function(t){var e=this;if(e._queue.length>0){var i=e._queue[0];i.event===t&&(e._queue.shift(),e._loadQueue()),t||i.action()}return e},_ended:function(t){var e=this,o=t._sprite;if(!e._webAudio&&t._node&&!t._node.paused&&!t._node.ended&&t._node.currentTime<t._stop)return setTimeout(e._ended.bind(e,t),100),e;var r=!(!t._loop&&!e._sprite[o][2]);if(e._emit("end",t._id),!e._webAudio&&r&&e.stop(t._id,!0).play(t._id),e._webAudio&&r){e._emit("play",t._id),t._seek=t._start||0,t._rateSeek=0,t._playStart=i.ctx.currentTime;var n=1e3*(t._stop-t._start)/Math.abs(t._rate);e._endTimers[t._id]=setTimeout(e._ended.bind(e,t),n)}return e._webAudio&&!r&&(t._paused=!0,t._ended=!0,t._seek=t._start||0,t._rateSeek=0,e._clearTimer(t._id),e._cleanBuffer(t._node),i._autoSuspend()),e._webAudio||r||e.stop(t._id,!0),e},_clearTimer:function(t){var e=this;if(e._endTimers[t]){if("function"!=typeof e._endTimers[t])clearTimeout(e._endTimers[t]);else{var i=e._soundById(t);i&&i._node&&i._node.removeEventListener("ended",e._endTimers[t],!1)}delete e._endTimers[t]}return e},_soundById:function(t){for(var e=this,i=0;i<e._sounds.length;i++)if(t===e._sounds[i]._id)return e._sounds[i];return null},_inactiveSound:function(){var t=this;t._drain();for(var e=0;e<t._sounds.length;e++)if(t._sounds[e]._ended)return t._sounds[e].reset();return new r(t)},_drain:function(){var t=this,e=t._pool,i=0,o=0;if(!(t._sounds.length<e)){for(o=0;o<t._sounds.length;o++)t._sounds[o]._ended&&i++;for(o=t._sounds.length-1;o>=0;o--){if(i<=e)return;t._sounds[o]._ended&&(t._webAudio&&t._sounds[o]._node&&t._sounds[o]._node.disconnect(0),t._sounds.splice(o,1),i--)}}},_getSoundIds:function(t){if(void 0===t){for(var e=[],i=0;i<this._sounds.length;i++)e.push(this._sounds[i]._id);return e}return[t]},_refreshBuffer:function(t){return t._node.bufferSource=i.ctx.createBufferSource(),t._node.bufferSource.buffer=n[this._src],t._panner?t._node.bufferSource.connect(t._panner):t._node.bufferSource.connect(t._node),t._node.bufferSource.loop=t._loop,t._loop&&(t._node.bufferSource.loopStart=t._start||0,t._node.bufferSource.loopEnd=t._stop||0),t._node.bufferSource.playbackRate.setValueAtTime(t._rate,i.ctx.currentTime),this},_cleanBuffer:function(t){var e=i._navigator&&i._navigator.vendor.indexOf("Apple")>=0;if(i._scratchBuffer&&t.bufferSource&&(t.bufferSource.onended=null,t.bufferSource.disconnect(0),e))try{t.bufferSource.buffer=i._scratchBuffer}catch(t){}return t.bufferSource=null,this},_clearSound:function(t){/MSIE |Trident\//.test(i._navigator&&i._navigator.userAgent)||(t.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(t){this._parent=t,this.init()};r.prototype={init:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++i._counter,e._sounds.push(t),t.create(),t},create:function(){var t=this,e=t._parent,o=i._muted||t._muted||t._parent._muted?0:t._volume;return e._webAudio?(t._node=void 0===i.ctx.createGain?i.ctx.createGainNode():i.ctx.createGain(),t._node.gain.setValueAtTime(o,i.ctx.currentTime),t._node.paused=!0,t._node.connect(i.masterGain)):i.noAudio||(t._node=i._obtainHtml5Audio(),t._errorFn=t._errorListener.bind(t),t._node.addEventListener("error",t._errorFn,!1),t._loadFn=t._loadListener.bind(t),t._node.addEventListener(i._canPlayEvent,t._loadFn,!1),t._endFn=t._endListener.bind(t),t._node.addEventListener("ended",t._endFn,!1),t._node.src=e._src,t._node.preload=!0===e._preload?"auto":e._preload,t._node.volume=o*i.volume(),t._node.load()),t},reset:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._rateSeek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++i._counter,t},_errorListener:function(){var t=this;t._parent._emit("loaderror",t._id,t._node.error?t._node.error.code:0),t._node.removeEventListener("error",t._errorFn,!1)},_loadListener:function(){var t=this,e=t._parent;e._duration=Math.ceil(10*t._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),t._node.removeEventListener(i._canPlayEvent,t._loadFn,!1)},_endListener:function(){var t=this,e=t._parent;e._duration===1/0&&(e._duration=Math.ceil(10*t._node.duration)/10,e._sprite.__default[1]===1/0&&(e._sprite.__default[1]=1e3*e._duration),e._ended(t)),t._node.removeEventListener("ended",t._endFn,!1)}};var n={},s=function(t){var e=t._src;if(n[e])return t._duration=n[e].duration,void h(t);if(/^data:[^;]+;base64,/.test(e)){for(var i=atob(e.split(",")[1]),o=new Uint8Array(i.length),r=0;r<i.length;++r)o[r]=i.charCodeAt(r);l(o.buffer,t)}else{var s=new XMLHttpRequest;s.open(t._xhr.method,e,!0),s.withCredentials=t._xhr.withCredentials,s.responseType="arraybuffer",t._xhr.headers&&Object.keys(t._xhr.headers).forEach((function(e){s.setRequestHeader(e,t._xhr.headers[e])})),s.onload=function(){var e=(s.status+"")[0];"0"===e||"2"===e||"3"===e?l(s.response,t):t._emit("loaderror",null,"Failed loading audio file with status: "+s.status+".")},s.onerror=function(){t._webAudio&&(t._html5=!0,t._webAudio=!1,t._sounds=[],delete n[e],t.load())},a(s)}},a=function(t){try{t.send()}catch(e){t.onerror()}},l=function(t,e){var o=function(){e._emit("loaderror",null,"Decoding audio data failed.")},r=function(t){t&&e._sounds.length>0?(n[e._src]=t,h(e,t)):o()};"undefined"!=typeof Promise&&1===i.ctx.decodeAudioData.length?i.ctx.decodeAudioData(t).then(r).catch(o):i.ctx.decodeAudioData(t,r,o)},h=function(t,e){e&&!t._duration&&(t._duration=e.duration),0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue())},c=function(){if(i.usingWebAudio){try{"undefined"!=typeof AudioContext?i.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?i.ctx=new webkitAudioContext:i.usingWebAudio=!1}catch(t){i.usingWebAudio=!1}i.ctx||(i.usingWebAudio=!1);var t=/iP(hone|od|ad)/.test(i._navigator&&i._navigator.platform),e=i._navigator&&i._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),o=e?parseInt(e[1],10):null;if(t&&o&&o<9){var r=/safari/.test(i._navigator&&i._navigator.userAgent.toLowerCase());i._navigator&&!r&&(i.usingWebAudio=!1)}i.usingWebAudio&&(i.masterGain=void 0===i.ctx.createGain?i.ctx.createGainNode():i.ctx.createGain(),i.masterGain.gain.setValueAtTime(i._muted?0:i._volume,i.ctx.currentTime),i.masterGain.connect(i.ctx.destination)),i._setup()}};t.Howler=i,t.Howl=o,void 0!==commonjsGlobal?(commonjsGlobal.HowlerGlobal=e,commonjsGlobal.Howler=i,commonjsGlobal.Howl=o,commonjsGlobal.Sound=r):"undefined"!=typeof window&&(window.HowlerGlobal=e,window.Howler=i,window.Howl=o,window.Sound=r)}(),
18
+ !function(t){!function(){var i=function(){this.init()};i.prototype={init:function(){var t=this||o;return t._counter=1e3,t._html5AudioPool=[],t.html5PoolSize=10,t._codecs={},t._howls=[],t._muted=!1,t._volume=1,t._canPlayEvent="canplaythrough",t._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,t.masterGain=null,t.noAudio=!1,t.usingWebAudio=!0,t.autoSuspend=!0,t.ctx=null,t.autoUnlock=!0,t._setup(),t},volume:function(t){var e=this||o;if(t=parseFloat(t),e.ctx||c(),void 0!==t&&t>=0&&t<=1){if(e._volume=t,e._muted)return e;e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t,o.ctx.currentTime);for(var i=0;i<e._howls.length;i++)if(!e._howls[i]._webAudio)for(var n=e._howls[i]._getSoundIds(),r=0;r<n.length;r++){var s=e._howls[i]._soundById(n[r]);s&&s._node&&(s._node.volume=s._volume*t)}return e}return e._volume},mute:function(t){var e=this||o;e.ctx||c(),e._muted=t,e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t?0:e._volume,o.ctx.currentTime);for(var i=0;i<e._howls.length;i++)if(!e._howls[i]._webAudio)for(var n=e._howls[i]._getSoundIds(),r=0;r<n.length;r++){var s=e._howls[i]._soundById(n[r]);s&&s._node&&(s._node.muted=!!t||s._muted)}return e},stop:function(){for(var t=this||o,e=0;e<t._howls.length;e++)t._howls[e].stop();return t},unload:function(){for(var t=this||o,e=t._howls.length-1;e>=0;e--)t._howls[e].unload();return t.usingWebAudio&&t.ctx&&void 0!==t.ctx.close&&(t.ctx.close(),t.ctx=null,c()),t},codecs:function(t){return(this||o)._codecs[t.replace(/^x-/,"")]},_setup:function(){var t=this||o;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(t){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||o,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(e){return t}if(!e||"function"!=typeof e.canPlayType)return t;var i=e.canPlayType("audio/mpeg;").replace(/^no$/,""),n=t._navigator?t._navigator.userAgent:"",r=n.match(/OPR\/([0-6].)/g),s=r&&parseInt(r[0].split("/")[1],10)<33,a=-1!==n.indexOf("Safari")&&-1===n.indexOf("Chrome"),h=n.match(/Version\/(.*?) /),l=a&&h&&parseInt(h[1],10)<15;return t._codecs={mp3:!(s||!i&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!i,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(l||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(l||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var t=this||o;if(!t._audioUnlocked&&t.ctx){t._audioUnlocked=!1,t.autoUnlock=!1,t._mobileUnloaded||44100===t.ctx.sampleRate||(t._mobileUnloaded=!0,t.unload()),t._scratchBuffer=t.ctx.createBuffer(1,1,22050);var e=function(i){for(;t._html5AudioPool.length<t.html5PoolSize;)try{var o=new Audio;o._unlocked=!0,t._releaseHtml5Audio(o)}catch(e){t.noAudio=!0;break}for(var n=0;n<t._howls.length;n++)if(!t._howls[n]._webAudio)for(var r=t._howls[n]._getSoundIds(),s=0;s<r.length;s++){var a=t._howls[n]._soundById(r[s]);a&&a._node&&!a._node._unlocked&&(a._node._unlocked=!0,a._node.load())}t._autoResume();var h=t.ctx.createBufferSource();h.buffer=t._scratchBuffer,h.connect(t.ctx.destination),void 0===h.start?h.noteOn(0):h.start(0),"function"==typeof t.ctx.resume&&t.ctx.resume(),h.onended=function(){h.disconnect(0),t._audioUnlocked=!0,document.removeEventListener("touchstart",e,!0),document.removeEventListener("touchend",e,!0),document.removeEventListener("click",e,!0),document.removeEventListener("keydown",e,!0);for(var i=0;i<t._howls.length;i++)t._howls[i]._emit("unlock")}};return document.addEventListener("touchstart",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("click",e,!0),document.addEventListener("keydown",e,!0),t}},_obtainHtml5Audio:function(){var t=this||o;if(t._html5AudioPool.length)return t._html5AudioPool.pop();var e=(new Audio).play();return e&&"undefined"!=typeof Promise&&(e instanceof Promise||"function"==typeof e.then)&&e.catch((function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")})),new Audio},_releaseHtml5Audio:function(t){var e=this||o;return t._unlocked&&e._html5AudioPool.push(t),e},_autoSuspend:function(){var t=this;if(t.autoSuspend&&t.ctx&&void 0!==t.ctx.suspend&&o.usingWebAudio){for(var e=0;e<t._howls.length;e++)if(t._howls[e]._webAudio)for(var i=0;i<t._howls[e]._sounds.length;i++)if(!t._howls[e]._sounds[i]._paused)return t;return t._suspendTimer&&clearTimeout(t._suspendTimer),t._suspendTimer=setTimeout((function(){if(t.autoSuspend){t._suspendTimer=null,t.state="suspending";var e=function(){t.state="suspended",t._resumeAfterSuspend&&(delete t._resumeAfterSuspend,t._autoResume())};t.ctx.suspend().then(e,e)}}),3e4),t}},_autoResume:function(){var t=this;if(t.ctx&&void 0!==t.ctx.resume&&o.usingWebAudio)return"running"===t.state&&"interrupted"!==t.ctx.state&&t._suspendTimer?(clearTimeout(t._suspendTimer),t._suspendTimer=null):"suspended"===t.state||"running"===t.state&&"interrupted"===t.ctx.state?(t.ctx.resume().then((function(){t.state="running";for(var e=0;e<t._howls.length;e++)t._howls[e]._emit("resume")})),t._suspendTimer&&(clearTimeout(t._suspendTimer),t._suspendTimer=null)):"suspending"===t.state&&(t._resumeAfterSuspend=!0),t}};var o=new i,n=function(t){t.src&&0!==t.src.length?this.init(t):console.error("An array of source files must be passed with any new Howl.")};n.prototype={init:function(t){var e=this;return o.ctx||c(),e._autoplay=t.autoplay||!1,e._format="string"!=typeof t.format?t.format:[t.format],e._html5=t.html5||!1,e._muted=t.mute||!1,e._loop=t.loop||!1,e._pool=t.pool||5,e._preload="boolean"!=typeof t.preload&&"metadata"!==t.preload||t.preload,e._rate=t.rate||1,e._sprite=t.sprite||{},e._src="string"!=typeof t.src?t.src:[t.src],e._volume=void 0!==t.volume?t.volume:1,e._xhr={method:t.xhr&&t.xhr.method?t.xhr.method:"GET",headers:t.xhr&&t.xhr.headers?t.xhr.headers:null,withCredentials:!(!t.xhr||!t.xhr.withCredentials)&&t.xhr.withCredentials},e._duration=0,e._state="unloaded",e._sounds=[],e._endTimers={},e._queue=[],e._playLock=!1,e._onend=t.onend?[{fn:t.onend}]:[],e._onfade=t.onfade?[{fn:t.onfade}]:[],e._onload=t.onload?[{fn:t.onload}]:[],e._onloaderror=t.onloaderror?[{fn:t.onloaderror}]:[],e._onplayerror=t.onplayerror?[{fn:t.onplayerror}]:[],e._onpause=t.onpause?[{fn:t.onpause}]:[],e._onplay=t.onplay?[{fn:t.onplay}]:[],e._onstop=t.onstop?[{fn:t.onstop}]:[],e._onmute=t.onmute?[{fn:t.onmute}]:[],e._onvolume=t.onvolume?[{fn:t.onvolume}]:[],e._onrate=t.onrate?[{fn:t.onrate}]:[],e._onseek=t.onseek?[{fn:t.onseek}]:[],e._onunlock=t.onunlock?[{fn:t.onunlock}]:[],e._onresume=[],e._webAudio=o.usingWebAudio&&!e._html5,void 0!==o.ctx&&o.ctx&&o.autoUnlock&&o._unlockAudio(),o._howls.push(e),e._autoplay&&e._queue.push({event:"play",action:function(){e.play()}}),e._preload&&"none"!==e._preload&&e.load(),e},load:function(){var t=this,e=null;if(o.noAudio)t._emit("loaderror",null,"No audio support.");else{"string"==typeof t._src&&(t._src=[t._src]);for(var i=0;i<t._src.length;i++){var n,s;if(t._format&&t._format[i])n=t._format[i];else{if("string"!=typeof(s=t._src[i])){t._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}(n=/^data:audio\/([^;,]+);/i.exec(s))||(n=/\.([^.]+)$/.exec(s.split("?",1)[0])),n&&(n=n[1].toLowerCase())}if(n||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),n&&o.codecs(n)){e=t._src[i];break}}if(e)return t._src=e,t._state="loading","https:"===window.location.protocol&&"http:"===e.slice(0,5)&&(t._html5=!0,t._webAudio=!1),new r(t),t._webAudio&&a(t),t;t._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(t,e){var i=this,n=null;if("number"==typeof t)n=t,t=null;else{if("string"==typeof t&&"loaded"===i._state&&!i._sprite[t])return null;if(void 0===t&&(t="__default",!i._playLock)){for(var r=0,s=0;s<i._sounds.length;s++)i._sounds[s]._paused&&!i._sounds[s]._ended&&(r++,n=i._sounds[s]._id);1===r?t=null:n=null}}var a=n?i._soundById(n):i._inactiveSound();if(!a)return null;if(n&&!t&&(t=a._sprite||"__default"),"loaded"!==i._state){a._sprite=t,a._ended=!1;var h=a._id;return i._queue.push({event:"play",action:function(){i.play(h)}}),h}if(n&&!a._paused)return e||i._loadQueue("play"),a._id;i._webAudio&&o._autoResume();var l=Math.max(0,a._seek>0?a._seek:i._sprite[t][0]/1e3),u=Math.max(0,(i._sprite[t][0]+i._sprite[t][1])/1e3-l),c=1e3*u/Math.abs(a._rate),p=i._sprite[t][0]/1e3,d=(i._sprite[t][0]+i._sprite[t][1])/1e3;a._sprite=t,a._ended=!1;var f=function(){a._paused=!1,a._seek=l,a._start=p,a._stop=d,a._loop=!(!a._loop&&!i._sprite[t][2])};if(!(l>=d)){var y=a._node;if(i._webAudio){var g=function(){i._playLock=!1,f(),i._refreshBuffer(a);var t=a._muted||i._muted?0:a._volume;y.gain.setValueAtTime(t,o.ctx.currentTime),a._playStart=o.ctx.currentTime,void 0===y.bufferSource.start?a._loop?y.bufferSource.noteGrainOn(0,l,86400):y.bufferSource.noteGrainOn(0,l,u):a._loop?y.bufferSource.start(0,l,86400):y.bufferSource.start(0,l,u),c!==1/0&&(i._endTimers[a._id]=setTimeout(i._ended.bind(i,a),c)),e||setTimeout((function(){i._emit("play",a._id),i._loadQueue()}),0)};"running"===o.state&&"interrupted"!==o.ctx.state?g():(i._playLock=!0,i.once("resume",g),i._clearTimer(a._id))}else{var v=function(){y.currentTime=l,y.muted=a._muted||i._muted||o._muted||y.muted,y.volume=a._volume*o.volume(),y.playbackRate=a._rate;try{var n=y.play();if(n&&"undefined"!=typeof Promise&&(n instanceof Promise||"function"==typeof n.then)?(i._playLock=!0,f(),n.then((function(){i._playLock=!1,y._unlocked=!0,e?i._loadQueue():i._emit("play",a._id)})).catch((function(){i._playLock=!1,i._emit("playerror",a._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),a._ended=!0,a._paused=!0}))):e||(i._playLock=!1,f(),i._emit("play",a._id)),y.playbackRate=a._rate,y.paused)return void i._emit("playerror",a._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==t||a._loop?i._endTimers[a._id]=setTimeout(i._ended.bind(i,a),c):(i._endTimers[a._id]=function(){i._ended(a),y.removeEventListener("ended",i._endTimers[a._id],!1)},y.addEventListener("ended",i._endTimers[a._id],!1))}catch(t){i._emit("playerror",a._id,t)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===y.src&&(y.src=i._src,y.load());var m=window&&window.ejecta||!y.readyState&&o._navigator.isCocoonJS;if(y.readyState>=3||m)v();else{i._playLock=!0,i._state="loading";var _=function(){i._state="loaded",v(),y.removeEventListener(o._canPlayEvent,_,!1)};y.addEventListener(o._canPlayEvent,_,!1),i._clearTimer(a._id)}}return a._id}i._ended(a)},pause:function(t){var e=arguments,i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"pause",action:function(){i.pause(t)}}),i;for(var o=i._getSoundIds(t),n=0;n<o.length;n++){i._clearTimer(o[n]);var r=i._soundById(o[n]);if(r&&!r._paused&&(r._seek=i.seek(o[n]),r._rateSeek=0,r._paused=!0,i._stopFade(o[n]),r._node))if(i._webAudio){if(!r._node.bufferSource)continue;void 0===r._node.bufferSource.stop?r._node.bufferSource.noteOff(0):r._node.bufferSource.stop(0),i._cleanBuffer(r._node)}else isNaN(r._node.duration)&&r._node.duration!==1/0||r._node.pause();e[1]||i._emit("pause",r?r._id:null)}return i},stop:function(t,e){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"stop",action:function(){i.stop(t)}}),i;for(var o=i._getSoundIds(t),n=0;n<o.length;n++){i._clearTimer(o[n]);var r=i._soundById(o[n]);r&&(r._seek=r._start||0,r._rateSeek=0,r._paused=!0,r._ended=!0,i._stopFade(o[n]),r._node&&(i._webAudio?r._node.bufferSource&&(void 0===r._node.bufferSource.stop?r._node.bufferSource.noteOff(0):r._node.bufferSource.stop(0),i._cleanBuffer(r._node)):isNaN(r._node.duration)&&r._node.duration!==1/0||(r._node.currentTime=r._start||0,r._node.pause(),r._node.duration===1/0&&i._clearSound(r._node))),e||i._emit("stop",r._id))}return i},mute:function(t,e){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"mute",action:function(){i.mute(t,e)}}),i;if(void 0===e){if("boolean"!=typeof t)return i._muted;i._muted=t}for(var n=i._getSoundIds(e),r=0;r<n.length;r++){var s=i._soundById(n[r]);s&&(s._muted=t,s._interval&&i._stopFade(s._id),i._webAudio&&s._node?s._node.gain.setValueAtTime(t?0:s._volume,o.ctx.currentTime):s._node&&(s._node.muted=!!o._muted||t),i._emit("mute",s._id))}return i},volume:function(){var t,e,i,n=this,r=arguments;if(0===r.length)return n._volume;if(1===r.length||2===r.length&&void 0===r[1]){var s=n._getSoundIds(),a=s.indexOf(r[0]);a>=0?e=parseInt(r[0],10):t=parseFloat(r[0])}else r.length>=2&&(t=parseFloat(r[0]),e=parseInt(r[1],10));if(!(void 0!==t&&t>=0&&t<=1))return(i=e?n._soundById(e):n._sounds[0])?i._volume:0;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"volume",action:function(){n.volume.apply(n,r)}}),n;void 0===e&&(n._volume=t),e=n._getSoundIds(e);for(var h=0;h<e.length;h++)(i=n._soundById(e[h]))&&(i._volume=t,r[2]||n._stopFade(e[h]),n._webAudio&&i._node&&!i._muted?i._node.gain.setValueAtTime(t,o.ctx.currentTime):i._node&&!i._muted&&(i._node.volume=t*o.volume()),n._emit("volume",i._id));return n},fade:function(t,e,i,n){var r=this;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"fade",action:function(){r.fade(t,e,i,n)}}),r;t=Math.min(Math.max(0,parseFloat(t)),1),e=Math.min(Math.max(0,parseFloat(e)),1),i=parseFloat(i),r.volume(t,n);for(var s=r._getSoundIds(n),a=0;a<s.length;a++){var h=r._soundById(s[a]);if(h){if(n||r._stopFade(s[a]),r._webAudio&&!h._muted){var l=o.ctx.currentTime,u=l+i/1e3;h._volume=t,h._node.gain.setValueAtTime(t,l),h._node.gain.linearRampToValueAtTime(e,u)}r._startFadeInterval(h,t,e,i,s[a],void 0===n)}}return r},_startFadeInterval:function(t,e,i,o,n,r){var s=this,a=e,h=i-e,l=Math.abs(h/.01),u=Math.max(4,l>0?o/l:o),c=Date.now();t._fadeTo=i,t._interval=setInterval((function(){var n=(Date.now()-c)/o;c=Date.now(),a+=h*n,a=Math.round(100*a)/100,a=h<0?Math.max(i,a):Math.min(i,a),s._webAudio?t._volume=a:s.volume(a,t._id,!0),r&&(s._volume=a),(i<e&&a<=i||i>e&&a>=i)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,s.volume(i,t._id),s._emit("fade",t._id))}),u)},_stopFade:function(t){var e=this,i=e._soundById(t);return i&&i._interval&&(e._webAudio&&i._node.gain.cancelScheduledValues(o.ctx.currentTime),clearInterval(i._interval),i._interval=null,e.volume(i._fadeTo,t),i._fadeTo=null,e._emit("fade",t)),e},loop:function(){var t,e,i,o=this,n=arguments;if(0===n.length)return o._loop;if(1===n.length){if("boolean"!=typeof n[0])return!!(i=o._soundById(parseInt(n[0],10)))&&i._loop;t=n[0],o._loop=t}else 2===n.length&&(t=n[0],e=parseInt(n[1],10));for(var r=o._getSoundIds(e),s=0;s<r.length;s++)(i=o._soundById(r[s]))&&(i._loop=t,o._webAudio&&i._node&&i._node.bufferSource&&(i._node.bufferSource.loop=t,t&&(i._node.bufferSource.loopStart=i._start||0,i._node.bufferSource.loopEnd=i._stop,o.playing(r[s])&&(o.pause(r[s],!0),o.play(r[s],!0)))));return o},rate:function(){var t,e,i,n=this,r=arguments;if(0===r.length)e=n._sounds[0]._id;else if(1===r.length){var s=n._getSoundIds(),a=s.indexOf(r[0]);a>=0?e=parseInt(r[0],10):t=parseFloat(r[0])}else 2===r.length&&(t=parseFloat(r[0]),e=parseInt(r[1],10));if("number"!=typeof t)return(i=n._soundById(e))?i._rate:n._rate;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"rate",action:function(){n.rate.apply(n,r)}}),n;void 0===e&&(n._rate=t),e=n._getSoundIds(e);for(var h=0;h<e.length;h++)if(i=n._soundById(e[h])){n.playing(e[h])&&(i._rateSeek=n.seek(e[h]),i._playStart=n._webAudio?o.ctx.currentTime:i._playStart),i._rate=t,n._webAudio&&i._node&&i._node.bufferSource?i._node.bufferSource.playbackRate.setValueAtTime(t,o.ctx.currentTime):i._node&&(i._node.playbackRate=t);var l=n.seek(e[h]),u=(n._sprite[i._sprite][0]+n._sprite[i._sprite][1])/1e3-l,c=1e3*u/Math.abs(i._rate);!n._endTimers[e[h]]&&i._paused||(n._clearTimer(e[h]),n._endTimers[e[h]]=setTimeout(n._ended.bind(n,i),c)),n._emit("rate",i._id)}return n},seek:function(){var t,e,i=this,n=arguments;if(0===n.length)i._sounds.length&&(e=i._sounds[0]._id);else if(1===n.length){var r=i._getSoundIds(),s=r.indexOf(n[0]);s>=0?e=parseInt(n[0],10):i._sounds.length&&(e=i._sounds[0]._id,t=parseFloat(n[0]))}else 2===n.length&&(t=parseFloat(n[0]),e=parseInt(n[1],10));if(void 0===e)return 0;if("number"==typeof t&&("loaded"!==i._state||i._playLock))return i._queue.push({event:"seek",action:function(){i.seek.apply(i,n)}}),i;var a=i._soundById(e);if(a){if(!("number"==typeof t&&t>=0)){if(i._webAudio){var h=i.playing(e)?o.ctx.currentTime-a._playStart:0,l=a._rateSeek?a._rateSeek-a._seek:0;return a._seek+(l+h*Math.abs(a._rate))}return a._node.currentTime}var u=i.playing(e);u&&i.pause(e,!0),a._seek=t,a._ended=!1,i._clearTimer(e),i._webAudio||!a._node||isNaN(a._node.duration)||(a._node.currentTime=t);var c=function(){u&&i.play(e,!0),i._emit("seek",e)};if(u&&!i._webAudio){var p=function(){i._playLock?setTimeout(p,0):c()};setTimeout(p,0)}else c()}return i},playing:function(t){var e=this;if("number"==typeof t){var i=e._soundById(t);return!!i&&!i._paused}for(var o=0;o<e._sounds.length;o++)if(!e._sounds[o]._paused)return!0;return!1},duration:function(t){var e=this,i=e._duration,o=e._soundById(t);return o&&(i=e._sprite[o._sprite][1]/1e3),i},state:function(){return this._state},unload:function(){for(var t=this,e=t._sounds,i=0;i<e.length;i++)e[i]._paused||t.stop(e[i]._id),t._webAudio||(t._clearSound(e[i]._node),e[i]._node.removeEventListener("error",e[i]._errorFn,!1),e[i]._node.removeEventListener(o._canPlayEvent,e[i]._loadFn,!1),e[i]._node.removeEventListener("ended",e[i]._endFn,!1),o._releaseHtml5Audio(e[i]._node)),delete e[i]._node,t._clearTimer(e[i]._id);var n=o._howls.indexOf(t);n>=0&&o._howls.splice(n,1);var r=!0;for(i=0;i<o._howls.length;i++)if(o._howls[i]._src===t._src||t._src.indexOf(o._howls[i]._src)>=0){r=!1;break}return s&&r&&delete s[t._src],o.noAudio=!1,t._state="unloaded",t._sounds=[],t=null,null},on:function(t,e,i,o){var n=this["_on"+t];return"function"==typeof e&&n.push(o?{id:i,fn:e,once:o}:{id:i,fn:e}),this},off:function(t,e,i){var o=this,n=o["_on"+t],r=0;if("number"==typeof e&&(i=e,e=null),e||i)for(r=0;r<n.length;r++){var s=i===n[r].id;if(e===n[r].fn&&s||!e&&s){n.splice(r,1);break}}else if(t)o["_on"+t]=[];else{var a=Object.keys(o);for(r=0;r<a.length;r++)0===a[r].indexOf("_on")&&Array.isArray(o[a[r]])&&(o[a[r]]=[])}return o},once:function(t,e,i){return this.on(t,e,i,1),this},_emit:function(t,e,i){for(var o=this,n=o["_on"+t],r=n.length-1;r>=0;r--)n[r].id&&n[r].id!==e&&"load"!==t||(setTimeout(function(t){t.call(this,e,i)}.bind(o,n[r].fn),0),n[r].once&&o.off(t,n[r].fn,n[r].id));return o._loadQueue(t),o},_loadQueue:function(t){var e=this;if(e._queue.length>0){var i=e._queue[0];i.event===t&&(e._queue.shift(),e._loadQueue()),t||i.action()}return e},_ended:function(t){var e=this,i=t._sprite;if(!e._webAudio&&t._node&&!t._node.paused&&!t._node.ended&&t._node.currentTime<t._stop)return setTimeout(e._ended.bind(e,t),100),e;var n=!(!t._loop&&!e._sprite[i][2]);if(e._emit("end",t._id),!e._webAudio&&n&&e.stop(t._id,!0).play(t._id),e._webAudio&&n){e._emit("play",t._id),t._seek=t._start||0,t._rateSeek=0,t._playStart=o.ctx.currentTime;var r=1e3*(t._stop-t._start)/Math.abs(t._rate);e._endTimers[t._id]=setTimeout(e._ended.bind(e,t),r)}return e._webAudio&&!n&&(t._paused=!0,t._ended=!0,t._seek=t._start||0,t._rateSeek=0,e._clearTimer(t._id),e._cleanBuffer(t._node),o._autoSuspend()),e._webAudio||n||e.stop(t._id,!0),e},_clearTimer:function(t){var e=this;if(e._endTimers[t]){if("function"!=typeof e._endTimers[t])clearTimeout(e._endTimers[t]);else{var i=e._soundById(t);i&&i._node&&i._node.removeEventListener("ended",e._endTimers[t],!1)}delete e._endTimers[t]}return e},_soundById:function(t){for(var e=this,i=0;i<e._sounds.length;i++)if(t===e._sounds[i]._id)return e._sounds[i];return null},_inactiveSound:function(){var t=this;t._drain();for(var e=0;e<t._sounds.length;e++)if(t._sounds[e]._ended)return t._sounds[e].reset();return new r(t)},_drain:function(){var t=this,e=t._pool,i=0,o=0;if(!(t._sounds.length<e)){for(o=0;o<t._sounds.length;o++)t._sounds[o]._ended&&i++;for(o=t._sounds.length-1;o>=0;o--){if(i<=e)return;t._sounds[o]._ended&&(t._webAudio&&t._sounds[o]._node&&t._sounds[o]._node.disconnect(0),t._sounds.splice(o,1),i--)}}},_getSoundIds:function(t){if(void 0===t){for(var e=[],i=0;i<this._sounds.length;i++)e.push(this._sounds[i]._id);return e}return[t]},_refreshBuffer:function(t){return t._node.bufferSource=o.ctx.createBufferSource(),t._node.bufferSource.buffer=s[this._src],t._panner?t._node.bufferSource.connect(t._panner):t._node.bufferSource.connect(t._node),t._node.bufferSource.loop=t._loop,t._loop&&(t._node.bufferSource.loopStart=t._start||0,t._node.bufferSource.loopEnd=t._stop||0),t._node.bufferSource.playbackRate.setValueAtTime(t._rate,o.ctx.currentTime),this},_cleanBuffer:function(t){var e=o._navigator&&o._navigator.vendor.indexOf("Apple")>=0;if(o._scratchBuffer&&t.bufferSource&&(t.bufferSource.onended=null,t.bufferSource.disconnect(0),e))try{t.bufferSource.buffer=o._scratchBuffer}catch(t){}return t.bufferSource=null,this},_clearSound:function(t){/MSIE |Trident\//.test(o._navigator&&o._navigator.userAgent)||(t.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(t){this._parent=t,this.init()};r.prototype={init:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++o._counter,e._sounds.push(t),t.create(),t},create:function(){var t=this,e=t._parent,i=o._muted||t._muted||t._parent._muted?0:t._volume;return e._webAudio?(t._node=void 0===o.ctx.createGain?o.ctx.createGainNode():o.ctx.createGain(),t._node.gain.setValueAtTime(i,o.ctx.currentTime),t._node.paused=!0,t._node.connect(o.masterGain)):o.noAudio||(t._node=o._obtainHtml5Audio(),t._errorFn=t._errorListener.bind(t),t._node.addEventListener("error",t._errorFn,!1),t._loadFn=t._loadListener.bind(t),t._node.addEventListener(o._canPlayEvent,t._loadFn,!1),t._endFn=t._endListener.bind(t),t._node.addEventListener("ended",t._endFn,!1),t._node.src=e._src,t._node.preload=!0===e._preload?"auto":e._preload,t._node.volume=i*o.volume(),t._node.load()),t},reset:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._rateSeek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++o._counter,t},_errorListener:function(){var t=this;t._parent._emit("loaderror",t._id,t._node.error?t._node.error.code:0),t._node.removeEventListener("error",t._errorFn,!1)},_loadListener:function(){var t=this,e=t._parent;e._duration=Math.ceil(10*t._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),t._node.removeEventListener(o._canPlayEvent,t._loadFn,!1)},_endListener:function(){var t=this,e=t._parent;e._duration===1/0&&(e._duration=Math.ceil(10*t._node.duration)/10,e._sprite.__default[1]===1/0&&(e._sprite.__default[1]=1e3*e._duration),e._ended(t)),t._node.removeEventListener("ended",t._endFn,!1)}};var s={},a=function(t){var e=t._src;if(s[e])return t._duration=s[e].duration,void u(t);if(/^data:[^;]+;base64,/.test(e)){for(var i=atob(e.split(",")[1]),o=new Uint8Array(i.length),n=0;n<i.length;++n)o[n]=i.charCodeAt(n);l(o.buffer,t)}else{var r=new XMLHttpRequest;r.open(t._xhr.method,e,!0),r.withCredentials=t._xhr.withCredentials,r.responseType="arraybuffer",t._xhr.headers&&Object.keys(t._xhr.headers).forEach((function(e){r.setRequestHeader(e,t._xhr.headers[e])})),r.onload=function(){var e=(r.status+"")[0];"0"===e||"2"===e||"3"===e?l(r.response,t):t._emit("loaderror",null,"Failed loading audio file with status: "+r.status+".")},r.onerror=function(){t._webAudio&&(t._html5=!0,t._webAudio=!1,t._sounds=[],delete s[e],t.load())},h(r)}},h=function(t){try{t.send()}catch(e){t.onerror()}},l=function(t,e){var i=function(){e._emit("loaderror",null,"Decoding audio data failed.")},n=function(t){t&&e._sounds.length>0?(s[e._src]=t,u(e,t)):i()};"undefined"!=typeof Promise&&1===o.ctx.decodeAudioData.length?o.ctx.decodeAudioData(t).then(n).catch(i):o.ctx.decodeAudioData(t,n,i)},u=function(t,e){e&&!t._duration&&(t._duration=e.duration),0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue())},c=function(){if(o.usingWebAudio){try{"undefined"!=typeof AudioContext?o.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?o.ctx=new webkitAudioContext:o.usingWebAudio=!1}catch(t){o.usingWebAudio=!1}o.ctx||(o.usingWebAudio=!1);var t=/iP(hone|od|ad)/.test(o._navigator&&o._navigator.platform),e=o._navigator&&o._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),i=e?parseInt(e[1],10):null;if(t&&i&&i<9){var n=/safari/.test(o._navigator&&o._navigator.userAgent.toLowerCase());o._navigator&&!n&&(o.usingWebAudio=!1)}o.usingWebAudio&&(o.masterGain=void 0===o.ctx.createGain?o.ctx.createGainNode():o.ctx.createGain(),o.masterGain.gain.setValueAtTime(o._muted?0:o._volume,o.ctx.currentTime),o.masterGain.connect(o.ctx.destination)),o._setup()}};t.Howler=o,t.Howl=n,void 0!==e?(e.HowlerGlobal=i,e.Howler=o,e.Howl=n,e.Sound=r):"undefined"!=typeof window&&(window.HowlerGlobal=i,window.Howler=o,window.Howl=n,window.Sound=r)}(),
19
19
  /*!
20
20
  * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
21
21
  *
@@ -27,4 +27,4 @@
27
27
  *
28
28
  * MIT License
29
29
  */
30
- function(){var t;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var i=e._howls.length-1;i>=0;i--)e._howls[i].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,i){var o=this;return o.ctx&&o.ctx.listener?(e="number"!=typeof e?o._pos[1]:e,i="number"!=typeof i?o._pos[2]:i,"number"!=typeof t?o._pos:(o._pos=[t,e,i],void 0!==o.ctx.listener.positionX?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]),o)):o},HowlerGlobal.prototype.orientation=function(t,e,i,o,r,n){var s=this;if(!s.ctx||!s.ctx.listener)return s;var a=s._orientation;return e="number"!=typeof e?a[1]:e,i="number"!=typeof i?a[2]:i,o="number"!=typeof o?a[3]:o,r="number"!=typeof r?a[4]:r,n="number"!=typeof n?a[5]:n,"number"!=typeof t?a:(s._orientation=[t,e,i,o,r,n],void 0!==s.ctx.listener.forwardX?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(n,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,i,o,r,n),s)},Howl.prototype.init=(t=Howl.prototype.init,function(e){var i=this;return i._orientation=e.orientation||[1,0,0],i._stereo=e.stereo||null,i._pos=e.pos||null,i._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},i._onstereo=e.onstereo?[{fn:e.onstereo}]:[],i._onpos=e.onpos?[{fn:e.onpos}]:[],i._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}),Howl.prototype.stereo=function(t,i){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"stereo",action:function(){o.stereo(t,i)}}),o;var r=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===i){if("number"!=typeof t)return o._stereo;o._stereo=t,o._pos=[t,0,0]}for(var n=o._getSoundIds(i),s=0;s<n.length;s++){var a=o._soundById(n[s]);if(a){if("number"!=typeof t)return a._stereo;a._stereo=t,a._pos=[t,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",a._panner&&a._panner.pan||e(a,r),"spatial"===r?void 0!==a._panner.positionX?(a._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(t,0,0):a._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),o._emit("stereo",a._id)}}return o},Howl.prototype.pos=function(t,i,o,r){var n=this;if(!n._webAudio)return n;if("loaded"!==n._state)return n._queue.push({event:"pos",action:function(){n.pos(t,i,o,r)}}),n;if(i="number"!=typeof i?0:i,o="number"!=typeof o?-.5:o,void 0===r){if("number"!=typeof t)return n._pos;n._pos=[t,i,o]}for(var s=n._getSoundIds(r),a=0;a<s.length;a++){var l=n._soundById(s[a]);if(l){if("number"!=typeof t)return l._pos;l._pos=[t,i,o],l._node&&(l._panner&&!l._panner.pan||e(l,"spatial"),void 0!==l._panner.positionX?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(o,Howler.ctx.currentTime)):l._panner.setPosition(t,i,o)),n._emit("pos",l._id)}}return n},Howl.prototype.orientation=function(t,i,o,r){var n=this;if(!n._webAudio)return n;if("loaded"!==n._state)return n._queue.push({event:"orientation",action:function(){n.orientation(t,i,o,r)}}),n;if(i="number"!=typeof i?n._orientation[1]:i,o="number"!=typeof o?n._orientation[2]:o,void 0===r){if("number"!=typeof t)return n._orientation;n._orientation=[t,i,o]}for(var s=n._getSoundIds(r),a=0;a<s.length;a++){var l=n._soundById(s[a]);if(l){if("number"!=typeof t)return l._orientation;l._orientation=[t,i,o],l._node&&(l._panner||(l._pos||(l._pos=n._pos||[0,0,-.5]),e(l,"spatial")),void 0!==l._panner.orientationX?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(o,Howler.ctx.currentTime)):l._panner.setOrientation(t,i,o)),n._emit("orientation",l._id)}}return n},Howl.prototype.pannerAttr=function(){var t,i,o,r=this,n=arguments;if(!r._webAudio)return r;if(0===n.length)return r._pannerAttr;if(1===n.length){if("object"!=typeof n[0])return(o=r._soundById(parseInt(n[0],10)))?o._pannerAttr:r._pannerAttr;t=n[0],void 0===i&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:void 0!==t.pannerAttr.coneInnerAngle?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:void 0!==t.pannerAttr.coneOuterAngle?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:void 0!==t.pannerAttr.coneOuterGain?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:void 0!==t.pannerAttr.distanceModel?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:void 0!==t.pannerAttr.maxDistance?t.pannerAttr.maxDistance:r._maxDistance,refDistance:void 0!==t.pannerAttr.refDistance?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:void 0!==t.pannerAttr.rolloffFactor?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:void 0!==t.pannerAttr.panningModel?t.pannerAttr.panningModel:r._panningModel})}else 2===n.length&&(t=n[0],i=parseInt(n[1],10));for(var s=r._getSoundIds(i),a=0;a<s.length;a++)if(o=r._soundById(s[a])){var l=o._pannerAttr;l={coneInnerAngle:void 0!==t.coneInnerAngle?t.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:void 0!==t.coneOuterAngle?t.coneOuterAngle:l.coneOuterAngle,coneOuterGain:void 0!==t.coneOuterGain?t.coneOuterGain:l.coneOuterGain,distanceModel:void 0!==t.distanceModel?t.distanceModel:l.distanceModel,maxDistance:void 0!==t.maxDistance?t.maxDistance:l.maxDistance,refDistance:void 0!==t.refDistance?t.refDistance:l.refDistance,rolloffFactor:void 0!==t.rolloffFactor?t.rolloffFactor:l.rolloffFactor,panningModel:void 0!==t.panningModel?t.panningModel:l.panningModel};var h=o._panner;h?(h.coneInnerAngle=l.coneInnerAngle,h.coneOuterAngle=l.coneOuterAngle,h.coneOuterGain=l.coneOuterGain,h.distanceModel=l.distanceModel,h.maxDistance=l.maxDistance,h.refDistance=l.refDistance,h.rolloffFactor=l.rolloffFactor,h.panningModel=l.panningModel):(o._pos||(o._pos=r._pos||[0,0,-.5]),e(o,"spatial"))}return r},Sound.prototype.init=function(t){return function(){var e=this,i=e._parent;e._orientation=i._orientation,e._stereo=i._stereo,e._pos=i._pos,e._pannerAttr=i._pannerAttr,t.call(this),e._stereo?i.stereo(e._stereo):e._pos&&i.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,i=e._parent;return e._orientation=i._orientation,e._stereo=i._stereo,e._pos=i._pos,e._pannerAttr=i._pannerAttr,e._stereo?i.stereo(e._stereo):e._pos?i.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,i._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var e=function(t,e){"spatial"===(e=e||"spatial")?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,void 0!==t._panner.positionX?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),void 0!==t._panner.orientationX?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}}()}(howler);var ObservableVector2d=function(t){function e(e,i,o){if(void 0===e&&(e=0),void 0===i&&(i=0),t.call(this,e,i),void 0===o)throw new Error("undefined `onUpdate` callback");this.setCallback(o.onUpdate,o.scope)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={x:{configurable:!0},y:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),this.setMuted(t,e),void 0!==i&&this.setCallback(i.onUpdate,i.scope),this},i.x.get=function(){return this._x},i.x.set=function(t){var e=this.onUpdate.call(this.scope,t,this._y,this._x,this._y);this._x=e&&"x"in e?e.x:t},i.y.get=function(){return this._y},i.y.set=function(t){var e=this.onUpdate.call(this.scope,this._x,t,this._x,this._y);this._y=e&&"y"in e?e.y:t},e.prototype._set=function(t,e){var i=this.onUpdate.call(this.scope,t,e,this._x,this._y);return i&&"x"in i&&"y"in i?(this._x=i.x,this._y=i.y):(this._x=t,this._y=e),this},e.prototype.setMuted=function(t,e){return this._x=t,this._y=e,this},e.prototype.setCallback=function(t,e){if(void 0===e&&(e=null),"function"!=typeof t)throw new Error("invalid `onUpdate` callback");return this.onUpdate=t,this.scope=e,this},e.prototype.add=function(t){return this._set(this._x+t.x,this._y+t.y)},e.prototype.sub=function(t){return this._set(this._x-t.x,this._y-t.y)},e.prototype.scale=function(t,e){return this._set(this._x*t,this._y*(void 0!==e?e:t))},e.prototype.scaleV=function(t){return this._set(this._x*t.x,this._y*t.y)},e.prototype.div=function(t){return this._set(this._x/t,this._y/t)},e.prototype.abs=function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y)},e.prototype.clamp=function(t,i){return new e(clamp(this.x,t,i),clamp(this.y,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(clamp(this._x,t,e),clamp(this._y,t,e))},e.prototype.minV=function(t){return this._set(this._x<t.x?this._x:t.x,this._y<t.y?this._y:t.y)},e.prototype.maxV=function(t){return this._set(this._x>t.x?this._x:t.x,this._y>t.y?this._y:t.y)},e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.floorSelf=function(){return this._set(Math.floor(this._x),Math.floor(this._y))},e.prototype.ceil=function(){return new e(Math.ceil(this._x),Math.ceil(this._y),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.ceilSelf=function(){return this._set(Math.ceil(this._x),Math.ceil(this._y))},e.prototype.negate=function(){return new e(-this._x,-this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.negateSelf=function(){return this._set(-this._x,-this._y)},e.prototype.copy=function(t){return this._set(t.x,t.y)},e.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},e.prototype.perp=function(){return this._set(this._y,-this._x)},e.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var r=this._x-i,n=this._y-o,s=Math.cos(t),a=Math.sin(t);return this._set(r*s-n*a+i,r*a+n*s+o)},e.prototype.dot=function(t){return this._x*t.x+this._y*t.y},e.prototype.cross=function(t){return this._x*t.y-this._y*t.x},e.prototype.lerp=function(t,e){return this._x+=(t.x-this._x)*e,this._y+=(t.y-this._y)*e,this},e.prototype.distance=function(t){return Math.sqrt((this._x-t.x)*(this._x-t.x)+(this._y-t.y)*(this._y-t.y))},e.prototype.clone=function(){return pool$1.pull("ObservableVector2d",this._x,this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.toVector2d=function(){return pool$1.pull("Vector2d",this._x,this._y)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y},Object.defineProperties(e.prototype,i),e}(Vector2d),Vector3d=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.onResetEvent(t,e,i)};Vector3d.prototype.onResetEvent=function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},Vector3d.prototype._set=function(t,e,i){return void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},Vector3d.prototype.set=function(t,e,i){if(t!==+t||e!==+e||void 0!==i&&i!==+i)throw new Error("invalid x, y, z parameters (not a number)");return this._set(t,e,i)},Vector3d.prototype.setZero=function(){return this.set(0,0,0)},Vector3d.prototype.setV=function(t){return this._set(t.x,t.y,t.z)},Vector3d.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y,this.z+(t.z||0))},Vector3d.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y,this.z-(t.z||0))},Vector3d.prototype.scale=function(t,e,i){return e=void 0!==e?e:t,this._set(this.x*t,this.y*e,this.z*(i||1))},Vector3d.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},Vector3d.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y),this.z)},Vector3d.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2,this.z)},Vector3d.prototype.div=function(t){return this._set(this.x/t,this.y/t,this.z/t)},Vector3d.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y,this.z<0?-this.z:this.z)},Vector3d.prototype.clamp=function(t,e){return new Vector3d(clamp(this.x,t,e),clamp(this.y,t,e),clamp(this.z,t,e))},Vector3d.prototype.clampSelf=function(t,e){return this._set(clamp(this.x,t,e),clamp(this.y,t,e),clamp(this.z,t,e))},Vector3d.prototype.minV=function(t){var e=t.z||0;return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y,this.z<e?this.z:e)},Vector3d.prototype.maxV=function(t){var e=t.z||0;return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y,this.z>e?this.z:e)},Vector3d.prototype.floor=function(){return new Vector3d(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},Vector3d.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},Vector3d.prototype.ceil=function(){return new Vector3d(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},Vector3d.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},Vector3d.prototype.negate=function(){return new Vector3d(-this.x,-this.y,-this.z)},Vector3d.prototype.negateSelf=function(){return this._set(-this.x,-this.y,-this.z)},Vector3d.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},Vector3d.prototype.equals=function(){var t,e,i;return arguments.length>=2?(t=arguments[0],e=arguments[1],i=arguments[2]):(t=arguments[0].x,e=arguments[0].y,i=arguments[0].z),void 0===i&&(i=this.z),this.x===t&&this.y===e&&this.z===i},Vector3d.prototype.normalize=function(){return this.div(this.length()||1)},Vector3d.prototype.perp=function(){return this._set(this.y,-this.x,this.z)},Vector3d.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var r=this.x-i,n=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(r*s-n*a+i,r*a+n*s+o,this.z)},Vector3d.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*(void 0!==t.z?t.z:this.z)},Vector3d.prototype.cross=function(t){var e=this.x,i=this.y,o=this.z,r=t.x,n=t.y,s=t.z;return this.x=i*s-o*n,this.y=o*r-e*s,this.z=e*n-i*r,this},Vector3d.prototype.length2=function(){return this.dot(this)},Vector3d.prototype.length=function(){return Math.sqrt(this.length2())},Vector3d.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},Vector3d.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y,o=this.z-(t.z||0);return Math.sqrt(e*e+i*i+o*o)},Vector3d.prototype.angle=function(t){return Math.acos(clamp(this.dot(t)/(this.length()*t.length()),-1,1))},Vector3d.prototype.project=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},Vector3d.prototype.projectN=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},Vector3d.prototype.clone=function(){return pool$1.pull("Vector3d",this.x,this.y,this.z)},Vector3d.prototype.toString=function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z};var ObservableVector3d=function(t){function e(e,i,o,r){if(void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0),t.call(this,e,i,o),void 0===r)throw new Error("undefined `onUpdate` callback");this.setCallback(r.onUpdate,r.scope)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i,o){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.setMuted(t,e,i),void 0!==o&&this.setCallback(o.onUpdate,o.scope),this},i.x.get=function(){return this._x},i.x.set=function(t){var e=this.onUpdate.call(this.scope,t,this._y,this._z,this._x,this._y,this._z);this._x=e&&"x"in e?e.x:t},i.y.get=function(){return this._y},i.y.set=function(t){var e=this.onUpdate.call(this.scope,this._x,t,this._z,this._x,this._y,this._z);this._y=e&&"y"in e?e.y:t},i.z.get=function(){return this._z},i.z.set=function(t){var e=this.onUpdate.call(this.scope,this._x,this._y,t,this._x,this._y,this._z);this._z=e&&"z"in e?e.z:t},e.prototype._set=function(t,e,i){var o=this.onUpdate.call(this.scope,t,e,i,this._x,this._y,this._z);return o&&"x"in o&&"y"in o&&"z"in o?(this._x=o.x,this._y=o.y,this._z=o.z):(this._x=t,this._y=e,this._z=i||0),this},e.prototype.setMuted=function(t,e,i){return this._x=t,this._y=e,this._z=i||0,this},e.prototype.setCallback=function(t,e){if(void 0===e&&(e=null),"function"!=typeof t)throw new Error("invalid `onUpdate` callback");return this.onUpdate=t,this.scope=e,this},e.prototype.add=function(t){return this._set(this._x+t.x,this._y+t.y,this._z+(t.z||0))},e.prototype.sub=function(t){return this._set(this._x-t.x,this._y-t.y,this._z-(t.z||0))},e.prototype.scale=function(t,e,i){return e=void 0!==e?e:t,this._set(this._x*t,this._y*e,this._z*(i||1))},e.prototype.scaleV=function(t){return this._set(this._x*t.x,this._y*t.y,this._z*(t.z||1))},e.prototype.div=function(t){return this._set(this._x/t,this._y/t,this._z/t)},e.prototype.abs=function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y,this._Z<0?-this._z:this._z)},e.prototype.clamp=function(t,i){return new e(clamp(this._x,t,i),clamp(this._y,t,i),clamp(this._z,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(clamp(this._x,t,e),clamp(this._y,t,e),clamp(this._z,t,e))},e.prototype.minV=function(t){var e=t.z||0;return this._set(this._x<t.x?this._x:t.x,this._y<t.y?this._y:t.y,this._z<e?this._z:e)},e.prototype.maxV=function(t){var e=t.z||0;return this._set(this._x>t.x?this._x:t.x,this._y>t.y?this._y:t.y,this._z>e?this._z:e)},e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.floorSelf=function(){return this._set(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},e.prototype.ceil=function(){return new e(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.ceilSelf=function(){return this._set(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z))},e.prototype.negate=function(){return new e(-this._x,-this._y,-this._z,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.negateSelf=function(){return this._set(-this._x,-this._y,-this._z)},e.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},e.prototype.equals=function(t){return this._x===t.x&&this._y===t.y&&this._z===(t.z||this._z)},e.prototype.perp=function(){return this._set(this._y,-this._x,this._z)},e.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var r=this.x-i,n=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(r*s-n*a+i,r*a+n*s+o,this.z)},e.prototype.dot=function(t){return this._x*t.x+this._y*t.y+this._z*(t.z||1)},e.prototype.cross=function(t){var e=this._x,i=this._y,o=this._z,r=t.x,n=t.y,s=t.z;return this._set(i*s-o*n,o*r-e*s,e*n-i*r)},e.prototype.lerp=function(t,e){return this._x+=(t.x-this._x)*e,this._y+=(t.y-this._y)*e,this._z+=(t.z-this._z)*e,this},e.prototype.distance=function(t){var e=this._x-t.x,i=this._y-t.y,o=this._z-(t.z||0);return Math.sqrt(e*e+i*i+o*o)},e.prototype.clone=function(){return pool$1.pull("ObservableVector3d",this._x,this._y,this._z,{onUpdate:this.onUpdate})},e.prototype.toVector3d=function(){return pool$1.pull("Vector3d",this._x,this._y,this._z)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y+",z:"+this._z},Object.defineProperties(e.prototype,i),e}(Vector3d),earcut$1={exports:{}};function earcut(t,e,i){i=i||2;var o,r,n,s,a,l,h,c=e&&e.length,u=c?e[0]*i:t.length,p=linkedList(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(c&&(p=eliminateHoles(t,e,p,i)),t.length>80*i){o=n=t[0],r=s=t[1];for(var f=i;f<u;f+=i)(a=t[f])<o&&(o=a),(l=t[f+1])<r&&(r=l),a>n&&(n=a),l>s&&(s=l);h=0!==(h=Math.max(n-o,s-r))?1/h:0}return earcutLinked(p,d,i,o,r,h),d}function linkedList(t,e,i,o,r){var n,s;if(r===signedArea(t,e,i,o)>0)for(n=e;n<i;n+=o)s=insertNode(n,t[n],t[n+1],s);else for(n=i-o;n>=e;n-=o)s=insertNode(n,t[n],t[n+1],s);return s&&equals(s,s.next)&&(removeNode(s),s=s.next),s}function filterPoints(t,e){if(!t)return t;e||(e=t);var i,o=t;do{if(i=!1,o.steiner||!equals(o,o.next)&&0!==area(o.prev,o,o.next))o=o.next;else{if(removeNode(o),(o=e=o.prev)===o.next)break;i=!0}}while(i||o!==e);return e}function earcutLinked(t,e,i,o,r,n,s){if(t){!s&&n&&indexCurve(t,o,r,n);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?isEarHashed(t,o,r,n):isEar(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),removeNode(t),t=l.next,h=l.next;else if((t=l)===h){s?1===s?earcutLinked(t=cureLocalIntersections(filterPoints(t),e,i),e,i,o,r,n,2):2===s&&splitEarcut(t,e,i,o,r,n):earcutLinked(filterPoints(t),e,i,o,r,n,1);break}}}function isEar(t){var e=t.prev,i=t,o=t.next;if(area(e,i,o)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(pointInTriangle(e.x,e.y,i.x,i.y,o.x,o.y,r.x,r.y)&&area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function isEarHashed(t,e,i,o){var r=t.prev,n=t,s=t.next;if(area(r,n,s)>=0)return!1;for(var a=r.x<n.x?r.x<s.x?r.x:s.x:n.x<s.x?n.x:s.x,l=r.y<n.y?r.y<s.y?r.y:s.y:n.y<s.y?n.y:s.y,h=r.x>n.x?r.x>s.x?r.x:s.x:n.x>s.x?n.x:s.x,c=r.y>n.y?r.y>s.y?r.y:s.y:n.y>s.y?n.y:s.y,u=zOrder(a,l,e,i,o),p=zOrder(h,c,e,i,o),d=t.prevZ,f=t.nextZ;d&&d.z>=u&&f&&f.z<=p;){if(d!==t.prev&&d!==t.next&&pointInTriangle(r.x,r.y,n.x,n.y,s.x,s.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==t.prev&&f!==t.next&&pointInTriangle(r.x,r.y,n.x,n.y,s.x,s.y,f.x,f.y)&&area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=u;){if(d!==t.prev&&d!==t.next&&pointInTriangle(r.x,r.y,n.x,n.y,s.x,s.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&pointInTriangle(r.x,r.y,n.x,n.y,s.x,s.y,f.x,f.y)&&area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function cureLocalIntersections(t,e,i){var o=t;do{var r=o.prev,n=o.next.next;!equals(r,n)&&intersects(r,o,o.next,n)&&locallyInside(r,n)&&locallyInside(n,r)&&(e.push(r.i/i),e.push(o.i/i),e.push(n.i/i),removeNode(o),removeNode(o.next),o=t=n),o=o.next}while(o!==t);return filterPoints(o)}function splitEarcut(t,e,i,o,r,n){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&isValidDiagonal(s,a)){var l=splitPolygon(s,a);return s=filterPoints(s,s.next),l=filterPoints(l,l.next),earcutLinked(s,e,i,o,r,n),void earcutLinked(l,e,i,o,r,n)}a=a.next}s=s.next}while(s!==t)}function eliminateHoles(t,e,i,o){var r,n,s,a=[];for(r=0,n=e.length;r<n;r++)(s=linkedList(t,e[r]*o,r<n-1?e[r+1]*o:t.length,o,!1))===s.next&&(s.steiner=!0),a.push(getLeftmost(s));for(a.sort(compareX),r=0;r<a.length;r++)i=filterPoints(i=eliminateHole(a[r],i),i.next);return i}function compareX(t,e){return t.x-e.x}function eliminateHole(t,e){var i=findHoleBridge(t,e);if(!i)return e;var o=splitPolygon(i,t),r=filterPoints(i,i.next);return filterPoints(o,o.next),e===i?r:e}function findHoleBridge(t,e){var i,o=e,r=t.x,n=t.y,s=-1/0;do{if(n<=o.y&&n>=o.next.y&&o.next.y!==o.y){var a=o.x+(n-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(a<=r&&a>s){if(s=a,a===r){if(n===o.y)return o;if(n===o.next.y)return o.next}i=o.x<o.next.x?o:o.next}}o=o.next}while(o!==e);if(!i)return null;if(r===s)return i;var l,h=i,c=i.x,u=i.y,p=1/0;o=i;do{r>=o.x&&o.x>=c&&r!==o.x&&pointInTriangle(n<u?r:s,n,c,u,n<u?s:r,n,o.x,o.y)&&(l=Math.abs(n-o.y)/(r-o.x),locallyInside(o,t)&&(l<p||l===p&&(o.x>i.x||o.x===i.x&&sectorContainsSector(i,o)))&&(i=o,p=l)),o=o.next}while(o!==h);return i}function sectorContainsSector(t,e){return area(t.prev,t,e.prev)<0&&area(e.next,t,t.next)<0}function indexCurve(t,e,i,o){var r=t;do{null===r.z&&(r.z=zOrder(r.x,r.y,e,i,o)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(t){var e,i,o,r,n,s,a,l,h=1;do{for(i=t,t=null,n=null,s=0;i;){for(s++,o=i,a=0,e=0;e<h&&(a++,o=o.nextZ);e++);for(l=h;a>0||l>0&&o;)0!==a&&(0===l||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,l--),n?n.nextZ=r:t=r,r.prevZ=n,n=r;i=o}n.nextZ=null,h*=2}while(s>1);return t}function zOrder(t,e,i,o,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-o)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function getLeftmost(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function pointInTriangle(t,e,i,o,r,n,s,a){return(r-s)*(e-a)-(t-s)*(n-a)>=0&&(t-s)*(o-a)-(i-s)*(e-a)>=0&&(i-s)*(n-a)-(r-s)*(o-a)>=0}function isValidDiagonal(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!intersectsPolygon(t,e)&&(locallyInside(t,e)&&locallyInside(e,t)&&middleInside(t,e)&&(area(t.prev,t,e.prev)||area(t,e.prev,e))||equals(t,e)&&area(t.prev,t,t.next)>0&&area(e.prev,e,e.next)>0)}function area(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function equals(t,e){return t.x===e.x&&t.y===e.y}function intersects(t,e,i,o){var r=sign(area(t,e,i)),n=sign(area(t,e,o)),s=sign(area(i,o,t)),a=sign(area(i,o,e));return r!==n&&s!==a||(!(0!==r||!onSegment(t,i,e))||(!(0!==n||!onSegment(t,o,e))||(!(0!==s||!onSegment(i,t,o))||!(0!==a||!onSegment(i,e,o)))))}function onSegment(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function sign(t){return t>0?1:t<0?-1:0}function intersectsPolygon(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&intersects(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}function locallyInside(t,e){return area(t.prev,t,t.next)<0?area(t,e,t.next)>=0&&area(t,t.prev,e)>=0:area(t,e,t.prev)<0||area(t,t.next,e)<0}function middleInside(t,e){var i=t,o=!1,r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(o=!o),i=i.next}while(i!==t);return o}function splitPolygon(t,e){var i=new Node$1(t.i,t.x,t.y),o=new Node$1(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,o.next=i,i.prev=o,n.next=o,o.prev=n,o}function insertNode(t,e,i,o){var r=new Node$1(t,e,i);return o?(r.next=o.next,r.prev=o,o.next.prev=r,o.next=r):(r.prev=r,r.next=r),r}function removeNode(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Node$1(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(t,e,i,o){for(var r=0,n=e,s=i-o;n<i;n+=o)r+=(t[s]-t[n])*(t[n+1]+t[s+1]),s=n;return r}earcut$1.exports=earcut,earcut$1.exports.default=earcut,earcut.deviation=function(t,e,i,o){var r=e&&e.length,n=r?e[0]*i:t.length,s=Math.abs(signedArea(t,0,n,i));if(r)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,c=a<l-1?e[a+1]*i:t.length;s-=Math.abs(signedArea(t,h,c,i))}var u=0;for(a=0;a<o.length;a+=3){var p=o[a]*i,d=o[a+1]*i,f=o[a+2]*i;u+=Math.abs((t[p]-t[f])*(t[d+1]-t[p+1])-(t[p]-t[d])*(t[f+1]-t[p+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},earcut.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},o=0,r=0;r<t.length;r++){for(var n=0;n<t[r].length;n++)for(var s=0;s<e;s++)i.vertices.push(t[r][n][s]);r>0&&(o+=t[r-1].length,i.holes.push(o))}return i};var Polygon=function(t,e,i){this.pos=pool$1.pull("Vector2d"),this._bounds,this.points=[],this.edges=[],this.indices=[],this.normals=[],this.shapeType="Polygon",this.setShape(t,e,i)};Polygon.prototype.onResetEvent=function(t,e,i){this.setShape(t,e,i)},Polygon.prototype.setShape=function(t,e,i){return this.pos.set(t,e),this.setVertices(i),this},Polygon.prototype.setVertices=function(t){var e=this;if(!Array.isArray(t))return this;if(t[0]instanceof Vector2d)this.points=t;else if(this.points.length=0,"object"==typeof t[0])t.forEach((function(t){e.points.push(pool$1.pull("Vector2d",t.x,t.y))}));else for(var i=0;i<t.length;i+=2)this.points.push(pool$1.pull("Vector2d",t[i],t[i+1]));return this.recalc(),this.updateBounds(),this},Polygon.prototype.transform=function(t){for(var e=this.points,i=e.length,o=0;o<i;o++)t.apply(e[o]);return this.recalc(),this.updateBounds(),this},Polygon.prototype.toIso=function(){return this.rotate(Math.PI/4).scale(Math.SQRT2,Math.SQRT1_2)},Polygon.prototype.to2d=function(){return this.scale(Math.SQRT1_2,Math.SQRT2).rotate(-Math.PI/4)},Polygon.prototype.rotate=function(t,e){if(0!==t){for(var i=this.points,o=i.length,r=0;r<o;r++)i[r].rotate(t,e);this.recalc(),this.updateBounds()}return this},Polygon.prototype.scale=function(t,e){e=void 0!==e?e:t;for(var i=this.points,o=i.length,r=0;r<o;r++)i[r].scale(t,e);return this.recalc(),this.updateBounds(),this},Polygon.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Polygon.prototype.recalc=function(){var t,e=this.edges,i=this.normals,o=this.indices,r=this.points,n=r.length;if(n<3)throw new Error("Requires at least 3 points");for(t=0;t<n;t++)void 0===e[t]&&(e[t]=pool$1.pull("Vector2d")),e[t].copy(r[(t+1)%n]).sub(r[t]),void 0===i[t]&&(i[t]=pool$1.pull("Vector2d")),i[t].copy(e[t]).perp().normalize();return e.length=n,i.length=n,o.length=0,this},Polygon.prototype.getIndices=function(){return 0===this.indices.length&&(this.indices=earcut$1.exports(this.points.flatMap((function(t){return[t.x,t.y]})))),this.indices},Polygon.prototype.isConvex=function(){var t,e,i,o,r=0,n=this.points,s=n.length;if(s<3)return null;for(t=0;t<s;t++)if(i=(t+2)%s,o=(n[e=(t+1)%s].x-n[t].x)*(n[i].y-n[e].y),(o-=(n[e].y-n[t].y)*(n[i].x-n[e].x))<0?r|=1:o>0&&(r|=2),3===r)return!1;return 0!==r||null},Polygon.prototype.translate=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x+=t,this.pos.y+=e,this.getBounds().translate(t,e),this},Polygon.prototype.shift=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x=t,this.pos.y=e,this.updateBounds()},Polygon.prototype.contains=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y);for(var i=!1,o=this.pos.x,r=this.pos.y,n=this.points,s=n.length,a=0,l=s-1;a<s;l=a++){var h=n[a].y+r,c=n[a].x+o,u=n[l].y+r,p=n[l].x+o;h>e!=u>e&&t<(p-c)*(e-h)/(u-h)+c&&(i=!i)}return i},Polygon.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=pool$1.pull("Bounds")),this._bounds},Polygon.prototype.updateBounds=function(){var t=this.getBounds();return t.update(this.points),t.translate(this.pos),t},Polygon.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new Polygon(this.pos.x,this.pos.y,t)};var Rect=function(t){function e(e,i,o,r){t.call(this,e,i,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",o,0),pool$1.pull("Vector2d",o,r),pool$1.pull("Vector2d",0,r)]),this.shapeType="Rectangle"}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={left:{configurable:!0},right:{configurable:!0},top:{configurable:!0},bottom:{configurable:!0},width:{configurable:!0},height:{configurable:!0},centerX:{configurable:!0},centerY:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},e.prototype.setShape=function(t,e,i,o){var r=i;return this.pos.set(t,e),4===arguments.length&&((r=this.points)[0].set(0,0),r[1].set(i,0),r[2].set(i,o),r[3].set(0,o)),this.setVertices(r),this},i.left.get=function(){return this.pos.x},i.right.get=function(){var t=this.width;return this.pos.x+t||t},i.top.get=function(){return this.pos.y},i.bottom.get=function(){var t=this.height;return this.pos.y+t||t},i.width.get=function(){return this.points[2].x},i.width.set=function(t){this.points[1].x=this.points[2].x=t,this.recalc(),this.updateBounds()},i.height.get=function(){return this.points[2].y},i.height.set=function(t){this.points[2].y=this.points[3].y=t,this.recalc(),this.updateBounds()},i.centerX.get=function(){return isFinite(this.width)?this.pos.x+this.width/2:this.width},i.centerX.set=function(t){this.pos.x=t-this.width/2},i.centerY.get=function(){return isFinite(this.height)?this.pos.y+this.height/2:this.height},i.centerY.set=function(t){this.pos.y=t-this.height/2},e.prototype.centerOn=function(t,e){return this.centerX=t,this.centerY=e,this},e.prototype.resize=function(t,e){return this.width=t,this.height=e,this},e.prototype.scale=function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},e.prototype.clone=function(){return new e(this.pos.x,this.pos.y,this.width,this.height)},e.prototype.copy=function(t){return this.setShape(t.pos.x,t.pos.y,t.width,t.height)},e.prototype.union=function(t){var e=Math.min(this.left,t.left),i=Math.min(this.top,t.top);return this.resize(Math.max(this.right,t.right)-e,Math.max(this.bottom,t.bottom)-i),this.pos.set(e,i),this},e.prototype.overlaps=function(t){return this.left<t.right&&t.left<this.right&&this.top<t.bottom&&t.top<this.bottom},e.prototype.contains=function(){var t,i,o,r,n=arguments[0];return 2===arguments.length?(t=i=n,o=r=arguments[1]):n instanceof e?(t=n.left,i=n.right,o=n.top,r=n.bottom):(t=i=n.x,o=r=n.y),t>=this.left&&i<=this.right&&o>=this.top&&r<=this.bottom},e.prototype.equals=function(t){return t.left===this.left&&t.right===this.right&&t.top===this.top&&t.bottom===this.bottom},e.prototype.isFinite=function(){return isFinite(this.pos.x)&&isFinite(this.pos.y)&&isFinite(this.width)&&isFinite(this.height)},e.prototype.toPolygon=function(){return pool$1.pull("Polygon",this.pos.x,this.pos.y,this.points)},Object.defineProperties(e.prototype,i),e}(Polygon),_keyStatus={},_keyLock={},_keyLocked={},_keyRefs={},_preventDefaultForKeys={},_keyBindings={},keyDownEvent=function(t,e,i){e=e||t.keyCode||t.button;var o=_keyBindings[e];if(emit(KEYDOWN,o,e,!o||!_keyLocked[o]),o){if(!_keyLocked[o]){var r=void 0!==i?i:e;_keyRefs[o][r]||(_keyStatus[o]++,_keyRefs[o][r]=!0)}return!_preventDefaultForKeys[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},keyUpEvent=function(t,e,i){e=e||t.keyCode||t.button;var o=_keyBindings[e];if(emit(KEYUP,o,e),o){var r=void 0!==i?i:e;return _keyRefs[o][r]=void 0,_keyStatus[o]>0&&_keyStatus[o]--,_keyLocked[o]=!1,!_preventDefaultForKeys[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},keyBoardEventTarget=null,KEY={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,NUM0:48,NUM1:49,NUM2:50,NUM3:51,NUM4:52,NUM5:53,NUM6:54,NUM7:55,NUM8:56,NUM9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,WINDOW_KEY:91,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBSTRACT:109,DECIMAL:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,TILDE:126,NUM_LOCK:144,SCROLL_LOCK:145,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWAND_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,SINGLE_QUOTE:222};function initKeyboardEvent(){null===keyBoardEventTarget&&!1===device$1.isMobile&&"function"==typeof(keyBoardEventTarget=globalThis).addEventListener&&(keyBoardEventTarget.addEventListener("keydown",keyDownEvent,!1),keyBoardEventTarget.addEventListener("keyup",keyUpEvent,!1))}function isKeyPressed(t){return!(!_keyStatus[t]||_keyLocked[t])&&(_keyLock[t]&&(_keyLocked[t]=!0),!0)}function keyStatus(t){return _keyStatus[t]>0}function triggerKeyEvent(t,e,i){!0===e?keyDownEvent({},t,i):keyUpEvent({},t,i)}function bindKey(t,e,i,o){void 0===o&&(o=preventDefault),_keyBindings[t]=e,_preventDefaultForKeys[t]=o,_keyStatus[e]=0,_keyLock[e]=i||!1,_keyLocked[e]=!1,_keyRefs[e]={}}function getBindingKey(t){return _keyBindings[t]}function unlockKey(t){_keyLocked[t]=!1}function unbindKey(t){var e=_keyBindings[t];_keyStatus[e]=0,_keyLock[e]=!1,_keyRefs[e]={},_keyBindings[t]=null,_preventDefaultForKeys[t]=null}var Bounds$1=function(t){this._center=new Vector2d,this.onResetEvent(t)},prototypeAccessors$1={x:{configurable:!0},y:{configurable:!0},width:{configurable:!0},height:{configurable:!0},left:{configurable:!0},right:{configurable:!0},top:{configurable:!0},bottom:{configurable:!0},centerX:{configurable:!0},centerY:{configurable:!0},center:{configurable:!0}};Bounds$1.prototype.onResetEvent=function(t){void 0===this.min?(this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0}):this.clear(),void 0!==t&&this.update(t)},Bounds$1.prototype.clear=function(){this.setMinMax(1/0,1/0,-1/0,-1/0)},Bounds$1.prototype.setMinMax=function(t,e,i,o){this.min.x=t,this.min.y=e,this.max.x=i,this.max.y=o},prototypeAccessors$1.x.get=function(){return this.min.x},prototypeAccessors$1.x.set=function(t){var e=this.max.x-this.min.x;this.min.x=t,this.max.x=t+e},prototypeAccessors$1.y.get=function(){return this.min.y},prototypeAccessors$1.y.set=function(t){var e=this.max.y-this.min.y;this.min.y=t,this.max.y=t+e},prototypeAccessors$1.width.get=function(){return this.max.x-this.min.x},prototypeAccessors$1.width.set=function(t){this.max.x=this.min.x+t},prototypeAccessors$1.height.get=function(){return this.max.y-this.min.y},prototypeAccessors$1.height.set=function(t){this.max.y=this.min.y+t},prototypeAccessors$1.left.get=function(){return this.min.x},prototypeAccessors$1.right.get=function(){return this.max.x},prototypeAccessors$1.top.get=function(){return this.min.y},prototypeAccessors$1.bottom.get=function(){return this.max.y},prototypeAccessors$1.centerX.get=function(){return this.min.x+this.width/2},prototypeAccessors$1.centerY.get=function(){return this.min.y+this.height/2},prototypeAccessors$1.center.get=function(){return this._center.set(this.centerX,this.centerY)},Bounds$1.prototype.update=function(t){this.add(t,!0)},Bounds$1.prototype.add=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear();for(var i=0;i<t.length;i++){var o=t[i];o.x>this.max.x&&(this.max.x=o.x),o.x<this.min.x&&(this.min.x=o.x),o.y>this.max.y&&(this.max.y=o.y),o.y<this.min.y&&(this.min.y=o.y)}},Bounds$1.prototype.addBounds=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear(),t.max.x>this.max.x&&(this.max.x=t.max.x),t.min.x<this.min.x&&(this.min.x=t.min.x),t.max.y>this.max.y&&(this.max.y=t.max.y),t.min.y<this.min.y&&(this.min.y=t.min.y)},Bounds$1.prototype.addPoint=function(t,e){void 0!==e&&(t=e.apply(t)),this.min.x=Math.min(this.min.x,t.x),this.max.x=Math.max(this.max.x,t.x),this.min.y=Math.min(this.min.y,t.y),this.max.y=Math.max(this.max.y,t.y)},Bounds$1.prototype.addFrame=function(t,e,i,o,r){var n=me.pool.pull("Vector2d");this.addPoint(n.set(t,e),r),this.addPoint(n.set(i,e),r),this.addPoint(n.set(t,o),r),this.addPoint(n.set(i,o),r),me.pool.push(n)},Bounds$1.prototype.contains=function(){var t,e,i,o,r=arguments[0];return 2===arguments.length?(t=e=r,i=o=arguments[1]):r instanceof Bounds$1?(t=r.min.x,e=r.max.x,i=r.min.y,o=r.max.y):(t=e=r.x,i=o=r.y),t>=this.min.x&&e<=this.max.x&&i>=this.min.y&&o<=this.max.y},Bounds$1.prototype.overlaps=function(t){return!(this.right<t.left||this.left>t.right||this.bottom<t.top||this.top>t.bottom)},Bounds$1.prototype.isFinite=function(){return isFinite(this.min.x)&&isFinite(this.max.x)&&isFinite(this.min.y)&&isFinite(this.max.y)},Bounds$1.prototype.translate=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.min.x+=t,this.max.x+=t,this.min.y+=e,this.max.y+=e},Bounds$1.prototype.shift=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y);var i=this.max.x-this.min.x,o=this.max.y-this.min.y;this.min.x=t,this.max.x=t+i,this.min.y=e,this.max.y=e+o},Bounds$1.prototype.clone=function(){var t=new Bounds$1;return t.addBounds(this),t},Bounds$1.prototype.toPolygon=function(){return pool$1.pull("Polygon",this.x,this.y,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height),pool$1.pull("Vector2d",0,this.height)])},Object.defineProperties(Bounds$1.prototype,prototypeAccessors$1);var tmpVec=new Vector2d,Pointer=function(t){function e(e,i,o,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),void 0===r&&(r=1),t.call(this),this.setMinMax(e,i,e+o,i+r),this.LEFT=0,this.MIDDLE=1,this.RIGHT=2,this.event=void 0,this.type=void 0,this.button=0,this.isPrimary=!1,this.pageX=0,this.pageY=0,this.clientX=0,this.clientY=0,this.movementX=0,this.movementY=0,this.deltaMode=0,this.deltaX=0,this.deltaY=0,this.deltaZ=0,this.gameX=0,this.gameY=0,this.gameScreenX=0,this.gameScreenY=0,this.gameWorldX=0,this.gameWorldY=0,this.gameLocalX=0,this.gameLocalY=0,this.pointerId=void 0,this.isNormalized=!1,this.locked=!1,this.bind=[0,0,0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setEvent=function(t,e,i,o,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===n&&(n=1),this.event=t,this.pageX=e,this.pageY=i,this.clientX=o,this.clientY=r,globalToLocal(this.pageX,this.pageY,tmpVec),this.gameScreenX=this.x=tmpVec.x,this.gameScreenY=this.y=tmpVec.y,this.isNormalized=!device$1.PointerEvent||device$1.PointerEvent&&!(t instanceof globalThis.PointerEvent),this.locked=locked,this.movementX=t.movementX||0,this.movementY=t.movementY||0,"wheel"===t.type?(this.deltaMode=t.deltaMode||0,this.deltaX=t.deltaX||0,this.deltaY=t.deltaY||0,this.deltaZ=t.deltaZ||0):(this.deltaMode=0,this.deltaX=0,this.deltaY=0,this.deltaZ=0),this.pointerId=n,this.isPrimary=void 0===t.isPrimary||t.isPrimary,this.button=t.button||0,this.type=t.type,void 0!==viewport&&viewport.localToWorld(this.gameScreenX,this.gameScreenY,tmpVec),this.gameWorldX=tmpVec.x,this.gameWorldY=tmpVec.y,!1===this.isNormalized?(this.width=t.width||1,this.height=t.height||1):"number"==typeof t.radiusX?(this.width=2*t.radiusX||1,this.height=2*t.radiusY||1):this.width=this.height=1},e}(Bounds$1),T_POINTERS=[],eventHandlers=new Map,currentPointer,pointerInitialized=!1,lastTimeStamp=0,activeEventList=[],WHEEL=["wheel"],POINTER_MOVE=["pointermove","mousemove","touchmove"],POINTER_DOWN=["pointerdown","mousedown","touchstart"],POINTER_UP=["pointerup","mouseup","touchend"],POINTER_CANCEL=["pointercancel","mousecancel","touchcancel"],POINTER_ENTER=["pointerenter","mouseenter","touchenter"],POINTER_OVER=["pointerover","mouseover","touchover"],POINTER_LEAVE=["pointerleave","mouseleave","touchleave"],pointerEventList=[WHEEL[0],POINTER_MOVE[0],POINTER_DOWN[0],POINTER_UP[0],POINTER_CANCEL[0],POINTER_ENTER[0],POINTER_OVER[0],POINTER_LEAVE[0]],mouseEventList=[WHEEL[0],POINTER_MOVE[1],POINTER_DOWN[1],POINTER_UP[1],POINTER_CANCEL[1],POINTER_ENTER[1],POINTER_OVER[1],POINTER_LEAVE[1]],touchEventList=[POINTER_MOVE[2],POINTER_DOWN[2],POINTER_UP[2],POINTER_CANCEL[2],POINTER_ENTER[2],POINTER_OVER[2],POINTER_LEAVE[2]],pointerEventMap={wheel:WHEEL,pointermove:POINTER_MOVE,pointerdown:POINTER_DOWN,pointerup:POINTER_UP,pointercancel:POINTER_CANCEL,pointerenter:POINTER_ENTER,pointerover:POINTER_OVER,pointerleave:POINTER_LEAVE},normalizedEvents=[];function registerEventListener(t,e){for(var i=0;i<t.length;i++)-1===POINTER_MOVE.indexOf(t[i])&&pointerEventTarget.addEventListener(t[i],e,{passive:!1===preventDefault})}function enablePointerEvent(){if(!pointerInitialized){currentPointer=new Rect(0,0,1,1);for(var t=0;t<device$1.maxTouchPoints;t++)T_POINTERS.push(new Pointer);var e;null===pointerEventTarget&&(pointerEventTarget=renderer.getScreenCanvas()),activeEventList=device$1.PointerEvent?pointerEventList:mouseEventList,device$1.touch&&!device$1.PointerEvent&&(activeEventList=activeEventList.concat(touchEventList)),registerEventListener(activeEventList,onPointerEvent),void 0===throttlingInterval&&(throttlingInterval=~~(1e3/timer$1.maxfps)),!0===device$1.autoFocus&&(device$1.focus(),pointerEventTarget.addEventListener(activeEventList[2],(function(){device$1.focus()}),{passive:!1===preventDefault}));var i=findAllActiveEvents(activeEventList,POINTER_MOVE);if(throttlingInterval<17)for(e=0;e<i.length;e++)-1!==activeEventList.indexOf(i[e])&&pointerEventTarget.addEventListener(i[e],onMoveEvent,{passive:!0});else for(e=0;e<i.length;e++)-1!==activeEventList.indexOf(i[e])&&pointerEventTarget.addEventListener(i[e],throttle(onMoveEvent,throttlingInterval,!1),{passive:!0});setTouchAction(pointerEventTarget),device$1.hasPointerLockSupport&&document.addEventListener("pointerlockchange",(function(){locked=document.pointerLockElement===getParent(),emit(POINTERLOCKCHANGE,locked)}),!0),pointerInitialized=!0}}function findActiveEvent(t,e){for(var i=0;i<e.length;i++){if(-1!==t.indexOf(e[i]))return e[i]}}function findAllActiveEvents(t,e){for(var i=[],o=0;o<e.length;o++){-1!==t.indexOf(e[o])&&i.push(e[o])}return i}function triggerEvent(t,e,i,o){var r;if(t.callbacks[e]){t.pointerId=o;for(var n=t.callbacks[e].length-1;n>=0&&(r=t.callbacks[e][n]);n--)if(!1===r(i))return!0}return!1}function dispatchEvent(t){for(var e=!1;t.length>0;){var i=t.pop();if(T_POINTERS.push(i),void 0!==i.event.timeStamp){if(i.event.timeStamp<lastTimeStamp)continue;lastTimeStamp=i.event.timeStamp}currentPointer.setShape(i.gameWorldX,i.gameWorldY,i.width,i.height),POINTER_MOVE.includes(i.type)&&(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY,emit(POINTERMOVE,i));for(var o,r=world.broadphase.retrieve(currentPointer,Container.prototype._sortReverseZ),n=(r=r.concat([viewport])).length;o=r[--n];){if(eventHandlers.has(o)&&!0!==o.isKinematic){var s,a=eventHandlers.get(o),l=a.region,h=l.ancestor,c=l.getBounds();if(!0===l.isFloating?(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY):(i.gameX=i.gameLocalX=i.gameWorldX,i.gameY=i.gameLocalY=i.gameWorldY),void 0!==h){var u=h.getBounds();i.gameLocalX=i.gameX-u.x,i.gameLocalY=i.gameY-u.y}var p=i.gameX,d=i.gameY;if(void 0!==l.currentTransform&&!l.currentTransform.isIdentity()){var f=l.currentTransform.applyInverse(pool$1.pull("Vector2d",p,d));p=f.x,d=f.y,pool$1.push(f)}switch(s=c.contains(p,d),i.type){case POINTER_MOVE[0]:case POINTER_MOVE[1]:case POINTER_MOVE[2]:case POINTER_MOVE[3]:if(a.pointerId!==i.pointerId||s){if(null===a.pointerId&&s&&triggerEvent(a,findActiveEvent(activeEventList,POINTER_ENTER),i,i.pointerId)){e=!0;break}}else if(triggerEvent(a,findActiveEvent(activeEventList,POINTER_LEAVE),i,null)){e=!0;break}if(s&&triggerEvent(a,i.type,i,i.pointerId)){e=!0;break}break;case POINTER_UP[0]:case POINTER_UP[1]:case POINTER_UP[2]:case POINTER_UP[3]:if(a.pointerId===i.pointerId&&s&&triggerEvent(a,i.type,i,null)){e=!0;break}break;case POINTER_CANCEL[0]:case POINTER_CANCEL[1]:case POINTER_CANCEL[2]:case POINTER_CANCEL[3]:if(a.pointerId===i.pointerId&&triggerEvent(a,i.type,i,null)){e=!0;break}break;default:if(s&&triggerEvent(a,i.type,i,i.pointerId)){e=!0;break}}}if(!0===e)break}}return e}function normalizeEvent(t){var e;if(device$1.TouchEvent&&t.changedTouches)for(var i=0,o=t.changedTouches.length;i<o;i++){var r=t.changedTouches[i];(e=T_POINTERS.pop()).setEvent(t,r.pageX,r.pageY,r.clientX,r.clientY,r.identifier),normalizedEvents.push(e)}else(e=T_POINTERS.pop()).setEvent(t,t.pageX,t.pageY,t.clientX,t.clientY,t.pointerId),normalizedEvents.push(e);return!1===t.isPrimary||(normalizedEvents[0].isPrimary=!0,Object.assign(pointer,normalizedEvents[0])),normalizedEvents}function onMoveEvent(t){dispatchEvent(normalizeEvent(t))}function onPointerEvent(t){normalizeEvent(t);var e=normalizedEvents[0].button;(dispatchEvent(normalizedEvents)||"wheel"===t.type)&&t.preventDefault();var i=pointer.bind[e];i&&triggerKeyEvent(i,POINTER_DOWN.includes(t.type),e+1)}var pointerEventTarget=null,pointer=new Pointer(0,0,1,1),locked=!1,throttlingInterval;function globalToLocal(t,e,i){i=i||pool$1.pull("Vector2d");var o=device$1.getElementBounds(renderer.getScreenCanvas()),r=device$1.devicePixelRatio;t-=o.left+(globalThis.pageXOffset||0),e-=o.top+(globalThis.pageYOffset||0);var n=scaleRatio;return 1===n.x&&1===n.y||(t/=n.x,e/=n.y),i.set(t*r,e*r)}function setTouchAction(t,e){t.style["touch-action"]=e||"none"}function bindPointer(){var t=arguments.length<2?pointer.LEFT:arguments[0],e=arguments.length<2?arguments[0]:arguments[1];if(enablePointerEvent(),!getBindingKey(e))throw new Error("no action defined for keycode "+e);pointer.bind[t]=e}function unbindPointer(t){pointer.bind[void 0===t?pointer.LEFT:t]=null}function registerPointerEvent(t,e,i){if(enablePointerEvent(),-1===pointerEventList.indexOf(t))throw new Error("invalid event type : "+t);if(void 0===e)throw new Error("registerPointerEvent: region for "+toString(e)+" event is undefined ");var o=findAllActiveEvents(activeEventList,pointerEventMap[t]);eventHandlers.has(e)||eventHandlers.set(e,{region:e,callbacks:{},pointerId:null});for(var r=eventHandlers.get(e),n=0;n<o.length;n++)t=o[n],r.callbacks[t]?r.callbacks[t].push(i):r.callbacks[t]=[i]}function releasePointerEvent(t,e,i){if(-1===pointerEventList.indexOf(t))throw new Error("invalid event type : "+t);var o=findAllActiveEvents(activeEventList,pointerEventMap[t]),r=eventHandlers.get(e);if(void 0!==r){for(var n=0;n<o.length;n++)if(t=o[n],r.callbacks[t]){if(void 0!==i)remove(r.callbacks[t],i);else for(;r.callbacks[t].length>0;)r.callbacks[t].pop();0===r.callbacks[t].length&&delete r.callbacks[t]}0===Object.keys(r.callbacks).length&&eventHandlers.delete(e)}}function releaseAllPointerEvents(t){if(eventHandlers.has(t))for(var e=0;e<pointerEventList.length;e++)releasePointerEvent(pointerEventList[e],t)}function requestPointerLock(){return!!device$1.hasPointerLockSupport&&(getParent().requestPointerLock(),!0)}function exitPointerLock(){return!!device$1.hasPointerLockSupport&&(document.exitPointerLock(),!0)}var deadzone=.1;function wiredXbox360NormalizeFn(t,e,i){return i===this.GAMEPAD.BUTTONS.L2||i===this.GAMEPAD.BUTTONS.R2?(t+1)/2:t}function ouyaNormalizeFn(t,e,i){return t=t>0?i===this.GAMEPAD.BUTTONS.L2?Math.max(0,t-2e4)/111070:(t-1)/131070:(65536+t)/131070+.5}var vendorProductRE=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,leadingZeroRE=/^0+/;function addMapping(t,e){var i=t.replace(vendorProductRE,(function(t,e,i){return"000".slice(e.length-1)+e+"-"+"000".slice(i.length-1)+i+"-"})),o=t.replace(vendorProductRE,(function(t,e,i){return e.replace(leadingZeroRE,"")+"-"+i.replace(leadingZeroRE,"")+"-"}));e.analog=e.analog||e.buttons.map((function(){return-1})),e.normalize_fn=e.normalize_fn||function(t){return t},remap.set(i,e),remap.set(o,e)}var bindings={},remap=new Map,updateEventHandler;[["45e-28e-Xbox 360 Wired Controller",{axes:[0,1,3,4],buttons:[11,12,13,14,8,9,-1,-1,5,4,6,7,0,1,2,3,10],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:wiredXbox360NormalizeFn}],["54c-268-PLAYSTATION(R)3 Controller",{axes:[0,1,2,3],buttons:[14,13,15,12,10,11,8,9,0,3,1,2,4,6,7,5,16]}],["54c-5c4-Wireless Controller",{axes:[0,1,2,3],buttons:[1,0,2,3,4,5,6,7,8,9,10,11,14,15,16,17,12,13]}],["2836-1-OUYA Game Controller",{axes:[0,3,7,9],buttons:[3,6,4,5,7,8,15,16,-1,-1,9,10,11,12,13,14,-1],analog:[-1,-1,-1,-1,-1,-1,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:ouyaNormalizeFn}],["OUYA Game Controller (Vendor: 2836 Product: 0001)",{axes:[0,1,3,4],buttons:[0,3,1,2,4,5,12,13,-1,-1,6,7,8,9,10,11,-1],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:ouyaNormalizeFn}]].forEach((function(t){addMapping(t[0],t[1])}));var updateGamepads=function(){var t=navigator.getGamepads();Object.keys(bindings).forEach((function(e){var i=t[e];if(i){var o=null;"standard"!==i.mapping&&(o=remap.get(i.id));var r=bindings[e];Object.keys(r.buttons).forEach((function(t){var n=r.buttons[t],s=t,a=-1;if(!(o&&(s=o.buttons[t],a=o.analog[t],s<0&&a<0))){var l=i.buttons[s]||{};if(o&&a>=0){var h=o.normalize_fn(i.axes[a],-1,+t);l={value:h,pressed:l.pressed||Math.abs(h)>=deadzone}}emit(GAMEPAD_UPDATE,e,"buttons",+t,l),!n.pressed&&l.pressed?triggerKeyEvent(n.keyCode,!0,s+256):n.pressed&&!l.pressed&&triggerKeyEvent(n.keyCode,!1,s+256),n.value=l.value,n.pressed=l.pressed}})),Object.keys(r.axes).forEach((function(t){var n=r.axes[t],s=t;if(!(o&&(s=o.axes[t])<0)){var a=i.axes[s];if(void 0!==a){o&&(a=o.normalize_fn(a,+t,-1));var l=Math.sign(a)||1;if(0!==n[l].keyCode){var h=Math.abs(a)>=deadzone+Math.abs(n[l].threshold);emit(GAMEPAD_UPDATE,e,"axes",+t,a),!n[l].pressed&&h?(n[-l].pressed&&(triggerKeyEvent(n[-l].keyCode,!1,s+256),n[-l].value=0,n[-l].pressed=!1),triggerKeyEvent(n[l].keyCode,!0,s+256)):!n[l].pressed&&!n[-l].pressed||h||triggerKeyEvent(n[l=n[l].pressed?l:-l].keyCode,!1,s+256),n[l].value=a,n[l].pressed=h}}}}))}}))};globalThis.navigator&&"function"==typeof globalThis.navigator.getGamepads&&(globalThis.addEventListener("gamepadconnected",(function(t){emit(GAMEPAD_CONNECTED,t.gamepad)}),!1),globalThis.addEventListener("gamepaddisconnected",(function(t){emit(GAMEPAD_DISCONNECTED,t.gamepad)}),!1));var GAMEPAD={AXES:{LX:0,LY:1,RX:2,RY:3,EXTRA_1:4,EXTRA_2:5,EXTRA_3:6,EXTRA_4:7},BUTTONS:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L1:4,R1:5,L2:6,R2:7,SELECT:8,BACK:8,START:9,FORWARD:9,L3:10,R3:11,UP:12,DOWN:13,LEFT:14,RIGHT:15,HOME:16,EXTRA_1:17,EXTRA_2:18,EXTRA_3:19,EXTRA_4:20}};function bindGamepad(t,e,i){if(!getBindingKey(i))throw new Error("no action defined for keycode "+i);void 0===updateEventHandler&&"function"==typeof navigator.getGamepads&&(updateEventHandler=on(GAME_BEFORE_UPDATE,updateGamepads)),bindings[t]||(bindings[t]={axes:{},buttons:{}});var o={keyCode:i,value:0,pressed:!1,threshold:e.threshold},r=bindings[t][e.type];if("buttons"===e.type)r[e.code]=o;else if("axes"===e.type){var n=Math.sign(e.threshold)||1;r[e.code]||(r[e.code]={});var s=r[e.code];s[n]=o,s[-n]||(s[-n]={keyCode:0,value:0,pressed:!1,threshold:-n})}}function unbindGamepad(t,e){if(!bindings[t])throw new Error("no bindings for gamepad "+t);bindings[t].buttons[e]={}}function setGamepadDeadzone(t){deadzone=t}var setGamepadMapping=addMapping,preventDefault=!0,input=Object.freeze({__proto__:null,preventDefault:preventDefault,get pointerEventTarget(){return pointerEventTarget},pointer:pointer,get locked(){return locked},get throttlingInterval(){return throttlingInterval},globalToLocal:globalToLocal,setTouchAction:setTouchAction,bindPointer:bindPointer,unbindPointer:unbindPointer,registerPointerEvent:registerPointerEvent,releasePointerEvent:releasePointerEvent,releaseAllPointerEvents:releaseAllPointerEvents,requestPointerLock:requestPointerLock,exitPointerLock:exitPointerLock,get keyBoardEventTarget(){return keyBoardEventTarget},KEY:KEY,initKeyboardEvent:initKeyboardEvent,isKeyPressed:isKeyPressed,keyStatus:keyStatus,triggerKeyEvent:triggerKeyEvent,bindKey:bindKey,getBindingKey:getBindingKey,unlockKey:unlockKey,unbindKey:unbindKey,GAMEPAD:GAMEPAD,bindGamepad:bindGamepad,unbindGamepad:unbindGamepad,setGamepadDeadzone:setGamepadDeadzone,setGamepadMapping:setGamepadMapping}),Renderable=function(t){function e(e,i,o,r){t.call(this,e,i,o,r),this.isRenderable=!0,this.isKinematic=!0,this.body=void 0,void 0===this.currentTransform&&(this.currentTransform=pool$1.pull("Matrix2d")),this.currentTransform.identity(),this.GUID=void 0,this.onVisibilityChange=void 0,this.alwaysUpdate=!1,this.updateWhenPaused=!1,this.isPersistent=!1,this.floating=!1,this.anchorPoint instanceof ObservableVector2d?this.anchorPoint.setMuted(.5,.5).setCallback(this.onAnchorUpdate,this):this.anchorPoint=pool$1.pull("ObservableVector2d",.5,.5,{onUpdate:this.onAnchorUpdate,scope:this}),this.autoTransform=!0,this.alpha=1,this.ancestor=void 0,this.mask=void 0,this.tint=pool$1.pull("Color",255,255,255,1),this.blendMode="normal",this.name="",this.pos instanceof ObservableVector3d?this.pos.setMuted(e,i,0).setCallback(this.updateBoundsPos,this):this.pos=pool$1.pull("ObservableVector3d",e,i,0,{onUpdate:this.updateBoundsPos,scope:this}),this.isDirty=!1,this._flip={x:!1,y:!1},this._inViewport=!1,this.setOpacity(1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isFloating:{configurable:!0},inViewport:{configurable:!0},isFlippedX:{configurable:!0},isFlippedY:{configurable:!0}};return i.isFloating.get=function(){return!0===this.floating||void 0!==this.ancestor&&!0===this.ancestor.floating},i.inViewport.get=function(){return this._inViewport},i.inViewport.set=function(t){this._inViewport!==t&&(this._inViewport=t,"function"==typeof this.onVisibilityChange&&this.onVisibilityChange.call(this,t))},i.isFlippedX.get=function(){return!0===this._flip.x},i.isFlippedY.get=function(){return!0===this._flip.y},e.prototype.getBounds=function(){return void 0===this._bounds&&(t.prototype.getBounds.call(this),this.isFinite()?this._bounds.setMinMax(this.pos.x,this.pos.y,this.pos.x+this.width,this.pos.y+this.height):this._bounds.setMinMax(this.pos.x,this.pos.y,this.width,this.height)),this._bounds},e.prototype.getOpacity=function(){return this.alpha},e.prototype.setOpacity=function(t){"number"==typeof t&&(this.alpha=clamp(t,0,1),isNaN(this.alpha)&&(this.alpha=1),this.isDirty=!0)},e.prototype.flipX=function(t){return void 0===t&&(t=!0),this._flip.x=!!t,this.isDirty=!0,this},e.prototype.flipY=function(t){return void 0===t&&(t=!0),this._flip.y=!!t,this.isDirty=!0,this},e.prototype.transform=function(t){return this.currentTransform.multiply(t),this.updateBoundsPos(this.pos.x,this.pos.y),this.isDirty=!0,this},e.prototype.angleTo=function(t){var i,o,r=this.getBounds();if(t instanceof e){var n=t.getBounds();i=n.centerX-r.centerX,o=n.centerY-r.centerY}else i=t.x-r.centerX,o=t.y-r.centerY;return Math.atan2(o,i)},e.prototype.distanceTo=function(t){var i,o,r=this.getBounds();if(t instanceof e){var n=t.getBounds();i=r.centerX-n.centerX,o=r.centerY-n.centerY}else i=r.centerX-t.x,o=r.centerY-t.y;return Math.sqrt(i*i+o*o)},e.prototype.lookAt=function(t){var i;i=t instanceof e?t.pos:t;var o=this.angleTo(i);return this.rotate(o),this},e.prototype.rotate=function(t,e){return isNaN(t)||(this.currentTransform.rotate(t,e),this.isDirty=!0),this},e.prototype.scale=function(e,i){return this.currentTransform.scale(e,i),t.prototype.scale.call(this,e,i),this.isDirty=!0,this},e.prototype.scaleV=function(t){return this.scale(t.x,t.y),this},e.prototype.update=function(t){return this.isDirty},e.prototype.updateBounds=function(){return t.prototype.updateBounds.call(this),this.updateBoundsPos(this.pos.x,this.pos.y),this.getBounds()},e.prototype.updateBoundsPos=function(t,e){var i=this.getBounds();i.shift(t,e),void 0!==this.anchorPoint&&i.isFinite()&&i.translate(-this.anchorPoint.x*i.width,-this.anchorPoint.y*i.height),this.ancestor instanceof Container&&!0!==this.floating&&i.translate(this.ancestor.getAbsolutePosition())},e.prototype.getAbsolutePosition=function(){return void 0===this._absPos&&(this._absPos=pool$1.pull("Vector2d")),this._absPos.set(this.pos.x,this.pos.y),this.ancestor instanceof Container&&!0!==this.floating&&this._absPos.add(this.ancestor.getAbsolutePosition()),this._absPos},e.prototype.onAnchorUpdate=function(t,e){this.anchorPoint.setMuted(t,e),this.updateBoundsPos(this.pos.x,this.pos.y)},e.prototype.preDraw=function(t){var e=this.getBounds(),i=e.width*this.anchorPoint.x,o=e.height*this.anchorPoint.y;if(t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity()),this._flip.x||this._flip.y){var r=this._flip.x?this.centerX-i:0,n=this._flip.y?this.centerY-o:0;t.translate(r,n),t.scale(this._flip.x?-1:1,this._flip.y?-1:1),t.translate(-r,-n)}void 0!==this.mask&&(t.translate(this.pos.x,this.pos.y),t.setMask(this.mask),t.translate(-this.pos.x,-this.pos.y)),!0!==this.autoTransform||this.currentTransform.isIdentity()||(t.translate(this.pos.x,this.pos.y),t.transform(this.currentTransform),t.translate(-this.pos.x,-this.pos.y)),t.translate(-i,-o),t.setTint(this.tint,this.getOpacity()),this.blendMode!==t.getBlendMode()&&t.setBlendMode(this.blendMode)},e.prototype.draw=function(t){},e.prototype.postDraw=function(t){t.clearTint(),void 0!==this.mask&&t.clearMask(),t.restore(),this.isDirty=!1},e.prototype.onCollision=function(){return!1},e.prototype.destroy=function(){pool$1.push(this.currentTransform),this.currentTransform=void 0,pool$1.push(this.anchorPoint),this.anchorPoint=void 0,pool$1.push(this.pos),this.pos=void 0,void 0!==this._absPos&&(pool$1.push(this._absPos),this._absPos=void 0),pool$1.push(this._bounds),this._bounds=void 0,this.onVisibilityChange=void 0,void 0!==this.mask&&(pool$1.push(this.mask),this.mask=void 0),void 0!==this.tint&&(pool$1.push(this.tint),this.tint=void 0),this.ancestor=void 0,void 0!==this.body&&(this.body.destroy.apply(this.body,arguments),this.body=void 0),releaseAllPointerEvents(this),this.onDestroyEvent.apply(this,arguments)},e.prototype.onDestroyEvent=function(){},Object.defineProperties(e.prototype,i),e}(Rect),Ellipse=function(t,e,i,o){this.pos=pool$1.pull("Vector2d"),this._bounds=void 0,this.radius=NaN,this.radiusV=pool$1.pull("Vector2d"),this.radiusSq=pool$1.pull("Vector2d"),this.ratio=pool$1.pull("Vector2d"),this.shapeType="Ellipse",this.setShape(t,e,i,o)};Ellipse.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},Ellipse.prototype.setShape=function(t,e,i,o){var r=i/2,n=o/2;this.pos.set(t,e),this.radius=Math.max(r,n),this.ratio.set(r/this.radius,n/this.radius),this.radiusV.set(this.radius,this.radius).scaleV(this.ratio);var s=this.radius*this.radius;return this.radiusSq.set(s,s).scaleV(this.ratio),this.getBounds().setMinMax(t,e,t+i,t+o),this.getBounds().translate(-this.radiusV.x,-this.radiusV.y),this},Ellipse.prototype.rotate=function(t,e){return this.pos.rotate(t,e),this.getBounds().shift(this.pos),this.getBounds().translate(-this.radiusV.x,-this.radiusV.y),this},Ellipse.prototype.scale=function(t,e){return e=void 0!==e?e:t,this.setShape(this.pos.x,this.pos.y,2*this.radiusV.x*t,2*this.radiusV.y*e)},Ellipse.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Ellipse.prototype.transform=function(){return this},Ellipse.prototype.translate=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x+=t,this.pos.y+=e,this.getBounds().translate(t,e),this},Ellipse.prototype.contains=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),t-=this.pos.x,e-=this.pos.y,t*t/this.radiusSq.x+e*e/this.radiusSq.y<=1},Ellipse.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=pool$1.pull("Bounds")),this._bounds},Ellipse.prototype.clone=function(){return new Ellipse(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)};for(var LEFT_VORNOI_REGION=-1,MIDDLE_VORNOI_REGION=0,RIGHT_VORNOI_REGION=1,T_VECTORS=[],v=0;v<10;v++)T_VECTORS.push(new Vector2d);for(var T_ARRAYS=[],a=0;a<5;a++)T_ARRAYS.push([]);function flattenPointsOn(t,e,i){for(var o=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=t.length,s=0;s<n;s++){var a=t[s].dot(e);a<o&&(o=a),a>r&&(r=a)}i[0]=o,i[1]=r}function isSeparatingAxis(t,e,i,o,r,n){var s=T_ARRAYS.pop(),a=T_ARRAYS.pop(),l=T_VECTORS.pop().copy(e).sub(t),h=l.dot(r);if(flattenPointsOn(i,r,s),flattenPointsOn(o,r,a),a[0]+=h,a[1]+=h,s[0]>a[1]||a[0]>s[1])return T_VECTORS.push(l),T_ARRAYS.push(s),T_ARRAYS.push(a),!0;if(n){var c=0;if(s[0]<a[0])if(n.aInB=!1,s[1]<a[1])c=s[1]-a[0],n.bInA=!1;else{var u=s[1]-a[0],p=a[1]-s[0];c=u<p?u:-p}else if(n.bInA=!1,s[1]>a[1])c=s[0]-a[1],n.aInB=!1;else{var d=s[1]-a[0],f=a[1]-s[0];c=d<f?d:-f}var y=Math.abs(c);y<n.overlap&&(n.overlap=y,n.overlapN.copy(r),c<0&&n.overlapN.negateSelf())}return T_VECTORS.push(l),T_ARRAYS.push(s),T_ARRAYS.push(a),!1}function vornoiRegion(t,e){var i=t.length2(),o=e.dot(t);return o<0?LEFT_VORNOI_REGION:o>i?RIGHT_VORNOI_REGION:MIDDLE_VORNOI_REGION}function testPolygonPolygon(t,e,i,o,r){var n,s=e.points,a=e.normals,l=a.length,h=o.points,c=o.normals,u=c.length,p=T_VECTORS.pop().copy(t.pos).add(t.ancestor.getAbsolutePosition()).add(e.pos),d=T_VECTORS.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos);for(n=0;n<l;n++)if(isSeparatingAxis(p,d,s,h,a[n],r))return T_VECTORS.push(p),T_VECTORS.push(d),!1;for(n=0;n<u;n++)if(isSeparatingAxis(p,d,s,h,c[n],r))return T_VECTORS.push(p),T_VECTORS.push(d),!1;return r&&(r.a=t,r.b=i,r.overlapV.copy(r.overlapN).scale(r.overlap)),T_VECTORS.push(p),T_VECTORS.push(d),!0}function testEllipseEllipse(t,e,i,o,r){var n=T_VECTORS.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos).sub(t.pos).add(t.ancestor.getAbsolutePosition()).sub(e.pos),s=e.radius,a=o.radius,l=s+a,h=l*l,c=n.length2();if(c>h)return T_VECTORS.push(n),!1;if(r){var u=Math.sqrt(c);r.a=t,r.b=i,r.overlap=l-u,r.overlapN.copy(n.normalize()),r.overlapV.copy(n).scale(r.overlap),r.aInB=s<=a&&u<=a-s,r.bInA=a<=s&&u<=s-a}return T_VECTORS.push(n),!0}function testPolygonEllipse(t,e,i,o,r){for(var n=T_VECTORS.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos).sub(t.pos).add(t.ancestor.getAbsolutePosition()).sub(e.pos),s=o.radius,a=s*s,l=e.points,h=e.edges,c=h.length,u=T_VECTORS.pop(),p=T_VECTORS.pop(),d=T_VECTORS.pop(),f=0,y=0;y<c;y++){var g=y===c-1?0:y+1,v=0===y?c-1:y-1,m=0,_=null;u.copy(h[y]),d.copy(n).sub(l[y]),r&&d.length2()>a&&(r.aInB=!1);var x=vornoiRegion(u,d),b=!0;if(x===LEFT_VORNOI_REGION){var T=null;if(c>1&&(u.copy(h[v]),(x=vornoiRegion(u,T=T_VECTORS.pop().copy(n).sub(l[v])))!==RIGHT_VORNOI_REGION&&(b=!1)),b){if((f=d.length())>s)return T_VECTORS.push(n),T_VECTORS.push(u),T_VECTORS.push(p),T_VECTORS.push(d),T&&T_VECTORS.push(T),!1;r&&(r.bInA=!1,_=d.normalize(),m=s-f)}T&&T_VECTORS.push(T)}else if(x===RIGHT_VORNOI_REGION){if(c>1&&(u.copy(h[g]),d.copy(n).sub(l[g]),(x=vornoiRegion(u,d))!==LEFT_VORNOI_REGION&&(b=!1)),b){if((f=d.length())>s)return T_VECTORS.push(n),T_VECTORS.push(u),T_VECTORS.push(p),T_VECTORS.push(d),!1;r&&(r.bInA=!1,_=d.normalize(),m=s-f)}}else{p.copy(e.normals[y]),f=d.dot(p);var w=Math.abs(f);if((1===c||f>0)&&w>s)return T_VECTORS.push(n),T_VECTORS.push(u),T_VECTORS.push(p),T_VECTORS.push(d),!1;r&&(_=p,m=s-f,(f>=0||m<2*s)&&(r.bInA=!1))}_&&r&&Math.abs(m)<Math.abs(r.overlap)&&(r.overlap=m,r.overlapN.copy(_))}return r&&(r.a=t,r.b=i,r.overlapV.copy(r.overlapN).scale(r.overlap)),T_VECTORS.push(n),T_VECTORS.push(u),T_VECTORS.push(p),T_VECTORS.push(d),!0}function testEllipsePolygon(t,e,i,o,r){var n=this.testPolygonEllipse(i,o,t,e,r);if(n&&r){var s=r.a,a=r.aInB;r.overlapN.negateSelf(),r.overlapV.negateSelf(),r.a=r.b,r.b=s,r.aInB=r.bInA,r.bInA=a}return n}var SAT=Object.freeze({__proto__:null,testPolygonPolygon:testPolygonPolygon,testEllipseEllipse:testEllipseEllipse,testPolygonEllipse:testPolygonEllipse,testEllipsePolygon:testEllipsePolygon}),dummyObj={pos:new Vector2d(0,0),ancestor:{_absPos:new Vector2d(0,0),getAbsolutePosition:function(){return this._absPos}}};function shouldCollide(t,e){return!0!==t.isKinematic&&!0!==e.isKinematic&&"object"==typeof t.body&&"object"==typeof e.body&&!(!0===t.body.isStatic&&!0===e.body.isStatic)&&0!=(t.body.collisionMask&e.body.collisionType)&&0!=(t.body.collisionType&e.body.collisionMask)}var ResponseObject=function(){this.a=null,this.b=null,this.overlapN=new Vector2d,this.overlapV=new Vector2d,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE};ResponseObject.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this};var globalResponse=new ResponseObject;function collisionCheck(t,e){void 0===e&&(e=globalResponse);for(var i,o=0,r=world.broadphase.retrieve(t),n=r.length;i=r[--n];)if(i!==t&&shouldCollide(t,i)&&t.body.getBounds().overlaps(i.body.getBounds())){var s=t.body.shapes.length,a=i.body.shapes.length;if(0===s||0===a)continue;var l=0;do{var h=t.body.getShape(l),c=0;do{var u=i.body.getShape(c);!0===SAT["test"+h.shapeType+u.shapeType].call(this,t,h,i,u,e.clear())&&(o++,e.indexShapeA=l,e.indexShapeB=c,t.onCollision&&!1!==t.onCollision(e,i)&&!1===t.body.isStatic&&t.body.respondToCollision.call(t.body,e),i.onCollision&&!1!==i.onCollision(e,t)&&!1===i.body.isStatic&&i.body.respondToCollision.call(i.body,e)),c++}while(c<a);l++}while(l<s)}return o>0}function rayCast(t,e){void 0===e&&(e=[]);for(var i,o=0,r=world.broadphase.retrieve(t),n=r.length;i=r[--n];)if(i.body&&t.getBounds().overlaps(i.getBounds())){var s=i.body.shapes.length;if(0===i.body.shapes.length)continue;var a=t,l=0;do{var h=i.body.getShape(l);SAT["test"+a.shapeType+h.shapeType].call(this,dummyObj,a,i,h)&&(e[o]=i,o++),l++}while(l<s)}return e.length=o,e}var collision={maxChildren:8,maxDepth:4,types:{NO_OBJECT:0,PLAYER_OBJECT:1,NPC_OBJECT:2,ENEMY_OBJECT:4,COLLECTABLE_OBJECT:8,ACTION_OBJECT:16,PROJECTILE_OBJECT:32,WORLD_SHAPE:64,USER:128,ALL_OBJECT:4294967295},response:globalResponse,rayCast:function(t,e){return rayCast(t,e)}},Body=function(t,e,i){if(this.ancestor=t,void 0===this.bounds&&(this.bounds=pool$1.pull("Bounds")),void 0===this.shapes&&(this.shapes=[]),this.collisionMask=collision.types.ALL_OBJECT,this.collisionType=collision.types.ENEMY_OBJECT,void 0===this.vel&&(this.vel=pool$1.pull("Vector2d")),this.vel.set(0,0),void 0===this.force&&(this.force=pool$1.pull("Vector2d")),this.force.set(0,0),void 0===this.friction&&(this.friction=pool$1.pull("Vector2d")),this.friction.set(0,0),this.bounce=0,this.mass=1,void 0===this.maxVel&&(this.maxVel=pool$1.pull("Vector2d")),this.maxVel.set(490,490),this.isStatic=!1,this.gravityScale=1,this.ignoreGravity=!1,this.falling=!1,this.jumping=!1,"function"==typeof i&&(this.onBodyUpdate=i),this.bounds.clear(),void 0!==e)if(Array.isArray(e))for(var o=0;o<e.length;o++)this.addShape(e[o]);else this.addShape(e);this.ancestor.isKinematic=!1};Body.prototype.setStatic=function(t){void 0===t&&(t=!0),this.isStatic=!0===t},Body.prototype.addShape=function(t){if(t instanceof Rect||t instanceof Bounds$1){var e=t.toPolygon();this.shapes.push(e),this.bounds.add(e.points),this.bounds.translate(e.pos)}else t instanceof Ellipse?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addBounds(t.getBounds()),this.bounds.translate(t.getBounds().x,t.getBounds().y)):t instanceof Polygon?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.add(t.points),this.bounds.translate(t.pos)):this.fromJSON(t);return"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this),this.shapes.length},Body.prototype.setVertices=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=!0);var o=this.getShape(e);o instanceof Polygon?o.setShape(0,0,t):this.shapes[e]=pool$1.pull("Polygon",0,0,t),this.bounds.add(this.shapes[e].points,i),"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this)},Body.prototype.addVertices=function(t,e){void 0===e&&(e=0),this.setVertices(t,e,!1)},Body.prototype.fromJSON=function(t,e){var i=t;if(void 0!==e&&(i=t[e]),void 0===i)throw new Error("Identifier ("+e+") undefined for the given JSON object)");if(i.length){for(var o=0;o<i.length;o++)this.addVertices(i[o].shape,o);this.mass=i[0].density||0,this.friction.set(i[0].friction||0,i[0].friction||0),this.bounce=i[0].bounce||0}return i.length},Body.prototype.getShape=function(t){return this.shapes[t||0]},Body.prototype.getBounds=function(){return this.bounds},Body.prototype.removeShape=function(t){this.bounds.clear(),remove(this.shapes,t);for(var e=0;e<this.shapes.length;e++)this.addShape(this.shapes[e]);return this.shapes.length},Body.prototype.removeShapeAt=function(t){return this.removeShape(this.getShape(t))},Body.prototype.setCollisionMask=function(t){void 0===t&&(t=collision.types.ALL_OBJECT),this.collisionMask=t},Body.prototype.setCollisionType=function(t){if(void 0!==t){if(void 0===collision.types[t])throw new Error("Invalid value for the collisionType property");this.collisionType=collision.types[t]}},Body.prototype.respondToCollision=function(t){var e=t.overlapV;if(this.ancestor.pos.sub(e),0!==e.x&&(this.vel.x=~~(.5+this.vel.x-e.x)||0,this.bounce>0&&(this.vel.x*=-this.bounce)),0!==e.y){this.vel.y=~~(.5+this.vel.y-e.y)||0,this.bounce>0&&(this.vel.y*=-this.bounce);var i=Math.sign(world.gravity.y*this.gravityScale)||1;this.falling=e.y>=i,this.jumping=e.y<=-i}},Body.prototype.forEach=function(t,e){var i=this,o=0,r=this.shapes,n=r.length;if("function"!=typeof t)throw new Error(t+" is not a function");for(arguments.length>1&&(i=e);o<n;)t.call(i,r[o],o,r),o++},Body.prototype.contains=function(){var t,e;if(2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.getBounds().contains(t,e))for(var i,o=this.shapes.length;o--,i=this.shapes[o];)if(i.contains(t,e))return!0;return!1},Body.prototype.rotate=function(t,e){var i=this;return void 0===e&&(e=this.getBounds().center),this.bounds.clear(),this.forEach((function(o){o.rotate(t,e),i.bounds.addBounds(o.getBounds()),o instanceof Ellipse?i.bounds.translate(o.getBounds().x,o.getBounds().y):i.bounds.translate(o.pos)})),this},Body.prototype.setMaxVelocity=function(t,e){this.maxVel.x=t,this.maxVel.y=e},Body.prototype.setFriction=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.friction.x=t,this.friction.y=e},Body.prototype.computeVelocity=function(){var t=timer$1.tick;if(!this.ignoreGravity){var e=world.gravity;this.vel.x+=e.x*this.gravityScale*t,this.vel.y+=e.y*this.gravityScale*t,this.falling=this.vel.y*Math.sign(e.y*this.gravityScale)>0,this.jumping=!this.falling&&this.jumping}if(0!==this.force.x&&(this.vel.x+=this.force.x*t),0!==this.force.y&&(this.vel.y+=this.force.y*t),this.friction.x>0){var i=this.friction.x*t,o=this.vel.x+i,r=this.vel.x-i;this.vel.x=o<0?o:r>0?r:0}if(this.friction.y>0){var n=this.friction.y*t,s=this.vel.y+n,a=this.vel.y-n;this.vel.y=s<0?s:a>0?a:0}0!==this.vel.y&&(this.vel.y=clamp(this.vel.y,-this.maxVel.y,this.maxVel.y)),0!==this.vel.x&&(this.vel.x=clamp(this.vel.x,-this.maxVel.x,this.maxVel.x))},Body.prototype.update=function(t){return this.computeVelocity(t),this.ancestor.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},Body.prototype.destroy=function(){pool$1.push(this.bounds),pool$1.push(this.vel),pool$1.push(this.force),pool$1.push(this.friction),pool$1.push(this.maxVel),this.shapes.forEach((function(t){pool$1.push(t)})),this.onBodyUpdate=void 0,this.ancestor=void 0,this.bounds=void 0,this.vel=void 0,this.force=void 0,this.friction=void 0,this.maxVel=void 0,this.shapes.length=0,this.setStatic(!1)};var deferredRemove=function(t,e){this.removeChildNow(t,e)},globalFloatingCounter=0,Container=function(t){function e(e,i,o,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=viewport.width),void 0===r&&(r=viewport.height),void 0===n&&(n=!1),t.call(this,e,i,o,r),this.pendingSort=null,this.root=n,this.children=void 0,this.sortOn=sortOn,this.autoSort=!0,this.autoDepth=!0,this.clipping=!1,this.onChildChange=function(){},this.enableChildBoundsUpdate=!1,this.backgroundColor=pool$1.pull("Color",0,0,0,0),this.drawCount=0,this.autoTransform=!0,this.isKinematic=!1,this.anchorPoint.set(0,0),!0===this.root&&on(CANVAS_ONRESIZE,this.updateBounds.bind(this,!0))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){this.pendingSort&&(clearTimeout(this.pendingSort),this.pendingSort=null);for(var t,e=this.getChildren(),i=e.length;i>=0;t=e[--i])t&&!0!==t.isPersistent&&this.removeChildNow(t);void 0!==this.currentTransform&&this.currentTransform.identity(),this.backgroundColor.setColor(0,0,0,0)},e.prototype.addChild=function(t,i){return t.ancestor instanceof e?t.ancestor.removeChildNow(t):t.isRenderable&&(t.GUID=utils.createGUID(t.id)),t.ancestor=this,this.getChildren().push(t),void 0!==t.pos&&("number"==typeof i?t.pos.z=i:!0===this.autoDepth&&(t.pos.z=this.getChildren().length)),!0===this.autoSort&&this.sort(),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Body&&world.addBody(t.body),this.onChildChange.call(this,this.getChildren().length-1),t},e.prototype.addChildAt=function(t,i){if(i>=0&&i<this.getChildren().length)return t.ancestor instanceof e?t.ancestor.removeChildNow(t):t.isRenderable&&(t.GUID=utils.createGUID()),t.ancestor=this,this.getChildren().splice(i,0,t),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Body&&world.addBody(t.body),this.onChildChange.call(this,i),t;throw new Error("Index ("+i+") Out Of Bounds for addChildAt()")},e.prototype.forEach=function(t,e){var i=this,o=0,r=this.getChildren(),n=r.length;if("function"!=typeof t)throw new Error(t+" is not a function");for(arguments.length>1&&(i=e);o<n;)t.call(i,r[o],o,r),o++},e.prototype.swapChildren=function(t,e){var i=this.getChildIndex(t),o=this.getChildIndex(e);if(-1===i||-1===o)throw new Error(t+" Both the supplied childs must be a child of the caller "+this);var r=t.pos.z;t.pos.z=e.pos.z,e.pos.z=r,this.getChildren()[i]=e,this.getChildren()[o]=t,this.isDirty=!0},e.prototype.getChildAt=function(t){if(t>=0&&t<this.getChildren().length)return this.getChildren()[t];throw new Error("Index ("+t+") Out Of Bounds for getChildAt()")},e.prototype.getChildIndex=function(t){return this.getChildren().indexOf(t)},e.prototype.getNextChild=function(t){var e=this.getChildren().indexOf(t)-1;if(e>=0&&e<this.getChildren().length)return this.getChildAt(e)},e.prototype.hasChild=function(t){return this===t.ancestor},e.prototype.getChildByProp=function(t,i){var o=[];return this.forEach((function(r){!function(t,e){var r=t[e];i instanceof RegExp&&"string"==typeof r?i.test(r)&&o.push(t):r===i&&o.push(t)}(r,t),r instanceof e&&(o=o.concat(r.getChildByProp(t,i)))})),o},e.prototype.getChildByType=function(t){var i=[];return this.forEach((function(o){o instanceof t&&i.push(o),o instanceof e&&(i=i.concat(o.getChildByType(t)))})),i},e.prototype.getChildByName=function(t){return this.getChildByProp("name",t)},e.prototype.getChildByGUID=function(t){var e=this.getChildByProp("GUID",t);return e.length>0?e[0]:null},e.prototype.getChildren=function(){return void 0===this.children&&(this.children=[]),this.children},e.prototype.updateBounds=function(e){void 0===e&&(e=!1),t.prototype.updateBounds.call(this);var i=this.getBounds();return!0!==e&&!0!==this.enableChildBoundsUpdate||this.forEach((function(t){t.isRenderable&&(t.getBounds().isFinite()&&i.addBounds(t.getBounds()))})),i},e.prototype.isAttachedToRoot=function(){if(!0===this.root)return!0;for(var t=this.ancestor;t;){if(!0===t.root)return!0;t=t.ancestor}return!1},e.prototype.updateBoundsPos=function(e,i){var o=this;return t.prototype.updateBoundsPos.call(this,e,i),this.forEach((function(t){t.isRenderable&&t.updateBoundsPos(t.pos.x+e-o.pos.x,t.pos.y+i-o.pos.y)})),this.getBounds()},e.prototype.onActivateEvent=function(){this.forEach((function(t){"function"==typeof t.onActivateEvent&&t.onActivateEvent()}))},e.prototype.removeChild=function(t,e){if(!this.hasChild(t))throw new Error("Child is not mine.");utils.function.defer(deferredRemove,this,t,e)},e.prototype.removeChildNow=function(t,e){if(this.hasChild(t)&&this.getChildIndex(t)>=0){"function"==typeof t.onDeactivateEvent&&t.onDeactivateEvent(),t.body instanceof Body&&world.removeBody(t.body),e||!1===pool$1.push(t,!1)&&"function"==typeof t.destroy&&t.destroy();var i=this.getChildIndex(t);i>=0&&(this.getChildren().splice(i,1),t.ancestor=void 0),!0===this.isAttachedToRoot()&&repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),this.onChildChange.call(this,i)}},e.prototype.setChildsProperty=function(t,i,o){this.forEach((function(r){!0===o&&r instanceof e&&r.setChildsProperty(t,i,o),r[t]=i}))},e.prototype.moveUp=function(t){var e=this.getChildIndex(t);e-1>=0&&(this.swapChildren(t,this.getChildAt(e-1)),this.isDirty=!0)},e.prototype.moveDown=function(t){var e=this.getChildIndex(t);e>=0&&e+1<this.getChildren().length&&(this.swapChildren(t,this.getChildAt(e+1)),this.isDirty=!0)},e.prototype.moveToTop=function(t){var e=this.getChildIndex(t);if(e>0){var i=this.getChildren();i.splice(0,0,i.splice(e,1)[0]),t.pos.z=i[1].pos.z+1,this.isDirty=!0}},e.prototype.moveToBottom=function(t){var e=this.getChildIndex(t),i=this.getChildren();e>=0&&e<i.length-1&&(i.splice(i.length-1,0,i.splice(e,1)[0]),t.pos.z=i[i.length-2].pos.z-1,this.isDirty=!0)},e.prototype.sort=function(t){this.pendingSort||(!0===t&&this.forEach((function(i){i instanceof e&&i.sort(t)})),this.pendingSort=utils.function.defer((function(){this.getChildren().sort(this["_sort"+this.sortOn.toUpperCase()]),this.pendingSort=null,repaint()}),this))},e.prototype.onDeactivateEvent=function(){this.forEach((function(t){"function"==typeof t.onDeactivateEvent&&t.onDeactivateEvent()}))},e.prototype._sortZ=function(t,e){return e.pos&&t.pos?e.pos.z-t.pos.z:t.pos?-1/0:1/0},e.prototype._sortReverseZ=function(t,e){return t.pos&&e.pos?t.pos.z-e.pos.z:t.pos?1/0:-1/0},e.prototype._sortX=function(t,e){if(!e.pos||!t.pos)return t.pos?-1/0:1/0;var i=e.pos.z-t.pos.z;return i||e.pos.x-t.pos.x},e.prototype._sortY=function(t,e){if(!e.pos||!t.pos)return t.pos?-1/0:1/0;var i=e.pos.z-t.pos.z;return i||e.pos.y-t.pos.y},e.prototype.destroy=function(){this.reset(),t.prototype.destroy.call(this,arguments)},e.prototype.update=function(e){for(var i,o=!1,r=state.isPaused(),n=this.getChildren(),s=n.length;s--,i=n[s];)r&&!i.updateWhenPaused||(i.isRenderable?((o=globalFloatingCounter>0||i.floating)&&globalFloatingCounter++,i.inViewport=!1,state.current().cameras.forEach((function(t){t.isVisible(i,o)&&(i.inViewport=!0)})),this.isDirty|=(i.inViewport||i.alwaysUpdate)&&i.update(e),globalFloatingCounter>0&&globalFloatingCounter--):this.isDirty|=i.update(e));return t.prototype.update.call(this,e)},e.prototype.draw=function(t,e){var i=!1,o=this.getBounds();this.drawCount=0,!1===this.root&&!0===this.clipping&&!0===o.isFinite()&&t.clipRect(o.left,o.top,o.width,o.height),t.translate(this.pos.x,this.pos.y),this.backgroundColor.alpha>1/255&&t.clearColor(this.backgroundColor);for(var r,n=this.getChildren(),s=n.length;r=n[--s];)r.isRenderable&&(i=!0===r.floating,(r.inViewport||i)&&(i&&(t.save(),t.resetTransform()),r.preDraw(t),r.draw(t,e),r.postDraw(t),i&&t.restore(),this.drawCount++))},e}(Renderable),QT_ARRAY=[];function QT_ARRAY_POP(t,e,i,o){if(void 0===e&&(e=4),void 0===i&&(i=4),void 0===o&&(o=0),QT_ARRAY.length>0){var r=QT_ARRAY.pop();return r.bounds=t,r.max_objects=e,r.max_levels=i,r.level=o,r}return new QuadTree(t,e,i,o)}function QT_ARRAY_PUSH(t){QT_ARRAY.push(t)}var QT_VECTOR=new Vector2d,QuadTree=function(t,e,i,o){void 0===e&&(e=4),void 0===i&&(i=4),void 0===o&&(o=0),this.max_objects=e,this.max_levels=i,this.level=o,this.bounds=t,this.objects=[],this.nodes=[]};QuadTree.prototype.split=function(){var t=this.level+1,e=this.bounds.width/2,i=this.bounds.height/2,o=this.bounds.left,r=this.bounds.top;this.nodes[0]=QT_ARRAY_POP({left:o+e,top:r,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[1]=QT_ARRAY_POP({left:o,top:r,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[2]=QT_ARRAY_POP({left:o,top:r+i,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[3]=QT_ARRAY_POP({left:o+e,top:r+i,width:e,height:i},this.max_objects,this.max_levels,t)},QuadTree.prototype.getIndex=function(t){var e,i=t.getBounds(),o=-1,r=(e=!0===t.isFloating?viewport.localToWorld(i.left,i.top,QT_VECTOR):QT_VECTOR.set(t.left,t.top)).x,n=e.y,s=i.width,a=i.height,l=this.bounds.left+this.bounds.width/2,h=this.bounds.top+this.bounds.height/2,c=n<h&&n+a<h,u=n>h;return r<l&&r+s<l?c?o=1:u&&(o=2):r>l&&(c?o=0:u&&(o=3)),o},QuadTree.prototype.insertContainer=function(t){for(var e,i=t.children.length;i--,e=t.children[i];)!0!==e.isKinematic&&(e instanceof Container?("rootContainer"!==e.name&&this.insert(e),this.insertContainer(e)):"function"==typeof e.getBounds&&this.insert(e))},QuadTree.prototype.insert=function(t){var e=-1;if(this.nodes.length>0&&-1!==(e=this.getIndex(t)))this.nodes[e].insert(t);else if(this.objects.push(t),this.objects.length>this.max_objects&&this.level<this.max_levels){0===this.nodes.length&&this.split();for(var i=0;i<this.objects.length;)-1!==(e=this.getIndex(this.objects[i]))?this.nodes[e].insert(this.objects.splice(i,1)[0]):i+=1}},QuadTree.prototype.retrieve=function(t,e){var i=this.objects;if(this.nodes.length>0){var o=this.getIndex(t);if(-1!==o)i=i.concat(this.nodes[o].retrieve(t));else for(var r=0;r<this.nodes.length;r+=1)i=i.concat(this.nodes[r].retrieve(t))}return"function"==typeof e&&i.sort(e),i},QuadTree.prototype.remove=function(t){var e=!1;if(void 0===t.getBounds)return!1;if(this.nodes.length>0){var i=this.getIndex(t);-1!==i&&(e=remove(this.nodes[i],t))&&this.nodes[i].isPrunable()&&this.nodes.splice(i,1)}return!1===e&&-1!==this.objects.indexOf(t)&&(remove(this.objects,t),e=!0),e},QuadTree.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},QuadTree.prototype.hasChildren=function(){for(var t=0;t<this.nodes.length;t+=1){var e=this.nodes[t];if(e.length>0||e.objects.length>0)return!0}return!1},QuadTree.prototype.clear=function(t){this.objects.length=0;for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear(),QT_ARRAY_PUSH(this.nodes[e]);this.nodes.length=0,void 0!==t&&this.bounds.setMinMax(t.min.x,t.min.y,t.max.x,t.max.y)};var World=function(t){function e(e,i,o,r){var n=this;void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1/0),void 0===r&&(r=1/0),t.call(this,e,i,o,r,!0),this.name="rootContainer",this.anchorPoint.set(0,0),this.fps=60,this.gravity=new Vector2d(0,.98),this.preRender=!1,this.bodies=new Set,this.broadphase=new QuadTree(this.getBounds().clone(),collision.maxChildren,collision.maxDepth),on(GAME_RESET,this.reset,this),on(LEVEL_LOADED,(function(){n.broadphase.clear(n.getBounds())}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){this.broadphase.clear(),this.anchorPoint.set(0,0),t.prototype.reset.call(this),this.bodies.clear()},e.prototype.addBody=function(t){return this.bodies.add(t),this},e.prototype.removeBody=function(t){return this.bodies.delete(t),this},e.prototype.update=function(e){var i=state.isPaused();return this.broadphase.clear(),this.broadphase.insertContainer(this),this.bodies.forEach((function(t){if(!t.isStatic){var o=t.ancestor;i&&!o.updateWhenPaused||!o.inViewport&&!o.alwaysUpdate||(!0===t.update(e)&&(o.isDirty=!0),collisionCheck(o))}})),t.prototype.update.call(this,e)},e}(Container),isDirty=!0,isAlwaysDirty=!1,frameCounter=0,frameRate=1,accumulator=0,accumulatorMax=0,accumulatorUpdateDelta=0,stepSize=1e3/60,updateDelta=0,lastUpdateStart=null,updateAverageDelta=0,viewport,world;on(BOOT,(function(){world=new World,emit(GAME_INIT)}));var mergeGroup=!0,sortOn="z",lastUpdate=globalThis.performance.now();function onLevelLoaded(){}function reset(){var t=state.current();void 0!==t&&(viewport=t.cameras.get("default")),emit(GAME_RESET),updateFrameRate()}function updateFrameRate(){frameCounter=0,frameRate=~~(.5+60/timer$1.maxfps),stepSize=1e3/world.fps,accumulator=0,accumulatorMax=10*stepSize,isAlwaysDirty=timer$1.maxfps>world.fps}function getParentContainer(t){return t.ancestor}function repaint(){isDirty=!0}function update$1(t,e){if(++frameCounter%frameRate==0){for(frameCounter=0,emit(GAME_BEFORE_UPDATE,t),accumulator+=timer$1.getDelta(),accumulator=Math.min(accumulator,accumulatorMax),updateDelta=timer$1.interpolation?timer$1.getDelta():stepSize,accumulatorUpdateDelta=timer$1.interpolation?updateDelta:Math.max(updateDelta,updateAverageDelta);accumulator>=accumulatorUpdateDelta||timer$1.interpolation;)if(lastUpdateStart=globalThis.performance.now(),!0!==state.isPaused()&&emit(GAME_UPDATE,t),isDirty=e.update(updateDelta)||isDirty,lastUpdate=globalThis.performance.now(),updateAverageDelta=lastUpdate-lastUpdateStart,accumulator-=accumulatorUpdateDelta,timer$1.interpolation){accumulator=0;break}emit(GAME_AFTER_UPDATE,lastUpdate)}}function draw(t){!0===renderer.isContextValid&&(isDirty||isAlwaysDirty)&&(emit(GAME_BEFORE_DRAW,globalThis.performance.now()),renderer.clear(),t.draw(renderer),isDirty=!1,renderer.flush(),emit(GAME_AFTER_DRAW,globalThis.performance.now()))}var game=Object.freeze({__proto__:null,get viewport(){return viewport},get world(){return world},mergeGroup:mergeGroup,sortOn:sortOn,get lastUpdate(){return lastUpdate},onLevelLoaded:onLevelLoaded,reset:reset,updateFrameRate:updateFrameRate,getParentContainer:getParentContainer,repaint:repaint,update:update$1,draw:draw}),MIN=Math.min,MAX=Math.max,targetV=new Vector2d,Camera2d=function(t){function e(e,i,o,r){t.call(this,e,i,o-e,r-i),this.AXIS={NONE:0,HORIZONTAL:1,VERTICAL:2,BOTH:3},this.bounds=pool$1.pull("Bounds"),this.smoothFollow=!0,this.damping=1,this.near=-1e3,this.far=1e3,this.projectionMatrix=new Matrix3d,this.invCurrentTransform=new Matrix2d,this.offset=new Vector2d,this.target=null,this.follow_axis=this.AXIS.NONE,this._shake={intensity:0,duration:0,axis:this.AXIS.BOTH,onComplete:null},this._fadeOut={color:null,tween:null},this._fadeIn={color:null,tween:null},this.name="default",this.setDeadzone(this.width/6,this.height/6),this.anchorPoint.set(0,0),this.isKinematic=!1,this.bounds.setMinMax(e,i,o,r),this._updateProjectionMatrix(),on(GAME_RESET,this.reset,this),on(CANVAS_ONRESIZE,this.resize,this)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._updateProjectionMatrix=function(){this.projectionMatrix.ortho(0,this.width,this.height,0,this.near,this.far)},e.prototype._followH=function(t){var e=this.pos.x;return t.x-this.pos.x>this.deadzone.right?e=MIN(t.x-this.deadzone.right,this.bounds.width-this.width):t.x-this.pos.x<this.deadzone.pos.x&&(e=MAX(t.x-this.deadzone.pos.x,this.bounds.left)),e},e.prototype._followV=function(t){var e=this.pos.y;return t.y-this.pos.y>this.deadzone.bottom?e=MIN(t.y-this.deadzone.bottom,this.bounds.height-this.height):t.y-this.pos.y<this.deadzone.pos.y&&(e=MAX(t.y-this.deadzone.pos.y,this.bounds.top)),e},e.prototype.reset=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.pos.x=t,this.pos.y=e,this.unfollow(),this.smoothFollow=!0,this.damping=1,this.currentTransform.identity(),this.invCurrentTransform.identity().invert(),this._updateProjectionMatrix()},e.prototype.setDeadzone=function(t,e){void 0===this.deadzone&&(this.deadzone=new Rect(0,0,0,0)),this.deadzone.pos.set(~~((this.width-t)/2),~~((this.height-e)/2-.25*e)),this.deadzone.resize(t,e),this.smoothFollow=!1,this.updateTarget(),this.smoothFollow=!0},e.prototype.resize=function(e,i){return t.prototype.resize.call(this,e,i),this.smoothFollow=!1,this.setBounds(0,0,e,i),this.setDeadzone(e/6,i/6),this.update(),this.smoothFollow=!0,this._updateProjectionMatrix(),emit(VIEWPORT_ONRESIZE,this.width,this.height),this},e.prototype.setBounds=function(t,e,i,o){this.smoothFollow=!1,this.bounds.setMinMax(t,e,i+t,o+e),this.moveTo(this.pos.x,this.pos.y),this.update(),this.smoothFollow=!0},e.prototype.follow=function(e,i,o){if(e instanceof t)this.target=e.pos;else{if(!(e instanceof Vector2d||e instanceof Vector3d||e instanceof ObservableVector2d||e instanceof ObservableVector3d))throw new Error("invalid target for me.Camera2d.follow");this.target=e}this.follow_axis=void 0===i?this.AXIS.BOTH:i,this.smoothFollow=!1,this.damping="number"!=typeof o?1:clamp(o,0,1),this.updateTarget(),this.smoothFollow=!0},e.prototype.unfollow=function(){this.target=null,this.follow_axis=this.AXIS.NONE},e.prototype.move=function(t,e){this.moveTo(this.pos.x+t,this.pos.y+e)},e.prototype.moveTo=function(t,e){var i=this.pos.x,o=this.pos.y;this.pos.x=clamp(t,this.bounds.left,this.bounds.width),this.pos.y=clamp(e,this.bounds.top,this.bounds.height),i===this.pos.x&&o===this.pos.y||(this.isDirty=!0)},e.prototype.updateTarget=function(){if(this.target){switch(targetV.setV(this.pos),this.follow_axis){case this.AXIS.NONE:break;case this.AXIS.HORIZONTAL:targetV.x=this._followH(this.target);break;case this.AXIS.VERTICAL:targetV.y=this._followV(this.target);break;case this.AXIS.BOTH:targetV.x=this._followH(this.target),targetV.y=this._followV(this.target)}if(!this.pos.equals(targetV)){if(!0===this.smoothFollow&&this.damping<1){if(toBeCloseTo(targetV.x,this.pos.x,2)&&toBeCloseTo(targetV.y,this.pos.y,2))return void this.pos.setV(targetV);this.pos.lerp(targetV,this.damping)}else this.pos.setV(targetV);this.isDirty=!0}}},e.prototype.update=function(e){return this.updateTarget(e),this._shake.duration>0&&(this._shake.duration-=e,this._shake.duration<=0?(this._shake.duration=0,this.offset.setZero(),"function"==typeof this._shake.onComplete&&this._shake.onComplete()):(this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.HORIZONTAL||(this.offset.x=(Math.random()-.5)*this._shake.intensity),this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.VERTICAL||(this.offset.y=(Math.random()-.5)*this._shake.intensity)),this.isDirty=!0),!0===this.isDirty&&emit(VIEWPORT_ONCHANGE,this.pos),null==this._fadeIn.tween&&null==this._fadeOut.tween||(this.isDirty=!0),this.currentTransform.isIdentity()?this.invCurrentTransform.identity():this.invCurrentTransform.copy(this.currentTransform).invert(),t.prototype.update.call(this,e)},e.prototype.shake=function(t,e,i,o,r){0!==this._shake.duration&&!0!==r||(this._shake.intensity=t,this._shake.duration=e,this._shake.axis=i||this.AXIS.BOTH,this._shake.onComplete="function"==typeof o?o:void 0)},e.prototype.fadeOut=function(t,e,i){void 0===e&&(e=1e3),this._fadeOut.color=pool$1.pull("Color").copy(t),this._fadeOut.tween=pool$1.pull("Tween",this._fadeOut.color).to({alpha:0},e).onComplete(i||null),this._fadeOut.tween.isPersistent=!0,this._fadeOut.tween.start()},e.prototype.fadeIn=function(t,e,i){void 0===e&&(e=1e3),this._fadeIn.color=pool$1.pull("Color").copy(t);var o=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=pool$1.pull("Tween",this._fadeIn.color).to({alpha:o},e).onComplete(i||null),this._fadeIn.tween.isPersistent=!0,this._fadeIn.tween.start()},e.prototype.focusOn=function(t){var e=t.getBounds();this.moveTo(t.pos.x+e.left+e.width/2,t.pos.y+e.top+e.height/2)},e.prototype.isVisible=function(t,e){return void 0===e&&(e=t.floating),!0===e||!0===t.floating?renderer.overlaps(t.getBounds()):t.getBounds().overlaps(this)},e.prototype.localToWorld=function(t,e,i){return(i=i||pool$1.pull("Vector2d")).set(t,e).add(this.pos).sub(world.pos),this.currentTransform.isIdentity()||this.invCurrentTransform.apply(i),i},e.prototype.worldToLocal=function(t,e,i){return(i=i||pool$1.pull("Vector2d")).set(t,e),this.currentTransform.isIdentity()||this.currentTransform.apply(i),i.sub(this.pos).add(world.pos)},e.prototype.drawFX=function(t){this._fadeIn.tween&&(t.save(),t.resetTransform(),t.setColor(this._fadeIn.color),t.fillRect(0,0,this.width,this.height),t.restore(),1===this._fadeIn.color.alpha&&(this._fadeIn.tween=null,pool$1.push(this._fadeIn.color),this._fadeIn.color=null)),this._fadeOut.tween&&(t.save(),t.resetTransform(),t.setColor(this._fadeOut.color),t.fillRect(0,0,this.width,this.height),t.restore(),0===this._fadeOut.color.alpha&&(this._fadeOut.tween=null,pool$1.push(this._fadeOut.color),this._fadeOut.color=null))},e.prototype.draw=function(t,e){var i=this.pos.x+this.offset.x,o=this.pos.y+this.offset.y;e.currentTransform.translate(-i,-o),t.setProjection(this.projectionMatrix),t.clipRect(0,0,this.width,this.height),this.preDraw(t),e.preDraw(t),e.draw(t,this),this.drawFX(t),e.postDraw(t),this.postDraw(t),e.currentTransform.translate(i,o)},e}(Renderable),default_camera,default_settings={cameras:[]},Stage=function(t){this.cameras=new Map,this.settings=Object.assign(default_settings,t||{})};Stage.prototype.reset=function(){var t=this;if(this.settings.cameras.forEach((function(e){t.cameras.set(e.name,e)})),!1===this.cameras.has("default")){if(void 0===default_camera){var e=renderer.getWidth(),i=renderer.getHeight();default_camera=new Camera2d(0,0,e,i)}this.cameras.set("default",default_camera)}reset(),this.onResetEvent.apply(this,arguments)},Stage.prototype.update=function(t){var e=world.update(t);return this.cameras.forEach((function(i){i.update(t)&&(e=!0)})),e},Stage.prototype.draw=function(t){this.cameras.forEach((function(e){e.draw(t,world)}))},Stage.prototype.destroy=function(){this.cameras.clear(),this.onDestroyEvent.apply(this,arguments)},Stage.prototype.onResetEvent=function(){"function"==typeof this.settings.onResetEvent&&this.settings.onResetEvent.apply(this,arguments)},Stage.prototype.onDestroyEvent=function(){"function"==typeof this.settings.onDestroyEvent&&this.settings.onDestroyEvent.apply(this,arguments)};var ProgressBar=function(t){function e(e,i,o,r){t.call(this,e,i,o,r),this.barHeight=r,this.anchorPoint.set(0,0),on(LOADER_PROGRESS,this.onProgressUpdate,this),on(VIEWPORT_ONRESIZE,this.resize,this),this.anchorPoint.set(0,0),this.progress=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onProgressUpdate=function(t){this.progress=~~(t*this.width),this.isDirty=!0},e.prototype.draw=function(t){t.setColor("black"),t.fillRect(this.pos.x,viewport.centerY,t.getWidth(),this.barHeight/2),t.setColor("#55aa00"),t.fillRect(this.pos.x,viewport.centerY,this.progress,this.barHeight/2)},e.prototype.onDestroyEvent=function(){off(LOADER_PROGRESS,this.onProgressUpdate),off(VIEWPORT_ONRESIZE,this.resize)},e}(Renderable),IconLogo=function(t){function e(e,i){t.call(this,e,i,100,85),this.iconCanvas=createCanvas(renderer.WebGLVersion>1?this.width:nextPowerOfTwo(this.width),renderer.WebGLVersion>1?this.height:nextPowerOfTwo(this.height),!1);var o=renderer.getContext2d(this.iconCanvas);o.beginPath(),o.moveTo(.7,48.9),o.bezierCurveTo(10.8,68.9,38.4,75.8,62.2,64.5),o.bezierCurveTo(86.1,53.1,97.2,27.7,87,7.7),o.lineTo(87,7.7),o.bezierCurveTo(89.9,15.4,73.9,30.2,50.5,41.4),o.bezierCurveTo(27.1,52.5,5.2,55.8,.7,48.9),o.lineTo(.7,48.9),o.closePath(),o.fillStyle="rgb(255, 255, 255)",o.fill(),o.beginPath(),o.moveTo(84,7),o.bezierCurveTo(87.6,14.7,72.5,30.2,50.2,41.6),o.bezierCurveTo(27.9,53,6.9,55.9,3.2,48.2),o.bezierCurveTo(-.5,40.4,14.6,24.9,36.9,13.5),o.bezierCurveTo(59.2,2.2,80.3,-.8,84,7),o.lineTo(84,7),o.closePath(),o.lineWidth=5.3,o.strokeStyle="rgb(255, 255, 255)",o.lineJoin="miter",o.miterLimit=4,o.stroke(),this.anchorPoint.set(.5,.5)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t){t.drawImage(this.iconCanvas,t.getWidth()/2,this.pos.y)},e}(Renderable),DefaultLoadingScreen=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(){world.backgroundColor.parseCSS("#202020"),world.addChild(new ProgressBar(0,renderer.getHeight()/2,renderer.getWidth(),8),1),world.addChild(new IconLogo(renderer.getWidth()/2,renderer.getHeight()/2-16-35),2);var t=pool$1.pull("Text",renderer.getWidth()/2,renderer.getHeight()/2+16,{font:"century gothic",size:32,fillStyle:"white",textAlign:"left",textBaseline:"top",text:"melon",offScreenCanvas:renderer.WebGLVersion>=1});t.anchorPoint.set(0,0);var e=pool$1.pull("Text",renderer.getWidth()/2,renderer.getHeight()/2+16,{font:"century gothic",size:32,fillStyle:"#55aa00",textAlign:"left",textBaseline:"top",bold:!0,text:"JS",offScreenCanvas:renderer.WebGLVersion>=1});e.anchorPoint.set(0,0);var i=t.getBounds().width+e.getBounds().width;t.pos.x=renderer.getWidth()/2-i/2,e.pos.x=t.pos.x+t.getBounds().width,world.addChild(t,2),world.addChild(e,2)},e}(Stage),_state=-1,_animFrameId=-1,_isPaused=!1,_stages={},_fade={color:"",duration:0},_onSwitchComplete=null,_extraArgs=null,_pauseTime=0;function _startRunLoop(){-1===_animFrameId&&-1!==_state&&(timer$1.reset(),_animFrameId=globalThis.requestAnimationFrame(_renderFrame))}function _resumeRunLoop(){_isPaused&&-1!==_state&&(timer$1.reset(),_isPaused=!1)}function _pauseRunLoop(){_isPaused=!0}function _renderFrame(t){var e=_stages[_state].stage;update$1(t,e),draw(e),-1!==_animFrameId&&(_animFrameId=globalThis.requestAnimationFrame(_renderFrame))}function _stopRunLoop(){globalThis.cancelAnimationFrame(_animFrameId),_animFrameId=-1}function _switchState(t){_stopRunLoop(),_stages[_state]&&_stages[_state].stage.destroy(),_stages[t]&&(_stages[_state=t].stage.reset.apply(_stages[_state].stage,_extraArgs),_startRunLoop(),_onSwitchComplete&&_onSwitchComplete(),repaint())}on(BOOT,(function(){state.set(state.LOADING,new DefaultLoadingScreen),state.set(state.DEFAULT,new Stage),on(VIDEO_INIT,(function(){state.change(state.DEFAULT,!0)}))}));var state={LOADING:0,MENU:1,READY:2,PLAY:3,GAMEOVER:4,GAME_END:5,SCORE:6,CREDITS:7,SETTINGS:8,DEFAULT:9,USER:100,stop:function(t){void 0===t&&(t=!1),_state!==this.LOADING&&this.isRunning()&&(_stopRunLoop(),!0===t&&t(),_pauseTime=globalThis.performance.now(),emit(STATE_STOP))},pause:function(t){void 0===t&&(t=!1),_state===this.LOADING||this.isPaused()||(_pauseRunLoop(),!0===t&&pauseTrack(),_pauseTime=globalThis.performance.now(),emit(STATE_PAUSE))},restart:function(t){void 0===t&&(t=!1),this.isRunning()||(_startRunLoop(),!0===t&&resumeTrack(),_pauseTime=globalThis.performance.now()-_pauseTime,repaint(),emit(STATE_RESTART,_pauseTime))},resume:function(t){void 0===t&&(t=!1),this.isPaused()&&(_resumeRunLoop(),!0===t&&resumeTrack(),_pauseTime=globalThis.performance.now()-_pauseTime,emit(STATE_RESUME,_pauseTime))},isRunning:function(){return-1!==_animFrameId},isPaused:function(){return _isPaused},set:function(t,e,i){if(void 0===i&&(i=!1),!(e instanceof Stage))throw new Error(e+" is not an instance of me.Stage");_stages[t]={},_stages[t].stage=e,_stages[t].transition=!0,!0===i&&this.change(t)},current:function(){if(void 0!==_stages[_state])return _stages[_state].stage},transition:function(t,e,i){"fade"===t&&(_fade.color=e,_fade.duration=i)},setTransition:function(t,e){_stages[t].transition=e},change:function(t,e){if(void 0===_stages[t])throw new Error("Undefined Stage for state '"+t+"'");this.isCurrent(t)||(_extraArgs=null,arguments.length>1&&(_extraArgs=Array.prototype.slice.call(arguments,1)),_fade.duration&&_stages[t].transition?(_onSwitchComplete=function(){viewport.fadeOut(_fade.color,_fade.duration)},viewport.fadeIn(_fade.color,_fade.duration,(function(){defer(_switchState,this,t)}))):!0===e?_switchState(t):defer(_switchState,this,t))},isCurrent:function(t){return _state===t}};function setTMXValue(name,type,value){var match;if("string"!=typeof value)return value;switch(type){case"int":case"float":value=Number(value);break;case"bool":value="true"===value;break;default:if(!value||isBoolean(value))value=!value||"true"===value;else if(isNumeric(value))value=Number(value);else if(0===value.search(/^json:/i)){match=value.split(/^json:/i)[1];try{value=JSON.parse(match)}catch(t){throw new Error("Unable to parse JSON: "+match)}}else if(0===value.search(/^eval:/i)){match=value.split(/^eval:/i)[1];try{value=eval(match)}catch(t){throw new Error("Unable to evaluate: "+match)}}else((match=value.match(/^#([\da-fA-F])([\da-fA-F]{3})$/))||(match=value.match(/^#([\da-fA-F]{2})([\da-fA-F]{6})$/)))&&(value="#"+match[2]+match[1]);0===name.search(/^(ratio|anchorPoint)$/)&&"number"==typeof value&&(value={x:value,y:value})}return value}function parseAttributes(t,e){if(e.attributes&&e.attributes.length>0)for(var i=0;i<e.attributes.length;i++){var o=e.attributes.item(i);void 0!==o.name?t[o.name]=o.value:t[o.nodeName]=o.nodeValue}}function decompress(){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")}function decodeCSV(t){for(var e=t.replace("\n","").trim().split(","),i=[],o=0;o<e.length;o++)i.push(+e[o]);return i}function decodeBase64AsArray(t,e){var i,o,r;e=e||1;var n=globalThis.atob(t.replace(/[^A-Za-z0-9\+\/\=]/g,"")),s=new Uint32Array(n.length/e);for(i=0,r=n.length/e;i<r;i++)for(s[i]=0,o=e-1;o>=0;--o)s[i]+=n.charCodeAt(i*e+o)<<(o<<3);return s}function decode(t,e,i){switch(i=i||"none",e=e||"none"){case"csv":return decodeCSV(t);case"base64":var o=decodeBase64AsArray(t,4);return"none"===i?o:decompress();case"none":return t;case"xml":throw new Error("XML encoding is deprecated, use base64 instead");default:throw new Error("Unknown layer encoding: "+e)}}function normalize(t,e){var i=e.nodeName;switch(i){case"data":var o=parse(e);o.text=o.text||o.chunk.text,o.encoding=o.encoding||"xml",t.data=decode(o.text,o.encoding,o.compression),t.encoding="none";break;case"imagelayer":case"layer":case"objectgroup":case"group":var r=parse(e);r.type="layer"===i?"tilelayer":i,r.image&&(r.image=r.image.source),t.layers=t.layers||[],t.layers.push(r);break;case"animation":t.animation=parse(e).frames;break;case"frame":case"object":var n=i+"s";t[n]=t[n]||[],t[n].push(parse(e));break;case"tile":var s=parse(e);s.image&&(s.imagewidth=s.image.width,s.imageheight=s.image.height,s.image=s.image.source),t.tiles=t.tiles||{},t.tiles[s.id]=s;break;case"tileset":var a=parse(e);a.image&&(a.imagewidth=a.image.width,a.imageheight=a.image.height,a.image=a.image.source),t.tilesets=t.tilesets||[],t.tilesets.push(a);break;case"polygon":case"polyline":t[i]=[];for(var l,h=parse(e).points.split(" "),c=0;c<h.length;c++)l=h[c].split(","),t[i].push({x:+l[0],y:+l[1]});break;case"properties":t.properties=parse(e);break;case"property":var u=parse(e),p=void 0!==u.value?u.value:u.text;t[u.name]=setTMXValue(u.name,u.type||"string",p);break;default:t[i]=parse(e)}}function parse(t){var e={},i="";if(1===t.nodeType&&parseAttributes(e,t),t.hasChildNodes())for(var o=0;o<t.childNodes.length;o++){var r=t.childNodes.item(o);switch(r.nodeType){case 1:normalize(e,r);break;case 3:i+=r.nodeValue.trim()}}return i&&(e.text=i),e}function applyTMXProperties(t,e){var i=e.properties,o=e.propertytypes;if(void 0!==i)for(var r in i)if(i.hasOwnProperty(r)){var n="string",s=r,a=i[r];void 0!==i[r].name&&(s=i[r].name),void 0!==o?n=o[r]:void 0!==i[r].type&&(n=i[r].type),void 0!==i[r].value&&(a=i[r].value),t[s]=setTMXValue(s,n,a)}}var src={},arraymultimap={},multimap={},__generator=commonjsGlobal&&commonjsGlobal.__generator||function(t,e){var i,o,r,n,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(r=2&n[0]?o.return:n[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,n[1])).done)return r;switch(o=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,o=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){s=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){s.label=n[1];break}if(6===n[0]&&s.label<r[1]){s.label=r[1],r=n;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(n);break}r[2]&&s.ops.pop(),s.trys.pop();continue}n=e.call(t,s)}catch(t){n=[6,t],o=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}},__values=commonjsGlobal&&commonjsGlobal.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],o=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=commonjsGlobal&&commonjsGlobal.__read||function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var o,r,n=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}return s};Object.defineProperty(multimap,"__esModule",{value:!0}),multimap.Multimap=void 0;var Multimap=function(){function t(t,e){var i,o;if(this.size_=0,this.map=new Map,this.operator=t,e)try{for(var r=__values(e),n=r.next();!n.done;n=r.next()){var s=__read(n.value,2),a=s[0],l=s[1];this.put(a,l)}}catch(t){i={error:t}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(i)throw i.error}}return this}return Object.defineProperty(t.prototype,"size",{get:function(){return this.size_},enumerable:!1,configurable:!0}),t.prototype.get=function(t){var e=this.map.get(t);return e?this.operator.clone(e):this.operator.create()},t.prototype.put=function(t,e){var i=this.map.get(t);return i||(i=this.operator.create()),!!this.operator.add(e,i)&&(this.map.set(t,i),this.size_++,!0)},t.prototype.putAll=function(e,i){var o,r,n,s,a=0;if(i){var l=e,h=i;try{for(var c=__values(h),u=c.next();!u.done;u=c.next()){var p=u.value;this.put(l,p),a++}}catch(t){o={error:t}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(o)throw o.error}}}else{if(!(e instanceof t))throw new TypeError("unexpected arguments");try{for(var d=__values(e.entries()),f=d.next();!f.done;f=d.next()){var y=__read(f.value,2);l=y[0],p=y[1];this.put(l,p),a++}}catch(t){n={error:t}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(n)throw n.error}}}return a>0},t.prototype.has=function(t){return this.map.has(t)},t.prototype.hasEntry=function(t,e){return this.operator.has(e,this.get(t))},t.prototype.delete=function(t){return this.size_-=this.operator.size(this.get(t)),this.map.delete(t)},t.prototype.deleteEntry=function(t,e){var i=this.get(t);return!!this.operator.delete(e,i)&&(this.map.set(t,i),this.size_--,!0)},t.prototype.clear=function(){this.map.clear(),this.size_=0},t.prototype.keys=function(){return this.map.keys()},t.prototype.entries=function(){var t=this;return function(){var e,i,o,r,n,s,a,l,h,c,u,p,d,f;return __generator(this,(function(y){switch(y.label){case 0:y.trys.push([0,11,12,13]),e=__values(t.map.entries()),i=e.next(),y.label=1;case 1:if(i.done)return[3,10];o=__read(i.value,2),r=o[0],n=o[1],y.label=2;case 2:y.trys.push([2,7,8,9]),d=void 0,s=__values(n),a=s.next(),y.label=3;case 3:return a.done?[3,6]:(l=a.value,[4,[r,l]]);case 4:y.sent(),y.label=5;case 5:return a=s.next(),[3,3];case 6:return[3,9];case 7:return h=y.sent(),d={error:h},[3,9];case 8:try{a&&!a.done&&(f=s.return)&&f.call(s)}finally{if(d)throw d.error}return[7];case 9:return i=e.next(),[3,1];case 10:return[3,13];case 11:return c=y.sent(),u={error:c},[3,13];case 12:try{i&&!i.done&&(p=e.return)&&p.call(e)}finally{if(u)throw u.error}return[7];case 13:return[2]}}))}()},t.prototype.values=function(){var t=this;return function(){var e,i,o,r,n,s;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=__values(t.entries()),i=e.next(),a.label=1;case 1:return i.done?[3,4]:(o=__read(i.value,2),[4,o[1]]);case 2:a.sent(),a.label=3;case 3:return i=e.next(),[3,1];case 4:return[3,7];case 5:return r=a.sent(),n={error:r},[3,7];case 6:try{i&&!i.done&&(s=e.return)&&s.call(e)}finally{if(n)throw n.error}return[7];case 7:return[2]}}))}()},t.prototype.forEach=function(t,e){var i,o;try{for(var r=__values(this.entries()),n=r.next();!n.done;n=r.next()){var s=__read(n.value,2),a=s[0],l=s[1];t.call(void 0===e?this:e,l,a,this)}}catch(t){i={error:t}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(i)throw i.error}}},t.prototype[Symbol.iterator]=function(){return this.entries()},t.prototype.asMap=function(){var t,e,i=new Map;try{for(var o=__values(this.keys()),r=o.next();!r.done;r=o.next()){var n=r.value;i.set(n,this.operator.clone(this.get(n)))}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return i},t}();multimap.Multimap=Multimap;var __extends$1=commonjsGlobal&&commonjsGlobal.__extends||(extendStatics=function(t,e){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},extendStatics(t,e)},function(t,e){function i(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),extendStatics;Object.defineProperty(arraymultimap,"__esModule",{value:!0}),arraymultimap.ArrayMultimap=void 0;var multimap_1$1=multimap,ArrayMultimap=function(t){function e(e){return t.call(this,new ArrayOperator,e)||this}return __extends$1(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"ArrayMultimap"},enumerable:!1,configurable:!0}),e}(multimap_1$1.Multimap);arraymultimap.ArrayMultimap=ArrayMultimap;var ArrayOperator=function(){function t(){}return t.prototype.create=function(){return[]},t.prototype.clone=function(t){return t.slice()},t.prototype.add=function(t,e){return e.push(t),!0},t.prototype.size=function(t){return t.length},t.prototype.delete=function(t,e){var i=e.indexOf(t);return i>-1&&(e.splice(i,1),!0)},t.prototype.has=function(t,e){return e.includes(t)},t}(),setmultimap={},__extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();Object.defineProperty(setmultimap,"__esModule",{value:!0}),setmultimap.SetMultimap=void 0;var multimap_1=multimap,SetMultimap=function(t){function e(e){return t.call(this,new SetOperator,e)||this}return __extends(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"SetMultimap"},enumerable:!1,configurable:!0}),e}(multimap_1.Multimap);setmultimap.SetMultimap=SetMultimap;var SetOperator=function(){function t(){}return t.prototype.create=function(){return new Set},t.prototype.clone=function(t){return new Set(t)},t.prototype.add=function(t,e){var i=e.size;return e.add(t),i!==e.size},t.prototype.size=function(t){return t.size},t.prototype.delete=function(t,e){return e.delete(t)},t.prototype.has=function(t,e){return e.has(t)},t}();!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SetMultimap=t.ArrayMultimap=void 0;var e=arraymultimap;Object.defineProperty(t,"ArrayMultimap",{enumerable:!0,get:function(){return e.ArrayMultimap}});var i=setmultimap;Object.defineProperty(t,"SetMultimap",{enumerable:!0,get:function(){return i.SetMultimap}})}(src);var TextureCache=function(t){this.cache=new src.ArrayMultimap,this.tinted=new Map,this.units=new Map,this.max_size=t||1/0,this.clear()};function createAtlas(t,e,i,o){return void 0===i&&(i="default"),void 0===o&&(o="no-repeat"),{meta:{app:"melonJS",size:{w:t,h:e},repeat:o,image:"default"},frames:[{filename:i,frame:{x:0,y:0,w:t,h:e}}]}}TextureCache.prototype.clear=function(){this.cache.clear(),this.tinted.clear(),this.units.clear(),this.length=0},TextureCache.prototype.validate=function(){if(this.length>=this.max_size)throw new Error("Texture cache overflow: "+this.max_size+" texture units available for this GPU.")},TextureCache.prototype.get=function(t,e){var i;return void 0===e?i=this.cache.get(t)[0]:this.cache.forEach((function(o,r){var n=o.getAtlas();r===t&&n[0].width===e.framewidth&&n[0].height===e.frameheight&&(i=o)})),void 0===i&&(e||(e=createAtlas(t.width,t.height,t.src?getBasename(t.src):void 0)),i=new TextureAtlas(e,t,!1),this.set(t,i)),i},TextureCache.prototype.delete=function(t){this.cache.has(t)||this.cache.delete(t)},TextureCache.prototype.tint=function(t,e){var i=this.tinted.get(t);return void 0===i&&(i=this.tinted.set(t,new Map)),i.has(e)||i.set(e,renderer.tint(t,e,"multiply")),i.get(e)},TextureCache.prototype.set=function(t,e){var i=t.width,o=t.height;if(!(1!==renderer.WebGLVersion||isPowerOfTwo(i)&&isPowerOfTwo(o))){var r=void 0!==t.src?t.src:t;console.warn("[Texture] "+r+" is not a POT texture ("+i+"x"+o+")")}return this.cache.put(t,e)},TextureCache.prototype.getUnit=function(t){return this.units.has(t)||(this.validate(),this.units.set(t,this.length++)),this.units.get(t)};var TextureAtlas=function(t,e,i){var o=this;if(this.format=null,this.sources=new Map,this.atlases=new Map,void 0!==t)for(var r in t=Array.isArray(t)?t:[t]){var n=t[r];if(void 0!==n.meta){if(n.meta.app.includes("texturepacker")||n.meta.app.includes("free-tex-packer")){if(this.format="texturepacker",void 0===e){var s=loader.getImage(n.meta.image);if(!s)throw new Error("Atlas texture '"+s+"' not found");this.sources.set(n.meta.image,s)}else this.sources.set(n.meta.image||"default","string"==typeof e?loader.getImage(e):e);this.repeat="no-repeat"}else if(n.meta.app.includes("ShoeBox")){if(!n.meta.exporter||!n.meta.exporter.includes("melonJS"))throw new Error("ShoeBox requires the JSON exporter : https://github.com/melonjs/melonJS/tree/master/media/shoebox_JSON_export.sbx");this.format="ShoeBox",this.repeat="no-repeat",this.sources.set("default","string"==typeof e?loader.getImage(e):e)}else n.meta.app.includes("melonJS")&&(this.format="melonJS",this.repeat=n.meta.repeat||"no-repeat",this.sources.set("default","string"==typeof e?loader.getImage(e):e));this.atlases.set(n.meta.image||"default",this.parse(n))}else void 0!==n.framewidth&&void 0!==n.frameheight&&(this.format="Spritesheet (fixed cell size)",this.repeat="no-repeat",void 0!==e&&(n.image="string"==typeof e?loader.getImage(e):e),this.atlases.set("default",this.parseFromSpriteSheet(n)),this.sources.set("default",n.image))}if(0===this.atlases.length)throw new Error("texture atlas format not supported");!1!==i&&this.sources.forEach((function(t){i instanceof TextureCache?i.set(t,o):renderer.cache.set(t,o)}))};TextureAtlas.prototype.parse=function(t){var e=this,i={};return t.frames.forEach((function(o){if(o.hasOwnProperty("filename")){var r,n,s=o.frame,a=o.spriteSourceSize&&o.sourceSize&&o.pivot;a&&(r=o.sourceSize.w*o.pivot.x-(o.trimmed?o.spriteSourceSize.x:0),n=o.sourceSize.h*o.pivot.y-(o.trimmed?o.spriteSourceSize.y:0)),i[o.filename]={name:o.filename,texture:t.meta.image||"default",offset:new Vector2d(s.x,s.y),anchorPoint:a?new Vector2d(r/s.w,n/s.h):null,trimmed:!!o.trimmed,width:s.w,height:s.h,angle:!0===o.rotated?-ETA:0},e.addUVs(i,o.filename,t.meta.size.w,t.meta.size.h)}})),i},TextureAtlas.prototype.parseFromSpriteSheet=function(t){var e={},i=t.image,o=t.spacing||0,r=t.margin||0,n=i.width,s=i.height,a=pool$1.pull("Vector2d",~~((n-r+o)/(t.framewidth+o)),~~((s-r+o)/(t.frameheight+o)));if(n%(t.framewidth+o)!=0||s%(t.frameheight+o)!=0){var l=a.x*(t.framewidth+o),h=a.y*(t.frameheight+o);l-n!==o&&h-s!==o&&(n=l,s=h,console.warn("Spritesheet Texture for image: "+i.src+" is not divisible by "+(t.framewidth+o)+"x"+(t.frameheight+o)+", truncating effective size to "+n+"x"+s))}for(var c=0,u=a.x*a.y;c<u;c++){var p=""+c;e[p]={name:p,texture:"default",offset:new Vector2d(r+(o+t.framewidth)*(c%a.x),r+(o+t.frameheight)*~~(c/a.x)),anchorPoint:t.anchorPoint||null,trimmed:!1,width:t.framewidth,height:t.frameheight,angle:0},this.addUVs(e,p,n,s)}return pool$1.push(a),e},TextureAtlas.prototype.getAtlas=function(t){return"string"==typeof t?this.atlases.get(t):this.atlases.values().next().value},TextureAtlas.prototype.getFormat=function(){return this.format},TextureAtlas.prototype.getTexture=function(t){return"object"==typeof t&&"string"==typeof t.texture?this.sources.get(t.texture):this.sources.values().next().value},TextureAtlas.prototype.addRegion=function(t,e,i,o,r){!0===renderer.settings.verbose&&console.warn("Adding texture region",t,"for texture",this);var n=this.getTexture(),s=this.getAtlas(),a=n.width,l=n.height;return s[t]={name:t,offset:new Vector2d(e,i),width:o,height:r,angle:0},this.addUVs(s,t,a,l),s[t]},TextureAtlas.prototype.getRegion=function(t,e){var i;return"string"==typeof e?i=this.getAtlas(e)[t]:this.atlases.forEach((function(e){void 0!==e[t]&&(i=e[t])})),i},TextureAtlas.prototype.getUVs=function(t){var e=this.getRegion(t);if(void 0===e){var i=t.split(","),o=+i[0],r=+i[1],n=+i[2],s=+i[3];e=this.addRegion(t,o,r,n,s)}return e.uvs},TextureAtlas.prototype.addUVs=function(t,e,i,o){if(renderer instanceof WebGLRenderer){var r=t[e].offset,n=t[e].width,s=t[e].height;t[e].uvs=new Float32Array([r.x/i,r.y/o,(r.x+n)/i,(r.y+s)/o]),t[r.x+","+r.y+","+i+","+o]=t[e]}return t[e].uvs},TextureAtlas.prototype.createSpriteFromName=function(t,e,i){return void 0===i&&(i=!1),pool$1.pull(!0===i?"me.NineSliceSprite":"me.Sprite",0,0,Object.assign({image:this,region:t},e||{}))},TextureAtlas.prototype.createAnimationFromName=function(t,e){for(var i,o=[],r={},n=0,s=0,a=0;a<t.length;++a){if(null==(i=this.getRegion(t[a])))throw new Error("Texture - region for "+t[a]+" not found");o[a]=i,r[t[a]]=a,n=Math.max(i.width,n),s=Math.max(i.height,s)}return new Sprite(0,0,Object.assign({image:this,framewidth:n,frameheight:s,margin:0,spacing:0,atlas:o,atlasIndices:r},e||{}))};var Sprite=function(t){function e(e,i,o){if(t.call(this,e,i,0,0),this.animationpause=!1,this.animationspeed=100,this.offset=pool$1.pull("Vector2d",0,0),this.source=null,this.anim={},this.resetAnim=void 0,this.current={name:"default",length:0,offset:pool$1.pull("Vector2d"),width:0,height:0,angle:0,idx:0},this.dt=0,this._flicker={isFlickering:!1,duration:0,callback:null,state:!1},o.image instanceof TextureAtlas){if(this.source=o.image,this.image=this.source.getTexture(),this.textureAtlas=o.image,void 0!==o.region){var r=this.source.getRegion(o.region);if(!r)throw new Error("Texture - region for "+o.region+" not found");this.setRegion(r),this.current.width=o.framewidth||r.width,this.current.height=o.frameheight||r.height}}else{if(this.image="object"==typeof o.image?o.image:loader.getImage(o.image),!this.image)throw new Error("me.Sprite: '"+o.image+"' image/texture not found!");this.current.width=o.framewidth=o.framewidth||this.image.width,this.current.height=o.frameheight=o.frameheight||this.image.height,this.source=renderer.cache.get(this.image,o),this.textureAtlas=this.source.getAtlas()}void 0!==o.atlas&&(this.textureAtlas=o.atlas,this.atlasIndices=o.atlasIndices),this.width=this.current.width,this.height=this.current.height,void 0!==o.flipX&&this.flipX(!!o.flipX),void 0!==o.flipY&&this.flipY(!!o.flipY),void 0!==o.rotation&&this.rotate(o.rotation),o.anchorPoint&&this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y),void 0!==o.tint&&this.tint.setColor(o.tint),"string"==typeof o.name&&(this.name=o.name),void 0!==o.z&&(this.pos.z=o.z),0!==this.addAnimation("default",null)&&this.setCurrentAnimation("default"),this.autoTransform=!0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isFlickering=function(){return this._flicker.isFlickering},e.prototype.flicker=function(t,e){return this._flicker.duration=t,this._flicker.duration<=0?(this._flicker.isFlickering=!1,this._flicker.callback=null):this._flicker.isFlickering||(this._flicker.callback=e,this._flicker.isFlickering=!0),this},e.prototype.addAnimation=function(t,e,i){this.anim[t]={name:t,frames:[],idx:0,length:0};var o=0;if("object"!=typeof this.textureAtlas)return 0;null==e&&(e=[],Object.keys(this.textureAtlas).forEach((function(t,i){e[i]=i})));for(var r=0,n=e.length;r<n;r++){var s,a=e[r],l=(s="number"==typeof a||"string"==typeof a?{name:a,delay:i||this.animationspeed}:a).name;if("number"==typeof l)void 0!==this.textureAtlas[l]&&(this.anim[t].frames[r]=Object.assign({},this.textureAtlas[l],s),o++);else{if(this.source.getFormat().includes("Spritesheet"))throw new Error("string parameters for addAnimation are not allowed for standard spritesheet based Texture");this.anim[t].frames[r]=Object.assign({},this.textureAtlas[this.atlasIndices[l]],s),o++}}return this.anim[t].length=o,o},e.prototype.setCurrentAnimation=function(t,e,i){if(!this.anim[t])throw new Error("animation id '"+t+"' not defined");return this.current.name=t,this.current.length=this.anim[this.current.name].length,this.resetAnim="string"==typeof e?this.setCurrentAnimation.bind(this,e,null,!0):"function"==typeof e?e:void 0,this.setAnimationFrame(this.current.idx),i||(this.dt=0),this.isDirty=!0,this},e.prototype.reverseAnimation=function(t){return void 0!==t&&void 0!==this.anim[t]?this.anim[t].frames.reverse():this.anim[this.current.name].frames.reverse(),this.isDirty=!0,this},e.prototype.isCurrentAnimation=function(t){return this.current.name===t},e.prototype.setRegion=function(t){return this.image=this.source.getTexture(t),this.current.offset.setV(t.offset),this.current.angle=t.angle,this.width=this.current.width=t.width,this.height=this.current.height=t.height,t.anchorPoint&&this.anchorPoint.set(this._flip.x&&!0===t.trimmed?1-t.anchorPoint.x:t.anchorPoint.x,this._flip.y&&!0===t.trimmed?1-t.anchorPoint.y:t.anchorPoint.y),this.isDirty=!0,this},e.prototype.setAnimationFrame=function(t){return this.current.idx=(t||0)%this.current.length,this.setRegion(this.getAnimationFrameObjectByIndex(this.current.idx))},e.prototype.getCurrentAnimationFrame=function(){return this.current.idx},e.prototype.getAnimationFrameObjectByIndex=function(t){return this.anim[this.current.name].frames[t]},e.prototype.update=function(e){if(!this.animationpause&&this.current&&this.current.length>0){var i=this.getAnimationFrameObjectByIndex(this.current.idx).delay;for(this.dt+=e;this.dt>=i;){this.isDirty=!0,this.dt-=i;var o=this.current.length>1?this.current.idx+1:this.current.idx;if(this.setAnimationFrame(o),0===this.current.idx&&"function"==typeof this.resetAnim&&!1===this.resetAnim()){this.setAnimationFrame(this.current.length-1),this.dt%=i;break}i=this.getAnimationFrameObjectByIndex(this.current.idx).delay}}return this._flicker.isFlickering&&(this._flicker.duration-=e,this._flicker.duration<0&&("function"==typeof this._flicker.callback&&this._flicker.callback(),this.flicker(-1)),this.isDirty=!0),t.prototype.update.call(this,e)},e.prototype.destroy=function(){pool$1.push(this.offset),this.offset=void 0,t.prototype.destroy.call(this)},e.prototype.draw=function(t){if(!this._flicker.isFlickering||(this._flicker.state=!this._flicker.state,this._flicker.state)){var e=this.current,i=this.pos.x,o=this.pos.y,r=e.width,n=e.height,s=e.offset,a=this.offset;0!==e.angle&&(t.translate(-i,-o),t.rotate(e.angle),i-=n,r=e.height,n=e.width),t.drawImage(this.image,a.x+s.x,a.y+s.y,r,n,i,o,r,n)}},e}(Renderable),TMX_FLIP_H=2147483648,TMX_FLIP_V=1073741824,TMX_FLIP_AD=536870912,TMX_CLEAR_BIT_MASK$1=536870911,Tile=function(t){function e(e,i,o,r){var n,s;if(t.call(this),r.isCollection){var a=r.getTileImage(o&TMX_CLEAR_BIT_MASK$1);n=a.width,s=a.height}else n=r.tilewidth,s=r.tileheight;this.setMinMax(0,0,n,s),this.tileset=r,this.currentTransform=null,this.col=e,this.row=i,this.tileId=o,this.flippedX=0!=(this.tileId&TMX_FLIP_H),this.flippedY=0!=(this.tileId&TMX_FLIP_V),this.flippedAD=0!=(this.tileId&TMX_FLIP_AD),this.flipped=this.flippedX||this.flippedY||this.flippedAD,!0===this.flipped&&(null===this.currentTransform&&(this.currentTransform=new Matrix2d),this.setTileTransform(this.currentTransform.identity())),this.tileId&=TMX_CLEAR_BIT_MASK$1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setTileTransform=function(t){t.translate(this.width/2,this.height/2),this.flippedAD&&(t.rotate(-90*Math.PI/180),t.scale(-1,1)),this.flippedX&&t.scale(this.flippedAD?1:-1,this.flippedAD?-1:1),this.flippedY&&t.scale(this.flippedAD?-1:1,this.flippedAD?1:-1),t.translate(-this.width/2,-this.height/2)},e.prototype.getRenderable=function(t){var e,i=this.tileset;if(i.animations.has(this.tileId)){var o=[],r=[];i.animations.get(this.tileId).frames.forEach((function(t){r.push(t.tileid),o.push({name:""+t.tileid,delay:t.duration})})),(e=i.texture.createAnimationFromName(r,t)).addAnimation(this.tileId-i.firstgid,o),e.setCurrentAnimation(this.tileId-i.firstgid)}else if(!0===i.isCollection){var n=i.getTileImage(this.tileId);(e=new Sprite(0,0,Object.assign({image:n}))).anchorPoint.set(0,0),e.scale(t.width/this.width,t.height/this.height),void 0!==t.rotation&&(e.anchorPoint.set(.5,.5),e.currentTransform.rotate(t.rotation),e.currentTransform.translate(t.width/2,t.height/2),t.rotation=void 0)}else(e=i.texture.createSpriteFromName(this.tileId-i.firstgid,t)).anchorPoint.set(0,0);return this.setTileTransform(e.currentTransform),e},e}(Bounds$1),RoundRect=function(t){function e(e,i,o,r,n){void 0===n&&(n=20),t.call(this,e,i,o,r),this.radius=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={radius:{configurable:!0}};return e.prototype.onResetEvent=function(e,i,o,r,n){t.prototype.setShape.call(this,e,i,o,r),this.radius=n},i.radius.get=function(){return this._radius},i.radius.set=function(t){this.width<2*t&&(t=this.width/2),this.height<2*t&&(t=this.height/2),this._radius=t},e.prototype.copy=function(e){return t.prototype.setShape.call(this,e.pos.x,e.pos.y,e.width,e.height),this.radius=e.radius,this},e.prototype.contains=function(){var e,i,o,r,n=arguments[0];if(2===arguments.length)e=n,i=arguments[1];else{if(n instanceof t)return t.prototype.contains.call(this,n);e=n.x,i=n.y}if(e<this.left||e>=this.right||i<this.top||i>=this.bottom)return!1;if(e>=this.left+this.radius&&e<=this.right-this.radius||i>=this.top+this.radius&&i<=this.bottom-this.radius)return!0;var s=Math.max(0,Math.min(this.radius,this.width/2)),a=Math.max(0,Math.min(this.radius,this.height/2));if(e<this.left+s&&i<this.top+a)o=e-this.left-s,r=i-this.top-a;else if(e>this.right-s&&i<this.top+a)o=e-this.right+s,r=i-this.top-a;else if(e>this.right-s&&i>this.bottom-a)o=e-this.right+s,r=i-this.bottom+a;else{if(!(e<this.left+s&&i>this.bottom-a))return!1;o=e-this.left-s,r=i-this.bottom+a}return o*o+r*r<=s*a},e.prototype.equals=function(e){return t.prototype.equals.call(this,e)&&this.radius===e.radius},e.prototype.clone=function(){return new e(this.pos.x,this.pos.y,this.width,this.height,radius)},Object.defineProperties(e.prototype,i),e}(Rect),Line=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.contains=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),t-=this.pos.x,e-=this.pos.y;var i=this.points[0],o=this.points[1];return(e-i.y)*(o.x-i.x)==(o.y-i.y)*(t-i.x)},e.prototype.recalc=function(){var t=this.edges,e=this.normals,i=this.indices,o=this.points;if(2!==o.length)throw new Error("Requires exactly 2 points");return void 0===t[0]&&(t[0]=pool$1.pull("Vector2d")),t[0].copy(o[1]).sub(o[0]),void 0===e[0]&&(e[0]=pool$1.pull("Vector2d")),e[0].copy(t[0]).perp().normalize(),i.length=0,this},e.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new e(this.pos.x,this.pos.y,t)},e}(Polygon),Path2D$1=function(){this.points=[],this.arcResolution=5,this.vertices=[]};Path2D$1.prototype.beginPath=function(){this.points.forEach((function(t){pool$1.push(t)})),this.points.length=0},Path2D$1.prototype.closePath=function(){var t=this.points;t.length>1&&!t[t.length-1].equals(t[0])&&t.push(pool$1.pull("Vector2d",t[0].x,t[0].y))},Path2D$1.prototype.triangulatePath=function(){var t=0,e=this.points,i=this.vertices,o=earcut$1.exports(e.flatMap((function(t){return[t.x,t.y]})));for(t=0;t<o.length;t++)void 0===i[t]&&(i[t]=pool$1.pull("Vector2d")),i[t].set(e[o[t]].x,e[o[t]].y);for(;i.length>o.length;)pool$1.push(i[i.length-1]),i.length-=1;return i},Path2D$1.prototype.moveTo=function(t,e){this.points.push(pool$1.pull("Vector2d",t,e))},Path2D$1.prototype.lineTo=function(t,e){this.points.push(pool$1.pull("Vector2d",t,e))},Path2D$1.prototype.arc=function(t,e,i,o,r,n){void 0===n&&(n=!1);var s=this.points;if(o!==r){var a=n?Math.abs(o-r)>=TAU:Math.abs(r-o)>=TAU;(o%=TAU)<0&&(o+=TAU),(r%=TAU)<0&&(r+=TAU),o>=r&&(r+=TAU);var l=r-o,h=1;n&&(h=-1,l=TAU-l),a&&(l=TAU);for(var c=l*i/this.arcResolution,u=l/c,p=o,d=0;d<c;d++)s.push(pool$1.pull("Vector2d",t+i*Math.cos(p),e+i*Math.sin(p))),p+=h*u;s.push(pool$1.pull("Vector2d",t+i*Math.cos(r),e+i*Math.sin(r)))}},Path2D$1.prototype.arcTo=function(t,e,i,o,r){var n=this.points,s=[n[n.length-1].x-t,n[n.length-1].y-e],a=[i-t,o-e],l=Math.sqrt(Math.pow(s[0],2)+Math.pow(s[1],2)),h=Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2));s[0]/=l,s[1]/=l,a[0]/=h,a[1]/=h;var c=Math.atan2(s[1],s[0])-Math.atan2(a[1],a[0]),u=r/Math.tan(c/2),p=[t+s[0]*u,e+s[1]*u],d=[t+a[0]*u,e+a[1]*u];n.push(pool$1.pull("Vector2d",p[0],p[1]));var f=[(s[0]+a[0])/2,(s[1]+a[1])/2],y=Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2));f[0]/=y,f[1]/=y;var g=Math.sqrt(Math.pow(r,2)+Math.pow(u,2)),v=[t+g*f[0],e+g*f[1]],m=Math.atan2(p[1]-v[1],p[0]-v[0]),_=Math.atan2(d[1]-v[1],d[0]-v[0]);this.arc(v[0],v[1],r,m,_)},Path2D$1.prototype.ellipse=function(t,e,i,o,r,n,s,a){void 0===a&&(a=!1);var l=this.points;if(n!==s){var h=a?Math.abs(n-s)>=TAU:Math.abs(s-n)>=TAU;(n%=TAU)<0&&(n+=TAU),(s%=TAU)<0&&(s+=TAU),n>=s&&(s+=TAU);var c=s-n,u=1;a&&(u=-1,c=TAU-c),h&&(c=TAU);for(var p=(c*i+c*o)/2/this.arcResolution,d=c/p,f=n,y=Math.cos(r),g=Math.sin(r),v=0;v<p;v++){var m=i*Math.cos(f),_=o*Math.sin(f),x=t+m*y-_*g,b=e+m*g+_*y;l.push(pool$1.pull("Vector2d",x,b)),f+=u*d}}},Path2D$1.prototype.rect=function(t,e,i,o){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+o),this.lineTo(t,e+o),this.lineTo(t,e)},Path2D$1.prototype.roundRect=function(t,e,i,o,r){this.moveTo(t+r,e),this.lineTo(t+i-r,e),this.arcTo(t+i,e,t+i,e+r,r),this.lineTo(t+i,e+o-r),this.arcTo(t+i,e+o,t+i-r,e+o,r),this.lineTo(t+r,e+o),this.arcTo(t,e+o,t,e+o-r,r),this.lineTo(t,e+r),this.arcTo(t,e,t+r,e,r)};var Renderer=function(t){this.settings=t,this.isContextValid=!0,this.path2D=new Path2D$1,this.currentScissor=new Int32Array([0,0,this.settings.width,this.settings.height]),this.currentBlendMode="none",!0===device$1.ejecta?this.canvas=document.getElementById("canvas"):void 0!==globalThis.canvas?this.canvas=globalThis.canvas:void 0!==this.settings.canvas?this.canvas=this.settings.canvas:this.canvas=createCanvas(this.settings.zoomX,this.settings.zoomY),this.backBufferCanvas=this.canvas,this.context=null,this.currentColor=new Color(0,0,0,1),this.currentTint=new Color(255,255,255,1),this.projectionMatrix=new Matrix3d,this.uvOffset=0,on(GAME_RESET,(function(){renderer.reset()}))};Renderer.prototype.clear=function(){},Renderer.prototype.reset=function(){this.resetTransform(),this.setBlendMode(this.settings.blendMode),this.setColor("#000000"),this.clearTint(),this.cache.clear(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height},Renderer.prototype.getCanvas=function(){return this.backBufferCanvas},Renderer.prototype.getScreenCanvas=function(){return this.canvas},Renderer.prototype.getScreenContext=function(){return this.context},Renderer.prototype.getBlendMode=function(){return this.currentBlendMode},Renderer.prototype.getContext2d=function(t,e){if(null==t)throw new Error("You must pass a canvas element in order to create a 2d context");if(void 0===t.getContext)throw new Error("Your browser does not support HTML5 canvas.");"boolean"!=typeof e&&(e=!0);var i=t.getContext("2d",{alpha:e});return i.canvas||(i.canvas=t),this.setAntiAlias(i,this.settings.antiAlias),i},Renderer.prototype.getWidth=function(){return this.backBufferCanvas.width},Renderer.prototype.getHeight=function(){return this.backBufferCanvas.height},Renderer.prototype.getColor=function(){return this.currentColor},Renderer.prototype.globalAlpha=function(){return this.currentColor.glArray[3]},Renderer.prototype.overlaps=function(t){return t.left<=this.getWidth()&&t.right>=0&&t.top<=this.getHeight()&&t.bottom>=0},Renderer.prototype.resize=function(t,e){t===this.backBufferCanvas.width&&e===this.backBufferCanvas.height||(this.canvas.width=this.backBufferCanvas.width=t,this.canvas.height=this.backBufferCanvas.height=e,this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=t,this.currentScissor[3]=e,emit(CANVAS_ONRESIZE,t,e))},Renderer.prototype.setAntiAlias=function(t,e){var i=t.canvas;setPrefixed("imageSmoothingEnabled",!0===e,t),!0!==e?(i.style["image-rendering"]="optimizeSpeed",i.style["image-rendering"]="-moz-crisp-edges",i.style["image-rendering"]="-o-crisp-edges",i.style["image-rendering"]="-webkit-optimize-contrast",i.style["image-rendering"]="optimize-contrast",i.style["image-rendering"]="crisp-edges",i.style["image-rendering"]="pixelated",i.style.msInterpolationMode="nearest-neighbor"):i.style["image-rendering"]="auto"},Renderer.prototype.setProjection=function(t){this.projectionMatrix.copy(t)},Renderer.prototype.stroke=function(t,e){if(t instanceof Rect||t instanceof Bounds$1)this.strokeRect(t.left,t.top,t.width,t.height,e);else if(t instanceof Line||t instanceof Polygon)this.strokePolygon(t,e);else if(t instanceof RoundRect)this.strokeRoundRect(t.left,t.top,t.width,t.height,t.radius,e);else{if(!(t instanceof Ellipse))throw new Error("Invalid geometry for fill/stroke");this.strokeEllipse(t.pos.x,t.pos.y,t.radiusV.x,t.radiusV.y,e)}},Renderer.prototype.fill=function(t){this.stroke(t,!0)},Renderer.prototype.tint=function(t,e,i){var o=createCanvas(t.width,t.height,!0),r=this.getContext2d(o);return r.save(),r.fillStyle=e instanceof Color?e.toRGB():e,r.fillRect(0,0,t.width,t.height),r.globalCompositeOperation=i||"multiply",r.drawImage(t,0,0),r.globalCompositeOperation="destination-atop",r.drawImage(t,0,0),r.restore(),o},Renderer.prototype.setMask=function(t){},Renderer.prototype.clearMask=function(){},Renderer.prototype.setTint=function(t,e){void 0===e&&(e=t.alpha),this.currentTint.copy(t),this.currentTint.alpha*=e},Renderer.prototype.clearTint=function(){this.currentTint.setColor(255,255,255,1)},Renderer.prototype.drawFont=function(){};var CanvasRenderer=function(t){function e(e){var i=this;t.call(this,e),this.context=this.getContext2d(this.getScreenCanvas(),this.settings.transparent),this.settings.doubleBuffering?(this.backBufferCanvas=createCanvas(this.settings.width,this.settings.height,!0),this.backBufferContext2D=this.getContext2d(this.backBufferCanvas)):(this.backBufferCanvas=this.getScreenCanvas(),this.backBufferContext2D=this.context),this.setBlendMode(this.settings.blendMode),this.setColor(this.currentColor),this.cache=new TextureCache,!1===this.settings.textureSeamFix||this.settings.antiAlias||(this.uvOffset=1),this.getScreenCanvas().addEventListener("contextlost",(function(t){t.preventDefault(),i.isContextValid=!1,event.emit(event.ONCONTEXT_LOST,i)}),!1),this.getScreenCanvas().addEventListener("contextrestored",(function(){i.isContextValid=!0,event.emit(event.ONCONTEXT_RESTORED,i)}),!1)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),this.clearColor(this.currentColor,!0!==this.settings.transparent)},e.prototype.resetTransform=function(){this.backBufferContext2D.setTransform(1,0,0,1,0,0)},e.prototype.setBlendMode=function(t,e){switch(void 0===t&&(t="normal"),e=e||this.getContext(),this.currentBlendMode=t,t){case"screen":e.globalCompositeOperation="screen";break;case"lighter":case"additive":e.globalCompositeOperation="lighter";break;case"multiply":e.globalCompositeOperation="multiply";break;default:e.globalCompositeOperation="source-over",this.currentBlendMode="normal"}this.settings.doubleBuffering&&this.settings.transparent&&(this.context.globalCompositeOperation="copy")},e.prototype.clear=function(){this.settings.transparent&&this.clearColor("rgba(0,0,0,0)",!0)},e.prototype.flush=function(){this.settings.doubleBuffering&&this.context.drawImage(this.backBufferCanvas,0,0)},e.prototype.clearColor=function(t,e){void 0===t&&(t="#000000"),this.save(),this.resetTransform(),this.backBufferContext2D.globalCompositeOperation=e?"copy":"source-over",this.backBufferContext2D.fillStyle=t instanceof Color?t.toRGBA():t,this.fillRect(0,0,this.backBufferCanvas.width,this.backBufferCanvas.height),this.restore()},e.prototype.clearRect=function(t,e,i,o){this.getContext().clearRect(t,e,i,o)},e.prototype.createPattern=function(t,e){return this.getContext().createPattern(t,e)},e.prototype.drawImage=function(t,e,i,o,r,n,s,a,l){if(!(this.getGlobalAlpha()<1/255)){var h=this.getContext();void 0===o?(o=a=t.width,r=l=t.height,n=e,s=i,e=0,i=0):void 0===n&&(n=e,s=i,a=o,l=r,o=t.width,r=t.height,e=0,i=0),!1===this.settings.subPixel&&(n=~~n,s=~~s);var c=t,u=this.currentTint.toArray();1===u[0]&&1===u[1]&&1===u[2]||(c=this.cache.tint(t,this.currentTint.toRGB())),h.drawImage(c,e,i,o,r,n,s,a,l)}},e.prototype.drawPattern=function(t,e,i,o,r){if(!(this.getGlobalAlpha()<1/255)){var n=this.getContext(),s=n.fillStyle;n.fillStyle=t,n.fillRect(e,i,o,r),n.fillStyle=s}},e.prototype.strokeArc=function(t,e,i,o,r,n,s){if(void 0===s&&(s=!1),!(this.getGlobalAlpha()<1/255)){var a=this.getContext();a.translate(t,e),a.beginPath(),a.arc(0,0,i,o,r,n||!1),a[!0===s?"fill":"stroke"](),a.translate(-t,-e)}},e.prototype.fillArc=function(t,e,i,o,r,n){this.strokeArc(t,e,i,o,r,n||!1,!0)},e.prototype.strokeEllipse=function(t,e,i,o,r){if(void 0===r&&(r=!1),!(this.getGlobalAlpha()<1/255)){var n=this.getContext(),s=t-i,a=t+i,l=e-o,h=e+o,c=.551784*i,u=.551784*o,p=t-c,d=t+c,f=e-u,y=e+u;n.beginPath(),n.moveTo(t,l),n.bezierCurveTo(d,l,a,f,a,e),n.bezierCurveTo(a,y,d,h,t,h),n.bezierCurveTo(p,h,s,y,s,e),n.bezierCurveTo(s,f,p,l,t,l),n[!0===r?"fill":"stroke"](),n.closePath()}},e.prototype.fillEllipse=function(t,e,i,o){this.strokeEllipse(t,e,i,o,!0)},e.prototype.strokeLine=function(t,e,i,o){this.getGlobalAlpha()<1/255||(context.beginPath(),context.moveTo(t,e),context.lineTo(i,o),context.stroke())},e.prototype.fillLine=function(t,e,i,o){this.strokeLine(t,e,i,o)},e.prototype.strokePolygon=function(t,e){if(void 0===e&&(e=!1),!(this.getGlobalAlpha()<1/255)){var i,o=this.getContext();this.translate(t.pos.x,t.pos.y),o.beginPath(),o.moveTo(t.points[0].x,t.points[0].y);for(var r=1;r<t.points.length;r++)i=t.points[r],o.lineTo(i.x,i.y);o.lineTo(t.points[0].x,t.points[0].y),o[!0===e?"fill":"stroke"](),o.closePath(),this.translate(-t.pos.x,-t.pos.y)}},e.prototype.fillPolygon=function(t){this.strokePolygon(t,!0)},e.prototype.strokeRect=function(t,e,i,o,r){(void 0===r&&(r=!1),this.getGlobalAlpha()<1/255)||this.getContext()[!0===r?"fillRect":"strokeRect"](t,e,i,o)},e.prototype.fillRect=function(t,e,i,o){this.strokeRect(t,e,i,o,!0)},e.prototype.strokeRoundRect=function(t,e,i,o,r,n){if(void 0===n&&(n=!1),!(this.getGlobalAlpha()<1/255)){var s=this.getContext();s.beginPath(),s.roundRect(t,e,i,o,r),s[!0===n?"fill":"stroke"]()}},e.prototype.fillRoundRect=function(t,e,i,o,r){this.strokeRoundRect(t,e,i,o,r,!0)},e.prototype.getContext=function(){return this.backBufferContext2D},e.prototype.getFontContext=function(){return this.getContext()},e.prototype.save=function(){this.backBufferContext2D.save()},e.prototype.restore=function(){this.backBufferContext2D.restore(),this.currentColor.glArray[3]=this.getGlobalAlpha(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height},e.prototype.rotate=function(t){this.backBufferContext2D.rotate(t)},e.prototype.scale=function(t,e){this.backBufferContext2D.scale(t,e)},e.prototype.setColor=function(t){this.backBufferContext2D.strokeStyle=this.backBufferContext2D.fillStyle=t instanceof Color?t.toRGBA():t},e.prototype.setGlobalAlpha=function(t){this.backBufferContext2D.globalAlpha=this.currentColor.glArray[3]=t},e.prototype.getGlobalAlpha=function(){return this.backBufferContext2D.globalAlpha},e.prototype.setLineWidth=function(t){this.backBufferContext2D.lineWidth=t},e.prototype.setTransform=function(t){this.resetTransform(),this.transform(t)},e.prototype.transform=function(t){var e=t.toArray(),i=e[0],o=e[1],r=e[3],n=e[4],s=e[6],a=e[7];!1===this.settings.subPixel&&(s|=0,a|=0),this.backBufferContext2D.transform(i,o,r,n,s,a)},e.prototype.translate=function(t,e){!1===this.settings.subPixel?this.backBufferContext2D.translate(~~t,~~e):this.backBufferContext2D.translate(t,e)},e.prototype.clipRect=function(t,e,i,o){var r=this.backBufferCanvas;if(0!==t||0!==e||i!==r.width||o!==r.height){var n=this.currentScissor;if(n[0]!==t||n[1]!==e||n[2]!==i||n[3]!==o){var s=this.backBufferContext2D;s.beginPath(),s.rect(t,e,i,o),s.clip(),n[0]=t,n[1]=e,n[2]=i,n[3]=o}}},e.prototype.setMask=function(t){var e=this.getContext(),i=t.pos.x,o=t.pos.y;if(e.save(),e.beginPath(),t instanceof Ellipse){var r=t.radiusV.x,n=t.radiusV.y,s=i-r,a=i+r,l=o-n,h=o+n,c=.551784*r,u=.551784*n,p=i-c,d=i+c,f=o-u,y=o+u;e.moveTo(i,l),e.bezierCurveTo(d,l,a,f,a,o),e.bezierCurveTo(a,y,d,h,i,h),e.bezierCurveTo(p,h,s,y,s,o),e.bezierCurveTo(s,f,p,l,i,l)}else if(t instanceof RoundRect)e.roundRect(i,o,t.width,t.height,t.radius);else{var g;e.moveTo(i+t.points[0].x,o+t.points[0].y);for(var v=1;v<t.points.length;v++)g=t.points[v],e.lineTo(i+g.x,o+g.y)}e.clip()},e.prototype.clearMask=function(){this.getContext().restore()},e}(Renderer);function initArray(t){t.layerData=new Array(t.cols);for(var e=0;e<t.cols;e++){t.layerData[e]=new Array(t.rows);for(var i=0;i<t.rows;i++)t.layerData[e][i]=null}}function setLayerData(t,e){var i=0;initArray(t);for(var o=0;o<t.rows;o++)for(var r=0;r<t.cols;r++){var n=e[i++];0!==n&&(t.layerData[r][o]=t.getTileById(n,r,o))}}function preRenderLayer(t,e){for(var i=0;i<t.rows;i++)for(var o=0;o<t.cols;o++){var r=t.layerData[o][i];r instanceof Tile&&t.getRenderer().drawTile(e,o,i,r)}}var TMXLayer=function(t){function e(e,i,o,r,n,s,a){t.call(this,0,0,0,0),this.tilewidth=i.tilewidth||o,this.tileheight=i.tileheight||r,this.orientation=n,this.tilesets=s,this.tileset=this.tilesets?this.tilesets.getTilesetByIndex(0):null,this.maxTileSize={width:0,height:0};for(var l=0;l<this.tilesets.length;l++){var h=this.tilesets.getTilesetByIndex(l);this.maxTileSize.width=Math.max(this.maxTileSize.width,h.tilewidth),this.maxTileSize.height=Math.max(this.maxTileSize.height,h.tileheight)}this.animatedTilesets=[],this.isAnimated=!1,this.renderorder=i.renderorder||"right-down",this.pos.z=a,this.anchorPoint.set(0,0),this.name=i.name,this.cols=+i.width,this.rows=+i.height;var c=void 0!==i.visible?+i.visible:1;this.setOpacity(c?+i.opacity:0),"string"==typeof i.tintcolor&&this.tint.parseHex(i.tintcolor,!0),"isometric"===this.orientation?(this.width=(this.cols+this.rows)*(this.tilewidth/2),this.height=(this.cols+this.rows)*(this.tileheight/2)):(this.width=this.cols*this.tilewidth,this.height=this.rows*this.tileheight),applyTMXProperties(this,i),void 0===this.preRender&&(this.preRender=world.preRender),this.setRenderer(e.getRenderer()),setLayerData(this,decode(i.data,i.encoding,i.compression))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onActivateEvent=function(){if(void 0===this.animatedTilesets&&(this.animatedTilesets=[]),this.tilesets)for(var t=this.tilesets.tilesets,e=0;e<t.length;e++)t[e].isAnimated&&this.animatedTilesets.push(t[e]);this.isAnimated=this.animatedTilesets.length>0,this.isAnimated&&(this.preRender=!1),this.getBounds().addBounds(this.getRenderer().getBounds(),!0),this.getBounds().shift(this.pos),!0!==this.preRender||this.canvasRenderer||(this.canvasRenderer=new CanvasRenderer({canvas:createCanvas(this.width,this.height),widht:this.width,heigth:this.height,transparent:!0}),preRenderLayer(this,this.canvasRenderer))},e.prototype.onDeactivateEvent=function(){this.animatedTilesets=void 0},e.prototype.setRenderer=function(t){this.renderer=t},e.prototype.getRenderer=function(){return this.renderer},e.prototype.getTileId=function(t,e){var i=this.getTile(t,e);return i?i.tileId:null},e.prototype.getTile=function(t,e){var i=null;if(this.contains(t,e)){var o=this.getRenderer().pixelToTileCoords(t,e,pool$1.pull("Vector2d"));i=this.cellAt(o.x,o.y),pool$1.push(o)}return i},e.prototype.setTile=function(t,e,i){return this.layerData[e][i]=t,t},e.prototype.getTileById=function(t,e,i){return this.tileset.contains(t)||(this.tileset=this.tilesets.getTilesetByGid(t)),new Tile(e,i,t,this.tileset)},e.prototype.cellAt=function(t,e,i){var o=~~t,r=~~e,n=this.getRenderer();return!1===i||o>=0&&o<n.cols&&r>=0&&r<n.rows?this.layerData[o][r]:null},e.prototype.clearTile=function(t,e){this.layerData[t][e]=null,this.preRender&&this.canvasRenderer.clearRect(t*this.tilewidth,e*this.tileheight,this.tilewidth,this.tileheight)},e.prototype.update=function(t){if(this.isAnimated){for(var e=!1,i=0;i<this.animatedTilesets.length;i++)e=this.animatedTilesets[i].update(t)||e;return e}return!1},e.prototype.draw=function(t,e){if(this.preRender){var i=Math.min(e.width,this.width),o=Math.min(e.height,this.height);t.drawImage(this.canvasRenderer.getCanvas(),e.pos.x,e.pos.y,i,o,e.pos.x,e.pos.y,i,o)}else this.getRenderer().drawTileLayer(t,this,e)},e}(Renderable),Bounds=function(t){this._center=new Vector2d,this.onResetEvent(t)},prototypeAccessors={x:{configurable:!0},y:{configurable:!0},width:{configurable:!0},height:{configurable:!0},left:{configurable:!0},right:{configurable:!0},top:{configurable:!0},bottom:{configurable:!0},centerX:{configurable:!0},centerY:{configurable:!0},center:{configurable:!0}};Bounds.prototype.onResetEvent=function(t){void 0===this.min?(this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0}):this.clear(),void 0!==t&&this.update(t)},Bounds.prototype.clear=function(){this.setMinMax(1/0,1/0,-1/0,-1/0)},Bounds.prototype.setMinMax=function(t,e,i,o){this.min.x=t,this.min.y=e,this.max.x=i,this.max.y=o},prototypeAccessors.x.get=function(){return this.min.x},prototypeAccessors.x.set=function(t){var e=this.max.x-this.min.x;this.min.x=t,this.max.x=t+e},prototypeAccessors.y.get=function(){return this.min.y},prototypeAccessors.y.set=function(t){var e=this.max.y-this.min.y;this.min.y=t,this.max.y=t+e},prototypeAccessors.width.get=function(){return this.max.x-this.min.x},prototypeAccessors.width.set=function(t){this.max.x=this.min.x+t},prototypeAccessors.height.get=function(){return this.max.y-this.min.y},prototypeAccessors.height.set=function(t){this.max.y=this.min.y+t},prototypeAccessors.left.get=function(){return this.min.x},prototypeAccessors.right.get=function(){return this.max.x},prototypeAccessors.top.get=function(){return this.min.y},prototypeAccessors.bottom.get=function(){return this.max.y},prototypeAccessors.centerX.get=function(){return this.min.x+this.width/2},prototypeAccessors.centerY.get=function(){return this.min.y+this.height/2},prototypeAccessors.center.get=function(){return this._center.set(this.centerX,this.centerY)},Bounds.prototype.update=function(t){this.add(t,!0)},Bounds.prototype.add=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear();for(var i=0;i<t.length;i++){var o=t[i];o.x>this.max.x&&(this.max.x=o.x),o.x<this.min.x&&(this.min.x=o.x),o.y>this.max.y&&(this.max.y=o.y),o.y<this.min.y&&(this.min.y=o.y)}},Bounds.prototype.addBounds=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear(),t.max.x>this.max.x&&(this.max.x=t.max.x),t.min.x<this.min.x&&(this.min.x=t.min.x),t.max.y>this.max.y&&(this.max.y=t.max.y),t.min.y<this.min.y&&(this.min.y=t.min.y)},Bounds.prototype.addPoint=function(t,e){void 0!==e&&(t=e.apply(t)),this.min.x=Math.min(this.min.x,t.x),this.max.x=Math.max(this.max.x,t.x),this.min.y=Math.min(this.min.y,t.y),this.max.y=Math.max(this.max.y,t.y)},Bounds.prototype.addFrame=function(t,e,i,o,r){var n=me.pool.pull("Vector2d");this.addPoint(n.set(t,e),r),this.addPoint(n.set(i,e),r),this.addPoint(n.set(t,o),r),this.addPoint(n.set(i,o),r),me.pool.push(n)},Bounds.prototype.contains=function(){var t,e,i,o,r=arguments[0];return 2===arguments.length?(t=e=r,i=o=arguments[1]):r instanceof Bounds?(t=r.min.x,e=r.max.x,i=r.min.y,o=r.max.y):(t=e=r.x,i=o=r.y),t>=this.min.x&&e<=this.max.x&&i>=this.min.y&&o<=this.max.y},Bounds.prototype.overlaps=function(t){return!(this.right<t.left||this.left>t.right||this.bottom<t.top||this.top>t.bottom)},Bounds.prototype.isFinite=function(){return isFinite(this.min.x)&&isFinite(this.max.x)&&isFinite(this.min.y)&&isFinite(this.max.y)},Bounds.prototype.translate=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.min.x+=t,this.max.x+=t,this.min.y+=e,this.max.y+=e},Bounds.prototype.shift=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y);var i=this.max.x-this.min.x,o=this.max.y-this.min.y;this.min.x=t,this.max.x=t+i,this.min.y=e,this.max.y=e+o},Bounds.prototype.clone=function(){var t=new Bounds;return t.addBounds(this),t},Bounds.prototype.toPolygon=function(){return pool$1.pull("Polygon",this.x,this.y,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height),pool$1.pull("Vector2d",0,this.height)])},Object.defineProperties(Bounds.prototype,prototypeAccessors);var TMXRenderer=function(t,e,i,o){this.cols=t,this.rows=e,this.tilewidth=i,this.tileheight=o,this.bounds=new Bounds};TMXRenderer.prototype.canRender=function(t){return this.tilewidth===t.tilewidth&&this.tileheight===t.tileheight},TMXRenderer.prototype.getBounds=function(t){var e=t instanceof TMXLayer?pool$1.pull("Bounds"):this.bounds;return e.setMinMax(0,0,this.cols*this.tilewidth,this.rows*this.tileheight),e},TMXRenderer.prototype.pixelToTileCoords=function(t,e,i){return i},TMXRenderer.prototype.tileToPixelCoords=function(t,e,i){return i},TMXRenderer.prototype.drawTile=function(t,e,i,o){},TMXRenderer.prototype.drawTileLayer=function(t,e,i){};var TMXOrthogonalRenderer=function(t){function e(e){t.call(this,e.cols,e.rows,e.tilewidth,e.tileheight)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"orthogonal"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.pixelToTileCoords=function(t,e,i){return(i||new Vector2d).set(t/this.tilewidth,e/this.tileheight)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new Vector2d).set(t*this.tilewidth,e*this.tileheight)},e.prototype.adjustPosition=function(t){"number"==typeof t.gid&&(t.y-=t.height)},e.prototype.drawTile=function(t,e,i,o){var r=o.tileset;r.drawTile(t,r.tileoffset.x+e*this.tilewidth,r.tileoffset.y+(i+1)*this.tileheight-r.tileheight,o)},e.prototype.drawTileLayer=function(t,e,i){var o=1,r=1,n=this.pixelToTileCoords(Math.max(i.pos.x-(e.maxTileSize.width-e.tilewidth),0),Math.max(i.pos.y-(e.maxTileSize.height-e.tileheight),0),pool$1.pull("Vector2d")).floorSelf(),s=this.pixelToTileCoords(i.pos.x+i.width+this.tilewidth,i.pos.y+i.height+this.tileheight,pool$1.pull("Vector2d")).ceilSelf();switch(s.x=s.x>this.cols?this.cols:s.x,s.y=s.y>this.rows?this.rows:s.y,e.renderorder){case"right-up":s.y=n.y+(n.y=s.y)-s.y,r=-1;break;case"left-down":s.x=n.x+(n.x=s.x)-s.x,o=-1;break;case"left-up":s.x=n.x+(n.x=s.x)-s.x,s.y=n.y+(n.y=s.y)-s.y,o=-1,r=-1}for(var a=n.y;a!==s.y;a+=r)for(var l=n.x;l!==s.x;l+=o){var h=e.cellAt(l,a,!1);h&&this.drawTile(t,l,a,h)}pool$1.push(n),pool$1.push(s)},e}(TMXRenderer),TMXIsometricRenderer=function(t){function e(e){t.call(this,e.cols,e.rows,e.tilewidth,e.tileheight),this.hTilewidth=this.tilewidth/2,this.hTileheight=this.tileheight/2,this.originX=this.rows*this.hTilewidth}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"isometric"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.getBounds=function(t){var e=t instanceof TMXLayer?pool$1.pull("Bounds"):this.bounds;return e.setMinMax(0,0,(this.cols+this.rows)*(this.tilewidth/2),(this.cols+this.rows)*(this.tileheight/2)),e},e.prototype.pixelToTileCoords=function(t,e,i){return(i||new Vector2d).set(e/this.tileheight+(t-this.originX)/this.tilewidth,e/this.tileheight-(t-this.originX)/this.tilewidth)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new Vector2d).set((t-e)*this.hTilewidth+this.originX,(t+e)*this.hTileheight)},e.prototype.adjustPosition=function(t){var e=t.x/this.hTilewidth,i=t.y/this.tileheight,o=pool$1.pull("Vector2d");this.tileToPixelCoords(e,i,o),t.x=o.x,t.y=o.y,pool$1.push(o)},e.prototype.drawTile=function(t,e,i,o){var r=o.tileset;r.drawTile(t,(this.cols-1)*r.tilewidth+(e-i)*r.tilewidth>>1,-r.tilewidth+(e+i)*r.tileheight>>2,o)},e.prototype.drawTileLayer=function(t,e,i){var o=e.tileset,r=this.pixelToTileCoords(i.pos.x-o.tilewidth,i.pos.y-o.tileheight,pool$1.pull("Vector2d")).floorSelf(),n=this.pixelToTileCoords(i.pos.x+i.width+o.tilewidth,i.pos.y+i.height+o.tileheight,pool$1.pull("Vector2d")).ceilSelf(),s=this.tileToPixelCoords(n.x,n.y,pool$1.pull("Vector2d")),a=this.tileToPixelCoords(r.x,r.y,pool$1.pull("Vector2d"));a.x-=this.hTilewidth,a.y+=this.tileheight;var l=a.y-i.pos.y>this.hTileheight,h=i.pos.x-a.x<this.hTilewidth;l&&(h?(r.x--,a.x-=this.hTilewidth):(r.y--,a.x+=this.hTilewidth),a.y-=this.hTileheight);for(var c=l^h,u=r.clone(),p=2*a.y;p-2*this.tileheight<2*s.y;p+=this.tileheight){u.setV(r);for(var d=a.x;d<s.x;d+=this.tilewidth){var f=e.cellAt(u.x,u.y);if(f){var y=(o=f.tileset).tileoffset;o.drawTile(t,y.x+d,y.y+p/2-o.tileheight,f)}u.x++,u.y--}c?(r.y++,a.x-=this.hTilewidth,c=!1):(r.x++,a.x+=this.hTilewidth,c=!0)}pool$1.push(u),pool$1.push(r),pool$1.push(n),pool$1.push(s),pool$1.push(a)},e}(TMXRenderer),offsetsStaggerX=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],offsetsStaggerY=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}],TMXHexagonalRenderer=function(t){function e(e){t.call(this,e.cols,e.rows,-2&e.tilewidth,-2&e.tileheight),this.hexsidelength=e.hexsidelength||0,this.staggerX="x"===e.staggeraxis,this.staggerEven="even"===e.staggerindex,this.sidelengthx=0,this.sidelengthy=0,"hexagonal"===e.orientation&&(this.staggerX?this.sidelengthx=this.hexsidelength:this.sidelengthy=this.hexsidelength),this.sideoffsetx=(this.tilewidth-this.sidelengthx)/2,this.sideoffsety=(this.tileheight-this.sidelengthy)/2,this.columnwidth=this.sideoffsetx+this.sidelengthx,this.rowheight=this.sideoffsety+this.sidelengthy,this.centers=[new Vector2d,new Vector2d,new Vector2d,new Vector2d]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"hexagonal"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.getBounds=function(t){var e=t instanceof TMXLayer?pool$1.pull("Bounds"):this.bounds;return this.staggerX?(e.setMinMax(0,0,this.cols*this.columnwidth+this.sideoffsetx,this.rows*(this.tileheight+this.sidelengthy)),e.width>1&&(e.height+=this.rowheight)):(e.setMinMax(0,0,this.cols*(this.tilewidth+this.sidelengthx),this.rows*this.rowheight+this.sideoffsety),e.height>1&&(e.width+=this.columnwidth)),e},e.prototype.doStaggerX=function(t){return this.staggerX&&1&t^this.staggerEven},e.prototype.doStaggerY=function(t){return!this.staggerX&&1&t^this.staggerEven},e.prototype.topLeft=function(t,e,i){var o=i||new Vector2d;return this.staggerX?1&t^this.staggerEven?o.set(t-1,e):o.set(t-1,e-1):1&e^this.staggerEven?o.set(t,e-1):o.set(t-1,e-1),o},e.prototype.topRight=function(t,e,i){var o=i||new Vector2d;return this.staggerX?1&t^this.staggerEven?o.set(t+1,e):o.set(t+1,e-1):1&e^this.staggerEven?o.set(t+1,e-1):o.set(t,e-1),o},e.prototype.bottomLeft=function(t,e,i){var o=i||new Vector2d;return this.staggerX?1&t^this.staggerEven?o.set(t-1,e+1):o.set(t-1,e):1&e^this.staggerEven?o.set(t,e+1):o.set(t-1,e+1),o},e.prototype.bottomRight=function(t,e,i){var o=i||new Vector2d;return this.staggerX?1&t^this.staggerEven?o.set(t+1,e+1):o.set(t+1,e):1&e^this.staggerEven?o.set(t+1,e+1):o.set(t,e+1),o},e.prototype.pixelToTileCoords=function(t,e,i){var o=i||new Vector2d;this.staggerX?t-=this.staggerEven?this.tilewidth:this.sideoffsetx:e-=this.staggerEven?this.tileheight:this.sideoffsety;var r,n,s,a,l=pool$1.pull("Vector2d",Math.floor(t/(2*this.columnwidth)),Math.floor(e/(2*this.rowheight))),h=pool$1.pull("Vector2d",t-l.x*(2*this.columnwidth),e-l.y*(2*this.rowheight));this.staggerX?(l.x=2*l.x,this.staggerEven&&++l.x):(l.y=2*l.y,this.staggerEven&&++l.y),this.staggerX?(s=(r=this.sidelengthx/2)+this.columnwidth,a=this.tileheight/2,this.centers[0].set(r,a),this.centers[1].set(s,a-this.rowheight),this.centers[2].set(s,a+this.rowheight),this.centers[3].set(s+this.columnwidth,a)):(n=this.sidelengthy/2,s=this.tilewidth/2,a=n+this.rowheight,this.centers[0].set(s,n),this.centers[1].set(s-this.columnwidth,a),this.centers[2].set(s+this.columnwidth,a),this.centers[3].set(s,a+this.rowheight));for(var c=0,u=Number.MAX_VALUE,p=0;p<4;++p){var d=this.centers[p].sub(h).length2();d<u&&(u=d,c=p)}var f=this.staggerX?offsetsStaggerX:offsetsStaggerY;return o.set(l.x+f[c].x,l.y+f[c].y),pool$1.push(l),pool$1.push(h),o},e.prototype.tileToPixelCoords=function(t,e,i){var o=Math.floor(t),r=Math.floor(e),n=i||new Vector2d;return this.staggerX?(n.y=r*(this.tileheight+this.sidelengthy),this.doStaggerX(o)&&(n.y+=this.rowheight),n.x=o*this.columnwidth):(n.x=o*(this.tilewidth+this.sidelengthx),this.doStaggerY(r)&&(n.x+=this.columnwidth),n.y=r*this.rowheight),n},e.prototype.adjustPosition=function(t){"number"==typeof t.gid&&(t.y-=t.height)},e.prototype.drawTile=function(t,e,i,o){var r=o.tileset,n=this.tileToPixelCoords(e,i,pool$1.pull("Vector2d"));r.drawTile(t,r.tileoffset.x+n.x,r.tileoffset.y+n.y+(this.tileheight-r.tileheight),o),pool$1.push(n)},e.prototype.drawTileLayer=function(t,e,i){var o,r=this.pixelToTileCoords(i.pos.x,i.pos.y,pool$1.pull("Vector2d"));r.sub(e.pos);var n=this.tileToPixelCoords(r.x+e.pos.x,r.y+e.pos.y,pool$1.pull("Vector2d")),s=r.clone(),a=n.clone(),l=i.pos.y-n.y<this.sideoffsety,h=i.pos.x-n.x<this.sideoffsetx;l&&r.y--,h&&r.x--;var c=e.cols,u=e.rows;if(this.staggerX){r.x=Math.max(0,r.x),r.y=Math.max(0,r.y),n=this.tileToPixelCoords(r.x+e.pos.x,r.y+e.pos.y);for(var p=this.doStaggerX(r.x+e.pos.x);n.y<i.bottom&&r.y<u;){for(s.setV(r),a.setV(n);a.x<i.right&&s.x<c;s.x+=2)(o=e.cellAt(s.x,s.y,!1))&&o.tileset.drawTile(t,a.x,a.y,o),a.x+=this.tilewidth+this.sidelengthx;p?(r.x-=1,r.y+=1,n.x-=this.columnwidth,p=!1):(r.x+=1,n.x+=this.columnwidth,p=!0),n.y+=this.rowheight}pool$1.push(s),pool$1.push(a)}else{for(r.x=Math.max(0,r.x),r.y=Math.max(0,r.y),n=this.tileToPixelCoords(r.x+e.pos.x,r.y+e.pos.y),this.doStaggerY(r.y)&&(n.x-=this.columnwidth);n.y<i.bottom&&r.y<u;r.y++){for(s.setV(r),a.setV(n),this.doStaggerY(r.y)&&(a.x+=this.columnwidth);a.x<i.right&&s.x<c;s.x++)(o=e.cellAt(s.x,s.y,!1))&&o.tileset.drawTile(t,a.x,a.y,o),a.x+=this.tilewidth+this.sidelengthx;n.y+=this.rowheight}pool$1.push(s),pool$1.push(a)}pool$1.push(r),pool$1.push(n)},e}(TMXRenderer),TMXStaggeredRenderer=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"staggered"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.pixelToTileCoords=function(t,e,i){var o=i||new Vector2d,r=t,n=e;this.staggerX?r-=this.staggerEven?this.sideoffsetx:0:n-=this.staggerEven?this.sideoffsety:0;var s=pool$1.pull("Vector2d",Math.floor(r/this.tilewidth),Math.floor(n/this.tileheight));this.staggerX?(s.x=2*s.x,this.staggerEven&&++s.x):(s.y=2*s.y,this.staggerEven&&++s.y);var a=pool$1.pull("Vector2d",r-s.x*this.tilewidth,n-s.y*this.tileheight),l=a.x*(this.tileheight/this.tilewidth);return this.sideoffsety-l>a.y&&(s=this.topLeft(s.x,s.y,s)),-this.sideoffsety+l>a.y&&(s=this.topRight(s.x,s.y,s)),this.sideoffsety+l<a.y&&(s=this.bottomLeft(s.x,s.y,s)),3*this.sideoffsety-l<a.y&&(s=this.bottomRight(s.x,s.y,s)),(o=this.tileToPixelCoords(s.x,s.y,o)).set(t-o.x,e-o.y),o.set(o.x-this.tilewidth/2,o.y*(this.tilewidth/this.tileheight)),o.div(this.tilewidth/Math.sqrt(2)).rotate(degToRad(-45)).add(s),pool$1.push(s),pool$1.push(a),o},e}(TMXHexagonalRenderer),TMXTileset=function(t){var e=0;if(this.TileProperties=[],this.imageCollection=[],this.firstgid=this.lastgid=+t.firstgid,void 0!==t.source){var i=t.source,o=getExtension(i);if(("tsx"===o||"json"===o)&&!(t=loader.getTMX(getBasename(i))))throw new Error(i+" external TSX/JSON tileset not found")}this.name=t.name,this.tilewidth=+t.tilewidth,this.tileheight=+t.tileheight,this.spacing=+t.spacing||0,this.margin=+t.margin||0,this.tileoffset=new Vector2d,this.isAnimated=!1,this.isCollection=!1,this.animations=new Map,this._lastUpdate=0;var r=t.tiles;for(e in r)if(r.hasOwnProperty(e)){if("animation"in r[e]&&(this.isAnimated=!0,this.animations.set(r[+e].animation[0].tileid,{dt:0,idx:0,frames:r[+e].animation,cur:r[+e].animation[0]})),"properties"in r[e])if(Array.isArray(r[e].properties)){var n={};for(var s in r[e].properties)n[r[e].properties[s].name]=r[e].properties[s].value;this.setTileProperty(+r[e].id+this.firstgid,n)}else this.setTileProperty(+e+this.firstgid,r[e].properties);if("image"in r[e]){var a=loader.getImage(r[e].image);if(!a)throw new Error("melonJS: '"+r[e].image+"' file for tile '"+(+e+this.firstgid)+"' not found!");this.imageCollection[+e+this.firstgid]=a}}this.isCollection=this.imageCollection.length>0;var l=t.tileoffset;l&&(this.tileoffset.x=+l.x,this.tileoffset.y=+l.y);var h=t.tileproperties;if(h)for(e in h)h.hasOwnProperty(e)&&this.setTileProperty(+e+this.firstgid,h[e]);if(!1===this.isCollection){if(this.image=loader.getImage(t.image),!this.image)throw new Error("melonJS: '"+t.image+"' file for tileset '"+this.name+"' not found!");this.texture=renderer.cache.get(this.image,{framewidth:this.tilewidth,frameheight:this.tileheight,margin:this.margin,spacing:this.spacing}),this.atlas=this.texture.getAtlas();var c=+t.columns||Math.round(this.image.width/(this.tilewidth+this.spacing)),u=Math.round(this.image.height/(this.tileheight+this.spacing));t.tilecount%c>0&&++u,this.lastgid=this.firstgid+(c*u-1||0),t.tilecount&&this.lastgid-this.firstgid+1!=+t.tilecount&&console.warn("Computed tilecount ("+(this.lastgid-this.firstgid+1)+") does not match expected tilecount ("+t.tilecount+")")}};TMXTileset.prototype.getTileImage=function(t){return this.imageCollection[t]},TMXTileset.prototype.setTileProperty=function(t,e){this.TileProperties[t]=e},TMXTileset.prototype.contains=function(t){return t>=this.firstgid&&t<=this.lastgid},TMXTileset.prototype.getViewTileId=function(t){var e=t-this.firstgid;return this.animations.has(e)?this.animations.get(e).cur.tileid:e},TMXTileset.prototype.getTileProperties=function(t){return this.TileProperties[t]},TMXTileset.prototype.update=function(t){var e=0,i=timer$1.getTime(),o=!1;return this._lastUpdate!==i&&(this._lastUpdate=i,this.animations.forEach((function(i){for(i.dt+=t,e=i.cur.duration;i.dt>=e;)i.dt-=e,i.idx=(i.idx+1)%i.frames.length,i.cur=i.frames[i.idx],e=i.cur.duration,o=!0}))),o},TMXTileset.prototype.drawTile=function(t,e,i,o){if(o.flipped&&(t.save(),t.translate(e,i),t.transform(o.currentTransform),e=i=0),!0===this.isCollection)t.drawImage(this.imageCollection[o.tileId],0,0,o.width,o.height,e,i,o.width,o.height);else{var r=this.atlas[this.getViewTileId(o.tileId)].offset;t.drawImage(this.image,r.x,r.y,this.tilewidth,this.tileheight,e,i,this.tilewidth+t.uvOffset,this.tileheight+t.uvOffset)}o.flipped&&t.restore()};var TMX_CLEAR_BIT_MASK=536870911,TMXTilesetGroup=function(){this.tilesets=[],this.length=0};TMXTilesetGroup.prototype.add=function(t){this.tilesets.push(t),this.length++},TMXTilesetGroup.prototype.getTilesetByIndex=function(t){return this.tilesets[t]},TMXTilesetGroup.prototype.getTilesetByGid=function(t){var e=-1;t&=TMX_CLEAR_BIT_MASK;for(var i=0,o=this.tilesets.length;i<o;i++){if(this.tilesets[i].contains(t))return this.tilesets[i];this.tilesets[i].firstgid===this.tilesets[i].lastgid&&t>=this.tilesets[i].firstgid&&(e=i)}if(-1!==e)return this.tilesets[e];throw new Error("no matching tileset found for gid "+t)};var TMXObject=function(t,e,i){this.points=void 0,this.name=e.name,this.x=+e.x,this.y=+e.y,this.z=+i,this.width=+e.width||0,this.height=+e.height||0,this.gid=+e.gid||null,this.tintcolor=e.tintcolor,this.type=e.type,this.type=e.type,this.rotation=degToRad(+e.rotation||0),this.id=+e.id||void 0,this.orientation=t.orientation,this.shapes=void 0,this.isEllipse=!1,this.isPolygon=!1,this.isPolyLine=!1,"number"==typeof this.gid?this.setTile(t.tilesets):void 0!==e.ellipse?this.isEllipse=!0:void 0!==e.polygon?(this.points=e.polygon,this.isPolygon=!0):void 0!==e.polyline&&(this.points=e.polyline,this.isPolyLine=!0),void 0!==e.text?(this.text=e.text,this.text.font=e.text.fontfamily||"sans-serif",this.text.size=e.text.pixelsize||16,this.text.fillStyle=e.text.color||"#000000",this.text.textAlign=e.text.halign||"left",this.text.textBaseline=e.text.valign||"top",this.text.width=this.width,this.text.height=this.height,applyTMXProperties(this.text,e)):(applyTMXProperties(this,e),this.shapes||(this.shapes=this.parseTMXShapes())),t.isEditor||t.getRenderer().adjustPosition(this)};TMXObject.prototype.setTile=function(t){var e=t.getTilesetByGid(this.gid);!1===e.isCollection&&(this.width=this.framewidth=e.tilewidth,this.height=this.frameheight=e.tileheight),this.tile=new Tile(this.x,this.y,this.gid,e)},TMXObject.prototype.parseTMXShapes=function(){var t=0,e=[];if(!0===this.isEllipse)e.push(pool$1.pull("Ellipse",this.width/2,this.height/2,this.width,this.height).rotate(this.rotation));else if(!0===this.isPolygon){var i=pool$1.pull("Polygon",0,0,this.points);if(!1===i.isConvex())throw new Error("collision polygones in Tiled should be defined as Convex");e.push(i.rotate(this.rotation))}else if(!0===this.isPolyLine){var o,r,n=this.points,s=n.length-1;for(t=0;t<s;t++)o=pool$1.pull("Vector2d",n[t].x,n[t].y),r=pool$1.pull("Vector2d",n[t+1].x,n[t+1].y),0!==this.rotation&&(o=o.rotate(this.rotation),r=r.rotate(this.rotation)),e.push(pool$1.pull("Line",0,0,[o,r]))}else e.push(pool$1.pull("Polygon",0,0,[pool$1.pull("Vector2d"),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height),pool$1.pull("Vector2d",0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(t=0;t<e.length;t++)e[t].toIso();return e},TMXObject.prototype.getObjectPropertyByName=function(t){return this[t]};var TMXGroup=function(t,e,i){var o=this;this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.tintcolor=e.tintcolor,this.z=i,this.objects=[];var r=void 0===e.visible||e.visible;this.opacity=!0===r?clamp(+e.opacity||1,0,1):0,applyTMXProperties(this,e),e.objects&&e.objects.forEach((function(e){e.tintcolor=o.tintcolor,o.objects.push(new TMXObject(t,e,i))})),e.layers&&e.layers.forEach((function(e){var r=new TMXLayer(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i++);r.setRenderer(t.getRenderer()),o.width=Math.max(o.width,r.width),o.height=Math.max(o.height,r.height),o.objects.push(r)}))};TMXGroup.prototype.destroy=function(){this.objects=null},TMXGroup.prototype.getObjectCount=function(){return this.objects.length},TMXGroup.prototype.getObjectByIndex=function(t){return this.objects[t]};var COLLISION_GROUP="collision";function getNewDefaultRenderer(t){switch(t.orientation){case"orthogonal":return new TMXOrthogonalRenderer(t);case"isometric":return new TMXIsometricRenderer(t);case"hexagonal":return new TMXHexagonalRenderer(t);case"staggered":return new TMXStaggeredRenderer(t);default:throw new Error(t.orientation+" type TMX Tile Map not supported!")}}function readLayer(t,e,i){return new TMXLayer(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i)}function readImageLayer(t,e,i){applyTMXProperties(e.properties,e);var o=pool$1.pull("ImageLayer",+e.offsetx||+e.x||0,+e.offsety||+e.y||0,Object.assign({name:e.name,image:e.image,ratio:pool$1.pull("Vector2d",+e.parallaxx||1,+e.parallaxy||1),tint:void 0!==e.tintcolor?pool$1.pull("Color").parseHex(e.tintcolor,!0):void 0,z:i},e.properties)),r=void 0===e.visible||e.visible;return o.setOpacity(r?+e.opacity:0),o}function readTileset(t){return new TMXTileset(t)}function readObjectGroup(t,e,i){return new TMXGroup(t,e,i)}var TMXTileMap=function(t,e){if(this.data=e,this.name=t,this.cols=+e.width,this.rows=+e.height,this.tilewidth=+e.tilewidth,this.tileheight=+e.tileheight,this.infinite=+e.infinite,this.orientation=e.orientation,this.renderorder=e.renderorder||"right-down",this.version=e.version,this.tiledversion=e.tiledversion,this.tilesets=null,void 0===this.layers&&(this.layers=[]),void 0===this.objectGroups&&(this.objectGroups=[]),this.isEditor="melon-editor"===e.editor,this.nextobjectid=+e.nextobjectid||void 0,this.hexsidelength=+e.hexsidelength,this.staggeraxis=e.staggeraxis,this.staggerindex=e.staggerindex,this.bounds=this.getRenderer().getBounds().clone(),this.width=this.bounds.width,this.height=this.bounds.height,this.backgroundcolor=e.backgroundcolor,applyTMXProperties(this,e),this.initialized=!1,1===this.infinite)throw new Error("Tiled Infinite Map not supported!")};TMXTileMap.prototype.getRenderer=function(){return void 0!==this.renderer&&this.renderer.canRender(this)||(this.renderer=getNewDefaultRenderer(this)),this.renderer},TMXTileMap.prototype.getBounds=function(){return this.bounds},TMXTileMap.prototype.readMapObjects=function(t){var e=this;if(!0!==this.initialized){var i=0;if(this.tilesets||(this.tilesets=new TMXTilesetGroup),void 0!==t.tilesets)t.tilesets.forEach((function(t){e.tilesets.add(readTileset(t))}));this.background_image&&this.layers.push(pool$1.pull("ImageLayer",0,0,{name:"background_image",image:this.background_image,z:i++})),t.layers.forEach((function(t){switch(t.type){case"imagelayer":e.layers.push(readImageLayer(e,t,i++));break;case"tilelayer":e.layers.push(readLayer(e,t,i++));break;case"objectgroup":case"group":e.objectGroups.push(readObjectGroup(e,t,i++))}})),this.initialized=!0}},TMXTileMap.prototype.addTo=function(t,e,i){var o=t.autoSort,r=t.autoDepth,n=this.getBounds();function s(e,i){viewport.setBounds(0,0,Math.max(n.width,e),Math.max(n.height,i)),t.pos.set(Math.max(0,~~((e-n.width)/2)),Math.max(0,~~((i-n.height)/2)),t.pos.z)}t.autoSort=!1,t.autoDepth=!1,this.backgroundcolor&&t.backgroundColor.parseCSS(this.backgroundcolor),this.getLayers().forEach((function(e){t.addChild(e)})),this.getObjects(e).forEach((function(e){t.addChild(e)})),t.resize(this.bounds.width,this.bounds.height),t.sort(!0),!0===i&&(off(VIEWPORT_ONRESIZE,s),s(viewport.width,viewport.height),on(VIEWPORT_ONRESIZE,s,this)),t.autoSort=o,t.autoDepth=r},TMXTileMap.prototype.getObjects=function(t){var e,i=[],o=!1;this.readMapObjects(this.data);for(var r=0;r<this.objectGroups.length;r++){var n=this.objectGroups[r];o=n.name.toLowerCase().includes(COLLISION_GROUP),!1===t&&((e=new Container(0,0,this.width,this.height)).anchorPoint.set(0,0),e.name=n.name,e.pos.z=n.z,e.setOpacity(n.opacity),e.autoSort=!1,e.autoDepth=!1);for(var s=0;s<n.objects.length;s++){var a,l,h=n.objects[s];void 0===h.anchorPoint&&(h.anchorPoint={x:0,y:0}),void 0!==h.tintcolor&&(h.tint=pool$1.pull("Color"),h.tint.parseHex(h.tintcolor,!0)),h instanceof TMXLayer?a=h:"object"==typeof h.text?(void 0===h.text.anchorPoint&&(h.text.anchorPoint=h.anchorPoint),(a=!0===h.text.bitmap?pool$1.pull("BitmapText",h.x,h.y,h.text):pool$1.pull("Text",h.x,h.y,h.text)).pos.z=h.z):"object"==typeof h.tile?(void 0===(l=h.shapes)&&(l=pool$1.pull("Polygon",0,0,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height)])),(a=h.tile.getRenderable(h)).body=new Body(a,l),a.body.setStatic(!0),a.pos.setMuted(h.x,h.y,h.z)):(void 0!==h.name&&""!==h.name?a=pool$1.pull(h.name,h.x,h.y,h):(a=pool$1.pull("Renderable",h.x,h.y,h.width,h.height),void 0===(l=h.shapes)&&(l=pool$1.pull("Polygon",0,0,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height)])),a.anchorPoint.set(0,0),a.name=h.name,a.type=h.type,a.id=h.id,a.body=new Body(a,l),a.body.setStatic(!0),a.resize(a.body.getBounds().width,a.body.getBounds().height)),a.pos.z=h.z),o&&!h.name&&a.body&&(a.body.collisionType=collision.types.WORLD_SHAPE,a.body.isStatic=!0),!1!==t?(!0===a.isRenderable&&(a.setOpacity(a.getOpacity()*n.opacity),a.renderable instanceof Renderable&&a.renderable.setOpacity(a.renderable.getOpacity()*n.opacity)),i.push(a)):e.addChild(a)}!1===t&&e.children.length>0&&(e.autoSort=!0,e.autoDepth=!0,i.push(e))}return i},TMXTileMap.prototype.getLayers=function(){return this.readMapObjects(this.data),this.layers},TMXTileMap.prototype.destroy=function(){this.tilesets=void 0,this.layers.length=0,this.objectGroups.length=0,this.initialized=!1};var levels={},levelIdx=[],currentLevelIdx=0;function safeLoadLevel(t,e,i){e.container.reset(),reset(),levels[level.getCurrentLevelId()]&&levels[level.getCurrentLevelId()].destroy(),currentLevelIdx=levelIdx.indexOf(t),loadTMXLevel(t,e.container,e.flatten,e.setViewportBounds),emit(LEVEL_LOADED,t),e.onLoaded(t),i&&state.restart()}function loadTMXLevel(t,e,i,o){var r=levels[t];utils.resetGUID(t,r.nextobjectid),e.anchorPoint.set(0,0),r.addTo(e,i,o)}var level={add:function(t,e,i){if("tmx"===t)return null==levels[e]&&(levels[e]=new TMXTileMap(e,loader.getTMX(e)),levelIdx.push(e),i&&i(),!0);throw new Error("no level loader defined for format "+t)},load:function(t,e){if(e=Object.assign({container:world,onLoaded:onLevelLoaded,flatten:mergeGroup,setViewportBounds:!0},e||{}),void 0===levels[t])throw new Error("level "+t+" not found");if(!(levels[t]instanceof TMXTileMap))throw new Error("no level loader defined");return state.isRunning()?(state.stop(),utils.function.defer(safeLoadLevel,this,t,e,!0)):safeLoadLevel(t,e),!0},getCurrentLevelId:function(){return levelIdx[currentLevelIdx]},getCurrentLevel:function(){return levels[this.getCurrentLevelId()]},reload:function(t){return this.load(this.getCurrentLevelId(),t)},next:function(t){return currentLevelIdx+1<levelIdx.length&&this.load(levelIdx[currentLevelIdx+1],t)},previous:function(t){return currentLevelIdx-1>=0&&this.load(levelIdx[currentLevelIdx-1],t)},levelCount:function(){return levelIdx.length}},imgList={},tmxList={},binList={},jsonList={},baseURL={},resourceCount=0,loadCount=0,timerId$1=0;function checkLoadStatus(t){if(loadCount===resourceCount){if(!t&&!loader.onload)throw new Error("no load callback defined");clearTimeout(timerId$1);var e=t||loader.onload;setTimeout((function(){e(),emit(LOADER_COMPLETE)}),300)}else timerId$1=setTimeout((function(){checkLoadStatus(t)}),100)}function preloadImage(t,e,i){imgList[t.name]=new Image,imgList[t.name].onload=e,imgList[t.name].onerror=i,"string"==typeof loader.crossOrigin&&(imgList[t.name].crossOrigin=loader.crossOrigin),imgList[t.name].src=t.src+loader.nocache}function preloadFontFace(t,e,i){var o=new FontFace(t.name,t.src);o.load().then((function(){document.fonts.add(o),document.body.style.fontFamily=t.name,e()}),(function(){i(t.name)}))}function preloadTMX(t,e,i){function o(e){tmxList[t.name]=e,"tmx"===t.type&&level.add(t.type,t.name)}if(t.data)return o(t.data),void e();var r=new XMLHttpRequest,n=getExtension(t.src);r.overrideMimeType&&("json"===n?r.overrideMimeType("application/json"):r.overrideMimeType("text/xml")),r.open("GET",t.src+loader.nocache,!0),r.withCredentials=loader.withCredentials,r.ontimeout=i,r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status||0===r.status&&r.responseText){var s=null;switch(n){case"xml":case"tmx":case"tsx":if(device$1.ua.match(/msie/i)||!r.responseXML){if(!globalThis.DOMParser)throw new Error("XML file format loading not supported, use the JSON file format instead");s=(new DOMParser).parseFromString(r.responseText,"text/xml")}else s=r.responseXML;var a=parse(s);switch(n){case"tmx":s=a.map;break;case"tsx":s=a.tilesets[0]}break;case"json":s=JSON.parse(r.responseText);break;default:throw new Error("TMX file format "+n+"not supported !")}o(s),e()}else i(t.name)},r.send()}function preloadJSON(t,e,i){var o=new XMLHttpRequest;o.overrideMimeType&&o.overrideMimeType("application/json"),o.open("GET",t.src+loader.nocache,!0),o.withCredentials=loader.withCredentials,o.ontimeout=i,o.onreadystatechange=function(){4===o.readyState&&(200===o.status||0===o.status&&o.responseText?(jsonList[t.name]=JSON.parse(o.responseText),e()):i(t.name))},o.send()}function preloadBinary(t,e,i){var o=new XMLHttpRequest;o.open("GET",t.src+loader.nocache,!0),o.withCredentials=loader.withCredentials,o.responseType="arraybuffer",o.onerror=i,o.onload=function(){var i=o.response;if(i){for(var r=new Uint8Array(i),n=[],s=0;s<r.byteLength;s++)n[s]=String.fromCharCode(r[s]);binList[t.name]=n.join(""),e()}},o.send()}function preloadJavascript(t,e,i){var o=document.createElement("script");o.src=t.src,o.type="text/javascript","string"==typeof loader.crossOrigin&&(o.crossOrigin=loader.crossOrigin),o.defer=!0,o.onload=function(){e()},o.onerror=function(){i(t.name)},document.getElementsByTagName("body")[0].appendChild(o)}var loader={nocache:"",onload:void 0,onProgress:void 0,crossOrigin:void 0,withCredentials:!1,onResourceLoaded:function(t){var e=++loadCount/resourceCount;this.onProgress&&this.onProgress(e,t),emit(LOADER_PROGRESS,e,t)},onLoadingError:function(t){throw new Error("Failed loading resource "+t.src)},setNocache:function(t){this.nocache=t?"?"+~~(1e7*Math.random()):""},setBaseURL:function(t,e){"*"!==t?baseURL[t]=e:(baseURL.audio=e,baseURL.binary=e,baseURL.image=e,baseURL.json=e,baseURL.js=e,baseURL.tmx=e,baseURL.tsx=e)},preload:function(t,e,i){void 0===i&&(i=!0);for(var o=0;o<t.length;o++)resourceCount+=this.load(t[o],this.onResourceLoaded.bind(this,t[o]),this.onLoadingError.bind(this,t[o]));void 0!==e&&(this.onload=e),!0===i&&state.change(state.LOADING),checkLoadStatus(e)},load:function(t,e,i){switch(void 0!==baseURL[t.type]&&(t.src=baseURL[t.type]+t.src),t.type){case"binary":return preloadBinary.call(this,t,e,i),1;case"image":return preloadImage.call(this,t,e,i),1;case"json":return preloadJSON.call(this,t,e,i),1;case"js":return preloadJavascript.call(this,t,e,i),1;case"tmx":case"tsx":return preloadTMX.call(this,t,e,i),1;case"audio":return load(t,!!t.stream,e,i),1;case"fontface":return preloadFontFace.call(this,t,e,i),1;default:throw new Error("load : unknown or invalid resource type : "+t.type)}},unload:function(t){switch(t.type){case"binary":return t.name in binList&&(delete binList[t.name],!0);case"image":return t.name in imgList&&(delete imgList[t.name],!0);case"json":return t.name in jsonList&&(delete jsonList[t.name],!0);case"js":case"fontface":return!0;case"tmx":case"tsx":return t.name in tmxList&&(delete tmxList[t.name],!0);case"audio":return unload(t.name);default:throw new Error("unload : unknown or invalid resource type : "+t.type)}},unloadAll:function(){var t;for(t in binList)binList.hasOwnProperty(t)&&this.unload({name:t,type:"binary"});for(t in imgList)imgList.hasOwnProperty(t)&&this.unload({name:t,type:"image"});for(t in tmxList)tmxList.hasOwnProperty(t)&&this.unload({name:t,type:"tmx"});for(t in jsonList)jsonList.hasOwnProperty(t)&&this.unload({name:t,type:"json"});unloadAll()},getTMX:function(t){return(t=""+t)in tmxList?tmxList[t]:null},getBinary:function(t){return(t=""+t)in binList?binList[t]:null},getImage:function(t){return(t=getBasename(""+t))in imgList?imgList[t]:null},getJSON:function(t){return(t=""+t)in jsonList?jsonList[t]:null}},audioTracks={},current_track_id=null,retry_counter=0,audioExts=[],soundLoadError=function(t,e){if(retry_counter++>3)throw new Error("melonJS: failed loading "+t);audioTracks[t].load()},stopOnAudioError=!0;function init$1(t){return void 0===t&&(t="mp3"),audioExts=t.split(","),!howler.Howler.noAudio}function hasFormat(t){return hasAudio()&&howler.Howler.codecs(t)}function hasAudio(){return!howler.Howler.noAudio}function enable(){unmuteAll()}function disable(){muteAll()}function load(t,e,i,o){var r=[];if(0===audioExts.length)throw new Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");for(var n=0;n<audioExts.length;n++)r.push(t.src+t.name+"."+audioExts[n]+loader.nocache);return audioTracks[t.name]=new howler.Howl({src:r,volume:howler.Howler.volume(),html5:!0===e,xhrWithCredentials:loader.withCredentials,onloaderror:function(){soundLoadError.call(this,t.name,o)},onload:function(){retry_counter=0,i&&i()}}),1}function play(t,e,i,o){void 0===e&&(e=!1);var r=audioTracks[t];if(r&&void 0!==r){var n=r.play();return"boolean"==typeof e&&r.loop(e,n),r.volume("number"==typeof o?clamp(o,0,1):howler.Howler.volume(),n),"function"==typeof i&&(!0===e?r.on("end",i,n):r.once("end",i,n)),n}throw new Error("audio clip "+t+" does not exist")}function fade(t,e,i,o,r){var n=audioTracks[t];if(!n||void 0===n)throw new Error("audio clip "+t+" does not exist");n.fade(e,i,o,r)}function seek(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];var o=audioTracks[t];if(o&&void 0!==o)return o.seek.apply(o,e);throw new Error("audio clip "+t+" does not exist")}function rate(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];var o=audioTracks[t];if(o&&void 0!==o)return o.rate.apply(o,e);throw new Error("audio clip "+t+" does not exist")}function stop(t,e){if(void 0!==t){var i=audioTracks[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.stop(e),i.off("end",void 0,e)}else howler.Howler.stop()}function pause(t,e){var i=audioTracks[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.pause(e)}function resume(t,e){var i=audioTracks[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.play(e)}function playTrack(t,e){return play(current_track_id=t,!0,null,e)}function stopTrack(){null!==current_track_id&&(audioTracks[current_track_id].stop(),current_track_id=null)}function pauseTrack(){null!==current_track_id&&audioTracks[current_track_id].pause()}function resumeTrack(){null!==current_track_id&&audioTracks[current_track_id].play()}function getCurrentTrack(){return current_track_id}function setVolume(t){howler.Howler.volume(t)}function getVolume(){return howler.Howler.volume()}function mute(t,e,i){i=void 0===i||!!i;var o=audioTracks[t];if(!o||void 0===o)throw new Error("audio clip "+t+" does not exist");o.mute(i,e)}function unmute(t,e){mute(t,e,!1)}function muteAll(){howler.Howler.mute(!0)}function unmuteAll(){howler.Howler.mute(!1)}function muted(){return howler.Howler._muted}function unload(t){return t in audioTracks&&(audioTracks[t].unload(),delete audioTracks[t],!0)}function unloadAll(){for(var t in audioTracks)audioTracks.hasOwnProperty(t)&&unload(t)}var audio=Object.freeze({__proto__:null,stopOnAudioError:stopOnAudioError,init:init$1,hasFormat:hasFormat,hasAudio:hasAudio,enable:enable,disable:disable,load:load,play:play,fade:fade,seek:seek,rate:rate,stop:stop,pause:pause,resume:resume,playTrack:playTrack,stopTrack:stopTrack,pauseTrack:pauseTrack,resumeTrack:resumeTrack,getCurrentTrack:getCurrentTrack,setVolume:setVolume,getVolume:getVolume,mute:mute,unmute:unmute,muteAll:muteAll,unmuteAll:unmuteAll,muted:muted,unload:unload,unloadAll:unloadAll}),data={};function isReserved(t){return"add"===t||"remove"===t}on(BOOT,(function(){if(!0===device$1.localStorage){var t=localStorage.getItem("me.save");if("string"==typeof t&&t.length>0)(JSON.parse(t)||[]).forEach((function(t){data[t]=JSON.parse(localStorage.getItem("me.save."+t))}))}}));var save={add:function(t){var e=save;Object.keys(t).forEach((function(i){var o;isReserved(i)||(o=i,Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:function(){return data[o]},set:function(t){data[o]=t,!0===device$1.localStorage&&localStorage.setItem("me.save."+o,JSON.stringify(t))}}),i in data||(e[i]=t[i]))})),!0===device$1.localStorage&&localStorage.setItem("me.save",JSON.stringify(Object.keys(data)))},remove:function(t){isReserved(t)||void 0!==data[t]&&(delete data[t],!0===device$1.localStorage&&(localStorage.removeItem("me.save."+t),localStorage.setItem("me.save",JSON.stringify(Object.keys(data)))))}},accelInitialized=!1,deviceOrientationInitialized=!1,swipeEnabled=!0;function _disableSwipeFn(t){return t.preventDefault(),"function"==typeof globalThis.scroll&&globalThis.scroll(0,0),!1}var readyBound=!1,isReady=!1,readyList=[];function _domReady(){if(!isReady){if(!device.nodeJS&&!document.body)return setTimeout(_domReady,13);for(void 0!==globalThis.document&&"function"==typeof globalThis.document.removeEventListener&&globalThis.document.removeEventListener("DOMContentLoaded",this._domReady,!1),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("load",_domReady,!1);readyList.length;)readyList.shift().call(globalThis,[]);isReady=!0}}var _domRect={left:0,top:0,x:0,y:0,width:0,height:0,right:0,bottom:0};function _detectDevice(){device.iOS=/iPhone|iPad|iPod/i.test(device.ua),device.android=/Android/i.test(device.ua),device.android2=/Android 2/i.test(device.ua),device.linux=/Linux/i.test(device.ua),device.chromeOS=/CrOS/.test(device.ua),device.wp=/Windows Phone/i.test(device.ua),device.BlackBerry=/BlackBerry/i.test(device.ua),device.Kindle=/Kindle|Silk.*Mobile Safari/i.test(device.ua),device.isMobile=/Mobi/i.test(device.ua)||device.iOS||device.android||device.wp||device.BlackBerry||device.Kindle||!1,device.ejecta=void 0!==globalThis.ejecta,device.isWeixin=/MicroMessenger/i.test(device.ua)}function _checkCapabilities(){_detectDevice(),device.TouchEvent=!!("ontouchstart"in globalThis),device.PointerEvent=!!globalThis.PointerEvent,globalThis.gesture=prefixed("gesture"),device.touch=device.TouchEvent||device.PointerEvent,device.maxTouchPoints=device.touch?device.PointerEvent?globalThis.navigator.maxTouchPoints||1:10:1,device.wheel=void 0!==globalThis.document&&"onwheel"in globalThis.document.createElement("div"),device.hasPointerLockSupport=void 0!==globalThis.document&&void 0!==globalThis.document.pointerLockElement,device.hasDeviceOrientation=!!globalThis.DeviceOrientationEvent,device.hasAccelerometer=!!globalThis.DeviceMotionEvent,device.ScreenOrientation="undefined"!=typeof screen&&void 0!==screen.orientation,device.hasFullscreenSupport=void 0!==globalThis.document&&(prefixed("fullscreenEnabled",globalThis.document)||globalThis.document.mozFullScreenEnabled),!0===device.hasFullscreenSupport&&(globalThis.document.exitFullscreen=void 0!==globalThis.document&&(prefixed("cancelFullScreen",globalThis.document)||prefixed("exitFullscreen",globalThis.document))),device.hasWebAudio=!(!globalThis.AudioContext&&!globalThis.webkitAudioContext);try{device.localStorage=!!globalThis.localStorage}catch(t){device.localStorage=!1}try{device.OffscreenCanvas=void 0!==globalThis.OffscreenCanvas&&null!==new OffscreenCanvas(0,0).getContext("2d")}catch(t){device.OffscreenCanvas=!1}var t,e;("function"==typeof globalThis.addEventListener&&(globalThis.addEventListener("blur",(function(){device.stopOnBlur&&state.stop(!0),device.pauseOnBlur&&state.pause(!0)}),!1),globalThis.addEventListener("focus",(function(){device.stopOnBlur&&state.restart(!0),device.resumeOnFocus&&state.resume(!0),device.autoFocus&&device.focus()}),!1)),void 0!==globalThis.document)&&(void 0!==globalThis.document.hidden?(t="hidden",e="visibilitychange"):void 0!==globalThis.document.mozHidden?(t="mozHidden",e="mozvisibilitychange"):void 0!==globalThis.document.msHidden?(t="msHidden",e="msvisibilitychange"):void 0!==globalThis.document.webkitHidden&&(t="webkitHidden",e="webkitvisibilitychange"),"string"==typeof e&&globalThis.document.addEventListener(e,(function(){globalThis.document[t]?(device.stopOnBlur&&state.stop(!0),device.pauseOnBlur&&state.pause(!0)):(device.stopOnBlur&&state.restart(!0),device.resumeOnFocus&&state.resume(!0))}),!1));device.isMobile&&device.enableSwipe(!1)}on(BOOT,(function(){_checkCapabilities()}));var device={ua:void 0!==globalThis.navigator?globalThis.navigator.userAgent:"",localStorage:!1,hasAccelerometer:!1,hasDeviceOrientation:!1,ScreenOrientation:!1,hasFullscreenSupport:!1,hasPointerLockSupport:!1,hasWebAudio:!1,nativeBase64:"function"==typeof globalThis.atob,maxTouchPoints:1,touch:!1,wheel:!1,isMobile:!1,iOS:!1,android:!1,android2:!1,linux:!1,ejecta:!1,isWeixin:!1,nodeJS:"undefined"!=typeof process&&"node"===process.release.name,chromeOS:!1,wp:!1,BlackBerry:!1,Kindle:!1,accelerationX:0,accelerationY:0,accelerationZ:0,gamma:0,beta:0,alpha:0,language:void 0!==globalThis.navigator&&(globalThis.navigator.language||globalThis.navigator.browserLanguage||globalThis.navigator.userLanguage)||"en",pauseOnBlur:!0,resumeOnFocus:!0,autoFocus:!0,stopOnBlur:!1,OffscreenCanvas:!1,onReady:function(t){isReady?t.call(globalThis,[]):(readyList.push(t),readyBound||(!0===device.nodeJS||void 0!==globalThis.document&&"complete"===globalThis.document.readyState?globalThis.setTimeout(_domReady,0):(void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("DOMContentLoaded",_domReady,!1),globalThis.addEventListener("load",_domReady,!1)),readyBound=!0))},enableSwipe:function(t){var e=device.PointerEvent?"pointermove":device.TouchEvent?"touchmove":"mousemove";!1!==t?!1===swipeEnabled&&(globalThis.document.removeEventListener(e,_disableSwipeFn),swipeEnabled=!0):!0===swipeEnabled&&(globalThis.document.addEventListener(e,_disableSwipeFn,{passive:!1}),swipeEnabled=!1)},requestFullscreen:function(t){this.hasFullscreenSupport&&((t=t||getParent()).requestFullscreen=prefixed("requestFullscreen",t)||t.mozRequestFullScreen,t.requestFullscreen())},exitFullscreen:function(){this.hasFullscreenSupport&&document.exitFullscreen()},getScreenOrientation:function(){var t="portrait",e="landscape",i=globalThis.screen;if(!0===this.ScreenOrientation){var o=prefixed("orientation",i);if(void 0!==o&&"string"==typeof o.type)return o.type;if("string"==typeof o)return o}return"number"==typeof globalThis.orientation?90===Math.abs(globalThis.orientation)?e:t:globalThis.outerWidth>globalThis.outerHeight?e:t},lockOrientation:function(t){var e=globalThis.screen;if(void 0!==e){var i=prefixed("lockOrientation",e);if(void 0!==i)return i(t)}return!1},unlockOrientation:function(){var t=globalThis.screen;if(void 0!==t){var e=prefixed("unlockOrientation",t);if(void 0!==e)return e()}return!1},isPortrait:function(){return this.getScreenOrientation().includes("portrait")},isLandscape:function(){return this.getScreenOrientation().includes("landscape")},getStorage:function(t){if(void 0===t&&(t="local"),"local"===t)return save;throw new Error("storage type "+t+" not supported")},getParentElement:function(t){var e=this.getElement(t);return null!==e.parentNode&&(e=e.parentNode),e},getElement:function(t){var e=null;return"undefined"!==t&&("string"==typeof t?e=document.getElementById(t):"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE&&(e=t)),e||(e=document.body),e},getElementBounds:function(t){return"object"==typeof t&&t!==document.body&&void 0!==t.getBoundingClientRect?t.getBoundingClientRect():(_domRect.width=_domRect.right=globalThis.innerWidth,_domRect.height=_domRect.bottom=globalThis.innerHeight,_domRect)},getParentBounds:function(t){return this.getElementBounds(this.getParentElement(t))},isWebGLSupported:function(t){var e=!1;try{var i=document.createElement("canvas"),o={stencil:!0,failIfMajorPerformanceCaveat:t.failIfMajorPerformanceCaveat};e=!(!globalThis.WebGLRenderingContext||!i.getContext("webgl",o)&&!i.getContext("experimental-webgl",o))}catch(t){e=!1}return e},getMaxShaderPrecision:function(t){return t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0?"highp":t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"},focus:function(){"function"==typeof globalThis.focus&&globalThis.focus()},onDeviceMotion:function(t){this.accelerationX=t.accelerationIncludingGravity.x,this.accelerationY=t.accelerationIncludingGravity.y,this.accelerationZ=t.accelerationIncludingGravity.z},onDeviceRotate:function(t){this.gamma=t.gamma,this.beta=t.beta,this.alpha=t.alpha},watchAccelerometer:function(){var t=this;return this.hasAccelerometer&&!accelInitialized&&(DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&(globalThis.addEventListener("devicemotion",t.onDeviceMotion,!1),accelInitialized=!0)})).catch(console.error):(globalThis.addEventListener("devicemotion",this.onDeviceMotion,!1),accelInitialized=!0)),accelInitialized},unwatchAccelerometer:function(){accelInitialized&&(globalThis.removeEventListener("devicemotion",this.onDeviceMotion,!1),accelInitialized=!1)},watchDeviceOrientation:function(){var t=this;return this.hasDeviceOrientation&&!deviceOrientationInitialized&&("function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&(globalThis.addEventListener("deviceorientation",t.onDeviceRotate,!1),deviceOrientationInitialized=!0)})).catch(console.error):(globalThis.addEventListener("deviceorientation",this.onDeviceRotate,!1),deviceOrientationInitialized=!0)),deviceOrientationInitialized},unwatchDeviceOrientation:function(){deviceOrientationInitialized&&(globalThis.removeEventListener("deviceorientation",this.onDeviceRotate,!1),deviceOrientationInitialized=!1)},vibrate:function(t){void 0!==globalThis.navigator&&"function"==typeof globalThis.navigator.vibrate&&globalThis.navigator.vibrate(t)}};Object.defineProperty(device,"devicePixelRatio",{get:function(){return globalThis.devicePixelRatio||1}}),Object.defineProperty(device,"isFullscreen",{get:function(){return!!this.hasFullscreenSupport&&!(!prefixed("fullscreenElement",document)&&!document.mozFullScreenElement)}}),Object.defineProperty(device,"sound",{get:function(){return hasAudio()}});var device$1=device,fnHash={bool:"1i",int:"1i",float:"1f",vec2:"2fv",vec3:"3fv",vec4:"4fv",bvec2:"2iv",bvec3:"3iv",bvec4:"4iv",ivec2:"2iv",ivec3:"3iv",ivec4:"4iv",mat2:"Matrix2fv",mat3:"Matrix3fv",mat4:"Matrix4fv",sampler2D:"1i"};function extractUniforms(t,e){var i,o={},r=/uniform\s+(\w+)\s+(\w+)/g,n={},s={},a={};return[e.vertex,e.fragment].forEach((function(t){for(;i=r.exec(t);)n[i[2]]=i[1]})),Object.keys(n).forEach((function(i){var o=n[i];a[i]=t.getUniformLocation(e.program,i),s[i]={get:function(t){return function(){return a[t]}}(i),set:function(e,i,o){return 0===i.indexOf("mat")?function(i){t[o](a[e],!1,i)}:function(i){var r=o;i.length&&"v"!==o.slice(-1)&&(r+="v"),t[r](a[e],i)}}(i,o,"uniform"+fnHash[o])}})),Object.defineProperties(o,s),o}function extractAttributes(t,e){for(var i,o={},r=/attribute\s+\w+\s+(\w+)/g,n=0;i=r.exec(e.vertex);)o[i[1]]=n++;return o}function compileShader(t,e,i){var o=t.createShader(e);if(t.shaderSource(o,i),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Error(t.getShaderInfoLog(o));return o}function compileProgram(t,e,i,o){var r=compileShader(t,t.VERTEX_SHADER,e),n=compileShader(t,t.FRAGMENT_SHADER,i),s=t.createProgram();for(var a in t.attachShader(s,r),t.attachShader(s,n),o)t.bindAttribLocation(s,o[a],a);if(t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS)){var l="Error initializing Shader "+this+"\ngl.VALIDATE_STATUS: "+t.getProgramParameter(s,t.VALIDATE_STATUS)+"\ngl.getError()"+t.getError()+"\ngl.getProgramInfoLog()"+t.getProgramInfoLog(s);throw t.deleteProgram(s),s=null,new Error(l)}return t.useProgram(s),t.deleteShader(r),t.deleteShader(n),s}function setPrecision(t,e){return"precision"!==t.substring(0,9)?"precision "+e+" float;"+t:t}function minify(t){return t=(t=(t=(t=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1")).replace(/(\\n\s+)|(\s+\\n)/g,"")).replace(/(\\r|\\n)+/g,"")).replace(/\s*([;,[\](){}\\\/\-+*|^&!=<>?~%])\s*/g,"$1")}var GLShader=function(t,e,i,o){this.gl=t,this.vertex=setPrecision(minify(e),o||device$1.getMaxShaderPrecision(this.gl)),this.fragment=setPrecision(minify(i),o||device$1.getMaxShaderPrecision(this.gl)),this.attributes=extractAttributes(this.gl,this),this.program=compileProgram(this.gl,this.vertex,this.fragment,this.attributes),this.uniforms=extractUniforms(this.gl,this),on(ONCONTEXT_LOST,this.destroy,this)};GLShader.prototype.bind=function(){this.gl.useProgram(this.program)},GLShader.prototype.getAttribLocation=function(t){var e=this.attributes[t];return void 0!==e?e:-1},GLShader.prototype.setUniform=function(t,e){var i=this.uniforms;if(void 0===i[t])throw new Error("undefined ("+t+") uniform for shader "+this);"object"==typeof e&&"function"==typeof e.toArray?i[t]=e.toArray():i[t]=e},GLShader.prototype.setVertexAttributes=function(t,e,i){for(var o=0;o<e.length;++o){var r=e[o],n=this.getAttribLocation(r.name);-1!==n?(t.enableVertexAttribArray(n),t.vertexAttribPointer(n,r.size,r.type,r.normalized,i,r.offset)):t.disableVertexAttribArray(o)}},GLShader.prototype.destroy=function(){this.uniforms=null,this.attributes=null,this.gl.deleteProgram(this.program),this.vertex=null,this.fragment=null};var VertexArrayBuffer=function(t,e){this.vertexSize=t,this.quadSize=e,this.maxVertex=256,this.vertexCount=0,this.buffer=new ArrayBuffer(this.maxVertex*this.vertexSize*this.quadSize),this.bufferF32=new Float32Array(this.buffer),this.bufferU32=new Uint32Array(this.buffer)};VertexArrayBuffer.prototype.clear=function(){this.vertexCount=0},VertexArrayBuffer.prototype.isFull=function(t){return void 0===t&&(t=this.quadSize),this.vertexCount+t>=this.maxVertex},VertexArrayBuffer.prototype.resize=function(){this.maxVertex<<=1;var t=this.bufferF32;return this.buffer=new ArrayBuffer(this.maxVertex*this.vertexSize*this.quadSize),this.bufferF32=new Float32Array(this.buffer),this.bufferU32=new Uint32Array(this.buffer),this.bufferF32.set(t),this},VertexArrayBuffer.prototype.push=function(t,e,i,o,r){var n=this.vertexCount*this.vertexSize;return this.vertexCount>=this.maxVertex&&this.resize(),this.bufferF32[n+0]=t,this.bufferF32[n+1]=e,void 0!==i&&(this.bufferF32[n+2]=i,this.bufferF32[n+3]=o),void 0!==r&&(this.bufferU32[n+4]=r),this.vertexCount++,this},VertexArrayBuffer.prototype.toFloat32=function(t,e){return void 0!==e?this.bufferF32.subarray(t,e):this.bufferF32},VertexArrayBuffer.prototype.toUint32=function(t,e){return void 0!==e?this.bufferU32.subarray(t,e):this.bufferU32},VertexArrayBuffer.prototype.length=function(){return this.vertexCount},VertexArrayBuffer.prototype.isEmpty=function(){return 0===this.vertexCount};var primitiveVertex="// Current vertex point\nattribute vec2 aVertex;\n\n// Projection matrix\nuniform mat4 uProjectionMatrix;\n\n// Vertex color\nuniform vec4 uColor;\n\n// Fragment color\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(uColor.rgb * uColor.a, uColor.a);\n}\n",primitiveFragment="varying vec4 vColor;\n\nvoid main(void) {\n gl_FragColor = vColor;\n}\n",quadVertex="attribute vec2 aVertex;\nattribute vec2 aRegion;\nattribute vec4 aColor;\n\nuniform mat4 uProjectionMatrix;\n\nvarying vec2 vRegion;\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(aColor.bgr * aColor.a, aColor.a);\n vRegion = aRegion;\n}\n",quadFragment="uniform sampler2D uSampler;\nvarying vec4 vColor;\nvarying vec2 vRegion;\n\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vRegion) * vColor;\n}\n",V_ARRAY=[new Vector2d,new Vector2d,new Vector2d,new Vector2d],WebGLCompositor=function(t){this.init(t)};WebGLCompositor.prototype.init=function(t){var e=this,i=t.gl;this.currentTextureUnit=-1,this.boundTextures=[],this.renderer=t,this.gl=t.gl,this.color=t.currentColor,this.viewMatrix=t.currentTransform,this.activeShader=null,this.mode=i.TRIANGLES,this.attributes=[],this.vertexByteSize=0,this.vertexSize=0,this.primitiveShader=new GLShader(this.gl,primitiveVertex,primitiveFragment),this.quadShader=new GLShader(this.gl,quadVertex,quadFragment),this.addAttribute("aVertex",2,i.FLOAT,!1,0*Float32Array.BYTES_PER_ELEMENT),this.addAttribute("aRegion",2,i.FLOAT,!1,2*Float32Array.BYTES_PER_ELEMENT),this.addAttribute("aColor",4,i.UNSIGNED_BYTE,!0,4*Float32Array.BYTES_PER_ELEMENT),this.vertexBuffer=new VertexArrayBuffer(this.vertexSize,6),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,this.vertexBuffer.buffer,i.STREAM_DRAW),on(CANVAS_ONRESIZE,(function(t,i){e.flush(),e.setViewport(0,0,t,i)}))},WebGLCompositor.prototype.reset=function(){this.gl=this.renderer.gl,this.flush(),this.setViewport(0,0,this.renderer.getScreenCanvas().width,this.renderer.getScreenCanvas().height),this.clearColor(0,0,0,0);for(var t=0;t<this.renderer.maxTextures;t++){var e=this.getTexture2D(t);void 0!==e&&this.deleteTexture2D(e)}this.currentTextureUnit=-1,this.useShader(this.quadShader)},WebGLCompositor.prototype.addAttribute=function(t,e,i,o,r){switch(this.attributes.push({name:t,size:e,type:i,normalized:o,offset:r}),i){case this.gl.BYTE:this.vertexByteSize+=e*Int8Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_BYTE:this.vertexByteSize+=e*Uint8Array.BYTES_PER_ELEMENT;break;case this.gl.SHORT:this.vertexByteSize+=e*Int16Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_SHORT:this.vertexByteSize+=e*Uint16Array.BYTES_PER_ELEMENT;break;case this.gl.INT:this.vertexByteSize+=e*Int32Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_INT:this.vertexByteSize+=e*Uint32Array.BYTES_PER_ELEMENT;break;case this.gl.FLOAT:this.vertexByteSize+=e*Float32Array.BYTES_PER_ELEMENT;break;default:throw new Error("Invalid GL Attribute type")}this.vertexSize=this.vertexByteSize/Float32Array.BYTES_PER_ELEMENT},WebGLCompositor.prototype.setViewport=function(t,e,i,o){this.gl.viewport(t,e,i,o)},WebGLCompositor.prototype.createTexture2D=function(t,e,i,o,r,n,s,a,l){void 0===o&&(o="no-repeat"),void 0===a&&(a=!0),void 0===l&&(l=!0);var h=this.gl,c=isPowerOfTwo(r||e.width)&&isPowerOfTwo(n||e.height),u=h.createTexture(),p=0===o.search(/^repeat(-x)?$/)&&(c||this.renderer.WebGLVersion>1)?h.REPEAT:h.CLAMP_TO_EDGE,d=0===o.search(/^repeat(-y)?$/)&&(c||this.renderer.WebGLVersion>1)?h.REPEAT:h.CLAMP_TO_EDGE;return this.bindTexture2D(u,t),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,p),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,d),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,i),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,i),h.pixelStorei(h.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a),r||n||s?h.texImage2D(h.TEXTURE_2D,0,h.RGBA,r,n,s,h.RGBA,h.UNSIGNED_BYTE,e):h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,e),c&&!1!==l&&h.generateMipmap(h.TEXTURE_2D),u},WebGLCompositor.prototype.deleteTexture2D=function(t){this.gl.deleteTexture(t),this.unbindTexture2D(t)},WebGLCompositor.prototype.getTexture2D=function(t){return this.boundTextures[t]},WebGLCompositor.prototype.bindTexture2D=function(t,e){var i=this.gl;t!==this.boundTextures[e]?(this.flush(),this.currentTextureUnit!==e&&(this.currentTextureUnit=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,t),this.boundTextures[e]=t):this.currentTextureUnit!==e&&(this.flush(),this.currentTextureUnit=e,i.activeTexture(i.TEXTURE0+e))},WebGLCompositor.prototype.unbindTexture2D=function(t,e){return void 0===e&&(e=this.boundTextures.indexOf(t)),-1!==e&&(delete this.boundTextures[e],e===this.currentTextureUnit&&(this.currentTextureUnit=-1)),e},WebGLCompositor.prototype.uploadTexture=function(t,e,i,o,r){void 0===r&&(r=!1);var n=this.renderer.cache.getUnit(t),s=this.boundTextures[n];return void 0===s||r?this.createTexture2D(n,t.getTexture(),this.renderer.settings.antiAlias?this.gl.LINEAR:this.gl.NEAREST,t.repeat,e,i,o,t.premultipliedAlpha):this.bindTexture2D(s,n),this.currentTextureUnit},WebGLCompositor.prototype.setProjection=function(t){this.activeShader.setUniform("uProjectionMatrix",t)},WebGLCompositor.prototype.useShader=function(t){this.activeShader!==t&&(this.flush(),this.activeShader=t,this.activeShader.bind(),this.activeShader.setUniform("uProjectionMatrix",this.renderer.projectionMatrix),this.activeShader.setVertexAttributes(this.gl,this.attributes,this.vertexByteSize))},WebGLCompositor.prototype.addQuad=function(t,e,i,o,r,n,s,a,l,h){if(!(this.color.alpha<1/255)){this.useShader(this.quadShader),this.vertexBuffer.isFull(6)&&this.flush();var c=this.uploadTexture(t);this.quadShader.setUniform("uSampler",c);var u=this.viewMatrix,p=V_ARRAY[0].set(e,i),d=V_ARRAY[1].set(e+o,i),f=V_ARRAY[2].set(e,i+r),y=V_ARRAY[3].set(e+o,i+r);u.isIdentity()||(u.apply(p),u.apply(d),u.apply(f),u.apply(y)),this.vertexBuffer.push(p.x,p.y,n,s,h),this.vertexBuffer.push(d.x,d.y,a,s,h),this.vertexBuffer.push(f.x,f.y,n,l,h),this.vertexBuffer.push(f.x,f.y,n,l,h),this.vertexBuffer.push(d.x,d.y,a,s,h),this.vertexBuffer.push(y.x,y.y,a,l,h)}},WebGLCompositor.prototype.flush=function(t){void 0===t&&(t=this.mode);var e=this.vertexBuffer,i=e.vertexCount;if(i>0){var o=this.gl,r=e.vertexSize;this.renderer.WebGLVersion>1?o.bufferData(o.ARRAY_BUFFER,e.toFloat32(),o.STREAM_DRAW,0,i*r):o.bufferData(o.ARRAY_BUFFER,e.toFloat32(0,i*r),o.STREAM_DRAW),o.drawArrays(t,0,i),e.clear()}},WebGLCompositor.prototype.drawVertices=function(t,e,i){void 0===i&&(i=e.length),this.useShader(this.primitiveShader),this.primitiveShader.setUniform("uColor",this.color);for(var o=this.viewMatrix,r=this.vertexBuffer,n=o.isIdentity(),s=0;s<i;s++)n||o.apply(e[s]),r.push(e[s].x,e[s].y);this.flush(t)},WebGLCompositor.prototype.clearColor=function(t,e,i,o){this.gl.clearColor(t,e,i,o)},WebGLCompositor.prototype.clear=function(){this.gl.clear(this.gl.COLOR_BUFFER_BIT)};var WebGLRenderer=function(t){function e(e){var i=this;t.call(this,e),this.WebGLVersion=1,this.GPUVendor=null,this.GPURenderer=null,this.context=this.gl=this.getContextGL(this.getScreenCanvas(),e.transparent),this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this._colorStack=[],this._matrixStack=[],this._scissorStack=[],this._blendStack=[],this.currentTransform=new Matrix2d,this.currentCompositor=null,this.compositors=new Map;var o=new(this.settings.compositor||WebGLCompositor)(this);this.compositors.set("default",o),this.setCompositor(o),this.gl.disable(this.gl.DEPTH_TEST),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.enable(this.gl.BLEND),this.setBlendMode(this.settings.blendMode);var r=this.gl.getExtension("WEBGL_debug_renderer_info");null!==r&&(this.GPUVendor=this.gl.getParameter(r.UNMASKED_VENDOR_WEBGL),this.GPURenderer=this.gl.getParameter(r.UNMASKED_RENDERER_WEBGL)),this.cache=new TextureCache(this.maxTextures),this.getScreenCanvas().addEventListener("webglcontextlost",(function(t){t.preventDefault(),i.isContextValid=!1,emit(ONCONTEXT_LOST,i)}),!1),this.getScreenCanvas().addEventListener("webglcontextrestored",(function(){i.reset(),i.isContextValid=!0,emit(ONCONTEXT_RESTORED,i)}),!1)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){var e=this;t.prototype.reset.call(this),this.compositors.forEach((function(t){!1===e.isContextValid?t.init(e):t.reset()})),this.gl.disable(this.gl.SCISSOR_TEST),void 0!==this.fontContext2D&&this.createFontTexture(this.cache)},e.prototype.setCompositor=function(t){if(void 0===t&&(t="default"),"string"==typeof t&&(t=this.compositors.get(t)),void 0===t)throw new Error("Invalid WebGL Compositor");this.currentCompositor!==t&&(null!==this.currentCompositor&&this.currentCompositor.flush(),this.currentCompositor=t)},e.prototype.resetTransform=function(){this.currentTransform.identity()},e.prototype.createFontTexture=function(t){if(void 0===this.fontTexture){var e=this.backBufferCanvas,i=e.width,o=e.height;1===this.WebGLVersion&&(isPowerOfTwo(i)||(i=nextPowerOfTwo(e.width)),isPowerOfTwo(o)||(o=nextPowerOfTwo(e.height)));var r=createCanvas(i,o,!0);this.fontContext2D=this.getContext2d(r),this.fontTexture=new TextureAtlas(createAtlas(e.width,e.height,"fontTexture"),r,t),this.currentCompositor.uploadTexture(this.fontTexture,0,0,0)}else t.set(this.fontContext2D.canvas,this.fontTexture)},e.prototype.createPattern=function(t,e){if(!(1!==renderer.WebGLVersion||isPowerOfTwo(t.width)&&isPowerOfTwo(t.height))){var i=void 0!==t.src?t.src:t;throw new Error("[WebGL Renderer] "+i+" is not a POT texture ("+t.width+"x"+t.height+")")}var o=new TextureAtlas(createAtlas(t.width,t.height,"pattern",e),t);return this.currentCompositor.uploadTexture(o),o},e.prototype.flush=function(){this.currentCompositor.flush()},e.prototype.setProjection=function(e){t.prototype.setProjection.call(this,e),this.currentCompositor.setProjection(e)},e.prototype.clearColor=function(t,e){var i;if(void 0===t&&(t="#000000"),void 0===e&&(e=!1),t instanceof Color)i=t.toArray();else{var o=pool$1.pull("me.Color");i=o.parseCSS(t).toArray(),pool$1.push(o)}this.currentCompositor.clearColor(i[0],i[1],i[2],!0===e?1:i[3]),this.currentCompositor.clear(),this.currentCompositor.clearColor(0,0,0,0)},e.prototype.clearRect=function(t,e,i,o){this.save(),this.clipRect(t,e,i,o),this.clearColor(),this.restore()},e.prototype.drawFont=function(t){var e=this.getFontContext();this.currentCompositor.uploadTexture(this.fontTexture,0,0,0,!0);var i=this.fontTexture.getUVs(t.left+","+t.top+","+t.width+","+t.height);this.currentCompositor.addQuad(this.fontTexture,t.left,t.top,t.width,t.height,i[0],i[1],i[2],i[3],this.currentTint.toUint32()),e.clearRect(t.left,t.top,t.width,t.height)},e.prototype.drawImage=function(t,e,i,o,r,n,s,a,l){void 0===o?(o=a=t.width,r=l=t.height,n=e,s=i,e=0,i=0):void 0===n&&(n=e,s=i,a=o,l=r,o=t.width,r=t.height,e=0,i=0),!1===this.settings.subPixel&&(n|=0,s|=0);var h=this.cache.get(t),c=h.getUVs(e+","+i+","+o+","+r);this.currentCompositor.addQuad(h,n,s,a,l,c[0],c[1],c[2],c[3],this.currentTint.toUint32())},e.prototype.drawPattern=function(t,e,i,o,r){var n=t.getUVs("0,0,"+o+","+r);this.currentCompositor.addQuad(t,e,i,o,r,n[0],n[1],n[2],n[3],this.currentTint.toUint32())},e.prototype.getScreenContext=function(){return this.gl},e.prototype.getContextGL=function(t,e){if(null==t)throw new Error("You must pass a canvas element in order to create a GL context");"boolean"!=typeof e&&(e=!0);var i,o={alpha:e,antialias:this.settings.antiAlias,depth:!1,stencil:!0,preserveDrawingBuffer:!1,premultipliedAlpha:e,powerPreference:this.settings.powerPreference,failIfMajorPerformanceCaveat:this.settings.failIfMajorPerformanceCaveat};if(!1===this.settings.preferWebGL1&&(i=t.getContext("webgl2",o))&&(this.WebGLVersion=2),i||(this.WebGLVersion=1,i=t.getContext("webgl",o)||t.getContext("experimental-webgl",o)),!i)throw new Error("A WebGL context could not be created.");return i},e.prototype.getContext=function(){return this.gl},e.prototype.setBlendMode=function(t,e){if(void 0===t&&(t="normal"),void 0===e&&(e=this.gl),this.currentBlendMode!==t)switch(this.flush(),e.enable(e.BLEND),this.currentBlendMode=t,t){case"screen":e.blendFunc(e.ONE,e.ONE_MINUS_SRC_COLOR);break;case"lighter":case"additive":e.blendFunc(e.ONE,e.ONE);break;case"multiply":e.blendFunc(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA);break;default:e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this.currentBlendMode="normal"}},e.prototype.getFontContext=function(){return void 0===this.fontContext2D&&(console.warn("[WebGL Renderer] WARNING : Using Standard me.Text with WebGL will severly impact performances !"),this.createFontTexture(this.cache)),this.fontContext2D},e.prototype.restore=function(){if(0!==this._matrixStack.length){var t=this._colorStack.pop(),e=this._matrixStack.pop();this.currentColor.copy(t),this.currentTransform.copy(e),this.setBlendMode(this._blendStack.pop()),pool$1.push(t),pool$1.push(e)}0!==this._scissorStack.length?this.currentScissor.set(this._scissorStack.pop()):(this.gl.disable(this.gl.SCISSOR_TEST),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height)},e.prototype.save=function(){this._colorStack.push(this.currentColor.clone()),this._matrixStack.push(this.currentTransform.clone()),this.gl.isEnabled(this.gl.SCISSOR_TEST)&&this._scissorStack.push(this.currentScissor.slice()),this._blendStack.push(this.getBlendMode())},e.prototype.rotate=function(t){this.currentTransform.rotate(t)},e.prototype.scale=function(t,e){this.currentTransform.scale(t,e)},e.prototype.setAntiAlias=function(e,i){t.prototype.setAntiAlias.call(this,e,i)},e.prototype.setGlobalAlpha=function(t){this.currentColor.alpha=t},e.prototype.getGlobalAlpha=function(){return this.currentColor.alpha},e.prototype.setColor=function(t){var e=this.currentColor.alpha;this.currentColor.copy(t),this.currentColor.alpha*=e},e.prototype.setLineWidth=function(t){this.getScreenContext().lineWidth(t)},e.prototype.strokeArc=function(t,e,i,o,r,n,s){void 0===n&&(n=!1),void 0===s&&(s=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.arc(t,e,i,o,r,n),!1===s?this.currentCompositor.drawVertices(this.gl.LINE_STRIP,this.path2D.points):(this.path2D.closePath(),this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath())))},e.prototype.fillArc=function(t,e,i,o,r,n){void 0===n&&(n=!1),this.strokeArc(t,e,i,o,r,n,!0)},e.prototype.strokeEllipse=function(t,e,i,o,r){void 0===r&&(r=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.ellipse(t,e,i,o,0,0,360),this.path2D.closePath(),!1===r?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()))},e.prototype.fillEllipse=function(t,e,i,o){this.strokeEllipse(t,e,i,o,!1)},e.prototype.strokeLine=function(t,e,i,o){this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.moveTo(t,e),this.path2D.lineTo(i,o),this.currentCompositor.drawVertices(this.gl.LINE_STRIP,this.path2D.points))},e.prototype.fillLine=function(t,e,i,o){this.strokeLine(t,e,i,o)},e.prototype.strokePolygon=function(t,e){if(void 0===e&&(e=!1),!(this.getGlobalAlpha()<1/255)){var i;this.translate(t.pos.x,t.pos.y),this.path2D.beginPath(),this.path2D.moveTo(t.points[0].x,t.points[0].y);for(var o=1;o<t.points.length;o++)i=t.points[o],this.path2D.lineTo(i.x,i.y);this.path2D.lineTo(t.points[0].x,t.points[0].y),this.path2D.closePath(),!1===e?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()),this.translate(-t.pos.x,-t.pos.y)}},e.prototype.fillPolygon=function(t){this.strokePolygon(t,!0)},e.prototype.strokeRect=function(t,e,i,o,r){void 0===r&&(r=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.rect(t,e,i,o),!1===r?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()))},e.prototype.fillRect=function(t,e,i,o){this.strokeRect(t,e,i,o,!0)},e.prototype.strokeRoundRect=function(t,e,i,o,r,n){void 0===n&&(n=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.roundRect(t,e,i,o,r),!1===n?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):(this.path2D.closePath(),this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath())))},e.prototype.fillRoundRect=function(t,e,i,o,r){this.strokeRoundRect(t,e,i,o,r,!0)},e.prototype.setTransform=function(t){this.resetTransform(),this.transform(t)},e.prototype.transform=function(t){var e=this.currentTransform;if(e.multiply(t),!1===this.settings.subPixel){var i=e.toArray();i[6]|=0,i[7]|=0}},e.prototype.translate=function(t,e){var i=this.currentTransform;if(i.translate(t,e),!1===this.settings.subPixel){var o=i.toArray();o[6]|=0,o[7]|=0}},e.prototype.clipRect=function(t,e,i,o){var r=this.backBufferCanvas,n=this.gl;if(0!==t||0!==e||i!==r.width||o!==r.height){var s=this.currentScissor;if(n.isEnabled(n.SCISSOR_TEST)&&s[0]===t&&s[1]===e&&s[2]===i&&s[3]===o)return;this.flush(),n.enable(this.gl.SCISSOR_TEST),n.scissor(t+this.currentTransform.tx,r.height-o-e-this.currentTransform.ty,i,o),s[0]=t,s[1]=e,s[2]=i,s[3]=o}else n.disable(n.SCISSOR_TEST)},e.prototype.setMask=function(t){var e=this.gl;this.flush(),e.enable(e.STENCIL_TEST),e.clear(e.STENCIL_BUFFER_BIT),e.colorMask(!1,!1,!1,!1),e.stencilFunc(e.NOTEQUAL,1,1),e.stencilOp(e.REPLACE,e.REPLACE,e.REPLACE),this.fill(t),this.flush(),e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.EQUAL,1,1),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)},e.prototype.clearMask=function(){this.flush(),this.gl.disable(this.gl.STENCIL_TEST)},e}(Renderer),designRatio=1,designWidth=0,designHeight=0,settings={parent:void 0,renderer:2,doubleBuffering:!1,autoScale:!1,scale:1,scaleMethod:"fit",transparent:!1,blendMode:"normal",antiAlias:!1,failIfMajorPerformanceCaveat:!0,subPixel:!1,preferWebGL1:!1,powerPreference:"default",verbose:!1,consoleHeader:!0};function autoDetectRenderer(t){try{if(device$1.isWebGLSupported(t))return new WebGLRenderer(t)}catch(t){console.log("Error creating WebGL renderer :"+t.message)}return new CanvasRenderer(t)}function onresize(){var t=renderer.settings,e=1,i=1;if(t.autoScale){var o=1/0,r=1/0;if(globalThis.getComputedStyle){var n=globalThis.getComputedStyle(renderer.getScreenCanvas(),null);o=parseInt(n.maxWidth,10)||1/0,r=parseInt(n.maxHeight,10)||1/0}var s=device$1.getParentBounds(getParent()),a=Math.min(o,s.width),l=Math.min(r,s.height),h=a/l;if("fill-min"===t.scaleMethod&&h>designRatio||"fill-max"===t.scaleMethod&&h<designRatio||"flex-width"===t.scaleMethod){var c=Math.min(o,designHeight*h);e=i=a/c,renderer.resize(Math.floor(c),designHeight)}else if("fill-min"===t.scaleMethod&&h<designRatio||"fill-max"===t.scaleMethod&&h>designRatio||"flex-height"===t.scaleMethod){var u=Math.min(r,designWidth*(l/a));e=i=l/u,renderer.resize(designWidth,Math.floor(u))}else"flex"===t.scaleMethod?renderer.resize(Math.floor(a),Math.floor(l)):"stretch"===t.scaleMethod?(e=a/designWidth,i=l/designHeight):e=i=h<designRatio?a/designWidth:l/designHeight;scale(e,i)}}var CANVAS=0,WEBGL=1,AUTO=2,parent=null,scaleRatio=new Vector2d(1,1),renderer=null;function init(t,e,i){if(!exports.initialized)throw new Error("me.video.init() called before engine initialization.");(settings=Object.assign(settings,i||{})).width=t,settings.height=e,settings.doubleBuffering=!!settings.doubleBuffering,settings.transparent=!!settings.transparent,settings.antiAlias=!!settings.antiAlias,settings.failIfMajorPerformanceCaveat=!!settings.failIfMajorPerformanceCaveat,settings.subPixel=!!settings.subPixel,settings.verbose=!!settings.verbose,-1!==settings.scaleMethod.search(/^(fill-(min|max)|fit|flex(-(width|height))?|stretch)$/)?settings.autoScale="auto"===settings.scale||!0:(settings.scaleMethod="fit",settings.autoScale="auto"===settings.scale||!1),!1!==settings.consoleHeader&&console.log("melonJS 2 (v"+version+") | http://melonjs.org");var o=utils.getUriFragment();!0!==o.webgl&&!0!==o.webgl1&&!0!==o.webgl2||(settings.renderer=WEBGL,!0===o.webgl1&&(settings.preferWebGL1=!0)),settings.scale=settings.autoScale?1:+settings.scale||1,scaleRatio.set(settings.scale,settings.scale),(settings.autoScale||1!==settings.scale)&&(settings.doubleBuffering=!0),designRatio=t/e,designWidth=t,designHeight=e,settings.zoomX=t*scaleRatio.x,settings.zoomY=e*scaleRatio.y,globalThis.addEventListener("resize",utils.function.throttle((function(t){emit(WINDOW_ONRESIZE,t)}),100),!1),globalThis.addEventListener("orientationchange",(function(t){emit(WINDOW_ONORIENTATION_CHANGE,t)}),!1),globalThis.addEventListener("onmozorientationchange",(function(t){emit(WINDOW_ONORIENTATION_CHANGE,t)}),!1),!0===device$1.ScreenOrientation&&(globalThis.screen.orientation.onchange=function(t){emit(WINDOW_ONORIENTATION_CHANGE,t)}),globalThis.addEventListener("scroll",utils.function.throttle((function(t){emit(WINDOW_ONSCROLL,t)}),100),!1),on(WINDOW_ONRESIZE,onresize,this),on(WINDOW_ONORIENTATION_CHANGE,onresize,this);try{switch(settings.renderer){case AUTO:case WEBGL:renderer=autoDetectRenderer(settings);break;default:renderer=new CanvasRenderer(settings)}}catch(t){return console(t.message),!1}((parent=device$1.getElement(void 0!==settings.parent?settings.parent:document.body)).appendChild(renderer.getScreenCanvas()),onresize(),"MutationObserver"in globalThis)&&new MutationObserver(onresize.bind(this)).observe(parent,{attributes:!1,childList:!0,subtree:!0});if(!1!==settings.consoleHeader){var r=renderer instanceof CanvasRenderer?"CANVAS":"WebGL"+renderer.WebGLVersion,n=device$1.hasWebAudio?"Web Audio":"HTML5 Audio",s="string"==typeof renderer.GPURenderer?" ("+renderer.GPURenderer+")":"";console.log(r+" renderer"+s+" | "+n+" | pixel ratio "+device$1.devicePixelRatio+" | "+(device$1.nodeJS?"node.js":device$1.isMobile?"mobile":"desktop")+" | "+device$1.getScreenOrientation()+" | "+device$1.language),console.log("resolution: requested "+t+"x"+e+", got "+renderer.getWidth()+"x"+renderer.getHeight())}return emit(VIDEO_INIT),!0}function createCanvas(t,e,i){var o;if(void 0===i&&(i=!1),0===t||0===e)throw new Error("width or height was zero, Canvas could not be initialized !");return!0===device$1.OffscreenCanvas&&!0===i?void 0===(o=new OffscreenCanvas(0,0)).style&&(o.style={}):o=document.createElement("canvas"),o.width=t,o.height=e,o}function getParent(){return parent}function scale(t,e){var i=renderer.getScreenCanvas(),o=renderer.getScreenContext(),r=renderer.settings,n=device$1.devicePixelRatio,s=r.zoomX=i.width*t*n,a=r.zoomY=i.height*e*n;scaleRatio.set(t*n,e*n),i.style.width=s/n+"px",i.style.height=a/n+"px",renderer.setAntiAlias(o,r.antiAlias),renderer.setBlendMode(r.blendMode,o),repaint()}var video=Object.freeze({__proto__:null,CANVAS:CANVAS,WEBGL:WEBGL,AUTO:AUTO,get parent(){return parent},scaleRatio:scaleRatio,get renderer(){return renderer},init:init,createCanvas:createCanvas,getParent:getParent,scale:scale}),GUID_base="",GUID_index=0,utils={agent:agentUtils,array:arrayUtils,file:fileUtils,string:stringUtils,function:fnUtils,getPixels:function(t){if(t instanceof HTMLImageElement){var e=CanvasRenderer.getContext2d(createCanvas(t.width,t.height));return e.drawImage(t,0,0),e.getImageData(0,0,t.width,t.height)}return t.getContext("2d").getImageData(0,0,t.width,t.height)},checkVersion:function(t,e){void 0===e&&(e=version);for(var i=t.split("."),o=e.split("."),r=Math.min(i.length,o.length),n=0,s=0;s<r&&!(n=+i[s]-+o[s]);s++);return n||i.length-o.length},getUriFragment:function(t){var e={};if(void 0===t){if(void 0===globalThis.document)return e;var i=globalThis.document.location;if(!i||!i.hash)return e;t=i.hash}else{var o=t.indexOf("#");if(-1===o)return e;t=t.slice(o,t.length)}return t.slice(1).split("&").filter((function(t){return""!==t})).forEach((function(t){var i=t.split("="),o=i.shift(),r=i.join("=");e[o]=r||!0})),e},resetGUID:function(t,e){void 0===e&&(e=0),GUID_base=toHex$1(t.toString().toUpperCase()),GUID_index=e},createGUID:function(t){return void 0===t&&(t=1),GUID_index+=t,GUID_base+"-"+(t||GUID_index)}},framecount=0,framedelta=0,last=0,now=0,delta=0,step=0,minstep=0,timers=[],timerId=0;function update(t){last=now,(delta=(now=t)-last)<0&&(delta=0),timer.tick=delta>minstep&&timer.interpolation?delta/step:1,updateTimers()}function clearTimer(t){for(var e=0,i=timers.length;e<i;e++)if(timers[e].timerId===t){timers.splice(e,1);break}}function updateTimers(){for(var t=0,e=timers.length;t<e;t++){var i=timers[t];i.pauseable&&state.isPaused()||(i.elapsed+=delta),i.elapsed>=i.delay&&(i.fn.apply(null,i.args),!0===i.repeat?i.elapsed-=i.delay:timer.clearTimeout(i.timerId))}}on(BOOT,(function(){timer.reset(),now=last=0,on(GAME_BEFORE_UPDATE,update)}));var timer={tick:1,fps:0,maxfps:60,interpolation:!1,reset:function(){last=now=globalThis.performance.now(),delta=0,framedelta=0,framecount=0,step=Math.ceil(1e3/this.maxfps),minstep=1e3/this.maxfps*1.25},setTimeout:function(t,e,i){for(var o=[],r=arguments.length-3;r-- >0;)o[r]=arguments[r+3];return timers.push({fn:t,delay:e,elapsed:0,repeat:!1,timerId:++timerId,pauseable:!0===i||!0,args:o}),timerId},setInterval:function(t,e,i){for(var o=[],r=arguments.length-3;r-- >0;)o[r]=arguments[r+3];return timers.push({fn:t,delay:e,elapsed:0,repeat:!0,timerId:++timerId,pauseable:!0===i||!0,args:o}),timerId},clearTimeout:function(t){utils.function.defer(clearTimer,this,t)},clearInterval:function(t){utils.function.defer(clearTimer,this,t)},getTime:function(){return now},getDelta:function(){return delta},countFPS:function(){framecount++,framedelta+=delta,framecount%10==0&&(this.fps=clamp(Math.round(1e3*framecount/framedelta),0,this.maxfps),framedelta=0,framecount=0)}},timer$1=timer,lastTime=0,vendors=["ms","moz","webkit","o"],x,requestAnimationFrame=globalThis.requestAnimationFrame,cancelAnimationFrame=globalThis.cancelAnimationFrame;for(x=0;x<vendors.length&&!requestAnimationFrame;++x)requestAnimationFrame=globalThis[vendors[x]+"RequestAnimationFrame"];for(x=0;x<vendors.length&&!cancelAnimationFrame;++x)cancelAnimationFrame=globalThis[vendors[x]+"CancelAnimationFrame"]||globalThis[vendors[x]+"CancelRequestAnimationFrame"];requestAnimationFrame&&cancelAnimationFrame||(requestAnimationFrame=function(t){var e=globalThis.performance.now(),i=Math.max(0,1e3/timer$1.maxfps-(e-lastTime)),o=globalThis.setTimeout((function(){t(e+i)}),i);return lastTime=e+i,o},cancelAnimationFrame=function(t){globalThis.clearTimeout(t)},globalThis.requestAnimationFrame=requestAnimationFrame,globalThis.cancelAnimationFrame=cancelAnimationFrame),function(){function t(t,e,i,o,r){if([t,e,i,o].every((function(t){return Number.isFinite(t)}))){var n,s,a,l;if(4===(r=function(t){var e=typeof t;if("undefined"===e||null===t)return[0];if("function"===e)return[NaN];if("object"===e)return"function"==typeof t[Symbol.iterator]?[].concat(t).map((function(t){var e=typeof t;return"undefined"===e||null===t?0:"function"===e?NaN:"object"===e?u(t):p(t)})):[u(t)];return[p(t)]}(r)).length)n=d(r[0]),s=d(r[1]),a=d(r[2]),l=d(r[3]);else if(3===r.length)n=d(r[0]),s=d(r[1]),l=d(r[1]),a=d(r[2]);else if(2===r.length)n=d(r[0]),a=d(r[0]),s=d(r[1]),l=d(r[1]);else{if(1!==r.length)throw new Error(r.length+" is not a valid size for radii sequence.");n=d(r[0]),s=d(r[0]),a=d(r[0]),l=d(r[0])}var h=[n,s,a,l],c=h.find((function(t){var e=t.x,i=t.y;return e<0||i<0}));if(!h.some((function(t){var e=t.x,i=t.y;return!Number.isFinite(e)||!Number.isFinite(i)}))){if(c)throw new Error("Radius value "+c+" is negative.");!function(t){var e=t[0],r=t[1],n=t[2],s=t[3],a=[Math.abs(i)/(e.x+r.x),Math.abs(o)/(r.y+n.y),Math.abs(i)/(n.x+s.x),Math.abs(o)/(e.y+s.y)],l=Math.min.apply(Math,a);l<=1&&t.forEach((function(t){t.x*=l,t.y*=l}))}(h),i<0&&o<0?(this.moveTo(t-n.x,e),this.ellipse(t+i+s.x,e-s.y,s.x,s.y,0,1.5*-Math.PI,-Math.PI),this.ellipse(t+i+a.x,e+o+a.y,a.x,a.y,0,-Math.PI,-Math.PI/2),this.ellipse(t-l.x,e+o+l.y,l.x,l.y,0,-Math.PI/2,0),this.ellipse(t-n.x,e-n.y,n.x,n.y,0,0,-Math.PI/2)):i<0?(this.moveTo(t-n.x,e),this.ellipse(t+i+s.x,e+s.y,s.x,s.y,0,-Math.PI/2,-Math.PI,1),this.ellipse(t+i+a.x,e+o-a.y,a.x,a.y,0,-Math.PI,1.5*-Math.PI,1),this.ellipse(t-l.x,e+o-l.y,l.x,l.y,0,Math.PI/2,0,1),this.ellipse(t-n.x,e+n.y,n.x,n.y,0,0,-Math.PI/2,1)):o<0?(this.moveTo(t+n.x,e),this.ellipse(t+i-s.x,e-s.y,s.x,s.y,0,Math.PI/2,0,1),this.ellipse(t+i-a.x,e+o+a.y,a.x,a.y,0,0,-Math.PI/2,1),this.ellipse(t+l.x,e+o+l.y,l.x,l.y,0,-Math.PI/2,-Math.PI,1),this.ellipse(t+n.x,e-n.y,n.x,n.y,0,-Math.PI,1.5*-Math.PI,1)):(this.moveTo(t+n.x,e),this.ellipse(t+i-s.x,e+s.y,s.x,s.y,0,-Math.PI/2,0),this.ellipse(t+i-a.x,e+o-a.y,a.x,a.y,0,0,Math.PI/2),this.ellipse(t+l.x,e+o-l.y,l.x,l.y,0,Math.PI/2,Math.PI),this.ellipse(t+n.x,e+n.y,n.x,n.y,0,Math.PI,1.5*Math.PI)),this.closePath(),this.moveTo(t,e)}}function u(t){return{x:t.x,y:t.y,z:t.z,w:t.w}}function p(t){return+t}function d(t){var e=p(t);return Number.isFinite(e)?{x:e,y:e}:Object(t)===t?{x:p(t.x||0),y:p(t.y||0)}:{x:NaN,y:NaN}}}void 0===Path2D.prototype.roundRect&&(Path2D.prototype.roundRect=t),globalThis.CanvasRenderingContext2D&&void 0===globalThis.CanvasRenderingContext2D.prototype.roundRect&&(globalThis.CanvasRenderingContext2D.prototype.roundRect=t),globalThis.OffscreenCanvasRenderingContext2D&&void 0===globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect&&(globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect=t)}();var plugins={},BasePlugin=function(){this.version="10.9.0"},plugin={Base:BasePlugin,patch:function(t,e,i){if(void 0!==t.prototype&&(t=t.prototype),"function"!=typeof t[e])throw new Error(e+" is not an existing function");var o=t[e];Object.defineProperty(t,e,{configurable:!0,value:function(t,e){return function(){this._patched=o;var t=e.apply(this,arguments);return this._patched=null,t}}(0,i)})},register:function(t,e){if(plugins[e])throw new Error("plugin "+e+" already registered");var i=[];arguments.length>2&&(i=Array.prototype.slice.call(arguments,1)),i[0]=t;var o=new(t.bind.apply(t,i));if(void 0===o||!(o instanceof plugin.Base))throw new Error("Plugin should extend the me.plugin.Base Class !");if(utils.checkVersion(o.version)>0)throw new Error("Plugin version mismatch, expected: "+o.version+", got: "+version);plugins[e]=o}},Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Easing.Bounce.In(2*t):.5*Easing.Bounce.Out(2*t-1)+.5}}},Interpolation={Linear:function(t,e){var i=t.length-1,o=i*e,r=Math.floor(o),n=Interpolation.Utils.Linear;return e<0?n(t[0],t[1],o):e>1?n(t[i],t[i-1],i-o):n(t[r],t[r+1>i?i:r+1],o-r)},Bezier:function(t,e){var i,o=0,r=t.length-1,n=Math.pow,s=Interpolation.Utils.Bernstein;for(i=0;i<=r;i++)o+=n(1-e,r-i)*n(e,i)*t[i]*s(r,i);return o},CatmullRom:function(t,e){var i=t.length-1,o=i*e,r=Math.floor(o),n=Interpolation.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(r=Math.floor(o=i*(1+e))),n(t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i],o-r)):e<0?t[0]-(n(t[0],t[0],t[1],t[1],-o)-t[0]):e>1?t[i]-(n(t[i],t[i],t[i-1],t[i-1],o-i)-t[i]):n(t[r?r-1:0],t[r],t[i<r+1?i:r+1],t[i<r+2?i:r+2],o-r)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=Interpolation.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:function(){var t=[1];return function(e){var i,o=1;if(t[e])return t[e];for(i=e;i>1;i--)o*=i;return t[e]=o,o}}(),CatmullRom:function(t,e,i,o,r){var n=.5*(i-t),s=.5*(o-e),a=r*r;return(2*e-2*i+n+s)*(r*a)+(-3*e+3*i-2*n-s)*a+n*r+e}}},Tween=function(t){this.setProperties(t)},staticAccessors={Easing:{configurable:!0},Interpolation:{configurable:!0}};function setContextStyle(t,e,i){void 0===i&&(i=!1),t.font=e.font,t.fillStyle=e.fillStyle.toRGBA(),!0===i&&(t.strokeStyle=e.strokeStyle.toRGBA(),t.lineWidth=e.lineWidth),t.textAlign=e.textAlign,t.textBaseline=e.textBaseline}Tween.prototype.onResetEvent=function(t){this.setProperties(t)},Tween.prototype.setProperties=function(t){for(var e in this._object=t,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=Easing.Linear.None,this._interpolationFunction=Interpolation.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._tweenTimeTracker=lastUpdate,this.isPersistent=!1,this.updateWhenPaused=!1,this.isRenderable=!1,t)"object"!=typeof t&&(this._valuesStart[e]=parseFloat(t[e]))},Tween.prototype._resumeCallback=function(t){this._startTime&&(this._startTime+=t)},Tween.prototype.onActivateEvent=function(){on(STATE_RESUME,this._resumeCallback,this)},Tween.prototype.onDeactivateEvent=function(){off(STATE_RESUME,this._resumeCallback)},Tween.prototype.to=function(t,e){return this._valuesEnd=t,void 0!==e&&("number"==typeof e?this._duration=e:"object"==typeof e&&(e.duration&&(this._duration=e.duration),e.yoyo&&this.yoyo(e.yoyo),e.easing&&this.easing(e.easing),e.repeat&&this.repeat(e.repeat),e.delay&&this.delay(e.delay),e.interpolation&&this.interpolation(e.interpolation),e.autoStart&&this.start())),this},Tween.prototype.start=function(t){for(var e in void 0===t&&(t=timer$1.getTime()),this._onStartCallbackFired=!1,world.addChild(this),this._startTime=t+this._delayTime,this._valuesEnd){if(this._valuesEnd[e]instanceof Array){if(0===this._valuesEnd[e].length)continue;this._valuesEnd[e]=[this._object[e]].concat(this._valuesEnd[e])}this._valuesStart[e]=this._object[e],this._valuesStart[e]instanceof Array==!1&&(this._valuesStart[e]*=1),this._valuesStartRepeat[e]=this._valuesStart[e]||0}return this},Tween.prototype.stop=function(){return world.removeChildNow(this),this},Tween.prototype.delay=function(t){return this._delayTime=t,this},Tween.prototype.repeat=function(t){return this._repeat=t,this},Tween.prototype.yoyo=function(t){return this._yoyo=t,this},Tween.prototype.easing=function(t){if("function"!=typeof t)throw new Error("invalid easing function for me.Tween.easing()");return this._easingFunction=t,this},Tween.prototype.interpolation=function(t){return this._interpolationFunction=t,this},Tween.prototype.chain=function(){return this._chainedTweens=arguments,this},Tween.prototype.onStart=function(t){return this._onStartCallback=t,this},Tween.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},Tween.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},Tween.prototype.update=function(t){this._tweenTimeTracker=lastUpdate>this._tweenTimeTracker?lastUpdate:this._tweenTimeTracker+t;var e,i=this._tweenTimeTracker;if(i<this._startTime)return!0;!1===this._onStartCallbackFired&&(null!==this._onStartCallback&&this._onStartCallback.call(this._object),this._onStartCallbackFired=!0);var o=(i-this._startTime)/this._duration;o=o>1?1:o;var r=this._easingFunction(o);for(e in this._valuesEnd){var n=this._valuesStart[e]||0,s=this._valuesEnd[e];s instanceof Array?this._object[e]=this._interpolationFunction(s,r):("string"==typeof s&&(s=n+parseFloat(s)),"number"==typeof s&&(this._object[e]=n+(s-n)*r))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,r),1===o){if(this._repeat>0){for(e in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat){if("string"==typeof this._valuesEnd[e]&&(this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(this._valuesEnd[e])),this._yoyo){var a=this._valuesStartRepeat[e];this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=a}this._valuesStart[e]=this._valuesStartRepeat[e]}return this._yoyo&&(this._reversed=!this._reversed),this._startTime=i+this._delayTime,!0}world.removeChildNow(this),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var l=0,h=this._chainedTweens.length;l<h;l++)this._chainedTweens[l].start(i);return!1}return!0},staticAccessors.Easing.get=function(){return Easing},staticAccessors.Interpolation.get=function(){return Interpolation},Object.defineProperties(Tween,staticAccessors);var TextMetrics=function(t){function e(e){t.call(this),this.ancestor=e,this.setMinMax(0,0,0,0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.lineHeight=function(){return this.ancestor instanceof Text?this.ancestor.fontSize*this.ancestor.lineHeight:this.ancestor.fontData.capHeight*this.ancestor.lineHeight*this.ancestor.fontScale.y},e.prototype.lineWidth=function(t,e){if(this.ancestor instanceof Text)return e.measureText(t).width;for(var i=t.split(""),o=0,r=null,n=0;n<i.length;n++){var s=i[n].charCodeAt(0),a=this.ancestor.fontData.glyphs[s],l=r&&r.kerning?r.getKerning(s):0;o+=(a.xadvance+l)*this.ancestor.fontScale.x,r=a}return o},e.prototype.measureText=function(t,e){var i;i=Array.isArray(t)?t:(""+t).split("\n"),void 0!==e&&(e.save(),setContextStyle(e,this.ancestor)),this.width=this.height=0;for(var o=0;o<i.length;o++)this.width=Math.max(this.lineWidth(trimRight(i[o]),e),this.width),this.height+=this.lineHeight();return this.width=Math.ceil(this.width),this.height=Math.ceil(this.height),this.x=Math.floor("right"===this.ancestor.textAlign?this.ancestor.pos.x-this.width:"center"===this.ancestor.textAlign?this.ancestor.pos.x-this.width/2:this.ancestor.pos.x),this.y=Math.floor(0===this.ancestor.textBaseline.search(/^(top|hanging)$/)?this.ancestor.pos.y:"middle"===this.ancestor.textBaseline?this.ancestor.pos.y-this.lineHeight()/2:this.ancestor.pos.y-this.lineHeight()),void 0!==e&&e.restore(),this},e.prototype.wordWrap=function(t,e,i){var o,r="",n=[];Array.isArray(t)&&(t=t.join(" ")),o=t.replace(/[\r\n]+/g," ").split(" "),void 0!==i&&(i.save(),setContextStyle(i,this.ancestor));for(var s=0;s<o.length;s++){var a=o[s];this.lineWidth(r+a+" ",i)<e?r+=a+" ":(n.push(r+"\n"),r=a+" ")}return n.push(r),void 0!==i&&i.restore(),n},e}(Bounds$1),runits=["ex","em","pt","px"],toPX=[12,24,.75,1],getContext2d=function(t,e){return!0===e.offScreenCanvas?e.context:t.getFontContext()},Text=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.onResetEvent(e,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e,i){void 0!==i.fillStyle?i.fillStyle instanceof Color?this.fillStyle=i.fillStyle:this.fillStyle=pool$1.pull("Color").parseCSS(i.fillStyle):this.fillStyle=pool$1.pull("Color",0,0,0),void 0!==i.strokeStyle?i.strokeStyle instanceof Color?this.strokeStyle=i.strokeStyle:this.strokeStyle=pool$1.pull("Color").parseCSS(i.strokeStyle):this.strokeStyle=pool$1.pull("Color",0,0,0),this.lineWidth=i.lineWidth||1,this.textAlign=i.textAlign||"left",this.textBaseline=i.textBaseline||"top",this.lineHeight=i.lineHeight||1,this.offScreenCanvas=!1,this.wordWrapWidth=i.wordWrapWidth||-1,this._text=[],this.fontSize=10,void 0!==i.anchorPoint?this.anchorPoint.setV(i.anchorPoint):this.anchorPoint.set(0,0),void 0!==i.floating&&(this.floating=!!i.floating),this.setFont(i.font,i.size),!0===i.bold&&this.bold(),!0===i.italic&&this.italic(),!0===i.offScreenCanvas&&(this.offScreenCanvas=!0,this.canvas=createCanvas(2,2,!0),this.context=this.canvas.getContext("2d")),this.metrics=new TextMetrics(this),this.setText(i.text)},e.prototype.onDeactivateEvent=function(){!0===this.offScreenCanvas&&(renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit)),renderer.cache.delete(this.canvas),this.canvas.width=this.canvas.height=0,this.context=void 0,this.canvas=void 0,this.glTextureUnit=void 0)},e.prototype.bold=function(){return this.font="bold "+this.font,this.isDirty=!0,this},e.prototype.italic=function(){return this.font="italic "+this.font,this.isDirty=!0,this},e.prototype.setFont=function(t,e){void 0===e&&(e=10);var i=t.split(",").map((function(t){return t=t.trim(),/(^".*"$)|(^'.*'$)/.test(t)?t:'"'+t+'"'}));if("number"==typeof e)this.fontSize=e,e+="px";else{var o=e.match(/([-+]?[\d.]*)(.*)/);this.fontSize=parseFloat(o[1]),o[2]?this.fontSize*=toPX[runits.indexOf(o[2])]:e+="px"}return this.height=this.fontSize,this.font=e+" "+i.join(","),this.isDirty=!0,this},e.prototype.setText=function(t){void 0===t&&(t="");var e=this.getBounds();if(this._text.toString()!==t.toString()&&(Array.isArray(t)?this._text=t:this._text=(""+t).split("\n")),this._text.length>0&&this.wordWrapWidth>0&&(this._text=this.metrics.wordWrap(this._text,this.wordWrapWidth,getContext2d(renderer,this))),e.addBounds(this.metrics.measureText(this._text,getContext2d(renderer,this)),!0),!0===this.offScreenCanvas){var i=Math.ceil(this.metrics.width),o=Math.ceil(this.metrics.height);renderer instanceof WebGLRenderer&&(this.glTextureUnit=renderer.cache.getUnit(renderer.cache.get(this.canvas)),renderer.currentCompositor.unbindTexture2D(null,this.glTextureUnit),1===renderer.WebGLVersion&&(i=nextPowerOfTwo(this.metrics.width),o=nextPowerOfTwo(this.metrics.height))),this.canvas.width<i||this.canvas.height<o?(this.canvas.width=i,this.canvas.height=o):this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this._drawFont(this.context,this._text,this.pos.x-this.metrics.x,this.pos.y-this.metrics.y,!1)}return this.isDirty=!0,this},e.prototype.measureText=function(t,e){return void 0===t&&(t=renderer),void 0===e&&(e=this._text),this.metrics.measureText(e,getContext2d(t,this))},e.prototype.draw=function(t,e,i,o,r){void 0===this.ancestor?(this.pos.x===i&&this.pos.y===o||(this.pos.x=i,this.pos.y=o,this.isDirty=!0),this.setText(e),i=this.metrics.x,o=this.metrics.y,t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity())):(i=this.pos.x,o=this.pos.y),!1===t.settings.subPixel&&(i=~~i,o=~~o),!0===this.offScreenCanvas?t.drawImage(this.canvas,i,o):t.drawFont(this._drawFont(t.getFontContext(),this._text,i,o,r)),void 0===this.ancestor&&t.restore()},e.prototype.drawStroke=function(t,e,i,o){this.draw(t,e,i,o,!0)},e.prototype._drawFont=function(t,e,i,o,r){void 0===r&&(r=!1),setContextStyle(t,this,r);for(var n=0;n<e.length;n++){var s=trimRight(e[n]);t[r?"strokeText":"fillText"](s,i,o),o+=this.metrics.lineHeight()}return this.metrics},e.prototype.destroy=function(){pool$1.push(this.fillStyle),pool$1.push(this.strokeStyle),this.fillStyle=this.strokeStyle=void 0,this.metrics=void 0,this._text.length=0,t.prototype.destroy.call(this)},e}(Renderable),BitmapText=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.textAlign=o.textAlign||"left",this.textBaseline=o.textBaseline||"top",this.lineHeight=o.lineHeight||1,this.wordWrapWidth=o.wordWrapWidth||-1,this._text=[],this.fontScale=pool$1.pull("Vector2d",1,1),this.fontImage="object"==typeof o.font?o.font:loader.getImage(o.font),"string"!=typeof o.fontData?this.fontData=pool$1.pull("BitmapTextData",loader.getBinary(o.font)):this.fontData=pool$1.pull("BitmapTextData",o.fontData.includes("info face")?o.fontData:loader.getBinary(o.fontData)),void 0!==o.floating&&(this.floating=!!o.floating),void 0!==o.fillStyle&&(o.fillStyle instanceof Color?this.fillStyle.setColor(o.fillStyle):this.fillStyle.parseCSS(o.fillStyle)),void 0!==o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),this.metrics=new TextMetrics(this),"number"==typeof o.size&&1!==o.size&&this.resize(o.size),this.setText(o.text)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={fillStyle:{configurable:!0}};return e.prototype.set=function(t,e){return this.textAlign=t,e&&this.resize(e),this.isDirty=!0,this},e.prototype.setText=function(t){return void 0===t&&(t=""),this._text.toString()!==t.toString()&&(Array.isArray(t)?this._text=t:this._text=(""+t).split("\n"),this.isDirty=!0),this._text.length>0&&this.wordWrapWidth>0&&(this._text=this.metrics.wordWrap(this._text,this.wordWrapWidth)),this.getBounds().addBounds(this.metrics.measureText(this._text),!0),this},i.fillStyle.get=function(){return this.tint},i.fillStyle.set=function(t){this.tint=t},e.prototype.resize=function(t){return this.fontScale.set(t,t),this.getBounds().addBounds(this.metrics.measureText(this._text),!0),this.isDirty=!0,this},e.prototype.measureText=function(t){return void 0===t&&(t=this._text),this.metrics.measureText(t)},e.prototype.draw=function(t,e,i,o){var r=t.globalAlpha();void 0===this.ancestor?(this.setText(e),t.setGlobalAlpha(r*this.getOpacity())):(i=this.pos.x,o=this.pos.y);for(var n=i,s=this.metrics.lineHeight(),a=0,l=0;l<this._text.length;l++){i=n;var h=trimRight(this._text[l]),c=this.metrics.lineWidth(h);switch(this.textAlign){case"right":i-=c;break;case"center":i-=.5*c}switch(this.textBaseline){case"middle":o-=.5*s;break;case"ideographic":case"alphabetic":case"bottom":o-=s}!0===this.isDirty&&void 0===this.ancestor&&(0===l&&(this.pos.y=o),a<c&&(a=c,this.pos.x=i));for(var u=null,p=0,d=h.length;p<d;p++){var f=h.charCodeAt(p),y=this.fontData.glyphs[f],g=y.width,v=y.height,m=u&&u.kerning?u.getKerning(f):0;0!==g&&0!==v&&t.drawImage(this.fontImage,y.x,y.y,g,v,i+y.xoffset,o+y.yoffset*this.fontScale.y,g*this.fontScale.x,v*this.fontScale.y),i+=(y.xadvance+m)*this.fontScale.x,u=y}o+=s}void 0===this.ancestor&&t.setGlobalAlpha(r),this.isDirty=!1},e.prototype.destroy=function(){pool$1.push(this.fontScale),this.fontScale=void 0,pool$1.push(this.fontData),this.fontData=void 0,this._text.length=0,this.metrics=void 0,t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(Renderable),LOG2_PAGE_SIZE=9,PAGE_SIZE=1<<LOG2_PAGE_SIZE,Glyph=function(){this.id=0,this.x=0,this.y=0,this.width=0,this.height=0,this.u=0,this.v=0,this.u2=0,this.v2=0,this.xoffset=0,this.yoffset=0,this.xadvance=0,this.fixedWidth=!1};Glyph.prototype.getKerning=function(t){if(this.kerning){var e=this.kerning[t>>>LOG2_PAGE_SIZE];if(e)return e[t&PAGE_SIZE-1]||0}return 0},Glyph.prototype.setKerning=function(t,e){this.kerning||(this.kerning={});var i=this.kerning[t>>>LOG2_PAGE_SIZE];void 0===i&&(this.kerning[t>>>LOG2_PAGE_SIZE]={},i=this.kerning[t>>>LOG2_PAGE_SIZE]),i[t&PAGE_SIZE-1]=e};var capChars=["M","N","B","D","C","E","F","K","A","G","H","I","J","L","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function getValueFromPair(t,e){var i=t.match(e);if(!i)throw new Error("Could not find pattern "+e+" in string: "+t);return i[0].split("=")[1]}function getFirstGlyph(t){for(var e=Object.keys(t),i=0;i<e.length;i++)if(e[i]>32)return t[e[i]];return null}function createSpaceGlyph(t){var e=" ".charCodeAt(0),i=t[e];i||((i=new Glyph).id=e,i.xadvance=getFirstGlyph(t).xadvance,t[e]=i)}var BitmapTextData=function(t){this.onResetEvent(t)};BitmapTextData.prototype.onResetEvent=function(t){this.padTop=0,this.padRight=0,this.padBottom=0,this.padLeft=0,this.lineHeight=0,this.capHeight=1,this.descent=0,this.glyphs={},this.parse(t)},BitmapTextData.prototype.parse=function(t){if(!t)throw new Error("File containing font data was empty, cannot load the bitmap font.");var e=t.split(/\r\n|\n/),i=t.match(/padding\=\d+,\d+,\d+,\d+/g);if(!i)throw new Error("Padding not found in first line");var o=i[0].split("=")[1].split(",");this.padTop=parseFloat(o[0]),this.padLeft=parseFloat(o[1]),this.padBottom=parseFloat(o[2]),this.padRight=parseFloat(o[3]),this.lineHeight=parseFloat(getValueFromPair(e[1],/lineHeight\=\d+/g));var r,n=parseFloat(getValueFromPair(e[1],/base\=\d+/g)),s=this.padTop+this.padBottom,a=null;for(r=4;r<e.length;r++){var l=e[r],h=l.split(/=|\s+/);if(l&&!/^kernings/.test(l))if(/^kerning\s/.test(l)){var c=parseFloat(h[2]),u=parseFloat(h[4]),p=parseFloat(h[6]);null!=(a=this.glyphs[c])&&a.setKerning(u,p)}else{a=new Glyph;var d=parseFloat(h[2]);a.id=d,a.x=parseFloat(h[4]),a.y=parseFloat(h[6]),a.width=parseFloat(h[8]),a.height=parseFloat(h[10]),a.xoffset=parseFloat(h[12]),a.yoffset=parseFloat(h[14]),a.xadvance=parseFloat(h[16]),a.width>0&&a.height>0&&(this.descent=Math.min(n+a.yoffset,this.descent)),this.glyphs[d]=a}}this.descent+=this.padBottom,createSpaceGlyph(this.glyphs);var f=null;for(r=0;r<capChars.length;r++){var y=capChars[r];if(f=this.glyphs[y.charCodeAt(0)])break}if(f)this.capHeight=f.height;else for(var g in this.glyphs)if(this.glyphs.hasOwnProperty(g)){if(0===(a=this.glyphs[g]).height||0===a.width)continue;this.capHeight=Math.max(this.capHeight,a.height)}this.capHeight-=s};var ColorLayer=function(t){function e(e,i,o){t.call(this,0,0,1/0,1/0),this.color=pool$1.pull("Color").parseCSS(i),this.onResetEvent(e,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e,i){void 0===i&&(i=0),this.name=t,this.pos.z=i,this.floating=!0,this.color.parseCSS(e)},e.prototype.draw=function(t,e){var i=viewport.pos;t.save(),t.clipRect(e.left-i.x,e.top-i.y,e.width,e.height),t.clearColor(this.color),t.restore()},e.prototype.destroy=function(){pool$1.push(this.color),this.color=void 0,t.prototype.destroy.call(this)},e}(Renderable),ImageLayer=function(t){function e(e,i,o){t.call(this,e,i,o),this.floating=!0,this.offset.set(e,i),this.ratio=pool$1.pull("Vector2d",1,1),void 0!==o.ratio&&(isNumeric(o.ratio)?this.ratio.set(o.ratio,+o.ratio):this.ratio.setV(o.ratio)),void 0===o.anchorPoint?this.anchorPoint.set(0,0):"number"==typeof o.anchorPoint?this.anchorPoint.set(o.anchorPoint,o.anchorPoint):this.anchorPoint.setV(o.anchorPoint),this.repeat=o.repeat||"repeat",on(ONCONTEXT_RESTORED,this.createPattern,this)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={repeat:{configurable:!0}};return i.repeat.get=function(){return this._repeat},i.repeat.set=function(t){switch(this._repeat=t,this._repeat){case"no-repeat":this.repeatX=!1,this.repeatY=!1;break;case"repeat-x":this.repeatX=!0,this.repeatY=!1;break;case"repeat-y":this.repeatX=!1,this.repeatY=!0;break;default:this.repeatX=!0,this.repeatY=!0}this.resize(viewport.width,viewport.height),this.createPattern()},e.prototype.onActivateEvent=function(){var t=this;on(VIEWPORT_ONCHANGE,this.updateLayer,this),on(VIEWPORT_ONRESIZE,this.resize,this),once(LEVEL_LOADED,(function(){t.updateLayer(viewport.pos)})),!0!==this.ancestor.root&&this.updateLayer(viewport.pos)},e.prototype.resize=function(e,i){t.prototype.resize.call(this,this.repeatX?1/0:e,this.repeatY?1/0:i)},e.prototype.createPattern=function(){this._pattern=renderer.createPattern(this.image,this._repeat)},e.prototype.updateLayer=function(t){var e=this.ratio.x,i=this.ratio.y;if(0!==e||0!==i){var o=this.width,r=this.height,n=viewport.bounds.width,s=viewport.bounds.height,a=this.anchorPoint.x,l=this.anchorPoint.y,h=a*(e-1)*(n-viewport.width)+this.offset.x-e*t.x,c=l*(i-1)*(s-viewport.height)+this.offset.y-i*t.y;this.repeatX?this.pos.x=h%o:this.pos.x=h,this.repeatY?this.pos.y=c%r:this.pos.y=c,this.isDirty=!0}},e.prototype.preDraw=function(t){t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity()),t.setTint(this.tint)},e.prototype.draw=function(t){var e=this.width,i=this.height,o=viewport.bounds.width,r=viewport.bounds.height,n=this.anchorPoint.x,s=this.anchorPoint.y,a=this.pos.x,l=this.pos.y;0===this.ratio.x&&0===this.ratio.y&&(a+=n*(o-e),l+=s*(r-i)),t.translate(a,l),t.drawPattern(this._pattern,0,0,2*viewport.width,2*viewport.height)},e.prototype.onDeactivateEvent=function(){off(VIEWPORT_ONCHANGE,this.updateLayer),off(VIEWPORT_ONRESIZE,this.resize)},e.prototype.destroy=function(){pool$1.push(this.ratio),this.ratio=void 0,off(ONCONTEXT_RESTORED,this.createPattern),t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(Sprite),NineSliceSprite=function(t){function e(e,i,o){if(t.call(this,e,i,o),"number"!=typeof o.width||"number"!=typeof o.height)throw new Error("height and width properties are mandatory");this.width=Math.floor(o.width),this.height=Math.floor(o.height),this.nss_width=this.width,this.nss_height=this.height,this.insetx=o.insetx,this.insety=o.insety}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t){var e=this.current,i=this.pos.x,o=this.pos.y,r=e.width,n=e.height,s=e.offset,a=this.offset;0!==e.angle&&(t.translate(-i,-o),t.rotate(e.angle),i-=n,r=e.height,n=e.width);var l=a.x+s.x,h=a.y+s.y,c=this.insetx||r/4,u=this.insety||n/4;t.drawImage(this.image,l,h,c,u,i,o,c,u),t.drawImage(this.image,l+r-c,h,c,u,i+this.nss_width-c,o,c,u),t.drawImage(this.image,l,h+n-u,c,u,i,o+this.nss_height-u,c,u),t.drawImage(this.image,l+r-c,h+n-u,c,u,i+this.nss_width-c,o+this.nss_height-u,c,u);var p=r-(c<<1),d=n-(u<<1),f=this.nss_width-(c<<1),y=this.nss_height-(u<<1);t.drawImage(this.image,l+c,h,p,u,i+c,o,f,u),t.drawImage(this.image,l+c,h+n-u,p,u,i+c,o+this.nss_height-u,f,u),t.drawImage(this.image,l,h+u,c,d,i,o+u,c,y),t.drawImage(this.image,l+r-c,h+u,c,d,i+this.nss_width-c,o+u,c,y),t.drawImage(this.image,l+c,h+u,p,d,i+c,o+u,f,y)},e}(Sprite),GUI_Object=function(t){function e(e,i,o){t.call(this,e,i,o),this.isClickable=!0,this.holdThreshold=250,this.isHoldable=!1,this.hover=!1,this.holdTimeout=null,this.released=!0,this.floating=!0,this.isKinematic=!1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clicked=function(t){if(0===t.button&&this.isClickable)return this.dirty=!0,this.released=!1,this.isHoldable&&(null!==this.holdTimeout&&timer$1.clearTimeout(this.holdTimeout),this.holdTimeout=timer$1.setTimeout(this.hold.bind(this),this.holdThreshold,!1),this.released=!1),this.onClick(t)},e.prototype.onClick=function(){return!1},e.prototype.enter=function(t){return this.hover=!0,this.dirty=!0,this.onOver(t)},e.prototype.onOver=function(){},e.prototype.leave=function(t){return this.hover=!1,this.dirty=!0,this.release(t),this.onOut(t)},e.prototype.onOut=function(){},e.prototype.release=function(t){if(!1===this.released)return this.released=!0,this.dirty=!0,timer$1.clearTimeout(this.holdTimeout),this.onRelease(t)},e.prototype.onRelease=function(){return!1},e.prototype.hold=function(){timer$1.clearTimeout(this.holdTimeout),this.dirty=!0,this.released||this.onHold()},e.prototype.onHold=function(){},e.prototype.onActivateEvent=function(){registerPointerEvent("pointerdown",this,this.clicked.bind(this)),registerPointerEvent("pointerup",this,this.release.bind(this)),registerPointerEvent("pointercancel",this,this.release.bind(this)),registerPointerEvent("pointerenter",this,this.enter.bind(this)),registerPointerEvent("pointerleave",this,this.leave.bind(this))},e.prototype.onDeactivateEvent=function(){releasePointerEvent("pointerdown",this),releasePointerEvent("pointerup",this),releasePointerEvent("pointercancel",this),releasePointerEvent("pointerenter",this),releasePointerEvent("pointerleave",this),timer$1.clearTimeout(this.holdTimeout)},e}(Sprite),Collectable=function(t){function e(e,i,o){t.call(this,e,i,o),this.name=o.name,this.type=o.type,this.id=o.id;var r=o.shapes;void 0===r&&(r=pool.pull("Polygon",0,0,[pool.pull("Vector2d",0,0),pool.pull("Vector2d",this.width,0),pool.pull("Vector2d",this.width,this.height)])),this.body=new Body(this,r),this.body.collisionType=collision.types.COLLECTABLE_OBJECT,this.body.setCollisionMask(collision.types.PLAYER_OBJECT),this.body.setStatic(!0),o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Sprite),Trigger=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.anchorPoint.set(0,0),this.fade=o.fade,this.duration=o.duration,this.fading=!1,this.name="Trigger",this.type=o.type,this.id=o.id,this.gotolevel=o.to,this.triggerSettings={event:"level"},["type","container","onLoaded","flatten","setViewportBounds","to"].forEach(function(t){void 0!==o[t]&&(this.triggerSettings[t]=o[t])}.bind(this));var r=o.shapes;void 0===r&&(r=pool.pull("Polygon",0,0,[pool.pull("Vector2d",0,0),pool.pull("Vector2d",this.width,0),pool.pull("Vector2d",this.width,this.height)])),this.body=new Body(this,r),this.body.collisionType=collision.types.ACTION_OBJECT,this.body.setCollisionMask(collision.types.PLAYER_OBJECT),this.body.setStatic(!0),this.resize(this.body.getBounds().width,this.body.getBounds().height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getTriggerSettings=function(){return"string"==typeof this.triggerSettings.container&&(this.triggerSettings.container=world.getChildByName(this.triggerSettings.container)[0]),this.triggerSettings},e.prototype.onFadeComplete=function(){level.load(this.gotolevel,this.getTriggerSettings()),viewport.fadeOut(this.fade,this.duration)},e.prototype.triggerEvent=function(){var t=this.getTriggerSettings();if("level"!==t.event)throw new Error("Trigger invalid type");this.gotolevel=t.to,this.fade&&this.duration?this.fading||(this.fading=!0,viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):level.load(this.gotolevel,t)},e.prototype.onCollision=function(){return"Trigger"===this.name&&this.triggerEvent.apply(this),!1},e}(Renderable),Draggable=function(t){function e(e,i,o,r){t.call(this,e,i,o,r),this.isKinematic=!1,this.dragging=!1,this.dragId=null,this.grabOffset=new Vector2d(0,0),this.initEvents()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.initEvents=function(){var t=this;registerPointerEvent("pointerdown",this,(function(e){emit(DRAGSTART,e,t)})),registerPointerEvent("pointerup",this,(function(e){emit(DRAGEND,e,t)})),registerPointerEvent("pointercancel",this,(function(e){emit(DRAGEND,e,t)})),on(POINTERMOVE,this.dragMove.bind(this)),on(DRAGSTART,(function(e,i){i===t&&t.dragStart(e)})),on(DRAGEND,(function(e,i){i===t&&t.dragEnd(e)}))},e.prototype.dragStart=function(t){if(!1===this.dragging)return this.dragging=!0,this.grabOffset.set(t.gameX,t.gameY),this.grabOffset.sub(this.pos),!1},e.prototype.dragMove=function(t){!0===this.dragging&&(this.pos.set(t.gameX,t.gameY,this.pos.z),this.pos.sub(this.grabOffset))},e.prototype.dragEnd=function(){if(!0===this.dragging)return this.dragging=!1,!1},e.prototype.destroy=function(){off(POINTERMOVE,this.dragMove),off(DRAGSTART,this.dragStart),off(DRAGEND,this.dragEnd),releasePointerEvent("pointerdown",this),releasePointerEvent("pointerup",this),releasePointerEvent("pointercancel",this),t.prototype.destroy.call(this)},e}(Renderable),DropTarget=function(t){function e(e,i,o,r){t.call(this,e,i,o,r),this.isKinematic=!1,this.CHECKMETHOD_OVERLAP="overlaps",this.CHECKMETHOD_CONTAINS="contains",this.checkMethod=this.CHECKMETHOD_OVERLAP,on(DRAGEND,this.checkOnMe,this)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setCheckMethod=function(t){"function"==typeof this.getBounds()[this.checkMethod]&&(this.checkMethod=t)},e.prototype.checkOnMe=function(t,e){e&&this.getBounds()[this.checkMethod](e.getBounds())&&this.drop(e)},e.prototype.drop=function(){},e.prototype.destroy=function(){off(DRAGEND,this.checkOnMe),t.prototype.destroy.call(this)},e}(Renderable),ParticleEmitterSettings={width:1,height:1,image:void 0,textureSize:8,tint:"#fff",totalParticles:50,angle:Math.PI/2,angleVariation:0,minLife:1e3,maxLife:3e3,speed:2,speedVariation:1,minRotation:0,maxRotation:0,minStartScale:1,maxStartScale:1,minEndScale:0,maxEndScale:0,gravity:0,wind:0,followTrajectory:!1,textureAdditive:!1,blendMode:"normal",onlyInViewport:!0,floating:!1,maxParticles:10,frequency:100,duration:1/0,framesToSkip:0},defaultParticleTexture;function createDefaultParticleTexture(t,e){if(void 0===t&&(t=8),void 0===e&&(e=8),void 0===defaultParticleTexture){var i=(defaultParticleTexture=createCanvas(t,e,!0)).getContext("2d");i.fillStyle="#fff",i.fillRect(0,0,t,e)}return defaultParticleTexture}var ParticleEmitter=function(t){function e(e,i,o){void 0===o&&(o={}),t.call(this,e,i,1|o.width,1|o.height),this.settings={},this.centerOn(e,i),this._stream=!1,this._frequencyTimer=0,this._durationTimer=0,this._enabled=!1,this.alwaysUpdate=!0,this.autoSort=!1,this._updateCount=0,this._dt=0,this.reset(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(t){void 0===t&&(t={}),Object.assign(this.settings,ParticleEmitterSettings,t),void 0===this.settings.image&&(this.settings.image=createDefaultParticleTexture(t.textureSize,t.textureSize)),this.floating=this.settings.floating,this.isDirty=!0},e.prototype.getRandomPointX=function(){return randomFloat(0,this.getBounds().width)},e.prototype.getRandomPointY=function(){return randomFloat(0,this.getBounds().height)},e.prototype.addParticles=function(t){for(var e=0;e<t;e++)this.addChild(pool$1.pull("Particle",this),this.pos.z);this.isDirty=!0},e.prototype.isRunning=function(){return this._enabled&&this._stream},e.prototype.streamParticles=function(t){this._enabled=!0,this._stream=!0,this.settings.frequency=Math.max(1,this.settings.frequency),this._durationTimer="number"==typeof t?t:this.settings.duration},e.prototype.stopStream=function(){this._enabled=!1},e.prototype.burstParticles=function(t){this._enabled=!0,this._stream=!1,this.addParticles("number"==typeof t?t:this.settings.totalParticles),this._enabled=!1},e.prototype.update=function(e){if(++this._updateCount>this.settings.framesToSkip&&(this._updateCount=0),this._updateCount>0)return this._dt+=e,this.isDirty;if(e+=this._dt,this._dt=0,this.isDirty|=t.prototype.update.call(this,e),this._enabled&&this._stream){if(this._durationTimer!==1/0&&(this._durationTimer-=e,this._durationTimer<=0))return this.stopStream(),this.isDirty;this._frequencyTimer+=e;var i=this.children.length;i<this.settings.totalParticles&&this._frequencyTimer>=this.settings.frequency&&(i+this.settings.maxParticles<=this.settings.totalParticles?this.addParticles(this.settings.maxParticles):this.addParticles(this.settings.totalParticles-i),this._frequencyTimer=0,this.isDirty=!0)}return this.isDirty},e.prototype.destroy=function(){t.prototype.destroy.call(this,arguments),this.settings.image=void 0,this.settings=void 0},e}(Container),Particle=function(t){function e(e){t.call(this,e.getRandomPointX(),e.getRandomPointY(),e.settings.image.width,e.settings.image.height),this.onResetEvent(e,!0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e){void 0===e&&(e=!1),!1===e?(this.pos.set(t.getRandomPointX(),t.getRandomPointY()),this.resize(t.settings.image.width,t.settings.image.height),this.currentTransform.identity()):this.vel=pool$1.pull("Vector2d"),this.image=t.settings.image,this.alwaysUpdate=!0,"string"==typeof t.settings.tint&&this.tint.parseCSS(t.settings.tint),!0===t.settings.textureAdditive&&(this.blendMode="additive"),"normal"!==t.settings.blendMode&&(this.blendMode=t.settings.blendMode);var i=t.settings.angle+(t.settings.angleVariation>0?(randomFloat(0,2)-1)*t.settings.angleVariation:0),o=t.settings.speed+(t.settings.speedVariation>0?(randomFloat(0,2)-1)*t.settings.speedVariation:0);this.vel.set(o*Math.cos(i),-o*Math.sin(i)),this.life=randomFloat(t.settings.minLife,t.settings.maxLife),this.startLife=this.life,this.startScale=clamp(randomFloat(t.settings.minStartScale,t.settings.maxStartScale),t.settings.minStartScale,t.settings.maxStartScale),this.endScale=clamp(randomFloat(t.settings.minEndScale,t.settings.maxEndScale),t.settings.minEndScale,t.settings.maxEndScale),this.gravity=t.settings.gravity,this.wind=t.settings.wind,this.followTrajectory=t.settings.followTrajectory,this.onlyInViewport=t.settings.onlyInViewport,this._deltaInv=timer$1.maxfps/1e3,t.settings.followTrajectory||(this.angle=randomFloat(t.settings.minRotation,t.settings.maxRotation))},e.prototype.update=function(e){var i=e*this._deltaInv;if(this.life=this.life>e?this.life-e:0,this.life<=0)return this.ancestor.removeChild(this),!1;var o=this.life/this.startLife,r=this.startScale;this.startScale>this.endScale?r=(r*=o)<this.endScale?this.endScale:r:this.startScale<this.endScale&&(r=(r/=o)>this.endScale?this.endScale:r),this.alpha=o,this.vel.x+=this.wind*i,this.vel.y+=this.gravity*i;var n=this.followTrajectory?Math.atan2(this.vel.y,this.vel.x):this.angle;return this.pos.x+=this.vel.x*i,this.pos.y+=this.vel.y*i,this.currentTransform.setTransform(r,0,0,0,r,0,this.pos.x,this.pos.y,1).rotate(n),this.isDirty=this.inViewport||!this.onlyInViewport,t.prototype.update.call(this,e)},e.prototype.draw=function(t){var e=this.width,i=this.height;t.drawImage(this.image,0,0,e,i,-e/2,-i/2,e,i)},e}(Renderable),Entity=function(t){function e(e,i,o){if("number"!=typeof o.width||"number"!=typeof o.height)throw new Error("height and width properties are mandatory when passing settings parameters to an object entity");t.call(this,e,i,o.width,o.height),this.children=[],o.image&&(o.framewidth=o.framewidth||o.width,o.frameheight=o.frameheight||o.height,this.renderable=new Sprite(0,0,o)),o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),"string"==typeof o.name&&(this.name=o.name),this.type=o.type||"",this.id=o.id||"",this.alive=!0,void 0===o.shapes&&(o.shapes=pool$1.pull("Polygon",0,0,[pool$1.pull("Vector2d",0,0),pool$1.pull("Vector2d",this.width,0),pool$1.pull("Vector2d",this.width,this.height),pool$1.pull("Vector2d",0,this.height)])),this.body=new Body(this,o.shapes,this.onBodyUpdate.bind(this)),0===this.width&&0===this.height&&this.resize(this.body.getBounds().width,this.body.getBounds().height),this.body.setCollisionMask(o.collisionMask),this.body.setCollisionType(o.collisionType),this.autoTransform=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={renderable:{configurable:!0}};return i.renderable.get=function(){return this.children[0]},i.renderable.set=function(e){if(!(e instanceof t))throw new Error(e+"should extend me.Renderable");this.children[0]=e,this.children[0].ancestor=this},e.prototype.update=function(e){return this.renderable&&(this.isDirty|=this.renderable.update(e)),t.prototype.update.call(this,e)},e.prototype.onBodyUpdate=function(t){this.getBounds().addBounds(t.getBounds(),!0),this.updateBoundsPos(this.pos.x,this.pos.y)},e.prototype.preDraw=function(e){e.save(),e.translate(this.pos.x+this.body.getBounds().x,this.pos.y+this.body.getBounds().y),this.renderable instanceof t&&e.translate(this.anchorPoint.x*this.body.getBounds().width,this.anchorPoint.y*this.body.getBounds().height)},e.prototype.draw=function(e,i){var o=this.renderable;o instanceof t&&(o.preDraw(e),o.draw(e,i),o.postDraw(e))},e.prototype.destroy=function(){this.renderable&&(this.renderable.destroy.apply(this.renderable,arguments),this.children.splice(0,1)),t.prototype.destroy.call(this,arguments)},e.prototype.onDeactivateEvent=function(){this.renderable&&this.renderable.onDeactivateEvent&&this.renderable.onDeactivateEvent()},Object.defineProperties(e.prototype,i),e}(Renderable);function warning(t,e,i){var o="melonJS: %s is deprecated since version %s, please use %s",r=(new Error).stack;console.groupCollapsed?console.groupCollapsed("%c"+o,"font-weight:normal;color:yellow;",t,i,e):console.warn(o,t,i,e),void 0!==r&&console.warn(r),console.groupCollapsed&&console.groupEnd()}device$1.turnOnPointerLock=function(){return warning("device.turnOnPointerLock()","input.requestPointerLock()","10.3.0"),requestPointerLock()},device$1.turnOffPointerLock=function(){return warning("device.turnOffPointerLock()","input.exitPointerLock()","10.3.0"),exitPointerLock()},Object.defineProperty(Renderer.prototype,"Texture",{get:function(){return warning("me.video.renderer.Texture","me.TextureAtlas","10.4.0"),TextureAtlas}});var DraggableEntity=function(t){function e(e,i,o){warning("DraggableEntity","Draggable","10.5.0"),t.call(this,e,i,o.width,o.height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Draggable),DroptargetEntity=function(t){function e(e,i,o){warning("DroptargetEntity","DropTarget","10.5.0"),t.call(this,e,i,o.width,o.height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(DropTarget),version="10.9.0";exports.initialized=!1;var skipAutoInit=!1;function boot(){!0!==exports.initialized&&(pool$1.register("me.Entity",Entity),pool$1.register("me.Collectable",Collectable),pool$1.register("me.Trigger",Trigger),pool$1.register("me.Tween",Tween,!0),pool$1.register("me.Color",Color,!0),pool$1.register("me.Particle",Particle,!0),pool$1.register("me.Sprite",Sprite),pool$1.register("me.NineSliceSprite",NineSliceSprite),pool$1.register("me.Renderable",Renderable),pool$1.register("me.Text",Text,!0),pool$1.register("me.BitmapText",BitmapText),pool$1.register("me.BitmapTextData",BitmapTextData,!0),pool$1.register("me.ImageLayer",ImageLayer),pool$1.register("me.ColorLayer",ColorLayer,!0),pool$1.register("me.Vector2d",Vector2d,!0),pool$1.register("me.Vector3d",Vector3d,!0),pool$1.register("me.ObservableVector2d",ObservableVector2d,!0),pool$1.register("me.ObservableVector3d",ObservableVector3d,!0),pool$1.register("me.Matrix2d",Matrix2d,!0),pool$1.register("me.Matrix3d",Matrix3d,!0),pool$1.register("me.Rect",Rect,!0),pool$1.register("me.RoundRect",RoundRect,!0),pool$1.register("me.Polygon",Polygon,!0),pool$1.register("me.Line",Line,!0),pool$1.register("me.Ellipse",Ellipse,!0),pool$1.register("me.Bounds",Bounds$1,!0),pool$1.register("Entity",Entity),pool$1.register("Collectable",Collectable),pool$1.register("Trigger",Trigger),pool$1.register("Tween",Tween,!0),pool$1.register("Color",Color,!0),pool$1.register("Particle",Particle,!0),pool$1.register("Sprite",Sprite),pool$1.register("NineSliceSprite",NineSliceSprite),pool$1.register("Renderable",Renderable),pool$1.register("Text",Text,!0),pool$1.register("BitmapText",BitmapText),pool$1.register("BitmapTextData",BitmapTextData,!0),pool$1.register("ImageLayer",ImageLayer),pool$1.register("ColorLayer",ColorLayer,!0),pool$1.register("Vector2d",Vector2d,!0),pool$1.register("Vector3d",Vector3d,!0),pool$1.register("ObservableVector2d",ObservableVector2d,!0),pool$1.register("ObservableVector3d",ObservableVector3d,!0),pool$1.register("Matrix2d",Matrix2d,!0),pool$1.register("Matrix3d",Matrix3d,!0),pool$1.register("Rect",Rect,!0),pool$1.register("RoundRect",RoundRect,!0),pool$1.register("Polygon",Polygon,!0),pool$1.register("Line",Line,!0),pool$1.register("Ellipse",Ellipse,!0),pool$1.register("Bounds",Bounds$1,!0),emit(BOOT),loader.setNocache(utils.getUriFragment().nocache||!1),initKeyboardEvent(),exports.initialized=!0)}device$1.onReady((function(){boot()})),exports.BitmapText=BitmapText,exports.BitmapTextData=BitmapTextData,exports.Body=Body,exports.Bounds=Bounds$1,exports.Camera2d=Camera2d,exports.CanvasRenderer=CanvasRenderer,exports.Collectable=Collectable,exports.Color=Color,exports.ColorLayer=ColorLayer,exports.Container=Container,exports.Draggable=Draggable,exports.DraggableEntity=DraggableEntity,exports.DropTarget=DropTarget,exports.DroptargetEntity=DroptargetEntity,exports.Ellipse=Ellipse,exports.Entity=Entity,exports.GLShader=GLShader,exports.GUI_Object=GUI_Object,exports.ImageLayer=ImageLayer,exports.Line=Line,exports.Math=math,exports.Matrix2d=Matrix2d,exports.Matrix3d=Matrix3d,exports.NineSliceSprite=NineSliceSprite,exports.ObservableVector2d=ObservableVector2d,exports.ObservableVector3d=ObservableVector3d,exports.Particle=Particle,exports.ParticleEmitter=ParticleEmitter,exports.ParticleEmitterSettings=ParticleEmitterSettings,exports.Pointer=Pointer,exports.Polygon=Polygon,exports.QuadTree=QuadTree,exports.Rect=Rect,exports.Renderable=Renderable,exports.Renderer=Renderer,exports.RoundRect=RoundRect,exports.Sprite=Sprite,exports.Stage=Stage,exports.TMXHexagonalRenderer=TMXHexagonalRenderer,exports.TMXIsometricRenderer=TMXIsometricRenderer,exports.TMXLayer=TMXLayer,exports.TMXOrthogonalRenderer=TMXOrthogonalRenderer,exports.TMXRenderer=TMXRenderer,exports.TMXStaggeredRenderer=TMXStaggeredRenderer,exports.TMXTileMap=TMXTileMap,exports.TMXTileset=TMXTileset,exports.TMXTilesetGroup=TMXTilesetGroup,exports.Text=Text,exports.TextureAtlas=TextureAtlas,exports.Tile=Tile,exports.Trigger=Trigger,exports.Tween=Tween,exports.Vector2d=Vector2d,exports.Vector3d=Vector3d,exports.WebGLCompositor=WebGLCompositor,exports.WebGLRenderer=WebGLRenderer,exports.World=World,exports.audio=audio,exports.boot=boot,exports.collision=collision,exports.device=device$1,exports.event=event$1,exports.game=game,exports.input=input,exports.level=level,exports.loader=loader,exports.plugin=plugin,exports.plugins=plugins,exports.pool=pool$1,exports.save=save,exports.skipAutoInit=skipAutoInit,exports.state=state,exports.timer=timer$1,exports.utils=utils,exports.version=version,exports.video=video,exports.warning=warning,Object.defineProperty(exports,"__esModule",{value:!0})}));
30
+ function(){var t;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var i=e._howls.length-1;i>=0;i--)e._howls[i].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,i){var o=this;return o.ctx&&o.ctx.listener?(e="number"!=typeof e?o._pos[1]:e,i="number"!=typeof i?o._pos[2]:i,"number"!=typeof t?o._pos:(o._pos=[t,e,i],void 0!==o.ctx.listener.positionX?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]),o)):o},HowlerGlobal.prototype.orientation=function(t,e,i,o,n,r){var s=this;if(!s.ctx||!s.ctx.listener)return s;var a=s._orientation;return e="number"!=typeof e?a[1]:e,i="number"!=typeof i?a[2]:i,o="number"!=typeof o?a[3]:o,n="number"!=typeof n?a[4]:n,r="number"!=typeof r?a[5]:r,"number"!=typeof t?a:(s._orientation=[t,e,i,o,n,r],void 0!==s.ctx.listener.forwardX?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(n,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(r,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,i,o,n,r),s)},Howl.prototype.init=(t=Howl.prototype.init,function(e){var i=this;return i._orientation=e.orientation||[1,0,0],i._stereo=e.stereo||null,i._pos=e.pos||null,i._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},i._onstereo=e.onstereo?[{fn:e.onstereo}]:[],i._onpos=e.onpos?[{fn:e.onpos}]:[],i._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}),Howl.prototype.stereo=function(t,i){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"stereo",action:function(){o.stereo(t,i)}}),o;var n=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===i){if("number"!=typeof t)return o._stereo;o._stereo=t,o._pos=[t,0,0]}for(var r=o._getSoundIds(i),s=0;s<r.length;s++){var a=o._soundById(r[s]);if(a){if("number"!=typeof t)return a._stereo;a._stereo=t,a._pos=[t,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",a._panner&&a._panner.pan||e(a,n),"spatial"===n?void 0!==a._panner.positionX?(a._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(t,0,0):a._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),o._emit("stereo",a._id)}}return o},Howl.prototype.pos=function(t,i,o,n){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"pos",action:function(){r.pos(t,i,o,n)}}),r;if(i="number"!=typeof i?0:i,o="number"!=typeof o?-.5:o,void 0===n){if("number"!=typeof t)return r._pos;r._pos=[t,i,o]}for(var s=r._getSoundIds(n),a=0;a<s.length;a++){var h=r._soundById(s[a]);if(h){if("number"!=typeof t)return h._pos;h._pos=[t,i,o],h._node&&(h._panner&&!h._panner.pan||e(h,"spatial"),void 0!==h._panner.positionX?(h._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),h._panner.positionZ.setValueAtTime(o,Howler.ctx.currentTime)):h._panner.setPosition(t,i,o)),r._emit("pos",h._id)}}return r},Howl.prototype.orientation=function(t,i,o,n){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"orientation",action:function(){r.orientation(t,i,o,n)}}),r;if(i="number"!=typeof i?r._orientation[1]:i,o="number"!=typeof o?r._orientation[2]:o,void 0===n){if("number"!=typeof t)return r._orientation;r._orientation=[t,i,o]}for(var s=r._getSoundIds(n),a=0;a<s.length;a++){var h=r._soundById(s[a]);if(h){if("number"!=typeof t)return h._orientation;h._orientation=[t,i,o],h._node&&(h._panner||(h._pos||(h._pos=r._pos||[0,0,-.5]),e(h,"spatial")),void 0!==h._panner.orientationX?(h._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),h._panner.orientationZ.setValueAtTime(o,Howler.ctx.currentTime)):h._panner.setOrientation(t,i,o)),r._emit("orientation",h._id)}}return r},Howl.prototype.pannerAttr=function(){var t,i,o,n=this,r=arguments;if(!n._webAudio)return n;if(0===r.length)return n._pannerAttr;if(1===r.length){if("object"!=typeof r[0])return(o=n._soundById(parseInt(r[0],10)))?o._pannerAttr:n._pannerAttr;t=r[0],void 0===i&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),n._pannerAttr={coneInnerAngle:void 0!==t.pannerAttr.coneInnerAngle?t.pannerAttr.coneInnerAngle:n._coneInnerAngle,coneOuterAngle:void 0!==t.pannerAttr.coneOuterAngle?t.pannerAttr.coneOuterAngle:n._coneOuterAngle,coneOuterGain:void 0!==t.pannerAttr.coneOuterGain?t.pannerAttr.coneOuterGain:n._coneOuterGain,distanceModel:void 0!==t.pannerAttr.distanceModel?t.pannerAttr.distanceModel:n._distanceModel,maxDistance:void 0!==t.pannerAttr.maxDistance?t.pannerAttr.maxDistance:n._maxDistance,refDistance:void 0!==t.pannerAttr.refDistance?t.pannerAttr.refDistance:n._refDistance,rolloffFactor:void 0!==t.pannerAttr.rolloffFactor?t.pannerAttr.rolloffFactor:n._rolloffFactor,panningModel:void 0!==t.pannerAttr.panningModel?t.pannerAttr.panningModel:n._panningModel})}else 2===r.length&&(t=r[0],i=parseInt(r[1],10));for(var s=n._getSoundIds(i),a=0;a<s.length;a++)if(o=n._soundById(s[a])){var h=o._pannerAttr;h={coneInnerAngle:void 0!==t.coneInnerAngle?t.coneInnerAngle:h.coneInnerAngle,coneOuterAngle:void 0!==t.coneOuterAngle?t.coneOuterAngle:h.coneOuterAngle,coneOuterGain:void 0!==t.coneOuterGain?t.coneOuterGain:h.coneOuterGain,distanceModel:void 0!==t.distanceModel?t.distanceModel:h.distanceModel,maxDistance:void 0!==t.maxDistance?t.maxDistance:h.maxDistance,refDistance:void 0!==t.refDistance?t.refDistance:h.refDistance,rolloffFactor:void 0!==t.rolloffFactor?t.rolloffFactor:h.rolloffFactor,panningModel:void 0!==t.panningModel?t.panningModel:h.panningModel};var l=o._panner;l?(l.coneInnerAngle=h.coneInnerAngle,l.coneOuterAngle=h.coneOuterAngle,l.coneOuterGain=h.coneOuterGain,l.distanceModel=h.distanceModel,l.maxDistance=h.maxDistance,l.refDistance=h.refDistance,l.rolloffFactor=h.rolloffFactor,l.panningModel=h.panningModel):(o._pos||(o._pos=n._pos||[0,0,-.5]),e(o,"spatial"))}return n},Sound.prototype.init=function(t){return function(){var e=this,i=e._parent;e._orientation=i._orientation,e._stereo=i._stereo,e._pos=i._pos,e._pannerAttr=i._pannerAttr,t.call(this),e._stereo?i.stereo(e._stereo):e._pos&&i.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,i=e._parent;return e._orientation=i._orientation,e._stereo=i._stereo,e._pos=i._pos,e._pannerAttr=i._pannerAttr,e._stereo?i.stereo(e._stereo):e._pos?i.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,i._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var e=function(t,e){"spatial"===(e=e||"spatial")?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,void 0!==t._panner.positionX?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),void 0!==t._panner.orientationX?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}}()}(mr);var _r=function(t){function e(e,i,o){if(void 0===e&&(e=0),void 0===i&&(i=0),t.call(this,e,i),void 0===o)throw new Error("undefined `onUpdate` callback");this.setCallback(o.onUpdate,o.scope)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={x:{configurable:!0},y:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),this.setMuted(t,e),void 0!==i&&this.setCallback(i.onUpdate,i.scope),this},i.x.get=function(){return this._x},i.x.set=function(t){var e=this.onUpdate.call(this.scope,t,this._y,this._x,this._y);this._x=e&&"x"in e?e.x:t},i.y.get=function(){return this._y},i.y.set=function(t){var e=this.onUpdate.call(this.scope,this._x,t,this._x,this._y);this._y=e&&"y"in e?e.y:t},e.prototype._set=function(t,e){var i=this.onUpdate.call(this.scope,t,e,this._x,this._y);return i&&"x"in i&&"y"in i?(this._x=i.x,this._y=i.y):(this._x=t,this._y=e),this},e.prototype.setMuted=function(t,e){return this._x=t,this._y=e,this},e.prototype.setCallback=function(t,e){if(void 0===e&&(e=null),"function"!=typeof t)throw new Error("invalid `onUpdate` callback");return this.onUpdate=t,this.scope=e,this},e.prototype.add=function(t){return this._set(this._x+t.x,this._y+t.y)},e.prototype.sub=function(t){return this._set(this._x-t.x,this._y-t.y)},e.prototype.scale=function(t,e){return this._set(this._x*t,this._y*(void 0!==e?e:t))},e.prototype.scaleV=function(t){return this._set(this._x*t.x,this._y*t.y)},e.prototype.div=function(t){return this._set(this._x/t,this._y/t)},e.prototype.abs=function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y)},e.prototype.clamp=function(t,i){return new e($o(this.x,t,i),$o(this.y,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set($o(this._x,t,e),$o(this._y,t,e))},e.prototype.minV=function(t){return this._set(this._x<t.x?this._x:t.x,this._y<t.y?this._y:t.y)},e.prototype.maxV=function(t){return this._set(this._x>t.x?this._x:t.x,this._y>t.y?this._y:t.y)},e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.floorSelf=function(){return this._set(Math.floor(this._x),Math.floor(this._y))},e.prototype.ceil=function(){return new e(Math.ceil(this._x),Math.ceil(this._y),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.ceilSelf=function(){return this._set(Math.ceil(this._x),Math.ceil(this._y))},e.prototype.negate=function(){return new e(-this._x,-this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.negateSelf=function(){return this._set(-this._x,-this._y)},e.prototype.copy=function(t){return this._set(t.x,t.y)},e.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},e.prototype.perp=function(){return this._set(this._y,-this._x)},e.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var n=this._x-i,r=this._y-o,s=Math.cos(t),a=Math.sin(t);return this._set(n*s-r*a+i,n*a+r*s+o)},e.prototype.dot=function(t){return this._x*t.x+this._y*t.y},e.prototype.cross=function(t){return this._x*t.y-this._y*t.x},e.prototype.lerp=function(t,e){return this._x+=(t.x-this._x)*e,this._y+=(t.y-this._y)*e,this},e.prototype.distance=function(t){return Math.sqrt((this._x-t.x)*(this._x-t.x)+(this._y-t.y)*(this._y-t.y))},e.prototype.clone=function(){return gn.pull("ObservableVector2d",this._x,this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.toVector2d=function(){return gn.pull("Vector2d",this._x,this._y)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y},Object.defineProperties(e.prototype,i),e}(vn),xr=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.onResetEvent(t,e,i)};xr.prototype.onResetEvent=function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},xr.prototype._set=function(t,e,i){return void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},xr.prototype.set=function(t,e,i){if(t!==+t||e!==+e||void 0!==i&&i!==+i)throw new Error("invalid x, y, z parameters (not a number)");return this._set(t,e,i)},xr.prototype.setZero=function(){return this.set(0,0,0)},xr.prototype.setV=function(t){return this._set(t.x,t.y,t.z)},xr.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y,this.z+(t.z||0))},xr.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y,this.z-(t.z||0))},xr.prototype.scale=function(t,e,i){return e=void 0!==e?e:t,this._set(this.x*t,this.y*e,this.z*(i||1))},xr.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},xr.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y),this.z)},xr.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2,this.z)},xr.prototype.div=function(t){return this._set(this.x/t,this.y/t,this.z/t)},xr.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y,this.z<0?-this.z:this.z)},xr.prototype.clamp=function(t,e){return new xr($o(this.x,t,e),$o(this.y,t,e),$o(this.z,t,e))},xr.prototype.clampSelf=function(t,e){return this._set($o(this.x,t,e),$o(this.y,t,e),$o(this.z,t,e))},xr.prototype.minV=function(t){var e=t.z||0;return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y,this.z<e?this.z:e)},xr.prototype.maxV=function(t){var e=t.z||0;return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y,this.z>e?this.z:e)},xr.prototype.floor=function(){return new xr(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},xr.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},xr.prototype.ceil=function(){return new xr(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},xr.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},xr.prototype.negate=function(){return new xr(-this.x,-this.y,-this.z)},xr.prototype.negateSelf=function(){return this._set(-this.x,-this.y,-this.z)},xr.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},xr.prototype.equals=function(){var t,e,i;return arguments.length>=2?(t=arguments[0],e=arguments[1],i=arguments[2]):(t=arguments[0].x,e=arguments[0].y,i=arguments[0].z),void 0===i&&(i=this.z),this.x===t&&this.y===e&&this.z===i},xr.prototype.normalize=function(){return this.div(this.length()||1)},xr.prototype.perp=function(){return this._set(this.y,-this.x,this.z)},xr.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var n=this.x-i,r=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(n*s-r*a+i,n*a+r*s+o,this.z)},xr.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*(void 0!==t.z?t.z:this.z)},xr.prototype.cross=function(t){var e=this.x,i=this.y,o=this.z,n=t.x,r=t.y,s=t.z;return this.x=i*s-o*r,this.y=o*n-e*s,this.z=e*r-i*n,this},xr.prototype.length2=function(){return this.dot(this)},xr.prototype.length=function(){return Math.sqrt(this.length2())},xr.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},xr.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y,o=this.z-(t.z||0);return Math.sqrt(e*e+i*i+o*o)},xr.prototype.angle=function(t){return Math.acos($o(this.dot(t)/(this.length()*t.length()),-1,1))},xr.prototype.project=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},xr.prototype.projectN=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},xr.prototype.clone=function(){return gn.pull("Vector3d",this.x,this.y,this.z)},xr.prototype.toString=function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z};var br=function(t){function e(e,i,o,n){if(void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0),t.call(this,e,i,o),void 0===n)throw new Error("undefined `onUpdate` callback");this.setCallback(n.onUpdate,n.scope)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i,o){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.setMuted(t,e,i),void 0!==o&&this.setCallback(o.onUpdate,o.scope),this},i.x.get=function(){return this._x},i.x.set=function(t){var e=this.onUpdate.call(this.scope,t,this._y,this._z,this._x,this._y,this._z);this._x=e&&"x"in e?e.x:t},i.y.get=function(){return this._y},i.y.set=function(t){var e=this.onUpdate.call(this.scope,this._x,t,this._z,this._x,this._y,this._z);this._y=e&&"y"in e?e.y:t},i.z.get=function(){return this._z},i.z.set=function(t){var e=this.onUpdate.call(this.scope,this._x,this._y,t,this._x,this._y,this._z);this._z=e&&"z"in e?e.z:t},e.prototype._set=function(t,e,i){var o=this.onUpdate.call(this.scope,t,e,i,this._x,this._y,this._z);return o&&"x"in o&&"y"in o&&"z"in o?(this._x=o.x,this._y=o.y,this._z=o.z):(this._x=t,this._y=e,this._z=i||0),this},e.prototype.setMuted=function(t,e,i){return this._x=t,this._y=e,this._z=i||0,this},e.prototype.setCallback=function(t,e){if(void 0===e&&(e=null),"function"!=typeof t)throw new Error("invalid `onUpdate` callback");return this.onUpdate=t,this.scope=e,this},e.prototype.add=function(t){return this._set(this._x+t.x,this._y+t.y,this._z+(t.z||0))},e.prototype.sub=function(t){return this._set(this._x-t.x,this._y-t.y,this._z-(t.z||0))},e.prototype.scale=function(t,e,i){return e=void 0!==e?e:t,this._set(this._x*t,this._y*e,this._z*(i||1))},e.prototype.scaleV=function(t){return this._set(this._x*t.x,this._y*t.y,this._z*(t.z||1))},e.prototype.div=function(t){return this._set(this._x/t,this._y/t,this._z/t)},e.prototype.abs=function(){return this._set(this._x<0?-this._x:this._x,this._y<0?-this._y:this._y,this._Z<0?-this._z:this._z)},e.prototype.clamp=function(t,i){return new e($o(this._x,t,i),$o(this._y,t,i),$o(this._z,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set($o(this._x,t,e),$o(this._y,t,e),$o(this._z,t,e))},e.prototype.minV=function(t){var e=t.z||0;return this._set(this._x<t.x?this._x:t.x,this._y<t.y?this._y:t.y,this._z<e?this._z:e)},e.prototype.maxV=function(t){var e=t.z||0;return this._set(this._x>t.x?this._x:t.x,this._y>t.y?this._y:t.y,this._z>e?this._z:e)},e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.floorSelf=function(){return this._set(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},e.prototype.ceil=function(){return new e(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.ceilSelf=function(){return this._set(Math.ceil(this._x),Math.ceil(this._y),Math.ceil(this._z))},e.prototype.negate=function(){return new e(-this._x,-this._y,-this._z,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.negateSelf=function(){return this._set(-this._x,-this._y,-this._z)},e.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},e.prototype.equals=function(t){return this._x===t.x&&this._y===t.y&&this._z===(t.z||this._z)},e.prototype.perp=function(){return this._set(this._y,-this._x,this._z)},e.prototype.rotate=function(t,e){var i=0,o=0;"object"==typeof e&&(i=e.x,o=e.y);var n=this.x-i,r=this.y-o,s=Math.cos(t),a=Math.sin(t);return this._set(n*s-r*a+i,n*a+r*s+o,this.z)},e.prototype.dot=function(t){return this._x*t.x+this._y*t.y+this._z*(t.z||1)},e.prototype.cross=function(t){var e=this._x,i=this._y,o=this._z,n=t.x,r=t.y,s=t.z;return this._set(i*s-o*r,o*n-e*s,e*r-i*n)},e.prototype.lerp=function(t,e){return this._x+=(t.x-this._x)*e,this._y+=(t.y-this._y)*e,this._z+=(t.z-this._z)*e,this},e.prototype.distance=function(t){var e=this._x-t.x,i=this._y-t.y,o=this._z-(t.z||0);return Math.sqrt(e*e+i*i+o*o)},e.prototype.clone=function(){return gn.pull("ObservableVector3d",this._x,this._y,this._z,{onUpdate:this.onUpdate})},e.prototype.toVector3d=function(){return gn.pull("Vector3d",this._x,this._y,this._z)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y+",z:"+this._z},Object.defineProperties(e.prototype,i),e}(xr),wr={exports:{}};function Tr(t,e,i){i=i||2;var o,n,r,s,a,h,l,u=e&&e.length,c=u?e[0]*i:t.length,p=Ar(t,0,c,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(t,e,i,o){var n,r,s,a=[];for(n=0,r=e.length;n<r;n++)(s=Ar(t,e[n]*o,n<r-1?e[n+1]*o:t.length,o,!1))===s.next&&(s.steiner=!0),a.push(Dr(s));for(a.sort(kr),n=0;n<a.length;n++)i=Sr(i=Ir(a[n],i),i.next);return i}(t,e,p,i)),t.length>80*i){o=r=t[0],n=s=t[1];for(var f=i;f<c;f+=i)(a=t[f])<o&&(o=a),(h=t[f+1])<n&&(n=h),a>r&&(r=a),h>s&&(s=h);l=0!==(l=Math.max(r-o,s-n))?1/l:0}return Er(p,d,i,o,n,l),d}function Ar(t,e,i,o,n){var r,s;if(n===qr(t,e,i,o)>0)for(r=e;r<i;r+=o)s=Hr(r,t[r],t[r+1],s);else for(r=i-o;r>=e;r-=o)s=Hr(r,t[r],t[r+1],s);return s&&Vr(s,s.next)&&(Wr(s),s=s.next),s}function Sr(t,e){if(!t)return t;e||(e=t);var i,o=t;do{if(i=!1,o.steiner||!Vr(o,o.next)&&0!==Fr(o.prev,o,o.next))o=o.next;else{if(Wr(o),(o=e=o.prev)===o.next)break;i=!0}}while(i||o!==e);return e}function Er(t,e,i,o,n,r,s){if(t){!s&&r&&function(t,e,i,o){var n=t;do{null===n.z&&(n.z=Br(n.x,n.y,e,i,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,o,n,r,s,a,h,l=1;do{for(i=t,t=null,r=null,s=0;i;){for(s++,o=i,a=0,e=0;e<l&&(a++,o=o.nextZ);e++);for(h=l;a>0||h>0&&o;)0!==a&&(0===h||!o||i.z<=o.z)?(n=i,i=i.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=o}r.nextZ=null,l*=2}while(s>1)}(n)}(t,o,n,r);for(var a,h,l=t;t.prev!==t.next;)if(a=t.prev,h=t.next,r?Mr(t,o,n,r):Cr(t))e.push(a.i/i),e.push(t.i/i),e.push(h.i/i),Wr(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?Er(t=Pr(Sr(t),e,i),e,i,o,n,r,2):2===s&&Or(t,e,i,o,n,r):Er(Sr(t),e,i,o,n,r,1);break}}}function Cr(t){var e=t.prev,i=t,o=t.next;if(Fr(e,i,o)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(Lr(e.x,e.y,i.x,i.y,o.x,o.y,n.x,n.y)&&Fr(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Mr(t,e,i,o){var n=t.prev,r=t,s=t.next;if(Fr(n,r,s)>=0)return!1;for(var a=n.x<r.x?n.x<s.x?n.x:s.x:r.x<s.x?r.x:s.x,h=n.y<r.y?n.y<s.y?n.y:s.y:r.y<s.y?r.y:s.y,l=n.x>r.x?n.x>s.x?n.x:s.x:r.x>s.x?r.x:s.x,u=n.y>r.y?n.y>s.y?n.y:s.y:r.y>s.y?r.y:s.y,c=Br(a,h,e,i,o),p=Br(l,u,e,i,o),d=t.prevZ,f=t.nextZ;d&&d.z>=c&&f&&f.z<=p;){if(d!==t.prev&&d!==t.next&&Lr(n.x,n.y,r.x,r.y,s.x,s.y,d.x,d.y)&&Fr(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==t.prev&&f!==t.next&&Lr(n.x,n.y,r.x,r.y,s.x,s.y,f.x,f.y)&&Fr(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=c;){if(d!==t.prev&&d!==t.next&&Lr(n.x,n.y,r.x,r.y,s.x,s.y,d.x,d.y)&&Fr(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&Lr(n.x,n.y,r.x,r.y,s.x,s.y,f.x,f.y)&&Fr(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Pr(t,e,i){var o=t;do{var n=o.prev,r=o.next.next;!Vr(n,r)&&jr(n,o,o.next,r)&&Gr(n,r)&&Gr(r,n)&&(e.push(n.i/i),e.push(o.i/i),e.push(r.i/i),Wr(o),Wr(o.next),o=t=r),o=o.next}while(o!==t);return Sr(o)}function Or(t,e,i,o,n,r){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&zr(s,a)){var h=Xr(s,a);return s=Sr(s,s.next),h=Sr(h,h.next),Er(s,e,i,o,n,r),void Er(h,e,i,o,n,r)}a=a.next}s=s.next}while(s!==t)}function kr(t,e){return t.x-e.x}function Ir(t,e){var i=function(t,e){var i,o=e,n=t.x,r=t.y,s=-1/0;do{if(r<=o.y&&r>=o.next.y&&o.next.y!==o.y){var a=o.x+(r-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(a<=n&&a>s){if(s=a,a===n){if(r===o.y)return o;if(r===o.next.y)return o.next}i=o.x<o.next.x?o:o.next}}o=o.next}while(o!==e);if(!i)return null;if(n===s)return i;var h,l=i,u=i.x,c=i.y,p=1/0;o=i;do{n>=o.x&&o.x>=u&&n!==o.x&&Lr(r<c?n:s,r,u,c,r<c?s:n,r,o.x,o.y)&&(h=Math.abs(r-o.y)/(n-o.x),Gr(o,t)&&(h<p||h===p&&(o.x>i.x||o.x===i.x&&Rr(i,o)))&&(i=o,p=h)),o=o.next}while(o!==l);return i}(t,e);if(!i)return e;var o=Xr(i,t),n=Sr(i,i.next);return Sr(o,o.next),e===i?n:e}function Rr(t,e){return Fr(t.prev,t,e.prev)<0&&Fr(e.next,t,t.next)<0}function Br(t,e,i,o,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-o)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Dr(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Lr(t,e,i,o,n,r,s,a){return(n-s)*(e-a)-(t-s)*(r-a)>=0&&(t-s)*(o-a)-(i-s)*(e-a)>=0&&(i-s)*(r-a)-(n-s)*(o-a)>=0}function zr(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&jr(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Gr(t,e)&&Gr(e,t)&&function(t,e){var i=t,o=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(o=!o),i=i.next}while(i!==t);return o}(t,e)&&(Fr(t.prev,t,e.prev)||Fr(t,e.prev,e))||Vr(t,e)&&Fr(t.prev,t,t.next)>0&&Fr(e.prev,e,e.next)>0)}function Fr(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Vr(t,e){return t.x===e.x&&t.y===e.y}function jr(t,e,i,o){var n=Ur(Fr(t,e,i)),r=Ur(Fr(t,e,o)),s=Ur(Fr(i,o,t)),a=Ur(Fr(i,o,e));return n!==r&&s!==a||(!(0!==n||!Nr(t,i,e))||(!(0!==r||!Nr(t,o,e))||(!(0!==s||!Nr(i,t,o))||!(0!==a||!Nr(i,e,o)))))}function Nr(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Ur(t){return t>0?1:t<0?-1:0}function Gr(t,e){return Fr(t.prev,t,t.next)<0?Fr(t,e,t.next)>=0&&Fr(t,t.prev,e)>=0:Fr(t,e,t.prev)<0||Fr(t,t.next,e)<0}function Xr(t,e){var i=new Yr(t.i,t.x,t.y),o=new Yr(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,o.next=i,i.prev=o,r.next=o,o.prev=r,o}function Hr(t,e,i,o){var n=new Yr(t,e,i);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function Wr(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Yr(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qr(t,e,i,o){for(var n=0,r=e,s=i-o;r<i;r+=o)n+=(t[s]-t[r])*(t[r+1]+t[s+1]),s=r;return n}wr.exports=Tr,wr.exports.default=Tr,Tr.deviation=function(t,e,i,o){var n=e&&e.length,r=n?e[0]*i:t.length,s=Math.abs(qr(t,0,r,i));if(n)for(var a=0,h=e.length;a<h;a++){var l=e[a]*i,u=a<h-1?e[a+1]*i:t.length;s-=Math.abs(qr(t,l,u,i))}var c=0;for(a=0;a<o.length;a+=3){var p=o[a]*i,d=o[a+1]*i,f=o[a+2]*i;c+=Math.abs((t[p]-t[f])*(t[d+1]-t[p+1])-(t[p]-t[d])*(t[f+1]-t[p+1]))}return 0===s&&0===c?0:Math.abs((c-s)/s)},Tr.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},o=0,n=0;n<t.length;n++){for(var r=0;r<t[n].length;r++)for(var s=0;s<e;s++)i.vertices.push(t[n][r][s]);n>0&&(o+=t[n-1].length,i.holes.push(o))}return i};var Zr=function(t,e,i){this.pos=gn.pull("Vector2d"),this._bounds,this.points=[],this.edges=[],this.indices=[],this.normals=[],this.shapeType="Polygon",this.setShape(t,e,i)};Zr.prototype.onResetEvent=function(t,e,i){this.setShape(t,e,i)},Zr.prototype.setShape=function(t,e,i){return this.pos.set(t,e),this.setVertices(i),this},Zr.prototype.setVertices=function(t){var e=this;if(!Array.isArray(t))return this;if(t[0]instanceof vn)this.points=t;else if(this.points.length=0,"object"==typeof t[0])t.forEach((function(t){e.points.push(gn.pull("Vector2d",t.x,t.y))}));else for(var i=0;i<t.length;i+=2)this.points.push(gn.pull("Vector2d",t[i],t[i+1]));return this.recalc(),this.updateBounds(),this},Zr.prototype.transform=function(t){for(var e=this.points,i=e.length,o=0;o<i;o++)t.apply(e[o]);return this.recalc(),this.updateBounds(),this},Zr.prototype.toIso=function(){return this.rotate(Math.PI/4).scale(Math.SQRT2,Math.SQRT1_2)},Zr.prototype.to2d=function(){return this.scale(Math.SQRT1_2,Math.SQRT2).rotate(-Math.PI/4)},Zr.prototype.rotate=function(t,e){if(0!==t){for(var i=this.points,o=i.length,n=0;n<o;n++)i[n].rotate(t,e);this.recalc(),this.updateBounds()}return this},Zr.prototype.scale=function(t,e){e=void 0!==e?e:t;for(var i=this.points,o=i.length,n=0;n<o;n++)i[n].scale(t,e);return this.recalc(),this.updateBounds(),this},Zr.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Zr.prototype.recalc=function(){var t,e=this.edges,i=this.normals,o=this.indices,n=this.points,r=n.length;if(r<3)throw new Error("Requires at least 3 points");for(t=0;t<r;t++)void 0===e[t]&&(e[t]=gn.pull("Vector2d")),e[t].copy(n[(t+1)%r]).sub(n[t]),void 0===i[t]&&(i[t]=gn.pull("Vector2d")),i[t].copy(e[t]).perp().normalize();return e.length=r,i.length=r,o.length=0,this},Zr.prototype.getIndices=function(){return 0===this.indices.length&&(this.indices=wr.exports(this.points.flatMap((function(t){return[t.x,t.y]})))),this.indices},Zr.prototype.isConvex=function(){var t,e,i,o,n=0,r=this.points,s=r.length;if(s<3)return null;for(t=0;t<s;t++)if(i=(t+2)%s,o=(r[e=(t+1)%s].x-r[t].x)*(r[i].y-r[e].y),(o-=(r[e].y-r[t].y)*(r[i].x-r[e].x))<0?n|=1:o>0&&(n|=2),3===n)return!1;return 0!==n||null},Zr.prototype.translate=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x+=t,this.pos.y+=e,this.getBounds().translate(t,e),this},Zr.prototype.shift=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x=t,this.pos.y=e,this.updateBounds()},Zr.prototype.contains=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y);for(var i=!1,o=this.pos.x,n=this.pos.y,r=this.points,s=r.length,a=0,h=s-1;a<s;h=a++){var l=r[a].y+n,u=r[a].x+o,c=r[h].y+n,p=r[h].x+o;l>e!=c>e&&t<(p-u)*(e-l)/(c-l)+u&&(i=!i)}return i},Zr.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=gn.pull("Bounds")),this._bounds},Zr.prototype.updateBounds=function(){var t=this.getBounds();return t.update(this.points),t.translate(this.pos),t},Zr.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new Zr(this.pos.x,this.pos.y,t)};var Kr=function(t){function e(e,i,o,n){t.call(this,e,i,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",o,0),gn.pull("Vector2d",o,n),gn.pull("Vector2d",0,n)]),this.shapeType="Rectangle"}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={left:{configurable:!0},right:{configurable:!0},top:{configurable:!0},bottom:{configurable:!0},width:{configurable:!0},height:{configurable:!0},centerX:{configurable:!0},centerY:{configurable:!0}};return e.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},e.prototype.setShape=function(t,e,i,o){var n=i;return this.pos.set(t,e),4===arguments.length&&((n=this.points)[0].set(0,0),n[1].set(i,0),n[2].set(i,o),n[3].set(0,o)),this.setVertices(n),this},i.left.get=function(){return this.pos.x},i.right.get=function(){var t=this.width;return this.pos.x+t||t},i.top.get=function(){return this.pos.y},i.bottom.get=function(){var t=this.height;return this.pos.y+t||t},i.width.get=function(){return this.points[2].x},i.width.set=function(t){this.points[1].x=this.points[2].x=t,this.recalc(),this.updateBounds()},i.height.get=function(){return this.points[2].y},i.height.set=function(t){this.points[2].y=this.points[3].y=t,this.recalc(),this.updateBounds()},i.centerX.get=function(){return isFinite(this.width)?this.pos.x+this.width/2:this.width},i.centerX.set=function(t){this.pos.x=t-this.width/2},i.centerY.get=function(){return isFinite(this.height)?this.pos.y+this.height/2:this.height},i.centerY.set=function(t){this.pos.y=t-this.height/2},e.prototype.centerOn=function(t,e){return this.centerX=t,this.centerY=e,this},e.prototype.resize=function(t,e){return this.width=t,this.height=e,this},e.prototype.scale=function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},e.prototype.clone=function(){return new e(this.pos.x,this.pos.y,this.width,this.height)},e.prototype.copy=function(t){return this.setShape(t.pos.x,t.pos.y,t.width,t.height)},e.prototype.union=function(t){var e=Math.min(this.left,t.left),i=Math.min(this.top,t.top);return this.resize(Math.max(this.right,t.right)-e,Math.max(this.bottom,t.bottom)-i),this.pos.set(e,i),this},e.prototype.overlaps=function(t){return this.left<t.right&&t.left<this.right&&this.top<t.bottom&&t.top<this.bottom},e.prototype.contains=function(){var t,i,o,n,r=arguments[0];return 2===arguments.length?(t=i=r,o=n=arguments[1]):r instanceof e?(t=r.left,i=r.right,o=r.top,n=r.bottom):(t=i=r.x,o=n=r.y),t>=this.left&&i<=this.right&&o>=this.top&&n<=this.bottom},e.prototype.equals=function(t){return t.left===this.left&&t.right===this.right&&t.top===this.top&&t.bottom===this.bottom},e.prototype.isFinite=function(){return isFinite(this.pos.x)&&isFinite(this.pos.y)&&isFinite(this.width)&&isFinite(this.height)},e.prototype.toPolygon=function(){return gn.pull("Polygon",this.pos.x,this.pos.y,this.points)},Object.defineProperties(e.prototype,i),e}(Zr),Jr={},$r={},Qr={},ts={},es={},is={},os=function(t,e,i){e=e||t.keyCode||t.button;var o=is[e];if(dr(Kn,o,e,!o||!Qr[o]),o){if(!Qr[o]){var n=void 0!==i?i:e;ts[o][n]||(Jr[o]++,ts[o][n]=!0)}return!es[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},ns=function(t,e,i){e=e||t.keyCode||t.button;var o=is[e];if(dr(Jn,o,e),o){var n=void 0!==i?i:e;return ts[o][n]=void 0,Jr[o]>0&&Jr[o]--,Qr[o]=!1,!es[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},rs=null;function ss(){null===rs&&!1===du.isMobile&&"function"==typeof(rs=globalThis).addEventListener&&(rs.addEventListener("keydown",os,!1),rs.addEventListener("keyup",ns,!1))}function as(t,e,i){!0===e?os({},t,i):ns({},t,i)}function hs(t){return is[t]}var ls=function(t){this._center=new vn,this.onResetEvent(t)},us={x:{configurable:!0},y:{configurable:!0},width:{configurable:!0},height:{configurable:!0},left:{configurable:!0},right:{configurable:!0},top:{configurable:!0},bottom:{configurable:!0},centerX:{configurable:!0},centerY:{configurable:!0},center:{configurable:!0}};ls.prototype.onResetEvent=function(t){void 0===this.min?(this.min={x:1/0,y:1/0},this.max={x:-1/0,y:-1/0}):this.clear(),void 0!==t&&this.update(t)},ls.prototype.clear=function(){this.setMinMax(1/0,1/0,-1/0,-1/0)},ls.prototype.setMinMax=function(t,e,i,o){this.min.x=t,this.min.y=e,this.max.x=i,this.max.y=o},us.x.get=function(){return this.min.x},us.x.set=function(t){var e=this.max.x-this.min.x;this.min.x=t,this.max.x=t+e},us.y.get=function(){return this.min.y},us.y.set=function(t){var e=this.max.y-this.min.y;this.min.y=t,this.max.y=t+e},us.width.get=function(){return this.max.x-this.min.x},us.width.set=function(t){this.max.x=this.min.x+t},us.height.get=function(){return this.max.y-this.min.y},us.height.set=function(t){this.max.y=this.min.y+t},us.left.get=function(){return this.min.x},us.right.get=function(){return this.max.x},us.top.get=function(){return this.min.y},us.bottom.get=function(){return this.max.y},us.centerX.get=function(){return this.min.x+this.width/2},us.centerY.get=function(){return this.min.y+this.height/2},us.center.get=function(){return this._center.set(this.centerX,this.centerY)},ls.prototype.update=function(t){this.add(t,!0)},ls.prototype.add=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear();for(var i=0;i<t.length;i++){var o=t[i];o.x>this.max.x&&(this.max.x=o.x),o.x<this.min.x&&(this.min.x=o.x),o.y>this.max.y&&(this.max.y=o.y),o.y<this.min.y&&(this.min.y=o.y)}},ls.prototype.addBounds=function(t,e){void 0===e&&(e=!1),!0===e&&this.clear(),t.max.x>this.max.x&&(this.max.x=t.max.x),t.min.x<this.min.x&&(this.min.x=t.min.x),t.max.y>this.max.y&&(this.max.y=t.max.y),t.min.y<this.min.y&&(this.min.y=t.min.y)},ls.prototype.addPoint=function(t,e){void 0!==e&&(t=e.apply(t)),this.min.x=Math.min(this.min.x,t.x),this.max.x=Math.max(this.max.x,t.x),this.min.y=Math.min(this.min.y,t.y),this.max.y=Math.max(this.max.y,t.y)},ls.prototype.addFrame=function(t,e,i,o,n){var r=gn.pull("Vector2d");this.addPoint(r.set(t,e),n),this.addPoint(r.set(i,e),n),this.addPoint(r.set(t,o),n),this.addPoint(r.set(i,o),n),gn.push(r)},ls.prototype.contains=function(){var t,e,i,o,n=arguments[0];return 2===arguments.length?(t=e=n,i=o=arguments[1]):n instanceof ls?(t=n.min.x,e=n.max.x,i=n.min.y,o=n.max.y):(t=e=n.x,i=o=n.y),t>=this.min.x&&e<=this.max.x&&i>=this.min.y&&o<=this.max.y},ls.prototype.overlaps=function(t){return!(this.right<t.left||this.left>t.right||this.bottom<t.top||this.top>t.bottom)},ls.prototype.isFinite=function(){return isFinite(this.min.x)&&isFinite(this.max.x)&&isFinite(this.min.y)&&isFinite(this.max.y)},ls.prototype.translate=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.min.x+=t,this.max.x+=t,this.min.y+=e,this.max.y+=e},ls.prototype.shift=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y);var i=this.max.x-this.min.x,o=this.max.y-this.min.y;this.min.x=t,this.max.x=t+i,this.min.y=e,this.max.y=e+o},ls.prototype.clone=function(){var t=new ls;return t.addBounds(this),t},ls.prototype.toPolygon=function(){return gn.pull("Polygon",this.x,this.y,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height),gn.pull("Vector2d",0,this.height)])},Object.defineProperties(ls.prototype,us);var cs,ps=new vn,ds=function(t){function e(e,i,o,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1),void 0===n&&(n=1),t.call(this),this.setMinMax(e,i,e+o,i+n),this.LEFT=0,this.MIDDLE=1,this.RIGHT=2,this.event=void 0,this.type=void 0,this.button=0,this.isPrimary=!1,this.pageX=0,this.pageY=0,this.clientX=0,this.clientY=0,this.movementX=0,this.movementY=0,this.deltaMode=0,this.deltaX=0,this.deltaY=0,this.deltaZ=0,this.gameX=0,this.gameY=0,this.gameScreenX=0,this.gameScreenY=0,this.gameWorldX=0,this.gameWorldY=0,this.gameLocalX=0,this.gameLocalY=0,this.pointerId=void 0,this.isNormalized=!1,this.locked=!1,this.bind=[0,0,0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setEvent=function(t,e,i,o,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===n&&(n=0),void 0===r&&(r=1),this.event=t,this.pageX=e,this.pageY=i,this.clientX=o,this.clientY=n,Xs(this.pageX,this.pageY,ps),this.gameScreenX=this.x=ps.x,this.gameScreenY=this.y=ps.y,this.isNormalized=!du.PointerEvent||du.PointerEvent&&!(t instanceof globalThis.PointerEvent),this.locked=Gs,this.movementX=t.movementX||0,this.movementY=t.movementY||0,"wheel"===t.type?(this.deltaMode=t.deltaMode||0,this.deltaX=t.deltaX||0,this.deltaY=t.deltaY||0,this.deltaZ=t.deltaZ||0):(this.deltaMode=0,this.deltaX=0,this.deltaY=0,this.deltaZ=0),this.pointerId=r,this.isPrimary=void 0===t.isPrimary||t.isPrimary,this.button=t.button||0,this.type=t.type,void 0!==Ra&&Ra.localToWorld(this.gameScreenX,this.gameScreenY,ps),this.gameWorldX=ps.x,this.gameWorldY=ps.y,!1===this.isNormalized?(this.width=t.width||1,this.height=t.height||1):"number"==typeof t.radiusX?(this.width=2*t.radiusX||1,this.height=2*t.radiusY||1):this.width=this.height=1},e}(ls),fs=[],ys=new Map,gs=!1,vs=0,ms=[],_s=["wheel"],xs=["pointermove","mousemove","touchmove"],bs=["pointerdown","mousedown","touchstart"],ws=["pointerup","mouseup","touchend"],Ts=["pointercancel","mousecancel","touchcancel"],As=["pointerenter","mouseenter","touchenter"],Ss=["pointerover","mouseover","touchover"],Es=["pointerleave","mouseleave","touchleave"],Cs=[_s[0],xs[0],bs[0],ws[0],Ts[0],As[0],Ss[0],Es[0]],Ms=[_s[0],xs[1],bs[1],ws[1],Ts[1],As[1],Ss[1],Es[1]],Ps=[xs[2],bs[2],ws[2],Ts[2],As[2],Ss[2],Es[2]],Os={wheel:_s,pointermove:xs,pointerdown:bs,pointerup:ws,pointercancel:Ts,pointerenter:As,pointerover:Ss,pointerleave:Es},ks=[];function Is(){if(!gs){cs=new Kr(0,0,1,1);for(var t=0;t<du.maxTouchPoints;t++)fs.push(new ds);var e;null===Ns&&(Ns=Ou.getScreenCanvas()),ms=du.PointerEvent?Cs:Ms,du.touch&&!du.PointerEvent&&(ms=ms.concat(Ps)),function(t,e){for(var i=0;i<t.length;i++)-1===xs.indexOf(t[i])&&Ns.addEventListener(t[i],e,{passive:!1===aa})}(ms,Vs),void 0===js&&(js=~~(1e3/ju.maxfps)),!0===du.autoFocus&&(du.focus(),Ns.addEventListener(ms[2],(function(){du.focus()}),{passive:!1===aa}));var i=Bs(ms,xs);if(js<17)for(e=0;e<i.length;e++)-1!==ms.indexOf(i[e])&&Ns.addEventListener(i[e],Fs,{passive:!0});else for(e=0;e<i.length;e++)-1!==ms.indexOf(i[e])&&Ns.addEventListener(i[e],dn(Fs,js,!1),{passive:!0});Hs(Ns),du.hasPointerLockSupport&&document.addEventListener("pointerlockchange",(function(){Gs=document.pointerLockElement===Iu(),dr(ir,Gs)}),!0),gs=!0}}function Rs(t,e){for(var i=0;i<e.length;i++){if(-1!==t.indexOf(e[i]))return e[i]}}function Bs(t,e){for(var i=[],o=0;o<e.length;o++){-1!==t.indexOf(e[o])&&i.push(e[o])}return i}function Ds(t,e,i,o){var n;if(t.callbacks[e]){t.pointerId=o;for(var r=t.callbacks[e].length-1;r>=0&&(n=t.callbacks[e][r]);r--)if(!1===n(i))return!0}return!1}function Ls(t){for(var e=!1;t.length>0;){var i=t.pop();if(fs.push(i),!0===i.isNormalized&&void 0!==i.event.timeStamp){if(i.event.timeStamp<vs)continue;vs=i.event.timeStamp}cs.setShape(i.gameWorldX,i.gameWorldY,i.width,i.height),xs.includes(i.type)&&(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY,dr(er,i));for(var o,n=Ba.broadphase.retrieve(cs,Ma.prototype._sortReverseZ),r=(n=n.concat([Ra])).length;o=n[--r];){if(ys.has(o)&&!0!==o.isKinematic){var s,a=ys.get(o),h=a.region,l=h.ancestor,u=h.getBounds();if(!0===h.isFloating?(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY):(i.gameX=i.gameLocalX=i.gameWorldX,i.gameY=i.gameLocalY=i.gameWorldY),void 0!==l){var c=l.getBounds();i.gameLocalX=i.gameX-c.x,i.gameLocalY=i.gameY-c.y}var p=i.gameX,d=i.gameY;if(void 0!==h.currentTransform&&!h.currentTransform.isIdentity()){var f=h.currentTransform.applyInverse(gn.pull("Vector2d",p,d));p=f.x,d=f.y,gn.push(f)}switch(s=u.contains(p,d),i.type){case xs[0]:case xs[1]:case xs[2]:case xs[3]:if(a.pointerId!==i.pointerId||s){if(null===a.pointerId&&s&&Ds(a,Rs(ms,As),i,i.pointerId)){e=!0;break}}else if(Ds(a,Rs(ms,Es),i,null)){e=!0;break}if(s&&Ds(a,i.type,i,i.pointerId)){e=!0;break}break;case ws[0]:case ws[1]:case ws[2]:case ws[3]:if(a.pointerId===i.pointerId&&s&&Ds(a,i.type,i,null)){e=!0;break}break;case Ts[0]:case Ts[1]:case Ts[2]:case Ts[3]:if(a.pointerId===i.pointerId&&Ds(a,i.type,i,null)){e=!0;break}break;default:if(s&&Ds(a,i.type,i,i.pointerId)){e=!0;break}}}if(!0===e)break}}return e}function zs(t){var e;if(du.TouchEvent&&t.changedTouches)for(var i=0,o=t.changedTouches.length;i<o;i++){var n=t.changedTouches[i];(e=fs.pop()).setEvent(t,n.pageX,n.pageY,n.clientX,n.clientY,n.identifier),ks.push(e)}else(e=fs.pop()).setEvent(t,t.pageX,t.pageY,t.clientX,t.clientY,t.pointerId),ks.push(e);return!1===t.isPrimary||(ks[0].isPrimary=!0,Object.assign(Us,ks[0])),ks}function Fs(t){Ls(zs(t))}function Vs(t){zs(t);var e=ks[0].button;(Ls(ks)||"wheel"===t.type)&&t.preventDefault();var i=Us.bind[e];i&&as(i,bs.includes(t.type),e+1)}var js,Ns=null,Us=new ds(0,0,1,1),Gs=!1;function Xs(t,e,i){i=i||gn.pull("Vector2d");var o=du.getElementBounds(Ou.getScreenCanvas()),n=du.devicePixelRatio;t-=o.left+(globalThis.pageXOffset||0),e-=o.top+(globalThis.pageYOffset||0);var r=Pu;return 1===r.x&&1===r.y||(t/=r.x,e/=r.y),i.set(t*n,e*n)}function Hs(t,e){t.style["touch-action"]=e||"none"}function Ws(t,e,i){if(Is(),-1===Cs.indexOf(t))throw new Error("invalid event type : "+t);if(void 0===e)throw new Error("registerPointerEvent: region for "+toString(e)+" event is undefined ");var o=Bs(ms,Os[t]);ys.has(e)||ys.set(e,{region:e,callbacks:{},pointerId:null});for(var n=ys.get(e),r=0;r<o.length;r++)t=o[r],n.callbacks[t]?n.callbacks[t].push(i):n.callbacks[t]=[i]}function Ys(t,e,i){if(-1===Cs.indexOf(t))throw new Error("invalid event type : "+t);var o=Bs(ms,Os[t]),n=ys.get(e);if(void 0!==n){for(var r=0;r<o.length;r++)if(t=o[r],n.callbacks[t]){if(void 0!==i)rn(n.callbacks[t],i);else for(;n.callbacks[t].length>0;)n.callbacks[t].pop();0===n.callbacks[t].length&&delete n.callbacks[t]}0===Object.keys(n.callbacks).length&&ys.delete(e)}}function qs(t){if(ys.has(t))for(var e=0;e<Cs.length;e++)Ys(Cs[e],t)}function Zs(){return!!du.hasPointerLockSupport&&(Iu().requestPointerLock(),!0)}function Ks(){return!!du.hasPointerLockSupport&&(document.exitPointerLock(),!0)}var Js=.1;function $s(t,e,i){return t=t>0?i===this.GAMEPAD.BUTTONS.L2?Math.max(0,t-2e4)/111070:(t-1)/131070:(65536+t)/131070+.5}var Qs=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,ta=/^0+/;function ea(t,e){var i=t.replace(Qs,(function(t,e,i){return"000".slice(e.length-1)+e+"-"+"000".slice(i.length-1)+i+"-"})),o=t.replace(Qs,(function(t,e,i){return e.replace(ta,"")+"-"+i.replace(ta,"")+"-"}));e.analog=e.analog||e.buttons.map((function(){return-1})),e.normalize_fn=e.normalize_fn||function(t){return t},na.set(i,e),na.set(o,e)}var ia,oa={},na=new Map;[["45e-28e-Xbox 360 Wired Controller",{axes:[0,1,3,4],buttons:[11,12,13,14,8,9,-1,-1,5,4,6,7,0,1,2,3,10],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:function(t,e,i){return i===this.GAMEPAD.BUTTONS.L2||i===this.GAMEPAD.BUTTONS.R2?(t+1)/2:t}}],["54c-268-PLAYSTATION(R)3 Controller",{axes:[0,1,2,3],buttons:[14,13,15,12,10,11,8,9,0,3,1,2,4,6,7,5,16]}],["54c-5c4-Wireless Controller",{axes:[0,1,2,3],buttons:[1,0,2,3,4,5,6,7,8,9,10,11,14,15,16,17,12,13]}],["2836-1-OUYA Game Controller",{axes:[0,3,7,9],buttons:[3,6,4,5,7,8,15,16,-1,-1,9,10,11,12,13,14,-1],analog:[-1,-1,-1,-1,-1,-1,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:$s}],["OUYA Game Controller (Vendor: 2836 Product: 0001)",{axes:[0,1,3,4],buttons:[0,3,1,2,4,5,12,13,-1,-1,6,7,8,9,10,11,-1],analog:[-1,-1,-1,-1,-1,-1,2,5,-1,-1,-1,-1,-1,-1,-1,-1,-1],normalize_fn:$s}]].forEach((function(t){ea(t[0],t[1])}));var ra=function(){var t=navigator.getGamepads();Object.keys(oa).forEach((function(e){var i=t[e];if(i){var o=null;"standard"!==i.mapping&&(o=na.get(i.id));var n=oa[e];Object.keys(n.buttons).forEach((function(t){var r=n.buttons[t],s=t,a=-1;if(!(o&&(s=o.buttons[t],a=o.analog[t],s<0&&a<0))){var h=i.buttons[s]||{};if(o&&a>=0){var l=o.normalize_fn(i.axes[a],-1,+t);h={value:l,pressed:h.pressed||Math.abs(l)>=Js}}dr(tr,e,"buttons",+t,h),!r.pressed&&h.pressed?as(r.keyCode,!0,s+256):r.pressed&&!h.pressed&&as(r.keyCode,!1,s+256),r.value=h.value,r.pressed=h.pressed}})),Object.keys(n.axes).forEach((function(t){var r=n.axes[t],s=t;if(!(o&&(s=o.axes[t])<0)){var a=i.axes[s];if(void 0!==a){o&&(a=o.normalize_fn(a,+t,-1));var h=Math.sign(a)||1;if(0!==r[h].keyCode){var l=Math.abs(a)>=Js+Math.abs(r[h].threshold);dr(tr,e,"axes",+t,a),!r[h].pressed&&l?(r[-h].pressed&&(as(r[-h].keyCode,!1,s+256),r[-h].value=0,r[-h].pressed=!1),as(r[h].keyCode,!0,s+256)):!r[h].pressed&&!r[-h].pressed||l||as(r[h=r[h].pressed?h:-h].keyCode,!1,s+256),r[h].value=a,r[h].pressed=l}}}}))}}))};globalThis.navigator&&"function"==typeof globalThis.navigator.getGamepads&&(globalThis.addEventListener("gamepadconnected",(function(t){dr($n,t.gamepad)}),!1),globalThis.addEventListener("gamepaddisconnected",(function(t){dr(Qn,t.gamepad)}),!1));var sa=ea,aa=!0,ha=Object.freeze({__proto__:null,preventDefault:aa,get pointerEventTarget(){return Ns},pointer:Us,get locked(){return Gs},get throttlingInterval(){return js},globalToLocal:Xs,setTouchAction:Hs,bindPointer:function(){var t=arguments.length<2?Us.LEFT:arguments[0],e=arguments.length<2?arguments[0]:arguments[1];if(Is(),!hs(e))throw new Error("no action defined for keycode "+e);Us.bind[t]=e},unbindPointer:function(t){Us.bind[void 0===t?Us.LEFT:t]=null},registerPointerEvent:Ws,releasePointerEvent:Ys,releaseAllPointerEvents:qs,requestPointerLock:Zs,exitPointerLock:Ks,get keyBoardEventTarget(){return rs},KEY:{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,NUM0:48,NUM1:49,NUM2:50,NUM3:51,NUM4:52,NUM5:53,NUM6:54,NUM7:55,NUM8:56,NUM9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,WINDOW_KEY:91,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBSTRACT:109,DECIMAL:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,TILDE:126,NUM_LOCK:144,SCROLL_LOCK:145,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWAND_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,SINGLE_QUOTE:222},initKeyboardEvent:ss,isKeyPressed:function(t){return!(!Jr[t]||Qr[t])&&($r[t]&&(Qr[t]=!0),!0)},keyStatus:function(t){return Jr[t]>0},triggerKeyEvent:as,bindKey:function(t,e,i,o){void 0===o&&(o=aa),is[t]=e,es[t]=o,Jr[e]=0,$r[e]=i||!1,Qr[e]=!1,ts[e]={}},getBindingKey:hs,unlockKey:function(t){Qr[t]=!1},unbindKey:function(t){var e=is[t];Jr[e]=0,$r[e]=!1,ts[e]={},is[t]=null,es[t]=null},GAMEPAD:{AXES:{LX:0,LY:1,RX:2,RY:3,EXTRA_1:4,EXTRA_2:5,EXTRA_3:6,EXTRA_4:7},BUTTONS:{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L1:4,R1:5,L2:6,R2:7,SELECT:8,BACK:8,START:9,FORWARD:9,L3:10,R3:11,UP:12,DOWN:13,LEFT:14,RIGHT:15,HOME:16,EXTRA_1:17,EXTRA_2:18,EXTRA_3:19,EXTRA_4:20}},bindGamepad:function(t,e,i){if(!hs(i))throw new Error("no action defined for keycode "+i);void 0===ia&&"function"==typeof navigator.getGamepads&&(ia=fr(Un,ra)),oa[t]||(oa[t]={axes:{},buttons:{}});var o={keyCode:i,value:0,pressed:!1,threshold:e.threshold},n=oa[t][e.type];if("buttons"===e.type)n[e.code]=o;else if("axes"===e.type){var r=Math.sign(e.threshold)||1;n[e.code]||(n[e.code]={});var s=n[e.code];s[r]=o,s[-r]||(s[-r]={keyCode:0,value:0,pressed:!1,threshold:-r})}},unbindGamepad:function(t,e){if(!oa[t])throw new Error("no bindings for gamepad "+t);oa[t].buttons[e]={}},setGamepadDeadzone:function(t){Js=t},setGamepadMapping:sa}),la=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.isRenderable=!0,this.isKinematic=!0,this.body=void 0,void 0===this.currentTransform&&(this.currentTransform=gn.pull("Matrix2d")),this.currentTransform.identity(),this.GUID=void 0,this.onVisibilityChange=void 0,this.alwaysUpdate=!1,this.updateWhenPaused=!1,this.isPersistent=!1,this.floating=!1,this.anchorPoint instanceof _r?this.anchorPoint.setMuted(.5,.5).setCallback(this.onAnchorUpdate,this):this.anchorPoint=gn.pull("ObservableVector2d",.5,.5,{onUpdate:this.onAnchorUpdate,scope:this}),this.autoTransform=!0,this.alpha=1,this.ancestor=void 0,this.mask=void 0,this.tint=gn.pull("Color",255,255,255,1),this.blendMode="normal",this.name="",this.pos instanceof br?this.pos.setMuted(e,i,0).setCallback(this.updateBoundsPos,this):this.pos=gn.pull("ObservableVector3d",e,i,0,{onUpdate:this.updateBoundsPos,scope:this}),this.isDirty=!1,this._flip={x:!1,y:!1},this._inViewport=!1,this.setOpacity(1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isFloating:{configurable:!0},inViewport:{configurable:!0},isFlippedX:{configurable:!0},isFlippedY:{configurable:!0}};return i.isFloating.get=function(){return!0===this.floating||void 0!==this.ancestor&&!0===this.ancestor.floating},i.inViewport.get=function(){return this._inViewport},i.inViewport.set=function(t){this._inViewport!==t&&(this._inViewport=t,"function"==typeof this.onVisibilityChange&&this.onVisibilityChange.call(this,t))},i.isFlippedX.get=function(){return!0===this._flip.x},i.isFlippedY.get=function(){return!0===this._flip.y},e.prototype.getBounds=function(){return void 0===this._bounds&&(t.prototype.getBounds.call(this),this.isFinite()?this._bounds.setMinMax(this.pos.x,this.pos.y,this.pos.x+this.width,this.pos.y+this.height):this._bounds.setMinMax(this.pos.x,this.pos.y,this.width,this.height)),this._bounds},e.prototype.getOpacity=function(){return this.alpha},e.prototype.setOpacity=function(t){"number"==typeof t&&(this.alpha=$o(t,0,1),isNaN(this.alpha)&&(this.alpha=1),this.isDirty=!0)},e.prototype.flipX=function(t){return void 0===t&&(t=!0),this._flip.x=!!t,this.isDirty=!0,this},e.prototype.flipY=function(t){return void 0===t&&(t=!0),this._flip.y=!!t,this.isDirty=!0,this},e.prototype.transform=function(t){return this.currentTransform.multiply(t),this.updateBoundsPos(this.pos.x,this.pos.y),this.isDirty=!0,this},e.prototype.angleTo=function(t){var i,o,n=this.getBounds();if(t instanceof e){var r=t.getBounds();i=r.centerX-n.centerX,o=r.centerY-n.centerY}else i=t.x-n.centerX,o=t.y-n.centerY;return Math.atan2(o,i)},e.prototype.distanceTo=function(t){var i,o,n=this.getBounds();if(t instanceof e){var r=t.getBounds();i=n.centerX-r.centerX,o=n.centerY-r.centerY}else i=n.centerX-t.x,o=n.centerY-t.y;return Math.sqrt(i*i+o*o)},e.prototype.lookAt=function(t){var i;i=t instanceof e?t.pos:t;var o=this.angleTo(i);return this.rotate(o),this},e.prototype.rotate=function(t,e){return isNaN(t)||(this.currentTransform.rotate(t,e),this.isDirty=!0),this},e.prototype.scale=function(e,i){return this.currentTransform.scale(e,i),t.prototype.scale.call(this,e,i),this.isDirty=!0,this},e.prototype.scaleV=function(t){return this.scale(t.x,t.y),this},e.prototype.update=function(t){return this.isDirty},e.prototype.updateBounds=function(){return t.prototype.updateBounds.call(this),this.updateBoundsPos(this.pos.x,this.pos.y),this.getBounds()},e.prototype.updateBoundsPos=function(t,e){var i=this.getBounds();i.shift(t,e),void 0!==this.anchorPoint&&i.isFinite()&&i.translate(-this.anchorPoint.x*i.width,-this.anchorPoint.y*i.height),this.ancestor instanceof Ma&&!0!==this.floating&&i.translate(this.ancestor.getAbsolutePosition()),this.isDirty=!0},e.prototype.getAbsolutePosition=function(){return void 0===this._absPos&&(this._absPos=gn.pull("Vector2d")),this._absPos.set(this.pos.x,this.pos.y),this.ancestor instanceof Ma&&!0!==this.floating&&this._absPos.add(this.ancestor.getAbsolutePosition()),this._absPos},e.prototype.onAnchorUpdate=function(t,e){this.anchorPoint.setMuted(t,e),this.updateBoundsPos(this.pos.x,this.pos.y)},e.prototype.preDraw=function(t){var e=this.getBounds(),i=e.width*this.anchorPoint.x,o=e.height*this.anchorPoint.y;if(t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity()),this._flip.x||this._flip.y){var n=this._flip.x?this.centerX-i:0,r=this._flip.y?this.centerY-o:0;t.translate(n,r),t.scale(this._flip.x?-1:1,this._flip.y?-1:1),t.translate(-n,-r)}void 0!==this.mask&&(t.translate(this.pos.x,this.pos.y),t.setMask(this.mask),t.translate(-this.pos.x,-this.pos.y)),!0!==this.autoTransform||this.currentTransform.isIdentity()||(t.translate(this.pos.x,this.pos.y),t.transform(this.currentTransform),t.translate(-this.pos.x,-this.pos.y)),t.translate(-i,-o),t.setTint(this.tint,this.getOpacity()),this.blendMode!==t.getBlendMode()&&t.setBlendMode(this.blendMode)},e.prototype.draw=function(t,e){},e.prototype.postDraw=function(t){t.clearTint(),void 0!==this.mask&&t.clearMask(),t.restore(),this.isDirty=!1},e.prototype.onCollision=function(t,e){return!1},e.prototype.destroy=function(){gn.push(this.currentTransform),this.currentTransform=void 0,gn.push(this.anchorPoint),this.anchorPoint=void 0,gn.push(this.pos),this.pos=void 0,void 0!==this._absPos&&(gn.push(this._absPos),this._absPos=void 0),gn.push(this._bounds),this._bounds=void 0,this.onVisibilityChange=void 0,void 0!==this.mask&&(gn.push(this.mask),this.mask=void 0),void 0!==this.tint&&(gn.push(this.tint),this.tint=void 0),this.ancestor=void 0,void 0!==this.body&&(this.body.destroy.apply(this.body,arguments),this.body=void 0),qs(this),this.onDestroyEvent.apply(this,arguments)},e.prototype.onDestroyEvent=function(){},Object.defineProperties(e.prototype,i),e}(Kr),ua=function(t,e,i,o){this.pos=gn.pull("Vector2d"),this._bounds=void 0,this.radius=NaN,this.radiusV=gn.pull("Vector2d"),this.radiusSq=gn.pull("Vector2d"),this.ratio=gn.pull("Vector2d"),this.shapeType="Ellipse",this.setShape(t,e,i,o)};ua.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},ua.prototype.setShape=function(t,e,i,o){var n=i/2,r=o/2;this.pos.set(t,e),this.radius=Math.max(n,r),this.ratio.set(n/this.radius,r/this.radius),this.radiusV.set(this.radius,this.radius).scaleV(this.ratio);var s=this.radius*this.radius;return this.radiusSq.set(s,s).scaleV(this.ratio),this.getBounds().setMinMax(t,e,t+i,t+o),this.getBounds().translate(-this.radiusV.x,-this.radiusV.y),this},ua.prototype.rotate=function(t,e){return this.pos.rotate(t,e),this.getBounds().shift(this.pos),this.getBounds().translate(-this.radiusV.x,-this.radiusV.y),this},ua.prototype.scale=function(t,e){return e=void 0!==e?e:t,this.setShape(this.pos.x,this.pos.y,2*this.radiusV.x*t,2*this.radiusV.y*e)},ua.prototype.scaleV=function(t){return this.scale(t.x,t.y)},ua.prototype.transform=function(t){return this},ua.prototype.translate=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.pos.x+=t,this.pos.y+=e,this.getBounds().translate(t,e),this},ua.prototype.contains=function(){var t,e;return 2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),t-=this.pos.x,e-=this.pos.y,t*t/this.radiusSq.x+e*e/this.radiusSq.y<=1},ua.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=gn.pull("Bounds")),this._bounds},ua.prototype.clone=function(){return new ua(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)};for(var ca=[],pa=0;pa<10;pa++)ca.push(new vn);for(var da=[],fa=0;fa<5;fa++)da.push([]);function ya(t,e,i){for(var o=Number.MAX_VALUE,n=-Number.MAX_VALUE,r=t.length,s=0;s<r;s++){var a=t[s].dot(e);a<o&&(o=a),a>n&&(n=a)}i[0]=o,i[1]=n}function ga(t,e,i,o,n,r){var s=da.pop(),a=da.pop(),h=ca.pop().copy(e).sub(t),l=h.dot(n);if(ya(i,n,s),ya(o,n,a),a[0]+=l,a[1]+=l,s[0]>a[1]||a[0]>s[1])return ca.push(h),da.push(s),da.push(a),!0;if(r){var u=0;if(s[0]<a[0])if(r.aInB=!1,s[1]<a[1])u=s[1]-a[0],r.bInA=!1;else{var c=s[1]-a[0],p=a[1]-s[0];u=c<p?c:-p}else if(r.bInA=!1,s[1]>a[1])u=s[0]-a[1],r.aInB=!1;else{var d=s[1]-a[0],f=a[1]-s[0];u=d<f?d:-f}var y=Math.abs(u);y<r.overlap&&(r.overlap=y,r.overlapN.copy(n),u<0&&r.overlapN.negateSelf())}return ca.push(h),da.push(s),da.push(a),!1}function va(t,e){var i=t.length2(),o=e.dot(t);return o<0?-1:o>i?1:0}function ma(t,e,i,o,n){for(var r=ca.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos).sub(t.pos).add(t.ancestor.getAbsolutePosition()).sub(e.pos),s=o.radius,a=s*s,h=e.points,l=e.edges,u=l.length,c=ca.pop(),p=ca.pop(),d=ca.pop(),f=0,y=0;y<u;y++){var g=y===u-1?0:y+1,v=0===y?u-1:y-1,m=0,_=null;c.copy(l[y]),d.copy(r).sub(h[y]),n&&d.length2()>a&&(n.aInB=!1);var x=va(c,d),b=!0;if(-1===x){var w=null;if(u>1&&(c.copy(l[v]),1!==(x=va(c,w=ca.pop().copy(r).sub(h[v])))&&(b=!1)),b){if((f=d.length())>s)return ca.push(r),ca.push(c),ca.push(p),ca.push(d),w&&ca.push(w),!1;n&&(n.bInA=!1,_=d.normalize(),m=s-f)}w&&ca.push(w)}else if(1===x){if(u>1&&(c.copy(l[g]),d.copy(r).sub(h[g]),-1!==(x=va(c,d))&&(b=!1)),b){if((f=d.length())>s)return ca.push(r),ca.push(c),ca.push(p),ca.push(d),!1;n&&(n.bInA=!1,_=d.normalize(),m=s-f)}}else{p.copy(e.normals[y]),f=d.dot(p);var T=Math.abs(f);if((1===u||f>0)&&T>s)return ca.push(r),ca.push(c),ca.push(p),ca.push(d),!1;n&&(_=p,m=s-f,(f>=0||m<2*s)&&(n.bInA=!1))}_&&n&&Math.abs(m)<Math.abs(n.overlap)&&(n.overlap=m,n.overlapN.copy(_))}return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),ca.push(r),ca.push(c),ca.push(p),ca.push(d),!0}var _a=Object.freeze({__proto__:null,testPolygonPolygon:function(t,e,i,o,n){var r,s=e.points,a=e.normals,h=a.length,l=o.points,u=o.normals,c=u.length,p=ca.pop().copy(t.pos).add(t.ancestor.getAbsolutePosition()).add(e.pos),d=ca.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos);for(r=0;r<h;r++)if(ga(p,d,s,l,a[r],n))return ca.push(p),ca.push(d),!1;for(r=0;r<c;r++)if(ga(p,d,s,l,u[r],n))return ca.push(p),ca.push(d),!1;return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),ca.push(p),ca.push(d),!0},testEllipseEllipse:function(t,e,i,o,n){var r=ca.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos).sub(t.pos).add(t.ancestor.getAbsolutePosition()).sub(e.pos),s=e.radius,a=o.radius,h=s+a,l=h*h,u=r.length2();if(u>l)return ca.push(r),!1;if(n){var c=Math.sqrt(u);n.a=t,n.b=i,n.overlap=h-c,n.overlapN.copy(r.normalize()),n.overlapV.copy(r).scale(n.overlap),n.aInB=s<=a&&c<=a-s,n.bInA=a<=s&&c<=s-a}return ca.push(r),!0},testPolygonEllipse:ma,testEllipsePolygon:function(t,e,i,o,n){var r=ma(i,o,t,e,n);if(r&&n){var s=n.a,a=n.aInB;n.overlapN.negateSelf(),n.overlapV.negateSelf(),n.a=n.b,n.b=s,n.aInB=n.bInA,n.bInA=a}return r}}),xa=function(){this.a=null,this.b=null,this.overlapN=new vn,this.overlapV=new vn,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE};xa.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this};var ba={pos:new vn(0,0),ancestor:{_absPos:new vn(0,0),getAbsolutePosition:function(){return this._absPos}}},wa=new xa;function Ta(t,e){return!0!==t.isKinematic&&!0!==e.isKinematic&&"object"==typeof t.body&&"object"==typeof e.body&&!(!0===t.body.isStatic&&!0===e.body.isStatic)&&0!=(t.body.collisionMask&e.body.collisionType)&&0!=(t.body.collisionType&e.body.collisionMask)}var Aa={maxChildren:8,maxDepth:4,types:{NO_OBJECT:0,PLAYER_OBJECT:1,NPC_OBJECT:2,ENEMY_OBJECT:4,COLLECTABLE_OBJECT:8,ACTION_OBJECT:16,PROJECTILE_OBJECT:32,WORLD_SHAPE:64,USER:128,ALL_OBJECT:4294967295},rayCast:function(t,e){return function(t,e){void 0===e&&(e=[]);for(var i,o=0,n=Ba.broadphase.retrieve(t),r=n.length;i=n[--r];)if(i.body&&t.getBounds().overlaps(i.getBounds())){var s=i.body.shapes.length;if(0===i.body.shapes.length)continue;var a=t,h=0;do{var l=i.body.getShape(h);_a["test"+a.shapeType+l.shapeType].call(this,ba,a,i,l)&&(e[o]=i,o++),h++}while(h<s)}return e.length=o,e}(t,e)}},Sa=function(t,e,i){if(this.ancestor=t,void 0===this.bounds&&(this.bounds=gn.pull("Bounds")),void 0===this.shapes&&(this.shapes=[]),this.collisionMask=Aa.types.ALL_OBJECT,this.collisionType=Aa.types.ENEMY_OBJECT,void 0===this.vel&&(this.vel=gn.pull("Vector2d")),this.vel.set(0,0),void 0===this.force&&(this.force=gn.pull("Vector2d")),this.force.set(0,0),void 0===this.friction&&(this.friction=gn.pull("Vector2d")),this.friction.set(0,0),this.bounce=0,this.mass=1,void 0===this.maxVel&&(this.maxVel=gn.pull("Vector2d")),this.maxVel.set(490,490),this.isStatic=!1,this.gravityScale=1,this.ignoreGravity=!1,this.falling=!1,this.jumping=!1,"function"==typeof i&&(this.onBodyUpdate=i),this.bounds.clear(),void 0!==e)if(Array.isArray(e))for(var o=0;o<e.length;o++)this.addShape(e[o]);else this.addShape(e);this.ancestor.isKinematic=!1};Sa.prototype.setStatic=function(t){void 0===t&&(t=!0),this.isStatic=!0===t},Sa.prototype.addShape=function(t){if(t instanceof Kr||t instanceof ls){var e=t.toPolygon();this.shapes.push(e),this.bounds.add(e.points),this.bounds.translate(e.pos)}else t instanceof ua?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addBounds(t.getBounds()),this.bounds.translate(t.getBounds().x,t.getBounds().y)):t instanceof Zr?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.add(t.points),this.bounds.translate(t.pos)):this.fromJSON(t);return"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this),this.shapes.length},Sa.prototype.setVertices=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=!0);var o=this.getShape(e);o instanceof Zr?o.setShape(0,0,t):this.shapes[e]=gn.pull("Polygon",0,0,t),this.bounds.add(this.shapes[e].points,i),"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this)},Sa.prototype.addVertices=function(t,e){void 0===e&&(e=0),this.setVertices(t,e,!1)},Sa.prototype.fromJSON=function(t,e){var i=t;if(void 0!==e&&(i=t[e]),void 0===i)throw new Error("Identifier ("+e+") undefined for the given JSON object)");if(i.length){for(var o=0;o<i.length;o++)this.addVertices(i[o].shape,o);this.mass=i[0].density||0,this.friction.set(i[0].friction||0,i[0].friction||0),this.bounce=i[0].bounce||0}return i.length},Sa.prototype.getShape=function(t){return this.shapes[t||0]},Sa.prototype.getBounds=function(){return this.bounds},Sa.prototype.removeShape=function(t){this.bounds.clear(),rn(this.shapes,t);for(var e=0;e<this.shapes.length;e++)this.addShape(this.shapes[e]);return this.shapes.length},Sa.prototype.removeShapeAt=function(t){return this.removeShape(this.getShape(t))},Sa.prototype.setCollisionMask=function(t){void 0===t&&(t=Aa.types.ALL_OBJECT),this.collisionMask=t},Sa.prototype.setCollisionType=function(t){if(void 0!==t){if(void 0===Aa.types[t])throw new Error("Invalid value for the collisionType property");this.collisionType=Aa.types[t]}},Sa.prototype.respondToCollision=function(t){var e=t.overlapV;if(this.ancestor.pos.sub(e),0!==e.x&&(this.vel.x=~~(.5+this.vel.x-e.x)||0,this.bounce>0&&(this.vel.x*=-this.bounce)),0!==e.y){this.vel.y=~~(.5+this.vel.y-e.y)||0,this.bounce>0&&(this.vel.y*=-this.bounce);var i=Math.sign(Ba.gravity.y*this.gravityScale)||1;this.falling=e.y>=i,this.jumping=e.y<=-i}},Sa.prototype.forEach=function(t,e){var i=this,o=0,n=this.shapes,r=n.length;if("function"!=typeof t)throw new Error(t+" is not a function");for(arguments.length>1&&(i=e);o<r;)t.call(i,n[o],o,n),o++},Sa.prototype.contains=function(){var t,e;if(2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),this.getBounds().contains(t,e))for(var i,o=this.shapes.length;o--,i=this.shapes[o];)if(i.contains(t,e))return!0;return!1},Sa.prototype.rotate=function(t,e){var i=this;return void 0===e&&(e=this.getBounds().center),this.bounds.clear(),this.forEach((function(o){o.rotate(t,e),i.bounds.addBounds(o.getBounds()),o instanceof ua?i.bounds.translate(o.getBounds().x,o.getBounds().y):i.bounds.translate(o.pos)})),this},Sa.prototype.setMaxVelocity=function(t,e){this.maxVel.x=t,this.maxVel.y=e},Sa.prototype.setFriction=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.friction.x=t,this.friction.y=e},Sa.prototype.computeVelocity=function(){var t=ju.tick;if(!this.ignoreGravity){var e=Ba.gravity;this.vel.x+=e.x*this.gravityScale*t,this.vel.y+=e.y*this.gravityScale*t,this.falling=this.vel.y*Math.sign(e.y*this.gravityScale)>0,this.jumping=!this.falling&&this.jumping}if(0!==this.force.x&&(this.vel.x+=this.force.x*t),0!==this.force.y&&(this.vel.y+=this.force.y*t),this.friction.x>0){var i=this.friction.x*t,o=this.vel.x+i,n=this.vel.x-i;this.vel.x=o<0?o:n>0?n:0}if(this.friction.y>0){var r=this.friction.y*t,s=this.vel.y+r,a=this.vel.y-r;this.vel.y=s<0?s:a>0?a:0}0!==this.vel.y&&(this.vel.y=$o(this.vel.y,-this.maxVel.y,this.maxVel.y)),0!==this.vel.x&&(this.vel.x=$o(this.vel.x,-this.maxVel.x,this.maxVel.x))},Sa.prototype.update=function(t){return this.computeVelocity(t),this.ancestor.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},Sa.prototype.destroy=function(){gn.push(this.bounds),gn.push(this.vel),gn.push(this.force),gn.push(this.friction),gn.push(this.maxVel),this.shapes.forEach((function(t){gn.push(t,!1)})),this.onBodyUpdate=void 0,this.ancestor=void 0,this.bounds=void 0,this.vel=void 0,this.force=void 0,this.friction=void 0,this.maxVel=void 0,this.shapes.length=0,this.setStatic(!1)};var Ea=function(t,e){this.removeChildNow(t,e)},Ca=0,Ma=function(t){function e(e,i,o,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=Ra.width),void 0===n&&(n=Ra.height),void 0===r&&(r=!1),t.call(this,e,i,o,n),this.pendingSort=null,this.root=r,this.children=void 0,this.sortOn=Ya,this.autoSort=!0,this.autoDepth=!0,this.clipping=!1,this.onChildChange=function(t){},this.enableChildBoundsUpdate=!1,this.backgroundColor=gn.pull("Color",0,0,0,0),this.drawCount=0,this.autoTransform=!0,this.isKinematic=!1,this.anchorPoint.set(0,0),!0===this.root&&fr(sr,this.updateBounds.bind(this,!0))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){this.pendingSort&&(clearTimeout(this.pendingSort),this.pendingSort=null);for(var t,e=this.getChildren(),i=e.length;i>=0;t=e[--i])t&&!0!==t.isPersistent&&this.removeChildNow(t);void 0!==this.currentTransform&&this.currentTransform.identity(),this.backgroundColor.setColor(0,0,0,0)},e.prototype.addChild=function(t,i){return t.ancestor instanceof e?t.ancestor.removeChildNow(t):t.isRenderable&&(t.GUID=zu.createGUID(t.id)),t.ancestor=this,this.getChildren().push(t),void 0!==t.pos&&("number"==typeof i?t.pos.z=i:!0===this.autoDepth&&(t.pos.z=this.getChildren().length)),!0===this.autoSort&&this.sort(),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&$a(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Sa&&Ba.addBody(t.body),this.onChildChange.call(this,this.getChildren().length-1),t},e.prototype.addChildAt=function(t,i){if(i>=0&&i<this.getChildren().length)return t.ancestor instanceof e?t.ancestor.removeChildNow(t):t.isRenderable&&(t.GUID=zu.createGUID()),t.ancestor=this,this.getChildren().splice(i,0,t),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&$a(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Sa&&Ba.addBody(t.body),this.onChildChange.call(this,i),t;throw new Error("Index ("+i+") Out Of Bounds for addChildAt()")},e.prototype.forEach=function(t,e){var i=this,o=0,n=this.getChildren(),r=n.length;if("function"!=typeof t)throw new Error(t+" is not a function");for(arguments.length>1&&(i=e);o<r;)t.call(i,n[o],o,n),o++},e.prototype.swapChildren=function(t,e){var i=this.getChildIndex(t),o=this.getChildIndex(e);if(-1===i||-1===o)throw new Error(t+" Both the supplied childs must be a child of the caller "+this);var n=t.pos.z;t.pos.z=e.pos.z,e.pos.z=n,this.getChildren()[i]=e,this.getChildren()[o]=t,this.isDirty=!0},e.prototype.getChildAt=function(t){if(t>=0&&t<this.getChildren().length)return this.getChildren()[t];throw new Error("Index ("+t+") Out Of Bounds for getChildAt()")},e.prototype.getChildIndex=function(t){return this.getChildren().indexOf(t)},e.prototype.getNextChild=function(t){var e=this.getChildren().indexOf(t)-1;if(e>=0&&e<this.getChildren().length)return this.getChildAt(e)},e.prototype.hasChild=function(t){return this===t.ancestor},e.prototype.getChildByProp=function(t,i){var o=[];return this.forEach((function(n){!function(t,e){var n=t[e];i instanceof RegExp&&"string"==typeof n?i.test(n)&&o.push(t):n===i&&o.push(t)}(n,t),n instanceof e&&(o=o.concat(n.getChildByProp(t,i)))})),o},e.prototype.getChildByType=function(t){var i=[];return this.forEach((function(o){o instanceof t&&i.push(o),o instanceof e&&(i=i.concat(o.getChildByType(t)))})),i},e.prototype.getChildByName=function(t){return this.getChildByProp("name",t)},e.prototype.getChildByGUID=function(t){var e=this.getChildByProp("GUID",t);return e.length>0?e[0]:null},e.prototype.getChildren=function(){return void 0===this.children&&(this.children=[]),this.children},e.prototype.updateBounds=function(e){void 0===e&&(e=!1),t.prototype.updateBounds.call(this);var i=this.getBounds();return!0!==e&&!0!==this.enableChildBoundsUpdate||this.forEach((function(t){t.isRenderable&&(t.getBounds().isFinite()&&i.addBounds(t.getBounds()))})),i},e.prototype.isAttachedToRoot=function(){if(!0===this.root)return!0;for(var t=this.ancestor;t;){if(!0===t.root)return!0;t=t.ancestor}return!1},e.prototype.updateBoundsPos=function(e,i){var o=this;return t.prototype.updateBoundsPos.call(this,e,i),this.forEach((function(t){t.isRenderable&&t.updateBoundsPos(t.pos.x+e-o.pos.x,t.pos.y+i-o.pos.y)})),this.getBounds()},e.prototype.onActivateEvent=function(){this.forEach((function(t){"function"==typeof t.onActivateEvent&&t.onActivateEvent()}))},e.prototype.removeChild=function(t,e){if(!this.hasChild(t))throw new Error("Child is not mine.");zu.function.defer(Ea,this,t,e)},e.prototype.removeChildNow=function(t,e){if(this.hasChild(t)&&this.getChildIndex(t)>=0){"function"==typeof t.onDeactivateEvent&&t.onDeactivateEvent(),t.body instanceof Sa&&Ba.removeBody(t.body),e||!1===gn.push(t,!1)&&"function"==typeof t.destroy&&t.destroy();var i=this.getChildIndex(t);i>=0&&(this.getChildren().splice(i,1),t.ancestor=void 0),!0===this.isAttachedToRoot()&&$a(),this.enableChildBoundsUpdate&&this.updateBounds(!0),this.onChildChange.call(this,i)}},e.prototype.setChildsProperty=function(t,i,o){this.forEach((function(n){!0===o&&n instanceof e&&n.setChildsProperty(t,i,o),n[t]=i}))},e.prototype.moveUp=function(t){var e=this.getChildIndex(t);e-1>=0&&(this.swapChildren(t,this.getChildAt(e-1)),this.isDirty=!0)},e.prototype.moveDown=function(t){var e=this.getChildIndex(t);e>=0&&e+1<this.getChildren().length&&(this.swapChildren(t,this.getChildAt(e+1)),this.isDirty=!0)},e.prototype.moveToTop=function(t){var e=this.getChildIndex(t);if(e>0){var i=this.getChildren();i.splice(0,0,i.splice(e,1)[0]),t.pos.z=i[1].pos.z+1,this.isDirty=!0}},e.prototype.moveToBottom=function(t){var e=this.getChildIndex(t),i=this.getChildren();e>=0&&e<i.length-1&&(i.splice(i.length-1,0,i.splice(e,1)[0]),t.pos.z=i[i.length-2].pos.z-1,this.isDirty=!0)},e.prototype.sort=function(t){this.pendingSort||(!0===t&&this.forEach((function(i){i instanceof e&&i.sort(t)})),this.pendingSort=zu.function.defer((function(){this.getChildren().sort(this["_sort"+this.sortOn.toUpperCase()]),this.pendingSort=null,$a()}),this))},e.prototype.onDeactivateEvent=function(){this.forEach((function(t){"function"==typeof t.onDeactivateEvent&&t.onDeactivateEvent()}))},e.prototype._sortZ=function(t,e){return e.pos&&t.pos?e.pos.z-t.pos.z:t.pos?-1/0:1/0},e.prototype._sortReverseZ=function(t,e){return t.pos&&e.pos?t.pos.z-e.pos.z:t.pos?1/0:-1/0},e.prototype._sortX=function(t,e){if(!e.pos||!t.pos)return t.pos?-1/0:1/0;var i=e.pos.z-t.pos.z;return i||e.pos.x-t.pos.x},e.prototype._sortY=function(t,e){if(!e.pos||!t.pos)return t.pos?-1/0:1/0;var i=e.pos.z-t.pos.z;return i||e.pos.y-t.pos.y},e.prototype.destroy=function(){this.reset(),t.prototype.destroy.call(this,arguments)},e.prototype.update=function(e){for(var i,o=!1,n=Ah.isPaused(),r=this.getChildren(),s=r.length;s--,i=r[s];)n&&!i.updateWhenPaused||(i.isRenderable?((o=Ca>0||i.floating)&&Ca++,i.inViewport=!1,Ah.current().cameras.forEach((function(t){t.isVisible(i,o)&&(i.inViewport=!0)})),this.isDirty|=(i.inViewport||i.alwaysUpdate)&&i.update(e),Ca>0&&Ca--):this.isDirty|=i.update(e));return t.prototype.update.call(this,e)},e.prototype.draw=function(t,e){var i=!1,o=this.getBounds();this.drawCount=0,!1===this.root&&!0===this.clipping&&!0===o.isFinite()&&t.clipRect(o.left,o.top,o.width,o.height),t.translate(this.pos.x,this.pos.y),this.backgroundColor.alpha>1/255&&t.clearColor(this.backgroundColor);for(var n,r=this.getChildren(),s=r.length;n=r[--s];)n.isRenderable&&(i=!0===n.floating,(n.inViewport||i)&&(i&&(t.save(),t.resetTransform()),n.preDraw(t),n.draw(t,e),n.postDraw(t),i&&t.restore(),this.drawCount++))},e}(la),Pa=[];function Oa(t,e,i,o){if(void 0===e&&(e=4),void 0===i&&(i=4),void 0===o&&(o=0),Pa.length>0){var n=Pa.pop();return n.bounds=t,n.max_objects=e,n.max_levels=i,n.level=o,n}return new Ia(t,e,i,o)}var ka=new vn,Ia=function(t,e,i,o){void 0===e&&(e=4),void 0===i&&(i=4),void 0===o&&(o=0),this.max_objects=e,this.max_levels=i,this.level=o,this.bounds=t,this.objects=[],this.nodes=[]};Ia.prototype.split=function(){var t=this.level+1,e=this.bounds.width/2,i=this.bounds.height/2,o=this.bounds.left,n=this.bounds.top;this.nodes[0]=Oa({left:o+e,top:n,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[1]=Oa({left:o,top:n,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[2]=Oa({left:o,top:n+i,width:e,height:i},this.max_objects,this.max_levels,t),this.nodes[3]=Oa({left:o+e,top:n+i,width:e,height:i},this.max_objects,this.max_levels,t)},Ia.prototype.getIndex=function(t){var e,i=t.getBounds(),o=-1,n=(e=!0===t.isFloating?Ra.localToWorld(i.left,i.top,ka):ka.set(t.left,t.top)).x,r=e.y,s=i.width,a=i.height,h=this.bounds.left+this.bounds.width/2,l=this.bounds.top+this.bounds.height/2,u=r<l&&r+a<l,c=r>l;return n<h&&n+s<h?u?o=1:c&&(o=2):n>h&&(u?o=0:c&&(o=3)),o},Ia.prototype.insertContainer=function(t){for(var e,i=t.children.length;i--,e=t.children[i];)!0!==e.isKinematic&&(e instanceof Ma?("rootContainer"!==e.name&&this.insert(e),this.insertContainer(e)):"function"==typeof e.getBounds&&this.insert(e))},Ia.prototype.insert=function(t){var e=-1;if(this.nodes.length>0&&-1!==(e=this.getIndex(t)))this.nodes[e].insert(t);else if(this.objects.push(t),this.objects.length>this.max_objects&&this.level<this.max_levels){0===this.nodes.length&&this.split();for(var i=0;i<this.objects.length;)-1!==(e=this.getIndex(this.objects[i]))?this.nodes[e].insert(this.objects.splice(i,1)[0]):i+=1}},Ia.prototype.retrieve=function(t,e){var i=this.objects;if(this.nodes.length>0){var o=this.getIndex(t);if(-1!==o)i=i.concat(this.nodes[o].retrieve(t));else for(var n=0;n<this.nodes.length;n+=1)i=i.concat(this.nodes[n].retrieve(t))}return"function"==typeof e&&i.sort(e),i},Ia.prototype.remove=function(t){var e=!1;if(void 0===t.getBounds)return!1;if(this.nodes.length>0){var i=this.getIndex(t);-1!==i&&(e=rn(this.nodes[i],t))&&this.nodes[i].isPrunable()&&this.nodes.splice(i,1)}return!1===e&&-1!==this.objects.indexOf(t)&&(rn(this.objects,t),e=!0),e},Ia.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},Ia.prototype.hasChildren=function(){for(var t=0;t<this.nodes.length;t+=1){var e=this.nodes[t];if(e.length>0||e.objects.length>0)return!0}return!1},Ia.prototype.clear=function(t){this.objects.length=0;for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear(),i=this.nodes[e],Pa.push(i);var i;this.nodes.length=0,void 0!==t&&this.bounds.setMinMax(t.min.x,t.min.y,t.max.x,t.max.y)};var Ra,Ba,Da=function(t){function e(e,i,o,n){var r=this;void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=1/0),void 0===n&&(n=1/0),t.call(this,e,i,o,n,!0),this.name="rootContainer",this.anchorPoint.set(0,0),this.fps=60,this.gravity=new vn(0,.98),this.preRender=!1,this.bodies=new Set,this.broadphase=new Ia(this.getBounds().clone(),Aa.maxChildren,Aa.maxDepth),fr(Nn,this.reset,this),fr(Yn,(function(){r.broadphase.clear(r.getBounds())}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){this.broadphase.clear(),this.anchorPoint.set(0,0),t.prototype.reset.call(this),this.bodies.clear()},e.prototype.addBody=function(t){return this.bodies.add(t),this},e.prototype.removeBody=function(t){return this.bodies.delete(t),this},e.prototype.update=function(e){var i=Ah.isPaused();return this.broadphase.clear(),this.broadphase.insertContainer(this),this.bodies.forEach((function(t){if(!t.isStatic){var o=t.ancestor;i&&!o.updateWhenPaused||!o.inViewport&&!o.alwaysUpdate||(!0===t.update(e)&&(o.isDirty=!0),function(t,e){void 0===e&&(e=wa);for(var i,o=0,n=Ba.broadphase.retrieve(t),r=n.length;i=n[--r];)if(i!==t&&Ta(t,i)&&t.body.getBounds().overlaps(i.body.getBounds())){var s=t.body.shapes.length,a=i.body.shapes.length;if(0===s||0===a)continue;var h=0;do{var l=t.body.getShape(h),u=0;do{var c=i.body.getShape(u);!0===_a["test"+l.shapeType+c.shapeType].call(this,t,l,i,c,e.clear())&&(o++,e.indexShapeA=h,e.indexShapeB=u,t.onCollision&&!1!==t.onCollision(e,i)&&!1===t.body.isStatic&&t.body.respondToCollision.call(t.body,e),i.onCollision&&!1!==i.onCollision(e,t)&&!1===i.body.isStatic&&i.body.respondToCollision.call(i.body,e)),u++}while(u<a);h++}while(h<s)}}(o))}})),t.prototype.update.call(this,e)},e}(Ma),La=!0,za=!1,Fa=0,Va=1,ja=0,Na=0,Ua=0,Ga=1e3/60,Xa=0,Ha=null,Wa=0;fr(Rn,(function(){Ba=new Da,dr(jn)}));var Ya="z",qa=globalThis.performance.now();function Za(){}function Ka(){var t=Ah.current();void 0!==t&&(Ra=t.cameras.get("default")),dr(Nn),Ja()}function Ja(){Fa=0,Va=~~(.5+60/ju.maxfps),Ga=1e3/Ba.fps,ja=0,Na=10*Ga,za=ju.maxfps>Ba.fps}function $a(){La=!0}function Qa(t,e){if(++Fa%Va==0){for(Fa=0,dr(Un,t),ja+=ju.getDelta(),ja=Math.min(ja,Na),Xa=ju.interpolation?ju.getDelta():Ga,Ua=ju.interpolation?Xa:Math.max(Xa,Wa);ja>=Ua||ju.interpolation;)if(Ha=globalThis.performance.now(),!0!==Ah.isPaused()&&dr(Xn,t),La=e.update(Xa)||La,qa=globalThis.performance.now(),Wa=qa-Ha,ja-=Ua,ju.interpolation){ja=0;break}dr(Gn,qa)}}function th(t){!0===Ou.isContextValid&&(La||za)&&(dr(Hn,globalThis.performance.now()),Ou.clear(),t.draw(Ou),La=!1,Ou.flush(),dr(Wn,globalThis.performance.now()))}var eh,ih=Object.freeze({__proto__:null,get viewport(){return Ra},get world(){return Ba},mergeGroup:true,sortOn:Ya,get lastUpdate(){return qa},onLevelLoaded:Za,reset:Ka,updateFrameRate:Ja,getParentContainer:function(t){return t.ancestor},repaint:$a,update:Qa,draw:th}),oh=Math.min,nh=Math.max,rh=new vn,sh=function(t){function e(e,i,o,n){t.call(this,e,i,o-e,n-i),this.AXIS={NONE:0,HORIZONTAL:1,VERTICAL:2,BOTH:3},this.bounds=gn.pull("Bounds"),this.smoothFollow=!0,this.damping=1,this.near=-1e3,this.far=1e3,this.projectionMatrix=new Cn,this.invCurrentTransform=new Pn,this.offset=new vn,this.target=null,this.follow_axis=this.AXIS.NONE,this._shake={intensity:0,duration:0,axis:this.AXIS.BOTH,onComplete:null},this._fadeOut={color:null,tween:null},this._fadeIn={color:null,tween:null},this.name="default",this.setDeadzone(this.width/6,this.height/6),this.anchorPoint.set(0,0),this.isKinematic=!1,this.bounds.setMinMax(e,i,o,n),this._updateProjectionMatrix(),fr(Nn,this.reset,this),fr(sr,this.resize,this)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._updateProjectionMatrix=function(){this.projectionMatrix.ortho(0,this.width,this.height,0,this.near,this.far)},e.prototype._followH=function(t){var e=this.pos.x;return t.x-this.pos.x>this.deadzone.right?e=oh(t.x-this.deadzone.right,this.bounds.width-this.width):t.x-this.pos.x<this.deadzone.pos.x&&(e=nh(t.x-this.deadzone.pos.x,this.bounds.left)),e},e.prototype._followV=function(t){var e=this.pos.y;return t.y-this.pos.y>this.deadzone.bottom?e=oh(t.y-this.deadzone.bottom,this.bounds.height-this.height):t.y-this.pos.y<this.deadzone.pos.y&&(e=nh(t.y-this.deadzone.pos.y,this.bounds.top)),e},e.prototype.reset=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.pos.x=t,this.pos.y=e,this.unfollow(),this.smoothFollow=!0,this.damping=1,this.currentTransform.identity(),this.invCurrentTransform.identity().invert(),this._updateProjectionMatrix()},e.prototype.setDeadzone=function(t,e){void 0===this.deadzone&&(this.deadzone=new Kr(0,0,0,0)),this.deadzone.pos.set(~~((this.width-t)/2),~~((this.height-e)/2-.25*e)),this.deadzone.resize(t,e),this.smoothFollow=!1,this.updateTarget(),this.smoothFollow=!0},e.prototype.resize=function(e,i){return t.prototype.resize.call(this,e,i),this.smoothFollow=!1,this.setBounds(0,0,e,i),this.setDeadzone(e/6,i/6),this.update(),this.smoothFollow=!0,this._updateProjectionMatrix(),dr(ar,this.width,this.height),this},e.prototype.setBounds=function(t,e,i,o){this.smoothFollow=!1,this.bounds.setMinMax(t,e,i+t,o+e),this.moveTo(this.pos.x,this.pos.y),this.update(),this.smoothFollow=!0},e.prototype.follow=function(e,i,o){if(e instanceof t)this.target=e.pos;else{if(!(e instanceof vn||e instanceof xr||e instanceof _r||e instanceof br))throw new Error("invalid target for me.Camera2d.follow");this.target=e}this.follow_axis=void 0===i?this.AXIS.BOTH:i,this.smoothFollow=!1,this.damping="number"!=typeof o?1:$o(o,0,1),this.updateTarget(),this.smoothFollow=!0},e.prototype.unfollow=function(){this.target=null,this.follow_axis=this.AXIS.NONE},e.prototype.move=function(t,e){this.moveTo(this.pos.x+t,this.pos.y+e)},e.prototype.moveTo=function(t,e){var i=this.pos.x,o=this.pos.y;this.pos.x=$o(t,this.bounds.left,this.bounds.width),this.pos.y=$o(e,this.bounds.top,this.bounds.height),i===this.pos.x&&o===this.pos.y||(this.isDirty=!0)},e.prototype.updateTarget=function(){if(this.target){switch(rh.setV(this.pos),this.follow_axis){case this.AXIS.NONE:break;case this.AXIS.HORIZONTAL:rh.x=this._followH(this.target);break;case this.AXIS.VERTICAL:rh.y=this._followV(this.target);break;case this.AXIS.BOTH:rh.x=this._followH(this.target),rh.y=this._followV(this.target)}if(!this.pos.equals(rh)){if(!0===this.smoothFollow&&this.damping<1){if(on(rh.x,this.pos.x,2)&&on(rh.y,this.pos.y,2))return void this.pos.setV(rh);this.pos.lerp(rh,this.damping)}else this.pos.setV(rh);this.isDirty=!0}}},e.prototype.update=function(e){return this.updateTarget(e),this._shake.duration>0&&(this._shake.duration-=e,this._shake.duration<=0?(this._shake.duration=0,this.offset.setZero(),"function"==typeof this._shake.onComplete&&this._shake.onComplete()):(this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.HORIZONTAL||(this.offset.x=(Math.random()-.5)*this._shake.intensity),this._shake.axis!==this.AXIS.BOTH&&this._shake.axis!==this.AXIS.VERTICAL||(this.offset.y=(Math.random()-.5)*this._shake.intensity)),this.isDirty=!0),!0===this.isDirty&&dr(ur,this.pos),null==this._fadeIn.tween&&null==this._fadeOut.tween||(this.isDirty=!0),this.currentTransform.isIdentity()?this.invCurrentTransform.identity():this.invCurrentTransform.copy(this.currentTransform).invert(),t.prototype.update.call(this,e)},e.prototype.shake=function(t,e,i,o,n){0!==this._shake.duration&&!0!==n||(this._shake.intensity=t,this._shake.duration=e,this._shake.axis=i||this.AXIS.BOTH,this._shake.onComplete="function"==typeof o?o:void 0)},e.prototype.fadeOut=function(t,e,i){void 0===e&&(e=1e3),this._fadeOut.color=gn.pull("Color").copy(t),this._fadeOut.tween=gn.pull("Tween",this._fadeOut.color).to({alpha:0},e).onComplete(i||null),this._fadeOut.tween.isPersistent=!0,this._fadeOut.tween.start()},e.prototype.fadeIn=function(t,e,i){void 0===e&&(e=1e3),this._fadeIn.color=gn.pull("Color").copy(t);var o=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=gn.pull("Tween",this._fadeIn.color).to({alpha:o},e).onComplete(i||null),this._fadeIn.tween.isPersistent=!0,this._fadeIn.tween.start()},e.prototype.focusOn=function(t){var e=t.getBounds();this.moveTo(t.pos.x+e.left+e.width/2,t.pos.y+e.top+e.height/2)},e.prototype.isVisible=function(t,e){return void 0===e&&(e=t.floating),!0===e||!0===t.floating?Ou.overlaps(t.getBounds()):t.getBounds().overlaps(this)},e.prototype.localToWorld=function(t,e,i){return(i=i||gn.pull("Vector2d")).set(t,e).add(this.pos).sub(Ba.pos),this.currentTransform.isIdentity()||this.invCurrentTransform.apply(i),i},e.prototype.worldToLocal=function(t,e,i){return(i=i||gn.pull("Vector2d")).set(t,e),this.currentTransform.isIdentity()||this.currentTransform.apply(i),i.sub(this.pos).add(Ba.pos)},e.prototype.drawFX=function(t){this._fadeIn.tween&&(t.save(),t.resetTransform(),t.setColor(this._fadeIn.color),t.fillRect(0,0,this.width,this.height),t.restore(),1===this._fadeIn.color.alpha&&(this._fadeIn.tween=null,gn.push(this._fadeIn.color),this._fadeIn.color=null)),this._fadeOut.tween&&(t.save(),t.resetTransform(),t.setColor(this._fadeOut.color),t.fillRect(0,0,this.width,this.height),t.restore(),0===this._fadeOut.color.alpha&&(this._fadeOut.tween=null,gn.push(this._fadeOut.color),this._fadeOut.color=null))},e.prototype.draw=function(t,e){var i=this.pos.x+this.offset.x,o=this.pos.y+this.offset.y;e.currentTransform.translate(-i,-o),t.setProjection(this.projectionMatrix),t.clipRect(0,0,this.width,this.height),this.preDraw(t),e.preDraw(t),e.draw(t,this),this.drawFX(t),e.postDraw(t),this.postDraw(t),e.currentTransform.translate(i,o)},e}(la),ah={cameras:[]},hh=function(t){this.cameras=new Map,this.lights=new Map,this.ambientLight=new Sn(0,0,0,0),this.settings=Object.assign(ah,t||{})};hh.prototype.reset=function(){var t=this;if(this.settings.cameras.forEach((function(e){t.cameras.set(e.name,e)})),!1===this.cameras.has("default")){if(void 0===eh){var e=Ou.getWidth(),i=Ou.getHeight();eh=new sh(0,0,e,i)}this.cameras.set("default",eh)}Ka(),this.onResetEvent.apply(this,arguments)},hh.prototype.update=function(t){var e=Ba.update(t);return this.cameras.forEach((function(i){!0===i.update(t)&&(e=!0)})),this.lights.forEach((function(i){!0===i.update(t)&&(e=!0)})),e},hh.prototype.draw=function(t){var e=this;this.cameras.forEach((function(i){i.draw(t,Ba),0!==e.ambientLight.alpha&&(t.save(),e.lights.forEach((function(e){t.setMask(e.getVisibleArea(),!0)})),t.setColor(e.ambientLight),t.fillRect(0,0,i.width,i.height),t.clearMask(),t.restore()),e.lights.forEach((function(e){e.preDraw(t,Ba),e.draw(t,Ba),e.postDraw(t,Ba)}))}))},hh.prototype.destroy=function(){this.cameras.clear(),this.lights.forEach((function(t){t.destroy()})),this.lights.clear(),this.onDestroyEvent.apply(this,arguments)},hh.prototype.onResetEvent=function(){"function"==typeof this.settings.onResetEvent&&this.settings.onResetEvent.apply(this,arguments)},hh.prototype.onDestroyEvent=function(){"function"==typeof this.settings.onDestroyEvent&&this.settings.onDestroyEvent.apply(this,arguments)};var lh=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.barHeight=n,this.anchorPoint.set(0,0),fr(Zn,this.onProgressUpdate,this),fr(ar,this.resize,this),this.anchorPoint.set(0,0),this.progress=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onProgressUpdate=function(t){this.progress=~~(t*this.width),this.isDirty=!0},e.prototype.draw=function(t){t.setColor("black"),t.fillRect(this.pos.x,Ra.centerY,t.getWidth(),this.barHeight/2),t.setColor("#55aa00"),t.fillRect(this.pos.x,Ra.centerY,this.progress,this.barHeight/2)},e.prototype.onDestroyEvent=function(){gr(Zn,this.onProgressUpdate),gr(ar,this.resize)},e}(la),uh=function(t){function e(e,i){t.call(this,e,i,100,85),this.iconTexture=gn.pull("CanvasTexture",Ou.WebGLVersion>1?this.width:Ko(this.width),Ou.WebGLVersion>1?this.height:Ko(this.height),{offscreenCanvas:!0});var o=this.iconTexture.context;o.beginPath(),o.moveTo(.7,48.9),o.bezierCurveTo(10.8,68.9,38.4,75.8,62.2,64.5),o.bezierCurveTo(86.1,53.1,97.2,27.7,87,7.7),o.lineTo(87,7.7),o.bezierCurveTo(89.9,15.4,73.9,30.2,50.5,41.4),o.bezierCurveTo(27.1,52.5,5.2,55.8,.7,48.9),o.lineTo(.7,48.9),o.closePath(),o.fillStyle="rgb(255, 255, 255)",o.fill(),o.beginPath(),o.moveTo(84,7),o.bezierCurveTo(87.6,14.7,72.5,30.2,50.2,41.6),o.bezierCurveTo(27.9,53,6.9,55.9,3.2,48.2),o.bezierCurveTo(-.5,40.4,14.6,24.9,36.9,13.5),o.bezierCurveTo(59.2,2.2,80.3,-.8,84,7),o.lineTo(84,7),o.closePath(),o.lineWidth=5.3,o.strokeStyle="rgb(255, 255, 255)",o.lineJoin="miter",o.miterLimit=4,o.stroke(),this.anchorPoint.set(.5,.5)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t){t.drawImage(this.iconTexture.canvas,t.getWidth()/2,this.pos.y)},e.prototype.destroy=function(){t.prototype.destroy.call(this,arguments),gn.push(this.iconTexture),this.iconTexture=void 0},e}(la),ch=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(){Ba.backgroundColor.parseCSS("#202020"),Ba.addChild(new lh(0,Ou.getHeight()/2,Ou.getWidth(),8),1),Ba.addChild(new uh(Ou.getWidth()/2,Ou.getHeight()/2-16-35),2);var t=gn.pull("Text",Ou.getWidth()/2,Ou.getHeight()/2+16,{font:"century gothic",size:32,fillStyle:"white",textAlign:"left",textBaseline:"top",text:"melon",offScreenCanvas:Ou.WebGLVersion>=1});t.anchorPoint.set(0,0);var e=gn.pull("Text",Ou.getWidth()/2,Ou.getHeight()/2+16,{font:"century gothic",size:32,fillStyle:"#55aa00",textAlign:"left",textBaseline:"top",bold:!0,text:"JS",offScreenCanvas:Ou.WebGLVersion>=1});e.anchorPoint.set(0,0);var i=t.getBounds().width+e.getBounds().width;t.pos.x=Ou.getWidth()/2-i/2,e.pos.x=t.pos.x+t.getBounds().width,Ba.addChild(t,2),Ba.addChild(e,2)},e}(hh),ph=-1,dh=-1,fh=!1,yh={},gh={color:"",duration:0},vh=null,mh=null,_h=0;function xh(){-1===dh&&-1!==ph&&(dh=globalThis.requestAnimationFrame(bh))}function bh(t){var e=yh[ph].stage;Qa(t,e),th(e),-1!==dh&&(dh=globalThis.requestAnimationFrame(bh))}function wh(){globalThis.cancelAnimationFrame(dh),dh=-1}function Th(t){wh(),yh[ph]&&yh[ph].stage.destroy(),yh[t]&&(yh[ph=t].stage.reset.apply(yh[ph].stage,mh),xh(),dr(Fn),vh&&vh(),$a())}fr(Rn,(function(){Ah.set(Ah.LOADING,new ch),Ah.set(Ah.DEFAULT,new hh),fr(Vn,(function(){Ah.change(Ah.DEFAULT,!0)}))}));var Ah={LOADING:0,MENU:1,READY:2,PLAY:3,GAMEOVER:4,GAME_END:5,SCORE:6,CREDITS:7,SETTINGS:8,DEFAULT:9,USER:100,stop:function(t){void 0===t&&(t=!1),ph!==this.LOADING&&this.isRunning()&&(wh(),!0===t&&t(),_h=globalThis.performance.now(),dr(Ln))},pause:function(t){void 0===t&&(t=!1),ph===this.LOADING||this.isPaused()||(fh=!0,!0===t&&Wl(),_h=globalThis.performance.now(),dr(Bn))},restart:function(t){void 0===t&&(t=!1),this.isRunning()||(xh(),!0===t&&Yl(),_h=globalThis.performance.now()-_h,$a(),dr(zn,_h))},resume:function(t){void 0===t&&(t=!1),this.isPaused()&&(fh&&-1!==ph&&(fh=!1),!0===t&&Yl(),_h=globalThis.performance.now()-_h,dr(Dn,_h))},isRunning:function(){return-1!==dh},isPaused:function(){return fh},set:function(t,e,i){if(void 0===i&&(i=!1),!(e instanceof hh))throw new Error(e+" is not an instance of me.Stage");yh[t]={},yh[t].stage=e,yh[t].transition=!0,!0===i&&this.change(t)},get:function(t){return void 0===t&&(t=ph),void 0!==yh[t]?yh[t].stage:void 0},current:function(){return this.get()},transition:function(t,e,i){"fade"===t&&(gh.color=e,gh.duration=i)},setTransition:function(t,e){yh[t].transition=e},change:function(t,e){if(void 0===yh[t])throw new Error("Undefined Stage for state '"+t+"'");this.isCurrent(t)||(mh=null,arguments.length>1&&(mh=Array.prototype.slice.call(arguments,1)),gh.duration&&yh[t].transition?(vh=function(){Ra.fadeOut(gh.color,gh.duration)},Ra.fadeIn(gh.color,gh.duration,(function(){pn(Th,this,t)}))):!0===e?Th(t):pn(Th,this,t))},isCurrent:function(t){return ph===t}};function Sh(t,e,i){var o;if("string"!=typeof i)return i;switch(e){case"int":case"float":i=Number(i);break;case"bool":i="true"===i;break;default:if(!i||zo(i))i=!i||"true"===i;else if(Lo(i))i=Number(i);else if(0===i.search(/^json:/i)){o=i.split(/^json:/i)[1];try{i=JSON.parse(o)}catch(t){throw new Error("Unable to parse JSON: "+o)}}else if(0===i.search(/^eval:/i)){o=i.split(/^eval:/i)[1];try{i=Function("'use strict';return ("+o+")")()}catch(t){throw new Error("Unable to evaluate: "+o)}}else((o=i.match(/^#([\da-fA-F])([\da-fA-F]{3})$/))||(o=i.match(/^#([\da-fA-F]{2})([\da-fA-F]{6})$/)))&&(i="#"+o[2]+o[1]);0===t.search(/^(ratio|anchorPoint)$/)&&"number"==typeof i&&(i={x:i,y:i})}return i}function Eh(t,e,i){switch(i=i||"none",e=e||"none"){case"csv":return function(t){for(var e=t.replace("\n","").trim().split(","),i=[],o=0;o<e.length;o++)i.push(+e[o]);return i}(t);case"base64":var o=function(t,e){var i,o,n;e=e||1;var r=globalThis.atob(t.replace(/[^A-Za-z0-9\+\/\=]/g,"")),s=new Uint32Array(r.length/e);for(i=0,n=r.length/e;i<n;i++)for(s[i]=0,o=e-1;o>=0;--o)s[i]+=r.charCodeAt(i*e+o)<<(o<<3);return s}(t,4);return"none"===i?o:function(){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")}();case"none":return t;case"xml":throw new Error("XML encoding is deprecated, use base64 instead");default:throw new Error("Unknown layer encoding: "+e)}}function Ch(t,e){var i=e.nodeName;switch(i){case"data":var o=Mh(e);o.text=o.text||o.chunk.text,o.encoding=o.encoding||"xml",t.data=Eh(o.text,o.encoding,o.compression),t.encoding="none";break;case"imagelayer":case"layer":case"objectgroup":case"group":var n=Mh(e);n.type="layer"===i?"tilelayer":i,n.image&&(n.image=n.image.source),t.layers=t.layers||[],t.layers.push(n);break;case"animation":t.animation=Mh(e).frames;break;case"frame":case"object":var r=i+"s";t[r]=t[r]||[],t[r].push(Mh(e));break;case"tile":var s=Mh(e);s.image&&(s.imagewidth=s.image.width,s.imageheight=s.image.height,s.image=s.image.source),t.tiles=t.tiles||{},t.tiles[s.id]=s;break;case"tileset":var a=Mh(e);a.image&&(a.imagewidth=a.image.width,a.imageheight=a.image.height,a.image=a.image.source),t.tilesets=t.tilesets||[],t.tilesets.push(a);break;case"polygon":case"polyline":t[i]=[];for(var h,l=Mh(e).points.split(" "),u=0;u<l.length;u++)h=l[u].split(","),t[i].push({x:+h[0],y:+h[1]});break;case"properties":t.properties=Mh(e);break;case"property":var c=Mh(e),p=void 0!==c.value?c.value:c.text;t[c.name]=Sh(c.name,c.type||"string",p);break;default:t[i]=Mh(e)}}function Mh(t){var e={},i="";if(1===t.nodeType&&function(t,e){if(e.attributes&&e.attributes.length>0)for(var i=0;i<e.attributes.length;i++){var o=e.attributes.item(i);void 0!==o.name?t[o.name]=o.value:t[o.nodeName]=o.nodeValue}}(e,t),t.hasChildNodes())for(var o=0;o<t.childNodes.length;o++){var n=t.childNodes.item(o);switch(n.nodeType){case 1:Ch(e,n);break;case 3:i+=n.nodeValue.trim()}}return i&&(e.text=i),e}function Ph(t,e){var i=e.properties,o=e.propertytypes;if(void 0!==i)for(var n in i)if(i.hasOwnProperty(n)){var r="string",s=n,a=i[n];void 0!==i[n].name&&(s=i[n].name),void 0!==o?r=o[n]:void 0!==i[n].type&&(r=i[n].type),void 0!==i[n].value&&(a=i[n].value),t[s]=Sh(s,r,a)}}var Oh={},kh={},Ih={},Rh=e&&e.__generator||function(t,e){var i,o,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(n=2&r[0]?o.return:r[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;switch(o=0,n&&(r=[2&r[0],n.value]),r[0]){case 0:case 1:n=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!n||r[1]>n[0]&&r[1]<n[3])){s.label=r[1];break}if(6===r[0]&&s.label<n[1]){s.label=n[1],n=r;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(r);break}n[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{i=n=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},Bh=e&&e.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],o=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Dh=e&&e.__read||function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var o,n,r=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}return s};Object.defineProperty(Ih,"__esModule",{value:!0}),Ih.Multimap=void 0;var Lh=function(){function t(t,e){var i,o;if(this.size_=0,this.map=new Map,this.operator=t,e)try{for(var n=Bh(e),r=n.next();!r.done;r=n.next()){var s=Dh(r.value,2),a=s[0],h=s[1];this.put(a,h)}}catch(t){i={error:t}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return this}return Object.defineProperty(t.prototype,"size",{get:function(){return this.size_},enumerable:!1,configurable:!0}),t.prototype.get=function(t){var e=this.map.get(t);return e?this.operator.clone(e):this.operator.create()},t.prototype.put=function(t,e){var i=this.map.get(t);return i||(i=this.operator.create()),!!this.operator.add(e,i)&&(this.map.set(t,i),this.size_++,!0)},t.prototype.putAll=function(e,i){var o,n,r,s,a=0;if(i){var h=e,l=i;try{for(var u=Bh(l),c=u.next();!c.done;c=u.next()){var p=c.value;this.put(h,p),a++}}catch(t){o={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}}else{if(!(e instanceof t))throw new TypeError("unexpected arguments");try{for(var d=Bh(e.entries()),f=d.next();!f.done;f=d.next()){var y=Dh(f.value,2);h=y[0],p=y[1];this.put(h,p),a++}}catch(t){r={error:t}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}return a>0},t.prototype.has=function(t){return this.map.has(t)},t.prototype.hasEntry=function(t,e){return this.operator.has(e,this.get(t))},t.prototype.delete=function(t){return this.size_-=this.operator.size(this.get(t)),this.map.delete(t)},t.prototype.deleteEntry=function(t,e){var i=this.get(t);return!!this.operator.delete(e,i)&&(this.map.set(t,i),this.size_--,!0)},t.prototype.clear=function(){this.map.clear(),this.size_=0},t.prototype.keys=function(){return this.map.keys()},t.prototype.entries=function(){var t=this;return function(){var e,i,o,n,r,s,a,h,l,u,c,p,d,f;return Rh(this,(function(y){switch(y.label){case 0:y.trys.push([0,11,12,13]),e=Bh(t.map.entries()),i=e.next(),y.label=1;case 1:if(i.done)return[3,10];o=Dh(i.value,2),n=o[0],r=o[1],y.label=2;case 2:y.trys.push([2,7,8,9]),d=void 0,s=Bh(r),a=s.next(),y.label=3;case 3:return a.done?[3,6]:(h=a.value,[4,[n,h]]);case 4:y.sent(),y.label=5;case 5:return a=s.next(),[3,3];case 6:return[3,9];case 7:return l=y.sent(),d={error:l},[3,9];case 8:try{a&&!a.done&&(f=s.return)&&f.call(s)}finally{if(d)throw d.error}return[7];case 9:return i=e.next(),[3,1];case 10:return[3,13];case 11:return u=y.sent(),c={error:u},[3,13];case 12:try{i&&!i.done&&(p=e.return)&&p.call(e)}finally{if(c)throw c.error}return[7];case 13:return[2]}}))}()},t.prototype.values=function(){var t=this;return function(){var e,i,o,n,r,s;return Rh(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=Bh(t.entries()),i=e.next(),a.label=1;case 1:return i.done?[3,4]:(o=Dh(i.value,2),[4,o[1]]);case 2:a.sent(),a.label=3;case 3:return i=e.next(),[3,1];case 4:return[3,7];case 5:return n=a.sent(),r={error:n},[3,7];case 6:try{i&&!i.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}return[7];case 7:return[2]}}))}()},t.prototype.forEach=function(t,e){var i,o;try{for(var n=Bh(this.entries()),r=n.next();!r.done;r=n.next()){var s=Dh(r.value,2),a=s[0],h=s[1];t.call(void 0===e?this:e,h,a,this)}}catch(t){i={error:t}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}},t.prototype[Symbol.iterator]=function(){return this.entries()},t.prototype.asMap=function(){var t,e,i=new Map;try{for(var o=Bh(this.keys()),n=o.next();!n.done;n=o.next()){var r=n.value;i.set(r,this.operator.clone(this.get(r)))}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return i},t}();Ih.Multimap=Lh;var zh,Fh=e&&e.__extends||(zh=function(t,e){return zh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},zh(t,e)},function(t,e){function i(){this.constructor=t}zh(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(kh,"__esModule",{value:!0}),kh.ArrayMultimap=void 0;var Vh=function(t){function e(e){return t.call(this,new jh,e)||this}return Fh(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"ArrayMultimap"},enumerable:!1,configurable:!0}),e}(Ih.Multimap);kh.ArrayMultimap=Vh;var jh=function(){function t(){}return t.prototype.create=function(){return[]},t.prototype.clone=function(t){return t.slice()},t.prototype.add=function(t,e){return e.push(t),!0},t.prototype.size=function(t){return t.length},t.prototype.delete=function(t,e){var i=e.indexOf(t);return i>-1&&(e.splice(i,1),!0)},t.prototype.has=function(t,e){return e.includes(t)},t}(),Nh={},Uh=e&&e.__extends||function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();Object.defineProperty(Nh,"__esModule",{value:!0}),Nh.SetMultimap=void 0;var Gh=function(t){function e(e){return t.call(this,new Xh,e)||this}return Uh(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"SetMultimap"},enumerable:!1,configurable:!0}),e}(Ih.Multimap);Nh.SetMultimap=Gh;var Xh=function(){function t(){}return t.prototype.create=function(){return new Set},t.prototype.clone=function(t){return new Set(t)},t.prototype.add=function(t,e){var i=e.size;return e.add(t),i!==e.size},t.prototype.size=function(t){return t.size},t.prototype.delete=function(t,e){return e.delete(t)},t.prototype.has=function(t,e){return e.has(t)},t}();!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SetMultimap=t.ArrayMultimap=void 0;var e=kh;Object.defineProperty(t,"ArrayMultimap",{enumerable:!0,get:function(){return e.ArrayMultimap}});var i=Nh;Object.defineProperty(t,"SetMultimap",{enumerable:!0,get:function(){return i.SetMultimap}})}(Oh);var Hh=function(t){this.cache=new Oh.ArrayMultimap,this.tinted=new Map,this.units=new Map,this.max_size=t||1/0,this.clear()};function Wh(t,e,i,o){return void 0===i&&(i="default"),void 0===o&&(o="no-repeat"),{meta:{app:"melonJS",size:{w:t,h:e},repeat:o,image:"default"},frames:[{filename:i,frame:{x:0,y:0,w:t,h:e}}]}}Hh.prototype.clear=function(){this.cache.clear(),this.tinted.clear(),this.units.clear(),this.length=0},Hh.prototype.validate=function(){if(this.length>=this.max_size)throw new Error("Texture cache overflow: "+this.max_size+" texture units available for this GPU.")},Hh.prototype.get=function(t,e){var i;return void 0===e?i=this.cache.get(t)[0]:this.cache.forEach((function(o,n){var r=o.getAtlas();n===t&&r[0].width===e.framewidth&&r[0].height===e.frameheight&&(i=o)})),void 0===i&&(e||(e=Wh(t.width,t.height,t.src?ln(t.src):void 0)),i=new Yh(e,t,!1),this.set(t,i)),i},Hh.prototype.delete=function(t){this.cache.has(t)||this.cache.delete(t)},Hh.prototype.tint=function(t,e){var i=this.tinted.get(t);return void 0===i&&(i=this.tinted.set(t,new Map)),i.has(e)||i.set(e,Ou.tint(t,e,"multiply")),i.get(e)},Hh.prototype.set=function(t,e){var i=t.width,o=t.height;if(!(1!==Ou.WebGLVersion||Zo(i)&&Zo(o))){var n=void 0!==t.src?t.src:t;console.warn("[Texture] "+n+" is not a POT texture ("+i+"x"+o+")")}return this.cache.put(t,e)},Hh.prototype.getUnit=function(t){return this.units.has(t)||(this.validate(),this.units.set(t,this.length++)),this.units.get(t)};var Yh=function(t,e,i){var o=this;if(this.format=null,this.sources=new Map,this.atlases=new Map,void 0!==t)for(var n in t=Array.isArray(t)?t:[t]){var r=t[n];if(void 0!==r.meta){if(r.meta.app.includes("texturepacker")||r.meta.app.includes("free-tex-packer")){if(this.format="texturepacker",void 0===e){var s=zl.getImage(r.meta.image);if(!s)throw new Error("Atlas texture '"+s+"' not found");this.sources.set(r.meta.image,s)}else this.sources.set(r.meta.image||"default","string"==typeof e?zl.getImage(e):e);this.repeat="no-repeat"}else if(r.meta.app.includes("ShoeBox")){if(!r.meta.exporter||!r.meta.exporter.includes("melonJS"))throw new Error("ShoeBox requires the JSON exporter : https://github.com/melonjs/melonJS/tree/master/media/shoebox_JSON_export.sbx");this.format="ShoeBox",this.repeat="no-repeat",this.sources.set("default","string"==typeof e?zl.getImage(e):e)}else r.meta.app.includes("melonJS")&&(this.format="melonJS",this.repeat=r.meta.repeat||"no-repeat",this.sources.set("default","string"==typeof e?zl.getImage(e):e));this.atlases.set(r.meta.image||"default",this.parse(r))}else void 0!==r.framewidth&&void 0!==r.frameheight&&(this.format="Spritesheet (fixed cell size)",this.repeat="no-repeat",void 0!==e&&(r.image="string"==typeof e?zl.getImage(e):e),this.atlases.set("default",this.parseFromSpriteSheet(r)),this.sources.set("default",r.image))}if(0===this.atlases.length)throw new Error("texture atlas format not supported");!1!==i&&this.sources.forEach((function(t){i instanceof Hh?i.set(t,o):Ou.cache.set(t,o)}))};Yh.prototype.parse=function(t){var e=this,i={};return t.frames.forEach((function(o){if(o.hasOwnProperty("filename")){var n,r,s=o.frame,a=o.spriteSourceSize&&o.sourceSize&&o.pivot;a&&(n=o.sourceSize.w*o.pivot.x-(o.trimmed?o.spriteSourceSize.x:0),r=o.sourceSize.h*o.pivot.y-(o.trimmed?o.spriteSourceSize.y:0)),i[o.filename]={name:o.filename,texture:t.meta.image||"default",offset:new vn(s.x,s.y),anchorPoint:a?new vn(n/s.w,r/s.h):null,trimmed:!!o.trimmed,width:s.w,height:s.h,angle:!0===o.rotated?-Yo:0},e.addUVs(i,o.filename,t.meta.size.w,t.meta.size.h)}})),i},Yh.prototype.parseFromSpriteSheet=function(t){var e={},i=t.image,o=t.spacing||0,n=t.margin||0,r=i.width,s=i.height,a=gn.pull("Vector2d",~~((r-n+o)/(t.framewidth+o)),~~((s-n+o)/(t.frameheight+o)));if(r%(t.framewidth+o)!=0||s%(t.frameheight+o)!=0){var h=a.x*(t.framewidth+o),l=a.y*(t.frameheight+o);h-r!==o&&l-s!==o&&(r=h,s=l,console.warn("Spritesheet Texture for image: "+i.src+" is not divisible by "+(t.framewidth+o)+"x"+(t.frameheight+o)+", truncating effective size to "+r+"x"+s))}for(var u=0,c=a.x*a.y;u<c;u++){var p=""+u;e[p]={name:p,texture:"default",offset:new vn(n+(o+t.framewidth)*(u%a.x),n+(o+t.frameheight)*~~(u/a.x)),anchorPoint:t.anchorPoint||null,trimmed:!1,width:t.framewidth,height:t.frameheight,angle:0},this.addUVs(e,p,r,s)}return gn.push(a),e},Yh.prototype.getAtlas=function(t){return"string"==typeof t?this.atlases.get(t):this.atlases.values().next().value},Yh.prototype.getFormat=function(){return this.format},Yh.prototype.getTexture=function(t){return"object"==typeof t&&"string"==typeof t.texture?this.sources.get(t.texture):this.sources.values().next().value},Yh.prototype.addRegion=function(t,e,i,o,n){!0===Ou.settings.verbose&&console.warn("Adding texture region",t,"for texture",this);var r=this.getTexture(),s=this.getAtlas(),a=r.width,h=r.height;return s[t]={name:t,offset:new vn(e,i),width:o,height:n,angle:0},this.addUVs(s,t,a,h),s[t]},Yh.prototype.getRegion=function(t,e){var i;return"string"==typeof e?i=this.getAtlas(e)[t]:this.atlases.forEach((function(e){void 0!==e[t]&&(i=e[t])})),i},Yh.prototype.getUVs=function(t){var e=this.getRegion(t);if(void 0===e){var i=t.split(","),o=+i[0],n=+i[1],r=+i[2],s=+i[3];e=this.addRegion(t,o,n,r,s)}return e.uvs},Yh.prototype.addUVs=function(t,e,i,o){if(Ou instanceof wu){var n=t[e].offset,r=t[e].width,s=t[e].height;t[e].uvs=new Float32Array([n.x/i,n.y/o,(n.x+r)/i,(n.y+s)/o]),t[n.x+","+n.y+","+i+","+o]=t[e]}return t[e].uvs},Yh.prototype.createSpriteFromName=function(t,e,i){return void 0===i&&(i=!1),gn.pull(!0===i?"me.NineSliceSprite":"me.Sprite",0,0,Object.assign({image:this,region:t},e||{}))},Yh.prototype.createAnimationFromName=function(t,e){for(var i,o=[],n={},r=0,s=0,a=0;a<t.length;++a){if(null==(i=this.getRegion(t[a])))throw new Error("Texture - region for "+t[a]+" not found");o[a]=i,n[t[a]]=a,r=Math.max(i.width,r),s=Math.max(i.height,s)}return new qh(0,0,Object.assign({image:this,framewidth:r,frameheight:s,margin:0,spacing:0,atlas:o,atlasIndices:n},e||{}))};var qh=function(t){function e(e,i,o){if(t.call(this,e,i,0,0),this.animationpause=!1,this.animationspeed=100,this.offset=gn.pull("Vector2d",0,0),this.source=null,this.anim={},this.resetAnim=void 0,this.current={name:"default",length:0,offset:gn.pull("Vector2d"),width:0,height:0,angle:0,idx:0},this.dt=0,this._flicker={isFlickering:!1,duration:0,callback:null,state:!1},o.image instanceof Yh){if(this.source=o.image,this.image=this.source.getTexture(),this.textureAtlas=o.image,void 0!==o.region){var n=this.source.getRegion(o.region);if(!n)throw new Error("Texture - region for "+o.region+" not found");this.setRegion(n),this.current.width=o.framewidth||n.width,this.current.height=o.frameheight||n.height}}else{if(this.image="object"==typeof o.image?o.image:zl.getImage(o.image),!this.image)throw new Error("me.Sprite: '"+o.image+"' image/texture not found!");this.current.width=o.framewidth=o.framewidth||this.image.width,this.current.height=o.frameheight=o.frameheight||this.image.height,this.source=Ou.cache.get(this.image,o),this.textureAtlas=this.source.getAtlas()}void 0!==o.atlas&&(this.textureAtlas=o.atlas,this.atlasIndices=o.atlasIndices),this.width=this.current.width,this.height=this.current.height,void 0!==o.flipX&&this.flipX(!!o.flipX),void 0!==o.flipY&&this.flipY(!!o.flipY),void 0!==o.rotation&&this.rotate(o.rotation),o.anchorPoint&&this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y),void 0!==o.tint&&this.tint.setColor(o.tint),"string"==typeof o.name&&(this.name=o.name),void 0!==o.z&&(this.pos.z=o.z),0!==this.addAnimation("default",null)&&this.setCurrentAnimation("default"),this.autoTransform=!0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isFlickering=function(){return this._flicker.isFlickering},e.prototype.flicker=function(t,e){return this._flicker.duration=t,this._flicker.duration<=0?(this._flicker.isFlickering=!1,this._flicker.callback=null):this._flicker.isFlickering||(this._flicker.callback=e,this._flicker.isFlickering=!0),this},e.prototype.addAnimation=function(t,e,i){this.anim[t]={name:t,frames:[],idx:0,length:0};var o=0;if("object"!=typeof this.textureAtlas)return 0;null==e&&(e=[],Object.keys(this.textureAtlas).forEach((function(t,i){e[i]=i})));for(var n=0,r=e.length;n<r;n++){var s,a=e[n],h=(s="number"==typeof a||"string"==typeof a?{name:a,delay:i||this.animationspeed}:a).name;if("number"==typeof h)void 0!==this.textureAtlas[h]&&(this.anim[t].frames[n]=Object.assign({},this.textureAtlas[h],s),o++);else{if(this.source.getFormat().includes("Spritesheet"))throw new Error("string parameters for addAnimation are not allowed for standard spritesheet based Texture");this.anim[t].frames[n]=Object.assign({},this.textureAtlas[this.atlasIndices[h]],s),o++}}return this.anim[t].length=o,o},e.prototype.setCurrentAnimation=function(t,e,i){if(!this.anim[t])throw new Error("animation id '"+t+"' not defined");return this.current.name=t,this.current.length=this.anim[this.current.name].length,this.resetAnim="string"==typeof e?this.setCurrentAnimation.bind(this,e,null,!0):"function"==typeof e?e:void 0,this.setAnimationFrame(this.current.idx),i||(this.dt=0),this.isDirty=!0,this},e.prototype.reverseAnimation=function(t){return void 0!==t&&void 0!==this.anim[t]?this.anim[t].frames.reverse():this.anim[this.current.name].frames.reverse(),this.isDirty=!0,this},e.prototype.isCurrentAnimation=function(t){return this.current.name===t},e.prototype.setRegion=function(t){return this.image=this.source.getTexture(t),this.current.offset.setV(t.offset),this.current.angle=t.angle,this.width=this.current.width=t.width,this.height=this.current.height=t.height,t.anchorPoint&&this.anchorPoint.set(this._flip.x&&!0===t.trimmed?1-t.anchorPoint.x:t.anchorPoint.x,this._flip.y&&!0===t.trimmed?1-t.anchorPoint.y:t.anchorPoint.y),this.isDirty=!0,this},e.prototype.setAnimationFrame=function(t){return this.current.idx=(t||0)%this.current.length,this.setRegion(this.getAnimationFrameObjectByIndex(this.current.idx))},e.prototype.getCurrentAnimationFrame=function(){return this.current.idx},e.prototype.getAnimationFrameObjectByIndex=function(t){return this.anim[this.current.name].frames[t]},e.prototype.update=function(e){if(!this.animationpause&&this.current&&this.current.length>0){var i=this.getAnimationFrameObjectByIndex(this.current.idx).delay;for(this.dt+=e;this.dt>=i;){this.isDirty=!0,this.dt-=i;var o=this.current.length>1?this.current.idx+1:this.current.idx;if(this.setAnimationFrame(o),0===this.current.idx&&"function"==typeof this.resetAnim&&!1===this.resetAnim()){this.setAnimationFrame(this.current.length-1),this.dt%=i;break}i=this.getAnimationFrameObjectByIndex(this.current.idx).delay}}return this._flicker.isFlickering&&(this._flicker.duration-=e,this._flicker.duration<0&&("function"==typeof this._flicker.callback&&this._flicker.callback(),this.flicker(-1)),this.isDirty=!0),t.prototype.update.call(this,e)},e.prototype.destroy=function(){gn.push(this.offset),this.offset=void 0,t.prototype.destroy.call(this)},e.prototype.draw=function(t,e){if(!this._flicker.isFlickering||(this._flicker.state=!this._flicker.state,this._flicker.state)){var i=this.current,o=this.pos.x,n=this.pos.y,r=i.width,s=i.height,a=i.offset,h=this.offset;0!==i.angle&&(t.translate(-o,-n),t.rotate(i.angle),o-=s,r=i.height,s=i.width),t.drawImage(this.image,h.x+a.x,h.y+a.y,r,s,o,n,r,s)}},e}(la),Zh=536870911,Kh=function(t){function e(e,i,o,n){var r,s;if(t.call(this),n.isCollection){var a=n.getTileImage(o&Zh);r=a.width,s=a.height}else r=n.tilewidth,s=n.tileheight;this.setMinMax(0,0,r,s),this.tileset=n,this.currentTransform=null,this.col=e,this.row=i,this.tileId=o,this.flippedX=0!=(2147483648&this.tileId),this.flippedY=0!=(1073741824&this.tileId),this.flippedAD=0!=(536870912&this.tileId),this.flipped=this.flippedX||this.flippedY||this.flippedAD,!0===this.flipped&&(null===this.currentTransform&&(this.currentTransform=new Pn),this.setTileTransform(this.currentTransform.identity())),this.tileId&=Zh}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setTileTransform=function(t){t.translate(this.width/2,this.height/2),this.flippedAD&&(t.rotate(-90*Math.PI/180),t.scale(-1,1)),this.flippedX&&t.scale(this.flippedAD?1:-1,this.flippedAD?-1:1),this.flippedY&&t.scale(this.flippedAD?-1:1,this.flippedAD?1:-1),t.translate(-this.width/2,-this.height/2)},e.prototype.getRenderable=function(t){var e,i=this.tileset;if(i.animations.has(this.tileId)){var o=[],n=[];i.animations.get(this.tileId).frames.forEach((function(t){n.push(t.tileid),o.push({name:""+t.tileid,delay:t.duration})})),(e=i.texture.createAnimationFromName(n,t)).addAnimation(this.tileId-i.firstgid,o),e.setCurrentAnimation(this.tileId-i.firstgid)}else if(!0===i.isCollection){var r=i.getTileImage(this.tileId);(e=new qh(0,0,Object.assign({image:r}))).anchorPoint.set(0,0),e.scale(t.width/this.width,t.height/this.height),void 0!==t.rotation&&(e.anchorPoint.set(.5,.5),e.currentTransform.rotate(t.rotation),e.currentTransform.translate(t.width/2,t.height/2),t.rotation=void 0)}else(e=i.texture.createSpriteFromName(this.tileId-i.firstgid,t)).anchorPoint.set(0,0);return this.setTileTransform(e.currentTransform),e},e}(ls),Jh=function(t){function e(e,i,o,n,r){void 0===r&&(r=20),t.call(this,e,i,o,n),this.radius=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={radius:{configurable:!0}};return e.prototype.onResetEvent=function(e,i,o,n,r){t.prototype.setShape.call(this,e,i,o,n),this.radius=r},i.radius.get=function(){return this._radius},i.radius.set=function(t){this.width<2*t&&(t=this.width/2),this.height<2*t&&(t=this.height/2),this._radius=t},e.prototype.copy=function(e){return t.prototype.setShape.call(this,e.pos.x,e.pos.y,e.width,e.height),this.radius=e.radius,this},e.prototype.contains=function(){var e,i,o,n,r=arguments[0];if(2===arguments.length)e=r,i=arguments[1];else{if(r instanceof t)return t.prototype.contains.call(this,r);e=r.x,i=r.y}if(e<this.left||e>=this.right||i<this.top||i>=this.bottom)return!1;if(e>=this.left+this.radius&&e<=this.right-this.radius||i>=this.top+this.radius&&i<=this.bottom-this.radius)return!0;var s=Math.max(0,Math.min(this.radius,this.width/2)),a=Math.max(0,Math.min(this.radius,this.height/2));if(e<this.left+s&&i<this.top+a)o=e-this.left-s,n=i-this.top-a;else if(e>this.right-s&&i<this.top+a)o=e-this.right+s,n=i-this.top-a;else if(e>this.right-s&&i>this.bottom-a)o=e-this.right+s,n=i-this.bottom+a;else{if(!(e<this.left+s&&i>this.bottom-a))return!1;o=e-this.left-s,n=i-this.bottom+a}return o*o+n*n<=s*a},e.prototype.equals=function(e){return t.prototype.equals.call(this,e)&&this.radius===e.radius},e.prototype.clone=function(){return new e(this.pos.x,this.pos.y,this.width,this.height,this.radius)},Object.defineProperties(e.prototype,i),e}(Kr),$h=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.contains=function(){var t,e;2===arguments.length?(t=arguments[0],e=arguments[1]):(t=arguments[0].x,e=arguments[0].y),t-=this.pos.x,e-=this.pos.y;var i=this.points[0],o=this.points[1];return(e-i.y)*(o.x-i.x)==(o.y-i.y)*(t-i.x)},e.prototype.recalc=function(){var t=this.edges,e=this.normals,i=this.indices,o=this.points;if(2!==o.length)throw new Error("Requires exactly 2 points");return void 0===t[0]&&(t[0]=gn.pull("Vector2d")),t[0].copy(o[1]).sub(o[0]),void 0===e[0]&&(e[0]=gn.pull("Vector2d")),e[0].copy(t[0]).perp().normalize(),i.length=0,this},e.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new e(this.pos.x,this.pos.y,t)},e}(Zr),Qh=function(){this.points=[],this.arcResolution=5,this.vertices=[]};Qh.prototype.beginPath=function(){this.points.forEach((function(t){gn.push(t)})),this.points.length=0},Qh.prototype.closePath=function(){var t=this.points;t.length>1&&!t[t.length-1].equals(t[0])&&t.push(gn.pull("Vector2d",t[0].x,t[0].y))},Qh.prototype.triangulatePath=function(){var t=0,e=this.points,i=this.vertices,o=wr.exports(e.flatMap((function(t){return[t.x,t.y]})));for(t=0;t<o.length;t++)void 0===i[t]&&(i[t]=gn.pull("Vector2d")),i[t].set(e[o[t]].x,e[o[t]].y);for(;i.length>o.length;)gn.push(i[i.length-1]),i.length-=1;return i},Qh.prototype.moveTo=function(t,e){this.points.push(gn.pull("Vector2d",t,e))},Qh.prototype.lineTo=function(t,e){this.points.push(gn.pull("Vector2d",t,e))},Qh.prototype.arc=function(t,e,i,o,n,r){void 0===r&&(r=!1);var s=this.points;if(o!==n){var a=r?Math.abs(o-n)>=Wo:Math.abs(n-o)>=Wo;(o%=Wo)<0&&(o+=Wo),(n%=Wo)<0&&(n+=Wo),o>=n&&(n+=Wo);var h=n-o,l=1;r&&(l=-1,h=Wo-h),a&&(h=Wo);for(var u=h*i/this.arcResolution,c=h/u,p=o,d=0;d<u;d++)s.push(gn.pull("Vector2d",t+i*Math.cos(p),e+i*Math.sin(p))),p+=l*c;s.push(gn.pull("Vector2d",t+i*Math.cos(n),e+i*Math.sin(n)))}},Qh.prototype.arcTo=function(t,e,i,o,n){var r=this.points,s=[r[r.length-1].x-t,r[r.length-1].y-e],a=[i-t,o-e],h=Math.sqrt(Math.pow(s[0],2)+Math.pow(s[1],2)),l=Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2));s[0]/=h,s[1]/=h,a[0]/=l,a[1]/=l;var u=Math.atan2(s[1],s[0])-Math.atan2(a[1],a[0]),c=n/Math.tan(u/2),p=[t+s[0]*c,e+s[1]*c],d=[t+a[0]*c,e+a[1]*c];r.push(gn.pull("Vector2d",p[0],p[1]));var f=[(s[0]+a[0])/2,(s[1]+a[1])/2],y=Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2));f[0]/=y,f[1]/=y;var g=Math.sqrt(Math.pow(n,2)+Math.pow(c,2)),v=[t+g*f[0],e+g*f[1]],m=Math.atan2(p[1]-v[1],p[0]-v[0]),_=Math.atan2(d[1]-v[1],d[0]-v[0]);this.arc(v[0],v[1],n,m,_)},Qh.prototype.ellipse=function(t,e,i,o,n,r,s,a){void 0===a&&(a=!1);var h=this.points;if(r!==s){var l=a?Math.abs(r-s)>=Wo:Math.abs(s-r)>=Wo;(r%=Wo)<0&&(r+=Wo),(s%=Wo)<0&&(s+=Wo),r>=s&&(s+=Wo);var u=s-r,c=1;a&&(c=-1,u=Wo-u),l&&(u=Wo);for(var p=(u*i+u*o)/2/this.arcResolution,d=u/p,f=r,y=Math.cos(n),g=Math.sin(n),v=0;v<p;v++){var m=i*Math.cos(f),_=o*Math.sin(f),x=t+m*y-_*g,b=e+m*g+_*y;h.push(gn.pull("Vector2d",x,b)),f+=c*d}}},Qh.prototype.rect=function(t,e,i,o){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+o),this.lineTo(t,e+o),this.lineTo(t,e)},Qh.prototype.roundRect=function(t,e,i,o,n){this.moveTo(t+n,e),this.lineTo(t+i-n,e),this.arcTo(t+i,e,t+i,e+n,n),this.lineTo(t+i,e+o-n),this.arcTo(t+i,e+o,t+i-n,e+o,n),this.lineTo(t+n,e+o),this.arcTo(t,e+o,t,e+o-n,n),this.lineTo(t,e+n),this.arcTo(t,e,t+n,e,n)};var tl=function(t){this.settings=t,this.isContextValid=!0,this.path2D=new Qh,this.currentScissor=new Int32Array([0,0,this.settings.width,this.settings.height]),this.maskLevel=0,this.currentBlendMode="none",!0===du.ejecta?this.canvas=document.getElementById("canvas"):void 0!==globalThis.canvas?this.canvas=globalThis.canvas:void 0!==this.settings.canvas?this.canvas=this.settings.canvas:this.canvas=ku(this.settings.zoomX,this.settings.zoomY),this.backBufferCanvas=this.canvas,this.context=null,this.currentColor=new Sn(0,0,0,1),this.currentTint=new Sn(255,255,255,1),this.projectionMatrix=new Cn,this.uvOffset=0,fr(Nn,(function(){Ou.reset()}))};tl.prototype.clear=function(){},tl.prototype.reset=function(){this.resetTransform(),this.setBlendMode(this.settings.blendMode),this.setColor("#000000"),this.clearTint(),this.cache.clear(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height,this.clearMask()},tl.prototype.getCanvas=function(){return this.backBufferCanvas},tl.prototype.getScreenCanvas=function(){return this.canvas},tl.prototype.getScreenContext=function(){return this.context},tl.prototype.getBlendMode=function(){return this.currentBlendMode},tl.prototype.getContext2d=function(t,e){if(null==t)throw new Error("You must pass a canvas element in order to create a 2d context");if(void 0===t.getContext)throw new Error("Your browser does not support HTML5 canvas.");"boolean"!=typeof e&&(e=!0);var i=t.getContext("2d",{alpha:e});return i.canvas||(i.canvas=t),this.setAntiAlias(i,this.settings.antiAlias),i},tl.prototype.getWidth=function(){return this.backBufferCanvas.width},tl.prototype.getHeight=function(){return this.backBufferCanvas.height},tl.prototype.getColor=function(){return this.currentColor},tl.prototype.globalAlpha=function(){return this.currentColor.glArray[3]},tl.prototype.overlaps=function(t){return t.left<=this.getWidth()&&t.right>=0&&t.top<=this.getHeight()&&t.bottom>=0},tl.prototype.resize=function(t,e){t===this.backBufferCanvas.width&&e===this.backBufferCanvas.height||(this.canvas.width=this.backBufferCanvas.width=t,this.canvas.height=this.backBufferCanvas.height=e,this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=t,this.currentScissor[3]=e,dr(sr,t,e))},tl.prototype.setAntiAlias=function(t,e){var i=t.canvas;Uo("imageSmoothingEnabled",!0===e,t),!0!==e?(i.style["image-rendering"]="optimizeSpeed",i.style["image-rendering"]="-moz-crisp-edges",i.style["image-rendering"]="-o-crisp-edges",i.style["image-rendering"]="-webkit-optimize-contrast",i.style["image-rendering"]="optimize-contrast",i.style["image-rendering"]="crisp-edges",i.style["image-rendering"]="pixelated",i.style.msInterpolationMode="nearest-neighbor"):i.style["image-rendering"]="auto"},tl.prototype.setProjection=function(t){this.projectionMatrix.copy(t)},tl.prototype.stroke=function(t,e){if(t instanceof Jh)this.strokeRoundRect(t.left,t.top,t.width,t.height,t.radius,e);else if(t instanceof Kr||t instanceof ls)this.strokeRect(t.left,t.top,t.width,t.height,e);else if(t instanceof $h||t instanceof Zr)this.strokePolygon(t,e);else{if(!(t instanceof ua))throw new Error("Invalid geometry for fill/stroke");this.strokeEllipse(t.pos.x,t.pos.y,t.radiusV.x,t.radiusV.y,e)}},tl.prototype.fill=function(t){this.stroke(t,!0)},tl.prototype.tint=function(t,e,i){var o=ku(t.width,t.height,!0),n=this.getContext2d(o);return n.save(),n.fillStyle=e instanceof Sn?e.toRGB():e,n.fillRect(0,0,t.width,t.height),n.globalCompositeOperation=i||"multiply",n.drawImage(t,0,0),n.globalCompositeOperation="destination-atop",n.drawImage(t,0,0),n.restore(),o},tl.prototype.setMask=function(t){},tl.prototype.clearMask=function(){},tl.prototype.setTint=function(t,e){void 0===e&&(e=t.alpha),this.currentTint.copy(t),this.currentTint.alpha*=e},tl.prototype.clearTint=function(){this.currentTint.setColor(255,255,255,1)},tl.prototype.drawFont=function(){};var el=function(t){function e(e){var i=this;t.call(this,e),this.context=this.getContext2d(this.getScreenCanvas(),this.settings.transparent),this.settings.doubleBuffering?(this.backBufferCanvas=ku(this.settings.width,this.settings.height,!0),this.backBufferContext2D=this.getContext2d(this.backBufferCanvas)):(this.backBufferCanvas=this.getScreenCanvas(),this.backBufferContext2D=this.context),this.setBlendMode(this.settings.blendMode),this.setColor(this.currentColor),this.cache=new Hh,!1===this.settings.textureSeamFix||this.settings.antiAlias||(this.uvOffset=1),this.getScreenCanvas().addEventListener("contextlost",(function(t){t.preventDefault(),i.isContextValid=!1,dr(cr,i)}),!1),this.getScreenCanvas().addEventListener("contextrestored",(function(){i.isContextValid=!0,dr(pr,i)}),!1)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),this.clearColor(this.currentColor,!0!==this.settings.transparent)},e.prototype.resetTransform=function(){this.backBufferContext2D.setTransform(1,0,0,1,0,0)},e.prototype.setBlendMode=function(t,e){switch(void 0===t&&(t="normal"),e=e||this.getContext(),this.currentBlendMode=t,t){case"screen":e.globalCompositeOperation="screen";break;case"lighter":case"additive":e.globalCompositeOperation="lighter";break;case"multiply":e.globalCompositeOperation="multiply";break;default:e.globalCompositeOperation="source-over",this.currentBlendMode="normal"}this.settings.doubleBuffering&&this.settings.transparent&&(this.context.globalCompositeOperation="copy")},e.prototype.clear=function(){this.settings.transparent&&this.clearColor("rgba(0,0,0,0)",!0)},e.prototype.flush=function(){this.settings.doubleBuffering&&this.context.drawImage(this.backBufferCanvas,0,0)},e.prototype.clearColor=function(t,e){void 0===t&&(t="#000000"),this.save(),this.resetTransform(),this.backBufferContext2D.globalCompositeOperation=e?"copy":"source-over",this.backBufferContext2D.fillStyle=t instanceof Sn?t.toRGBA():t,this.fillRect(0,0,this.backBufferCanvas.width,this.backBufferCanvas.height),this.restore()},e.prototype.clearRect=function(t,e,i,o){this.getContext().clearRect(t,e,i,o)},e.prototype.createPattern=function(t,e){return this.getContext().createPattern(t,e)},e.prototype.drawImage=function(t,e,i,o,n,r,s,a,h){if(!(this.getGlobalAlpha()<1/255)){var l=this.getContext();void 0===o?(o=a=t.width,n=h=t.height,r=e,s=i,e=0,i=0):void 0===r&&(r=e,s=i,a=o,h=n,o=t.width,n=t.height,e=0,i=0),!1===this.settings.subPixel&&(r=~~r,s=~~s);var u=t,c=this.currentTint.toArray();1===c[0]&&1===c[1]&&1===c[2]||(u=this.cache.tint(t,this.currentTint.toRGB())),l.drawImage(u,e,i,o,n,r,s,a,h)}},e.prototype.drawPattern=function(t,e,i,o,n){if(!(this.getGlobalAlpha()<1/255)){var r=this.getContext(),s=r.fillStyle;r.fillStyle=t,r.fillRect(e,i,o,n),r.fillStyle=s}},e.prototype.strokeArc=function(t,e,i,o,n,r,s){if(void 0===s&&(s=!1),!(this.getGlobalAlpha()<1/255)){var a=this.getContext();a.translate(t,e),a.beginPath(),a.arc(0,0,i,o,n,r||!1),a[!0===s?"fill":"stroke"](),a.translate(-t,-e)}},e.prototype.fillArc=function(t,e,i,o,n,r){this.strokeArc(t,e,i,o,n,r||!1,!0)},e.prototype.strokeEllipse=function(t,e,i,o,n){if(void 0===n&&(n=!1),!(this.getGlobalAlpha()<1/255)){var r=this.getContext(),s=t-i,a=t+i,h=e-o,l=e+o,u=.551784*i,c=.551784*o,p=t-u,d=t+u,f=e-c,y=e+c;r.beginPath(),r.moveTo(t,h),r.bezierCurveTo(d,h,a,f,a,e),r.bezierCurveTo(a,y,d,l,t,l),r.bezierCurveTo(p,l,s,y,s,e),r.bezierCurveTo(s,f,p,h,t,h),r[!0===n?"fill":"stroke"](),r.closePath()}},e.prototype.fillEllipse=function(t,e,i,o){this.strokeEllipse(t,e,i,o,!0)},e.prototype.strokeLine=function(t,e,i,o){if(!(this.getGlobalAlpha()<1/255)){var n=this.getContext();n.beginPath(),n.moveTo(t,e),n.lineTo(i,o),n.stroke()}},e.prototype.fillLine=function(t,e,i,o){this.strokeLine(t,e,i,o)},e.prototype.strokePolygon=function(t,e){if(void 0===e&&(e=!1),!(this.getGlobalAlpha()<1/255)){var i,o=this.getContext();this.translate(t.pos.x,t.pos.y),o.beginPath(),o.moveTo(t.points[0].x,t.points[0].y);for(var n=1;n<t.points.length;n++)i=t.points[n],o.lineTo(i.x,i.y);o.lineTo(t.points[0].x,t.points[0].y),o[!0===e?"fill":"stroke"](),o.closePath(),this.translate(-t.pos.x,-t.pos.y)}},e.prototype.fillPolygon=function(t){this.strokePolygon(t,!0)},e.prototype.strokeRect=function(t,e,i,o,n){(void 0===n&&(n=!1),this.getGlobalAlpha()<1/255)||this.getContext()[!0===n?"fillRect":"strokeRect"](t,e,i,o)},e.prototype.fillRect=function(t,e,i,o){this.strokeRect(t,e,i,o,!0)},e.prototype.strokeRoundRect=function(t,e,i,o,n,r){if(void 0===r&&(r=!1),!(this.getGlobalAlpha()<1/255)){var s=this.getContext();s.beginPath(),s.roundRect(t,e,i,o,n),s[!0===r?"fill":"stroke"]()}},e.prototype.fillRoundRect=function(t,e,i,o,n){this.strokeRoundRect(t,e,i,o,n,!0)},e.prototype.getContext=function(){return this.backBufferContext2D},e.prototype.getFontContext=function(){return this.getContext()},e.prototype.save=function(){this.backBufferContext2D.save()},e.prototype.restore=function(){this.backBufferContext2D.restore(),this.currentColor.glArray[3]=this.getGlobalAlpha(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height},e.prototype.rotate=function(t){this.backBufferContext2D.rotate(t)},e.prototype.scale=function(t,e){this.backBufferContext2D.scale(t,e)},e.prototype.setColor=function(t){this.backBufferContext2D.strokeStyle=this.backBufferContext2D.fillStyle=t instanceof Sn?t.toRGBA():t},e.prototype.setGlobalAlpha=function(t){this.backBufferContext2D.globalAlpha=this.currentColor.glArray[3]=t},e.prototype.getGlobalAlpha=function(){return this.backBufferContext2D.globalAlpha},e.prototype.setLineWidth=function(t){this.backBufferContext2D.lineWidth=t},e.prototype.setTransform=function(t){this.resetTransform(),this.transform(t)},e.prototype.transform=function(t){var e=t.toArray(),i=e[0],o=e[1],n=e[3],r=e[4],s=e[6],a=e[7];!1===this.settings.subPixel&&(s|=0,a|=0),this.backBufferContext2D.transform(i,o,n,r,s,a)},e.prototype.translate=function(t,e){!1===this.settings.subPixel?this.backBufferContext2D.translate(~~t,~~e):this.backBufferContext2D.translate(t,e)},e.prototype.clipRect=function(t,e,i,o){var n=this.backBufferCanvas;if(0!==t||0!==e||i!==n.width||o!==n.height){var r=this.currentScissor;if(r[0]!==t||r[1]!==e||r[2]!==i||r[3]!==o){var s=this.backBufferContext2D;s.beginPath(),s.rect(t,e,i,o),s.clip(),r[0]=t,r[1]=e,r[2]=i,r[3]=o}}},e.prototype.setMask=function(t,e){void 0===e&&(e=!1);var i=this.getContext();if(0===this.maskLevel)i.save(),i.beginPath();else if(t instanceof Jh)i.roundRect(t.top,t.left,t.width,t.height,t.radius);else if(t instanceof Kr||t instanceof ls)i.rect(t.top,t.left,t.width,t.height);else if(t instanceof ua){var o=t.pos.x,n=t.pos.y,r=t.radiusV.x,s=t.radiusV.y,a=o-r,h=o+r,l=n-s,u=n+s,c=.551784*r,p=.551784*s,d=o-c,f=o+c,y=n-p,g=n+p;i.moveTo(o,l),i.bezierCurveTo(f,l,h,y,h,n),i.bezierCurveTo(h,g,f,u,o,u),i.bezierCurveTo(d,u,a,g,a,n),i.bezierCurveTo(a,y,d,l,o,l)}else{var v,m=t.pos.x,_=t.pos.y;i.moveTo(m+t.points[0].x,_+t.points[0].y);for(var x=1;x<t.points.length;x++)v=t.points[x],i.lineTo(m+v.x,_+v.y)}this.maskLevel++,!0===e?(i.closePath(),i.globalCompositeOperation="destination-atop",i.fill()):i.clip()},e.prototype.clearMask=function(){this.maskLevel>0&&(this.maskLevel=0,this.getContext().restore())},e}(tl);function il(t,e){var i=0;!function(t){t.layerData=new Array(t.cols);for(var e=0;e<t.cols;e++){t.layerData[e]=new Array(t.rows);for(var i=0;i<t.rows;i++)t.layerData[e][i]=null}}(t);for(var o=0;o<t.rows;o++)for(var n=0;n<t.cols;n++){var r=e[i++];0!==r&&(t.layerData[n][o]=t.getTileById(r,n,o))}}var ol=function(t){function e(e,i,o,n,r,s,a){t.call(this,0,0,0,0),this.tilewidth=i.tilewidth||o,this.tileheight=i.tileheight||n,this.orientation=r,this.tilesets=s,this.tileset=this.tilesets?this.tilesets.getTilesetByIndex(0):null,this.maxTileSize={width:0,height:0};for(var h=0;h<this.tilesets.length;h++){var l=this.tilesets.getTilesetByIndex(h);this.maxTileSize.width=Math.max(this.maxTileSize.width,l.tilewidth),this.maxTileSize.height=Math.max(this.maxTileSize.height,l.tileheight)}this.animatedTilesets=[],this.isAnimated=!1,this.renderorder=i.renderorder||"right-down",this.pos.z=a,this.anchorPoint.set(0,0),this.name=i.name,this.cols=+i.width,this.rows=+i.height;var u=void 0!==i.visible?+i.visible:1;this.setOpacity(u?+i.opacity:0),"string"==typeof i.tintcolor&&this.tint.parseHex(i.tintcolor,!0),"isometric"===this.orientation?(this.width=(this.cols+this.rows)*(this.tilewidth/2),this.height=(this.cols+this.rows)*(this.tileheight/2)):(this.width=this.cols*this.tilewidth,this.height=this.rows*this.tileheight),Ph(this,i),void 0===this.preRender&&(this.preRender=Ba.preRender),this.setRenderer(e.getRenderer()),il(this,Eh(i.data,i.encoding,i.compression))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onActivateEvent=function(){if(void 0===this.animatedTilesets&&(this.animatedTilesets=[]),this.tilesets)for(var t=this.tilesets.tilesets,e=0;e<t.length;e++)t[e].isAnimated&&this.animatedTilesets.push(t[e]);this.isAnimated=this.animatedTilesets.length>0,this.isAnimated&&(this.preRender=!1),this.getBounds().addBounds(this.getRenderer().getBounds(),!0),this.getBounds().shift(this.pos),!0!==this.preRender||this.canvasRenderer||(this.canvasRenderer=new el({canvas:ku(this.width,this.height),widht:this.width,heigth:this.height,transparent:!0}),function(t,e){for(var i=0;i<t.rows;i++)for(var o=0;o<t.cols;o++){var n=t.layerData[o][i];n instanceof Kh&&t.getRenderer().drawTile(e,o,i,n)}}(this,this.canvasRenderer))},e.prototype.onDeactivateEvent=function(){this.animatedTilesets=void 0},e.prototype.setRenderer=function(t){this.renderer=t},e.prototype.getRenderer=function(){return this.renderer},e.prototype.getTileId=function(t,e){var i=this.getTile(t,e);return i?i.tileId:null},e.prototype.getTile=function(t,e){var i=null;if(this.contains(t,e)){var o=this.getRenderer().pixelToTileCoords(t,e,gn.pull("Vector2d"));i=this.cellAt(o.x,o.y),gn.push(o)}return i},e.prototype.setTile=function(t,e,i){return this.layerData[e][i]=t,t},e.prototype.getTileById=function(t,e,i){return this.tileset.contains(t)||(this.tileset=this.tilesets.getTilesetByGid(t)),new Kh(e,i,t,this.tileset)},e.prototype.cellAt=function(t,e,i){var o=~~t,n=~~e,r=this.getRenderer();return!1===i||o>=0&&o<r.cols&&n>=0&&n<r.rows?this.layerData[o][n]:null},e.prototype.clearTile=function(t,e){this.layerData[t][e]=null,this.preRender&&this.canvasRenderer.clearRect(t*this.tilewidth,e*this.tileheight,this.tilewidth,this.tileheight)},e.prototype.update=function(t){if(this.isAnimated){for(var e=!1,i=0;i<this.animatedTilesets.length;i++)e=this.animatedTilesets[i].update(t)||e;return e}return!1},e.prototype.draw=function(t,e){if(this.preRender){var i=Math.min(e.width,this.width),o=Math.min(e.height,this.height);t.drawImage(this.canvasRenderer.getCanvas(),e.pos.x,e.pos.y,i,o,e.pos.x,e.pos.y,i,o)}else this.getRenderer().drawTileLayer(t,this,e)},e}(la),nl=function(t,e,i,o){this.cols=t,this.rows=e,this.tilewidth=i,this.tileheight=o,this.bounds=new ls};nl.prototype.canRender=function(t){return this.tilewidth===t.tilewidth&&this.tileheight===t.tileheight},nl.prototype.getBounds=function(t){var e=t instanceof ol?gn.pull("Bounds"):this.bounds;return e.setMinMax(0,0,this.cols*this.tilewidth,this.rows*this.tileheight),e},nl.prototype.pixelToTileCoords=function(t,e,i){return i},nl.prototype.tileToPixelCoords=function(t,e,i){return i},nl.prototype.drawTile=function(t,e,i,o){},nl.prototype.drawTileLayer=function(t,e,i){};var rl=function(t){function e(e){t.call(this,e.cols,e.rows,e.tilewidth,e.tileheight)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"orthogonal"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.pixelToTileCoords=function(t,e,i){return(i||new vn).set(t/this.tilewidth,e/this.tileheight)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new vn).set(t*this.tilewidth,e*this.tileheight)},e.prototype.adjustPosition=function(t){"number"==typeof t.gid&&(t.y-=t.height)},e.prototype.drawTile=function(t,e,i,o){var n=o.tileset;n.drawTile(t,n.tileoffset.x+e*this.tilewidth,n.tileoffset.y+(i+1)*this.tileheight-n.tileheight,o)},e.prototype.drawTileLayer=function(t,e,i){var o=1,n=1,r=this.pixelToTileCoords(Math.max(i.pos.x-(e.maxTileSize.width-e.tilewidth),0),Math.max(i.pos.y-(e.maxTileSize.height-e.tileheight),0),gn.pull("Vector2d")).floorSelf(),s=this.pixelToTileCoords(i.pos.x+i.width+this.tilewidth,i.pos.y+i.height+this.tileheight,gn.pull("Vector2d")).ceilSelf();switch(s.x=s.x>this.cols?this.cols:s.x,s.y=s.y>this.rows?this.rows:s.y,e.renderorder){case"right-up":s.y=r.y+(r.y=s.y)-s.y,n=-1;break;case"left-down":s.x=r.x+(r.x=s.x)-s.x,o=-1;break;case"left-up":s.x=r.x+(r.x=s.x)-s.x,s.y=r.y+(r.y=s.y)-s.y,o=-1,n=-1}for(var a=r.y;a!==s.y;a+=n)for(var h=r.x;h!==s.x;h+=o){var l=e.cellAt(h,a,!1);l&&this.drawTile(t,h,a,l)}gn.push(r),gn.push(s)},e}(nl),sl=function(t){function e(e){t.call(this,e.cols,e.rows,e.tilewidth,e.tileheight),this.hTilewidth=this.tilewidth/2,this.hTileheight=this.tileheight/2,this.originX=this.rows*this.hTilewidth}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"isometric"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.getBounds=function(t){var e=t instanceof ol?gn.pull("Bounds"):this.bounds;return e.setMinMax(0,0,(this.cols+this.rows)*(this.tilewidth/2),(this.cols+this.rows)*(this.tileheight/2)),e},e.prototype.pixelToTileCoords=function(t,e,i){return(i||new vn).set(e/this.tileheight+(t-this.originX)/this.tilewidth,e/this.tileheight-(t-this.originX)/this.tilewidth)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new vn).set((t-e)*this.hTilewidth+this.originX,(t+e)*this.hTileheight)},e.prototype.adjustPosition=function(t){var e=t.x/this.hTilewidth,i=t.y/this.tileheight,o=gn.pull("Vector2d");this.tileToPixelCoords(e,i,o),t.x=o.x,t.y=o.y,gn.push(o)},e.prototype.drawTile=function(t,e,i,o){var n=o.tileset;n.drawTile(t,(this.cols-1)*n.tilewidth+(e-i)*n.tilewidth>>1,-n.tilewidth+(e+i)*n.tileheight>>2,o)},e.prototype.drawTileLayer=function(t,e,i){var o=e.tileset,n=this.pixelToTileCoords(i.pos.x-o.tilewidth,i.pos.y-o.tileheight,gn.pull("Vector2d")).floorSelf(),r=this.pixelToTileCoords(i.pos.x+i.width+o.tilewidth,i.pos.y+i.height+o.tileheight,gn.pull("Vector2d")).ceilSelf(),s=this.tileToPixelCoords(r.x,r.y,gn.pull("Vector2d")),a=this.tileToPixelCoords(n.x,n.y,gn.pull("Vector2d"));a.x-=this.hTilewidth,a.y+=this.tileheight;var h=a.y-i.pos.y>this.hTileheight,l=i.pos.x-a.x<this.hTilewidth;h&&(l?(n.x--,a.x-=this.hTilewidth):(n.y--,a.x+=this.hTilewidth),a.y-=this.hTileheight);for(var u=h^l,c=n.clone(),p=2*a.y;p-2*this.tileheight<2*s.y;p+=this.tileheight){c.setV(n);for(var d=a.x;d<s.x;d+=this.tilewidth){var f=e.cellAt(c.x,c.y);if(f){var y=(o=f.tileset).tileoffset;o.drawTile(t,y.x+d,y.y+p/2-o.tileheight,f)}c.x++,c.y--}u?(n.y++,a.x-=this.hTilewidth,u=!1):(n.x++,a.x+=this.hTilewidth,u=!0)}gn.push(c),gn.push(n),gn.push(r),gn.push(s),gn.push(a)},e}(nl),al=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],hl=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}],ll=function(t){function e(e){t.call(this,e.cols,e.rows,-2&e.tilewidth,-2&e.tileheight),this.hexsidelength=e.hexsidelength||0,this.staggerX="x"===e.staggeraxis,this.staggerEven="even"===e.staggerindex,this.sidelengthx=0,this.sidelengthy=0,"hexagonal"===e.orientation&&(this.staggerX?this.sidelengthx=this.hexsidelength:this.sidelengthy=this.hexsidelength),this.sideoffsetx=(this.tilewidth-this.sidelengthx)/2,this.sideoffsety=(this.tileheight-this.sidelengthy)/2,this.columnwidth=this.sideoffsetx+this.sidelengthx,this.rowheight=this.sideoffsety+this.sidelengthy,this.centers=[new vn,new vn,new vn,new vn]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"hexagonal"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.getBounds=function(t){var e=t instanceof ol?gn.pull("Bounds"):this.bounds;return this.staggerX?(e.setMinMax(0,0,this.cols*this.columnwidth+this.sideoffsetx,this.rows*(this.tileheight+this.sidelengthy)),e.width>1&&(e.height+=this.rowheight)):(e.setMinMax(0,0,this.cols*(this.tilewidth+this.sidelengthx),this.rows*this.rowheight+this.sideoffsety),e.height>1&&(e.width+=this.columnwidth)),e},e.prototype.doStaggerX=function(t){return this.staggerX&&1&t^this.staggerEven},e.prototype.doStaggerY=function(t){return!this.staggerX&&1&t^this.staggerEven},e.prototype.topLeft=function(t,e,i){var o=i||new vn;return this.staggerX?1&t^this.staggerEven?o.set(t-1,e):o.set(t-1,e-1):1&e^this.staggerEven?o.set(t,e-1):o.set(t-1,e-1),o},e.prototype.topRight=function(t,e,i){var o=i||new vn;return this.staggerX?1&t^this.staggerEven?o.set(t+1,e):o.set(t+1,e-1):1&e^this.staggerEven?o.set(t+1,e-1):o.set(t,e-1),o},e.prototype.bottomLeft=function(t,e,i){var o=i||new vn;return this.staggerX?1&t^this.staggerEven?o.set(t-1,e+1):o.set(t-1,e):1&e^this.staggerEven?o.set(t,e+1):o.set(t-1,e+1),o},e.prototype.bottomRight=function(t,e,i){var o=i||new vn;return this.staggerX?1&t^this.staggerEven?o.set(t+1,e+1):o.set(t+1,e):1&e^this.staggerEven?o.set(t+1,e+1):o.set(t,e+1),o},e.prototype.pixelToTileCoords=function(t,e,i){var o=i||new vn;this.staggerX?t-=this.staggerEven?this.tilewidth:this.sideoffsetx:e-=this.staggerEven?this.tileheight:this.sideoffsety;var n,r,s,a,h=gn.pull("Vector2d",Math.floor(t/(2*this.columnwidth)),Math.floor(e/(2*this.rowheight))),l=gn.pull("Vector2d",t-h.x*(2*this.columnwidth),e-h.y*(2*this.rowheight));this.staggerX?(h.x=2*h.x,this.staggerEven&&++h.x):(h.y=2*h.y,this.staggerEven&&++h.y),this.staggerX?(s=(n=this.sidelengthx/2)+this.columnwidth,a=this.tileheight/2,this.centers[0].set(n,a),this.centers[1].set(s,a-this.rowheight),this.centers[2].set(s,a+this.rowheight),this.centers[3].set(s+this.columnwidth,a)):(r=this.sidelengthy/2,s=this.tilewidth/2,a=r+this.rowheight,this.centers[0].set(s,r),this.centers[1].set(s-this.columnwidth,a),this.centers[2].set(s+this.columnwidth,a),this.centers[3].set(s,a+this.rowheight));for(var u=0,c=Number.MAX_VALUE,p=0;p<4;++p){var d=this.centers[p].sub(l).length2();d<c&&(c=d,u=p)}var f=this.staggerX?al:hl;return o.set(h.x+f[u].x,h.y+f[u].y),gn.push(h),gn.push(l),o},e.prototype.tileToPixelCoords=function(t,e,i){var o=Math.floor(t),n=Math.floor(e),r=i||new vn;return this.staggerX?(r.y=n*(this.tileheight+this.sidelengthy),this.doStaggerX(o)&&(r.y+=this.rowheight),r.x=o*this.columnwidth):(r.x=o*(this.tilewidth+this.sidelengthx),this.doStaggerY(n)&&(r.x+=this.columnwidth),r.y=n*this.rowheight),r},e.prototype.adjustPosition=function(t){"number"==typeof t.gid&&(t.y-=t.height)},e.prototype.drawTile=function(t,e,i,o){var n=o.tileset,r=this.tileToPixelCoords(e,i,gn.pull("Vector2d"));n.drawTile(t,n.tileoffset.x+r.x,n.tileoffset.y+r.y+(this.tileheight-n.tileheight),o),gn.push(r)},e.prototype.drawTileLayer=function(t,e,i){var o,n=this.pixelToTileCoords(i.pos.x,i.pos.y,gn.pull("Vector2d"));n.sub(e.pos);var r=this.tileToPixelCoords(n.x+e.pos.x,n.y+e.pos.y,gn.pull("Vector2d")),s=n.clone(),a=r.clone(),h=i.pos.y-r.y<this.sideoffsety,l=i.pos.x-r.x<this.sideoffsetx;h&&n.y--,l&&n.x--;var u=e.cols,c=e.rows;if(this.staggerX){n.x=Math.max(0,n.x),n.y=Math.max(0,n.y),r=this.tileToPixelCoords(n.x+e.pos.x,n.y+e.pos.y);for(var p=this.doStaggerX(n.x+e.pos.x);r.y<i.bottom&&n.y<c;){for(s.setV(n),a.setV(r);a.x<i.right&&s.x<u;s.x+=2)(o=e.cellAt(s.x,s.y,!1))&&o.tileset.drawTile(t,a.x,a.y,o),a.x+=this.tilewidth+this.sidelengthx;p?(n.x-=1,n.y+=1,r.x-=this.columnwidth,p=!1):(n.x+=1,r.x+=this.columnwidth,p=!0),r.y+=this.rowheight}gn.push(s),gn.push(a)}else{for(n.x=Math.max(0,n.x),n.y=Math.max(0,n.y),r=this.tileToPixelCoords(n.x+e.pos.x,n.y+e.pos.y),this.doStaggerY(n.y)&&(r.x-=this.columnwidth);r.y<i.bottom&&n.y<c;n.y++){for(s.setV(n),a.setV(r),this.doStaggerY(n.y)&&(a.x+=this.columnwidth);a.x<i.right&&s.x<u;s.x++)(o=e.cellAt(s.x,s.y,!1))&&o.tileset.drawTile(t,a.x,a.y,o),a.x+=this.tilewidth+this.sidelengthx;r.y+=this.rowheight}gn.push(s),gn.push(a)}gn.push(n),gn.push(r)},e}(nl),ul=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.canRender=function(e){return"staggered"===e.orientation&&t.prototype.canRender.call(this,e)},e.prototype.pixelToTileCoords=function(t,e,i){var o=i||new vn,n=t,r=e;this.staggerX?n-=this.staggerEven?this.sideoffsetx:0:r-=this.staggerEven?this.sideoffsety:0;var s=gn.pull("Vector2d",Math.floor(n/this.tilewidth),Math.floor(r/this.tileheight));this.staggerX?(s.x=2*s.x,this.staggerEven&&++s.x):(s.y=2*s.y,this.staggerEven&&++s.y);var a=gn.pull("Vector2d",n-s.x*this.tilewidth,r-s.y*this.tileheight),h=a.x*(this.tileheight/this.tilewidth);return this.sideoffsety-h>a.y&&(s=this.topLeft(s.x,s.y,s)),-this.sideoffsety+h>a.y&&(s=this.topRight(s.x,s.y,s)),this.sideoffsety+h<a.y&&(s=this.bottomLeft(s.x,s.y,s)),3*this.sideoffsety-h<a.y&&(s=this.bottomRight(s.x,s.y,s)),(o=this.tileToPixelCoords(s.x,s.y,o)).set(t-o.x,e-o.y),o.set(o.x-this.tilewidth/2,o.y*(this.tilewidth/this.tileheight)),o.div(this.tilewidth/Math.sqrt(2)).rotate(Jo(-45)).add(s),gn.push(s),gn.push(a),o},e}(ll),cl=function(t){var e=0;if(this.TileProperties=[],this.imageCollection=[],this.firstgid=this.lastgid=+t.firstgid,void 0!==t.source){var i=t.source,o=un(i);if(("tsx"===o||"json"===o)&&!(t=zl.getTMX(ln(i))))throw new Error(i+" external TSX/JSON tileset not found")}this.name=t.name,this.tilewidth=+t.tilewidth,this.tileheight=+t.tileheight,this.spacing=+t.spacing||0,this.margin=+t.margin||0,this.tileoffset=new vn,this.isAnimated=!1,this.isCollection=!1,this.animations=new Map,this._lastUpdate=0;var n=t.tiles;for(e in n)if(n.hasOwnProperty(e)){if("animation"in n[e]&&(this.isAnimated=!0,this.animations.set(n[+e].animation[0].tileid,{dt:0,idx:0,frames:n[+e].animation,cur:n[+e].animation[0]})),"properties"in n[e])if(Array.isArray(n[e].properties)){var r={};for(var s in n[e].properties)r[n[e].properties[s].name]=n[e].properties[s].value;this.setTileProperty(+n[e].id+this.firstgid,r)}else this.setTileProperty(+e+this.firstgid,n[e].properties);if("image"in n[e]){var a=zl.getImage(n[e].image);if(!a)throw new Error("melonJS: '"+n[e].image+"' file for tile '"+(+e+this.firstgid)+"' not found!");this.imageCollection[+e+this.firstgid]=a}}this.isCollection=this.imageCollection.length>0;var h=t.tileoffset;h&&(this.tileoffset.x=+h.x,this.tileoffset.y=+h.y);var l=t.tileproperties;if(l)for(e in l)l.hasOwnProperty(e)&&this.setTileProperty(+e+this.firstgid,l[e]);if(!1===this.isCollection){if(this.image=zl.getImage(t.image),!this.image)throw new Error("melonJS: '"+t.image+"' file for tileset '"+this.name+"' not found!");this.texture=Ou.cache.get(this.image,{framewidth:this.tilewidth,frameheight:this.tileheight,margin:this.margin,spacing:this.spacing}),this.atlas=this.texture.getAtlas();var u=+t.columns||Math.round(this.image.width/(this.tilewidth+this.spacing)),c=Math.round(this.image.height/(this.tileheight+this.spacing));t.tilecount%u>0&&++c,this.lastgid=this.firstgid+(u*c-1||0),t.tilecount&&this.lastgid-this.firstgid+1!=+t.tilecount&&console.warn("Computed tilecount ("+(this.lastgid-this.firstgid+1)+") does not match expected tilecount ("+t.tilecount+")")}};cl.prototype.getTileImage=function(t){return this.imageCollection[t]},cl.prototype.setTileProperty=function(t,e){this.TileProperties[t]=e},cl.prototype.contains=function(t){return t>=this.firstgid&&t<=this.lastgid},cl.prototype.getViewTileId=function(t){var e=t-this.firstgid;return this.animations.has(e)?this.animations.get(e).cur.tileid:e},cl.prototype.getTileProperties=function(t){return this.TileProperties[t]},cl.prototype.update=function(t){var e=0,i=ju.getTime(),o=!1;return this._lastUpdate!==i&&(this._lastUpdate=i,this.animations.forEach((function(i){for(i.dt+=t,e=i.cur.duration;i.dt>=e;)i.dt-=e,i.idx=(i.idx+1)%i.frames.length,i.cur=i.frames[i.idx],e=i.cur.duration,o=!0}))),o},cl.prototype.drawTile=function(t,e,i,o){if(o.flipped&&(t.save(),t.translate(e,i),t.transform(o.currentTransform),e=i=0),!0===this.isCollection)t.drawImage(this.imageCollection[o.tileId],0,0,o.width,o.height,e,i,o.width,o.height);else{var n=this.atlas[this.getViewTileId(o.tileId)].offset;t.drawImage(this.image,n.x,n.y,this.tilewidth,this.tileheight,e,i,this.tilewidth+t.uvOffset,this.tileheight+t.uvOffset)}o.flipped&&t.restore()};var pl=function(){this.tilesets=[],this.length=0};pl.prototype.add=function(t){this.tilesets.push(t),this.length++},pl.prototype.getTilesetByIndex=function(t){return this.tilesets[t]},pl.prototype.getTilesetByGid=function(t){var e=-1;t&=536870911;for(var i=0,o=this.tilesets.length;i<o;i++){if(this.tilesets[i].contains(t))return this.tilesets[i];this.tilesets[i].firstgid===this.tilesets[i].lastgid&&t>=this.tilesets[i].firstgid&&(e=i)}if(-1!==e)return this.tilesets[e];throw new Error("no matching tileset found for gid "+t)};var dl=function(t,e,i){this.points=void 0,this.name=e.name,this.x=+e.x,this.y=+e.y,this.z=+i,this.width=+e.width||0,this.height=+e.height||0,this.gid=+e.gid||null,this.tintcolor=e.tintcolor,this.type=e.type,this.type=e.type,this.rotation=Jo(+e.rotation||0),this.id=+e.id||void 0,this.orientation=t.orientation,this.shapes=void 0,this.isEllipse=!1,this.isPolygon=!1,this.isPolyLine=!1,"number"==typeof this.gid?this.setTile(t.tilesets):void 0!==e.ellipse?this.isEllipse=!0:void 0!==e.polygon?(this.points=e.polygon,this.isPolygon=!0):void 0!==e.polyline&&(this.points=e.polyline,this.isPolyLine=!0),void 0!==e.text?(this.text=e.text,this.text.font=e.text.fontfamily||"sans-serif",this.text.size=e.text.pixelsize||16,this.text.fillStyle=e.text.color||"#000000",this.text.textAlign=e.text.halign||"left",this.text.textBaseline=e.text.valign||"top",this.text.width=this.width,this.text.height=this.height,Ph(this.text,e)):(Ph(this,e),this.shapes||(this.shapes=this.parseTMXShapes())),t.isEditor||t.getRenderer().adjustPosition(this)};dl.prototype.setTile=function(t){var e=t.getTilesetByGid(this.gid);!1===e.isCollection&&(this.width=this.framewidth=e.tilewidth,this.height=this.frameheight=e.tileheight),this.tile=new Kh(this.x,this.y,this.gid,e)},dl.prototype.parseTMXShapes=function(){var t=0,e=[];if(!0===this.isEllipse)e.push(gn.pull("Ellipse",this.width/2,this.height/2,this.width,this.height).rotate(this.rotation));else if(!0===this.isPolygon){var i=gn.pull("Polygon",0,0,this.points);if(!1===i.isConvex())throw new Error("collision polygones in Tiled should be defined as Convex");e.push(i.rotate(this.rotation))}else if(!0===this.isPolyLine){var o,n,r=this.points,s=r.length-1;for(t=0;t<s;t++)o=gn.pull("Vector2d",r[t].x,r[t].y),n=gn.pull("Vector2d",r[t+1].x,r[t+1].y),0!==this.rotation&&(o=o.rotate(this.rotation),n=n.rotate(this.rotation)),e.push(gn.pull("Line",0,0,[o,n]))}else e.push(gn.pull("Polygon",0,0,[gn.pull("Vector2d"),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height),gn.pull("Vector2d",0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(t=0;t<e.length;t++)e[t].toIso();return e},dl.prototype.getObjectPropertyByName=function(t){return this[t]};var fl=function(t,e,i){var o=this;this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.tintcolor=e.tintcolor,this.z=i,this.objects=[];var n=void 0===e.visible||e.visible;this.opacity=!0===n?$o(+e.opacity||1,0,1):0,Ph(this,e),e.objects&&e.objects.forEach((function(e){e.tintcolor=o.tintcolor,o.objects.push(new dl(t,e,i))})),e.layers&&e.layers.forEach((function(e){var n=new ol(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i++);n.setRenderer(t.getRenderer()),o.width=Math.max(o.width,n.width),o.height=Math.max(o.height,n.height),o.objects.push(n)}))};fl.prototype.destroy=function(){this.objects=null},fl.prototype.getObjectCount=function(){return this.objects.length},fl.prototype.getObjectByIndex=function(t){return this.objects[t]};function yl(t,e,i){return new fl(t,e,i)}var gl=function(t,e){if(this.data=e,this.name=t,this.cols=+e.width,this.rows=+e.height,this.tilewidth=+e.tilewidth,this.tileheight=+e.tileheight,this.infinite=+e.infinite,this.orientation=e.orientation,this.renderorder=e.renderorder||"right-down",this.version=e.version,this.tiledversion=e.tiledversion,this.tilesets=null,void 0===this.layers&&(this.layers=[]),void 0===this.objectGroups&&(this.objectGroups=[]),this.isEditor="melon-editor"===e.editor,this.nextobjectid=+e.nextobjectid||void 0,this.hexsidelength=+e.hexsidelength,this.staggeraxis=e.staggeraxis,this.staggerindex=e.staggerindex,this.bounds=this.getRenderer().getBounds().clone(),this.width=this.bounds.width,this.height=this.bounds.height,this.backgroundcolor=e.backgroundcolor,Ph(this,e),this.initialized=!1,1===this.infinite)throw new Error("Tiled Infinite Map not supported!")};gl.prototype.getRenderer=function(){return void 0!==this.renderer&&this.renderer.canRender(this)||(this.renderer=function(t){switch(t.orientation){case"orthogonal":return new rl(t);case"isometric":return new sl(t);case"hexagonal":return new ll(t);case"staggered":return new ul(t);default:throw new Error(t.orientation+" type TMX Tile Map not supported!")}}(this)),this.renderer},gl.prototype.getBounds=function(){return this.bounds},gl.prototype.readMapObjects=function(t){var e=this;if(!0!==this.initialized){var i=0;if(this.tilesets||(this.tilesets=new pl),void 0!==t.tilesets)t.tilesets.forEach((function(t){e.tilesets.add(function(t){return new cl(t)}(t))}));this.background_image&&this.layers.push(gn.pull("ImageLayer",0,0,{name:"background_image",image:this.background_image,z:i++})),t.layers.forEach((function(t){switch(t.type){case"imagelayer":e.layers.push(function(t,e,i){Ph(e.properties,e);var o=gn.pull("ImageLayer",+e.offsetx||+e.x||0,+e.offsety||+e.y||0,Object.assign({name:e.name,image:e.image,ratio:gn.pull("Vector2d",+e.parallaxx||1,+e.parallaxy||1),tint:void 0!==e.tintcolor?gn.pull("Color").parseHex(e.tintcolor,!0):void 0,z:i},e.properties)),n=void 0===e.visible||e.visible;return o.setOpacity(n?+e.opacity:0),o}(0,t,i++));break;case"tilelayer":e.layers.push(function(t,e,i){return new ol(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i)}(e,t,i++));break;case"objectgroup":case"group":e.objectGroups.push(yl(e,t,i++))}})),this.initialized=!0}},gl.prototype.addTo=function(t,e,i){var o=t.autoSort,n=t.autoDepth,r=this.getBounds();function s(e,i){Ra.setBounds(0,0,Math.max(r.width,e),Math.max(r.height,i)),t.pos.set(Math.max(0,~~((e-r.width)/2)),Math.max(0,~~((i-r.height)/2)),t.pos.z)}t.autoSort=!1,t.autoDepth=!1,this.backgroundcolor&&t.backgroundColor.parseCSS(this.backgroundcolor),this.getLayers().forEach((function(e){t.addChild(e)})),this.getObjects(e).forEach((function(e){t.addChild(e)})),t.resize(this.bounds.width,this.bounds.height),t.sort(!0),!0===i&&(gr(ar,s),s(Ra.width,Ra.height),fr(ar,s,this)),t.autoSort=o,t.autoDepth=n},gl.prototype.getObjects=function(t){var e,i=[],o=!1;this.readMapObjects(this.data);for(var n=0;n<this.objectGroups.length;n++){var r=this.objectGroups[n];o=r.name.toLowerCase().includes("collision"),!1===t&&((e=new Ma(0,0,this.width,this.height)).anchorPoint.set(0,0),e.name=r.name,e.pos.z=r.z,e.setOpacity(r.opacity),e.autoSort=!1,e.autoDepth=!1);for(var s=0;s<r.objects.length;s++){var a,h,l=r.objects[s];void 0===l.anchorPoint&&(l.anchorPoint={x:0,y:0}),void 0!==l.tintcolor&&(l.tint=gn.pull("Color"),l.tint.parseHex(l.tintcolor,!0)),l instanceof ol?a=l:"object"==typeof l.text?(void 0===l.text.anchorPoint&&(l.text.anchorPoint=l.anchorPoint),(a=!0===l.text.bitmap?gn.pull("BitmapText",l.x,l.y,l.text):gn.pull("Text",l.x,l.y,l.text)).pos.z=l.z):"object"==typeof l.tile?(void 0===(h=l.shapes)&&(h=gn.pull("Polygon",0,0,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height)])),(a=l.tile.getRenderable(l)).body=new Sa(a,h),a.body.setStatic(!0),a.pos.setMuted(l.x,l.y,l.z)):(void 0!==l.name&&""!==l.name?a=gn.pull(l.name,l.x,l.y,l):(a=gn.pull("Renderable",l.x,l.y,l.width,l.height),void 0===(h=l.shapes)&&(h=gn.pull("Polygon",0,0,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height)])),a.anchorPoint.set(0,0),a.name=l.name,a.type=l.type,a.id=l.id,a.body=new Sa(a,h),a.body.setStatic(!0),a.resize(a.body.getBounds().width,a.body.getBounds().height)),a.pos.z=l.z),o&&!l.name&&a.body&&(a.body.collisionType=Aa.types.WORLD_SHAPE,a.body.isStatic=!0),!1!==t?(!0===a.isRenderable&&(a.setOpacity(a.getOpacity()*r.opacity),a.renderable instanceof la&&a.renderable.setOpacity(a.renderable.getOpacity()*r.opacity)),i.push(a)):e.addChild(a)}!1===t&&e.children.length>0&&(e.autoSort=!0,e.autoDepth=!0,i.push(e))}return i},gl.prototype.getLayers=function(){return this.readMapObjects(this.data),this.layers},gl.prototype.destroy=function(){this.tilesets=void 0,this.layers.length=0,this.objectGroups.length=0,this.initialized=!1};var vl={},ml=[],_l=0;function xl(t,e,i){e.container.reset(),Ka(),vl[bl.getCurrentLevelId()]&&vl[bl.getCurrentLevelId()].destroy(),_l=ml.indexOf(t),function(t,e,i,o){var n=vl[t];zu.resetGUID(t,n.nextobjectid),e.anchorPoint.set(0,0),n.addTo(e,i,o)}(t,e.container,e.flatten,e.setViewportBounds),dr(Yn,t),e.onLoaded(t),i&&Ah.restart()}var bl={add:function(t,e,i){if("tmx"===t)return null==vl[e]&&(vl[e]=new gl(e,zl.getTMX(e)),ml.push(e),i&&i(),!0);throw new Error("no level loader defined for format "+t)},load:function(t,e){if(e=Object.assign({container:Ba,onLoaded:Za,flatten:true,setViewportBounds:!0},e||{}),void 0===vl[t])throw new Error("level "+t+" not found");if(!(vl[t]instanceof gl))throw new Error("no level loader defined");return Ah.isRunning()?(Ah.stop(),zu.function.defer(xl,this,t,e,!0)):xl(t,e),!0},getCurrentLevelId:function(){return ml[_l]},getCurrentLevel:function(){return vl[this.getCurrentLevelId()]},reload:function(t){return this.load(this.getCurrentLevelId(),t)},next:function(t){return _l+1<ml.length&&this.load(ml[_l+1],t)},previous:function(t){return _l-1>=0&&this.load(ml[_l-1],t)},levelCount:function(){return ml.length}},wl={},Tl={},Al={},Sl={},El={},Cl=0,Ml=0,Pl=0;function Ol(t){if(Ml===Cl){if(!t&&!zl.onload)throw new Error("no load callback defined");clearTimeout(Pl);var e=t||zl.onload;setTimeout((function(){e(),dr(qn)}),300)}else Pl=setTimeout((function(){Ol(t)}),100)}function kl(t,e,i){wl[t.name]=new Image,wl[t.name].onload=e,wl[t.name].onerror=i,"string"==typeof zl.crossOrigin&&(wl[t.name].crossOrigin=zl.crossOrigin),wl[t.name].src=t.src+zl.nocache}function Il(t,e,i){var o=new FontFace(t.name,t.src);o.load().then((function(){document.fonts.add(o),document.body.style.fontFamily=t.name,e()}),(function(){i(t.name)}))}function Rl(t,e,i){function o(e){Tl[t.name]=e,"tmx"===t.type&&bl.add(t.type,t.name)}if(t.data)return o(t.data),void e();var n=new XMLHttpRequest,r=un(t.src);n.overrideMimeType&&("json"===r?n.overrideMimeType("application/json"):n.overrideMimeType("text/xml")),n.open("GET",t.src+zl.nocache,!0),n.withCredentials=zl.withCredentials,n.ontimeout=i,n.onreadystatechange=function(){if(4===n.readyState)if(200===n.status||0===n.status&&n.responseText){var s=null;switch(r){case"xml":case"tmx":case"tsx":if(du.ua.match(/msie/i)||!n.responseXML){if(!globalThis.DOMParser)throw new Error("XML file format loading not supported, use the JSON file format instead");s=(new DOMParser).parseFromString(n.responseText,"text/xml")}else s=n.responseXML;var a=Mh(s);switch(r){case"tmx":s=a.map;break;case"tsx":s=a.tilesets[0]}break;case"json":s=JSON.parse(n.responseText);break;default:throw new Error("TMX file format "+r+"not supported !")}o(s),e()}else i(t.name)},n.send()}function Bl(t,e,i){var o=new XMLHttpRequest;o.overrideMimeType&&o.overrideMimeType("application/json"),o.open("GET",t.src+zl.nocache,!0),o.withCredentials=zl.withCredentials,o.ontimeout=i,o.onreadystatechange=function(){4===o.readyState&&(200===o.status||0===o.status&&o.responseText?(Sl[t.name]=JSON.parse(o.responseText),e()):i(t.name))},o.send()}function Dl(t,e,i){var o=new XMLHttpRequest;o.open("GET",t.src+zl.nocache,!0),o.withCredentials=zl.withCredentials,o.responseType="arraybuffer",o.onerror=i,o.onload=function(){var i=o.response;if(i){for(var n=new Uint8Array(i),r=[],s=0;s<n.byteLength;s++)r[s]=String.fromCharCode(n[s]);Al[t.name]=r.join(""),e()}},o.send()}function Ll(t,e,i){var o=document.createElement("script");o.src=t.src,o.type="text/javascript","string"==typeof zl.crossOrigin&&(o.crossOrigin=zl.crossOrigin),o.defer=!0,o.onload=function(){e()},o.onerror=function(){i(t.name)},document.getElementsByTagName("body")[0].appendChild(o)}var zl={nocache:"",onload:void 0,onProgress:void 0,crossOrigin:void 0,withCredentials:!1,onResourceLoaded:function(t){var e=++Ml/Cl;this.onProgress&&this.onProgress(e,t),dr(Zn,e,t)},onLoadingError:function(t){throw new Error("Failed loading resource "+t.src)},setNocache:function(t){this.nocache=t?"?"+~~(1e7*Math.random()):""},setBaseURL:function(t,e){"*"!==t?El[t]=e:(El.audio=e,El.binary=e,El.image=e,El.json=e,El.js=e,El.tmx=e,El.tsx=e)},preload:function(t,e,i){void 0===i&&(i=!0);for(var o=0;o<t.length;o++)Cl+=this.load(t[o],this.onResourceLoaded.bind(this,t[o]),this.onLoadingError.bind(this,t[o]));void 0!==e&&(this.onload=e),!0===i&&Ah.change(Ah.LOADING),Ol(e)},load:function(t,e,i){switch(void 0!==El[t.type]&&(t.src=El[t.type]+t.src),t.type){case"binary":return Dl.call(this,t,e,i),1;case"image":return kl.call(this,t,e,i),1;case"json":return Bl.call(this,t,e,i),1;case"js":return Ll.call(this,t,e,i),1;case"tmx":case"tsx":return Rl.call(this,t,e,i),1;case"audio":return Xl(t,!!t.stream,e,i),1;case"fontface":return Il.call(this,t,e,i),1;default:throw new Error("load : unknown or invalid resource type : "+t.type)}},unload:function(t){switch(t.type){case"binary":return t.name in Al&&(delete Al[t.name],!0);case"image":return t.name in wl&&(delete wl[t.name],!0);case"json":return t.name in Sl&&(delete Sl[t.name],!0);case"js":case"fontface":return!0;case"tmx":case"tsx":return t.name in Tl&&(delete Tl[t.name],!0);case"audio":return Jl(t.name);default:throw new Error("unload : unknown or invalid resource type : "+t.type)}},unloadAll:function(){var t;for(t in Al)Al.hasOwnProperty(t)&&this.unload({name:t,type:"binary"});for(t in wl)wl.hasOwnProperty(t)&&this.unload({name:t,type:"image"});for(t in Tl)Tl.hasOwnProperty(t)&&this.unload({name:t,type:"tmx"});for(t in Sl)Sl.hasOwnProperty(t)&&this.unload({name:t,type:"json"});$l()},getTMX:function(t){return(t=""+t)in Tl?Tl[t]:null},getBinary:function(t){return(t=""+t)in Al?Al[t]:null},getImage:function(t){return(t=ln(""+t))in wl?wl[t]:null},getJSON:function(t){return(t=""+t)in Sl?Sl[t]:null}},Fl={},Vl=null,jl=0,Nl=[],Ul=function(t,e){if(jl++>3)throw new Error("melonJS: failed loading "+t);Fl[t].load()};function Gl(){return!mr.Howler.noAudio}function Xl(t,e,i,o){var n=[];if(0===Nl.length)throw new Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");for(var r=0;r<Nl.length;r++)n.push(t.src+t.name+"."+Nl[r]+zl.nocache);return Fl[t.name]=new mr.Howl({src:n,volume:mr.Howler.volume(),html5:!0===e,xhrWithCredentials:zl.withCredentials,onloaderror:function(){Ul.call(this,t.name,o)},onload:function(){jl=0,i&&i()}}),1}function Hl(t,e,i,o){void 0===e&&(e=!1);var n=Fl[t];if(n&&void 0!==n){var r=n.play();return"boolean"==typeof e&&n.loop(e,r),n.volume("number"==typeof o?$o(o,0,1):mr.Howler.volume(),r),"function"==typeof i&&(!0===e?n.on("end",i,r):n.once("end",i,r)),r}throw new Error("audio clip "+t+" does not exist")}function Wl(){null!==Vl&&Fl[Vl].pause()}function Yl(){null!==Vl&&Fl[Vl].play()}function ql(t,e,i){i=void 0===i||!!i;var o=Fl[t];if(!o||void 0===o)throw new Error("audio clip "+t+" does not exist");o.mute(i,e)}function Zl(){mr.Howler.mute(!0)}function Kl(){mr.Howler.mute(!1)}function Jl(t){return t in Fl&&(Fl[t].unload(),delete Fl[t],!0)}function $l(){for(var t in Fl)Fl.hasOwnProperty(t)&&Jl(t)}var Ql=Object.freeze({__proto__:null,stopOnAudioError:!0,init:function(t){return void 0===t&&(t="mp3"),Nl=t.split(","),!mr.Howler.noAudio},hasFormat:function(t){return Gl()&&mr.Howler.codecs(t)},hasAudio:Gl,enable:function(){Kl()},disable:function(){Zl()},load:Xl,play:Hl,fade:function(t,e,i,o,n){var r=Fl[t];if(!r||void 0===r)throw new Error("audio clip "+t+" does not exist");r.fade(e,i,o,n)},seek:function(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];var o=Fl[t];if(o&&void 0!==o)return o.seek.apply(o,e);throw new Error("audio clip "+t+" does not exist")},rate:function(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];var o=Fl[t];if(o&&void 0!==o)return o.rate.apply(o,e);throw new Error("audio clip "+t+" does not exist")},stop:function(t,e){if(void 0!==t){var i=Fl[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.stop(e),i.off("end",void 0,e)}else mr.Howler.stop()},pause:function(t,e){var i=Fl[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.pause(e)},resume:function(t,e){var i=Fl[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.play(e)},playTrack:function(t,e){return Hl(Vl=t,!0,null,e)},stopTrack:function(){null!==Vl&&(Fl[Vl].stop(),Vl=null)},pauseTrack:Wl,resumeTrack:Yl,getCurrentTrack:function(){return Vl},setVolume:function(t){mr.Howler.volume(t)},getVolume:function(){return mr.Howler.volume()},mute:ql,unmute:function(t,e){ql(t,e,!1)},muteAll:Zl,unmuteAll:Kl,muted:function(){return mr.Howler._muted},unload:Jl,unloadAll:$l}),tu={};function eu(t){return"add"===t||"remove"===t}fr(Rn,(function(){if(void 0!==globalThis.localStorage){var t=globalThis.localStorage.getItem("me.save");if("string"==typeof t&&t.length>0)(JSON.parse(t)||[]).forEach((function(t){tu[t]=JSON.parse(globalThis.localStorage.getItem("me.save."+t))}))}}));var iu={add:function(t){var e=iu;Object.keys(t).forEach((function(i){var o;eu(i)||(o=i,Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:function(){return tu[o]},set:function(t){tu[o]=t,!0===du.localStorage&&globalThis.localStorage.setItem("me.save."+o,JSON.stringify(t))}}),i in tu||(e[i]=t[i]))})),!0===du.localStorage&&globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(tu)))},remove:function(t){eu(t)||void 0!==tu[t]&&(delete tu[t],!0===du.localStorage&&(globalThis.localStorage.removeItem("me.save."+t),globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(tu)))))}},ou=!1,nu=!1,ru=!0;function su(t){return t.preventDefault(),"function"==typeof globalThis.scroll&&globalThis.scroll(0,0),!1}var au=!1,hu=!1,lu=[];function uu(){if(!hu){if(void 0!==globalThis.document&&!globalThis.document.body)return setTimeout(uu,13);for(void 0!==globalThis.document&&"function"==typeof globalThis.document.removeEventListener&&globalThis.document.removeEventListener("DOMContentLoaded",this._domReady,!1),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("load",uu,!1);lu.length;)lu.shift().call(globalThis,[]);hu=!0}}var cu={left:0,top:0,x:0,y:0,width:0,height:0,right:0,bottom:0};function pu(){du.iOS=/iPhone|iPad|iPod/i.test(du.ua),du.android=/Android/i.test(du.ua),du.android2=/Android 2/i.test(du.ua),du.linux=/Linux/i.test(du.ua),du.chromeOS=/CrOS/.test(du.ua),du.wp=/Windows Phone/i.test(du.ua),du.BlackBerry=/BlackBerry/i.test(du.ua),du.Kindle=/Kindle|Silk.*Mobile Safari/i.test(du.ua),du.isMobile=/Mobi/i.test(du.ua)||du.iOS||du.android||du.wp||du.BlackBerry||du.Kindle||!1,du.ejecta=void 0!==globalThis.ejecta,du.isWeixin=/MicroMessenger/i.test(du.ua),du.TouchEvent=!!("ontouchstart"in globalThis),du.PointerEvent=!!globalThis.PointerEvent,globalThis.gesture=No("gesture"),du.touch=du.TouchEvent||du.PointerEvent,du.maxTouchPoints=du.touch?du.PointerEvent?globalThis.navigator.maxTouchPoints||1:10:1,du.wheel=void 0!==globalThis.document&&"onwheel"in globalThis.document.createElement("div"),du.hasPointerLockSupport=void 0!==globalThis.document&&void 0!==globalThis.document.pointerLockElement,du.hasDeviceOrientation=!!globalThis.DeviceOrientationEvent,du.hasAccelerometer=!!globalThis.DeviceMotionEvent,du.ScreenOrientation="undefined"!=typeof screen&&void 0!==screen.orientation,du.hasFullscreenSupport=void 0!==globalThis.document&&(No("fullscreenEnabled",globalThis.document)||globalThis.document.mozFullScreenEnabled),!0===du.hasFullscreenSupport&&(globalThis.document.exitFullscreen=void 0!==globalThis.document&&(No("cancelFullScreen",globalThis.document)||No("exitFullscreen",globalThis.document))),du.hasWebAudio=!(!globalThis.AudioContext&&!globalThis.webkitAudioContext);try{du.localStorage=!!globalThis.localStorage}catch(t){du.localStorage=!1}try{du.OffscreenCanvas=void 0!==globalThis.OffscreenCanvas&&null!==new OffscreenCanvas(0,0).getContext("2d")}catch(t){du.OffscreenCanvas=!1}var t,e;("function"==typeof globalThis.addEventListener&&(globalThis.addEventListener("blur",(function(){du.stopOnBlur&&Ah.stop(!0),du.pauseOnBlur&&Ah.pause(!0)}),!1),globalThis.addEventListener("focus",(function(){du.stopOnBlur&&Ah.restart(!0),du.resumeOnFocus&&Ah.resume(!0),du.autoFocus&&du.focus()}),!1)),void 0!==globalThis.document)&&(void 0!==globalThis.document.hidden?(t="hidden",e="visibilitychange"):void 0!==globalThis.document.mozHidden?(t="mozHidden",e="mozvisibilitychange"):void 0!==globalThis.document.msHidden?(t="msHidden",e="msvisibilitychange"):void 0!==globalThis.document.webkitHidden&&(t="webkitHidden",e="webkitvisibilitychange"),"string"==typeof e&&globalThis.document.addEventListener(e,(function(){globalThis.document[t]?(du.stopOnBlur&&Ah.stop(!0),du.pauseOnBlur&&Ah.pause(!0)):(du.stopOnBlur&&Ah.restart(!0),du.resumeOnFocus&&Ah.resume(!0))}),!1));du.isMobile&&du.enableSwipe(!1)}fr(Rn,(function(){pu()}));var du={ua:void 0!==globalThis.navigator?globalThis.navigator.userAgent:"",localStorage:!1,hasAccelerometer:!1,hasDeviceOrientation:!1,ScreenOrientation:!1,hasFullscreenSupport:!1,hasPointerLockSupport:!1,hasWebAudio:!1,nativeBase64:"function"==typeof globalThis.atob,maxTouchPoints:1,touch:!1,wheel:!1,isMobile:!1,iOS:!1,android:!1,android2:!1,linux:!1,ejecta:!1,isWeixin:!1,nodeJS:"undefined"!=typeof process&&"node"===process.release.name,chromeOS:!1,wp:!1,BlackBerry:!1,Kindle:!1,accelerationX:0,accelerationY:0,accelerationZ:0,gamma:0,beta:0,alpha:0,language:void 0!==globalThis.navigator&&(globalThis.navigator.language||globalThis.navigator.browserLanguage||globalThis.navigator.userLanguage)||"en",pauseOnBlur:!0,resumeOnFocus:!0,autoFocus:!0,stopOnBlur:!1,OffscreenCanvas:!1,onReady:function(t){hu?t.call(globalThis,[]):(lu.push(t),au||(!0===du.nodeJS||void 0!==globalThis.document&&"complete"===globalThis.document.readyState?globalThis.setTimeout(uu,0):(void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("DOMContentLoaded",uu,!1),globalThis.addEventListener("load",uu,!1)),au=!0))},enableSwipe:function(t){var e=du.PointerEvent?"pointermove":du.TouchEvent?"touchmove":"mousemove";!1!==t?!1===ru&&(globalThis.document.removeEventListener(e,su),ru=!0):!0===ru&&(globalThis.document.addEventListener(e,su,{passive:!1}),ru=!1)},requestFullscreen:function(t){this.hasFullscreenSupport&&((t=t||Iu()).requestFullscreen=No("requestFullscreen",t)||t.mozRequestFullScreen,t.requestFullscreen())},exitFullscreen:function(){this.hasFullscreenSupport&&document.exitFullscreen()},getScreenOrientation:function(){var t="portrait",e="landscape",i=globalThis.screen;if(!0===this.ScreenOrientation){var o=No("orientation",i);if(void 0!==o&&"string"==typeof o.type)return o.type;if("string"==typeof o)return o}return"number"==typeof globalThis.orientation?90===Math.abs(globalThis.orientation)?e:t:globalThis.outerWidth>globalThis.outerHeight?e:t},lockOrientation:function(t){var e=globalThis.screen;if(void 0!==e){var i=No("lockOrientation",e);if(void 0!==i)return i(t)}return!1},unlockOrientation:function(){var t=globalThis.screen;if(void 0!==t){var e=No("unlockOrientation",t);if(void 0!==e)return e()}return!1},isPortrait:function(){return this.getScreenOrientation().includes("portrait")},isLandscape:function(){return this.getScreenOrientation().includes("landscape")},getStorage:function(t){if(void 0===t&&(t="local"),"local"===t)return iu;throw new Error("storage type "+t+" not supported")},getParentElement:function(t){var e=this.getElement(t);return null!==e.parentNode&&(e=e.parentNode),e},getElement:function(t){var e=null;return"undefined"!==t&&("string"==typeof t?e=document.getElementById(t):"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE&&(e=t)),e||(e=document.body),e},getElementBounds:function(t){return"object"==typeof t&&t!==document.body&&void 0!==t.getBoundingClientRect?t.getBoundingClientRect():(cu.width=cu.right=globalThis.innerWidth,cu.height=cu.bottom=globalThis.innerHeight,cu)},getParentBounds:function(t){return this.getElementBounds(this.getParentElement(t))},isWebGLSupported:function(t){var e=!1;try{var i=document.createElement("canvas"),o={stencil:!0,failIfMajorPerformanceCaveat:t.failIfMajorPerformanceCaveat};e=!(!globalThis.WebGLRenderingContext||!i.getContext("webgl",o)&&!i.getContext("experimental-webgl",o))}catch(t){e=!1}return e},getMaxShaderPrecision:function(t){return t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0?"highp":t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"},focus:function(){"function"==typeof globalThis.focus&&globalThis.focus()},onDeviceMotion:function(t){this.accelerationX=t.accelerationIncludingGravity.x,this.accelerationY=t.accelerationIncludingGravity.y,this.accelerationZ=t.accelerationIncludingGravity.z},onDeviceRotate:function(t){this.gamma=t.gamma,this.beta=t.beta,this.alpha=t.alpha},watchAccelerometer:function(){var t=this;return this.hasAccelerometer&&!ou&&(DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&(globalThis.addEventListener("devicemotion",t.onDeviceMotion,!1),ou=!0)})).catch(console.error):(globalThis.addEventListener("devicemotion",this.onDeviceMotion,!1),ou=!0)),ou},unwatchAccelerometer:function(){ou&&(globalThis.removeEventListener("devicemotion",this.onDeviceMotion,!1),ou=!1)},watchDeviceOrientation:function(){var t=this;return this.hasDeviceOrientation&&!nu&&("function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&(globalThis.addEventListener("deviceorientation",t.onDeviceRotate,!1),nu=!0)})).catch(console.error):(globalThis.addEventListener("deviceorientation",this.onDeviceRotate,!1),nu=!0)),nu},unwatchDeviceOrientation:function(){nu&&(globalThis.removeEventListener("deviceorientation",this.onDeviceRotate,!1),nu=!1)},vibrate:function(t){void 0!==globalThis.navigator&&"function"==typeof globalThis.navigator.vibrate&&globalThis.navigator.vibrate(t)}};Object.defineProperty(du,"devicePixelRatio",{get:function(){return globalThis.devicePixelRatio||1}}),Object.defineProperty(du,"isFullscreen",{get:function(){return!!this.hasFullscreenSupport&&!(!No("fullscreenElement",document)&&!document.mozFullScreenElement)}}),Object.defineProperty(du,"sound",{get:function(){return Gl()}});var fu={bool:"1i",int:"1i",float:"1f",vec2:"2fv",vec3:"3fv",vec4:"4fv",bvec2:"2iv",bvec3:"3iv",bvec4:"4iv",ivec2:"2iv",ivec3:"3iv",ivec4:"4iv",mat2:"Matrix2fv",mat3:"Matrix3fv",mat4:"Matrix4fv",sampler2D:"1i"};function yu(t,e,i){var o=t.createShader(e);if(t.shaderSource(o,i),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Error(t.getShaderInfoLog(o));return o}function gu(t,e){return"precision"!==t.substring(0,9)?"precision "+e+" float;"+t:t}function vu(t){return t=(t=(t=(t=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1")).replace(/(\\n\s+)|(\s+\\n)/g,"")).replace(/(\\r|\\n)+/g,"")).replace(/\s*([;,[\](){}\\\/\-+*|^&!=<>?~%])\s*/g,"$1")}var mu=function(t,e,i,o){this.gl=t,this.vertex=gu(vu(e),o||du.getMaxShaderPrecision(this.gl)),this.fragment=gu(vu(i),o||du.getMaxShaderPrecision(this.gl)),this.attributes=function(t,e){for(var i,o={},n=/attribute\s+\w+\s+(\w+)/g,r=0;i=n.exec(e.vertex);)o[i[1]]=r++;return o}(this.gl,this),this.program=function(t,e,i,o){var n=yu(t,t.VERTEX_SHADER,e),r=yu(t,t.FRAGMENT_SHADER,i),s=t.createProgram();for(var a in t.attachShader(s,n),t.attachShader(s,r),o)t.bindAttribLocation(s,o[a],a);if(t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS)){var h="Error initializing Shader "+this+"\ngl.VALIDATE_STATUS: "+t.getProgramParameter(s,t.VALIDATE_STATUS)+"\ngl.getError()"+t.getError()+"\ngl.getProgramInfoLog()"+t.getProgramInfoLog(s);throw t.deleteProgram(s),s=null,new Error(h)}return t.useProgram(s),t.deleteShader(n),t.deleteShader(r),s}(this.gl,this.vertex,this.fragment,this.attributes),this.uniforms=function(t,e){var i,o={},n=/uniform\s+(\w+)\s+(\w+)/g,r={},s={},a={};return[e.vertex,e.fragment].forEach((function(t){for(;i=n.exec(t);)r[i[2]]=i[1]})),Object.keys(r).forEach((function(i){var o=r[i];a[i]=t.getUniformLocation(e.program,i),s[i]={get:function(t){return function(){return a[t]}}(i),set:function(e,i,o){return 0===i.indexOf("mat")?function(i){t[o](a[e],!1,i)}:function(i){var n=o;i.length&&"v"!==o.slice(-1)&&(n+="v"),t[n](a[e],i)}}(i,o,"uniform"+fu[o])}})),Object.defineProperties(o,s),o}(this.gl,this),fr(cr,this.destroy,this)};mu.prototype.bind=function(){this.gl.useProgram(this.program)},mu.prototype.getAttribLocation=function(t){var e=this.attributes[t];return void 0!==e?e:-1},mu.prototype.setUniform=function(t,e){var i=this.uniforms;if(void 0===i[t])throw new Error("undefined ("+t+") uniform for shader "+this);"object"==typeof e&&"function"==typeof e.toArray?i[t]=e.toArray():i[t]=e},mu.prototype.setVertexAttributes=function(t,e,i){for(var o=0;o<e.length;++o){var n=e[o],r=this.getAttribLocation(n.name);-1!==r?(t.enableVertexAttribArray(r),t.vertexAttribPointer(r,n.size,n.type,n.normalized,i,n.offset)):t.disableVertexAttribArray(o)}},mu.prototype.destroy=function(){this.uniforms=null,this.attributes=null,this.gl.deleteProgram(this.program),this.vertex=null,this.fragment=null};var _u=function(t,e){this.vertexSize=t,this.quadSize=e,this.maxVertex=256,this.vertexCount=0,this.buffer=new ArrayBuffer(this.maxVertex*this.vertexSize*this.quadSize),this.bufferF32=new Float32Array(this.buffer),this.bufferU32=new Uint32Array(this.buffer)};_u.prototype.clear=function(){this.vertexCount=0},_u.prototype.isFull=function(t){return void 0===t&&(t=this.quadSize),this.vertexCount+t>=this.maxVertex},_u.prototype.resize=function(){this.maxVertex<<=1;var t=this.bufferF32;return this.buffer=new ArrayBuffer(this.maxVertex*this.vertexSize*this.quadSize),this.bufferF32=new Float32Array(this.buffer),this.bufferU32=new Uint32Array(this.buffer),this.bufferF32.set(t),this},_u.prototype.push=function(t,e,i,o,n){var r=this.vertexCount*this.vertexSize;return this.vertexCount>=this.maxVertex&&this.resize(),this.bufferF32[r+0]=t,this.bufferF32[r+1]=e,void 0!==i&&(this.bufferF32[r+2]=i,this.bufferF32[r+3]=o),void 0!==n&&(this.bufferU32[r+4]=n),this.vertexCount++,this},_u.prototype.toFloat32=function(t,e){return void 0!==e?this.bufferF32.subarray(t,e):this.bufferF32},_u.prototype.toUint32=function(t,e){return void 0!==e?this.bufferU32.subarray(t,e):this.bufferU32},_u.prototype.length=function(){return this.vertexCount},_u.prototype.isEmpty=function(){return 0===this.vertexCount};var xu=[new vn,new vn,new vn,new vn],bu=function(t){this.init(t)};bu.prototype.init=function(t){var e=this,i=t.gl;this.currentTextureUnit=-1,this.boundTextures=[],this.renderer=t,this.gl=t.gl,this.color=t.currentColor,this.viewMatrix=t.currentTransform,this.activeShader=null,this.mode=i.TRIANGLES,this.attributes=[],this.vertexByteSize=0,this.vertexSize=0,this.primitiveShader=new mu(this.gl,"// Current vertex point\nattribute vec2 aVertex;\n\n// Projection matrix\nuniform mat4 uProjectionMatrix;\n\n// Vertex color\nuniform vec4 uColor;\n\n// Fragment color\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(uColor.rgb * uColor.a, uColor.a);\n}\n","varying vec4 vColor;\n\nvoid main(void) {\n gl_FragColor = vColor;\n}\n"),this.quadShader=new mu(this.gl,"attribute vec2 aVertex;\nattribute vec2 aRegion;\nattribute vec4 aColor;\n\nuniform mat4 uProjectionMatrix;\n\nvarying vec2 vRegion;\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(aColor.bgr * aColor.a, aColor.a);\n vRegion = aRegion;\n}\n","uniform sampler2D uSampler;\nvarying vec4 vColor;\nvarying vec2 vRegion;\n\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vRegion) * vColor;\n}\n"),this.addAttribute("aVertex",2,i.FLOAT,!1,0*Float32Array.BYTES_PER_ELEMENT),this.addAttribute("aRegion",2,i.FLOAT,!1,2*Float32Array.BYTES_PER_ELEMENT),this.addAttribute("aColor",4,i.UNSIGNED_BYTE,!0,4*Float32Array.BYTES_PER_ELEMENT),this.vertexBuffer=new _u(this.vertexSize,6),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,this.vertexBuffer.buffer,i.STREAM_DRAW),fr(sr,(function(t,i){e.flush(),e.setViewport(0,0,t,i)}))},bu.prototype.reset=function(){this.gl=this.renderer.gl,this.flush(),this.setViewport(0,0,this.renderer.getScreenCanvas().width,this.renderer.getScreenCanvas().height),this.clearColor(0,0,0,0);for(var t=0;t<this.renderer.maxTextures;t++){var e=this.getTexture2D(t);void 0!==e&&this.deleteTexture2D(e)}this.currentTextureUnit=-1,this.useShader(this.quadShader)},bu.prototype.addAttribute=function(t,e,i,o,n){switch(this.attributes.push({name:t,size:e,type:i,normalized:o,offset:n}),i){case this.gl.BYTE:this.vertexByteSize+=e*Int8Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_BYTE:this.vertexByteSize+=e*Uint8Array.BYTES_PER_ELEMENT;break;case this.gl.SHORT:this.vertexByteSize+=e*Int16Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_SHORT:this.vertexByteSize+=e*Uint16Array.BYTES_PER_ELEMENT;break;case this.gl.INT:this.vertexByteSize+=e*Int32Array.BYTES_PER_ELEMENT;break;case this.gl.UNSIGNED_INT:this.vertexByteSize+=e*Uint32Array.BYTES_PER_ELEMENT;break;case this.gl.FLOAT:this.vertexByteSize+=e*Float32Array.BYTES_PER_ELEMENT;break;default:throw new Error("Invalid GL Attribute type")}this.vertexSize=this.vertexByteSize/Float32Array.BYTES_PER_ELEMENT},bu.prototype.setViewport=function(t,e,i,o){this.gl.viewport(t,e,i,o)},bu.prototype.createTexture2D=function(t,e,i,o,n,r,s,a,h){void 0===o&&(o="no-repeat"),void 0===a&&(a=!0),void 0===h&&(h=!0);var l=this.gl,u=Zo(n||e.width)&&Zo(r||e.height),c=l.createTexture(),p=0===o.search(/^repeat(-x)?$/)&&(u||this.renderer.WebGLVersion>1)?l.REPEAT:l.CLAMP_TO_EDGE,d=0===o.search(/^repeat(-y)?$/)&&(u||this.renderer.WebGLVersion>1)?l.REPEAT:l.CLAMP_TO_EDGE;return this.bindTexture2D(c,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,p),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,d),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,i),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a),n||r||s?l.texImage2D(l.TEXTURE_2D,0,l.RGBA,n,r,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,e),u&&!1!==h&&l.generateMipmap(l.TEXTURE_2D),c},bu.prototype.deleteTexture2D=function(t){this.gl.deleteTexture(t),this.unbindTexture2D(t)},bu.prototype.getTexture2D=function(t){return this.boundTextures[t]},bu.prototype.bindTexture2D=function(t,e){var i=this.gl;t!==this.boundTextures[e]?(this.flush(),this.currentTextureUnit!==e&&(this.currentTextureUnit=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,t),this.boundTextures[e]=t):this.currentTextureUnit!==e&&(this.flush(),this.currentTextureUnit=e,i.activeTexture(i.TEXTURE0+e))},bu.prototype.unbindTexture2D=function(t,e){return void 0===e&&(e=this.boundTextures.indexOf(t)),-1!==e&&(delete this.boundTextures[e],e===this.currentTextureUnit&&(this.currentTextureUnit=-1)),e},bu.prototype.uploadTexture=function(t,e,i,o,n){void 0===n&&(n=!1);var r=this.renderer.cache.getUnit(t),s=this.boundTextures[r];return void 0===s||n?this.createTexture2D(r,t.getTexture(),this.renderer.settings.antiAlias?this.gl.LINEAR:this.gl.NEAREST,t.repeat,e,i,o,t.premultipliedAlpha):this.bindTexture2D(s,r),this.currentTextureUnit},bu.prototype.setProjection=function(t){this.activeShader.setUniform("uProjectionMatrix",t)},bu.prototype.useShader=function(t){this.activeShader!==t&&(this.flush(),this.activeShader=t,this.activeShader.bind(),this.activeShader.setUniform("uProjectionMatrix",this.renderer.projectionMatrix),this.activeShader.setVertexAttributes(this.gl,this.attributes,this.vertexByteSize))},bu.prototype.addQuad=function(t,e,i,o,n,r,s,a,h,l){if(!(this.color.alpha<1/255)){this.useShader(this.quadShader),this.vertexBuffer.isFull(6)&&this.flush();var u=this.uploadTexture(t);this.quadShader.setUniform("uSampler",u);var c=this.viewMatrix,p=xu[0].set(e,i),d=xu[1].set(e+o,i),f=xu[2].set(e,i+n),y=xu[3].set(e+o,i+n);c.isIdentity()||(c.apply(p),c.apply(d),c.apply(f),c.apply(y)),this.vertexBuffer.push(p.x,p.y,r,s,l),this.vertexBuffer.push(d.x,d.y,a,s,l),this.vertexBuffer.push(f.x,f.y,r,h,l),this.vertexBuffer.push(f.x,f.y,r,h,l),this.vertexBuffer.push(d.x,d.y,a,s,l),this.vertexBuffer.push(y.x,y.y,a,h,l)}},bu.prototype.flush=function(t){void 0===t&&(t=this.mode);var e=this.vertexBuffer,i=e.vertexCount;if(i>0){var o=this.gl,n=e.vertexSize;this.renderer.WebGLVersion>1?o.bufferData(o.ARRAY_BUFFER,e.toFloat32(),o.STREAM_DRAW,0,i*n):o.bufferData(o.ARRAY_BUFFER,e.toFloat32(0,i*n),o.STREAM_DRAW),o.drawArrays(t,0,i),e.clear()}},bu.prototype.drawVertices=function(t,e,i){void 0===i&&(i=e.length),this.useShader(this.primitiveShader),this.primitiveShader.setUniform("uColor",this.color);for(var o=this.viewMatrix,n=this.vertexBuffer,r=o.isIdentity(),s=0;s<i;s++)r||o.apply(e[s]),n.push(e[s].x,e[s].y);this.flush(t)},bu.prototype.clearColor=function(t,e,i,o){this.gl.clearColor(t,e,i,o)},bu.prototype.clear=function(){this.gl.clear(this.gl.COLOR_BUFFER_BIT)};var wu=function(t){function e(e){var i=this;t.call(this,e),this.WebGLVersion=1,this.GPUVendor=null,this.GPURenderer=null,this.context=this.gl=this.getContextGL(this.getScreenCanvas(),e.transparent),this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this._colorStack=[],this._matrixStack=[],this._scissorStack=[],this._blendStack=[],this.currentTransform=new Pn,this.currentCompositor=null,this.compositors=new Map;var o=new(this.settings.compositor||bu)(this);this.compositors.set("default",o),this.setCompositor(o),this.gl.disable(this.gl.DEPTH_TEST),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.enable(this.gl.BLEND),this.setBlendMode(this.settings.blendMode);var n=this.gl.getExtension("WEBGL_debug_renderer_info");null!==n&&(this.GPUVendor=this.gl.getParameter(n.UNMASKED_VENDOR_WEBGL),this.GPURenderer=this.gl.getParameter(n.UNMASKED_RENDERER_WEBGL)),this.cache=new Hh(this.maxTextures),this.getScreenCanvas().addEventListener("webglcontextlost",(function(t){t.preventDefault(),i.isContextValid=!1,dr(cr,i)}),!1),this.getScreenCanvas().addEventListener("webglcontextrestored",(function(){i.reset(),i.isContextValid=!0,dr(pr,i)}),!1)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(){var e=this;t.prototype.reset.call(this),this.compositors.forEach((function(t){!1===e.isContextValid?t.init(e):t.reset()})),this.gl.disable(this.gl.SCISSOR_TEST),void 0!==this.fontContext2D&&this.createFontTexture(this.cache)},e.prototype.setCompositor=function(t){if(void 0===t&&(t="default"),"string"==typeof t&&(t=this.compositors.get(t)),void 0===t)throw new Error("Invalid WebGL Compositor");this.currentCompositor!==t&&(null!==this.currentCompositor&&this.currentCompositor.flush(),this.currentCompositor=t)},e.prototype.resetTransform=function(){this.currentTransform.identity()},e.prototype.createFontTexture=function(t){if(void 0===this.fontTexture){var e=this.backBufferCanvas,i=e.width,o=e.height;1===this.WebGLVersion&&(Zo(i)||(i=Ko(e.width)),Zo(o)||(o=Ko(e.height)));var n=ku(i,o,!0);this.fontContext2D=this.getContext2d(n),this.fontTexture=new Yh(Wh(e.width,e.height,"fontTexture"),n,t),this.currentCompositor.uploadTexture(this.fontTexture,0,0,0)}else t.set(this.fontContext2D.canvas,this.fontTexture)},e.prototype.createPattern=function(t,e){if(!(1!==Ou.WebGLVersion||Zo(t.width)&&Zo(t.height))){var i=void 0!==t.src?t.src:t;throw new Error("[WebGL Renderer] "+i+" is not a POT texture ("+t.width+"x"+t.height+")")}var o=new Yh(Wh(t.width,t.height,"pattern",e),t);return this.currentCompositor.uploadTexture(o),o},e.prototype.flush=function(){this.currentCompositor.flush()},e.prototype.setProjection=function(e){t.prototype.setProjection.call(this,e),this.currentCompositor.setProjection(e)},e.prototype.clearColor=function(t,e){var i;if(void 0===t&&(t="#000000"),void 0===e&&(e=!1),t instanceof Sn)i=t.toArray();else{var o=gn.pull("me.Color");i=o.parseCSS(t).toArray(),gn.push(o)}this.currentCompositor.clearColor(i[0],i[1],i[2],!0===e?1:i[3]),this.currentCompositor.clear(),this.currentCompositor.clearColor(0,0,0,0)},e.prototype.clearRect=function(t,e,i,o){this.save(),this.clipRect(t,e,i,o),this.clearColor(),this.restore()},e.prototype.drawFont=function(t){var e=this.getFontContext();this.currentCompositor.uploadTexture(this.fontTexture,0,0,0,!0);var i=this.fontTexture.getUVs(t.left+","+t.top+","+t.width+","+t.height);this.currentCompositor.addQuad(this.fontTexture,t.left,t.top,t.width,t.height,i[0],i[1],i[2],i[3],this.currentTint.toUint32()),e.clearRect(t.left,t.top,t.width,t.height)},e.prototype.drawImage=function(t,e,i,o,n,r,s,a,h){void 0===o?(o=a=t.width,n=h=t.height,r=e,s=i,e=0,i=0):void 0===r&&(r=e,s=i,a=o,h=n,o=t.width,n=t.height,e=0,i=0),!1===this.settings.subPixel&&(r|=0,s|=0);var l=this.cache.get(t),u=l.getUVs(e+","+i+","+o+","+n);this.currentCompositor.addQuad(l,r,s,a,h,u[0],u[1],u[2],u[3],this.currentTint.toUint32())},e.prototype.drawPattern=function(t,e,i,o,n){var r=t.getUVs("0,0,"+o+","+n);this.currentCompositor.addQuad(t,e,i,o,n,r[0],r[1],r[2],r[3],this.currentTint.toUint32())},e.prototype.getScreenContext=function(){return this.gl},e.prototype.getContextGL=function(t,e){if(null==t)throw new Error("You must pass a canvas element in order to create a GL context");"boolean"!=typeof e&&(e=!0);var i,o={alpha:e,antialias:this.settings.antiAlias,depth:!1,stencil:!0,preserveDrawingBuffer:!1,premultipliedAlpha:e,powerPreference:this.settings.powerPreference,failIfMajorPerformanceCaveat:this.settings.failIfMajorPerformanceCaveat};if(!1===this.settings.preferWebGL1&&(i=t.getContext("webgl2",o))&&(this.WebGLVersion=2),i||(this.WebGLVersion=1,i=t.getContext("webgl",o)||t.getContext("experimental-webgl",o)),!i)throw new Error("A WebGL context could not be created.");return i},e.prototype.getContext=function(){return this.gl},e.prototype.setBlendMode=function(t,e){if(void 0===t&&(t="normal"),void 0===e&&(e=this.gl),this.currentBlendMode!==t)switch(this.flush(),e.enable(e.BLEND),this.currentBlendMode=t,t){case"screen":e.blendFunc(e.ONE,e.ONE_MINUS_SRC_COLOR);break;case"lighter":case"additive":e.blendFunc(e.ONE,e.ONE);break;case"multiply":e.blendFunc(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA);break;default:e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this.currentBlendMode="normal"}},e.prototype.getFontContext=function(){return void 0===this.fontContext2D&&(console.warn("[WebGL Renderer] WARNING : Using Standard me.Text with WebGL will severly impact performances !"),this.createFontTexture(this.cache)),this.fontContext2D},e.prototype.restore=function(){if(0!==this._matrixStack.length){var t=this._colorStack.pop(),e=this._matrixStack.pop();this.currentColor.copy(t),this.currentTransform.copy(e),this.setBlendMode(this._blendStack.pop()),gn.push(t),gn.push(e)}0!==this._scissorStack.length?this.currentScissor.set(this._scissorStack.pop()):(this.gl.disable(this.gl.SCISSOR_TEST),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.backBufferCanvas.width,this.currentScissor[3]=this.backBufferCanvas.height)},e.prototype.save=function(){this._colorStack.push(this.currentColor.clone()),this._matrixStack.push(this.currentTransform.clone()),this.gl.isEnabled(this.gl.SCISSOR_TEST)&&this._scissorStack.push(this.currentScissor.slice()),this._blendStack.push(this.getBlendMode())},e.prototype.rotate=function(t){this.currentTransform.rotate(t)},e.prototype.scale=function(t,e){this.currentTransform.scale(t,e)},e.prototype.setAntiAlias=function(e,i){t.prototype.setAntiAlias.call(this,e,i)},e.prototype.setGlobalAlpha=function(t){this.currentColor.alpha=t},e.prototype.getGlobalAlpha=function(){return this.currentColor.alpha},e.prototype.setColor=function(t){var e=this.currentColor.alpha;this.currentColor.copy(t),this.currentColor.alpha*=e},e.prototype.setLineWidth=function(t){this.getScreenContext().lineWidth(t)},e.prototype.strokeArc=function(t,e,i,o,n,r,s){void 0===r&&(r=!1),void 0===s&&(s=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.arc(t,e,i,o,n,r),!1===s?this.currentCompositor.drawVertices(this.gl.LINE_STRIP,this.path2D.points):(this.path2D.closePath(),this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath())))},e.prototype.fillArc=function(t,e,i,o,n,r){void 0===r&&(r=!1),this.strokeArc(t,e,i,o,n,r,!0)},e.prototype.strokeEllipse=function(t,e,i,o,n){void 0===n&&(n=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.ellipse(t,e,i,o,0,0,360),this.path2D.closePath(),!1===n?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()))},e.prototype.fillEllipse=function(t,e,i,o){this.strokeEllipse(t,e,i,o,!1)},e.prototype.strokeLine=function(t,e,i,o){this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.moveTo(t,e),this.path2D.lineTo(i,o),this.currentCompositor.drawVertices(this.gl.LINE_STRIP,this.path2D.points))},e.prototype.fillLine=function(t,e,i,o){this.strokeLine(t,e,i,o)},e.prototype.strokePolygon=function(t,e){if(void 0===e&&(e=!1),!(this.getGlobalAlpha()<1/255)){var i;this.translate(t.pos.x,t.pos.y),this.path2D.beginPath(),this.path2D.moveTo(t.points[0].x,t.points[0].y);for(var o=1;o<t.points.length;o++)i=t.points[o],this.path2D.lineTo(i.x,i.y);this.path2D.lineTo(t.points[0].x,t.points[0].y),this.path2D.closePath(),!1===e?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()),this.translate(-t.pos.x,-t.pos.y)}},e.prototype.fillPolygon=function(t){this.strokePolygon(t,!0)},e.prototype.strokeRect=function(t,e,i,o,n){void 0===n&&(n=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.rect(t,e,i,o),!1===n?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath()))},e.prototype.fillRect=function(t,e,i,o){this.strokeRect(t,e,i,o,!0)},e.prototype.strokeRoundRect=function(t,e,i,o,n,r){void 0===r&&(r=!1),this.getGlobalAlpha()<1/255||(this.path2D.beginPath(),this.path2D.roundRect(t,e,i,o,n),!1===r?this.currentCompositor.drawVertices(this.gl.LINE_LOOP,this.path2D.points):(this.path2D.closePath(),this.currentCompositor.drawVertices(this.gl.TRIANGLES,this.path2D.triangulatePath())))},e.prototype.fillRoundRect=function(t,e,i,o,n){this.strokeRoundRect(t,e,i,o,n,!0)},e.prototype.setTransform=function(t){this.resetTransform(),this.transform(t)},e.prototype.transform=function(t){var e=this.currentTransform;if(e.multiply(t),!1===this.settings.subPixel){var i=e.toArray();i[6]|=0,i[7]|=0}},e.prototype.translate=function(t,e){var i=this.currentTransform;if(i.translate(t,e),!1===this.settings.subPixel){var o=i.toArray();o[6]|=0,o[7]|=0}},e.prototype.clipRect=function(t,e,i,o){var n=this.backBufferCanvas,r=this.gl;if(0!==t||0!==e||i!==n.width||o!==n.height){var s=this.currentScissor;if(r.isEnabled(r.SCISSOR_TEST)&&s[0]===t&&s[1]===e&&s[2]===i&&s[3]===o)return;this.flush(),r.enable(this.gl.SCISSOR_TEST),r.scissor(t+this.currentTransform.tx,n.height-o-e-this.currentTransform.ty,i,o),s[0]=t,s[1]=e,s[2]=i,s[3]=o}else r.disable(r.SCISSOR_TEST)},e.prototype.setMask=function(t,e){void 0===e&&(e=!1);var i=this.gl;this.flush(),0===this.maskLevel&&(i.enable(i.STENCIL_TEST),i.clear(i.STENCIL_BUFFER_BIT)),this.maskLevel++,i.colorMask(!1,!1,!1,!1),i.stencilFunc(i.EQUAL,this.maskLevel,1),i.stencilOp(i.REPLACE,i.REPLACE,i.REPLACE),this.fill(t),this.flush(),i.colorMask(!0,!0,!0,!0),!0===e?i.stencilFunc(i.EQUAL,this.maskLevel+1,1):i.stencilFunc(i.NOTEQUAL,this.maskLevel+1,1),i.stencilOp(i.KEEP,i.KEEP,i.KEEP)},e.prototype.clearMask=function(){this.maskLevel>0&&(this.flush(),this.maskLevel=0,this.gl.disable(this.gl.STENCIL_TEST))},e}(tl),Tu=1,Au=0,Su=0,Eu={parent:void 0,renderer:2,doubleBuffering:!1,autoScale:!1,scale:1,scaleMethod:"fit",transparent:!1,blendMode:"normal",antiAlias:!1,failIfMajorPerformanceCaveat:!0,subPixel:!1,preferWebGL1:!1,powerPreference:"default",verbose:!1,consoleHeader:!0};function Cu(){var t=Ou.settings,e=1,i=1;if(t.autoScale){var o=1/0,n=1/0;if(globalThis.getComputedStyle){var r=globalThis.getComputedStyle(Ou.getScreenCanvas(),null);o=parseInt(r.maxWidth,10)||1/0,n=parseInt(r.maxHeight,10)||1/0}var s=du.getParentBounds(Iu()),a=Math.min(o,s.width),h=Math.min(n,s.height),l=a/h;if("fill-min"===t.scaleMethod&&l>Tu||"fill-max"===t.scaleMethod&&l<Tu||"flex-width"===t.scaleMethod){var u=Math.min(o,Su*l);e=i=a/u,Ou.resize(Math.floor(u),Su)}else if("fill-min"===t.scaleMethod&&l<Tu||"fill-max"===t.scaleMethod&&l>Tu||"flex-height"===t.scaleMethod){var c=Math.min(n,Au*(h/a));e=i=h/c,Ou.resize(Au,Math.floor(c))}else"flex"===t.scaleMethod?Ou.resize(Math.floor(a),Math.floor(h)):"stretch"===t.scaleMethod?(e=a/Au,i=h/Su):e=i=l<Tu?a/Au:h/Su;Ru(e,i)}}var Mu=null,Pu=new vn(1,1),Ou=null;function ku(t,e,i){var o;if(void 0===i&&(i=!1),0===t||0===e)throw new Error("width or height was zero, Canvas could not be initialized !");return!0===du.OffscreenCanvas&&!0===i?void 0===(o=new OffscreenCanvas(0,0)).style&&(o.style={}):o=document.createElement("canvas"),o.width=t,o.height=e,o}function Iu(){return Mu}function Ru(t,e){var i=Ou.getScreenCanvas(),o=Ou.getScreenContext(),n=Ou.settings,r=du.devicePixelRatio,s=n.zoomX=i.width*t*r,a=n.zoomY=i.height*e*r;Pu.set(t*r,e*r),i.style.width=s/r+"px",i.style.height=a/r+"px",Ou.setAntiAlias(o,n.antiAlias),Ou.setBlendMode(n.blendMode,o),$a()}var Bu=Object.freeze({__proto__:null,CANVAS:0,WEBGL:1,AUTO:2,get parent(){return Mu},scaleRatio:Pu,get renderer(){return Ou},init:function(e,i,o){if(!t.initialized)throw new Error("me.video.init() called before engine initialization.");(Eu=Object.assign(Eu,o||{})).width=e,Eu.height=i,Eu.doubleBuffering=!!Eu.doubleBuffering,Eu.transparent=!!Eu.transparent,Eu.antiAlias=!!Eu.antiAlias,Eu.failIfMajorPerformanceCaveat=!!Eu.failIfMajorPerformanceCaveat,Eu.subPixel=!!Eu.subPixel,Eu.verbose=!!Eu.verbose,-1!==Eu.scaleMethod.search(/^(fill-(min|max)|fit|flex(-(width|height))?|stretch)$/)?Eu.autoScale="auto"===Eu.scale||!0:(Eu.scaleMethod="fit",Eu.autoScale="auto"===Eu.scale||!1),!1!==Eu.consoleHeader&&console.log("melonJS 2 (v"+Mc+") | http://melonjs.org");var n=zu.getUriFragment();!0!==n.webgl&&!0!==n.webgl1&&!0!==n.webgl2||(Eu.renderer=1,!0===n.webgl1&&(Eu.preferWebGL1=!0)),Eu.scale=Eu.autoScale?1:+Eu.scale||1,Pu.set(Eu.scale,Eu.scale),(Eu.autoScale||1!==Eu.scale)&&(Eu.doubleBuffering=!0),Tu=e/i,Au=e,Su=i,Eu.zoomX=e*Pu.x,Eu.zoomY=i*Pu.y,globalThis.addEventListener("resize",zu.function.throttle((function(t){dr(rr,t)}),100),!1),globalThis.addEventListener("orientationchange",(function(t){dr(hr,t)}),!1),globalThis.addEventListener("onmozorientationchange",(function(t){dr(hr,t)}),!1),!0===du.ScreenOrientation&&(globalThis.screen.orientation.onchange=function(t){dr(hr,t)}),globalThis.addEventListener("scroll",zu.function.throttle((function(t){dr(lr,t)}),100),!1),fr(rr,Cu,this),fr(hr,Cu,this);try{switch(Eu.renderer){case 2:case 1:Ou=function(t){try{if(du.isWebGLSupported(t))return new wu(t)}catch(t){console.log("Error creating WebGL renderer :"+t.message)}return new el(t)}(Eu);break;default:Ou=new el(Eu)}}catch(t){return console(t.message),!1}if((Mu=du.getElement(void 0!==Eu.parent?Eu.parent:document.body)).appendChild(Ou.getScreenCanvas()),Cu(),"MutationObserver"in globalThis&&new MutationObserver(Cu.bind(this)).observe(Mu,{attributes:!1,childList:!0,subtree:!0}),!1!==Eu.consoleHeader){var r=Ou instanceof el?"CANVAS":"WebGL"+Ou.WebGLVersion,s=du.hasWebAudio?"Web Audio":"HTML5 Audio",a="string"==typeof Ou.GPURenderer?" ("+Ou.GPURenderer+")":"";console.log(r+" renderer"+a+" | "+s+" | pixel ratio "+du.devicePixelRatio+" | "+(du.nodeJS?"node.js":du.isMobile?"mobile":"desktop")+" | "+du.getScreenOrientation()+" | "+du.language),console.log("resolution: requested "+e+"x"+i+", got "+Ou.getWidth()+"x"+Ou.getHeight())}return dr(Vn),!0},createCanvas:ku,getParent:Iu,scale:Ru}),Du="",Lu=0,zu={agent:Go,array:sn,file:cn,string:Vo,function:fn,getPixels:function(t){if(t instanceof HTMLImageElement){var e=el.getContext2d(ku(t.width,t.height));return e.drawImage(t,0,0),e.getImageData(0,0,t.width,t.height)}return t.getContext("2d").getImageData(0,0,t.width,t.height)},checkVersion:function(t,e){void 0===e&&(e=Mc);for(var i=t.split("."),o=e.split("."),n=Math.min(i.length,o.length),r=0,s=0;s<n&&!(r=+i[s]-+o[s]);s++);return r||i.length-o.length},getUriFragment:function(t){var e={};if(void 0===t){if(void 0===globalThis.document)return e;var i=globalThis.document.location;if(!i||!i.hash)return e;t=i.hash}else{var o=t.indexOf("#");if(-1===o)return e;t=t.slice(o,t.length)}return t.slice(1).split("&").filter((function(t){return""!==t})).forEach((function(t){var i=t.split("="),o=i.shift(),n=i.join("=");e[o]=n||!0})),e},resetGUID:function(t,e){void 0===e&&(e=0),Du=Fo(t.toString().toUpperCase()),Lu=e},createGUID:function(t){return void 0===t&&(t=1),Lu+=t,Du+"-"+(t||Lu)}},Fu=function(){var t=this;this.tick=1,this.fps=0,this.maxfps=60,this.interpolation=!1,this.framecount=0,this.framedelta=0,this.last=0,this.now=0,this.delta=0,this.step=0,this.minstep=0,this.timers=[],this.timerId=0,fr(Rn,(function(){t.reset(),t.now=t.last=0,fr(Un,t.update.bind(t))})),fr(Dn,(function(){t.reset()})),fr(zn,(function(){t.reset()})),fr(Fn,(function(){t.reset()}))};Fu.prototype.reset=function(){this.last=this.now=globalThis.performance.now(),this.delta=0,this.framedelta=0,this.framecount=0,this.step=Math.ceil(1e3/this.maxfps),this.minstep=1e3/this.maxfps*1.25},Fu.prototype.setTimeout=function(t,e,i){for(var o=[],n=arguments.length-3;n-- >0;)o[n]=arguments[n+3];return this.timers.push({fn:t,delay:e,elapsed:0,repeat:!1,timerId:++this.timerId,pauseable:!0===i||!0,args:o}),this.timerId},Fu.prototype.setInterval=function(t,e,i){for(var o=[],n=arguments.length-3;n-- >0;)o[n]=arguments[n+3];return this.timers.push({fn:t,delay:e,elapsed:0,repeat:!0,timerId:++this.timerId,pauseable:!0===i||!0,args:o}),this.timerId},Fu.prototype.clearTimeout=function(t){zu.function.defer(this.clearTimer.bind(this),this,t)},Fu.prototype.clearInterval=function(t){zu.function.defer(this.clearTimer.bind(this),this,t)},Fu.prototype.getTime=function(){return this.now},Fu.prototype.getDelta=function(){return this.delta},Fu.prototype.countFPS=function(){this.framecount++,this.framedelta+=this.delta,this.framecount%10==0&&(this.fps=$o(Math.round(1e3*this.framecount/this.framedelta),0,this.maxfps),this.framedelta=0,this.framecount=0)},Fu.prototype.update=function(t){this.last=this.now,this.now=t,this.delta=this.now-this.last,this.delta<0&&(this.delta=0),this.tick=this.delta>this.minstep&&this.interpolation?this.delta/this.step:1,this.updateTimers()},Fu.prototype.clearTimer=function(t){for(var e=0,i=this.timers.length;e<i;e++)if(this.timers[e].timerId===t){this.timers.splice(e,1);break}},Fu.prototype.updateTimers=function(){for(var t=0,e=this.timers.length;t<e;t++){var i=this.timers[t];i.pauseable&&Ah.isPaused()||(i.elapsed+=this.delta),i.elapsed>=i.delay&&(i.fn.apply(null,i.args),!0===i.repeat?i.elapsed-=i.delay:this.clearTimeout(i.timerId))}};var Vu,ju=new Fu,Nu=0,Uu=["ms","moz","webkit","o"],Gu=globalThis.requestAnimationFrame,Xu=globalThis.cancelAnimationFrame;for(Vu=0;Vu<Uu.length&&!Gu;++Vu)Gu=globalThis[Uu[Vu]+"RequestAnimationFrame"];for(Vu=0;Vu<Uu.length&&!Xu;++Vu)Xu=globalThis[Uu[Vu]+"CancelAnimationFrame"]||globalThis[Uu[Vu]+"CancelRequestAnimationFrame"];Gu&&Xu||(Gu=function(t){var e=globalThis.performance.now(),i=Math.max(0,1e3/ju.maxfps-(e-Nu)),o=globalThis.setTimeout((function(){t(e+i)}),i);return Nu=e+i,o},Xu=function(t){globalThis.clearTimeout(t)},globalThis.requestAnimationFrame=Gu,globalThis.cancelAnimationFrame=Xu),function(){function t(t,e,i,o,n){if([t,e,i,o].every((function(t){return Number.isFinite(t)}))){var r,s,a,h;if(4===(n=function(t){var e=typeof t;if("undefined"===e||null===t)return[0];if("function"===e)return[NaN];if("object"===e)return"function"==typeof t[Symbol.iterator]?[].concat(t).map((function(t){var e=typeof t;return"undefined"===e||null===t?0:"function"===e?NaN:"object"===e?c(t):p(t)})):[c(t)];return[p(t)]}(n)).length)r=d(n[0]),s=d(n[1]),a=d(n[2]),h=d(n[3]);else if(3===n.length)r=d(n[0]),s=d(n[1]),h=d(n[1]),a=d(n[2]);else if(2===n.length)r=d(n[0]),a=d(n[0]),s=d(n[1]),h=d(n[1]);else{if(1!==n.length)throw new Error(n.length+" is not a valid size for radii sequence.");r=d(n[0]),s=d(n[0]),a=d(n[0]),h=d(n[0])}var l=[r,s,a,h],u=l.find((function(t){var e=t.x,i=t.y;return e<0||i<0}));if(!l.some((function(t){var e=t.x,i=t.y;return!Number.isFinite(e)||!Number.isFinite(i)}))){if(u)throw new Error("Radius value "+u+" is negative.");!function(t){var e=t[0],n=t[1],r=t[2],s=t[3],a=[Math.abs(i)/(e.x+n.x),Math.abs(o)/(n.y+r.y),Math.abs(i)/(r.x+s.x),Math.abs(o)/(e.y+s.y)],h=Math.min.apply(Math,a);h<=1&&t.forEach((function(t){t.x*=h,t.y*=h}))}(l),i<0&&o<0?(this.moveTo(t-r.x,e),this.ellipse(t+i+s.x,e-s.y,s.x,s.y,0,1.5*-Math.PI,-Math.PI),this.ellipse(t+i+a.x,e+o+a.y,a.x,a.y,0,-Math.PI,-Math.PI/2),this.ellipse(t-h.x,e+o+h.y,h.x,h.y,0,-Math.PI/2,0),this.ellipse(t-r.x,e-r.y,r.x,r.y,0,0,-Math.PI/2)):i<0?(this.moveTo(t-r.x,e),this.ellipse(t+i+s.x,e+s.y,s.x,s.y,0,-Math.PI/2,-Math.PI,1),this.ellipse(t+i+a.x,e+o-a.y,a.x,a.y,0,-Math.PI,1.5*-Math.PI,1),this.ellipse(t-h.x,e+o-h.y,h.x,h.y,0,Math.PI/2,0,1),this.ellipse(t-r.x,e+r.y,r.x,r.y,0,0,-Math.PI/2,1)):o<0?(this.moveTo(t+r.x,e),this.ellipse(t+i-s.x,e-s.y,s.x,s.y,0,Math.PI/2,0,1),this.ellipse(t+i-a.x,e+o+a.y,a.x,a.y,0,0,-Math.PI/2,1),this.ellipse(t+h.x,e+o+h.y,h.x,h.y,0,-Math.PI/2,-Math.PI,1),this.ellipse(t+r.x,e-r.y,r.x,r.y,0,-Math.PI,1.5*-Math.PI,1)):(this.moveTo(t+r.x,e),this.ellipse(t+i-s.x,e+s.y,s.x,s.y,0,-Math.PI/2,0),this.ellipse(t+i-a.x,e+o-a.y,a.x,a.y,0,0,Math.PI/2),this.ellipse(t+h.x,e+o-h.y,h.x,h.y,0,Math.PI/2,Math.PI),this.ellipse(t+r.x,e+r.y,r.x,r.y,0,Math.PI,1.5*Math.PI)),this.closePath(),this.moveTo(t,e)}}function c(t){return{x:t.x,y:t.y,z:t.z,w:t.w}}function p(t){return+t}function d(t){var e=p(t);return Number.isFinite(e)?{x:e,y:e}:Object(t)===t?{x:p(t.x||0),y:p(t.y||0)}:{x:NaN,y:NaN}}}globalThis.CanvasRenderingContext2D&&void 0===globalThis.Path2D.prototype.roundRect&&(globalThis.Path2D.prototype.roundRect=t),globalThis.CanvasRenderingContext2D&&void 0===globalThis.CanvasRenderingContext2D.prototype.roundRect&&(globalThis.CanvasRenderingContext2D.prototype.roundRect=t),globalThis.OffscreenCanvasRenderingContext2D&&void 0===globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect&&(globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect=t)}();var Hu={},Wu={Base:function(){this.version="10.12.0"},patch:function(t,e,i){if(void 0!==t.prototype&&(t=t.prototype),"function"!=typeof t[e])throw new Error(e+" is not an existing function");var o=t[e];Object.defineProperty(t,e,{configurable:!0,value:function(t,e){return function(){this._patched=o;var t=e.apply(this,arguments);return this._patched=null,t}}(0,i)})},register:function(t,e){if(Hu[e])throw new Error("plugin "+e+" already registered");var i=[];arguments.length>2&&(i=Array.prototype.slice.call(arguments,1)),i[0]=t;var o=new(t.bind.apply(t,i));if(void 0===o||!(o instanceof Wu.Base))throw new Error("Plugin should extend the me.plugin.Base Class !");if(zu.checkVersion(o.version)>0)throw new Error("Plugin version mismatch, expected: "+o.version+", got: "+Mc);Hu[e]=o}},Yu={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-Yu.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Yu.Bounce.In(2*t):.5*Yu.Bounce.Out(2*t-1)+.5}}},qu={Linear:function(t,e){var i=t.length-1,o=i*e,n=Math.floor(o),r=qu.Utils.Linear;return e<0?r(t[0],t[1],o):e>1?r(t[i],t[i-1],i-o):r(t[n],t[n+1>i?i:n+1],o-n)},Bezier:function(t,e){var i,o=0,n=t.length-1,r=Math.pow,s=qu.Utils.Bernstein;for(i=0;i<=n;i++)o+=r(1-e,n-i)*r(e,i)*t[i]*s(n,i);return o},CatmullRom:function(t,e){var i=t.length-1,o=i*e,n=Math.floor(o),r=qu.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(n=Math.floor(o=i*(1+e))),r(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],o-n)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-o)-t[0]):e>1?t[i]-(r(t[i],t[i],t[i-1],t[i-1],o-i)-t[i]):r(t[n?n-1:0],t[n],t[i<n+1?i:n+1],t[i<n+2?i:n+2],o-n)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=qu.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:function(){var t=[1];return function(e){var i,o=1;if(t[e])return t[e];for(i=e;i>1;i--)o*=i;return t[e]=o,o}}(),CatmullRom:function(t,e,i,o,n){var r=.5*(i-t),s=.5*(o-e),a=n*n;return(2*e-2*i+r+s)*(n*a)+(-3*e+3*i-2*r-s)*a+r*n+e}}},Zu=function(t){this.setProperties(t)},Ku={Easing:{configurable:!0},Interpolation:{configurable:!0}};Zu.prototype.onResetEvent=function(t){this.setProperties(t)},Zu.prototype.setProperties=function(t){for(var e in this._object=t,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=Yu.Linear.None,this._interpolationFunction=qu.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._tweenTimeTracker=qa,this.isPersistent=!1,this.updateWhenPaused=!1,this.isRenderable=!1,t)"object"!=typeof t&&(this._valuesStart[e]=parseFloat(t[e]))},Zu.prototype._resumeCallback=function(t){this._startTime&&(this._startTime+=t)},Zu.prototype.onActivateEvent=function(){fr(Dn,this._resumeCallback,this)},Zu.prototype.onDeactivateEvent=function(){gr(Dn,this._resumeCallback)},Zu.prototype.to=function(t,e){return this._valuesEnd=t,void 0!==e&&("number"==typeof e?this._duration=e:"object"==typeof e&&(e.duration&&(this._duration=e.duration),e.yoyo&&this.yoyo(e.yoyo),e.easing&&this.easing(e.easing),e.repeat&&this.repeat(e.repeat),e.delay&&this.delay(e.delay),e.interpolation&&this.interpolation(e.interpolation),e.autoStart&&this.start())),this},Zu.prototype.start=function(t){for(var e in void 0===t&&(t=ju.getTime()),this._onStartCallbackFired=!1,Ba.addChild(this),this._startTime=t+this._delayTime,this._valuesEnd){if(this._valuesEnd[e]instanceof Array){if(0===this._valuesEnd[e].length)continue;this._valuesEnd[e]=[this._object[e]].concat(this._valuesEnd[e])}this._valuesStart[e]=this._object[e],this._valuesStart[e]instanceof Array==!1&&(this._valuesStart[e]*=1),this._valuesStartRepeat[e]=this._valuesStart[e]||0}return this},Zu.prototype.stop=function(){return Ba.removeChildNow(this),this},Zu.prototype.delay=function(t){return this._delayTime=t,this},Zu.prototype.repeat=function(t){return this._repeat=t,this},Zu.prototype.yoyo=function(t){return this._yoyo=t,this},Zu.prototype.easing=function(t){if("function"!=typeof t)throw new Error("invalid easing function for me.Tween.easing()");return this._easingFunction=t,this},Zu.prototype.interpolation=function(t){return this._interpolationFunction=t,this},Zu.prototype.chain=function(){return this._chainedTweens=arguments,this},Zu.prototype.onStart=function(t){return this._onStartCallback=t,this},Zu.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},Zu.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},Zu.prototype.update=function(t){this._tweenTimeTracker=qa>this._tweenTimeTracker?qa:this._tweenTimeTracker+t;var e,i=this._tweenTimeTracker;if(i<this._startTime)return!0;!1===this._onStartCallbackFired&&(null!==this._onStartCallback&&this._onStartCallback.call(this._object),this._onStartCallbackFired=!0);var o=(i-this._startTime)/this._duration;o=o>1?1:o;var n=this._easingFunction(o);for(e in this._valuesEnd){var r=this._valuesStart[e]||0,s=this._valuesEnd[e];s instanceof Array?this._object[e]=this._interpolationFunction(s,n):("string"==typeof s&&(s=r+parseFloat(s)),"number"==typeof s&&(this._object[e]=r+(s-r)*n))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,n),1===o){if(this._repeat>0){for(e in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat){if("string"==typeof this._valuesEnd[e]&&(this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(this._valuesEnd[e])),this._yoyo){var a=this._valuesStartRepeat[e];this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=a}this._valuesStart[e]=this._valuesStartRepeat[e]}return this._yoyo&&(this._reversed=!this._reversed),this._startTime=i+this._delayTime,!0}Ba.removeChildNow(this),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,l=this._chainedTweens.length;h<l;h++)this._chainedTweens[h].start(i);return!1}return!0},Ku.Easing.get=function(){return Yu},Ku.Interpolation.get=function(){return qu},Object.defineProperties(Zu,Ku);var Ju={offscreenCanvas:!1,willReadFrequently:!1},$u=function(t,e,i){void 0===i&&(i=Ju),i=Object.assign(Ju,i||{}),this.canvas=ku(t,e,i.offscreenCanvas),this.context=this.canvas.getContext("2d",{willReadFrequently:i.willReadFrequently})},Qu={width:{configurable:!0},height:{configurable:!0}};function tc(t,e,i){void 0===i&&(i=!1),t.font=e.font,t.fillStyle=e.fillStyle.toRGBA(),!0===i&&(t.strokeStyle=e.strokeStyle.toRGBA(),t.lineWidth=e.lineWidth),t.textAlign=e.textAlign,t.textBaseline=e.textBaseline}$u.prototype.onResetEvent=function(t,e){this.clear(),this.resize(t,e)},$u.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},$u.prototype.resize=function(t,e){this.canvas.width=Math.round(t),this.canvas.height=Math.round(e)},$u.prototype.destroy=function(){this.context=void 0,this.canvas=void 0},Qu.width.get=function(){return this.canvas.width},Qu.width.set=function(t){this.canvas.width=Math.round(t)},Qu.height.get=function(){return this.canvas.height},Qu.height.set=function(t){this.canvas.height=Math.round(t)},Object.defineProperties($u.prototype,Qu);var ec=function(t){function e(e){t.call(this),this.ancestor=e,this.setMinMax(0,0,0,0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.lineHeight=function(){return this.ancestor instanceof rc?this.ancestor.fontSize*this.ancestor.lineHeight:this.ancestor.fontData.capHeight*this.ancestor.lineHeight*this.ancestor.fontScale.y},e.prototype.lineWidth=function(t,e){if(this.ancestor instanceof rc)return e.measureText(t).width;for(var i=t.split(""),o=0,n=null,r=0;r<i.length;r++){var s=i[r].charCodeAt(0),a=this.ancestor.fontData.glyphs[s],h=n&&n.kerning?n.getKerning(s):0;o+=(a.xadvance+h)*this.ancestor.fontScale.x,n=a}return o},e.prototype.measureText=function(t,e){var i;i=Array.isArray(t)?t:(""+t).split("\n"),void 0!==e&&(e.save(),tc(e,this.ancestor)),this.width=this.height=0;for(var o=0;o<i.length;o++)this.width=Math.max(this.lineWidth(Do(i[o]),e),this.width),this.height+=this.lineHeight();return this.width=Math.ceil(this.width),this.height=Math.ceil(this.height),this.x=Math.floor("right"===this.ancestor.textAlign?this.ancestor.pos.x-this.width:"center"===this.ancestor.textAlign?this.ancestor.pos.x-this.width/2:this.ancestor.pos.x),this.y=Math.floor(0===this.ancestor.textBaseline.search(/^(top|hanging)$/)?this.ancestor.pos.y:"middle"===this.ancestor.textBaseline?this.ancestor.pos.y-this.lineHeight()/2:this.ancestor.pos.y-this.lineHeight()),void 0!==e&&e.restore(),this},e.prototype.wordWrap=function(t,e,i){var o,n="",r=[];Array.isArray(t)&&(t=t.join(" ")),o=t.replace(/[\r\n]+/g," ").split(" "),void 0!==i&&(i.save(),tc(i,this.ancestor));for(var s=0;s<o.length;s++){var a=o[s];this.lineWidth(n+a+" ",i)<e?n+=a+" ":(r.push(n+"\n"),n=a+" ")}return r.push(n),void 0!==i&&i.restore(),r},e}(ls),ic=["ex","em","pt","px"],oc=[12,24,.75,1],nc=function(t,e){return!0===e.offScreenCanvas?e.canvasTexture.context:(void 0===t&&(t=Ou),t.getFontContext())},rc=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.onResetEvent(e,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e,i){void 0!==i.fillStyle?i.fillStyle instanceof Sn?this.fillStyle=i.fillStyle:this.fillStyle=gn.pull("Color").parseCSS(i.fillStyle):this.fillStyle=gn.pull("Color",0,0,0),void 0!==i.strokeStyle?i.strokeStyle instanceof Sn?this.strokeStyle=i.strokeStyle:this.strokeStyle=gn.pull("Color").parseCSS(i.strokeStyle):this.strokeStyle=gn.pull("Color",0,0,0),this.lineWidth=i.lineWidth||1,this.textAlign=i.textAlign||"left",this.textBaseline=i.textBaseline||"top",this.lineHeight=i.lineHeight||1,this.offScreenCanvas=!1,this.wordWrapWidth=i.wordWrapWidth||-1,this._text=[],this.fontSize=10,void 0!==i.anchorPoint?this.anchorPoint.setV(i.anchorPoint):this.anchorPoint.set(0,0),void 0!==i.floating&&(this.floating=!!i.floating),this.setFont(i.font,i.size),!0===i.bold&&this.bold(),!0===i.italic&&this.italic(),!0===i.offScreenCanvas&&(this.offScreenCanvas=!0,this.canvasTexture=gn.pull("CanvasTexture",2,2,{offscreenCanvas:!0})),this.metrics=new ec(this),this.setText(i.text)},e.prototype.onDeactivateEvent=function(){!0===this.offScreenCanvas&&(Ou.currentCompositor.deleteTexture2D(Ou.currentCompositor.getTexture2D(this.glTextureUnit)),Ou.cache.delete(this.canvasTexture.canvas),gn.push(this.canvasTexture),this.canvasTexture=void 0,this.glTextureUnit=void 0)},e.prototype.bold=function(){return this.font="bold "+this.font,this.isDirty=!0,this},e.prototype.italic=function(){return this.font="italic "+this.font,this.isDirty=!0,this},e.prototype.setFont=function(t,e){void 0===e&&(e=10);var i=t.split(",").map((function(t){return t=t.trim(),/(^".*"$)|(^'.*'$)/.test(t)?t:'"'+t+'"'}));if("number"==typeof e)this.fontSize=e,e+="px";else{var o=e.match(/([-+]?[\d.]*)(.*)/);this.fontSize=parseFloat(o[1]),o[2]?this.fontSize*=oc[ic.indexOf(o[2])]:e+="px"}return this.height=this.fontSize,this.font=e+" "+i.join(","),this.isDirty=!0,this},e.prototype.setText=function(t){void 0===t&&(t="");var e=this.getBounds();if(this._text.toString()!==t.toString()&&(Array.isArray(t)?this._text=t:this._text=(""+t).split("\n")),this._text.length>0&&this.wordWrapWidth>0&&(this._text=this.metrics.wordWrap(this._text,this.wordWrapWidth,nc(Ou,this))),e.addBounds(this.metrics.measureText(this._text,nc(Ou,this)),!0),!0===this.offScreenCanvas){var i=Math.ceil(this.metrics.width),o=Math.ceil(this.metrics.height);Ou instanceof wu&&(this.glTextureUnit=Ou.cache.getUnit(Ou.cache.get(this.canvasTexture.canvas)),Ou.currentCompositor.unbindTexture2D(null,this.glTextureUnit),1===Ou.WebGLVersion&&(i=Ko(this.metrics.width),o=Ko(this.metrics.height))),(this.canvasTexture.width<i||this.canvasTexture.height<o)&&this.canvasTexture.resize(i,o),this.canvasTexture.clear(),this._drawFont(this.canvasTexture.context,this._text,this.pos.x-this.metrics.x,this.pos.y-this.metrics.y,!1)}return this.isDirty=!0,this},e.prototype.measureText=function(t,e){return void 0===e&&(e=this._text),this.metrics.measureText(e,nc(t,this))},e.prototype.draw=function(t,e,i,o,n){void 0===i&&(i=this.pos.x),void 0===o&&(o=this.pos.y),void 0===n&&(n=!1),void 0===this.ancestor?(this.pos.x===i&&this.pos.y===o||(this.pos.x=i,this.pos.y=o,this.isDirty=!0),this.setText(e),i=this.metrics.x,o=this.metrics.y,t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity())):(i=this.pos.x,o=this.pos.y),!1===t.settings.subPixel&&(i=~~i,o=~~o),!0===this.offScreenCanvas?t.drawImage(this.canvasTexture.canvas,i,o):t.drawFont(this._drawFont(t.getFontContext(),this._text,i,o,n)),void 0===this.ancestor&&t.restore()},e.prototype.drawStroke=function(t,e,i,o){this.draw(t,e,i,o,!0)},e.prototype._drawFont=function(t,e,i,o,n){void 0===n&&(n=!1),tc(t,this,n);for(var r=0;r<e.length;r++){var s=Do(e[r]);t[n?"strokeText":"fillText"](s,i,o),o+=this.metrics.lineHeight()}return this.metrics},e.prototype.destroy=function(){gn.push(this.fillStyle),gn.push(this.strokeStyle),this.fillStyle=this.strokeStyle=void 0,this.metrics=void 0,this._text.length=0,t.prototype.destroy.call(this)},e}(la),sc=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.textAlign=o.textAlign||"left",this.textBaseline=o.textBaseline||"top",this.lineHeight=o.lineHeight||1,this.wordWrapWidth=o.wordWrapWidth||-1,this._text=[],this.fontScale=gn.pull("Vector2d",1,1),this.fontImage="object"==typeof o.font?o.font:zl.getImage(o.font),"string"!=typeof o.fontData?this.fontData=gn.pull("BitmapTextData",zl.getBinary(o.font)):this.fontData=gn.pull("BitmapTextData",o.fontData.includes("info face")?o.fontData:zl.getBinary(o.fontData)),void 0!==o.floating&&(this.floating=!!o.floating),void 0!==o.fillStyle&&(o.fillStyle instanceof Sn?this.fillStyle.setColor(o.fillStyle):this.fillStyle.parseCSS(o.fillStyle)),void 0!==o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),this.metrics=new ec(this),"number"==typeof o.size&&1!==o.size&&this.resize(o.size),this.setText(o.text)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={fillStyle:{configurable:!0}};return e.prototype.set=function(t,e){return this.textAlign=t,e&&this.resize(e),this.isDirty=!0,this},e.prototype.setText=function(t){return void 0===t&&(t=""),this._text.toString()!==t.toString()&&(Array.isArray(t)?this._text=t:this._text=(""+t).split("\n"),this.isDirty=!0),this._text.length>0&&this.wordWrapWidth>0&&(this._text=this.metrics.wordWrap(this._text,this.wordWrapWidth)),this.getBounds().addBounds(this.metrics.measureText(this._text),!0),this},i.fillStyle.get=function(){return this.tint},i.fillStyle.set=function(t){this.tint=t},e.prototype.resize=function(t){return this.fontScale.set(t,t),this.getBounds().addBounds(this.metrics.measureText(this._text),!0),this.isDirty=!0,this},e.prototype.measureText=function(t){return void 0===t&&(t=this._text),this.metrics.measureText(t)},e.prototype.draw=function(t,e,i,o){var n=t.globalAlpha();void 0===this.ancestor?(this.setText(e),t.setGlobalAlpha(n*this.getOpacity())):(i=this.pos.x,o=this.pos.y);for(var r=i,s=this.metrics.lineHeight(),a=0,h=0;h<this._text.length;h++){i=r;var l=Do(this._text[h]),u=this.metrics.lineWidth(l);switch(this.textAlign){case"right":i-=u;break;case"center":i-=.5*u}switch(this.textBaseline){case"middle":o-=.5*s;break;case"ideographic":case"alphabetic":case"bottom":o-=s}!0===this.isDirty&&void 0===this.ancestor&&(0===h&&(this.pos.y=o),a<u&&(a=u,this.pos.x=i));for(var c=null,p=0,d=l.length;p<d;p++){var f=l.charCodeAt(p),y=this.fontData.glyphs[f],g=y.width,v=y.height,m=c&&c.kerning?c.getKerning(f):0;0!==g&&0!==v&&t.drawImage(this.fontImage,y.x,y.y,g,v,i+y.xoffset,o+y.yoffset*this.fontScale.y,g*this.fontScale.x,v*this.fontScale.y),i+=(y.xadvance+m)*this.fontScale.x,c=y}o+=s}void 0===this.ancestor&&t.setGlobalAlpha(n),this.isDirty=!1},e.prototype.destroy=function(){gn.push(this.fontScale),this.fontScale=void 0,gn.push(this.fontData),this.fontData=void 0,this._text.length=0,this.metrics=void 0,t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(la),ac=function(){this.id=0,this.x=0,this.y=0,this.width=0,this.height=0,this.u=0,this.v=0,this.u2=0,this.v2=0,this.xoffset=0,this.yoffset=0,this.xadvance=0,this.fixedWidth=!1};ac.prototype.getKerning=function(t){if(this.kerning){var e=this.kerning[t>>>9];if(e)return e[511&t]||0}return 0},ac.prototype.setKerning=function(t,e){this.kerning||(this.kerning={});var i=this.kerning[t>>>9];void 0===i&&(this.kerning[t>>>9]={},i=this.kerning[t>>>9]),i[511&t]=e};var hc=["M","N","B","D","C","E","F","K","A","G","H","I","J","L","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function lc(t,e){var i=t.match(e);if(!i)throw new Error("Could not find pattern "+e+" in string: "+t);return i[0].split("=")[1]}function uc(t){var e=" ".charCodeAt(0),i=t[e];i||((i=new ac).id=e,i.xadvance=function(t){for(var e=Object.keys(t),i=0;i<e.length;i++)if(e[i]>32)return t[e[i]];return null}(t).xadvance,t[e]=i)}var cc=function(t){this.onResetEvent(t)};cc.prototype.onResetEvent=function(t){this.padTop=0,this.padRight=0,this.padBottom=0,this.padLeft=0,this.lineHeight=0,this.capHeight=1,this.descent=0,this.glyphs={},this.parse(t)},cc.prototype.parse=function(t){if(!t)throw new Error("File containing font data was empty, cannot load the bitmap font.");var e=t.split(/\r\n|\n/),i=t.match(/padding\=\d+,\d+,\d+,\d+/g);if(!i)throw new Error("Padding not found in first line");var o=i[0].split("=")[1].split(",");this.padTop=parseFloat(o[0]),this.padLeft=parseFloat(o[1]),this.padBottom=parseFloat(o[2]),this.padRight=parseFloat(o[3]),this.lineHeight=parseFloat(lc(e[1],/lineHeight\=\d+/g));var n,r=parseFloat(lc(e[1],/base\=\d+/g)),s=this.padTop+this.padBottom,a=null;for(n=4;n<e.length;n++){var h=e[n],l=h.split(/=|\s+/);if(h&&!/^kernings/.test(h))if(/^kerning\s/.test(h)){var u=parseFloat(l[2]),c=parseFloat(l[4]),p=parseFloat(l[6]);null!=(a=this.glyphs[u])&&a.setKerning(c,p)}else{a=new ac;var d=parseFloat(l[2]);a.id=d,a.x=parseFloat(l[4]),a.y=parseFloat(l[6]),a.width=parseFloat(l[8]),a.height=parseFloat(l[10]),a.xoffset=parseFloat(l[12]),a.yoffset=parseFloat(l[14]),a.xadvance=parseFloat(l[16]),a.width>0&&a.height>0&&(this.descent=Math.min(r+a.yoffset,this.descent)),this.glyphs[d]=a}}this.descent+=this.padBottom,uc(this.glyphs);var f=null;for(n=0;n<hc.length;n++){var y=hc[n];if(f=this.glyphs[y.charCodeAt(0)])break}if(f)this.capHeight=f.height;else for(var g in this.glyphs)if(this.glyphs.hasOwnProperty(g)){if(0===(a=this.glyphs[g]).height||0===a.width)continue;this.capHeight=Math.max(this.capHeight,a.height)}this.capHeight-=s};var pc=function(t){function e(e,i,o){t.call(this,0,0,1/0,1/0),this.color=gn.pull("Color").parseCSS(i),this.onResetEvent(e,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e,i){void 0===i&&(i=0),this.name=t,this.pos.z=i,this.floating=!0,this.color.parseCSS(e)},e.prototype.draw=function(t,e){t.save(),t.clipRect(0,0,e.width,e.height),t.clearColor(this.color),t.restore()},e.prototype.destroy=function(){gn.push(this.color),this.color=void 0,t.prototype.destroy.call(this)},e}(la),dc=function(t){function e(e,i,o){t.call(this,e,i,o),this.floating=!0,this.offset.set(e,i),this.ratio=gn.pull("Vector2d",1,1),void 0!==o.ratio&&(Lo(o.ratio)?this.ratio.set(o.ratio,+o.ratio):this.ratio.setV(o.ratio)),void 0===o.anchorPoint?this.anchorPoint.set(0,0):"number"==typeof o.anchorPoint?this.anchorPoint.set(o.anchorPoint,o.anchorPoint):this.anchorPoint.setV(o.anchorPoint),this.repeat=o.repeat||"repeat",fr(pr,this.createPattern,this)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={repeat:{configurable:!0}};return i.repeat.get=function(){return this._repeat},i.repeat.set=function(t){switch(this._repeat=t,this._repeat){case"no-repeat":this.repeatX=!1,this.repeatY=!1;break;case"repeat-x":this.repeatX=!0,this.repeatY=!1;break;case"repeat-y":this.repeatX=!1,this.repeatY=!0;break;default:this.repeatX=!0,this.repeatY=!0}this.resize(Ra.width,Ra.height),this.createPattern()},e.prototype.onActivateEvent=function(){var t=this;fr(ur,this.updateLayer,this),fr(ar,this.resize,this),yr(Yn,(function(){t.updateLayer(Ra.pos)})),!0!==this.ancestor.root&&this.updateLayer(Ra.pos)},e.prototype.resize=function(e,i){return t.prototype.resize.call(this,this.repeatX?1/0:e,this.repeatY?1/0:i)},e.prototype.createPattern=function(){this._pattern=Ou.createPattern(this.image,this._repeat)},e.prototype.updateLayer=function(t){var e=this.ratio.x,i=this.ratio.y;if(0!==e||0!==i){var o=this.width,n=this.height,r=Ra.bounds.width,s=Ra.bounds.height,a=this.anchorPoint.x,h=this.anchorPoint.y,l=a*(e-1)*(r-Ra.width)+this.offset.x-e*t.x,u=h*(i-1)*(s-Ra.height)+this.offset.y-i*t.y;this.repeatX?this.pos.x=l%o:this.pos.x=l,this.repeatY?this.pos.y=u%n:this.pos.y=u,this.isDirty=!0}},e.prototype.preDraw=function(t){t.save(),t.setGlobalAlpha(t.globalAlpha()*this.getOpacity()),t.setTint(this.tint)},e.prototype.draw=function(t,e){var i=this.width,o=this.height,n=e.bounds.width,r=e.bounds.height,s=this.anchorPoint.x,a=this.anchorPoint.y,h=this.pos.x,l=this.pos.y;0===this.ratio.x&&0===this.ratio.y&&(h+=s*(n-i),l+=a*(r-o)),t.translate(h,l),t.drawPattern(this._pattern,0,0,2*e.width,2*e.height)},e.prototype.onDeactivateEvent=function(){gr(ur,this.updateLayer),gr(ar,this.resize)},e.prototype.destroy=function(){gn.push(this.ratio),this.ratio=void 0,gr(pr,this.createPattern),t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(qh),fc=function(t){function e(e,i,o){if(t.call(this,e,i,o),"number"!=typeof o.width||"number"!=typeof o.height)throw new Error("height and width properties are mandatory");this.width=Math.floor(o.width),this.height=Math.floor(o.height),this.nss_width=this.width,this.nss_height=this.height,this.insetx=o.insetx,this.insety=o.insety}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t){var e=this.current,i=this.pos.x,o=this.pos.y,n=e.width,r=e.height,s=e.offset,a=this.offset;0!==e.angle&&(t.translate(-i,-o),t.rotate(e.angle),i-=r,n=e.height,r=e.width);var h=a.x+s.x,l=a.y+s.y,u=this.insetx||n/4,c=this.insety||r/4;t.drawImage(this.image,h,l,u,c,i,o,u,c),t.drawImage(this.image,h+n-u,l,u,c,i+this.nss_width-u,o,u,c),t.drawImage(this.image,h,l+r-c,u,c,i,o+this.nss_height-c,u,c),t.drawImage(this.image,h+n-u,l+r-c,u,c,i+this.nss_width-u,o+this.nss_height-c,u,c);var p=n-(u<<1),d=r-(c<<1),f=this.nss_width-(u<<1),y=this.nss_height-(c<<1);t.drawImage(this.image,h+u,l,p,c,i+u,o,f,c),t.drawImage(this.image,h+u,l+r-c,p,c,i+u,o+this.nss_height-c,f,c),t.drawImage(this.image,h,l+c,u,d,i,o+c,u,y),t.drawImage(this.image,h+n-u,l+c,u,d,i+this.nss_width-u,o+c,u,y),t.drawImage(this.image,h+u,l+c,p,d,i+u,o+c,f,y)},e}(qh),yc=function(t){function e(e,i,o){t.call(this,e,i,o),this.isClickable=!0,this.holdThreshold=250,this.isHoldable=!1,this.hover=!1,this.holdTimeout=null,this.released=!0,this.floating=!0,this.isKinematic=!1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clicked=function(t){if(0===t.button&&this.isClickable)return this.dirty=!0,this.released=!1,this.isHoldable&&(null!==this.holdTimeout&&ju.clearTimeout(this.holdTimeout),this.holdTimeout=ju.setTimeout(this.hold.bind(this),this.holdThreshold,!1),this.released=!1),this.onClick(t)},e.prototype.onClick=function(t){return!1},e.prototype.enter=function(t){return this.hover=!0,this.dirty=!0,this.onOver(t)},e.prototype.onOver=function(t){},e.prototype.leave=function(t){return this.hover=!1,this.dirty=!0,this.release(t),this.onOut(t)},e.prototype.onOut=function(t){},e.prototype.release=function(t){if(!1===this.released)return this.released=!0,this.dirty=!0,ju.clearTimeout(this.holdTimeout),this.onRelease(t)},e.prototype.onRelease=function(){return!1},e.prototype.hold=function(){ju.clearTimeout(this.holdTimeout),this.dirty=!0,this.released||this.onHold()},e.prototype.onHold=function(){},e.prototype.onActivateEvent=function(){Ws("pointerdown",this,this.clicked.bind(this)),Ws("pointerup",this,this.release.bind(this)),Ws("pointercancel",this,this.release.bind(this)),Ws("pointerenter",this,this.enter.bind(this)),Ws("pointerleave",this,this.leave.bind(this))},e.prototype.onDeactivateEvent=function(){Ys("pointerdown",this),Ys("pointerup",this),Ys("pointercancel",this),Ys("pointerenter",this),Ys("pointerleave",this),ju.clearTimeout(this.holdTimeout)},e}(qh),gc=function(t){function e(e,i,o){t.call(this,e,i,o),this.name=o.name,this.type=o.type,this.id=o.id;var n=o.shapes;void 0===n&&(n=gn.pull("Polygon",0,0,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height)])),this.body=new Sa(this,n),this.body.collisionType=Aa.types.COLLECTABLE_OBJECT,this.body.setCollisionMask(Aa.types.PLAYER_OBJECT),this.body.setStatic(!0),o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(qh),vc=function(t){function e(e,i,o){t.call(this,e,i,o.width||0,o.height||0),this.anchorPoint.set(0,0),this.fade=o.fade,this.duration=o.duration,this.fading=!1,this.name="Trigger",this.type=o.type,this.id=o.id,this.gotolevel=o.to,this.triggerSettings={event:"level"},["type","container","onLoaded","flatten","setViewportBounds","to"].forEach(function(t){void 0!==o[t]&&(this.triggerSettings[t]=o[t])}.bind(this));var n=o.shapes;void 0===n&&(n=gn.pull("Polygon",0,0,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height)])),this.body=new Sa(this,n),this.body.collisionType=Aa.types.ACTION_OBJECT,this.body.setCollisionMask(Aa.types.PLAYER_OBJECT),this.body.setStatic(!0),this.resize(this.body.getBounds().width,this.body.getBounds().height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getTriggerSettings=function(){return"string"==typeof this.triggerSettings.container&&(this.triggerSettings.container=Ba.getChildByName(this.triggerSettings.container)[0]),this.triggerSettings},e.prototype.onFadeComplete=function(){bl.load(this.gotolevel,this.getTriggerSettings()),Ra.fadeOut(this.fade,this.duration)},e.prototype.triggerEvent=function(){var t=this.getTriggerSettings();if("level"!==t.event)throw new Error("Trigger invalid type");this.gotolevel=t.to,this.fade&&this.duration?this.fading||(this.fading=!0,Ra.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):bl.load(this.gotolevel,t)},e.prototype.onCollision=function(t,e){return"Trigger"===this.name&&this.triggerEvent.apply(this),!1},e}(la);var mc=function(t){function e(e,i,o,n,r){var s,a,h,l,u;void 0===n&&(n="#FFF"),void 0===r&&(r=.7),t.call(this,e,i,2*o,2*o),this.color=gn.pull("Color").parseCSS(n),this.radius=o,this.intensity=r,this.blendMode="lighter",this.visibleArea=gn.pull("Ellipse",this.centerX,this.centerY,this.width,this.height),this.texture=gn.pull("CanvasTexture",this.width,this.height,{offscreenCanvas:!1}),this.anchorPoint.set(0,0),a=(s=this).texture.context,h=s.texture.width/2,l=s.texture.height/2,u=a.createRadialGradient(h,l,0,h,l,s.radius),s.texture.clear(),u.addColorStop(0,s.color.toRGBA(s.intensity)),u.addColorStop(1,s.color.toRGBA(0)),a.beginPath(),a.fillStyle=u,a.arc(h,l,s.radius,0,2*Math.PI,!1),a.fill()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getVisibleArea=function(){return this.visibleArea.setShape(this.getBounds().centerX,this.getBounds().centerY,this.width,this.height)},e.prototype.draw=function(t,e){t.drawImage(this.texture.canvas,this.getBounds().x,this.getBounds().y)},e.prototype.destroy=function(){gn.push(this.color),this.color=void 0,gn.push(this.texture),this.texture=void 0,gn.push(this.visibleArea),this.visibleArea=void 0,t.prototype.destroy.call(this)},e}(la),_c=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.isKinematic=!1,this.dragging=!1,this.dragId=null,this.grabOffset=new vn(0,0),this.initEvents()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.initEvents=function(){var t=this;Ws("pointerdown",this,(function(e){dr(or,e,t)})),Ws("pointerup",this,(function(e){dr(nr,e,t)})),Ws("pointercancel",this,(function(e){dr(nr,e,t)})),fr(er,this.dragMove.bind(this)),fr(or,(function(e,i){i===t&&t.dragStart(e)})),fr(nr,(function(e,i){i===t&&t.dragEnd(e)}))},e.prototype.dragStart=function(t){if(!1===this.dragging)return this.dragging=!0,this.grabOffset.set(t.gameX,t.gameY),this.grabOffset.sub(this.pos),!1},e.prototype.dragMove=function(t){!0===this.dragging&&(this.pos.set(t.gameX,t.gameY,this.pos.z),this.pos.sub(this.grabOffset))},e.prototype.dragEnd=function(){if(!0===this.dragging)return this.dragging=!1,!1},e.prototype.destroy=function(){gr(er,this.dragMove),gr(or,this.dragStart),gr(nr,this.dragEnd),Ys("pointerdown",this),Ys("pointerup",this),Ys("pointercancel",this),t.prototype.destroy.call(this)},e}(la),xc=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.isKinematic=!1,this.CHECKMETHOD_OVERLAP="overlaps",this.CHECKMETHOD_CONTAINS="contains",this.checkMethod=this.CHECKMETHOD_OVERLAP,fr(nr,this.checkOnMe,this)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setCheckMethod=function(t){"function"==typeof this.getBounds()[this.checkMethod]&&(this.checkMethod=t)},e.prototype.checkOnMe=function(t,e){e&&this.getBounds()[this.checkMethod](e.getBounds())&&this.drop(e)},e.prototype.drop=function(t){},e.prototype.destroy=function(){gr(nr,this.checkOnMe),t.prototype.destroy.call(this)},e}(la),bc={width:1,height:1,image:void 0,textureSize:8,tint:"#fff",totalParticles:50,angle:Math.PI/2,angleVariation:0,minLife:1e3,maxLife:3e3,speed:2,speedVariation:1,minRotation:0,maxRotation:0,minStartScale:1,maxStartScale:1,minEndScale:0,maxEndScale:0,gravity:0,wind:0,followTrajectory:!1,textureAdditive:!1,blendMode:"normal",onlyInViewport:!0,floating:!1,maxParticles:10,frequency:100,duration:1/0,framesToSkip:0};var wc=function(t){function e(e,i,o){void 0===o&&(o={}),t.call(this,e,i,1|o.width,1|o.height),this.settings={},this.centerOn(e,i),this._stream=!1,this._frequencyTimer=0,this._durationTimer=0,this._enabled=!1,this.alwaysUpdate=!0,this.autoSort=!1,this._updateCount=0,this._dt=0,this.reset(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.reset=function(t){void 0===t&&(t={}),Object.assign(this.settings,bc,t),void 0===this.settings.image&&(this._defaultParticle=function(t,e){void 0===t&&(t=8),void 0===e&&(e=8);var i=gn.pull("CanvasTexture",t,e,{offscreenCanvas:!0});return i.context.fillStyle="#fff",i.context.fillRect(0,0,t,e),i}(t.textureSize,t.textureSize),this.settings.image=this._defaultParticle.canvas),this.floating=this.settings.floating,this.isDirty=!0},e.prototype.getRandomPointX=function(){return tn(0,this.getBounds().width)},e.prototype.getRandomPointY=function(){return tn(0,this.getBounds().height)},e.prototype.addParticles=function(t){for(var e=0;e<t;e++)this.addChild(gn.pull("Particle",this),this.pos.z);this.isDirty=!0},e.prototype.isRunning=function(){return this._enabled&&this._stream},e.prototype.streamParticles=function(t){this._enabled=!0,this._stream=!0,this.settings.frequency=Math.max(1,this.settings.frequency),this._durationTimer="number"==typeof t?t:this.settings.duration},e.prototype.stopStream=function(){this._enabled=!1},e.prototype.burstParticles=function(t){this._enabled=!0,this._stream=!1,this.addParticles("number"==typeof t?t:this.settings.totalParticles),this._enabled=!1},e.prototype.update=function(e){if(++this._updateCount>this.settings.framesToSkip&&(this._updateCount=0),this._updateCount>0)return this._dt+=e,this.isDirty;if(e+=this._dt,this._dt=0,this.isDirty|=t.prototype.update.call(this,e),this._enabled&&this._stream){if(this._durationTimer!==1/0&&(this._durationTimer-=e,this._durationTimer<=0))return this.stopStream(),this.isDirty;this._frequencyTimer+=e;var i=this.children.length;i<this.settings.totalParticles&&this._frequencyTimer>=this.settings.frequency&&(i+this.settings.maxParticles<=this.settings.totalParticles?this.addParticles(this.settings.maxParticles):this.addParticles(this.settings.totalParticles-i),this._frequencyTimer=0,this.isDirty=!0)}return this.isDirty},e.prototype.destroy=function(){t.prototype.destroy.call(this,arguments),void 0!==this._defaultParticle&&(gn.push(this._defaultParticle),this._defaultParticle=void 0),this.settings.image=void 0,this.settings=void 0},e}(Ma),Tc=function(t){function e(e){t.call(this,e.getRandomPointX(),e.getRandomPointY(),e.settings.image.width,e.settings.image.height),this.onResetEvent(e,!0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onResetEvent=function(t,e){void 0===e&&(e=!1),!1===e?(this.pos.set(t.getRandomPointX(),t.getRandomPointY()),this.resize(t.settings.image.width,t.settings.image.height),this.currentTransform.identity()):this.vel=gn.pull("Vector2d"),this.image=t.settings.image,this.alwaysUpdate=!0,"string"==typeof t.settings.tint&&this.tint.parseCSS(t.settings.tint),!0===t.settings.textureAdditive&&(this.blendMode="additive"),"normal"!==t.settings.blendMode&&(this.blendMode=t.settings.blendMode);var i=t.settings.angle+(t.settings.angleVariation>0?(tn(0,2)-1)*t.settings.angleVariation:0),o=t.settings.speed+(t.settings.speedVariation>0?(tn(0,2)-1)*t.settings.speedVariation:0);this.vel.set(o*Math.cos(i),-o*Math.sin(i)),this.life=tn(t.settings.minLife,t.settings.maxLife),this.startLife=this.life,this.startScale=$o(tn(t.settings.minStartScale,t.settings.maxStartScale),t.settings.minStartScale,t.settings.maxStartScale),this.endScale=$o(tn(t.settings.minEndScale,t.settings.maxEndScale),t.settings.minEndScale,t.settings.maxEndScale),this.gravity=t.settings.gravity,this.wind=t.settings.wind,this.followTrajectory=t.settings.followTrajectory,this.onlyInViewport=t.settings.onlyInViewport,this._deltaInv=ju.maxfps/1e3,t.settings.followTrajectory||(this.angle=tn(t.settings.minRotation,t.settings.maxRotation))},e.prototype.update=function(e){var i=e*this._deltaInv;if(this.life=this.life>e?this.life-e:0,this.life<=0)return this.ancestor.removeChild(this),!1;var o=this.life/this.startLife,n=this.startScale;this.startScale>this.endScale?n=(n*=o)<this.endScale?this.endScale:n:this.startScale<this.endScale&&(n=(n/=o)>this.endScale?this.endScale:n),this.alpha=o,this.vel.x+=this.wind*i,this.vel.y+=this.gravity*i;var r=this.followTrajectory?Math.atan2(this.vel.y,this.vel.x):this.angle;return this.pos.x+=this.vel.x*i,this.pos.y+=this.vel.y*i,this.currentTransform.setTransform(n,0,0,0,n,0,this.pos.x,this.pos.y,1).rotate(r),this.isDirty=this.inViewport||!this.onlyInViewport,t.prototype.update.call(this,e)},e.prototype.draw=function(t){var e=this.width,i=this.height;t.drawImage(this.image,0,0,e,i,-e/2,-i/2,e,i)},e}(la),Ac=function(t){function e(e,i,o){if("number"!=typeof o.width||"number"!=typeof o.height)throw new Error("height and width properties are mandatory when passing settings parameters to an object entity");t.call(this,e,i,o.width,o.height),this.children=[],o.image&&(o.framewidth=o.framewidth||o.width,o.frameheight=o.frameheight||o.height,this.renderable=new qh(0,0,o)),o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),"string"==typeof o.name&&(this.name=o.name),this.type=o.type||"",this.id=o.id||"",this.alive=!0,void 0===o.shapes&&(o.shapes=gn.pull("Polygon",0,0,[gn.pull("Vector2d",0,0),gn.pull("Vector2d",this.width,0),gn.pull("Vector2d",this.width,this.height),gn.pull("Vector2d",0,this.height)])),this.body=new Sa(this,o.shapes,this.onBodyUpdate.bind(this)),0===this.width&&0===this.height&&this.resize(this.body.getBounds().width,this.body.getBounds().height),this.body.setCollisionMask(o.collisionMask),this.body.setCollisionType(o.collisionType),this.autoTransform=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={renderable:{configurable:!0}};return i.renderable.get=function(){return this.children[0]},i.renderable.set=function(e){if(!(e instanceof t))throw new Error(e+"should extend me.Renderable");this.children[0]=e,this.children[0].ancestor=this},e.prototype.update=function(e){return this.renderable&&(this.isDirty|=this.renderable.update(e)),t.prototype.update.call(this,e)},e.prototype.onBodyUpdate=function(t){this.getBounds().addBounds(t.getBounds(),!0),this.updateBoundsPos(this.pos.x,this.pos.y)},e.prototype.preDraw=function(e){e.save(),e.translate(this.pos.x+this.body.getBounds().x,this.pos.y+this.body.getBounds().y),this.renderable instanceof t&&e.translate(this.anchorPoint.x*this.body.getBounds().width,this.anchorPoint.y*this.body.getBounds().height)},e.prototype.draw=function(e,i){var o=this.renderable;o instanceof t&&(o.preDraw(e),o.draw(e,i),o.postDraw(e))},e.prototype.destroy=function(){this.renderable&&(this.renderable.destroy.apply(this.renderable,arguments),this.children.splice(0,1)),t.prototype.destroy.call(this,arguments)},e.prototype.onDeactivateEvent=function(){this.renderable&&this.renderable.onDeactivateEvent&&this.renderable.onDeactivateEvent()},Object.defineProperties(e.prototype,i),e}(la);function Sc(t,e,i){var o="melonJS: %s is deprecated since version %s, please use %s",n=(new Error).stack;console.groupCollapsed?console.groupCollapsed("%c"+o,"font-weight:normal;color:yellow;",t,i,e):console.warn(o,t,i,e),void 0!==n&&console.warn(n),console.groupCollapsed&&console.groupEnd()}du.turnOnPointerLock=function(){return Sc("device.turnOnPointerLock()","input.requestPointerLock()","10.3.0"),Zs()},du.turnOffPointerLock=function(){return Sc("device.turnOffPointerLock()","input.exitPointerLock()","10.3.0"),Ks()},Object.defineProperty(tl.prototype,"Texture",{get:function(){return Sc("me.video.renderer.Texture","me.TextureAtlas","10.4.0"),Yh}});var Ec=function(t){function e(e,i,o){Sc("DraggableEntity","Draggable","10.5.0"),t.call(this,e,i,o.width,o.height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(_c),Cc=function(t){function e(e,i,o){Sc("DroptargetEntity","DropTarget","10.5.0"),t.call(this,e,i,o.width,o.height)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(xc),Mc="10.12.0";t.initialized=!1;function Pc(){!0!==t.initialized&&(gn.register("me.Entity",Ac),gn.register("me.Collectable",gc),gn.register("me.Trigger",vc),gn.register("me.Light2d",mc),gn.register("me.Tween",Zu,!0),gn.register("me.Color",Sn,!0),gn.register("me.Particle",Tc,!0),gn.register("me.Sprite",qh),gn.register("me.NineSliceSprite",fc),gn.register("me.Renderable",la),gn.register("me.Text",rc,!0),gn.register("me.BitmapText",sc),gn.register("me.BitmapTextData",cc,!0),gn.register("me.ImageLayer",dc),gn.register("me.ColorLayer",pc,!0),gn.register("me.Vector2d",vn,!0),gn.register("me.Vector3d",xr,!0),gn.register("me.ObservableVector2d",_r,!0),gn.register("me.ObservableVector3d",br,!0),gn.register("me.Matrix2d",Pn,!0),gn.register("me.Matrix3d",Cn,!0),gn.register("me.Rect",Kr,!0),gn.register("me.RoundRect",Jh,!0),gn.register("me.Polygon",Zr,!0),gn.register("me.Line",$h,!0),gn.register("me.Ellipse",ua,!0),gn.register("me.Bounds",ls,!0),gn.register("Entity",Ac),gn.register("Collectable",gc),gn.register("Trigger",vc),gn.register("Light2d",mc),gn.register("Tween",Zu,!0),gn.register("Color",Sn,!0),gn.register("Particle",Tc,!0),gn.register("Sprite",qh),gn.register("NineSliceSprite",fc),gn.register("Renderable",la),gn.register("Text",rc,!0),gn.register("BitmapText",sc),gn.register("BitmapTextData",cc,!0),gn.register("ImageLayer",dc),gn.register("ColorLayer",pc,!0),gn.register("Vector2d",vn,!0),gn.register("Vector3d",xr,!0),gn.register("ObservableVector2d",_r,!0),gn.register("ObservableVector3d",br,!0),gn.register("Matrix2d",Pn,!0),gn.register("Matrix3d",Cn,!0),gn.register("Rect",Kr,!0),gn.register("RoundRect",Jh,!0),gn.register("Polygon",Zr,!0),gn.register("Line",$h,!0),gn.register("Ellipse",ua,!0),gn.register("Bounds",ls,!0),gn.register("CanvasTexture",$u,!0),dr(Rn),zl.setNocache(zu.getUriFragment().nocache||!1),ss(),t.initialized=!0)}du.onReady((function(){Pc()})),t.BitmapText=sc,t.BitmapTextData=cc,t.Body=Sa,t.Bounds=ls,t.Camera2d=sh,t.CanvasRenderer=el,t.Collectable=gc,t.Color=Sn,t.ColorLayer=pc,t.Container=Ma,t.Draggable=_c,t.DraggableEntity=Ec,t.DropTarget=xc,t.DroptargetEntity=Cc,t.Ellipse=ua,t.Entity=Ac,t.GLShader=mu,t.GUI_Object=yc,t.ImageLayer=dc,t.Light2d=mc,t.Line=$h,t.Math=nn,t.Matrix2d=Pn,t.Matrix3d=Cn,t.NineSliceSprite=fc,t.ObservableVector2d=_r,t.ObservableVector3d=br,t.Particle=Tc,t.ParticleEmitter=wc,t.ParticleEmitterSettings=bc,t.Pointer=ds,t.Polygon=Zr,t.QuadTree=Ia,t.Rect=Kr,t.Renderable=la,t.Renderer=tl,t.RoundRect=Jh,t.Sprite=qh,t.Stage=hh,t.TMXHexagonalRenderer=ll,t.TMXIsometricRenderer=sl,t.TMXLayer=ol,t.TMXOrthogonalRenderer=rl,t.TMXRenderer=nl,t.TMXStaggeredRenderer=ul,t.TMXTileMap=gl,t.TMXTileset=cl,t.TMXTilesetGroup=pl,t.Text=rc,t.TextureAtlas=Yh,t.Tile=Kh,t.Trigger=vc,t.Tween=Zu,t.Vector2d=vn,t.Vector3d=xr,t.WebGLCompositor=bu,t.WebGLRenderer=wu,t.World=Da,t.audio=Ql,t.boot=Pc,t.collision=Aa,t.device=du,t.event=vr,t.game=ih,t.input=ha,t.level=bl,t.loader=zl,t.plugin=Wu,t.plugins=Hu,t.pool=gn,t.save=iu,t.skipAutoInit=!1,t.state=Ah,t.timer=ju,t.utils=zu,t.version=Mc,t.video=Bu,t.warning=Sc,Object.defineProperty(t,"__esModule",{value:!0})}));