melonjs 13.3.0 → 13.4.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.
- package/dist/melonjs.js +82 -59
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.js +82 -59
- package/package.json +8 -8
- package/src/text/bitmaptext.js +25 -18
- package/src/text/textmetrics.js +5 -3
package/dist/melonjs.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v13.
|
|
2
|
+
* melonJS Game Engine - v13.4.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 (AltByte Pte Ltd)
|
|
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(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,x=Function.prototype,_=x.bind,b=x.call,w=m&&_.bind(b,b),T=m?function(t){return t&&w(t)}:function(t){return t&&function(){return b.apply(t,arguments)}},A=T,E=A({}.toString),S=A("".slice),C=function(t){return S(E(t),8,-1)},M=r,P=C,O=Object,I=T("".split),k=M((function(){return!O("z").propertyIsEnumerable(0)}))?function(t){return"String"==P(t)?I(t,""):O(t)}:O,R=function(t){return null==t},B=R,D=TypeError,L=function(t){if(B(t))throw D("Can't call method on "+t);return t},z=k,F=L,j=function(t){return z(F(t))},V=function(t){return"function"==typeof t},U=V,N="object"==typeof document&&document.all,G=void 0===N&&void 0!==N?function(t){return"object"==typeof t?null!==t:U(t)||t===N}:function(t){return"object"==typeof t?null!==t:U(t)},X=o,H=V,Y=function(t){return H(t)?t:void 0},W=function(t,e){return arguments.length<2?Y(X[t]):X[t]&&X[t][e]},q=T({}.isPrototypeOf),K=o,Z=W("navigator","userAgent")||"",Q=K.process,J=K.Deno,$=Q&&Q.versions||J&&J.version,tt=$&&$.v8;tt&&(g=(y=tt.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!g&&Z&&(!(y=Z.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=Z.match(/Chrome\/(\d+)/))&&(g=+y[1]);var et=g,it=r,ot=!!Object.getOwnPropertySymbols&&!it((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&et&&et<41})),nt=ot&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,rt=W,st=V,at=q,ht=Object,lt=nt?function(t){return"symbol"==typeof t}:function(t){var e=rt("Symbol");return st(e)&&at(e.prototype,ht(t))},ut=String,ct=V,pt=function(t){try{return ut(t)}catch(t){return"Object"}},dt=TypeError,ft=function(t){if(ct(t))return t;throw dt(pt(t)+" is not a function")},yt=R,gt=u,vt=V,mt=G,xt=TypeError,_t={exports:{}},bt=o,wt=Object.defineProperty,Tt=function(t,e){try{wt(bt,t,{value:e,configurable:!0,writable:!0})}catch(i){bt[t]=e}return e},At=Tt,Et="__core-js_shared__",St=o[Et]||At(Et,{}),Ct=St;(_t.exports=function(t,e){return Ct[t]||(Ct[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.25.0",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Mt=L,Pt=Object,Ot=function(t){return Pt(Mt(t))},It=T({}.hasOwnProperty),kt=Object.hasOwn||function(t,e){return It(Ot(t),e)},Rt=T,Bt=0,Dt=Math.random(),Lt=Rt(1..toString),zt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+Lt(++Bt+Dt,36)},Ft=o,jt=_t.exports,Vt=kt,Ut=zt,Nt=ot,Gt=nt,Xt=jt("wks"),Ht=Ft.Symbol,Yt=Ht&&Ht.for,Wt=Gt?Ht:Ht&&Ht.withoutSetter||Ut,qt=function(t){if(!Vt(Xt,t)||!Nt&&"string"!=typeof Xt[t]){var e="Symbol."+t;Nt&&Vt(Ht,t)?Xt[t]=Ht[t]:Xt[t]=Gt&&Yt?Yt(e):Wt(e)}return Xt[t]},Kt=u,Zt=G,Qt=lt,Jt=function(t,e){var i=t[e];return yt(i)?void 0:ft(i)},$t=function(t,e){var i,o;if("string"===e&&vt(i=t.toString)&&!mt(o=gt(i,t)))return o;if(vt(i=t.valueOf)&&!mt(o=gt(i,t)))return o;if("string"!==e&&vt(i=t.toString)&&!mt(o=gt(i,t)))return o;throw xt("Can't convert object to primitive value")},te=TypeError,ee=qt("toPrimitive"),ie=function(t,e){if(!Zt(t)||Qt(t))return t;var i,o=Jt(t,ee);if(o){if(void 0===e&&(e="default"),i=Kt(o,t,e),!Zt(i)||Qt(i))return i;throw te("Can't convert object to primitive value")}return void 0===e&&(e="number"),$t(t,e)},oe=lt,ne=function(t){var e=ie(t,"string");return oe(e)?e:e+""},re=G,se=o.document,ae=re(se)&&re(se.createElement),he=function(t){return ae?se.createElement(t):{}},le=!s&&!r((function(){return 7!=Object.defineProperty(he("div"),"a",{get:function(){return 7}}).a})),ue=s,ce=u,pe=c,de=v,fe=j,ye=ne,ge=kt,ve=le,me=Object.getOwnPropertyDescriptor;n.f=ue?me:function(t,e){if(t=fe(t),e=ye(e),ve)try{return me(t,e)}catch(t){}if(ge(t,e))return de(!ce(pe.f,t,e),t[e])};var xe={},_e=s&&r((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),be=G,we=String,Te=TypeError,Ae=function(t){if(be(t))return t;throw Te(we(t)+" is not an object")},Ee=s,Se=le,Ce=_e,Me=Ae,Pe=ne,Oe=TypeError,Ie=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,Re="enumerable",Be="configurable",De="writable";xe.f=Ee?Ce?function(t,e,i){if(Me(t),e=Pe(e),Me(i),"function"==typeof t&&"prototype"===e&&"value"in i&&De in i&&!i.writable){var o=ke(t,e);o&&o.writable&&(t[e]=i.value,i={configurable:Be in i?i.configurable:o.configurable,enumerable:Re in i?i.enumerable:o.enumerable,writable:!1})}return Ie(t,e,i)}:Ie:function(t,e,i){if(Me(t),e=Pe(e),Me(i),Se)try{return Ie(t,e,i)}catch(t){}if("get"in i||"set"in i)throw Oe("Accessors not supported");return"value"in i&&(t[e]=i.value),t};var Le=xe,ze=v,Fe=s?function(t,e,i){return Le.f(t,e,ze(1,i))}:function(t,e,i){return t[e]=i,t},je={exports:{}},Ve=s,Ue=kt,Ne=Function.prototype,Ge=Ve&&Object.getOwnPropertyDescriptor,Xe=Ue(Ne,"name"),He={EXISTS:Xe,PROPER:Xe&&"something"===function(){}.name,CONFIGURABLE:Xe&&(!Ve||Ve&&Ge(Ne,"name").configurable)},Ye=V,We=St,qe=T(Function.toString);Ye(We.inspectSource)||(We.inspectSource=function(t){return qe(t)});var Ke,Ze,Qe,Je=We.inspectSource,$e=V,ti=o.WeakMap,ei=$e(ti)&&/native code/.test(String(ti)),ii=_t.exports,oi=zt,ni=ii("keys"),ri={},si=ei,ai=o,hi=T,li=G,ui=Fe,ci=kt,pi=St,di=function(t){return ni[t]||(ni[t]=oi(t))},fi=ri,yi="Object already initialized",gi=ai.TypeError,vi=ai.WeakMap;if(si||pi.state){var mi=pi.state||(pi.state=new vi),xi=hi(mi.get),_i=hi(mi.has),bi=hi(mi.set);Ke=function(t,e){if(_i(mi,t))throw gi(yi);return e.facade=t,bi(mi,t,e),e},Ze=function(t){return xi(mi,t)||{}},Qe=function(t){return _i(mi,t)}}else{var wi=di("state");fi[wi]=!0,Ke=function(t,e){if(ci(t,wi))throw gi(yi);return e.facade=t,ui(t,wi,e),e},Ze=function(t){return ci(t,wi)?t[wi]:{}},Qe=function(t){return ci(t,wi)}}var Ti={set:Ke,get:Ze,has:Qe,enforce:function(t){return Qe(t)?Ze(t):Ke(t,{})},getterFor:function(t){return function(e){var i;if(!li(e)||(i=Ze(e)).type!==t)throw gi("Incompatible receiver, "+t+" required");return i}}},Ai=r,Ei=V,Si=kt,Ci=s,Mi=He.CONFIGURABLE,Pi=Je,Oi=Ti.enforce,Ii=Ti.get,ki=Object.defineProperty,Ri=Ci&&!Ai((function(){return 8!==ki((function(){}),"length",{value:8}).length})),Bi=String(String).split("String"),Di=je.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),(!Si(t,"name")||Mi&&t.name!==e)&&(Ci?ki(t,"name",{value:e,configurable:!0}):t.name=e),Ri&&i&&Si(i,"arity")&&t.length!==i.arity&&ki(t,"length",{value:i.arity});try{i&&Si(i,"constructor")&&i.constructor?Ci&&ki(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=Oi(t);return Si(o,"source")||(o.source=Bi.join("string"==typeof e?e:"")),t};Function.prototype.toString=Di((function(){return Ei(this)&&Ii(this).source||Pi(this)}),"toString");var Li=V,zi=xe,Fi=je.exports,ji=Tt,Vi={},Ui=Math.ceil,Ni=Math.floor,Gi=Math.trunc||function(t){var e=+t;return(e>0?Ni:Ui)(e)},Xi=Gi,Hi=function(t){var e=+t;return e!=e||0===e?0:Xi(e)},Yi=Hi,Wi=Math.max,qi=Math.min,Ki=Hi,Zi=Math.min,Qi=function(t){return t>0?Zi(Ki(t),9007199254740991):0},Ji=j,$i=function(t,e){var i=Yi(t);return i<0?Wi(i+e,0):qi(i,e)},to=function(t){return Qi(t.length)},eo=function(t){return function(e,i,o){var n,r=Ji(e),s=to(r),a=$i(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}},io={includes:eo(!0),indexOf:eo(!1)},oo=kt,no=j,ro=io.indexOf,so=ri,ao=T([].push),ho=function(t,e){var i,o=no(t),n=0,r=[];for(i in o)!oo(so,i)&&oo(o,i)&&ao(r,i);for(;e.length>n;)oo(o,i=e[n++])&&(~ro(r,i)||ao(r,i));return r},lo=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Vi.f=Object.getOwnPropertyNames||function(t){return ho(t,lo)};var uo={};uo.f=Object.getOwnPropertySymbols;var co=W,po=Vi,fo=uo,yo=Ae,go=T([].concat),vo=co("Reflect","ownKeys")||function(t){var e=po.f(yo(t)),i=fo.f;return i?go(e,i(t)):e},mo=kt,xo=vo,_o=n,bo=xe,wo=r,To=V,Ao=/#|\.prototype\./,Eo=function(t,e){var i=Co[So(t)];return i==Po||i!=Mo&&(To(e)?wo(e):!!e)},So=Eo.normalize=function(t){return String(t).replace(Ao,".").toLowerCase()},Co=Eo.data={},Mo=Eo.NATIVE="N",Po=Eo.POLYFILL="P",Oo=Eo,Io=o,ko=n.f,Ro=Fe,Bo=function(t,e,i,o){o||(o={});var n=o.enumerable,r=void 0!==o.name?o.name:e;if(Li(i)&&Fi(i,r,o),o.global)n?t[e]=i:ji(e,i);else{try{o.unsafe?t[e]&&(n=!0):delete t[e]}catch(t){}n?t[e]=i:zi.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return t},Do=Tt,Lo=function(t,e,i){for(var o=xo(e),n=bo.f,r=_o.f,s=0;s<o.length;s++){var a=o[s];mo(t,a)||i&&mo(i,a)||n(t,a,r(e,a))}},zo=Oo,Fo=function(t,e){var i,o,n,r,s,a=t.target,h=t.global,l=t.stat;if(i=h?Io:l?Io[a]||Do(a,{}):(Io[a]||{}).prototype)for(o in e){if(r=e[o],n=t.dontCallGetSet?(s=ko(i,o))&&s.value:i[o],!zo(h?o:a+(l?".":"#")+o,t.forced)&&void 0!==n){if(typeof r==typeof n)continue;Lo(r,n)}(t.sham||n&&n.sham)&&Ro(r,"sham",!0),Bo(i,o,r,t)}};Fo({global:!0},{globalThis:o});var jo={};jo[qt("toStringTag")]="z";var Vo="[object z]"===String(jo),Uo=V,No=C,Go=qt("toStringTag"),Xo=Object,Ho="Arguments"==No(function(){return arguments}()),Yo=Vo?No:function(t){var e,i,o;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Xo(t),Go))?i:Ho?No(e):"Object"==(o=No(e))&&Uo(e.callee)?"Arguments":o},Wo=String,qo="\t\n\v\f\r \u2028\u2029\ufeff",Ko=L,Zo=function(t){if("Symbol"===Yo(t))throw TypeError("Cannot convert a Symbol value to a string");return Wo(t)},Qo=T("".replace),Jo="[\t\n\v\f\r \u2028\u2029\ufeff]",$o=RegExp("^"+Jo+Jo+"*"),tn=RegExp(Jo+Jo+"*$"),en=function(t){return function(e){var i=Zo(Ko(e));return 1&t&&(i=Qo(i,$o,"")),2&t&&(i=Qo(i,tn,"")),i}},on={start:en(1),end:en(2),trim:en(3)},nn=He.PROPER,rn=r,sn=qo,an=function(t){return rn((function(){return!!sn[t]()||"
"!=="
"[t]()||nn&&sn[t].name!==t}))},hn=on.start,ln=an("trimStart")?function(){return hn(this)}:"".trimStart;Fo({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==ln},{trimLeft:ln});Fo({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==ln},{trimStart:ln});var un=o,cn=T,pn=function(t,e){return cn(un[t].prototype[e])};pn("String","trimLeft");var dn=on.end,fn=an("trimEnd")?function(){return dn(this)}:"".trimEnd;Fo({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==fn},{trimRight:fn});if(Fo({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==fn},{trimEnd:fn}),pn("String","trimRight"),"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 yn=Date.now();performance.timing&&performance.timing.navigationStart&&(yn=performance.timing.navigationStart),globalThis.performance.now=function(){return Date.now()-yn}}function gn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function vn(t){return"string"==typeof t&&(t=t.trim()),!isNaN(t)&&/[+-]?([0-9]*[.])?[0-9]+/.test(t)}function mn(t){var e=t.trim();return"true"===e||"false"===e}function xn(t){for(var e="",i=0;i<t.length;)e+=t.charCodeAt(i++).toString(16);return e}function _n(t){return/^data:(.+);base64,(.+)$/.test(t)}var bn=Object.freeze({__proto__:null,capitalize:gn,isNumeric:vn,isBoolean:mn,toHex:xn,isDataUrl:_n}),wn=["ms","MS","moz","webkit","o"];function Tn(t,e){if(t in(e=e||globalThis))return e[t];var i,o=gn(t);return wn.some((function(t){var n=t+o;return i=n in e?e[n]:void 0})),i}function An(t,e,i){if(!(t in(i=i||globalThis))){var o=gn(t);return wn.some((function(t){var n=t+o;if(n in i)return i[n]=e,!0})),!1}i[t]=e}var En=Object.freeze({__proto__:null,prefixed:Tn,setPrefixed:An}),Sn=Math.PI/180,Cn=180/Math.PI,Mn=2*Math.PI,Pn=.5*Math.PI,On=1e-6;function In(t){return 0==(t&t-1)}function kn(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function Rn(t){return t*Sn}function Bn(t,e,i){return t<e?e:t>i?i:+t}function Dn(t,e){return~~(Math.random()*(e-t))+t}function Ln(t,e){return Math.random()*(e-t)+t}function zn(t,e){return~~(Math.pow(Math.random(),2)*(e-t))+t}function Fn(t,e,i){return void 0===i&&(i=2),Math.abs(t-e)<Math.pow(10,-i)/2}var jn=Object.freeze({__proto__:null,DEG_TO_RAD:Sn,RAD_TO_DEG:Cn,TAU:Mn,ETA:Pn,EPSILON:On,isPowerOfTwo:In,nextPowerOfTwo:kn,degToRad:Rn,radToDeg:function(t){return t*Cn},clamp:Bn,random:Dn,randomFloat:Ln,weightedRandom:zn,round:function(t,e){void 0===e&&(e=0);var i=Math.pow(10,e);return~~(.5+t*i)/i},toBeCloseTo:Fn});function Vn(t,e){var i=Array.prototype.indexOf.call(t,e);return-1!==i&&Array.prototype.splice.call(t,i,1),t}var Un=Object.freeze({__proto__:null,remove:Vn,random:function(t){return t[Dn(0,t.length)]},weightedRandom:function(t){return t[zn(0,t.length)]}}),Nn=/^.*(\\|\/|\:)/,Gn=/\.[^\.]*$/;function Xn(t){return t.replace(Nn,"").replace(Gn,"")}function Hn(t){return t.substring(t.lastIndexOf(".")+1,t.length)}var Yn=Object.freeze({__proto__:null,getBasename:Xn,getExtension:Hn});function Wn(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 qn(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 Kn=Object.freeze({__proto__:null,defer:Wn,throttle:qn}),Zn=function(){this.objectClass={},this.instance_counter=0};Zn.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}},Zn.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+"'")},Zn.prototype.purge=function(){for(var t in this.objectClass)this.objectClass[t]&&(this.objectClass[t].pool=[]);this.instance_counter=0},Zn.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},Zn.prototype.exists=function(t){return t in this.objectClass},Zn.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},Zn.prototype.getInstanceCount=function(){return this.instance_counter};var Qn=new Zn,Jn=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.onResetEvent(t,e)};function $n(t){return"0123456789ABCDEF".charAt(t-t%16>>4)+"0123456789ABCDEF".charAt(t%16)}function tr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}Jn.prototype.onResetEvent=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},Jn.prototype._set=function(t,e){return this.x=t,this.y=e,this},Jn.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)},Jn.prototype.setZero=function(){return this.set(0,0)},Jn.prototype.setV=function(t){return this._set(t.x,t.y)},Jn.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y)},Jn.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y)},Jn.prototype.scale=function(t,e){return this._set(this.x*t,this.y*(void 0!==e?e:t))},Jn.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y))},Jn.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2)},Jn.prototype.scaleV=function(t){return this._set(this.x*t.x,this.y*t.y)},Jn.prototype.div=function(t){return this._set(this.x/t,this.y/t)},Jn.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y)},Jn.prototype.clamp=function(t,e){return new Jn(Bn(this.x,t,e),Bn(this.y,t,e))},Jn.prototype.clampSelf=function(t,e){return this._set(Bn(this.x,t,e),Bn(this.y,t,e))},Jn.prototype.minV=function(t){return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y)},Jn.prototype.maxV=function(t){return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y)},Jn.prototype.floor=function(){return new Jn(Math.floor(this.x),Math.floor(this.y))},Jn.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y))},Jn.prototype.ceil=function(){return new Jn(Math.ceil(this.x),Math.ceil(this.y))},Jn.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},Jn.prototype.negate=function(){return new Jn(-this.x,-this.y)},Jn.prototype.negateSelf=function(){return this._set(-this.x,-this.y)},Jn.prototype.copy=function(t){return this._set(t.x,t.y)},Jn.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},Jn.prototype.normalize=function(){return this.div(this.length()||1)},Jn.prototype.perp=function(){return this._set(this.y,-this.x)},Jn.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)},Jn.prototype.dot=function(t){return this.x*t.x+this.y*t.y},Jn.prototype.cross=function(t){return this.x*t.y-this.y*t.x},Jn.prototype.length2=function(){return this.dot(this)},Jn.prototype.length=function(){return Math.sqrt(this.length2())},Jn.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},Jn.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this.y,t.x-this.x),o=this.distance(t);return 0===o||e>=0&&o<=e*e?t:(this.x+=Math.cos(i)*e,this.y+=Math.sin(i)*e,this)},Jn.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},Jn.prototype.angle=function(t){return Math.acos(Bn(this.dot(t)/(this.length()*t.length()),-1,1))},Jn.prototype.project=function(t){return this.scale(this.dot(t)/t.length2())},Jn.prototype.projectN=function(t){return this.scale(this.dot(t))},Jn.prototype.clone=function(){return Qn.pull("Vector2d",this.x,this.y)},Jn.prototype.toString=function(){return"x:"+this.x+",y:"+this.y};var er=/^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/,ir=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,or=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,nr=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,rr=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,sr=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){sr.set(t[0],t[1])}));var ar=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)},hr={r:{configurable:!0},g:{configurable:!0},b:{configurable:!0},alpha:{configurable:!0}};ar.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)},hr.r.get=function(){return~~(255*this.glArray[0])},hr.r.set=function(t){this.glArray[0]=Bn(~~t||0,0,255)/255},hr.g.get=function(){return~~(255*this.glArray[1])},hr.g.set=function(t){this.glArray[1]=Bn(~~t||0,0,255)/255},hr.b.get=function(){return~~(255*this.glArray[2])},hr.b.set=function(t){this.glArray[2]=Bn(~~t||0,0,255)/255},hr.alpha.get=function(){return this.glArray[3]},hr.alpha.set=function(t){this.glArray[3]=void 0===t?1:Bn(+t,0,1)},ar.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},ar.prototype.setHSV=function(t,e,i){var o,n,r,s=Math.floor(6*t),a=6*t-s,h=i*(1-e),l=i*(1-a*e),u=i*(1-(1-a)*e);switch(s%6){case 0:o=i,n=u,r=h;break;case 1:o=l,n=i,r=h;break;case 2:o=h,n=i,r=u;break;case 3:o=h,n=l,r=i;break;case 4:o=u,n=h,r=i;break;case 5:o=i,n=h,r=l}return this.setColor(255*o,255*n,255*r)},ar.prototype.setHSL=function(t,e,i){var o,n,r;if(0===e)o=n=r=i;else{var s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;o=tr(a,s,t+1/3),n=tr(a,s,t),r=tr(a,s,t-1/3)}return this.setColor(255*o,255*n,255*r)},ar.prototype.clone=function(){return Qn.pull("Color").copy(this)},ar.prototype.copy=function(t){return t instanceof ar?(this.glArray.set(t.glArray),this):this.parseCSS(t)},ar.prototype.add=function(t){return this.glArray[0]=Bn(this.glArray[0]+t.glArray[0],0,1),this.glArray[1]=Bn(this.glArray[1]+t.glArray[1],0,1),this.glArray[2]=Bn(this.glArray[2]+t.glArray[2],0,1),this.glArray[3]=(this.glArray[3]+t.glArray[3])/2,this},ar.prototype.darken=function(t){return t=Bn(t,0,1),this.glArray[0]*=t,this.glArray[1]*=t,this.glArray[2]*=t,this},ar.prototype.lerp=function(t,e){return e=Bn(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},ar.prototype.lighten=function(t){return t=Bn(t,0,1),this.glArray[0]=Bn(this.glArray[0]+(1-this.glArray[0])*t,0,1),this.glArray[1]=Bn(this.glArray[1]+(1-this.glArray[1])*t,0,1),this.glArray[2]=Bn(this.glArray[2]+(1-this.glArray[2])*t,0,1),this},ar.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(Dn(t,e),Dn(t,e),Dn(t,e),this.alpha)},ar.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]},ar.prototype.parseCSS=function(t){return sr.has(t)?this.setColor.apply(this,sr.get(t)):this.parseRGB(t)},ar.prototype.parseRGB=function(t){var e=er.exec(t);return e?this.setColor(+e[1],+e[2],+e[3],+e[5]):this.parseHex(t)},ar.prototype.parseHex=function(t,e){var i;if(void 0===e&&(e=!1),i=rr.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),(Bn(parseInt(i[!1===e?4:1],16),0,255)/255).toFixed(1));if(i=nr.exec(t))return this.setColor(parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16));if(i=or.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),(Bn(parseInt(s+s,16),0,255)/255).toFixed(1))}if(i=ir.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)},ar.prototype.toUint32=function(t){return void 0===t&&(t=1),((255*t&255)<<24)+((255&this.r)<<16)+((255&this.g)<<8)+(255&this.b)},ar.prototype.toArray=function(){return this.glArray},ar.prototype.toHex=function(){return"#"+$n(this.r)+$n(this.g)+$n(this.b)},ar.prototype.toHex8=function(t){return void 0===t&&(t=this.alpha),"#"+$n(this.r)+$n(this.g)+$n(this.b)+$n(255*t)},ar.prototype.toRGB=function(){return"rgb("+this.r+","+this.g+","+this.b+")"},ar.prototype.toRGBA=function(t){return void 0===t&&(t=this.alpha),"rgba("+this.r+","+this.g+","+this.b+","+t+")"},Object.defineProperties(ar.prototype,hr);var lr=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},ur={tx:{configurable:!0},ty:{configurable:!0},tz:{configurable:!0}};lr.prototype.onResetEvent=function(){void 0===this.val&&(this.val=new Float32Array(16)),arguments.length&&arguments[0]instanceof lr?this.copy(arguments[0]):16===arguments.length?this.setTransform.apply(this,arguments):this.identity()},ur.tx.get=function(){return this.val[12]},ur.ty.get=function(){return this.val[13]},ur.tz.get=function(){return this.val[14]},lr.prototype.identity=function(){return this.setTransform(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},lr.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},lr.prototype.copy=function(t){return this.val.set(t.val),this},lr.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)},lr.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],x=i[0],_=i[1],b=i[2],w=i[3];return e[0]=x*o+_*a+b*c+w*y,e[1]=x*n+_*h+b*p+w*g,e[2]=x*r+_*l+b*d+w*v,e[3]=x*s+_*u+b*f+w*m,x=i[4],_=i[5],b=i[6],w=i[7],e[4]=x*o+_*a+b*c+w*y,e[5]=x*n+_*h+b*p+w*g,e[6]=x*r+_*l+b*d+w*v,e[7]=x*s+_*u+b*f+w*m,x=i[8],_=i[9],b=i[10],w=i[11],e[8]=x*o+_*a+b*c+w*y,e[9]=x*n+_*h+b*p+w*g,e[10]=x*r+_*l+b*d+w*v,e[11]=x*s+_*u+b*f+w*m,x=i[12],_=i[13],b=i[14],w=i[15],e[12]=x*o+_*a+b*c+w*y,e[13]=x*n+_*h+b*p+w*g,e[14]=x*r+_*l+b*d+w*v,e[15]=x*s+_*u+b*f+w*m,this},lr.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},lr.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,x=e*h-n*r,_=i*a-o*s,b=i*h-n*s,w=o*h-n*a,T=l*f-u*d,A=l*y-c*d,E=l*g-p*d,S=u*y-c*f,C=u*g-p*f,M=c*g-p*y,P=v*M-m*C+x*S+_*E-b*A+w*T;return P?(P=1/P,t[0]=(s*M-a*C+h*S)*P,t[1]=(o*C-i*M-n*S)*P,t[2]=(f*w-y*b+g*_)*P,t[3]=(c*b-u*w-p*_)*P,t[4]=(a*E-r*M-h*A)*P,t[5]=(e*M-o*E+n*A)*P,t[6]=(y*x-d*w-g*m)*P,t[7]=(l*w-c*x+p*m)*P,t[8]=(r*C-s*E+h*T)*P,t[9]=(i*E-e*C-n*T)*P,t[10]=(d*b-f*x+g*v)*P,t[11]=(u*x-l*b-p*v)*P,t[12]=(s*A-r*S-a*T)*P,t[13]=(e*S-i*A+o*T)*P,t[14]=(f*m-d*_-y*v)*P,t[15]=(l*_-u*m+c*v)*P,this):null},lr.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},lr.prototype.applyInverse=function(t){var e=Qn.pull("Matrix3d",this).invert();return e.apply(t),Qn.push(e),t},lr.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},lr.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},lr.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},lr.prototype.scaleX=function(t){return this.scale(t,1)},lr.prototype.scaleY=function(t){return this.scale(1,t)},lr.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,E,S=this.val,C=e.x,M=e.y,P=e.z,O=Math.sqrt(C*C+M*M+P*P);if(O<On)return null;C*=O=1/O,M*=O,P*=O,i=Math.sin(t),n=1-(o=Math.cos(t)),r=S[0],s=S[1],a=S[2],h=S[3],l=S[4],u=S[5],c=S[6],p=S[7],d=S[8],f=S[9],y=S[10],g=S[11],v=C*C*n+o,m=M*C*n+P*i,x=P*C*n-M*i,_=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,E=P*P*n+o,S[0]=r*v+l*m+d*x,S[1]=s*v+u*m+f*x,S[2]=a*v+c*m+y*x,S[3]=h*v+p*m+g*x,S[4]=r*_+l*b+d*w,S[5]=s*_+u*b+f*w,S[6]=a*_+c*b+y*w,S[7]=h*_+p*b+g*w,S[8]=r*T+l*A+d*E,S[9]=s*T+u*A+f*E,S[10]=a*T+c*A+y*E,S[11]=h*T+p*A+g*E}return this},lr.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},lr.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]},lr.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]},lr.prototype.clone=function(){return Qn.pull("Matrix3d",this)},lr.prototype.toArray=function(){return this.val},lr.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(lr.prototype,ur);var cr=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},pr={tx:{configurable:!0},ty:{configurable:!0}};cr.prototype.onResetEvent=function(){return void 0===this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof cr?this.copy(arguments[0]):arguments.length&&arguments[0]instanceof lr?this.fromMat3d(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.identity(),this},pr.tx.get=function(){return this.val[6]},pr.ty.get=function(){return this.val[7]},cr.prototype.identity=function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},cr.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},cr.prototype.copy=function(t){return this.val.set(t.val),this},cr.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},cr.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},cr.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},cr.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},cr.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},cr.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},cr.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},cr.prototype.scaleV=function(t){return this.scale(t.x,t.y)},cr.prototype.scaleX=function(t){return this.scale(t,1)},cr.prototype.scaleY=function(t){return this.scale(1,t)},cr.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},cr.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},cr.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]},cr.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]},cr.prototype.clone=function(){return Qn.pull("Matrix2d",this)},cr.prototype.toArray=function(){return this.val},cr.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(cr.prototype,pr);var dr={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}(dr);var fr=new(0,dr.exports),yr="dom_ready",gr="me.boot",vr="me.state.onPause",mr="me.state.onResume",xr="me.state.onStop",_r="me.state.onRestart",br="me.state.onChange",wr="me.video.onInit",Tr="me.game.onInit",Ar="me.game.onReset",Er="me.game.beforeUpdate",Sr="me.game.afterUpdate",Cr="me.game.onUpdate",Mr="me.game.beforeDraw",Pr="me.game.afterDraw",Or="me.game.onLevelLoaded",Ir="me.loader.onload",kr="me.loader.onProgress",Rr="me.input.keydown",Br="me.input.keyup",Dr="gamepad.connected",Lr="gamepad.disconnected",zr="gamepad.update",Fr="me.event.pointermove",jr="me.event.pointerlockChange",Vr="me.game.dragstart",Ur="me.game.dragend",Nr="globalThis.onresize",Gr="canvas.onresize",Xr="viewport.onresize",Hr="globalThis.orientationchange",Yr="globalThis.onscroll",Wr="viewport.onchange",qr="renderer.contextlost",Kr="renderer.contextrestored";function Zr(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];return fr.emit.apply(fr,[t].concat(e))}function Qr(t,e,i){return fr.on(t,e,i)}function Jr(t,e,i){return fr.once(t,e,i)}function $r(t,e){return fr.off(t,e)}var ts=Object.freeze({__proto__:null,DOM_READY:yr,BOOT:gr,STATE_PAUSE:vr,STATE_RESUME:mr,STATE_STOP:xr,STATE_RESTART:_r,STATE_CHANGE:br,VIDEO_INIT:wr,GAME_INIT:Tr,GAME_RESET:Ar,GAME_BEFORE_UPDATE:Er,GAME_AFTER_UPDATE:Sr,GAME_UPDATE:Cr,GAME_BEFORE_DRAW:Mr,GAME_AFTER_DRAW:Pr,LEVEL_LOADED:Or,LOADER_COMPLETE:Ir,LOADER_PROGRESS:kr,KEYDOWN:Rr,KEYUP:Br,GAMEPAD_CONNECTED:Dr,GAMEPAD_DISCONNECTED:Lr,GAMEPAD_UPDATE:zr,POINTERMOVE:Fr,POINTERLOCKCHANGE:jr,DRAGSTART:Vr,DRAGEND:Ur,WINDOW_ONRESIZE:Nr,CANVAS_ONRESIZE:Gr,VIEWPORT_ONRESIZE:Xr,WINDOW_ONORIENTATION_CHANGE:Hr,WINDOW_ONSCROLL:Yr,VIEWPORT_ONCHANGE:Wr,ONCONTEXT_LOST:qr,ONCONTEXT_RESTORED:Kr,emit:Zr,on:Qr,once:Jr,off:$r}),es={},is=!1;try{is="undefined"!=typeof globalThis&&void 0!==globalThis.localStorage}catch(t){is=!1}function os(t){return"add"===t||"remove"===t}Qr(gr,(function(){if(!0===is){var t=globalThis.localStorage.getItem("me.save");if("string"==typeof t&&t.length>0)(JSON.parse(t)||[]).forEach((function(t){es[t]=JSON.parse(globalThis.localStorage.getItem("me.save."+t))}))}}));var ns={add:function(t){var e=ns;Object.keys(t).forEach((function(i){var o;os(i)||(o=i,Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:function(){return es[o]},set:function(t){es[o]=t,!0===is&&globalThis.localStorage.setItem("me.save."+o,JSON.stringify(t))}}),i in es||(e[i]=t[i]))})),!0===is&&globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(es)))},remove:function(t){os(t)||void 0!==es[t]&&(delete es[t],!0===is&&(globalThis.localStorage.removeItem("me.save."+t),globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(es)))))}},rs=!1,ss=!1;function as(){if(!ss){if(void 0!==globalThis.document&&!globalThis.document.body)return setTimeout(as,13);void 0!==globalThis.document&&"function"==typeof globalThis.document.removeEventListener&&globalThis.document.removeEventListener("DOMContentLoaded",as,!1),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("load",as,!1),Zr(yr),ss=!0}}var hs=void 0!==globalThis.navigator?globalThis.navigator.userAgent:"",ls=/iPhone|iPad|iPod/i.test(hs),us=/Android/i.test(hs),cs=/Android 2/i.test(hs),ps=/Linux/i.test(hs),ds=/CrOS/.test(hs),fs=/Windows Phone/i.test(hs),ys=/BlackBerry/i.test(hs),gs=/Kindle|Silk.*Mobile Safari/i.test(hs),vs=void 0!==globalThis.ejecta,ms=/MicroMessenger/i.test(hs),xs=void 0!==globalThis.process&&void 0!==globalThis.process.release&&"node"===globalThis.process.release.name,_s=/Mobi/i.test(hs)||ls||us||fs||ys||gs||!1,bs=!1,ws=!1,Ts=!0,As={left:0,top:0,x:0,y:0,width:0,height:0,right:0,bottom:0};function Es(t){return t.preventDefault(),"function"==typeof globalThis.scroll&&globalThis.scroll(0,0),!1}function Ss(t){qs=t.accelerationIncludingGravity.x,Ks=t.accelerationIncludingGravity.y,Zs=t.accelerationIncludingGravity.z}function Cs(t){Qs=t.gamma,Js=t.beta,$s=t.alpha}var Ms=Object.freeze({__proto__:null,ua:hs,iOS:ls,android:us,android2:cs,linux:ps,chromeOS:ds,wp:fs,BlackBerry:ys,Kindle:gs,ejecta:vs,isWeixin:ms,nodeJS:xs,isMobile:_s}),Ps=!!("ontouchstart"in globalThis),Os=!!globalThis.PointerEvent,Is=Ps||Os,ks=Is?Os?globalThis.navigator.maxTouchPoints||1:10:1,Rs=void 0!==globalThis.document&&"onwheel"in globalThis.document.createElement("div"),Bs=void 0!==globalThis.document&&void 0!==globalThis.document.pointerLockElement,Ds=!!globalThis.DeviceOrientationEvent,Ls="undefined"!=typeof screen&&void 0!==screen.orientation,zs=!!globalThis.DeviceMotionEvent,Fs=void 0!==globalThis.document&&(Tn("fullscreenEnabled",globalThis.document)||globalThis.document.mozFullScreenEnabled);!0===Fs&&(globalThis.document.exitFullscreen=Tn("cancelFullScreen",globalThis.document)||Tn("exitFullscreen",globalThis.document));var js=!(!globalThis.AudioContext&&!globalThis.webkitAudioContext),Vs=void 0!==globalThis.Audio,Us=js||Vs,Ns=function(){try{return!!globalThis.localStorage}catch(t){return!1}}(),Gs=function(){try{return void 0!==globalThis.OffscreenCanvas&&null!==new globalThis.OffscreenCanvas(0,0).getContext("2d")}catch(t){return!1}}(),Xs="function"==typeof globalThis.atob,Hs=void 0!==globalThis.navigator&&(globalThis.navigator.language||globalThis.navigator.browserLanguage||globalThis.navigator.userLanguage)||"en",Ys=globalThis.devicePixelRatio||1,Ws=Ms.isMobile,qs=0,Ks=0,Zs=0,Qs=0,Js=0,$s=0;function ta(t){!function(t){ss?t.call(globalThis,[]):(Jr(yr,t,globalThis),rs||("undefined"!=typeof process&&"node"===process.release.name||void 0!==globalThis.document&&"complete"===globalThis.document.readyState?globalThis.setTimeout(as,0):(void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("DOMContentLoaded",as,!1),globalThis.addEventListener("load",as,!1)),rs=!0))}(t)}function ea(t){var e=Os?"pointermove":Ps?"touchmove":"mousemove";!1!==t?!1===Ts&&(globalThis.document.removeEventListener(e,Es),Ts=!0):!0===Ts&&(globalThis.document.addEventListener(e,Es,{passive:!1}),Ts=!1)}function ia(){return!!Fs&&!(!Tn("fullscreenElement",document)&&!document.mozFullScreenElement)}function oa(){var t="portrait",e="landscape",i=globalThis.screen;if(!0===Ls){var o=Tn("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}function na(t){var e=ra(t);return null!==e.parentNode&&(e=e.parentNode),e}function ra(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}function sa(t){return"object"==typeof t&&t!==document.body&&void 0!==t.getBoundingClientRect?t.getBoundingClientRect():(As.width=As.right=globalThis.innerWidth,As.height=As.bottom=globalThis.innerHeight,As)}function aa(t){return sa(na(t))}function ha(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}function la(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"}function ua(){"function"==typeof globalThis.focus&&globalThis.focus()}var ca=Object.freeze({__proto__:null,onDeviceRotate:Cs,platform:Ms,touchEvent:Ps,pointerEvent:Os,touch:Is,maxTouchPoints:ks,wheel:Rs,hasPointerLockSupport:Bs,hasDeviceOrientation:Ds,screenOrientation:Ls,hasAccelerometer:zs,hasFullscreenSupport:Fs,hasWebAudio:js,hasHTML5Audio:Vs,sound:Us,localStorage:Ns,offscreenCanvas:Gs,nativeBase64:Xs,language:Hs,devicePixelRatio:Ys,isMobile:Ws,get accelerationX(){return qs},get accelerationY(){return Ks},get accelerationZ(){return Zs},get gamma(){return Qs},get beta(){return Js},get alpha(){return $s},pauseOnBlur:!0,resumeOnFocus:!0,autoFocus:!0,stopOnBlur:!1,onReady:ta,enableSwipe:ea,isFullscreen:ia,requestFullscreen:function(t){Fs&&!ia()&&((t=t||Xc()).requestFullscreen=Tn("requestFullscreen",t)||t.mozRequestFullScreen,t.requestFullscreen())},exitFullscreen:function(){Fs&&ia()&&document.exitFullscreen()},getScreenOrientation:oa,lockOrientation:function(t){var e=globalThis.screen;if(void 0!==e){var i=Tn("lockOrientation",e);if(void 0!==i)return i(t)}return!1},unlockOrientation:function(){var t=globalThis.screen;if(void 0!==t){var e=Tn("unlockOrientation",t);if(void 0!==e)return e()}return!1},isPortrait:function(){return oa().includes("portrait")},isLandscape:function(){return oa().includes("landscape")},getStorage:function(t){if(void 0===t&&(t="local"),"local"===t)return ns;throw new Error("storage type "+t+" not supported")},getParentElement:na,getElement:ra,getElementBounds:sa,getParentBounds:aa,isWebGLSupported:ha,getMaxShaderPrecision:la,focus:ua,watchAccelerometer:function(){return zs&&!bs&&(DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&(globalThis.addEventListener("devicemotion",Ss,!1),bs=!0)})).catch(console.error):(globalThis.addEventListener("devicemotion",Ss,!1),bs=!0)),bs},unwatchAccelerometer:function(){bs&&(globalThis.removeEventListener("devicemotion",Ss,!1),bs=!1)},watchDeviceOrientation:function(){return Ds&&!ws&&("function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&(globalThis.addEventListener("deviceorientation",Cs,!1),ws=!0)})).catch(console.error):(globalThis.addEventListener("deviceorientation",Cs,!1),ws=!0)),ws},unwatchDeviceOrientation:function(){ws&&(globalThis.removeEventListener("deviceorientation",Cs,!1),ws=!1)},vibrate:function(t){void 0!==globalThis.navigator&&"function"==typeof globalThis.navigator.vibrate&&globalThis.navigator.vibrate(t)}}),pa={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 da(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 fa(t,e){return"precision"!==t.substring(0,9)?"precision "+e+" float;"+t:t}function ya(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 ga=function(t,e,i,o){this.gl=t,this.vertex=fa(ya(e),o||la(this.gl)),this.fragment=fa(ya(i),o||la(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=da(t,t.VERTEX_SHADER,e),r=da(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"+pa[o])}})),Object.defineProperties(o,s),o}(this.gl,this),Qr(qr,this.destroy,this)};ga.prototype.bind=function(){this.gl.useProgram(this.program)},ga.prototype.getAttribLocation=function(t){var e=this.attributes[t];return void 0!==e?e:-1},ga.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},ga.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)}},ga.prototype.destroy=function(){this.uniforms=null,this.attributes=null,this.gl.deleteProgram(this.program),this.vertex=null,this.fragment=null};var va=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)};va.prototype.clear=function(){this.vertexCount=0},va.prototype.isFull=function(t){return void 0===t&&(t=this.quadSize),this.vertexCount+t>=this.maxVertex},va.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},va.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},va.prototype.toFloat32=function(t,e){return void 0!==e?this.bufferF32.subarray(t,e):this.bufferF32},va.prototype.toUint32=function(t,e){return void 0!==e?this.bufferU32.subarray(t,e):this.bufferU32},va.prototype.length=function(){return this.vertexCount},va.prototype.isEmpty=function(){return 0===this.vertexCount};var ma=[new Jn,new Jn,new Jn,new Jn],xa=function(t){this.init(t)};xa.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 ga(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 ga(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 va(this.vertexSize,6),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,this.vertexBuffer.buffer,i.STREAM_DRAW),Qr(Gr,(function(t,i){e.flush(),e.setViewport(0,0,t,i)}))},xa.prototype.reset=function(){this.gl=this.renderer.gl,this.flush(),this.setViewport(0,0,this.renderer.getCanvas().width,this.renderer.getCanvas().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)},xa.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},xa.prototype.setViewport=function(t,e,i,o){this.gl.viewport(t,e,i,o)},xa.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=In(n||e.width)&&In(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},xa.prototype.deleteTexture2D=function(t){this.gl.deleteTexture(t),this.unbindTexture2D(t)},xa.prototype.getTexture2D=function(t){return this.boundTextures[t]},xa.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))},xa.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},xa.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},xa.prototype.setProjection=function(t){this.activeShader.setUniform("uProjectionMatrix",t)},xa.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))},xa.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=ma[0].set(e,i),d=ma[1].set(e+o,i),f=ma[2].set(e,i+n),y=ma[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)}},xa.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()}},xa.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)},xa.prototype.clear=function(t){void 0===t&&(t=0);var e=this.gl;e.clearColor(0,0,0,t),e.clear(e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT)},xa.prototype.clearColor=function(t,e,i,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0);var n=this.gl;n.clearColor(t,e,i,o),n.clear(n.COLOR_BUFFER_BIT)};var _a={exports:{}};function ba(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=wa(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=wa(t,e[n]*o,n<r-1?e[n+1]*o:t.length,o,!1))===s.next&&(s.steiner=!0),a.push(Ra(s));for(a.sort(Pa),n=0;n<a.length;n++)i=Oa(a[n],i);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))?32767/l:0}return Aa(p,d,i,o,n,l,0),d}function wa(t,e,i,o,n){var r,s;if(n===Ya(t,e,i,o)>0)for(r=e;r<i;r+=o)s=Ga(r,t[r],t[r+1],s);else for(r=i-o;r>=e;r-=o)s=Ga(r,t[r],t[r+1],s);return s&&za(s,s.next)&&(Xa(s),s=s.next),s}function Ta(t,e){if(!t)return t;e||(e=t);var i,o=t;do{if(i=!1,o.steiner||!za(o,o.next)&&0!==La(o.prev,o,o.next))o=o.next;else{if(Xa(o),(o=e=o.prev)===o.next)break;i=!0}}while(i||o!==e);return e}function Aa(t,e,i,o,n,r,s){if(t){!s&&r&&function(t,e,i,o){var n=t;do{0===n.z&&(n.z=ka(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?Sa(t,o,n,r):Ea(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(h.i/i|0),Xa(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?Aa(t=Ca(Ta(t),e,i),e,i,o,n,r,2):2===s&&Ma(t,e,i,o,n,r):Aa(Ta(t),e,i,o,n,r,1);break}}}function Ea(t){var e=t.prev,i=t,o=t.next;if(La(e,i,o)>=0)return!1;for(var n=e.x,r=i.x,s=o.x,a=e.y,h=i.y,l=o.y,u=n<r?n<s?n:s:r<s?r:s,c=a<h?a<l?a:l:h<l?h:l,p=n>r?n>s?n:s:r>s?r:s,d=a>h?a>l?a:l:h>l?h:l,f=o.next;f!==e;){if(f.x>=u&&f.x<=p&&f.y>=c&&f.y<=d&&Ba(n,a,r,h,s,l,f.x,f.y)&&La(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Sa(t,e,i,o){var n=t.prev,r=t,s=t.next;if(La(n,r,s)>=0)return!1;for(var a=n.x,h=r.x,l=s.x,u=n.y,c=r.y,p=s.y,d=a<h?a<l?a:l:h<l?h:l,f=u<c?u<p?u:p:c<p?c:p,y=a>h?a>l?a:l:h>l?h:l,g=u>c?u>p?u:p:c>p?c:p,v=ka(d,f,e,i,o),m=ka(y,g,e,i,o),x=t.prevZ,_=t.nextZ;x&&x.z>=v&&_&&_.z<=m;){if(x.x>=d&&x.x<=y&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&Ba(a,u,h,c,l,p,x.x,x.y)&&La(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,_.x>=d&&_.x<=y&&_.y>=f&&_.y<=g&&_!==n&&_!==s&&Ba(a,u,h,c,l,p,_.x,_.y)&&La(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=d&&x.x<=y&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&Ba(a,u,h,c,l,p,x.x,x.y)&&La(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=m;){if(_.x>=d&&_.x<=y&&_.y>=f&&_.y<=g&&_!==n&&_!==s&&Ba(a,u,h,c,l,p,_.x,_.y)&&La(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Ca(t,e,i){var o=t;do{var n=o.prev,r=o.next.next;!za(n,r)&&Fa(n,o,o.next,r)&&Ua(n,r)&&Ua(r,n)&&(e.push(n.i/i|0),e.push(o.i/i|0),e.push(r.i/i|0),Xa(o),Xa(o.next),o=t=r),o=o.next}while(o!==t);return Ta(o)}function Ma(t,e,i,o,n,r){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Da(s,a)){var h=Na(s,a);return s=Ta(s,s.next),h=Ta(h,h.next),Aa(s,e,i,o,n,r,0),void Aa(h,e,i,o,n,r,0)}a=a.next}s=s.next}while(s!==t)}function Pa(t,e){return t.x-e.x}function Oa(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&&(s=a,i=o.x<o.next.x?o:o.next,a===n))return i}o=o.next}while(o!==e);if(!i)return null;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&&Ba(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),Ua(o,t)&&(h<p||h===p&&(o.x>i.x||o.x===i.x&&Ia(i,o)))&&(i=o,p=h)),o=o.next}while(o!==l);return i}(t,e);if(!i)return e;var o=Na(i,t);return Ta(o,o.next),Ta(i,i.next)}function Ia(t,e){return La(t.prev,t,e.prev)<0&&La(e.next,t,t.next)<0}function ka(t,e,i,o,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ra(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 Ba(t,e,i,o,n,r,s,a){return(n-s)*(e-a)>=(t-s)*(r-a)&&(t-s)*(o-a)>=(i-s)*(e-a)&&(i-s)*(r-a)>=(n-s)*(o-a)}function Da(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&&Fa(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Ua(t,e)&&Ua(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)&&(La(t.prev,t,e.prev)||La(t,e.prev,e))||za(t,e)&&La(t.prev,t,t.next)>0&&La(e.prev,e,e.next)>0)}function La(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function za(t,e){return t.x===e.x&&t.y===e.y}function Fa(t,e,i,o){var n=Va(La(t,e,i)),r=Va(La(t,e,o)),s=Va(La(i,o,t)),a=Va(La(i,o,e));return n!==r&&s!==a||(!(0!==n||!ja(t,i,e))||(!(0!==r||!ja(t,o,e))||(!(0!==s||!ja(i,t,o))||!(0!==a||!ja(i,e,o)))))}function ja(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 Va(t){return t>0?1:t<0?-1:0}function Ua(t,e){return La(t.prev,t,t.next)<0?La(t,e,t.next)>=0&&La(t,t.prev,e)>=0:La(t,e,t.prev)<0||La(t,t.next,e)<0}function Na(t,e){var i=new Ha(t.i,t.x,t.y),o=new Ha(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 Ga(t,e,i,o){var n=new Ha(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 Xa(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 Ha(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ya(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}_a.exports=ba,_a.exports.default=ba,ba.deviation=function(t,e,i,o){var n=e&&e.length,r=n?e[0]*i:t.length,s=Math.abs(Ya(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(Ya(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)},ba.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 Wa=function(t,e,i){this.pos=Qn.pull("Vector2d"),this._bounds,this.points=[],this.edges=[],this.indices=[],this.normals=[],this.shapeType="Polygon",this.setShape(t,e,i)};Wa.prototype.onResetEvent=function(t,e,i){this.setShape(t,e,i)},Wa.prototype.setShape=function(t,e,i){return this.pos.set(t,e),this.setVertices(i),this},Wa.prototype.setVertices=function(t){var e=this;if(!Array.isArray(t))return this;if(t[0]instanceof Jn)this.points=t;else if(this.points.length=0,"object"==typeof t[0])t.forEach((function(t){e.points.push(Qn.pull("Vector2d",t.x,t.y))}));else for(var i=0;i<t.length;i+=2)this.points.push(Qn.pull("Vector2d",t[i],t[i+1]));return this.recalc(),this.updateBounds(),this},Wa.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},Wa.prototype.toIso=function(){return this.rotate(Math.PI/4).scale(Math.SQRT2,Math.SQRT1_2)},Wa.prototype.to2d=function(){return this.scale(Math.SQRT1_2,Math.SQRT2).rotate(-Math.PI/4)},Wa.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},Wa.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},Wa.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Wa.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]=Qn.pull("Vector2d")),e[t].copy(n[(t+1)%r]).sub(n[t]),void 0===i[t]&&(i[t]=Qn.pull("Vector2d")),i[t].copy(e[t]).perp().normalize();return e.length=r,i.length=r,o.length=0,this},Wa.prototype.getIndices=function(){return 0===this.indices.length&&(this.indices=_a.exports(this.points.flatMap((function(t){return[t.x,t.y]})))),this.indices},Wa.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},Wa.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},Wa.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()},Wa.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},Wa.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=Qn.pull("Bounds")),this._bounds},Wa.prototype.updateBounds=function(){var t=this.getBounds();return t.update(this.points),t.translate(this.pos),t},Wa.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new Wa(this.pos.x,this.pos.y,t)};var qa=function(t){function e(e,i,o,n){t.call(this,e,i,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",o,0),Qn.pull("Vector2d",o,n),Qn.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 Qn.pull("Polygon",this.pos.x,this.pos.y,this.points)},Object.defineProperties(e.prototype,i),e}(Wa),Ka=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}(qa),Za=function(t,e,i,o){this.pos=Qn.pull("Vector2d"),this._bounds=void 0,this.radius=NaN,this.radiusV=Qn.pull("Vector2d"),this.radiusSq=Qn.pull("Vector2d"),this.ratio=Qn.pull("Vector2d"),this.shapeType="Ellipse",this.setShape(t,e,i,o)};Za.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},Za.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},Za.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},Za.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)},Za.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Za.prototype.transform=function(t){return this},Za.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},Za.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},Za.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=Qn.pull("Bounds")),this._bounds},Za.prototype.clone=function(){return new Za(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)};var Qa=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]=Qn.pull("Vector2d")),t[0].copy(o[1]).sub(o[0]),void 0===e[0]&&(e[0]=Qn.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}(Wa),Ja=function(t){this._center=new Jn,this.onResetEvent(t)},$a={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}};Ja.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)},Ja.prototype.clear=function(){this.setMinMax(1/0,1/0,-1/0,-1/0)},Ja.prototype.setMinMax=function(t,e,i,o){this.min.x=t,this.min.y=e,this.max.x=i,this.max.y=o},$a.x.get=function(){return this.min.x},$a.x.set=function(t){var e=this.max.x-this.min.x;this.min.x=t,this.max.x=t+e},$a.y.get=function(){return this.min.y},$a.y.set=function(t){var e=this.max.y-this.min.y;this.min.y=t,this.max.y=t+e},$a.width.get=function(){return this.max.x-this.min.x},$a.width.set=function(t){this.max.x=this.min.x+t},$a.height.get=function(){return this.max.y-this.min.y},$a.height.set=function(t){this.max.y=this.min.y+t},$a.left.get=function(){return this.min.x},$a.right.get=function(){return this.max.x},$a.top.get=function(){return this.min.y},$a.bottom.get=function(){return this.max.y},$a.centerX.get=function(){return this.min.x+this.width/2},$a.centerY.get=function(){return this.min.y+this.height/2},$a.center.get=function(){return this._center.set(this.centerX,this.centerY)},Ja.prototype.update=function(t){this.add(t,!0)},Ja.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)}},Ja.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)},Ja.prototype.addPoint=function(t,e){void 0!==e&&"function"==typeof t.rotate&&(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)},Ja.prototype.addFrame=function(t,e,i,o,n){var r=Qn.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),Qn.push(r)},Ja.prototype.contains=function(){var t,e,i,o,n=arguments[0];return 2===arguments.length?(t=e=n,i=o=arguments[1]):n instanceof Ja?(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},Ja.prototype.overlaps=function(t){return!(this.right<t.left||this.left>t.right||this.bottom<t.top||this.top>t.bottom)},Ja.prototype.isFinite=function(){return isFinite(this.min.x)&&isFinite(this.max.x)&&isFinite(this.min.y)&&isFinite(this.max.y)},Ja.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},Ja.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},Ja.prototype.clone=function(){var t=new Ja;return t.addBounds(this),t},Ja.prototype.toPolygon=function(){return Qn.pull("Polygon",this.x,this.y,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height),Qn.pull("Vector2d",0,this.height)])},Object.defineProperties(Ja.prototype,$a);var th=function(){this.points=[],this.arcResolution=5,this.vertices=[]};th.prototype.beginPath=function(){this.points.forEach((function(t){Qn.push(t)})),this.points.length=0},th.prototype.closePath=function(){var t=this.points;t.length>1&&!t[t.length-1].equals(t[0])&&t.push(Qn.pull("Vector2d",t[0].x,t[0].y))},th.prototype.triangulatePath=function(){var t=0,e=this.points,i=this.vertices,o=_a.exports(e.flatMap((function(t){return[t.x,t.y]})));for(t=0;t<o.length;t++)void 0===i[t]&&(i[t]=Qn.pull("Vector2d")),i[t].set(e[o[t]].x,e[o[t]].y);for(;i.length>o.length;)Qn.push(i[i.length-1]),i.length-=1;return i},th.prototype.moveTo=function(t,e){this.points.push(Qn.pull("Vector2d",t,e))},th.prototype.lineTo=function(t,e){this.points.push(Qn.pull("Vector2d",t,e))},th.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)>=Mn:Math.abs(n-o)>=Mn;(o%=Mn)<0&&(o+=Mn),(n%=Mn)<0&&(n+=Mn),o>=n&&(n+=Mn);var h=n-o,l=1;r&&(l=-1,h=Mn-h),a&&(h=Mn);for(var u=h*i/this.arcResolution,c=h/u,p=o,d=0;d<u;d++)s.push(Qn.pull("Vector2d",t+i*Math.cos(p),e+i*Math.sin(p))),p+=l*c;s.push(Qn.pull("Vector2d",t+i*Math.cos(n),e+i*Math.sin(n)))}},th.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(Qn.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]),x=Math.atan2(d[1]-v[1],d[0]-v[0]);this.arc(v[0],v[1],n,m,x)},th.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)>=Mn:Math.abs(s-r)>=Mn;(r%=Mn)<0&&(r+=Mn),(s%=Mn)<0&&(s+=Mn),r>=s&&(s+=Mn);var u=s-r,c=1;a&&(c=-1,u=Mn-u),l&&(u=Mn);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),x=o*Math.sin(f),_=t+m*y-x*g,b=e+m*g+x*y;h.push(Qn.pull("Vector2d",_,b)),f+=c*d}}},th.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)},th.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 eh=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e};eh.prototype.onResetEvent=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.set(t,e)},eh.prototype.set=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},eh.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},eh.prototype.clone=function(){return new eh(this.x,this.y)};var ih=function(t){this.settings=t,this.isContextValid=!0,this.path2D=new th,this.currentScissor=new Int32Array([0,0,this.settings.width,this.settings.height]),this.maskLevel=0,this.currentBlendMode="none",void 0!==globalThis.canvas?this.canvas=globalThis.canvas:void 0!==this.settings.canvas?this.canvas=this.settings.canvas:this.canvas=Gc(this.settings.width,this.settings.height),this.currentColor=new ar(0,0,0,1),this.currentTint=new ar(255,255,255,1),this.projectionMatrix=new lr,this.uvOffset=0,Qr(Ar,(function(){Nc.reset()}))};ih.prototype.clear=function(){},ih.prototype.flush=function(){},ih.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.getCanvas().width,this.currentScissor[3]=this.getCanvas().height,this.clearMask()},ih.prototype.getCanvas=function(){return this.canvas},ih.prototype.getContext=function(){return this.context},ih.prototype.getBlendMode=function(){return this.currentBlendMode},ih.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},ih.prototype.getWidth=function(){return this.getCanvas().width},ih.prototype.getHeight=function(){return this.getCanvas().height},ih.prototype.getColor=function(){return this.currentColor},ih.prototype.globalAlpha=function(){return this.currentColor.glArray[3]},ih.prototype.overlaps=function(t){return t.left<=this.getWidth()&&t.right>=0&&t.top<=this.getHeight()&&t.bottom>=0},ih.prototype.resize=function(t,e){var i=this.getCanvas();t===i.width&&e===i.height||(i.width=t,i.height=e,this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=t,this.currentScissor[3]=e,Zr(Gr,t,e))},ih.prototype.setAntiAlias=function(t,e){var i=t.canvas;An("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"},ih.prototype.setProjection=function(t){this.projectionMatrix.copy(t)},ih.prototype.stroke=function(t,e){if(t instanceof Ka)this.strokeRoundRect(t.left,t.top,t.width,t.height,t.radius,e);else if(t instanceof qa||t instanceof Ja)this.strokeRect(t.left,t.top,t.width,t.height,e);else if(t instanceof Qa||t instanceof Wa)this.strokePolygon(t,e);else if(t instanceof Za)this.strokeEllipse(t.pos.x,t.pos.y,t.radiusV.x,t.radiusV.y,e);else{if(!(t instanceof eh))throw new Error("Invalid geometry for fill/stroke");this.strokePoint(t.x,t.y)}},ih.prototype.fill=function(t){this.stroke(t,!0)},ih.prototype.tint=function(t,e,i){var o=Gc(t.width,t.height,!0),n=this.getContext2d(o);return n.save(),n.fillStyle=e instanceof ar?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},ih.prototype.setMask=function(t){},ih.prototype.clearMask=function(){},ih.prototype.setTint=function(t,e){void 0===e&&(e=t.alpha),this.currentTint.copy(t),this.currentTint.alpha*=e},ih.prototype.clearTint=function(){this.currentTint.setColor(255,255,255,1)},ih.prototype.drawFont=function(){};var oh={};
|
|
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,x=Function.prototype,_=x.bind,b=x.call,w=m&&_.bind(b,b),T=m?function(t){return t&&w(t)}:function(t){return t&&function(){return b.apply(t,arguments)}},A=T,E=A({}.toString),S=A("".slice),C=function(t){return S(E(t),8,-1)},M=r,P=C,O=Object,I=T("".split),k=M((function(){return!O("z").propertyIsEnumerable(0)}))?function(t){return"String"==P(t)?I(t,""):O(t)}:O,R=function(t){return null==t},B=R,D=TypeError,L=function(t){if(B(t))throw D("Can't call method on "+t);return t},z=k,F=L,j=function(t){return z(F(t))},V="object"==typeof document&&document.all,U={all:V,IS_HTMLDDA:void 0===V&&void 0!==V},N=U.all,G=U.IS_HTMLDDA?function(t){return"function"==typeof t||t===N}:function(t){return"function"==typeof t},X=G,H=U.all,Y=U.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:X(t)||t===H}:function(t){return"object"==typeof t?null!==t:X(t)},W=o,q=G,K=function(t){return q(t)?t:void 0},Z=function(t,e){return arguments.length<2?K(W[t]):W[t]&&W[t][e]},Q=T({}.isPrototypeOf),J=o,$=Z("navigator","userAgent")||"",tt=J.process,et=J.Deno,it=tt&&tt.versions||et&&et.version,ot=it&&it.v8;ot&&(g=(y=ot.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!g&&$&&(!(y=$.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=$.match(/Chrome\/(\d+)/))&&(g=+y[1]);var nt=g,rt=r,st=!!Object.getOwnPropertySymbols&&!rt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&nt&&nt<41})),at=st&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ht=Z,lt=G,ut=Q,ct=Object,pt=at?function(t){return"symbol"==typeof t}:function(t){var e=ht("Symbol");return lt(e)&&ut(e.prototype,ct(t))},dt=String,ft=G,yt=function(t){try{return dt(t)}catch(t){return"Object"}},gt=TypeError,vt=function(t){if(ft(t))return t;throw gt(yt(t)+" is not a function")},mt=R,xt=u,_t=G,bt=Y,wt=TypeError,Tt={exports:{}},At=o,Et=Object.defineProperty,St=function(t,e){try{Et(At,t,{value:e,configurable:!0,writable:!0})}catch(i){At[t]=e}return e},Ct=St,Mt="__core-js_shared__",Pt=o[Mt]||Ct(Mt,{}),Ot=Pt;(Tt.exports=function(t,e){return Ot[t]||(Ot[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.25.3",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.3/LICENSE",source:"https://github.com/zloirock/core-js"});var It=L,kt=Object,Rt=function(t){return kt(It(t))},Bt=T({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return Bt(Rt(t),e)},Lt=T,zt=0,Ft=Math.random(),jt=Lt(1..toString),Vt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+jt(++zt+Ft,36)},Ut=o,Nt=Tt.exports,Gt=Dt,Xt=Vt,Ht=st,Yt=at,Wt=Nt("wks"),qt=Ut.Symbol,Kt=qt&&qt.for,Zt=Yt?qt:qt&&qt.withoutSetter||Xt,Qt=function(t){if(!Gt(Wt,t)||!Ht&&"string"!=typeof Wt[t]){var e="Symbol."+t;Ht&&Gt(qt,t)?Wt[t]=qt[t]:Wt[t]=Yt&&Kt?Kt(e):Zt(e)}return Wt[t]},Jt=u,$t=Y,te=pt,ee=function(t,e){var i=t[e];return mt(i)?void 0:vt(i)},ie=function(t,e){var i,o;if("string"===e&&_t(i=t.toString)&&!bt(o=xt(i,t)))return o;if(_t(i=t.valueOf)&&!bt(o=xt(i,t)))return o;if("string"!==e&&_t(i=t.toString)&&!bt(o=xt(i,t)))return o;throw wt("Can't convert object to primitive value")},oe=TypeError,ne=Qt("toPrimitive"),re=function(t,e){if(!$t(t)||te(t))return t;var i,o=ee(t,ne);if(o){if(void 0===e&&(e="default"),i=Jt(o,t,e),!$t(i)||te(i))return i;throw oe("Can't convert object to primitive value")}return void 0===e&&(e="number"),ie(t,e)},se=pt,ae=function(t){var e=re(t,"string");return se(e)?e:e+""},he=Y,le=o.document,ue=he(le)&&he(le.createElement),ce=function(t){return ue?le.createElement(t):{}},pe=!s&&!r((function(){return 7!=Object.defineProperty(ce("div"),"a",{get:function(){return 7}}).a})),de=s,fe=u,ye=c,ge=v,ve=j,me=ae,xe=Dt,_e=pe,be=Object.getOwnPropertyDescriptor;n.f=de?be:function(t,e){if(t=ve(t),e=me(e),_e)try{return be(t,e)}catch(t){}if(xe(t,e))return ge(!fe(ye.f,t,e),t[e])};var we={},Te=s&&r((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Ae=Y,Ee=String,Se=TypeError,Ce=function(t){if(Ae(t))return t;throw Se(Ee(t)+" is not an object")},Me=s,Pe=pe,Oe=Te,Ie=Ce,ke=ae,Re=TypeError,Be=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Le="enumerable",ze="configurable",Fe="writable";we.f=Me?Oe?function(t,e,i){if(Ie(t),e=ke(e),Ie(i),"function"==typeof t&&"prototype"===e&&"value"in i&&Fe in i&&!i.writable){var o=De(t,e);o&&o.writable&&(t[e]=i.value,i={configurable:ze in i?i.configurable:o.configurable,enumerable:Le in i?i.enumerable:o.enumerable,writable:!1})}return Be(t,e,i)}:Be:function(t,e,i){if(Ie(t),e=ke(e),Ie(i),Pe)try{return Be(t,e,i)}catch(t){}if("get"in i||"set"in i)throw Re("Accessors not supported");return"value"in i&&(t[e]=i.value),t};var je=we,Ve=v,Ue=s?function(t,e,i){return je.f(t,e,Ve(1,i))}:function(t,e,i){return t[e]=i,t},Ne={exports:{}},Ge=s,Xe=Dt,He=Function.prototype,Ye=Ge&&Object.getOwnPropertyDescriptor,We=Xe(He,"name"),qe={EXISTS:We,PROPER:We&&"something"===function(){}.name,CONFIGURABLE:We&&(!Ge||Ge&&Ye(He,"name").configurable)},Ke=G,Ze=Pt,Qe=T(Function.toString);Ke(Ze.inspectSource)||(Ze.inspectSource=function(t){return Qe(t)});var Je,$e,ti,ei=Ze.inspectSource,ii=G,oi=o.WeakMap,ni=ii(oi)&&/native code/.test(String(oi)),ri=Tt.exports,si=Vt,ai=ri("keys"),hi={},li=ni,ui=o,ci=T,pi=Y,di=Ue,fi=Dt,yi=Pt,gi=function(t){return ai[t]||(ai[t]=si(t))},vi=hi,mi="Object already initialized",xi=ui.TypeError,_i=ui.WeakMap;if(li||yi.state){var bi=yi.state||(yi.state=new _i),wi=ci(bi.get),Ti=ci(bi.has),Ai=ci(bi.set);Je=function(t,e){if(Ti(bi,t))throw xi(mi);return e.facade=t,Ai(bi,t,e),e},$e=function(t){return wi(bi,t)||{}},ti=function(t){return Ti(bi,t)}}else{var Ei=gi("state");vi[Ei]=!0,Je=function(t,e){if(fi(t,Ei))throw xi(mi);return e.facade=t,di(t,Ei,e),e},$e=function(t){return fi(t,Ei)?t[Ei]:{}},ti=function(t){return fi(t,Ei)}}var Si={set:Je,get:$e,has:ti,enforce:function(t){return ti(t)?$e(t):Je(t,{})},getterFor:function(t){return function(e){var i;if(!pi(e)||(i=$e(e)).type!==t)throw xi("Incompatible receiver, "+t+" required");return i}}},Ci=r,Mi=G,Pi=Dt,Oi=s,Ii=qe.CONFIGURABLE,ki=ei,Ri=Si.enforce,Bi=Si.get,Di=Object.defineProperty,Li=Oi&&!Ci((function(){return 8!==Di((function(){}),"length",{value:8}).length})),zi=String(String).split("String"),Fi=Ne.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),(!Pi(t,"name")||Ii&&t.name!==e)&&(Oi?Di(t,"name",{value:e,configurable:!0}):t.name=e),Li&&i&&Pi(i,"arity")&&t.length!==i.arity&&Di(t,"length",{value:i.arity});try{i&&Pi(i,"constructor")&&i.constructor?Oi&&Di(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=Ri(t);return Pi(o,"source")||(o.source=zi.join("string"==typeof e?e:"")),t};Function.prototype.toString=Fi((function(){return Mi(this)&&Bi(this).source||ki(this)}),"toString");var ji=G,Vi=we,Ui=Ne.exports,Ni=St,Gi={},Xi=Math.ceil,Hi=Math.floor,Yi=Math.trunc||function(t){var e=+t;return(e>0?Hi:Xi)(e)},Wi=Yi,qi=function(t){var e=+t;return e!=e||0===e?0:Wi(e)},Ki=qi,Zi=Math.max,Qi=Math.min,Ji=qi,$i=Math.min,to=function(t){return t>0?$i(Ji(t),9007199254740991):0},eo=j,io=function(t,e){var i=Ki(t);return i<0?Zi(i+e,0):Qi(i,e)},oo=function(t){return to(t.length)},no=function(t){return function(e,i,o){var n,r=eo(e),s=oo(r),a=io(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}},ro={includes:no(!0),indexOf:no(!1)},so=Dt,ao=j,ho=ro.indexOf,lo=hi,uo=T([].push),co=function(t,e){var i,o=ao(t),n=0,r=[];for(i in o)!so(lo,i)&&so(o,i)&&uo(r,i);for(;e.length>n;)so(o,i=e[n++])&&(~ho(r,i)||uo(r,i));return r},po=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Gi.f=Object.getOwnPropertyNames||function(t){return co(t,po)};var fo={};fo.f=Object.getOwnPropertySymbols;var yo=Z,go=Gi,vo=fo,mo=Ce,xo=T([].concat),_o=yo("Reflect","ownKeys")||function(t){var e=go.f(mo(t)),i=vo.f;return i?xo(e,i(t)):e},bo=Dt,wo=_o,To=n,Ao=we,Eo=r,So=G,Co=/#|\.prototype\./,Mo=function(t,e){var i=Oo[Po(t)];return i==ko||i!=Io&&(So(e)?Eo(e):!!e)},Po=Mo.normalize=function(t){return String(t).replace(Co,".").toLowerCase()},Oo=Mo.data={},Io=Mo.NATIVE="N",ko=Mo.POLYFILL="P",Ro=Mo,Bo=o,Do=n.f,Lo=Ue,zo=function(t,e,i,o){o||(o={});var n=o.enumerable,r=void 0!==o.name?o.name:e;if(ji(i)&&Ui(i,r,o),o.global)n?t[e]=i:Ni(e,i);else{try{o.unsafe?t[e]&&(n=!0):delete t[e]}catch(t){}n?t[e]=i:Vi.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return t},Fo=St,jo=function(t,e,i){for(var o=wo(e),n=Ao.f,r=To.f,s=0;s<o.length;s++){var a=o[s];bo(t,a)||i&&bo(i,a)||n(t,a,r(e,a))}},Vo=Ro,Uo=function(t,e){var i,o,n,r,s,a=t.target,h=t.global,l=t.stat;if(i=h?Bo:l?Bo[a]||Fo(a,{}):(Bo[a]||{}).prototype)for(o in e){if(r=e[o],n=t.dontCallGetSet?(s=Do(i,o))&&s.value:i[o],!Vo(h?o:a+(l?".":"#")+o,t.forced)&&void 0!==n){if(typeof r==typeof n)continue;jo(r,n)}(t.sham||n&&n.sham)&&Lo(r,"sham",!0),zo(i,o,r,t)}},No=o;Uo({global:!0,forced:No.globalThis!==No},{globalThis:No});var Go={};Go[Qt("toStringTag")]="z";var Xo="[object z]"===String(Go),Ho=G,Yo=C,Wo=Qt("toStringTag"),qo=Object,Ko="Arguments"==Yo(function(){return arguments}()),Zo=Xo?Yo:function(t){var e,i,o;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=qo(t),Wo))?i:Ko?Yo(e):"Object"==(o=Yo(e))&&Ho(e.callee)?"Arguments":o},Qo=String,Jo="\t\n\v\f\r \u2028\u2029\ufeff",$o=L,tn=function(t){if("Symbol"===Zo(t))throw TypeError("Cannot convert a Symbol value to a string");return Qo(t)},en=T("".replace),on="[\t\n\v\f\r \u2028\u2029\ufeff]",nn=RegExp("^"+on+on+"*"),rn=RegExp(on+on+"*$"),sn=function(t){return function(e){var i=tn($o(e));return 1&t&&(i=en(i,nn,"")),2&t&&(i=en(i,rn,"")),i}},an={start:sn(1),end:sn(2),trim:sn(3)},hn=qe.PROPER,ln=r,un=Jo,cn=function(t){return ln((function(){return!!un[t]()||"
"!=="
"[t]()||hn&&un[t].name!==t}))},pn=an.start,dn=cn("trimStart")?function(){return pn(this)}:"".trimStart;Uo({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==dn},{trimLeft:dn});Uo({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==dn},{trimStart:dn});var fn=o,yn=T,gn=function(t,e){return yn(fn[t].prototype[e])};gn("String","trimLeft");var vn=an.end,mn=cn("trimEnd")?function(){return vn(this)}:"".trimEnd;Uo({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==mn},{trimRight:mn});if(Uo({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==mn},{trimEnd:mn}),gn("String","trimRight"),"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 xn=Date.now();performance.timing&&performance.timing.navigationStart&&(xn=performance.timing.navigationStart),globalThis.performance.now=function(){return Date.now()-xn}}function _n(t){return t.charAt(0).toUpperCase()+t.slice(1)}function bn(t){return"string"==typeof t&&(t=t.trim()),!isNaN(t)&&/[+-]?([0-9]*[.])?[0-9]+/.test(t)}function wn(t){var e=t.trim();return"true"===e||"false"===e}function Tn(t){for(var e="",i=0;i<t.length;)e+=t.charCodeAt(i++).toString(16);return e}function An(t){return/^data:(.+);base64,(.+)$/.test(t)}var En=Object.freeze({__proto__:null,capitalize:_n,isNumeric:bn,isBoolean:wn,toHex:Tn,isDataUrl:An}),Sn=["ms","MS","moz","webkit","o"];function Cn(t,e){if(t in(e=e||globalThis))return e[t];var i,o=_n(t);return Sn.some((function(t){var n=t+o;return i=n in e?e[n]:void 0})),i}function Mn(t,e,i){if(!(t in(i=i||globalThis))){var o=_n(t);return Sn.some((function(t){var n=t+o;if(n in i)return i[n]=e,!0})),!1}i[t]=e}var Pn=Object.freeze({__proto__:null,prefixed:Cn,setPrefixed:Mn}),On=Math.PI/180,In=180/Math.PI,kn=2*Math.PI,Rn=.5*Math.PI,Bn=1e-6;function Dn(t){return 0==(t&t-1)}function Ln(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function zn(t){return t*On}function Fn(t,e,i){return t<e?e:t>i?i:+t}function jn(t,e){return~~(Math.random()*(e-t))+t}function Vn(t,e){return Math.random()*(e-t)+t}function Un(t,e){return~~(Math.pow(Math.random(),2)*(e-t))+t}function Nn(t,e,i){return void 0===i&&(i=2),Math.abs(t-e)<Math.pow(10,-i)/2}var Gn=Object.freeze({__proto__:null,DEG_TO_RAD:On,RAD_TO_DEG:In,TAU:kn,ETA:Rn,EPSILON:Bn,isPowerOfTwo:Dn,nextPowerOfTwo:Ln,degToRad:zn,radToDeg:function(t){return t*In},clamp:Fn,random:jn,randomFloat:Vn,weightedRandom:Un,round:function(t,e){void 0===e&&(e=0);var i=Math.pow(10,e);return~~(.5+t*i)/i},toBeCloseTo:Nn});function Xn(t,e){var i=Array.prototype.indexOf.call(t,e);return-1!==i&&Array.prototype.splice.call(t,i,1),t}var Hn=Object.freeze({__proto__:null,remove:Xn,random:function(t){return t[jn(0,t.length)]},weightedRandom:function(t){return t[Un(0,t.length)]}}),Yn=/^.*(\\|\/|\:)/,Wn=/\.[^\.]*$/;function qn(t){return t.replace(Yn,"").replace(Wn,"")}function Kn(t){return t.substring(t.lastIndexOf(".")+1,t.length)}var Zn=Object.freeze({__proto__:null,getBasename:qn,getExtension:Kn});function Qn(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 Jn(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 $n=Object.freeze({__proto__:null,defer:Qn,throttle:Jn}),tr=function(){this.objectClass={},this.instance_counter=0};tr.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}},tr.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+"'")},tr.prototype.purge=function(){for(var t in this.objectClass)this.objectClass[t]&&(this.objectClass[t].pool=[]);this.instance_counter=0},tr.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},tr.prototype.exists=function(t){return t in this.objectClass},tr.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},tr.prototype.getInstanceCount=function(){return this.instance_counter};var er=new tr,ir=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.onResetEvent(t,e)};function or(t){return"0123456789ABCDEF".charAt(t-t%16>>4)+"0123456789ABCDEF".charAt(t%16)}function nr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}ir.prototype.onResetEvent=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},ir.prototype._set=function(t,e){return this.x=t,this.y=e,this},ir.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)},ir.prototype.setZero=function(){return this.set(0,0)},ir.prototype.setV=function(t){return this._set(t.x,t.y)},ir.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y)},ir.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y)},ir.prototype.scale=function(t,e){return this._set(this.x*t,this.y*(void 0!==e?e:t))},ir.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y))},ir.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2)},ir.prototype.scaleV=function(t){return this._set(this.x*t.x,this.y*t.y)},ir.prototype.div=function(t){return this._set(this.x/t,this.y/t)},ir.prototype.abs=function(){return this._set(this.x<0?-this.x:this.x,this.y<0?-this.y:this.y)},ir.prototype.clamp=function(t,e){return new ir(Fn(this.x,t,e),Fn(this.y,t,e))},ir.prototype.clampSelf=function(t,e){return this._set(Fn(this.x,t,e),Fn(this.y,t,e))},ir.prototype.minV=function(t){return this._set(this.x<t.x?this.x:t.x,this.y<t.y?this.y:t.y)},ir.prototype.maxV=function(t){return this._set(this.x>t.x?this.x:t.x,this.y>t.y?this.y:t.y)},ir.prototype.floor=function(){return new ir(Math.floor(this.x),Math.floor(this.y))},ir.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y))},ir.prototype.ceil=function(){return new ir(Math.ceil(this.x),Math.ceil(this.y))},ir.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y))},ir.prototype.negate=function(){return new ir(-this.x,-this.y)},ir.prototype.negateSelf=function(){return this._set(-this.x,-this.y)},ir.prototype.copy=function(t){return this._set(t.x,t.y)},ir.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},ir.prototype.normalize=function(){return this.div(this.length()||1)},ir.prototype.perp=function(){return this._set(this.y,-this.x)},ir.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)},ir.prototype.dot=function(t){return this.x*t.x+this.y*t.y},ir.prototype.cross=function(t){return this.x*t.y-this.y*t.x},ir.prototype.length2=function(){return this.dot(this)},ir.prototype.length=function(){return Math.sqrt(this.length2())},ir.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},ir.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this.y,t.x-this.x),o=this.distance(t);return 0===o||e>=0&&o<=e*e?t:(this.x+=Math.cos(i)*e,this.y+=Math.sin(i)*e,this)},ir.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},ir.prototype.angle=function(t){return Math.acos(Fn(this.dot(t)/(this.length()*t.length()),-1,1))},ir.prototype.project=function(t){return this.scale(this.dot(t)/t.length2())},ir.prototype.projectN=function(t){return this.scale(this.dot(t))},ir.prototype.clone=function(){return er.pull("Vector2d",this.x,this.y)},ir.prototype.toString=function(){return"x:"+this.x+",y:"+this.y};var rr=/^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/,sr=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,ar=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])([\da-fA-F])$/,hr=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,lr=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/,ur=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){ur.set(t[0],t[1])}));var cr=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)},pr={r:{configurable:!0},g:{configurable:!0},b:{configurable:!0},alpha:{configurable:!0}};cr.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)},pr.r.get=function(){return~~(255*this.glArray[0])},pr.r.set=function(t){this.glArray[0]=Fn(~~t||0,0,255)/255},pr.g.get=function(){return~~(255*this.glArray[1])},pr.g.set=function(t){this.glArray[1]=Fn(~~t||0,0,255)/255},pr.b.get=function(){return~~(255*this.glArray[2])},pr.b.set=function(t){this.glArray[2]=Fn(~~t||0,0,255)/255},pr.alpha.get=function(){return this.glArray[3]},pr.alpha.set=function(t){this.glArray[3]=void 0===t?1:Fn(+t,0,1)},cr.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},cr.prototype.setHSV=function(t,e,i){var o,n,r,s=Math.floor(6*t),a=6*t-s,h=i*(1-e),l=i*(1-a*e),u=i*(1-(1-a)*e);switch(s%6){case 0:o=i,n=u,r=h;break;case 1:o=l,n=i,r=h;break;case 2:o=h,n=i,r=u;break;case 3:o=h,n=l,r=i;break;case 4:o=u,n=h,r=i;break;case 5:o=i,n=h,r=l}return this.setColor(255*o,255*n,255*r)},cr.prototype.setHSL=function(t,e,i){var o,n,r;if(0===e)o=n=r=i;else{var s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;o=nr(a,s,t+1/3),n=nr(a,s,t),r=nr(a,s,t-1/3)}return this.setColor(255*o,255*n,255*r)},cr.prototype.clone=function(){return er.pull("Color").copy(this)},cr.prototype.copy=function(t){return t instanceof cr?(this.glArray.set(t.glArray),this):this.parseCSS(t)},cr.prototype.add=function(t){return this.glArray[0]=Fn(this.glArray[0]+t.glArray[0],0,1),this.glArray[1]=Fn(this.glArray[1]+t.glArray[1],0,1),this.glArray[2]=Fn(this.glArray[2]+t.glArray[2],0,1),this.glArray[3]=(this.glArray[3]+t.glArray[3])/2,this},cr.prototype.darken=function(t){return t=Fn(t,0,1),this.glArray[0]*=t,this.glArray[1]*=t,this.glArray[2]*=t,this},cr.prototype.lerp=function(t,e){return e=Fn(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},cr.prototype.lighten=function(t){return t=Fn(t,0,1),this.glArray[0]=Fn(this.glArray[0]+(1-this.glArray[0])*t,0,1),this.glArray[1]=Fn(this.glArray[1]+(1-this.glArray[1])*t,0,1),this.glArray[2]=Fn(this.glArray[2]+(1-this.glArray[2])*t,0,1),this},cr.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(jn(t,e),jn(t,e),jn(t,e),this.alpha)},cr.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]},cr.prototype.parseCSS=function(t){return ur.has(t)?this.setColor.apply(this,ur.get(t)):this.parseRGB(t)},cr.prototype.parseRGB=function(t){var e=rr.exec(t);return e?this.setColor(+e[1],+e[2],+e[3],+e[5]):this.parseHex(t)},cr.prototype.parseHex=function(t,e){var i;if(void 0===e&&(e=!1),i=lr.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),(Fn(parseInt(i[!1===e?4:1],16),0,255)/255).toFixed(1));if(i=hr.exec(t))return this.setColor(parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16));if(i=ar.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),(Fn(parseInt(s+s,16),0,255)/255).toFixed(1))}if(i=sr.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)},cr.prototype.toUint32=function(t){return void 0===t&&(t=1),((255*t&255)<<24)+((255&this.r)<<16)+((255&this.g)<<8)+(255&this.b)},cr.prototype.toArray=function(){return this.glArray},cr.prototype.toHex=function(){return"#"+or(this.r)+or(this.g)+or(this.b)},cr.prototype.toHex8=function(t){return void 0===t&&(t=this.alpha),"#"+or(this.r)+or(this.g)+or(this.b)+or(255*t)},cr.prototype.toRGB=function(){return"rgb("+this.r+","+this.g+","+this.b+")"},cr.prototype.toRGBA=function(t){return void 0===t&&(t=this.alpha),"rgba("+this.r+","+this.g+","+this.b+","+t+")"},Object.defineProperties(cr.prototype,pr);var dr=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},fr={tx:{configurable:!0},ty:{configurable:!0},tz:{configurable:!0}};dr.prototype.onResetEvent=function(){void 0===this.val&&(this.val=new Float32Array(16)),arguments.length&&arguments[0]instanceof dr?this.copy(arguments[0]):16===arguments.length?this.setTransform.apply(this,arguments):this.identity()},fr.tx.get=function(){return this.val[12]},fr.ty.get=function(){return this.val[13]},fr.tz.get=function(){return this.val[14]},dr.prototype.identity=function(){return this.setTransform(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},dr.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},dr.prototype.copy=function(t){return this.val.set(t.val),this},dr.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)},dr.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],x=i[0],_=i[1],b=i[2],w=i[3];return e[0]=x*o+_*a+b*c+w*y,e[1]=x*n+_*h+b*p+w*g,e[2]=x*r+_*l+b*d+w*v,e[3]=x*s+_*u+b*f+w*m,x=i[4],_=i[5],b=i[6],w=i[7],e[4]=x*o+_*a+b*c+w*y,e[5]=x*n+_*h+b*p+w*g,e[6]=x*r+_*l+b*d+w*v,e[7]=x*s+_*u+b*f+w*m,x=i[8],_=i[9],b=i[10],w=i[11],e[8]=x*o+_*a+b*c+w*y,e[9]=x*n+_*h+b*p+w*g,e[10]=x*r+_*l+b*d+w*v,e[11]=x*s+_*u+b*f+w*m,x=i[12],_=i[13],b=i[14],w=i[15],e[12]=x*o+_*a+b*c+w*y,e[13]=x*n+_*h+b*p+w*g,e[14]=x*r+_*l+b*d+w*v,e[15]=x*s+_*u+b*f+w*m,this},dr.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},dr.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,x=e*h-n*r,_=i*a-o*s,b=i*h-n*s,w=o*h-n*a,T=l*f-u*d,A=l*y-c*d,E=l*g-p*d,S=u*y-c*f,C=u*g-p*f,M=c*g-p*y,P=v*M-m*C+x*S+_*E-b*A+w*T;return P?(P=1/P,t[0]=(s*M-a*C+h*S)*P,t[1]=(o*C-i*M-n*S)*P,t[2]=(f*w-y*b+g*_)*P,t[3]=(c*b-u*w-p*_)*P,t[4]=(a*E-r*M-h*A)*P,t[5]=(e*M-o*E+n*A)*P,t[6]=(y*x-d*w-g*m)*P,t[7]=(l*w-c*x+p*m)*P,t[8]=(r*C-s*E+h*T)*P,t[9]=(i*E-e*C-n*T)*P,t[10]=(d*b-f*x+g*v)*P,t[11]=(u*x-l*b-p*v)*P,t[12]=(s*A-r*S-a*T)*P,t[13]=(e*S-i*A+o*T)*P,t[14]=(f*m-d*_-y*v)*P,t[15]=(l*_-u*m+c*v)*P,this):null},dr.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},dr.prototype.applyInverse=function(t){var e=er.pull("Matrix3d",this).invert();return e.apply(t),er.push(e),t},dr.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},dr.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},dr.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},dr.prototype.scaleX=function(t){return this.scale(t,1)},dr.prototype.scaleY=function(t){return this.scale(1,t)},dr.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,E,S=this.val,C=e.x,M=e.y,P=e.z,O=Math.sqrt(C*C+M*M+P*P);if(O<Bn)return null;C*=O=1/O,M*=O,P*=O,i=Math.sin(t),n=1-(o=Math.cos(t)),r=S[0],s=S[1],a=S[2],h=S[3],l=S[4],u=S[5],c=S[6],p=S[7],d=S[8],f=S[9],y=S[10],g=S[11],v=C*C*n+o,m=M*C*n+P*i,x=P*C*n-M*i,_=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,E=P*P*n+o,S[0]=r*v+l*m+d*x,S[1]=s*v+u*m+f*x,S[2]=a*v+c*m+y*x,S[3]=h*v+p*m+g*x,S[4]=r*_+l*b+d*w,S[5]=s*_+u*b+f*w,S[6]=a*_+c*b+y*w,S[7]=h*_+p*b+g*w,S[8]=r*T+l*A+d*E,S[9]=s*T+u*A+f*E,S[10]=a*T+c*A+y*E,S[11]=h*T+p*A+g*E}return this},dr.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},dr.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]},dr.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]},dr.prototype.clone=function(){return er.pull("Matrix3d",this)},dr.prototype.toArray=function(){return this.val},dr.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(dr.prototype,fr);var yr=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this).onResetEvent.apply(t,e)},gr={tx:{configurable:!0},ty:{configurable:!0}};yr.prototype.onResetEvent=function(){return void 0===this.val&&(this.val=new Float32Array(9)),arguments.length&&arguments[0]instanceof yr?this.copy(arguments[0]):arguments.length&&arguments[0]instanceof dr?this.fromMat3d(arguments[0]):arguments.length>=6?this.setTransform.apply(this,arguments):this.identity(),this},gr.tx.get=function(){return this.val[6]},gr.ty.get=function(){return this.val[7]},yr.prototype.identity=function(){return this.setTransform(1,0,0,0,1,0,0,0,1),this},yr.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},yr.prototype.copy=function(t){return this.val.set(t.val),this},yr.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},yr.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},yr.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},yr.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},yr.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},yr.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},yr.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},yr.prototype.scaleV=function(t){return this.scale(t.x,t.y)},yr.prototype.scaleX=function(t){return this.scale(t,1)},yr.prototype.scaleY=function(t){return this.scale(1,t)},yr.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},yr.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},yr.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]},yr.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]},yr.prototype.clone=function(){return er.pull("Matrix2d",this)},yr.prototype.toArray=function(){return this.val},yr.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(yr.prototype,gr);var vr={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}(vr);var mr=new(0,vr.exports),xr="dom_ready",_r="me.boot",br="me.state.onPause",wr="me.state.onResume",Tr="me.state.onStop",Ar="me.state.onRestart",Er="me.state.onChange",Sr="me.video.onInit",Cr="me.game.onInit",Mr="me.game.onReset",Pr="me.game.beforeUpdate",Or="me.game.afterUpdate",Ir="me.game.onUpdate",kr="me.game.beforeDraw",Rr="me.game.afterDraw",Br="me.game.onLevelLoaded",Dr="me.loader.onload",Lr="me.loader.onProgress",zr="me.input.keydown",Fr="me.input.keyup",jr="gamepad.connected",Vr="gamepad.disconnected",Ur="gamepad.update",Nr="me.event.pointermove",Gr="me.event.pointerlockChange",Xr="me.game.dragstart",Hr="me.game.dragend",Yr="globalThis.onresize",Wr="canvas.onresize",qr="viewport.onresize",Kr="globalThis.orientationchange",Zr="globalThis.onscroll",Qr="viewport.onchange",Jr="renderer.contextlost",$r="renderer.contextrestored";function ts(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];return mr.emit.apply(mr,[t].concat(e))}function es(t,e,i){return mr.on(t,e,i)}function is(t,e,i){return mr.once(t,e,i)}function os(t,e){return mr.off(t,e)}var ns=Object.freeze({__proto__:null,DOM_READY:xr,BOOT:_r,STATE_PAUSE:br,STATE_RESUME:wr,STATE_STOP:Tr,STATE_RESTART:Ar,STATE_CHANGE:Er,VIDEO_INIT:Sr,GAME_INIT:Cr,GAME_RESET:Mr,GAME_BEFORE_UPDATE:Pr,GAME_AFTER_UPDATE:Or,GAME_UPDATE:Ir,GAME_BEFORE_DRAW:kr,GAME_AFTER_DRAW:Rr,LEVEL_LOADED:Br,LOADER_COMPLETE:Dr,LOADER_PROGRESS:Lr,KEYDOWN:zr,KEYUP:Fr,GAMEPAD_CONNECTED:jr,GAMEPAD_DISCONNECTED:Vr,GAMEPAD_UPDATE:Ur,POINTERMOVE:Nr,POINTERLOCKCHANGE:Gr,DRAGSTART:Xr,DRAGEND:Hr,WINDOW_ONRESIZE:Yr,CANVAS_ONRESIZE:Wr,VIEWPORT_ONRESIZE:qr,WINDOW_ONORIENTATION_CHANGE:Kr,WINDOW_ONSCROLL:Zr,VIEWPORT_ONCHANGE:Qr,ONCONTEXT_LOST:Jr,ONCONTEXT_RESTORED:$r,emit:ts,on:es,once:is,off:os}),rs={},ss=!1;try{ss="undefined"!=typeof globalThis&&void 0!==globalThis.localStorage}catch(t){ss=!1}function as(t){return"add"===t||"remove"===t}es(_r,(function(){if(!0===ss){var t=globalThis.localStorage.getItem("me.save");if("string"==typeof t&&t.length>0)(JSON.parse(t)||[]).forEach((function(t){rs[t]=JSON.parse(globalThis.localStorage.getItem("me.save."+t))}))}}));var hs={add:function(t){var e=hs;Object.keys(t).forEach((function(i){var o;as(i)||(o=i,Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:function(){return rs[o]},set:function(t){rs[o]=t,!0===ss&&globalThis.localStorage.setItem("me.save."+o,JSON.stringify(t))}}),i in rs||(e[i]=t[i]))})),!0===ss&&globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(rs)))},remove:function(t){as(t)||void 0!==rs[t]&&(delete rs[t],!0===ss&&(globalThis.localStorage.removeItem("me.save."+t),globalThis.localStorage.setItem("me.save",JSON.stringify(Object.keys(rs)))))}},ls=!1,us=!1;function cs(){if(!us){if(void 0!==globalThis.document&&!globalThis.document.body)return setTimeout(cs,13);void 0!==globalThis.document&&"function"==typeof globalThis.document.removeEventListener&&globalThis.document.removeEventListener("DOMContentLoaded",cs,!1),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("load",cs,!1),ts(xr),us=!0}}var ps=void 0!==globalThis.navigator?globalThis.navigator.userAgent:"",ds=/iPhone|iPad|iPod/i.test(ps),fs=/Android/i.test(ps),ys=/Android 2/i.test(ps),gs=/Linux/i.test(ps),vs=/CrOS/.test(ps),ms=/Windows Phone/i.test(ps),xs=/BlackBerry/i.test(ps),_s=/Kindle|Silk.*Mobile Safari/i.test(ps),bs=void 0!==globalThis.ejecta,ws=/MicroMessenger/i.test(ps),Ts=void 0!==globalThis.process&&void 0!==globalThis.process.release&&"node"===globalThis.process.release.name,As=/Mobi/i.test(ps)||ds||fs||ms||xs||_s||!1,Es=!1,Ss=!1,Cs=!0,Ms={left:0,top:0,x:0,y:0,width:0,height:0,right:0,bottom:0};function Ps(t){return t.preventDefault(),"function"==typeof globalThis.scroll&&globalThis.scroll(0,0),!1}function Os(t){Js=t.accelerationIncludingGravity.x,$s=t.accelerationIncludingGravity.y,ta=t.accelerationIncludingGravity.z}function Is(t){ea=t.gamma,ia=t.beta,oa=t.alpha}var ks=Object.freeze({__proto__:null,ua:ps,iOS:ds,android:fs,android2:ys,linux:gs,chromeOS:vs,wp:ms,BlackBerry:xs,Kindle:_s,ejecta:bs,isWeixin:ws,nodeJS:Ts,isMobile:As}),Rs=!!("ontouchstart"in globalThis),Bs=!!globalThis.PointerEvent,Ds=Rs||Bs,Ls=Ds?Bs?globalThis.navigator.maxTouchPoints||1:10:1,zs=void 0!==globalThis.document&&"onwheel"in globalThis.document.createElement("div"),Fs=void 0!==globalThis.document&&void 0!==globalThis.document.pointerLockElement,js=!!globalThis.DeviceOrientationEvent,Vs="undefined"!=typeof screen&&void 0!==screen.orientation,Us=!!globalThis.DeviceMotionEvent,Ns=void 0!==globalThis.document&&(Cn("fullscreenEnabled",globalThis.document)||globalThis.document.mozFullScreenEnabled);!0===Ns&&(globalThis.document.exitFullscreen=Cn("cancelFullScreen",globalThis.document)||Cn("exitFullscreen",globalThis.document));var Gs=!(!globalThis.AudioContext&&!globalThis.webkitAudioContext),Xs=void 0!==globalThis.Audio,Hs=Gs||Xs,Ys=function(){try{return!!globalThis.localStorage}catch(t){return!1}}(),Ws=function(){try{return void 0!==globalThis.OffscreenCanvas&&null!==new globalThis.OffscreenCanvas(0,0).getContext("2d")}catch(t){return!1}}(),qs="function"==typeof globalThis.atob,Ks=void 0!==globalThis.navigator&&(globalThis.navigator.language||globalThis.navigator.browserLanguage||globalThis.navigator.userLanguage)||"en",Zs=globalThis.devicePixelRatio||1,Qs=ks.isMobile,Js=0,$s=0,ta=0,ea=0,ia=0,oa=0;function na(t){!function(t){us?t.call(globalThis,[]):(is(xr,t,globalThis),ls||("undefined"!=typeof process&&"node"===process.release.name||void 0!==globalThis.document&&"complete"===globalThis.document.readyState?globalThis.setTimeout(cs,0):(void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("DOMContentLoaded",cs,!1),globalThis.addEventListener("load",cs,!1)),ls=!0))}(t)}function ra(t){var e=Bs?"pointermove":Rs?"touchmove":"mousemove";!1!==t?!1===Cs&&(globalThis.document.removeEventListener(e,Ps),Cs=!0):!0===Cs&&(globalThis.document.addEventListener(e,Ps,{passive:!1}),Cs=!1)}function sa(){return!!Ns&&!(!Cn("fullscreenElement",document)&&!document.mozFullScreenElement)}function aa(){var t="portrait",e="landscape",i=globalThis.screen;if(!0===Vs){var o=Cn("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}function ha(t){var e=la(t);return null!==e.parentNode&&(e=e.parentNode),e}function la(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}function ua(t){return"object"==typeof t&&t!==document.body&&void 0!==t.getBoundingClientRect?t.getBoundingClientRect():(Ms.width=Ms.right=globalThis.innerWidth,Ms.height=Ms.bottom=globalThis.innerHeight,Ms)}function ca(t){return ua(ha(t))}function pa(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}function da(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"}function fa(){"function"==typeof globalThis.focus&&globalThis.focus()}var ya=Object.freeze({__proto__:null,onDeviceRotate:Is,platform:ks,touchEvent:Rs,pointerEvent:Bs,touch:Ds,maxTouchPoints:Ls,wheel:zs,hasPointerLockSupport:Fs,hasDeviceOrientation:js,screenOrientation:Vs,hasAccelerometer:Us,hasFullscreenSupport:Ns,hasWebAudio:Gs,hasHTML5Audio:Xs,sound:Hs,localStorage:Ys,offscreenCanvas:Ws,nativeBase64:qs,language:Ks,devicePixelRatio:Zs,isMobile:Qs,get accelerationX(){return Js},get accelerationY(){return $s},get accelerationZ(){return ta},get gamma(){return ea},get beta(){return ia},get alpha(){return oa},pauseOnBlur:!0,resumeOnFocus:!0,autoFocus:!0,stopOnBlur:!1,onReady:na,enableSwipe:ra,isFullscreen:sa,requestFullscreen:function(t){Ns&&!sa()&&((t=t||qc()).requestFullscreen=Cn("requestFullscreen",t)||t.mozRequestFullScreen,t.requestFullscreen())},exitFullscreen:function(){Ns&&sa()&&document.exitFullscreen()},getScreenOrientation:aa,lockOrientation:function(t){var e=globalThis.screen;if(void 0!==e){var i=Cn("lockOrientation",e);if(void 0!==i)return i(t)}return!1},unlockOrientation:function(){var t=globalThis.screen;if(void 0!==t){var e=Cn("unlockOrientation",t);if(void 0!==e)return e()}return!1},isPortrait:function(){return aa().includes("portrait")},isLandscape:function(){return aa().includes("landscape")},getStorage:function(t){if(void 0===t&&(t="local"),"local"===t)return hs;throw new Error("storage type "+t+" not supported")},getParentElement:ha,getElement:la,getElementBounds:ua,getParentBounds:ca,isWebGLSupported:pa,getMaxShaderPrecision:da,focus:fa,watchAccelerometer:function(){return Us&&!Es&&(DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&(globalThis.addEventListener("devicemotion",Os,!1),Es=!0)})).catch(console.error):(globalThis.addEventListener("devicemotion",Os,!1),Es=!0)),Es},unwatchAccelerometer:function(){Es&&(globalThis.removeEventListener("devicemotion",Os,!1),Es=!1)},watchDeviceOrientation:function(){return js&&!Ss&&("function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&(globalThis.addEventListener("deviceorientation",Is,!1),Ss=!0)})).catch(console.error):(globalThis.addEventListener("deviceorientation",Is,!1),Ss=!0)),Ss},unwatchDeviceOrientation:function(){Ss&&(globalThis.removeEventListener("deviceorientation",Is,!1),Ss=!1)},vibrate:function(t){void 0!==globalThis.navigator&&"function"==typeof globalThis.navigator.vibrate&&globalThis.navigator.vibrate(t)}}),ga={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 va(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 ma(t,e){return"precision"!==t.substring(0,9)?"precision "+e+" float;"+t:t}function xa(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 _a=function(t,e,i,o){this.gl=t,this.vertex=ma(xa(e),o||da(this.gl)),this.fragment=ma(xa(i),o||da(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=va(t,t.VERTEX_SHADER,e),r=va(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"+ga[o])}})),Object.defineProperties(o,s),o}(this.gl,this),es(Jr,this.destroy,this)};_a.prototype.bind=function(){this.gl.useProgram(this.program)},_a.prototype.getAttribLocation=function(t){var e=this.attributes[t];return void 0!==e?e:-1},_a.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},_a.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)}},_a.prototype.destroy=function(){this.uniforms=null,this.attributes=null,this.gl.deleteProgram(this.program),this.vertex=null,this.fragment=null};var ba=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)};ba.prototype.clear=function(){this.vertexCount=0},ba.prototype.isFull=function(t){return void 0===t&&(t=this.quadSize),this.vertexCount+t>=this.maxVertex},ba.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},ba.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},ba.prototype.toFloat32=function(t,e){return void 0!==e?this.bufferF32.subarray(t,e):this.bufferF32},ba.prototype.toUint32=function(t,e){return void 0!==e?this.bufferU32.subarray(t,e):this.bufferU32},ba.prototype.length=function(){return this.vertexCount},ba.prototype.isEmpty=function(){return 0===this.vertexCount};var wa=[new ir,new ir,new ir,new ir],Ta=function(t){this.init(t)};Ta.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 _a(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 _a(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 ba(this.vertexSize,6),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),i.bufferData(i.ARRAY_BUFFER,this.vertexBuffer.buffer,i.STREAM_DRAW),es(Wr,(function(t,i){e.flush(),e.setViewport(0,0,t,i)}))},Ta.prototype.reset=function(){this.gl=this.renderer.gl,this.flush(),this.setViewport(0,0,this.renderer.getCanvas().width,this.renderer.getCanvas().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)},Ta.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},Ta.prototype.setViewport=function(t,e,i,o){this.gl.viewport(t,e,i,o)},Ta.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=Dn(n||e.width)&&Dn(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},Ta.prototype.deleteTexture2D=function(t){this.gl.deleteTexture(t),this.unbindTexture2D(t)},Ta.prototype.getTexture2D=function(t){return this.boundTextures[t]},Ta.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))},Ta.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},Ta.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},Ta.prototype.setProjection=function(t){this.activeShader.setUniform("uProjectionMatrix",t)},Ta.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))},Ta.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=wa[0].set(e,i),d=wa[1].set(e+o,i),f=wa[2].set(e,i+n),y=wa[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)}},Ta.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()}},Ta.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)},Ta.prototype.clear=function(t){void 0===t&&(t=0);var e=this.gl;e.clearColor(0,0,0,t),e.clear(e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT)},Ta.prototype.clearColor=function(t,e,i,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=0);var n=this.gl;n.clearColor(t,e,i,o),n.clear(n.COLOR_BUFFER_BIT)};var Aa={exports:{}};function Ea(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=Sa(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=Sa(t,e[n]*o,n<r-1?e[n+1]*o:t.length,o,!1))===s.next&&(s.steiner=!0),a.push(za(s));for(a.sort(Ra),n=0;n<a.length;n++)i=Ba(a[n],i);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))?32767/l:0}return Ma(p,d,i,o,n,l,0),d}function Sa(t,e,i,o,n){var r,s;if(n===Za(t,e,i,o)>0)for(r=e;r<i;r+=o)s=Wa(r,t[r],t[r+1],s);else for(r=i-o;r>=e;r-=o)s=Wa(r,t[r],t[r+1],s);return s&&Ua(s,s.next)&&(qa(s),s=s.next),s}function Ca(t,e){if(!t)return t;e||(e=t);var i,o=t;do{if(i=!1,o.steiner||!Ua(o,o.next)&&0!==Va(o.prev,o,o.next))o=o.next;else{if(qa(o),(o=e=o.prev)===o.next)break;i=!0}}while(i||o!==e);return e}function Ma(t,e,i,o,n,r,s){if(t){!s&&r&&function(t,e,i,o){var n=t;do{0===n.z&&(n.z=La(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?Oa(t,o,n,r):Pa(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(h.i/i|0),qa(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?Ma(t=Ia(Ca(t),e,i),e,i,o,n,r,2):2===s&&ka(t,e,i,o,n,r):Ma(Ca(t),e,i,o,n,r,1);break}}}function Pa(t){var e=t.prev,i=t,o=t.next;if(Va(e,i,o)>=0)return!1;for(var n=e.x,r=i.x,s=o.x,a=e.y,h=i.y,l=o.y,u=n<r?n<s?n:s:r<s?r:s,c=a<h?a<l?a:l:h<l?h:l,p=n>r?n>s?n:s:r>s?r:s,d=a>h?a>l?a:l:h>l?h:l,f=o.next;f!==e;){if(f.x>=u&&f.x<=p&&f.y>=c&&f.y<=d&&Fa(n,a,r,h,s,l,f.x,f.y)&&Va(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Oa(t,e,i,o){var n=t.prev,r=t,s=t.next;if(Va(n,r,s)>=0)return!1;for(var a=n.x,h=r.x,l=s.x,u=n.y,c=r.y,p=s.y,d=a<h?a<l?a:l:h<l?h:l,f=u<c?u<p?u:p:c<p?c:p,y=a>h?a>l?a:l:h>l?h:l,g=u>c?u>p?u:p:c>p?c:p,v=La(d,f,e,i,o),m=La(y,g,e,i,o),x=t.prevZ,_=t.nextZ;x&&x.z>=v&&_&&_.z<=m;){if(x.x>=d&&x.x<=y&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&Fa(a,u,h,c,l,p,x.x,x.y)&&Va(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,_.x>=d&&_.x<=y&&_.y>=f&&_.y<=g&&_!==n&&_!==s&&Fa(a,u,h,c,l,p,_.x,_.y)&&Va(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=d&&x.x<=y&&x.y>=f&&x.y<=g&&x!==n&&x!==s&&Fa(a,u,h,c,l,p,x.x,x.y)&&Va(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=m;){if(_.x>=d&&_.x<=y&&_.y>=f&&_.y<=g&&_!==n&&_!==s&&Fa(a,u,h,c,l,p,_.x,_.y)&&Va(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Ia(t,e,i){var o=t;do{var n=o.prev,r=o.next.next;!Ua(n,r)&&Na(n,o,o.next,r)&&Ha(n,r)&&Ha(r,n)&&(e.push(n.i/i|0),e.push(o.i/i|0),e.push(r.i/i|0),qa(o),qa(o.next),o=t=r),o=o.next}while(o!==t);return Ca(o)}function ka(t,e,i,o,n,r){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&ja(s,a)){var h=Ya(s,a);return s=Ca(s,s.next),h=Ca(h,h.next),Ma(s,e,i,o,n,r,0),void Ma(h,e,i,o,n,r,0)}a=a.next}s=s.next}while(s!==t)}function Ra(t,e){return t.x-e.x}function Ba(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&&(s=a,i=o.x<o.next.x?o:o.next,a===n))return i}o=o.next}while(o!==e);if(!i)return null;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&&Fa(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),Ha(o,t)&&(h<p||h===p&&(o.x>i.x||o.x===i.x&&Da(i,o)))&&(i=o,p=h)),o=o.next}while(o!==l);return i}(t,e);if(!i)return e;var o=Ya(i,t);return Ca(o,o.next),Ca(i,i.next)}function Da(t,e){return Va(t.prev,t,e.prev)<0&&Va(e.next,t,t.next)<0}function La(t,e,i,o,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function za(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 Fa(t,e,i,o,n,r,s,a){return(n-s)*(e-a)>=(t-s)*(r-a)&&(t-s)*(o-a)>=(i-s)*(e-a)&&(i-s)*(r-a)>=(n-s)*(o-a)}function ja(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&&Na(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Ha(t,e)&&Ha(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)&&(Va(t.prev,t,e.prev)||Va(t,e.prev,e))||Ua(t,e)&&Va(t.prev,t,t.next)>0&&Va(e.prev,e,e.next)>0)}function Va(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ua(t,e){return t.x===e.x&&t.y===e.y}function Na(t,e,i,o){var n=Xa(Va(t,e,i)),r=Xa(Va(t,e,o)),s=Xa(Va(i,o,t)),a=Xa(Va(i,o,e));return n!==r&&s!==a||(!(0!==n||!Ga(t,i,e))||(!(0!==r||!Ga(t,o,e))||(!(0!==s||!Ga(i,t,o))||!(0!==a||!Ga(i,e,o)))))}function Ga(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 Xa(t){return t>0?1:t<0?-1:0}function Ha(t,e){return Va(t.prev,t,t.next)<0?Va(t,e,t.next)>=0&&Va(t,t.prev,e)>=0:Va(t,e,t.prev)<0||Va(t,t.next,e)<0}function Ya(t,e){var i=new Ka(t.i,t.x,t.y),o=new Ka(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 Wa(t,e,i,o){var n=new Ka(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 qa(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 Ka(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Za(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}Aa.exports=Ea,Aa.exports.default=Ea,Ea.deviation=function(t,e,i,o){var n=e&&e.length,r=n?e[0]*i:t.length,s=Math.abs(Za(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(Za(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)},Ea.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 Qa=function(t,e,i){this.pos=er.pull("Vector2d"),this._bounds,this.points=[],this.edges=[],this.indices=[],this.normals=[],this.shapeType="Polygon",this.setShape(t,e,i)};Qa.prototype.onResetEvent=function(t,e,i){this.setShape(t,e,i)},Qa.prototype.setShape=function(t,e,i){return this.pos.set(t,e),this.setVertices(i),this},Qa.prototype.setVertices=function(t){var e=this;if(!Array.isArray(t))return this;if(t[0]instanceof ir)this.points=t;else if(this.points.length=0,"object"==typeof t[0])t.forEach((function(t){e.points.push(er.pull("Vector2d",t.x,t.y))}));else for(var i=0;i<t.length;i+=2)this.points.push(er.pull("Vector2d",t[i],t[i+1]));return this.recalc(),this.updateBounds(),this},Qa.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},Qa.prototype.toIso=function(){return this.rotate(Math.PI/4).scale(Math.SQRT2,Math.SQRT1_2)},Qa.prototype.to2d=function(){return this.scale(Math.SQRT1_2,Math.SQRT2).rotate(-Math.PI/4)},Qa.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},Qa.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},Qa.prototype.scaleV=function(t){return this.scale(t.x,t.y)},Qa.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]=er.pull("Vector2d")),e[t].copy(n[(t+1)%r]).sub(n[t]),void 0===i[t]&&(i[t]=er.pull("Vector2d")),i[t].copy(e[t]).perp().normalize();return e.length=r,i.length=r,o.length=0,this},Qa.prototype.getIndices=function(){return 0===this.indices.length&&(this.indices=Aa.exports(this.points.flatMap((function(t){return[t.x,t.y]})))),this.indices},Qa.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},Qa.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},Qa.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()},Qa.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},Qa.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=er.pull("Bounds")),this._bounds},Qa.prototype.updateBounds=function(){var t=this.getBounds();return t.update(this.points),t.translate(this.pos),t},Qa.prototype.clone=function(){var t=[];return this.points.forEach((function(e){t.push(e.clone())})),new Qa(this.pos.x,this.pos.y,t)};var Ja=function(t){function e(e,i,o,n){t.call(this,e,i,[er.pull("Vector2d",0,0),er.pull("Vector2d",o,0),er.pull("Vector2d",o,n),er.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 er.pull("Polygon",this.pos.x,this.pos.y,this.points)},Object.defineProperties(e.prototype,i),e}(Qa),$a=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}(Ja),th=function(t,e,i,o){this.pos=er.pull("Vector2d"),this._bounds=void 0,this.radius=NaN,this.radiusV=er.pull("Vector2d"),this.radiusSq=er.pull("Vector2d"),this.ratio=er.pull("Vector2d"),this.shapeType="Ellipse",this.setShape(t,e,i,o)};th.prototype.onResetEvent=function(t,e,i,o){this.setShape(t,e,i,o)},th.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},th.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},th.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)},th.prototype.scaleV=function(t){return this.scale(t.x,t.y)},th.prototype.transform=function(t){return this},th.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},th.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},th.prototype.getBounds=function(){return void 0===this._bounds&&(this._bounds=er.pull("Bounds")),this._bounds},th.prototype.clone=function(){return new th(this.pos.x,this.pos.y,2*this.radiusV.x,2*this.radiusV.y)};var eh=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]=er.pull("Vector2d")),t[0].copy(o[1]).sub(o[0]),void 0===e[0]&&(e[0]=er.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}(Qa),ih=function(t){this._center=new ir,this.onResetEvent(t)},oh={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}};ih.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)},ih.prototype.clear=function(){this.setMinMax(1/0,1/0,-1/0,-1/0)},ih.prototype.setMinMax=function(t,e,i,o){this.min.x=t,this.min.y=e,this.max.x=i,this.max.y=o},oh.x.get=function(){return this.min.x},oh.x.set=function(t){var e=this.max.x-this.min.x;this.min.x=t,this.max.x=t+e},oh.y.get=function(){return this.min.y},oh.y.set=function(t){var e=this.max.y-this.min.y;this.min.y=t,this.max.y=t+e},oh.width.get=function(){return this.max.x-this.min.x},oh.width.set=function(t){this.max.x=this.min.x+t},oh.height.get=function(){return this.max.y-this.min.y},oh.height.set=function(t){this.max.y=this.min.y+t},oh.left.get=function(){return this.min.x},oh.right.get=function(){return this.max.x},oh.top.get=function(){return this.min.y},oh.bottom.get=function(){return this.max.y},oh.centerX.get=function(){return this.min.x+this.width/2},oh.centerY.get=function(){return this.min.y+this.height/2},oh.center.get=function(){return this._center.set(this.centerX,this.centerY)},ih.prototype.update=function(t){this.add(t,!0)},ih.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)}},ih.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)},ih.prototype.addPoint=function(t,e){void 0!==e&&"function"==typeof t.rotate&&(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)},ih.prototype.addFrame=function(t,e,i,o,n){var r=er.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),er.push(r)},ih.prototype.contains=function(){var t,e,i,o,n=arguments[0];return 2===arguments.length?(t=e=n,i=o=arguments[1]):n instanceof ih?(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},ih.prototype.overlaps=function(t){return!(this.right<t.left||this.left>t.right||this.bottom<t.top||this.top>t.bottom)},ih.prototype.isFinite=function(){return isFinite(this.min.x)&&isFinite(this.max.x)&&isFinite(this.min.y)&&isFinite(this.max.y)},ih.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},ih.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},ih.prototype.clone=function(){var t=new ih;return t.addBounds(this),t},ih.prototype.toPolygon=function(){return er.pull("Polygon",this.x,this.y,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height),er.pull("Vector2d",0,this.height)])},Object.defineProperties(ih.prototype,oh);var nh=function(){this.points=[],this.arcResolution=5,this.vertices=[]};nh.prototype.beginPath=function(){this.points.forEach((function(t){er.push(t)})),this.points.length=0},nh.prototype.closePath=function(){var t=this.points;t.length>1&&!t[t.length-1].equals(t[0])&&t.push(er.pull("Vector2d",t[0].x,t[0].y))},nh.prototype.triangulatePath=function(){var t=0,e=this.points,i=this.vertices,o=Aa.exports(e.flatMap((function(t){return[t.x,t.y]})));for(t=0;t<o.length;t++)void 0===i[t]&&(i[t]=er.pull("Vector2d")),i[t].set(e[o[t]].x,e[o[t]].y);for(;i.length>o.length;)er.push(i[i.length-1]),i.length-=1;return i},nh.prototype.moveTo=function(t,e){this.points.push(er.pull("Vector2d",t,e))},nh.prototype.lineTo=function(t,e){this.points.push(er.pull("Vector2d",t,e))},nh.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)>=kn:Math.abs(n-o)>=kn;(o%=kn)<0&&(o+=kn),(n%=kn)<0&&(n+=kn),o>=n&&(n+=kn);var h=n-o,l=1;r&&(l=-1,h=kn-h),a&&(h=kn);for(var u=h*i/this.arcResolution,c=h/u,p=o,d=0;d<u;d++)s.push(er.pull("Vector2d",t+i*Math.cos(p),e+i*Math.sin(p))),p+=l*c;s.push(er.pull("Vector2d",t+i*Math.cos(n),e+i*Math.sin(n)))}},nh.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(er.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]),x=Math.atan2(d[1]-v[1],d[0]-v[0]);this.arc(v[0],v[1],n,m,x)},nh.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)>=kn:Math.abs(s-r)>=kn;(r%=kn)<0&&(r+=kn),(s%=kn)<0&&(s+=kn),r>=s&&(s+=kn);var u=s-r,c=1;a&&(c=-1,u=kn-u),l&&(u=kn);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),x=o*Math.sin(f),_=t+m*y-x*g,b=e+m*g+x*y;h.push(er.pull("Vector2d",_,b)),f+=c*d}}},nh.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)},nh.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 rh=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e};rh.prototype.onResetEvent=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.set(t,e)},rh.prototype.set=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},rh.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},rh.prototype.clone=function(){return new rh(this.x,this.y)};var sh=function(t){this.settings=t,this.isContextValid=!0,this.path2D=new nh,this.currentScissor=new Int32Array([0,0,this.settings.width,this.settings.height]),this.maskLevel=0,this.currentBlendMode="none",void 0!==globalThis.canvas?this.canvas=globalThis.canvas:void 0!==this.settings.canvas?this.canvas=this.settings.canvas:this.canvas=Wc(this.settings.width,this.settings.height),this.currentColor=new cr(0,0,0,1),this.currentTint=new cr(255,255,255,1),this.projectionMatrix=new dr,this.uvOffset=0,es(Mr,(function(){Yc.reset()}))};sh.prototype.clear=function(){},sh.prototype.flush=function(){},sh.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.getCanvas().width,this.currentScissor[3]=this.getCanvas().height,this.clearMask()},sh.prototype.getCanvas=function(){return this.canvas},sh.prototype.getContext=function(){return this.context},sh.prototype.getBlendMode=function(){return this.currentBlendMode},sh.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},sh.prototype.getWidth=function(){return this.getCanvas().width},sh.prototype.getHeight=function(){return this.getCanvas().height},sh.prototype.getColor=function(){return this.currentColor},sh.prototype.globalAlpha=function(){return this.currentColor.glArray[3]},sh.prototype.overlaps=function(t){return t.left<=this.getWidth()&&t.right>=0&&t.top<=this.getHeight()&&t.bottom>=0},sh.prototype.resize=function(t,e){var i=this.getCanvas();t===i.width&&e===i.height||(i.width=t,i.height=e,this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=t,this.currentScissor[3]=e,ts(Wr,t,e))},sh.prototype.setAntiAlias=function(t,e){var i=t.canvas;Mn("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"},sh.prototype.setProjection=function(t){this.projectionMatrix.copy(t)},sh.prototype.stroke=function(t,e){if(t instanceof $a)this.strokeRoundRect(t.left,t.top,t.width,t.height,t.radius,e);else if(t instanceof Ja||t instanceof ih)this.strokeRect(t.left,t.top,t.width,t.height,e);else if(t instanceof eh||t instanceof Qa)this.strokePolygon(t,e);else if(t instanceof th)this.strokeEllipse(t.pos.x,t.pos.y,t.radiusV.x,t.radiusV.y,e);else{if(!(t instanceof rh))throw new Error("Invalid geometry for fill/stroke");this.strokePoint(t.x,t.y)}},sh.prototype.fill=function(t){this.stroke(t,!0)},sh.prototype.tint=function(t,e,i){var o=Wc(t.width,t.height,!0),n=this.getContext2d(o);return n.save(),n.fillStyle=e instanceof cr?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},sh.prototype.setMask=function(t){},sh.prototype.clearMask=function(){},sh.prototype.setTint=function(t,e){void 0===e&&(e=t.alpha),this.currentTint.copy(t),this.currentTint.alpha*=e},sh.prototype.clearTint=function(){this.currentTint.setColor(255,255,255,1)},sh.prototype.drawFont=function(){};var ah={};
|
|
9
9
|
/*!
|
|
10
10
|
* howler.js v2.2.3
|
|
11
11
|
* howlerjs.com
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
*
|
|
27
27
|
* MIT License
|
|
28
28
|
*/
|
|
29
|
-
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)}}()}(oh);var nh={},rh=null,sh=0,ah=[],hh=function(t,e){if(sh++>3)throw new Error("melonJS: failed loading "+t);nh[t].load()};function lh(){return!oh.Howler.noAudio}function uh(t,e,i,o){var n=[];if(0===ah.length)throw new Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");if(!0===_n(t.src))n.push(t.src);else for(var r=0;r<ah.length;r++)n.push(t.src+t.name+"."+ah[r]+fc.nocache);return nh[t.name]=new oh.Howl({src:n,volume:oh.Howler.volume(),html5:!0===e,xhrWithCredentials:fc.withCredentials,onloaderror:function(){hh.call(this,t.name,o)},onload:function(){sh=0,i&&i()}}),1}function ch(t,e,i,o){void 0===e&&(e=!1);var n=nh[t];if(n&&void 0!==n){var r=n.play();return"boolean"==typeof e&&n.loop(e,r),n.volume("number"==typeof o?Bn(o,0,1):oh.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 ph(){null!==rh&&nh[rh].pause()}function dh(){null!==rh&&nh[rh].play()}function fh(t,e,i){i=void 0===i||!!i;var o=nh[t];if(!o||void 0===o)throw new Error("audio clip "+t+" does not exist");o.mute(i,e)}function yh(){oh.Howler.mute(!0)}function gh(){oh.Howler.mute(!1)}function vh(t){return t in nh&&(nh[t].unload(),delete nh[t],!0)}function mh(){for(var t in nh)nh.hasOwnProperty(t)&&vh(t)}var xh=Object.freeze({__proto__:null,stopOnAudioError:!0,init:function(t){return void 0===t&&(t="mp3"),ah=t.split(","),!oh.Howler.noAudio},hasFormat:function(t){return lh()&&oh.Howler.codecs(t)},hasAudio:lh,enable:function(){gh()},disable:function(){yh()},load:uh,play:ch,fade:function(t,e,i,o,n){var r=nh[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=nh[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=nh[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=nh[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 oh.Howler.stop()},pause:function(t,e){var i=nh[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.pause(e)},resume:function(t,e){var i=nh[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.play(e)},playTrack:function(t,e){return ch(rh=t,!0,null,e)},stopTrack:function(){null!==rh&&(nh[rh].stop(),rh=null)},pauseTrack:ph,resumeTrack:dh,getCurrentTrack:function(){return rh},setVolume:function(t){oh.Howler.volume(t)},getVolume:function(){return oh.Howler.volume()},mute:fh,unmute:function(t,e){fh(t,e,!1)},muteAll:yh,unmuteAll:gh,muted:function(){return oh.Howler._muted},unload:vh,unloadAll:mh}),_h=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(Bn(this.x,t,i),Bn(this.y,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(Bn(this._x,t,e),Bn(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._set(this._x+(t.x-this._x)*e,this._y+(t.y-this._y)*e)},e.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this._y,t.x-this._x),o=this.distance(t);return 0===o||e>=0&&o<=e*e?t:(this._x+=Math.cos(i)*e,this._y+=Math.sin(i)*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 Qn.pull("ObservableVector2d",this._x,this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.toVector2d=function(){return Qn.pull("Vector2d",this._x,this._y)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y},Object.defineProperties(e.prototype,i),e}(Jn),bh=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.onResetEvent(t,e,i)};bh.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},bh.prototype._set=function(t,e,i){return void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},bh.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)},bh.prototype.setZero=function(){return this.set(0,0,0)},bh.prototype.setV=function(t){return this._set(t.x,t.y,t.z)},bh.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y,this.z+(t.z||0))},bh.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y,this.z-(t.z||0))},bh.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))},bh.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},bh.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y),this.z)},bh.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2,this.z)},bh.prototype.div=function(t){return this._set(this.x/t,this.y/t,this.z/t)},bh.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)},bh.prototype.clamp=function(t,e){return new bh(Bn(this.x,t,e),Bn(this.y,t,e),Bn(this.z,t,e))},bh.prototype.clampSelf=function(t,e){return this._set(Bn(this.x,t,e),Bn(this.y,t,e),Bn(this.z,t,e))},bh.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)},bh.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)},bh.prototype.floor=function(){return new bh(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},bh.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},bh.prototype.ceil=function(){return new bh(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},bh.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},bh.prototype.negate=function(){return new bh(-this.x,-this.y,-this.z)},bh.prototype.negateSelf=function(){return this._set(-this.x,-this.y,-this.z)},bh.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},bh.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},bh.prototype.normalize=function(){return this.div(this.length()||1)},bh.prototype.perp=function(){return this._set(this.y,-this.x,this.z)},bh.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)},bh.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*(void 0!==t.z?t.z:this.z)},bh.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},bh.prototype.length2=function(){return this.dot(this)},bh.prototype.length=function(){return Math.sqrt(this.length2())},bh.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},bh.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this.y,t.x-this.x),o=this.x-t.x,n=this.y-t.y,r=Math.sqrt(o*o+n*n);return 0===r||e>=0&&r<=e*e?t:(this.x+=Math.cos(i)*e,this.y+=Math.sin(i)*e,this)},bh.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)},bh.prototype.angle=function(t){return Math.acos(Bn(this.dot(t)/(this.length()*t.length()),-1,1))},bh.prototype.project=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},bh.prototype.projectN=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},bh.prototype.clone=function(){return Qn.pull("Vector3d",this.x,this.y,this.z)},bh.prototype.toString=function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z};var wh=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(Bn(this._x,t,i),Bn(this._y,t,i),Bn(this._z,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(Bn(this._x,t,e),Bn(this._y,t,e),Bn(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._set(this._x+(t.x-this._x)*e,this._y+(t.y-this._y)*e,this._z+(t.z-this._z)*e)},e.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this._y,t.x-this._x),o=this._x-t.x,n=this._y-t.y,r=Math.sqrt(o*o+n*n);return 0===r||e>=0&&r<=e*e?t:this._set(this._x+Math.cos(i)*e,this._y+Math.sin(i)*e,this._z)},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 Qn.pull("ObservableVector3d",this._x,this._y,this._z,{onUpdate:this.onUpdate})},e.prototype.toVector3d=function(){return Qn.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}(bh),Th={},Ah={},Eh={},Sh={},Ch={},Mh={},Ph=function(t,e,i){e=e||t.keyCode||t.button;var o=Mh[e];if(Zr(Rr,o,e,!o||!Eh[o]),o){if(!Eh[o]){var n=void 0!==i?i:e;Sh[o][n]||(Th[o]++,Sh[o][n]=!0)}return!Ch[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},Oh=function(t,e,i){e=e||t.keyCode||t.button;var o=Mh[e];if(Zr(Br,o,e),o){var n=void 0!==i?i:e;return Sh[o][n]=void 0,Th[o]>0&&Th[o]--,Eh[o]=!1,!Ch[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},Ih=null;function kh(){null===Ih&&!1===_s&&"function"==typeof(Ih=globalThis).addEventListener&&(Ih.addEventListener("keydown",Ph,!1),Ih.addEventListener("keyup",Oh,!1))}function Rh(t,e,i){!0===e?Ph({},t,i):Oh({},t,i)}function Bh(t){return Mh[t]}var Dh,Lh=new Jn,zh=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,fl(this.pageX,this.pageY,Lh),this.gameScreenX=this.x=Lh.x,this.gameScreenY=this.y=Lh.y,this.isNormalized=void 0!==globalThis.PointerEvent&&!(t instanceof globalThis.PointerEvent),this.locked=dl,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!==iu.viewport&&iu.viewport.localToWorld(this.gameScreenX,this.gameScreenY,Lh),this.gameWorldX=Lh.x,this.gameWorldY=Lh.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}(Ja),Fh=[],jh=new Map,Vh=!1,Uh=0,Nh=[],Gh=["wheel"],Xh=["pointermove","mousemove","touchmove"],Hh=["pointerdown","mousedown","touchstart"],Yh=["pointerup","mouseup","touchend"],Wh=["pointercancel","mousecancel","touchcancel"],qh=["pointerenter","mouseenter","touchenter"],Kh=["pointerover","mouseover","touchover"],Zh=["pointerleave","mouseleave","touchleave"],Qh=[Gh[0],Xh[0],Hh[0],Yh[0],Wh[0],qh[0],Kh[0],Zh[0]],Jh=[Gh[0],Xh[1],Hh[1],Yh[1],Wh[1],qh[1],Kh[1],Zh[1]],$h=[Xh[2],Hh[2],Yh[2],Wh[2],qh[2],Kh[2],Zh[2]],tl={wheel:Gh,pointermove:Xh,pointerdown:Hh,pointerup:Yh,pointercancel:Wh,pointerenter:qh,pointerover:Kh,pointerleave:Zh},el=[];function il(){if(!Vh){Dh=new qa(0,0,1,1);for(var t=0;t<ks;t++)Fh.push(new zh);var e;null===cl&&(cl=Nc.getCanvas()),Nh=Os?Qh:Jh,Is&&!Os&&(Nh=Nh.concat($h)),function(t,e){for(var i=0;i<t.length;i++)-1===Xh.indexOf(t[i])&&cl.addEventListener(t[i],e,{passive:!1===Pl})}(Nh,ll),void 0===ul&&(ul=~~(1e3/Jc.maxfps)),ua(),cl.addEventListener(Nh[2],(function(){ua()}),{passive:!1===Pl});var i=nl(Nh,Xh);if(ul<17)for(e=0;e<i.length;e++)-1!==Nh.indexOf(i[e])&&cl.addEventListener(i[e],hl,{passive:!0});else for(e=0;e<i.length;e++)-1!==Nh.indexOf(i[e])&&cl.addEventListener(i[e],qn(hl,ul,!1),{passive:!0});yl(cl),Bs&&document.addEventListener("pointerlockchange",(function(){dl=document.pointerLockElement===Xc(),Zr(jr,dl)}),!0),Vh=!0}}function ol(t,e){for(var i=0;i<e.length;i++){if(-1!==t.indexOf(e[i]))return e[i]}}function nl(t,e){for(var i=[],o=0;o<e.length;o++){-1!==t.indexOf(e[o])&&i.push(e[o])}return i}function rl(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 sl(t){for(var e=!1;t.length>0;){var i=t.pop();if(Fh.push(i),!0===i.isNormalized&&void 0!==i.event.timeStamp){if(i.event.timeStamp<Uh)continue;Uh=i.event.timeStamp}Dh.setShape(i.gameWorldX,i.gameWorldY,i.width,i.height),Xh.includes(i.type)&&(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY,Zr(Fr,i));for(var o,n=iu.world.broadphase.retrieve(Dh,Kl.prototype._sortReverseZ),r=(n=n.concat([iu.viewport])).length;o=n[--r];){if(jh.has(o)&&!0!==o.isKinematic){var s,a=jh.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(Qn.pull("Vector2d",p,d));p=f.x,d=f.y,Qn.push(f)}switch(s=u.contains(p,d),i.type){case Xh[0]:case Xh[1]:case Xh[2]:case Xh[3]:if(a.pointerId!==i.pointerId||s){if(null===a.pointerId&&s&&rl(a,ol(Nh,qh),i,i.pointerId)){e=!0;break}}else if(rl(a,ol(Nh,Zh),i,null)){e=!0;break}if(s&&rl(a,i.type,i,i.pointerId)){e=!0;break}break;case Yh[0]:case Yh[1]:case Yh[2]:case Yh[3]:if(a.pointerId===i.pointerId&&s&&rl(a,i.type,i,null)){e=!0;break}break;case Wh[0]:case Wh[1]:case Wh[2]:case Wh[3]:if(a.pointerId===i.pointerId&&rl(a,i.type,i,null)){e=!0;break}break;default:if(s&&rl(a,i.type,i,i.pointerId)){e=!0;break}}}if(!0===e)break}}return e}function al(t){var e;if(Ps&&t.changedTouches)for(var i=0,o=t.changedTouches.length;i<o;i++){var n=t.changedTouches[i];(e=Fh.pop()).setEvent(t,n.pageX,n.pageY,n.clientX,n.clientY,n.identifier),el.push(e)}else(e=Fh.pop()).setEvent(t,t.pageX,t.pageY,t.clientX,t.clientY,t.pointerId),el.push(e);return!1===t.isPrimary||(el[0].isPrimary=!0,Object.assign(pl,el[0])),el}function hl(t){sl(al(t))}function ll(t){al(t);var e=el[0].button;(sl(el)||"wheel"===t.type)&&t.preventDefault();var i=pl.bind[e];i&&Rh(i,Hh.includes(t.type),e+1)}var ul,cl=null,pl=new zh(0,0,1,1),dl=!1;function fl(t,e,i){i=i||Qn.pull("Vector2d");var o=sa(Nc.getCanvas()),n=globalThis.devicePixelRatio||1;t-=o.left+(globalThis.pageXOffset||0),e-=o.top+(globalThis.pageYOffset||0);var r=Uc;return 1===r.x&&1===r.y||(t/=r.x,e/=r.y),i.set(t*n,e*n)}function yl(t,e){t.style["touch-action"]=e||"none"}function gl(t,e,i){if(il(),-1===Qh.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=nl(Nh,tl[t]);jh.has(e)||jh.set(e,{region:e,callbacks:{},pointerId:null});for(var n=jh.get(e),r=0;r<o.length;r++)t=o[r],n.callbacks[t]?n.callbacks[t].push(i):n.callbacks[t]=[i]}function vl(t,e,i){if(-1===Qh.indexOf(t))throw new Error("invalid event type : "+t);var o=nl(Nh,tl[t]),n=jh.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)Vn(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&&jh.delete(e)}}function ml(t){if(jh.has(t))for(var e=0;e<Qh.length;e++)vl(Qh[e],t)}var xl=.1;function _l(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 bl=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,wl=/^0+/;function Tl(t,e){var i=t.replace(bl,(function(t,e,i){return"000".slice(e.length-1)+e+"-"+"000".slice(i.length-1)+i+"-"})),o=t.replace(bl,(function(t,e,i){return e.replace(wl,"")+"-"+i.replace(wl,"")+"-"}));e.analog=e.analog||e.buttons.map((function(){return-1})),e.normalize_fn=e.normalize_fn||function(t){return t},Sl.set(i,e),Sl.set(o,e)}var Al,El={},Sl=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:_l}],["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:_l}]].forEach((function(t){Tl(t[0],t[1])}));var Cl=function(){var t=navigator.getGamepads();Object.keys(El).forEach((function(e){var i=t[e];if(i){var o=null;"standard"!==i.mapping&&(o=Sl.get(i.id));var n=El[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)>=xl}}Zr(zr,e,"buttons",+t,h),!r.pressed&&h.pressed?Rh(r.keyCode,!0,s+256):r.pressed&&!h.pressed&&Rh(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)>=xl+Math.abs(r[h].threshold);Zr(zr,e,"axes",+t,a),!r[h].pressed&&l?(r[-h].pressed&&(Rh(r[-h].keyCode,!1,s+256),r[-h].value=0,r[-h].pressed=!1),Rh(r[h].keyCode,!0,s+256)):!r[h].pressed&&!r[-h].pressed||l||Rh(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){Zr(Dr,t.gamepad)}),!1),globalThis.addEventListener("gamepaddisconnected",(function(t){Zr(Lr,t.gamepad)}),!1));for(var Ml=Tl,Pl=!0,Ol=Object.freeze({__proto__:null,preventDefault:Pl,get pointerEventTarget(){return cl},pointer:pl,get locked(){return dl},get throttlingInterval(){return ul},globalToLocal:fl,setTouchAction:yl,bindPointer:function(){var t=arguments.length<2?pl.LEFT:arguments[0],e=arguments.length<2?arguments[0]:arguments[1];if(il(),!Bh(e))throw new Error("no action defined for keycode "+e);pl.bind[t]=e},unbindPointer:function(t){pl.bind[void 0===t?pl.LEFT:t]=null},registerPointerEvent:gl,releasePointerEvent:vl,releaseAllPointerEvents:ml,requestPointerLock:function(){return!!Bs&&(Xc().requestPointerLock(),!0)},exitPointerLock:function(){return!!Bs&&(document.exitPointerLock(),!0)},get keyBoardEventTarget(){return Ih},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:kh,isKeyPressed:function(t){return!(!Th[t]||Eh[t])&&(Ah[t]&&(Eh[t]=!0),!0)},keyStatus:function(t){return Th[t]>0},triggerKeyEvent:Rh,bindKey:function(t,e,i,o){void 0===o&&(o=Pl),Mh[t]=e,Ch[t]=o,Th[e]=0,Ah[e]=i||!1,Eh[e]=!1,Sh[e]={}},getBindingKey:Bh,unlockKey:function(t){Eh[t]=!1},unbindKey:function(t){var e=Mh[t];Th[e]=0,Ah[e]=!1,Sh[e]={},Mh[t]=null,Ch[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(!Bh(i))throw new Error("no action defined for keycode "+i);void 0===Al&&"function"==typeof navigator.getGamepads&&(Al=Qr(Er,Cl)),El[t]||(El[t]={axes:{},buttons:{}});var o={keyCode:i,value:0,pressed:!1,threshold:e.threshold},n=El[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(!El[t])throw new Error("no bindings for gamepad "+t);El[t].buttons[e]={}},setGamepadDeadzone:function(t){xl=t},setGamepadMapping:Ml}),Il=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=Qn.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 _h?this.anchorPoint.setMuted(.5,.5).setCallback(this.onAnchorUpdate,this):this.anchorPoint=Qn.pull("ObservableVector2d",.5,.5,{onUpdate:this.onAnchorUpdate,scope:this}),this.autoTransform=!0,this.alpha=1,this.ancestor=void 0,this.mask=void 0,this.blendMode="normal",this.name="",this.pos instanceof wh?this.pos.setMuted(e,i,0).setCallback(this.updateBoundsPos,this):this.pos=Qn.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},tint:{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.tint.get=function(){return void 0===this._tint&&(this._tint=Qn.pull("Color",255,255,255,1)),this._tint},i.tint.set=function(t){void 0===this._tint&&(this._tint=Qn.pull("Color",255,255,255,1)),t instanceof ar?this._tint.copy(t):this._tint.parseCSS(t)},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=Bn(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 Kl&&!0!==this.floating&&i.translate(this.ancestor.getAbsolutePosition()),this.isDirty=!0},e.prototype.getAbsolutePosition=function(){return void 0===this._absPos&&(this._absPos=Qn.pull("Vector2d")),this._absPos.set(this.pos.x,this.pos.y),this.ancestor instanceof Kl&&!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(){Qn.push(this.currentTransform),this.currentTransform=void 0,Qn.push(this.anchorPoint),this.anchorPoint=void 0,Qn.push(this.pos),this.pos=void 0,void 0!==this._absPos&&(Qn.push(this._absPos),this._absPos=void 0),Qn.push(this._bounds),this._bounds=void 0,this.onVisibilityChange=void 0,void 0!==this.mask&&(Qn.push(this.mask),this.mask=void 0),void 0!==this._tint&&(Qn.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),ml(this),this.onDestroyEvent.apply(this,arguments)},e.prototype.onDestroyEvent=function(){},Object.defineProperties(e.prototype,i),e}(qa),kl=[],Rl=0;Rl<10;Rl++)kl.push(new Jn);for(var Bl=[],Dl=0;Dl<5;Dl++)Bl.push([]);function Ll(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 zl(t,e,i,o,n,r){var s=Bl.pop(),a=Bl.pop(),h=kl.pop().copy(e).sub(t),l=h.dot(n);if(Ll(i,n,s),Ll(o,n,a),a[0]+=l,a[1]+=l,s[0]>a[1]||a[0]>s[1])return kl.push(h),Bl.push(s),Bl.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 kl.push(h),Bl.push(s),Bl.push(a),!1}function Fl(t,e){var i=t.length2(),o=e.dot(t);return o<0?-1:o>i?1:0}function jl(t,e,i,o,n){for(var r=kl.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=kl.pop(),p=kl.pop(),d=kl.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,x=null;c.copy(l[y]),d.copy(r).sub(h[y]),n&&d.length2()>a&&(n.aInB=!1);var _=Fl(c,d),b=!0;if(-1===_){var w=null;if(u>1&&(c.copy(l[v]),1!==(_=Fl(c,w=kl.pop().copy(r).sub(h[v])))&&(b=!1)),b){if((f=d.length())>s)return kl.push(r),kl.push(c),kl.push(p),kl.push(d),w&&kl.push(w),!1;n&&(n.bInA=!1,x=d.normalize(),m=s-f)}w&&kl.push(w)}else if(1===_){if(u>1&&(c.copy(l[g]),d.copy(r).sub(h[g]),-1!==(_=Fl(c,d))&&(b=!1)),b){if((f=d.length())>s)return kl.push(r),kl.push(c),kl.push(p),kl.push(d),!1;n&&(n.bInA=!1,x=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 kl.push(r),kl.push(c),kl.push(p),kl.push(d),!1;n&&(x=p,m=s-f,(f>=0||m<2*s)&&(n.bInA=!1))}x&&n&&Math.abs(m)<Math.abs(n.overlap)&&(n.overlap=m,n.overlapN.copy(x))}return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),kl.push(r),kl.push(c),kl.push(p),kl.push(d),!0}var Vl=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=kl.pop().copy(t.pos).add(t.ancestor.getAbsolutePosition()).add(e.pos),d=kl.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos);for(r=0;r<h;r++)if(zl(p,d,s,l,a[r],n))return kl.push(p),kl.push(d),!1;for(r=0;r<c;r++)if(zl(p,d,s,l,u[r],n))return kl.push(p),kl.push(d),!1;return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),kl.push(p),kl.push(d),!0},testEllipseEllipse:function(t,e,i,o,n){var r=kl.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 kl.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 kl.push(r),!0},testPolygonEllipse:jl,testEllipsePolygon:function(t,e,i,o,n){var r=jl(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}}),Ul=function(){this.a=null,this.b=null,this.overlapN=new Jn,this.overlapV=new Jn,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE};Ul.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this};var Nl={pos:new Jn(0,0),ancestor:{_absPos:new Jn(0,0),getAbsolutePosition:function(){return this._absPos}}},Gl=new Ul;function Xl(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 Hl={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=iu.world.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);Vl["test"+a.shapeType+l.shapeType].call(this,Nl,a,i,l)&&(e[o]=i,o++),h++}while(h<s)}return e.length=o,e}(t,e)}},Yl=function(t,e,i){if(this.ancestor=t,void 0===this.bounds&&(this.bounds=Qn.pull("Bounds")),void 0===this.shapes&&(this.shapes=[]),this.collisionMask=Hl.types.ALL_OBJECT,this.collisionType=Hl.types.ENEMY_OBJECT,void 0===this.vel&&(this.vel=Qn.pull("Vector2d")),this.vel.set(0,0),void 0===this.force&&(this.force=Qn.pull("Vector2d")),this.force.set(0,0),void 0===this.friction&&(this.friction=Qn.pull("Vector2d")),this.friction.set(0,0),this.bounce=0,this.mass=1,void 0===this.maxVel&&(this.maxVel=Qn.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};Yl.prototype.setStatic=function(t){void 0===t&&(t=!0),this.isStatic=!0===t},Yl.prototype.addShape=function(t){if(t instanceof qa||t instanceof Ja){var e=t.toPolygon();this.shapes.push(e),this.bounds.add(e.points),this.bounds.translate(e.pos)}else t instanceof Za?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addBounds(t.getBounds()),this.bounds.translate(t.getBounds().x,t.getBounds().y)):t instanceof Wa?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.add(t.points),this.bounds.translate(t.pos)):t instanceof eh?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addPoint(t)):this.fromJSON(t);return"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this),this.shapes.length},Yl.prototype.setVertices=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=!0);var o=this.getShape(e);o instanceof Wa?o.setShape(0,0,t):this.shapes[e]=Qn.pull("Polygon",0,0,t),this.bounds.add(this.shapes[e].points,i),"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this)},Yl.prototype.addVertices=function(t,e){void 0===e&&(e=0),this.setVertices(t,e,!1)},Yl.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},Yl.prototype.getShape=function(t){return this.shapes[t||0]},Yl.prototype.getBounds=function(){return this.bounds},Yl.prototype.removeShape=function(t){this.bounds.clear(),Vn(this.shapes,t);for(var e=0;e<this.shapes.length;e++)this.addShape(this.shapes[e]);return this.shapes.length},Yl.prototype.removeShapeAt=function(t){return this.removeShape(this.getShape(t))},Yl.prototype.setCollisionMask=function(t){void 0===t&&(t=Hl.types.ALL_OBJECT),this.collisionMask=t},Yl.prototype.setCollisionType=function(t){if(void 0!==t){if(void 0===Hl.types[t])throw new Error("Invalid value for the collisionType property");this.collisionType=Hl.types[t]}},Yl.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),!this.ignoreGravity)){var i=!0===this.falling?1:!0===this.jumping?-1:0;this.falling=e.y>=i,this.jumping=e.y<=-i}},Yl.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++},Yl.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},Yl.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 Za?i.bounds.translate(o.getBounds().x,o.getBounds().y):i.bounds.translate(o.pos)})),this},Yl.prototype.setMaxVelocity=function(t,e){this.maxVel.x=t,this.maxVel.y=e},Yl.prototype.setFriction=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.friction.x=t,this.friction.y=e},Yl.prototype.update=function(t){var e=Jc.tick;if(0!==this.force.x&&(this.vel.x+=this.force.x*e),0!==this.force.y&&(this.vel.y+=this.force.y*e),this.friction.x>0){var i=this.friction.x*e,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*e,s=this.vel.y+r,a=this.vel.y-r;this.vel.y=s<0?s:a>0?a:0}return 0!==this.vel.y&&(this.vel.y=Bn(this.vel.y,-this.maxVel.y,this.maxVel.y)),0!==this.vel.x&&(this.vel.x=Bn(this.vel.x,-this.maxVel.x,this.maxVel.x)),this.falling=this.vel.y*Math.sign(this.force.y)>0,this.jumping=!this.falling&&this.jumping,this.ancestor.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},Yl.prototype.destroy=function(){Qn.push(this.bounds),Qn.push(this.vel),Qn.push(this.force),Qn.push(this.friction),Qn.push(this.maxVel),this.shapes.forEach((function(t){Qn.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 Wl=function(t,e){this.removeChildNow(t,e)},ql=0,Kl=function(t){function e(e,i,o,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=iu.viewport.width),void 0===n&&(n=iu.viewport.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=iu.sortOn,this.autoSort=!0,this.autoDepth=!0,this.clipping=!1,this.onChildChange=function(t){},this.enableChildBoundsUpdate=!1,this.backgroundColor=Qn.pull("Color",0,0,0,0),this.drawCount=0,this.autoTransform=!0,this.isKinematic=!1,this.anchorPoint.set(0,0),!0===this.root&&Qr(Gr,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=Kc.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()&&iu.repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Yl&&iu.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=Kc.createGUID()),t.ancestor=this,this.getChildren().splice(i,0,t),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&iu.repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Yl&&iu.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,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.");Kc.function.defer(Wl,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 Yl&&iu.world.removeBody(t.body),e||!1===Qn.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()&&iu.repaint(),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=Kc.function.defer((function(){this.getChildren().sort(this["_sort"+this.sortOn.toUpperCase()]),this.pendingSort=null,iu.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,n=Au.isPaused(),r=this.getChildren(),s=r.length;s--,i=r[s];)n&&!i.updateWhenPaused||(i.isRenderable?((o=ql>0||i.floating)&&ql++,i.inViewport=!1,Au.current().cameras.forEach((function(t){t.isVisible(i,o)&&(i.inViewport=!0)})),this.isDirty|=(i.inViewport||i.alwaysUpdate)&&i.update(e),ql>0&&ql--):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}(Il),Zl=[];function Ql(t,e,i,o,n){if(void 0===i&&(i=4),void 0===o&&(o=4),void 0===n&&(n=0),Zl.length>0){var r=Zl.pop();return r.world=t,r.bounds=e,r.max_objects=i,r.max_levels=o,r.level=n,r}return new $l(t,e,i,o,n)}var Jl=new Jn,$l=function(t,e,i,o,n){void 0===i&&(i=4),void 0===o&&(o=4),void 0===n&&(n=0),this.world=t,this.bounds=e,this.max_objects=i,this.max_levels=o,this.level=n,this.bounds=e,this.objects=[],this.nodes=[]};$l.prototype.split=function(){this.level;var t=this.bounds.width/2,e=this.bounds.height/2,i=this.bounds.left,o=this.bounds.top;this.nodes[0]=Ql(this.world,this.bounds,{left:i+t,top:o,width:t,height:e},this.max_objects,this.max_levels),this.nodes[1]=Ql(this.world,this.bounds,{left:i,top:o,width:t,height:e},this.max_objects,this.max_levels),this.nodes[2]=Ql(this.world,this.bounds,{left:i,top:o+e,width:t,height:e},this.max_objects,this.max_levels),this.nodes[3]=Ql(this.world,this.bounds,{left:i+t,top:o+e,width:t,height:e},this.max_objects,this.max_levels)},$l.prototype.getIndex=function(t){var e,i=t.getBounds(),o=-1,n=(e=!0===t.isFloating?this.world.app.viewport.localToWorld(i.left,i.top,Jl):Jl.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},$l.prototype.insertContainer=function(t){for(var e,i=t.children.length;i--,e=t.children[i];)!0!==e.isKinematic&&(e instanceof Kl?("rootContainer"!==e.name&&this.insert(e),this.insertContainer(e)):"function"==typeof e.getBounds&&this.insert(e))},$l.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}},$l.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},$l.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=Vn(this.nodes[i],t))&&this.nodes[i].isPrunable()&&this.nodes.splice(i,1)}return!1===e&&-1!==this.objects.indexOf(t)&&(Vn(this.objects,t),e=!0),e},$l.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},$l.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},$l.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],Zl.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 tu=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.app=null,this.fps=60,this.gravity=new Jn(0,.98),this.preRender=!1,this.bodies=new Set,this.broadphase=new $l(this,this.getBounds().clone(),Hl.maxChildren,Hl.maxDepth),Qr(Ar,this.reset,this),Qr(Or,(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.bodyApplyGravity=function(t){if(!t.ignoreGravity&&0!==t.gravityScale){var e=this.gravity;t.force.x+=t.mass*e.x*t.gravityScale,t.force.y+=t.mass*e.y*t.gravityScale}},e.prototype.update=function(e){var i=this,o=Au.isPaused();return this.broadphase.clear(),this.broadphase.insertContainer(this),this.bodies.forEach((function(t){if(!t.isStatic){var n=t.ancestor;o&&!n.updateWhenPaused||!n.inViewport&&!n.alwaysUpdate||(i.bodyApplyGravity(t),!0===t.update(e)&&(n.isDirty=!0),function(t,e){void 0===e&&(e=Gl);for(var i,o=0,n=iu.world.broadphase.retrieve(t),r=n.length;i=n[--r];)if(i!==t&&Xl(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===Vl["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)}}(n),t.force.set(0,0))}})),t.prototype.update.call(this,e)},e}(Kl),eu=function(){this.viewport=null,this.world=null,this.mergeGroup=!0,this.sortOn="z",this.lastUpdate=0,this.isDirty=!0,this.isAlwaysDirty=!1,this.frameCounter=0,this.frameRate=1,this.accumulator=0,this.accumulatorMax=0,this.accumulatorUpdateDelta=0,this.stepSize=1e3/60,this.updateDelta=0,this.lastUpdateStart=null,this.updateAverageDelta=0};eu.prototype.init=function(){this.world=new tu,this.world.app=this,this.lastUpdate=globalThis.performance.now(),Zr(Tr,this)},eu.prototype.reset=function(){var t=Au.get();void 0!==t&&(this.viewport=t.cameras.get("default")),Zr(Ar),this.updateFrameRate()},eu.prototype.onLevelLoaded=function(){},eu.prototype.updateFrameRate=function(){this.frameCounter=0,this.frameRate=~~(.5+60/Jc.maxfps),this.stepSize=1e3/this.world.fps,this.accumulator=0,this.accumulatorMax=10*this.stepSize,this.isAlwaysDirty=Jc.maxfps>this.world.fps},eu.prototype.getParentContainer=function(t){return t.ancestor},eu.prototype.repaint=function(){this.isDirty=!0},eu.prototype.update=function(t,e){if(++this.frameCounter%this.frameRate==0){for(this.frameCounter=0,Zr(Er,t),this.accumulator+=Jc.getDelta(),this.accumulator=Math.min(this.accumulator,this.accumulatorMax),this.updateDelta=Jc.interpolation?Jc.getDelta():this.stepSize,this.accumulatorUpdateDelta=Jc.interpolation?this.updateDelta:Math.max(this.updateDelta,this.updateAverageDelta);this.accumulator>=this.accumulatorUpdateDelta||Jc.interpolation;)if(this.lastUpdateStart=globalThis.performance.now(),!0!==Au.isPaused()&&Zr(Cr,t),this.isDirty=e.update(this.updateDelta)||this.isDirty,this.lastUpdate=globalThis.performance.now(),this.updateAverageDelta=this.lastUpdate-this.lastUpdateStart,this.accumulator-=this.accumulatorUpdateDelta,Jc.interpolation){this.accumulator=0;break}Zr(Sr,this.lastUpdate)}},eu.prototype.draw=function(t){!0===Nc.isContextValid&&(this.isDirty||this.isAlwaysDirty)&&(Zr(Mr,globalThis.performance.now()),Nc.clear(),t.draw(Nc),this.isDirty=!1,Nc.flush(),Zr(Pr,globalThis.performance.now()))};var iu=new eu;Qr(gr,(function(){iu.init()}));var ou,nu=Math.min,ru=Math.max,su=new Jn,au=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=Qn.pull("Bounds"),this.smoothFollow=!0,this.damping=1,this.near=-1e3,this.far=1e3,this.projectionMatrix=new lr,this.invCurrentTransform=new cr,this.offset=new Jn,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(),Qr(Ar,this.reset,this),Qr(Gr,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=nu(t.x-this.deadzone.right,this.bounds.width-this.width):t.x-this.pos.x<this.deadzone.pos.x&&(e=ru(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=nu(t.y-this.deadzone.bottom,this.bounds.height-this.height):t.y-this.pos.y<this.deadzone.pos.y&&(e=ru(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 qa(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(),Zr(Xr,this.width,this.height,this),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 Jn||e instanceof bh||e instanceof _h||e instanceof wh))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:Bn(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=Bn(t,this.bounds.left,this.bounds.width),this.pos.y=Bn(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(su.setV(this.pos),this.follow_axis){case this.AXIS.NONE:break;case this.AXIS.HORIZONTAL:su.x=this._followH(this.target);break;case this.AXIS.VERTICAL:su.y=this._followV(this.target);break;case this.AXIS.BOTH:su.x=this._followH(this.target),su.y=this._followV(this.target)}if(!this.pos.equals(su)){if(!0===this.smoothFollow&&this.damping<1){if(Fn(su.x,this.pos.x,2)&&Fn(su.y,this.pos.y,2))return void this.pos.setV(su);this.pos.lerp(su,this.damping)}else this.pos.setV(su);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&&Zr(Wr,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=Qn.pull("Color").copy(t),this._fadeOut.tween=Qn.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=Qn.pull("Color").copy(t);var o=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=Qn.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?Nc.overlaps(t.getBounds()):t.getBounds().overlaps(this)},e.prototype.localToWorld=function(t,e,i){return(i=i||Qn.pull("Vector2d")).set(t,e).add(this.pos).sub(iu.world.pos),this.currentTransform.isIdentity()||this.invCurrentTransform.apply(i),i},e.prototype.worldToLocal=function(t,e,i){return(i=i||Qn.pull("Vector2d")).set(t,e),this.currentTransform.isIdentity()||this.currentTransform.apply(i),i.sub(this.pos).add(iu.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,Qn.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,Qn.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,this),e.draw(t,this),this.drawFX(t),e.postDraw(t,this),this.postDraw(t),e.currentTransform.translate(i,o)},e}(Il),hu={cameras:[]},lu=function(t){this.cameras=new Map,this.lights=new Map,this.ambientLight=new ar(0,0,0,0),this.settings=Object.assign(hu,t||{})};lu.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===ou){var e=Nc.getWidth(),i=Nc.getHeight();ou=new au(0,0,e,i)}this.cameras.set("default",ou)}iu.reset(),this.onResetEvent.apply(this,arguments)},lu.prototype.update=function(t){var e=iu.world.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},lu.prototype.draw=function(t){var e=this;this.cameras.forEach((function(i){i.draw(t,iu.world),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,iu.world),e.draw(t,iu.world),e.postDraw(t,iu.world)}))}))},lu.prototype.destroy=function(){this.cameras.clear(),this.lights.forEach((function(t){t.destroy()})),this.lights.clear(),this.onDestroyEvent.apply(this,arguments)},lu.prototype.onResetEvent=function(){"function"==typeof this.settings.onResetEvent&&this.settings.onResetEvent.apply(this,arguments)},lu.prototype.onDestroyEvent=function(){"function"==typeof this.settings.onDestroyEvent&&this.settings.onDestroyEvent.apply(this,arguments)};var uu=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.barHeight=n,this.anchorPoint.set(0,0),Qr(kr,this.onProgressUpdate,this),Qr(Xr,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,e){t.setColor("black"),t.fillRect(this.pos.x,e.centerY,t.getWidth(),this.barHeight/2),t.setColor("#55aa00"),t.fillRect(this.pos.x,e.centerY,this.progress,this.barHeight/2)},e.prototype.onDestroyEvent=function(){$r(kr,this.onProgressUpdate),$r(Xr,this.resize)},e}(Il),cu=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(){iu.world.backgroundColor.parseCSS("#202020"),iu.world.addChild(new uu(0,Nc.getHeight()/2,Nc.getWidth(),8),1),fc.load({name:"melonjs_logo",type:"image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAA8FBMVEUgICBrqDHRZVtqpzEhJCAjKCBurTIfHyDQZFptrDEWAB8OAB7VZ1wtIiIAEhYlISDYaF4SAB4pIiEAFhkcFh8eGyBopDAMAB5noS8kKyAAGhtjmy4bEB9lni8ZBR/HYFdPeim/XFQ9XCUaCh9flS1VhCtSfyorOSEVHh4HHB1EZyatVExhmC5ajCxHbSc0SyMuQCInMiFKcSgxRSI6VSRBYiWdTUZdki09JyZ8PzpYiSs3UCRlNjK1WE9ckC1MdShbjywyJCONRkDKYliUSUNeMzBDKShXMC2kUEl1PDeEQj1OLStnNjNxOjZsODQAAAcMh1CFAAAU4UlEQVR42uyaa3fSMBjHk5EQkgClkBZKoXblNhlswIooc2N6pp7jUb//x/FpRbnt4JWwzv7eraQvfs/zby7tUEpKSkpKSkpKSkpKSkpKSkqKTsg30P8E+FIArJllqQaglMXQt6tPuhogGSlaLWFKKU2hEB33eqPRqDemRAlhRhdbVjwIBj8xogajhpBSkNH1dOJ37mYDt1mr2UCt1mwOZned7qQfjhxPVs0WovTpRIFFNkpIU42CSWfm2phnIzjHP+DLS9hutjuL4IqZUigC9yU/CWDBhBROOJkPbBxL4swKjDf/jEvBbXe4CMeiKixKEx0EAq03JbqeDJs4Ul9a7mE5AqqAazM/pJCb5JaAUmWa42nHBflYDf8y8WC4qznv9yRKZAUIRUKO+/Maz/J1+d8ugu0rK3kVoNSTVhDZr8v/WRGyQw8lC0KJMK989+/sVzXILiRNzmrACGXSC4Z2lsf2f08GN2lyHgJCLUn6bRw1/2dim+A9hIKiJMAQ6NOJu7f5a7r8B+u/7N7BAzMZBaBIkkkz0t83sfMsgDHsgN1BOybaFNvww2qblMgEUGKqi2aU/X3u2HZnHf8iuL4aO0S1PKDVQM54dBn0F50718bfq5CwOYBQIaaDVfd37MG91u5MwhER8WHQU8qC2wCEmFJefEYUrBdedGe15b4xQasAtaqXt/wh/W87W1679YNeCxQbjNCItTchBFheRErAmHEYb575ch/Qeuz9ByXpdHH2QX2wx4NuMBbSbJCfn3IJWZ4dndBvZ6Bytt949A8AbZjT6OHftQeDTHtx2VgebhFj6KfAmGisJaS46k+mj/4sELW/N+QP6UOIXf/Sqwq0p/F7okA8KU312BcAqmTf3k1/1Hx7HlgyskfsL96h7b3XMNCRcYQzz+KH9N3FSC57fxiYUTDOWLmAjgcjpBo2d9oPKxdv95Fs0UPGl5XPinWDVYqGwdBxYFQJH/Mdfc5nQUuyw77KYYXKm/ub09PzV/Xn5SNVAOJ/B/Hf0W8HwiQUHRTwf/2slM/nS6WbN/XjZIDK6534w8zv9r1In6GDUq6/y+VzMaVTdGYg7cDj38/wHX17YknQPzSGUb8p5U5icqX7ovaZkBFk+nw7/hx3epIdvPtAufIpf7Ikl39W0B0BRpToQPy32j8IZUPPW+xC8S0E4Afv6noLwGgL3WZ32u8roetbTqF4v1aA/JdKGWmEUc8ZgP/m0j+4riKKNFEoflwrQO6D1gQwKnrulj/mXUto048XgZV+/vQMaYQ5otfc8s/Wpprav5oFz5cRgHXwo85VgFHw55nN+Ld7UvMnPOP5y2elXMRJ6VzDA7DPH2e7XstBemHl+vubfAk4efGc6SsAo9542x9fVJH+D/lQgfrnF+fn9++KWv0bdHP+z3A7rFKC9MMMo1KsVIr1ssYHgFiqvemfdUemg45EuVAuFMpIH4SI4ZZ/2xEOQ8eCAUgjVHa3/G+txuN/Z/+vYE51suU/9NT/5G8GIL3uPxfsCfwf11fyrW1FgRiGTkna0vZpYHQUXRHdVZBhvCMorP7/V+3oyprgPiy2Dxk2HzA06TknpyHz19CjVfcpf9kj+6SBtqgcMPz/q/vPdPgwLP/DsCM1f2vTf7Ifap5/hYXQ/FGnX7S16LdABADc23oqVP91kYfgrU5b1GxKHSCo7tILzR/z9eJ8nliv0zqAMZ8ATEJfaP6+7jlj3CDlXpHVfsfnH+eyn4kMzMdGQRNO7fNkGEXbGTigBkDq1lZzU07BnaXzIab6LCMAuEEmdWcD8+ax9uNTckxFqyWxwKBgKXZrzerHtAbcPhFQ0R8oAExdChXADIt1Tz0KkGi9TjML1CBLqgA0YZGIFZhZqVNUtf9GCdBbF0IF4Be/vvQYz6pyxhRwH+QC4CpXoAgELvE6iKMtfwJLzv+5YU2iDasOR0MJMBdMgFsMK6ICrppGY+rELGAdhFpAYoXYgRdBRzsLUtB3L/z+7zpITFvHYhQAdorGyQudAdCuNe8qoJjVNgYAF0M+9iFbAe9tK2w4BKIIdVJ0CLASv7jeBFo7cBwCrxcgP1IAjEv5ALipwII1gmGGMR4A2uEB+blJK4x4E1kdZhQA5xYowPe58z3lwKfH199WbQRAc/LpuwPWu17k0qaFCnANAgHSvKJcZdMCxJtgOsQuKsexG2uCwMxa8O8aUa/axHZCe/OUZA42ag0Avqi5ll2nYSAaRQEbZI+NrbKwEFFYJURCiEcpqEE0aZOmBfH/f4PLQ+OEttwxLKg3jq5Or3TG9jyOJ/FjgSIGZvBRLhB1oFvi7/3X5CIDhZHodOLtfyyEXUlh0IGzyDoQM+rbGljFRNaE2ZOXj0MT3pALxGQo8v1z1ILRBb6+hTJoZgLvBoMYRjZAeALuv/v/hZCzeTxWRIu/iwEvbqQMmKcxUekwHqF/KQSo74OCVX8rCyQoC9C/QYBZENZTcYMlRkqjWFlVZfn9OWGXwcoDVFKewD+fo33v9AwQD3HGFqH5XsXHACWVA7BObfp+YyoL4BKpLvb+MuvBlVn1q03iwIONVNFy1jPUBvGyPOaGJT4GGOPAHd9v66bIuy7Pi3p5GKoTrYSdeRXaQrk7LD02P2Gbejv2FqrYdugFxgHM5ChBEFNpIn/czxaObdMJrcXP4Z94sdxZUGZmAZmA+7ws0im4a9oenFQsKg58uE8NhBgE43+LlBysa65FmvJweIppMzobsmJKWve+EFrMsUJ3+wEqGaUKPA9XkSYNhj0xUd8xYkbBsU516lnMhv+LFs1nKCX7BZYVjIUQZ8FC830PRjG6LnSqBzCSPcloP0U9IaLZhknntlynSGhOS+yV/bWuEla1EPwSONXdAc0VKYv4ZcyoWQBGEDp/2zdI/zyrYgfyR6CAL7nm18BC18pJFnlLhuUMsScgvs9CwjrXyOgCq/Q9yIQpBa0Q/DqW6+JoJSNX9AGNT4S2uezhx8B9kBvu2AZGjpQubwLRglHKLnX6Z7DodmgBQjDHkji7O3+MoFFZgITx+pLiMdiChL1G7DUL8DWQLBDPw3dGh5Yjn38YT+TuMrhuvy71HbGiGyzRAg8DVYQQzO49evYg7ArLiP7v82/7n3OcZ8u6F36+IzjfVCqivwkTetqNCHpP2nvdfS74PJTr7zH+NM9pTflPwTMbcN1YkgEwFcL7EXIddf85LQ1SrtZ8FsO6uh13w7Abt02nZ7tjbiuR1+2Xn2COYPxaCCM3+KCqQz86fnpDSgOkPQg+i/dtb8E6P/zUt8Vln+/pF4fVD7D103Gbz8B8cIbULeJlHXqLM2ZQZDHEuGMnpsF+m0Alpfk+pKmAtZdCJNf5wUGJYAervRB8eggotSH2SlAy2myBchi14VbCxKlzka+BScWCqofBUASYCbsVKAQzD65g7CbmEl9OCTQtocEm74ysiPsq6imhilLVxANyUfR2o9i0SN7YstH8DP+9db+DYcD/iFsgqnXWd02SXAc9CrLpx124yFd2w35HlQ4tEPCHxPwO9haY7oG1NbQbMnLPYPbw2YNIMYAlxeTIDlP+WP0axAUhTrGzefUXEeK+kXetvU3DUDQtqdxKSQwJG1romIbQSLWhfuChFRioG92rsP//c3AiwbErxfKxBMoFf/am5cyPc+899/hDkTOJHZ4IKMQQrC6irDZTh+YVa9VHlsbuyK6uEe7tINCdK9hVutGkUgL/S0pox5cEchPX2X9qrXVfuIQIoAcsDN2sj+yb5XuVU8JZlgkpZ+PMzMbhvG0AwKqfteh6O3VZbqL8J4tNhggAluxxBgaNEIK7A/BNWvkWC7DCV/X+3qsMU0+LkqiS75NyMUhD+LqqrjdT51TPlQeAVTZ11nXpW1nm1sDOWhA1blBBcGEincwV1crqwV7Vq6r0U8ZxiCEevONwtzaaKnGS6X3lCGRHSwaAuyzU4Uyr5tjaLv4wL6+cm3BbxwFw9pSujJsfowBY2UfAutHeyRftZGwXb4RxY2+XDQHAgQGAlblMHI382xeRABwnSicBpyDYjS/HADYILhiYFAMA6k8DUDgANCQAfue0bPy3AeC3QD48AGK2gHLOgJFwAKhDENfgvwkArkGGCH0SDcAuEeKp8MhQYcEAtFT4EU2Fn9nB0HvJAExQHEMwRIfDogFgw2GI7eGXIhkANyESlxITvQLc/2UwAO+cLILgW4BMikIg46TF01QwAGxaHOwBuoI9uQBwhRGMPbs09nouFwCo3fAlLG6GCooFAMVRrGVaXTUz5XGxAHjK44xAQioArUBiZgskYiUyUrcAKhygdDEiqT2xPACZDS6qSe2+y04hIROAFM5aSO6F2qe5pmxDAMBJivJCydFhqsiOK9SHhQLQNb/ahTHFycsglh7EFogB4IQUSyORsqT841Aay8aBxR7VqYlQHPfK33SysAUVwY/qzF/ZO5kRfKLljAkidJMfZaEPgJXVD+ubNnUZqL0yS0upwKAOWidW7ZY++UhSIRQxp79KmAvth8sIha5Q8VZJ0B6YdquFaZlBTjyl7UMQEQcXyG8fZ93TN+MHCJv75l4bzWQ3+RhlRI8A2UzGozpEdpvjgSDRYALh7TY6qS+PWpHvBcT9nmdizk+nmQHsNq+xAHoRuLkYt21k32qlQ/01D0es0gVUCIcAZUimdbG+u7z/XOP7PQgsiu395WpbNKUKaEKqNmbyeZFoNiEKOscrDHkf1bxpmz91GdZY2HWHhjWHlt3kRc6bS/I2IoijIkyadZ7nJTNZU5PpByHAAmhXvkgfGqXUACY77fOc5h2SeXRciTNQ2Gkef56oOAsNtF1KQwCRIN/9CxqFZII8E5WXFpdFiZeW2oNHyRrIhSAfGrMHUCUfrKN8yAI+oYyUkFK2HaVFW2khtR/rPzDal+UkZGjwzOMAwRSJkReScwyi5QGdEvxI2wqZSEdNeGryRNYl018dT9X/zlIzndt0eHR4MNSnVXyPgoAGR3tKYidJ8dOa4PRCTTD2eRl7CUyEmAqirIHqbuxveuOcAjIuApwAHjNFKqmC5lsZIdH8zGuuzp8mYJQCTgGo/FARix7KMSQzYzn8vAAU8gFGcPQS+DJ8AH4rndH8PqQ3S35yd2U7isNAMFHasWw/WcopQhRBIBICQsggJCIx/P9XrTMcDWbZY5YQs36Yh4EZXNXl7vJB3Hkjd7fCkCfc3/ZGbgh4zp5xwYbuBdBWGr00pF2OrT0E6p/sIH6V1uRHTANeDv1NE/j4rB1mFYMHgTYJsJtnrGORL1W9w107NA4/u+gqjL+cFXprU2+cbSvA828GxFKImwRmLpDiji6WwCdvsuDjOU1MA7iI+WzXBj4MmfFpQKuAeC7wOdss6n8afe8qjaUaqNdRWoeEPt1g4wPGpFkMUJKuIruDAaA/ahsToVmXr4NnYanq4GI4eq4waLKJZxADYF12MvFIEO3EZKPLTMxxhADo1ztK0zgtxIND3JhieKnTeKEEhacT4F9OHOB+qRkMXHZwcCOzgwxFv76IfKszMxgg4bqNDDa26cSs01hsmKMtDlj9X8La4sfAdHkvHn6vHhngtGcGAJT+EX+3RxnwDDV+GPf7rIYUQGQa/tyj3RFA063GwN4f98cAJT6f3HaIDaukO1FS8GCuMTCveGz10yhJvIWGP+rWolKSFkMtEw7LvuaGMa/yW/y208iO8GMxXEXslnRnE8LrUyEFIpqhht8edb5aRWNeawzYLJMvnxhQsMKZw16KHw2RzoC7iF+dCOJ0PGX2a/Hj0sNFA5gIPl4zDFD+KzX8dfzhoyh0zwCzP/nrREA8MQu0HtjOSHTeAcwDxcDVPt/d1iGQVygQiKx2rq1FIPh4BX7MA/G5AOEwCNZKBN3PjuJEbCLX0cZgVL90kY6SxFcW5E4EZegTq9N+ECssdszWyZ8X/DX4UYc+n+oydFx7SgR0Z4sogEzWgc684x6s9PV1GMS6DbsmguGMc9IRBUC4HM3d+w+d9jIlAxKOIi0R2A5z85HkHWRDCiQV5YIxR8PP7KWAfiblsSxyV++P6tDhQz5dBS38emLfhV9ZkKa/Q8xknKAdu04Fiw/OLfKssFCLAJf1xEH4PZpQ3ZBvMCdddcvejxLhE3hO8KnkzQ7hX8t/LfvdnwAiiz327IoCli9jwUFxQP8l9kBgLKzNvhX/Pc/zpo+JqD4M+NpBEVzlAjeaNqkYA4Hv00s8wetswJDj6/BPfQNOKlCAsN7+rIPtSMjXKy4SIH8rBGoBEPCkqGYHx8XMfx3+wUdombE9RzhfBg8ocIPDUnHAfULgr0JP1R8Vs13kovZvEq2TqfCbsC1xMkXFzsY46RxsPxuQioRWCQC/RA5AFPhUCL9cL6JW+j+Dz1rXTfuXPzaSiNEcY3XHgT3YLRvCheSeBQR5oKpdIQfLS6WQUM4mA8e9Qa/7TWPCf/FpfLwcIgU6B0zBGe6zWVklMlQ8jD2/BX0mg3pjLkUo07jcZIsWPEP0OvwgA9l78r9vBAT5jB5QcESjYDlRvpsuN01dES/lnEupfqQeVKtmtMx2+dBhJ/APmHSdaWGW+rERPyymAVKgtRMq5rYIg2g4z/P9YbFY7PN8PoyC4wuI/QH8yUokxDIu/Ofk7YVFFmllSyfhjJCxFvIXaqa99Ah+MKnF2KzBf0dBElbrAdNk8IAKbL9/txJIlK1EajT8Yzb0hTXb2pjC/7k5X55qvqzCxHT458mL4M10iDL4bsMSEuxGifDeAv5RBcBFPDsEWMq/H3vmOttlIbhFzKt8v5SBL/hquW85QBL+Xvmuk3+W/H2CfyuDccvBIrKxsP859jb0LNqvy1RweK/gYwMCiZDVKMsDdlLCr2m4vEWBD+bTTcFFCu8XfI0Dr53XjbL9yeRh/dNgo0+yo+10s1LcJW+O/ryo05IQ8ricZYt5pGg4Wr6bxo6/taP5YTprKh624AmYavn+urVgfC6F9KpSef7JYTtQ7jcInLYFyhcP8sMkW27KwudCcA/I+4f+Tgnn+a5CKCT3SVWs6ros63q1qgg9/do7vY3+L6H/0a4dqgAAg1AULYPBsjax+P//uA3TwuJAxj3RJiYf7xJ5rBVVLNzHcA8T7fkZl6iePpchSDvs8b9XBwAAAAAAqGQCc31B4/xqSwwAAAAASUVORK5CYII="},(function(){iu.world.addChild(new yc(Nc.getWidth()/2,Nc.getHeight()/2,{image:"melonjs_logo",framewidth:256,frameheight:256}),2)}))},e.prototype.onDestroyEvent=function(){fc.unload({name:"melonjs_logo",type:"image"})},e}(lu),pu=-1,du=-1,fu=!1,yu={},gu={color:"",duration:0},vu=null,mu=null,xu=0;function _u(){-1===du&&-1!==pu&&(du=globalThis.requestAnimationFrame(bu))}function bu(t){var e=yu[pu].stage;iu.update(t,e),iu.draw(e),-1!==du&&(du=globalThis.requestAnimationFrame(bu))}function wu(){globalThis.cancelAnimationFrame(du),du=-1}function Tu(t){wu(),yu[pu]&&yu[pu].stage.destroy(),yu[t]&&(yu[pu=t].stage.reset.apply(yu[pu].stage,mu),_u(),Zr(br),vu&&vu(),iu.repaint())}Qr(gr,(function(){Au.set(Au.LOADING,new cu),Au.set(Au.DEFAULT,new lu),Qr(wr,(function(){Au.change(Au.DEFAULT,!0)})),"function"==typeof globalThis.addEventListener&&(globalThis.addEventListener("blur",(function(){Au.pause(!0)}),!1),globalThis.addEventListener("focus",(function(){Au.resume(!0),ua()}),!1)),void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("visibilitychange",(function(){"visible"===globalThis.document.visibilityState?Au.resume(!0):Au.pause(!0)}),!1)}));var Au={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),pu!==this.LOADING&&this.isRunning()&&(wu(),!0===t&&t(),xu=globalThis.performance.now(),Zr(xr))},pause:function(t){void 0===t&&(t=!1),pu===this.LOADING||this.isPaused()||(fu=!0,!0===t&&ph(),xu=globalThis.performance.now(),Zr(vr))},restart:function(t){void 0===t&&(t=!1),this.isRunning()||(_u(),!0===t&&dh(),xu=globalThis.performance.now()-xu,iu.repaint(),Zr(_r,xu))},resume:function(t){void 0===t&&(t=!1),this.isPaused()&&(fu&&-1!==pu&&(fu=!1),!0===t&&dh(),xu=globalThis.performance.now()-xu,Zr(mr,xu))},isRunning:function(){return-1!==du},isPaused:function(){return fu},set:function(t,e,i){if(void 0===i&&(i=!1),!(e instanceof lu))throw new Error(e+" is not an instance of me.Stage");yu[t]={},yu[t].stage=e,yu[t].transition=!0,!0===i&&this.change(t)},get:function(t){return void 0===t&&(t=pu),void 0!==yu[t]?yu[t].stage:void 0},current:function(){return this.get()},transition:function(t,e,i){"fade"===t&&(gu.color=e,gu.duration=i)},setTransition:function(t,e){yu[t].transition=e},change:function(t,e){if(void 0===yu[t])throw new Error("Undefined Stage for state '"+t+"'");this.isCurrent(t)||(mu=null,arguments.length>1&&(mu=Array.prototype.slice.call(arguments,1)),gu.duration&&yu[t].transition?(vu=function(){iu.viewport.fadeOut(gu.color,gu.duration)},iu.viewport.fadeIn(gu.color,gu.duration,(function(){Wn(Tu,this,t)}))):!0===e?Tu(t):Wn(Tu,this,t))},isCurrent:function(t){return pu===t}};function Eu(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||mn(i))i=!i||"true"===i;else if(vn(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 Su(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 Cu(t,e){var i=e.nodeName;switch(i){case"data":var o=Mu(e);o.text=o.text||o.chunk.text,o.encoding=o.encoding||"xml",t.data=Su(o.text,o.encoding,o.compression),t.encoding="none";break;case"imagelayer":case"layer":case"objectgroup":case"group":var n=Mu(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=Mu(e).frames;break;case"frame":case"object":var r=i+"s";t[r]=t[r]||[],t[r].push(Mu(e));break;case"tile":var s=Mu(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=Mu(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=Mu(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=Mu(e);break;case"property":var c=Mu(e),p=void 0!==c.value?c.value:c.text;t[c.name]=Eu(c.name,c.type||"string",p);break;default:t[i]=Mu(e)}}function Mu(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:Cu(e,n);break;case 3:i+=n.nodeValue.trim()}}return i&&(e.text=i),e}function Pu(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]=Eu(s,r,a)}}var Ou=536870911,Iu=function(t){function e(e,i,o,n){var r,s;if(t.call(this),n.isCollection){var a=n.getTileImage(o&Ou);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 cr),this.setTileTransform(this.currentTransform.identity())),this.tileId&=Ou}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 yc(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}(Ja),ku=function(t){function e(e){var i=this;t.call(this,e),this.context=this.getContext2d(this.getCanvas(),this.settings.transparent),this.setBlendMode(this.settings.blendMode),this.setColor(this.currentColor),this.cache=new Rc,!1===this.settings.textureSeamFix||this.settings.antiAlias||(this.uvOffset=1),this.getCanvas().addEventListener("contextlost",(function(t){t.preventDefault(),i.isContextValid=!1,Zr(qr,i)}),!1),this.getCanvas().addEventListener("contextrestored",(function(){i.isContextValid=!0,Zr(Kr,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.getContext().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"}},e.prototype.clear=function(){if(!1===this.settings.transparent){var t=this.getCanvas();this.getContext().clearRect(0,0,t.width,t.height)}},e.prototype.clearColor=function(t,e){void 0===t&&(t="#000000"),void 0===e&&(e=!1);var i=this.getCanvas(),o=this.getContext();this.save(),this.resetTransform(),o.globalAlpha=1,o.globalCompositeOperation=!0===e?"copy":"source-over",o.fillStyle=t instanceof ar?t.toRGBA():t,this.fillRect(0,0,i.width,i.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.strokePoint=function(t,e){this.strokeLine(t,e,t+1,e+1)},e.prototype.fillPoint=function(t,e){this.strokePoint(t,e)},e.prototype.getFontContext=function(){return this.getContext()},e.prototype.save=function(){this.getContext().save()},e.prototype.restore=function(){this.getContext().restore(),this.currentColor.glArray[3]=this.getGlobalAlpha(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.getCanvas().width,this.currentScissor[3]=this.getCanvas().height},e.prototype.rotate=function(t){this.getContext().rotate(t)},e.prototype.scale=function(t,e){this.getContext().scale(t,e)},e.prototype.setColor=function(t){var e=this.getContext();e.strokeStyle=e.fillStyle=t instanceof ar?t.toRGBA():t},e.prototype.setGlobalAlpha=function(t){this.getContext().globalAlpha=this.currentColor.glArray[3]=t},e.prototype.getGlobalAlpha=function(){return this.getContext().globalAlpha},e.prototype.setLineWidth=function(t){this.getContext().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.getContext().transform(i,o,n,r,s,a)},e.prototype.translate=function(t,e){!1===this.settings.subPixel?this.getContext().translate(~~t,~~e):this.getContext().translate(t,e)},e.prototype.clipRect=function(t,e,i,o){var n=this.getCanvas();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.getContext();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()),t instanceof Ka)i.roundRect(t.top,t.left,t.width,t.height,t.radius);else if(t instanceof qa||t instanceof Ja)i.rect(t.top,t.left,t.width,t.height);else if(t instanceof Za){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,x=t.pos.y;i.moveTo(m+t.points[0].x,x+t.points[0].y);for(var _=1;_<t.points.length;_++)v=t.points[_],i.lineTo(m+v.x,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}(ih);function Ru(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 Bu=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.class=i.class,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),Pu(this,i),void 0===this.preRender&&(this.preRender=iu.world.preRender),this.setRenderer(e.getRenderer()),Ru(this,Su(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 ku({canvas:Gc(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 Iu&&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,Qn.pull("Vector2d"));i=this.cellAt(o.x,o.y),Qn.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 Iu(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}(Il),Du=function(t,e,i,o){this.cols=t,this.rows=e,this.tilewidth=i,this.tileheight=o,this.bounds=new Ja};Du.prototype.canRender=function(t){return this.tilewidth===t.tilewidth&&this.tileheight===t.tileheight},Du.prototype.getBounds=function(t){var e=t instanceof Bu?Qn.pull("Bounds"):this.bounds;return e.setMinMax(0,0,this.cols*this.tilewidth,this.rows*this.tileheight),e},Du.prototype.pixelToTileCoords=function(t,e,i){return i},Du.prototype.tileToPixelCoords=function(t,e,i){return i},Du.prototype.drawTile=function(t,e,i,o){},Du.prototype.drawTileLayer=function(t,e,i){};var Lu=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 Jn).set(t/this.tilewidth,e/this.tileheight)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new Jn).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),Qn.pull("Vector2d")).floorSelf(),s=this.pixelToTileCoords(i.pos.x+i.width+this.tilewidth,i.pos.y+i.height+this.tileheight,Qn.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)}Qn.push(r),Qn.push(s)},e}(Du),zu=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 Bu?Qn.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 Jn).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 Jn).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=Qn.pull("Vector2d");this.tileToPixelCoords(e,i,o),t.x=o.x,t.y=o.y,Qn.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,Qn.pull("Vector2d")).floorSelf(),r=this.pixelToTileCoords(i.pos.x+i.width+o.tilewidth,i.pos.y+i.height+o.tileheight,Qn.pull("Vector2d")).ceilSelf(),s=this.tileToPixelCoords(r.x,r.y,Qn.pull("Vector2d")),a=this.tileToPixelCoords(n.x,n.y,Qn.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)}Qn.push(c),Qn.push(n),Qn.push(r),Qn.push(s),Qn.push(a)},e}(Du),Fu=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],ju=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}],Vu=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 Jn,new Jn,new Jn,new Jn]}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 Bu?Qn.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 Jn;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 Jn;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 Jn;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 Jn;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 Jn;this.staggerX?t-=this.staggerEven?this.tilewidth:this.sideoffsetx:e-=this.staggerEven?this.tileheight:this.sideoffsety;var n,r,s,a,h=Qn.pull("Vector2d",Math.floor(t/(2*this.columnwidth)),Math.floor(e/(2*this.rowheight))),l=Qn.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?Fu:ju;return o.set(h.x+f[u].x,h.y+f[u].y),Qn.push(h),Qn.push(l),o},e.prototype.tileToPixelCoords=function(t,e,i){var o=Math.floor(t),n=Math.floor(e),r=i||new Jn;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,Qn.pull("Vector2d"));n.drawTile(t,n.tileoffset.x+r.x,n.tileoffset.y+r.y+(this.tileheight-n.tileheight),o),Qn.push(r)},e.prototype.drawTileLayer=function(t,e,i){var o,n=this.pixelToTileCoords(i.pos.x,i.pos.y,Qn.pull("Vector2d"));n.sub(e.pos);var r=this.tileToPixelCoords(n.x+e.pos.x,n.y+e.pos.y,Qn.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}Qn.push(s),Qn.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}Qn.push(s),Qn.push(a)}Qn.push(n),Qn.push(r)},e}(Du),Uu=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 Jn,n=t,r=e;this.staggerX?n-=this.staggerEven?this.sideoffsetx:0:r-=this.staggerEven?this.sideoffsety:0;var s=Qn.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=Qn.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(Rn(-45)).add(s),Qn.push(s),Qn.push(a),o},e}(Vu),Nu=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=Hn(i);if(("tsx"===o||"json"===o)&&!(t=fc.getTMX(Xn(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 Jn,this.isAnimated=!1,this.isCollection=!1,this.class=t.class,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=fc.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=fc.getImage(t.image),!this.image)throw new Error("melonJS: '"+t.image+"' file for tileset '"+this.name+"' not found!");this.texture=Nc.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+")")}};Nu.prototype.getTileImage=function(t){return this.imageCollection[t]},Nu.prototype.setTileProperty=function(t,e){this.TileProperties[t]=e},Nu.prototype.contains=function(t){return t>=this.firstgid&&t<=this.lastgid},Nu.prototype.getViewTileId=function(t){var e=t-this.firstgid;return this.animations.has(e)?this.animations.get(e).cur.tileid:e},Nu.prototype.getTileProperties=function(t){return this.TileProperties[t]},Nu.prototype.update=function(t){var e=0,i=Jc.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},Nu.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 Gu=function(){this.tilesets=[],this.length=0};Gu.prototype.add=function(t){this.tilesets.push(t),this.length++},Gu.prototype.getTilesetByIndex=function(t){return this.tilesets[t]},Gu.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 Xu=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.class=void 0!==e.class?e.class:e.type,this.text=void 0,this.rotation=Rn(+e.rotation||0),this.id=+e.id||void 0,this.orientation=t.orientation,this.shapes=void 0,this.isEllipse=!1,this.isPoint=!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.point?this.isPoint=!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,Pu(this.text,e)):(Pu(this,e),this.shapes||(this.shapes=this.parseTMXShapes())),t.isEditor||t.getRenderer().adjustPosition(this)};Xu.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 Iu(this.x,this.y,this.gid,e)},Xu.prototype.parseTMXShapes=function(){var t=0,e=[];if(!0===this.isEllipse)e.push(Qn.pull("Ellipse",this.width/2,this.height/2,this.width,this.height).rotate(this.rotation));else if(!0===this.isPoint)e.push(Qn.pull("Point",this.x,this.y));else if(!0===this.isPolygon){var i=Qn.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=Qn.pull("Vector2d",r[t].x,r[t].y),n=Qn.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(Qn.pull("Line",0,0,[o,n]))}else e.push(Qn.pull("Polygon",0,0,[Qn.pull("Vector2d"),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height),Qn.pull("Vector2d",0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(t=0;t<e.length;t++)"function"==typeof e[t].toIso&&e[t].toIso();return e},Xu.prototype.getObjectPropertyByName=function(t){return this[t]};var Hu=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.class=e.class,this.z=i,this.objects=[];var n=void 0===e.visible||e.visible;this.opacity=!0===n?Bn(+e.opacity||1,0,1):0,Pu(this,e),e.objects&&e.objects.forEach((function(e){e.tintcolor=o.tintcolor,o.objects.push(new Xu(t,e,i))})),e.layers&&e.layers.forEach((function(e){var n=new Bu(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)}))};Hu.prototype.destroy=function(){this.objects=null},Hu.prototype.getObjectCount=function(){return this.objects.length},Hu.prototype.getObjectByIndex=function(t){return this.objects[t]};function Yu(t,e,i){return new Hu(t,e,i)}var Wu=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.class=e.class,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,Pu(this,e),this.initialized=!1,1===this.infinite)throw new Error("Tiled Infinite Map not supported!")};Wu.prototype.getRenderer=function(){return void 0!==this.renderer&&this.renderer.canRender(this)||(this.renderer=function(t){switch(t.orientation){case"orthogonal":return new Lu(t);case"isometric":return new zu(t);case"hexagonal":return new Vu(t);case"staggered":return new Uu(t);default:throw new Error(t.orientation+" type TMX Tile Map not supported!")}}(this)),this.renderer},Wu.prototype.getBounds=function(){return this.bounds},Wu.prototype.readMapObjects=function(t){var e=this;if(!0!==this.initialized){var i=0;if(this.tilesets||(this.tilesets=new Gu),void 0!==t.tilesets)t.tilesets.forEach((function(t){e.tilesets.add(function(t){return new Nu(t)}(t))}));this.background_image&&this.layers.push(Qn.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){Pu(e.properties,e);var o=Qn.pull("ImageLayer",+e.offsetx||+e.x||0,+e.offsety||+e.y||0,Object.assign({name:e.name,image:e.image,ratio:Qn.pull("Vector2d",+e.parallaxx||1,+e.parallaxy||1),tint:void 0!==e.tintcolor?Qn.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 Bu(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i)}(e,t,i++));break;case"objectgroup":case"group":e.objectGroups.push(Yu(e,t,i++))}})),this.initialized=!0}},Wu.prototype.addTo=function(t,e,i){var o=t.autoSort,n=t.autoDepth,r=this.getBounds();function s(e,i){iu.viewport.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&&($r(Xr,s),s(iu.viewport.width,iu.viewport.height),Qr(Xr,s,this)),t.autoSort=o,t.autoDepth=n},Wu.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 Kl(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=Qn.pull("Color"),l.tint.parseHex(l.tintcolor,!0)),l instanceof Bu?a=l:"object"==typeof l.text?(void 0===l.text.anchorPoint&&(l.text.anchorPoint=l.anchorPoint),(a=!0===l.text.bitmap?Qn.pull("BitmapText",l.x,l.y,l.text):Qn.pull("Text",l.x,l.y,l.text)).pos.z=l.z):"object"==typeof l.tile?(void 0===(h=l.shapes)&&(h=Qn.pull("Polygon",0,0,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height)])),(a=l.tile.getRenderable(l)).body=new Yl(a,h),a.body.setStatic(!0),a.pos.setMuted(l.x,l.y,l.z)):(void 0!==l.name&&""!==l.name?a=Qn.pull(l.name,l.x,l.y,l):(a=Qn.pull("Renderable",l.x,l.y,l.width,l.height),void 0===(h=l.shapes)&&(h=Qn.pull("Polygon",0,0,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height)])),a.anchorPoint.set(0,0),a.name=l.name,a.type=l.type,a.class=l.class||l.type,a.id=l.id,a.body=new Yl(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=Hl.types.WORLD_SHAPE,a.body.isStatic=!0),!1!==t?(!0===a.isRenderable&&(a.setOpacity(a.getOpacity()*r.opacity),a.renderable instanceof Il&&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},Wu.prototype.getLayers=function(){return this.readMapObjects(this.data),this.layers},Wu.prototype.destroy=function(){this.tilesets=void 0,this.layers.length=0,this.objectGroups.length=0,this.initialized=!1};var qu={},Ku=[],Zu=0;function Qu(t,e,i){e.container.reset(),iu.reset(),qu[Ju.getCurrentLevelId()]&&qu[Ju.getCurrentLevelId()].destroy(),Zu=Ku.indexOf(t),function(t,e,i,o){var n=qu[t];Kc.resetGUID(t,n.nextobjectid),e.anchorPoint.set(0,0),n.addTo(e,i,o)}(t,e.container,e.flatten,e.setViewportBounds),Zr(Or,t),e.onLoaded(t),i&&Au.restart()}var Ju={add:function(t,e,i){if("tmx"===t)return null==qu[e]&&(qu[e]=new Wu(e,fc.getTMX(e)),Ku.push(e),i&&i(),!0);throw new Error("no level loader defined for format "+t)},load:function(t,e){if(e=Object.assign({container:iu.world,onLoaded:iu.onLevelLoaded,flatten:iu.mergeGroup,setViewportBounds:!0},e||{}),void 0===qu[t])throw new Error("level "+t+" not found");if(!(qu[t]instanceof Wu))throw new Error("no level loader defined");return Au.isRunning()?(Au.stop(),Kc.function.defer(Qu,this,t,e,!0)):Qu(t,e),!0},getCurrentLevelId:function(){return Ku[Zu]},getCurrentLevel:function(){return qu[this.getCurrentLevelId()]},reload:function(t){return this.load(this.getCurrentLevelId(),t)},next:function(t){return Zu+1<Ku.length&&this.load(Ku[Zu+1],t)},previous:function(t){return Zu-1>=0&&this.load(Ku[Zu-1],t)},levelCount:function(){return Ku.length}},$u={},tc={},ec={},ic={},oc={},nc=0,rc=0,sc=0;function ac(t){if(rc===nc){if("function"!=typeof t&&!fc.onload)throw new Error("no load callback defined");clearTimeout(sc);var e=t||fc.onload;setTimeout((function(){e(),Zr(Ir)}),300)}else sc=setTimeout((function(){ac(t)}),100)}function hc(t,e,i){$u[t.name]=new Image,"function"==typeof e&&($u[t.name].onload=e),"function"==typeof i&&($u[t.name].onerror=i),"string"==typeof fc.crossOrigin&&($u[t.name].crossOrigin=fc.crossOrigin),$u[t.name].src=t.src+fc.nocache}function lc(t,e,i){!0===_n(t.src)&&(t.src.startsWith("url(")||(t.src="url("+t.src+")"));var o=new FontFace(t.name,t.src);o.load().then((function(){document.fonts.add(o),document.body.style.fontFamily=t.name,"function"==typeof e&&e()}),(function(){"function"==typeof i&&i(t.name)}))}function uc(t,e,i){function o(e){tc[t.name]=e,"tmx"===t.type&&Ju.add(t.type,t.name)}if(t.data)return o(t.data),void("function"==typeof e&&e());var n=new XMLHttpRequest,r=Hn(t.src);n.overrideMimeType&&("json"===r?n.overrideMimeType("application/json"):n.overrideMimeType("text/xml")),n.open("GET",t.src+fc.nocache,!0),n.withCredentials=fc.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(hs.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=Mu(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),"function"==typeof e&&e()}else"function"==typeof i&&i(t.name)},n.send()}function cc(t,e,i){var o=new XMLHttpRequest;o.overrideMimeType&&o.overrideMimeType("application/json"),o.open("GET",t.src+fc.nocache,!0),o.withCredentials=fc.withCredentials,o.ontimeout=i,o.onreadystatechange=function(){4===o.readyState&&(200===o.status||0===o.status&&o.responseText?(ic[t.name]=JSON.parse(o.responseText),"function"==typeof e&&e()):"function"==typeof i&&i(t.name))},o.send()}function pc(t,e,i){var o=new XMLHttpRequest;o.open("GET",t.src+fc.nocache,!0),o.withCredentials=fc.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]);ec[t.name]=r.join(""),"function"==typeof e&&e()}},o.send()}function dc(t,e,i){var o=document.createElement("script");o.src=t.src,o.type="text/javascript","string"==typeof fc.crossOrigin&&(o.crossOrigin=fc.crossOrigin),o.defer=!0,"function"==typeof e&&(o.onload=function(){e()}),"function"==typeof i&&(o.onerror=function(){i(t.name)}),document.getElementsByTagName("body")[0].appendChild(o)}var fc={nocache:"",onload:void 0,onProgress:void 0,crossOrigin:void 0,withCredentials:!1,onResourceLoaded:function(t){var e=++rc/nc;this.onProgress&&this.onProgress(e,t),Zr(kr,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?oc[t]=e:(oc.audio=e,oc.binary=e,oc.image=e,oc.json=e,oc.js=e,oc.tmx=e,oc.tsx=e)},preload:function(t,e,i){void 0===i&&(i=!0);for(var o=0;o<t.length;o++)nc+=this.load(t[o],this.onResourceLoaded.bind(this,t[o]),this.onLoadingError.bind(this,t[o]));void 0!==e&&(this.onload=e),!0===i&&Au.change(Au.LOADING),ac(e)},load:function(t,e,i){switch(void 0!==oc[t.type]&&(t.src=oc[t.type]+t.src),t.type){case"binary":return pc.call(this,t,e,i),1;case"image":return hc.call(this,t,e,i),1;case"json":return cc.call(this,t,e,i),1;case"js":return dc.call(this,t,e,i),1;case"tmx":case"tsx":return uc.call(this,t,e,i),1;case"audio":return uh(t,!!t.stream,e,i),1;case"fontface":return lc.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 ec&&(delete ec[t.name],!0);case"image":return t.name in $u&&(delete $u[t.name],!0);case"json":return t.name in ic&&(delete ic[t.name],!0);case"js":case"fontface":return!0;case"tmx":case"tsx":return t.name in tc&&(delete tc[t.name],!0);case"audio":return vh(t.name);default:throw new Error("unload : unknown or invalid resource type : "+t.type)}},unloadAll:function(){var t;for(t in ec)ec.hasOwnProperty(t)&&this.unload({name:t,type:"binary"});for(t in $u)$u.hasOwnProperty(t)&&this.unload({name:t,type:"image"});for(t in tc)tc.hasOwnProperty(t)&&this.unload({name:t,type:"tmx"});for(t in ic)ic.hasOwnProperty(t)&&this.unload({name:t,type:"json"});mh()},getTMX:function(t){return(t=""+t)in tc?tc[t]:null},getBinary:function(t){return(t=""+t)in ec?ec[t]:null},getImage:function(t){return(t=Xn(""+t))in $u?$u[t]:null},getJSON:function(t){return(t=""+t)in ic?ic[t]:null}},yc=function(t){function e(e,i,o){if(t.call(this,e,i,0,0),this.animationpause=!1,this.animationspeed=100,this.offset=Qn.pull("Vector2d",0,0),this.source=null,this.anim={},this.resetAnim=void 0,this.current={name:"default",length:0,offset:Qn.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 vc){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:fc.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=Nc.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&&(o.tint instanceof ar?this.tint.copy(o.tint):this.tint.parseCSS(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(){Qn.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}(Il);function gc(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}}]}}var vc=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=fc.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?fc.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?fc.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?fc.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?fc.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 Rc?i.set(t,o):Nc.cache.set(t,o)}))};vc.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 Jn(s.x,s.y),anchorPoint:a?new Jn(n/s.w,r/s.h):null,trimmed:!!o.trimmed,width:s.w,height:s.h,angle:!0===o.rotated?-Pn:0},e.addUVs(i,o.filename,t.meta.size.w,t.meta.size.h)}})),i},vc.prototype.parseFromSpriteSheet=function(t){var e={},i=t.image,o=t.spacing||0,n=t.margin||0,r=i.width,s=i.height,a=Qn.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 Jn(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 Qn.push(a),e},vc.prototype.getAtlas=function(t){return"string"==typeof t?this.atlases.get(t):this.atlases.values().next().value},vc.prototype.getFormat=function(){return this.format},vc.prototype.getTexture=function(t){return"object"==typeof t&&"string"==typeof t.texture?this.sources.get(t.texture):this.sources.values().next().value},vc.prototype.addRegion=function(t,e,i,o,n){!0===Nc.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 Jn(e,i),width:o,height:n,angle:0},this.addUVs(s,t,a,h),s[t]},vc.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},vc.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},vc.prototype.addUVs=function(t,e,i,o){if(Nc instanceof Bc){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},vc.prototype.createSpriteFromName=function(t,e,i){return void 0===i&&(i=!1),Qn.pull(!0===i?"me.NineSliceSprite":"me.Sprite",0,0,Object.assign({image:this,region:t},e||{}))},vc.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 yc(0,0,Object.assign({image:this,framewidth:r,frameheight:s,margin:0,spacing:0,atlas:o,atlasIndices:n},e||{}))};var mc={},xc={},_c={},bc=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])}}},wc=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.")},Tc=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(_c,"__esModule",{value:!0}),_c.Multimap=void 0;var Ac=function(){function t(t,e){var i,o;if(this.size_=0,this.map=new Map,this.operator=t,e)try{for(var n=wc(e),r=n.next();!r.done;r=n.next()){var s=Tc(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=wc(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=wc(e.entries()),f=d.next();!f.done;f=d.next()){var y=Tc(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 bc(this,(function(y){switch(y.label){case 0:y.trys.push([0,11,12,13]),e=wc(t.map.entries()),i=e.next(),y.label=1;case 1:if(i.done)return[3,10];o=Tc(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=wc(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 bc(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=wc(t.entries()),i=e.next(),a.label=1;case 1:return i.done?[3,4]:(o=Tc(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=wc(this.entries()),r=n.next();!r.done;r=n.next()){var s=Tc(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=wc(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}();_c.Multimap=Ac;var Ec,Sc=e&&e.__extends||(Ec=function(t,e){return Ec=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])},Ec(t,e)},function(t,e){function i(){this.constructor=t}Ec(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(xc,"__esModule",{value:!0}),xc.ArrayMultimap=void 0;var Cc=function(t){function e(e){return t.call(this,new Mc,e)||this}return Sc(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"ArrayMultimap"},enumerable:!1,configurable:!0}),e}(_c.Multimap);xc.ArrayMultimap=Cc;var Mc=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}(),Pc={},Oc=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(Pc,"__esModule",{value:!0}),Pc.SetMultimap=void 0;var Ic=function(t){function e(e){return t.call(this,new kc,e)||this}return Oc(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"SetMultimap"},enumerable:!1,configurable:!0}),e}(_c.Multimap);Pc.SetMultimap=Ic;var kc=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=xc;Object.defineProperty(t,"ArrayMultimap",{enumerable:!0,get:function(){return e.ArrayMultimap}});var i=Pc;Object.defineProperty(t,"SetMultimap",{enumerable:!0,get:function(){return i.SetMultimap}})}(mc);var Rc=function(t){this.cache=new mc.ArrayMultimap,this.tinted=new Map,this.units=new Map,this.max_size=t||1/0,this.clear()};Rc.prototype.clear=function(){this.cache.clear(),this.tinted.clear(),this.units.clear(),this.length=0},Rc.prototype.validate=function(){if(this.length>=this.max_size)throw new Error("Texture cache overflow: "+this.max_size+" texture units available for this GPU.")},Rc.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=gc(t.width,t.height,t.src?Xn(t.src):void 0)),i=new vc(e,t,!1),this.set(t,i)),i},Rc.prototype.delete=function(t){this.cache.has(t)||this.cache.delete(t)},Rc.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,Nc.tint(t,e,"multiply")),i.get(e)},Rc.prototype.set=function(t,e){var i=t.width,o=t.height;if(!(1!==Nc.WebGLVersion||In(i)&&In(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)},Rc.prototype.getUnit=function(t){return this.units.has(t)||(this.validate(),this.units.set(t,this.length++)),this.units.get(t)};var Bc=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.getCanvas(),e.transparent),this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this._colorStack=[],this._matrixStack=[],this._scissorStack=[],this._blendStack=[],this.currentTransform=new cr,this.currentCompositor=null,this.compositors=new Map;var o=new(this.settings.compositor||xa)(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 Rc(this.maxTextures),this.getCanvas().addEventListener("webglcontextlost",(function(t){t.preventDefault(),i.isContextValid=!1,Zr(qr,i)}),!1),this.getCanvas().addEventListener("webglcontextrestored",(function(){i.reset(),i.isContextValid=!0,Zr(Kr,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.getCanvas(),i=e.width,o=e.height;1===this.WebGLVersion&&(In(i)||(i=kn(e.width)),In(o)||(o=kn(e.height)));var n=Gc(i,o,!0);this.fontContext2D=this.getContext2d(n),this.fontTexture=new vc(gc(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!==Nc.WebGLVersion||In(t.width)&&In(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 vc(gc(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.clear=function(){this.currentCompositor.clear(this.settings.transparent?0:1)},e.prototype.clearColor=function(t,e){var i;if(void 0===t&&(t="#000000"),void 0===e&&(e=!1),t instanceof ar)i=t.toArray();else{var o=Qn.pull("me.Color");i=o.parseCSS(t).toArray(),Qn.push(o)}this.currentCompositor.clearColor(i[0],i[1],i[2],!0===e?1:i[3])},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(this.getGlobalAlpha())),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(this.getGlobalAlpha()))},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(this.getGlobalAlpha()))},e.prototype.getContextGL=function(t,e){if(void 0===e&&(e=!1),null==t)throw new Error("You must pass a canvas element in order to create a GL context");var i,o={alpha:e,antialias:this.settings.antiAlias,depth:!1,stencil:!0,preserveDrawingBuffer:!1,premultipliedAlpha:!!e&&this.settings.premultipliedAlpha,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()),Qn.push(t),Qn.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.getCanvas().width,this.currentScissor[3]=this.getCanvas().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.getContext().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.strokePoint=function(t,e){this.strokeLine(t,e,t+1,e+1)},e.prototype.fillPoint=function(t,e){this.strokePoint(t,e)},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.getCanvas(),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}(ih),Dc=1,Lc=0,zc=0,Fc={parent:void 0,renderer:2,autoScale:!1,scale:1,scaleMethod:"manual",transparent:!1,premultipliedAlpha:!0,blendMode:"normal",antiAlias:!1,failIfMajorPerformanceCaveat:!0,subPixel:!1,preferWebGL1:!1,powerPreference:"default",verbose:!1,consoleHeader:!0};function jc(){var t=Nc.settings,e=1,i=1;if(t.autoScale){var o=1/0,n=1/0;if(globalThis.getComputedStyle){var r=globalThis.getComputedStyle(Nc.getCanvas(),null);o=parseInt(r.maxWidth,10)||1/0,n=parseInt(r.maxHeight,10)||1/0}var s=aa(Xc()),a=Math.min(o,s.width),h=Math.min(n,s.height),l=a/h;if("fill-min"===t.scaleMethod&&l>Dc||"fill-max"===t.scaleMethod&&l<Dc||"flex-width"===t.scaleMethod){var u=Math.min(o,zc*l);e=i=a/u,Nc.resize(Math.floor(u),zc)}else if("fill-min"===t.scaleMethod&&l<Dc||"fill-max"===t.scaleMethod&&l>Dc||"flex-height"===t.scaleMethod){var c=Math.min(n,Lc*(h/a));e=i=h/c,Nc.resize(Lc,Math.floor(c))}else"flex"===t.scaleMethod?Nc.resize(Math.floor(a),Math.floor(h)):"stretch"===t.scaleMethod?(e=a/Lc,i=h/zc):e=i=l<Dc?a/Lc:h/zc;Hc(e,i)}else Hc(t.scale,t.scale)}var Vc=null,Uc=new Jn(1,1),Nc=null;function Gc(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===Gs&&!0===i?void 0===(o=new globalThis.OffscreenCanvas(0,0)).style&&(o.style={}):o=document.createElement("canvas"),o.width=t,o.height=e,o}function Xc(){return Vc}function Hc(t,e){var i=Nc.getCanvas(),o=Nc.getContext(),n=Nc.settings,r=Ys,s=n.zoomX=i.width*t*r,a=n.zoomY=i.height*e*r;Uc.set(t*r,e*r),i.style.width=s/r+"px",i.style.height=a/r+"px",Nc.setAntiAlias(o,n.antiAlias),Nc.setBlendMode(n.blendMode,o),iu.repaint()}var Yc=Object.freeze({__proto__:null,CANVAS:0,WEBGL:1,AUTO:2,get parent(){return Vc},scaleRatio:Uc,get renderer(){return Nc},init:function(e,i,o){if(!t.initialized)throw new Error("me.video.init() called before engine initialization.");(Fc=Object.assign(Fc,o||{})).width=e,Fc.height=i,Fc.transparent=!!Fc.transparent,Fc.antiAlias=!!Fc.antiAlias,Fc.failIfMajorPerformanceCaveat=!!Fc.failIfMajorPerformanceCaveat,Fc.subPixel=!!Fc.subPixel,Fc.verbose=!!Fc.verbose,-1!==Fc.scaleMethod.search(/^(fill-(min|max)|fit|flex(-(width|height))?|stretch)$/)?Fc.autoScale="auto"===Fc.scale||!0:(Fc.scaleMethod="fit",Fc.autoScale="auto"===Fc.scale||!1),!1!==Fc.consoleHeader&&console.log("melonJS 2 (v"+Vp+") | http://melonjs.org");var n=Kc.getUriFragment();!0===n.webgl||!0===n.webgl1||!0===n.webgl2?(Fc.renderer=1,!0===n.webgl1&&(Fc.preferWebGL1=!0)):!0===n.canvas&&(Fc.renderer=0),Fc.scale=Fc.autoScale?1:+Fc.scale||1,Uc.set(Fc.scale,Fc.scale),Dc=e/i,Lc=e,zc=i,Fc.zoomX=e*Uc.x,Fc.zoomY=i*Uc.y,globalThis.addEventListener("resize",Kc.function.throttle((function(t){Zr(Nr,t)}),100),!1),globalThis.addEventListener("orientationchange",(function(t){Zr(Hr,t)}),!1),globalThis.addEventListener("onmozorientationchange",(function(t){Zr(Hr,t)}),!1),!0===Ls&&(globalThis.screen.orientation.onchange=function(t){Zr(Hr,t)}),globalThis.addEventListener("scroll",Kc.function.throttle((function(t){Zr(Yr,t)}),100),!1),Qr(Nr,jc,this),Qr(Hr,jc,this);try{switch(Fc.renderer){case 2:case 1:Nc=function(t){try{if(ha(t))return new Bc(t)}catch(t){console.log("Error creating WebGL renderer :"+t.message)}return new ku(t)}(Fc);break;default:Nc=new ku(Fc)}}catch(t){return console(t.message),!1}if((Vc=ra(void 0!==Fc.parent?Fc.parent:document.body)).appendChild(Nc.getCanvas()),Ms.isMobile&&ea(!1),jc(),"MutationObserver"in globalThis&&new MutationObserver(jc.bind(this)).observe(Vc,{attributes:!1,childList:!0,subtree:!0}),!1!==Fc.consoleHeader){var r=Nc instanceof ku?"CANVAS":"WebGL"+Nc.WebGLVersion,s=js?"Web Audio":"HTML5 Audio",a="string"==typeof Nc.GPURenderer?" ("+Nc.GPURenderer+")":"";console.log(r+" renderer"+a+" | "+s+" | pixel ratio "+Ys+" | "+(Ms.nodeJS?"node.js":Ms.isMobile?"mobile":"desktop")+" | "+oa()+" | "+Hs),console.log("resolution: requested "+e+"x"+i+", got "+Nc.getWidth()+"x"+Nc.getHeight())}return Zr(wr),!0},createCanvas:Gc,getParent:Xc,scale:Hc}),Wc="",qc=0,Kc={agent:En,array:Un,file:Yn,string:bn,function:Kn,getPixels:function(t){if(t instanceof HTMLImageElement){var e=ku.getContext2d(Gc(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=Vp);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),Wc=xn(t.toString().toUpperCase()),qc=e},createGUID:function(t){return void 0===t&&(t=1),qc+=t,Wc+"-"+(t||qc)}},Zc=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,Qr(gr,(function(){t.reset(),t.now=t.last=0,Qr(Er,t.update.bind(t))})),Qr(mr,(function(){t.reset()})),Qr(_r,(function(){t.reset()})),Qr(br,(function(){t.reset()}))};Zc.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},Zc.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},Zc.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},Zc.prototype.clearTimeout=function(t){Kc.function.defer(this.clearTimer.bind(this),this,t)},Zc.prototype.clearInterval=function(t){Kc.function.defer(this.clearTimer.bind(this),this,t)},Zc.prototype.getTime=function(){return this.now},Zc.prototype.getDelta=function(){return this.delta},Zc.prototype.countFPS=function(){this.framecount++,this.framedelta+=this.delta,this.framecount%10==0&&(this.fps=Bn(Math.round(1e3*this.framecount/this.framedelta),0,this.maxfps),this.framedelta=0,this.framecount=0)},Zc.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()},Zc.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}},Zc.prototype.updateTimers=function(){for(var t=0,e=this.timers.length;t<e;t++){var i=this.timers[t];i.pauseable&&Au.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 Qc,Jc=new Zc,$c=0,tp=["ms","moz","webkit","o"],ep=globalThis.requestAnimationFrame,ip=globalThis.cancelAnimationFrame;for(Qc=0;Qc<tp.length&&!ep;++Qc)ep=globalThis[tp[Qc]+"RequestAnimationFrame"];for(Qc=0;Qc<tp.length&&!ip;++Qc)ip=globalThis[tp[Qc]+"CancelAnimationFrame"]||globalThis[tp[Qc]+"CancelRequestAnimationFrame"];ep&&ip||(ep=function(t){var e=globalThis.performance.now(),i=Math.max(0,1e3/Jc.maxfps-(e-$c)),o=globalThis.setTimeout((function(){t(e+i)}),i);return $c=e+i,o},ip=function(t){globalThis.clearTimeout(t)},globalThis.requestAnimationFrame=ep,globalThis.cancelAnimationFrame=ip),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 op={},np={Base:function(){this.version="13.3.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(op[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 np.Base))throw new Error("Plugin should extend the me.plugin.Base Class !");if(Kc.checkVersion(o.version)>0)throw new Error("Plugin version mismatch, expected: "+o.version+", got: "+Vp);op[e]=o}},rp={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-rp.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*rp.Bounce.In(2*t):.5*rp.Bounce.Out(2*t-1)+.5}}},sp={Linear:function(t,e){var i=t.length-1,o=i*e,n=Math.floor(o),r=sp.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=sp.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=sp.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=sp.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}}},ap=function(t){this.setProperties(t)},hp={Easing:{configurable:!0},Interpolation:{configurable:!0}};ap.prototype.onResetEvent=function(t){this.setProperties(t)},ap.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=rp.Linear.None,this._interpolationFunction=sp.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._tweenTimeTracker=iu.lastUpdate,this.isPersistent=!1,this.updateWhenPaused=!1,this.isRenderable=!1,t)"object"!=typeof t&&(this._valuesStart[e]=parseFloat(t[e]))},ap.prototype._resumeCallback=function(t){this._startTime&&(this._startTime+=t)},ap.prototype.onActivateEvent=function(){Qr(mr,this._resumeCallback,this)},ap.prototype.onDeactivateEvent=function(){$r(mr,this._resumeCallback)},ap.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},ap.prototype.start=function(t){for(var e in void 0===t&&(t=Jc.getTime()),this._onStartCallbackFired=!1,iu.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},ap.prototype.stop=function(){return iu.world.removeChildNow(this),this},ap.prototype.delay=function(t){return this._delayTime=t,this},ap.prototype.repeat=function(t){return this._repeat=t,this},ap.prototype.yoyo=function(t){return this._yoyo=t,this},ap.prototype.easing=function(t){if("function"!=typeof t)throw new Error("invalid easing function for me.Tween.easing()");return this._easingFunction=t,this},ap.prototype.interpolation=function(t){return this._interpolationFunction=t,this},ap.prototype.chain=function(){return this._chainedTweens=arguments,this},ap.prototype.onStart=function(t){return this._onStartCallback=t,this},ap.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},ap.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},ap.prototype.update=function(t){this._tweenTimeTracker=iu.lastUpdate>this._tweenTimeTracker?iu.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 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}iu.world.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},hp.Easing.get=function(){return rp},hp.Interpolation.get=function(){return sp},Object.defineProperties(ap,hp);var lp={offscreenCanvas:!1,willReadFrequently:!1,antiAlias:!1,context:"2d"},up=function(t,e,i){void 0===i&&(i=lp),i=Object.assign(lp,i||{}),this.canvas=Gc(t,e,i.offscreenCanvas),this.context=this.canvas.getContext("2d",{willReadFrequently:i.willReadFrequently}),this.setAntiAlias(i.antiAlias)},cp={width:{configurable:!0},height:{configurable:!0}};function pp(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}up.prototype.onResetEvent=function(t,e){this.clear(),this.resize(t,e)},up.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},up.prototype.setAntiAlias=function(t){void 0===t&&(t=!1);var e=this.canvas;An("imageSmoothingEnabled",t,this.context),void 0!==e.style&&(!0!==t?(e.style["image-rendering"]="optimizeSpeed",e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-o-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="optimize-contrast",e.style["image-rendering"]="crisp-edges",e.style["image-rendering"]="pixelated",e.style.msInterpolationMode="nearest-neighbor"):e.style["image-rendering"]="auto")},up.prototype.resize=function(t,e){this.canvas.width=Math.round(t),this.canvas.height=Math.round(e)},up.prototype.destroy=function(){this.context=void 0,this.canvas=void 0},cp.width.get=function(){return this.canvas.width},cp.width.set=function(t){this.canvas.width=Math.round(t)},cp.height.get=function(){return this.canvas.height},cp.height.set=function(t){this.canvas.height=Math.round(t)},Object.defineProperties(up.prototype,cp);var dp=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 vp?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 vp)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(),pp(e,this.ancestor)),this.width=this.height=0;for(var o=0;o<i.length;o++)this.width=Math.max(this.lineWidth(i[o].trimEnd(),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(),pp(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}(Ja),fp=["ex","em","pt","px"],yp=[12,24,.75,1],gp=function(t,e){return!0===e.offScreenCanvas?e.canvasTexture.context:(void 0===t&&(t=Nc),t.getFontContext())},vp=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 ar?this.fillStyle=i.fillStyle:this.fillStyle=Qn.pull("Color").parseCSS(i.fillStyle):this.fillStyle=Qn.pull("Color",0,0,0),void 0!==i.strokeStyle?i.strokeStyle instanceof ar?this.strokeStyle=i.strokeStyle:this.strokeStyle=Qn.pull("Color").parseCSS(i.strokeStyle):this.strokeStyle=Qn.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=Qn.pull("CanvasTexture",2,2,{offscreenCanvas:!0})),this.metrics=new dp(this),this.setText(i.text)},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*=yp[fp.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,gp(Nc,this))),e.addBounds(this.metrics.measureText(this._text,gp(Nc,this)),!0),!0===this.offScreenCanvas){var i=Math.ceil(this.metrics.width),o=Math.ceil(this.metrics.height);Nc instanceof Bc&&(this.glTextureUnit=Nc.cache.getUnit(Nc.cache.get(this.canvasTexture.canvas)),Nc.currentCompositor.unbindTexture2D(null,this.glTextureUnit),1===Nc.WebGLVersion&&(i=kn(this.metrics.width),o=kn(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,gp(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),pp(t,this,n);for(var r=0;r<e.length;r++){var s=e[r].trimEnd();t[n?"strokeText":"fillText"](s,i,o),o+=this.metrics.lineHeight()}return this.metrics},e.prototype.destroy=function(){!0===this.offScreenCanvas&&(Nc instanceof Bc&&(Nc.currentCompositor.deleteTexture2D(Nc.currentCompositor.getTexture2D(this.glTextureUnit)),this.glTextureUnit=void 0),Nc.cache.delete(this.canvasTexture.canvas),Qn.push(this.canvasTexture),this.canvasTexture=void 0),Qn.push(this.fillStyle),Qn.push(this.strokeStyle),this.fillStyle=this.strokeStyle=void 0,this.metrics=void 0,this._text.length=0,t.prototype.destroy.call(this)},e}(Il),mp=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=Qn.pull("Vector2d",1,1),this.fontImage="object"==typeof o.font?o.font:fc.getImage(o.font),"string"!=typeof o.fontData?this.fontData=Qn.pull("BitmapTextData",fc.getBinary(o.font)):this.fontData=Qn.pull("BitmapTextData",o.fontData.includes("info face")?o.fontData:fc.getBinary(o.fontData)),void 0!==o.floating&&(this.floating=!!o.floating),void 0!==o.fillStyle&&(this.fillStyle=o.fillStyle),void 0!==o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),this.metrics=new dp(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){t instanceof ar?this.tint.copy(t):this.tint.parseCSS(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=this._text[h].trimEnd(),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(){Qn.push(this.fontScale),this.fontScale=void 0,Qn.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}(Il),xp=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};xp.prototype.getKerning=function(t){if(this.kerning){var e=this.kerning[t>>>9];if(e)return e[511&t]||0}return 0},xp.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 _p=["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 bp(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 wp(t){var e=" ".charCodeAt(0),i=t[e];i||((i=new xp).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 Tp=function(t){this.onResetEvent(t)};Tp.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)},Tp.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(bp(e[1],/lineHeight\=\d+/g));var n,r=parseFloat(bp(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 xp;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,wp(this.glyphs);var f=null;for(n=0;n<_p.length;n++){var y=_p[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 Ap=function(t){function e(e,i,o){t.call(this,0,0,1/0,1/0),this.color=Qn.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(){Qn.push(this.color),this.color=void 0,t.prototype.destroy.call(this)},e}(Il),Ep=function(t){function e(e,i,o){t.call(this,e,i,o),this.floating=!0,this.offset.set(e,i),this.ratio=Qn.pull("Vector2d",1,1),void 0!==o.ratio&&(vn(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",Qr(Kr,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(iu.viewport.width,iu.viewport.height),this.createPattern()},e.prototype.onActivateEvent=function(){var t=this;Qr(Wr,this.updateLayer,this),Qr(Xr,this.resize,this),Jr(Or,(function(){t.updateLayer(iu.viewport.pos)})),!0!==this.ancestor.root&&this.updateLayer(iu.viewport.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=Nc.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=iu.viewport.bounds.width,s=iu.viewport.bounds.height,a=this.anchorPoint.x,h=this.anchorPoint.y,l=a*(e-1)*(r-iu.viewport.width)+this.offset.x-e*t.x,u=h*(i-1)*(s-iu.viewport.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(){$r(Wr,this.updateLayer),$r(Xr,this.resize)},e.prototype.destroy=function(){Qn.push(this.ratio),this.ratio=void 0,$r(Kr,this.createPattern),t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(yc),Sp=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}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={width:{configurable:!0},height:{configurable:!0}};return i.width.get=function(){return t.prototype.width},i.width.set=function(e){t.prototype.width=this.nss_width=e},i.height.get=function(){return t.prototype.height},i.height.set=function(e){t.prototype.height=this.nss_height=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)},Object.defineProperties(e.prototype,i),e}(yc),Cp=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&&Jc.clearTimeout(this.holdTimeout),this.holdTimeout=Jc.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,Jc.clearTimeout(this.holdTimeout),this.onRelease(t)},e.prototype.onRelease=function(){return!1},e.prototype.hold=function(){Jc.clearTimeout(this.holdTimeout),this.dirty=!0,this.released||this.onHold()},e.prototype.onHold=function(){},e.prototype.onActivateEvent=function(){gl("pointerdown",this,this.clicked.bind(this)),gl("pointerup",this,this.release.bind(this)),gl("pointercancel",this,this.release.bind(this)),gl("pointerenter",this,this.enter.bind(this)),gl("pointerleave",this,this.leave.bind(this))},e.prototype.onDeactivateEvent=function(){vl("pointerdown",this),vl("pointerup",this),vl("pointercancel",this),vl("pointerenter",this),vl("pointerleave",this),Jc.clearTimeout(this.holdTimeout)},e}(yc),Mp=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=Qn.pull("Polygon",0,0,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height)])),this.body=new Yl(this,n),this.body.collisionType=Hl.types.COLLECTABLE_OBJECT,this.body.setCollisionMask(Hl.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}(yc),Pp=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=Qn.pull("Polygon",0,0,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height)])),this.body=new Yl(this,n),this.body.collisionType=Hl.types.ACTION_OBJECT,this.body.setCollisionMask(Hl.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=iu.world.getChildByName(this.triggerSettings.container)[0]),this.triggerSettings},e.prototype.onFadeComplete=function(){Ju.load(this.gotolevel,this.getTriggerSettings()),iu.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,iu.viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):Ju.load(this.gotolevel,t)},e.prototype.onCollision=function(t,e){return"Trigger"===this.name&&this.triggerEvent.apply(this),!1},e}(Il);var Op=function(t){function e(e,i,o,n,r,s){void 0===n&&(n=o),void 0===r&&(r="#FFF"),void 0===s&&(s=.7),t.call(this,e,i,2*o,2*n),this.color=Qn.pull("Color").parseCSS(r),this.radiusX=o,this.radiusY=n,this.intensity=s,this.blendMode="lighter",this.visibleArea=Qn.pull("Ellipse",this.centerX,this.centerY,this.width,this.height),this.texture=Qn.pull("CanvasTexture",this.width,this.height,{offscreenCanvas:!1}),this.anchorPoint.set(0,0),function(t){var e,i,o,n,r,s=t.texture.context,a=t.texture.width/2,h=t.texture.height/2,l=t.radiusX,u=t.radiusY;t.texture.clear(),l>=u?(e=1,o=1,i=u/l,n=l/u,r=s.createRadialGradient(a,h*n,0,a,u*n,l)):(i=1,n=1,e=l/u,o=u/l,r=s.createRadialGradient(a*o,h,0,a*o,h,u)),r.addColorStop(0,t.color.toRGBA(t.intensity)),r.addColorStop(1,t.color.toRGBA(0)),s.fillStyle=r,s.setTransform(e,0,0,i,0,0),s.fillRect(0,0,t.texture.width*o,t.texture.height*n)}(this)}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(){Qn.push(this.color),this.color=void 0,Qn.push(this.texture),this.texture=void 0,Qn.push(this.visibleArea),this.visibleArea=void 0,t.prototype.destroy.call(this)},e}(Il),Ip=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 Jn(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;gl("pointerdown",this,(function(e){Zr(Vr,e,t)})),gl("pointerup",this,(function(e){Zr(Ur,e,t)})),gl("pointercancel",this,(function(e){Zr(Ur,e,t)})),Qr(Fr,this.dragMove.bind(this)),Qr(Vr,(function(e,i){i===t&&t.dragStart(e)})),Qr(Ur,(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(){$r(Fr,this.dragMove),$r(Vr,this.dragStart),$r(Ur,this.dragEnd),vl("pointerdown",this),vl("pointerup",this),vl("pointercancel",this),t.prototype.destroy.call(this)},e}(Il),kp=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,Qr(Ur,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(){$r(Ur,this.checkOnMe),t.prototype.destroy.call(this)},e}(Il),Rp={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 Bp=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,Rp,t),void 0===this.settings.image&&(this._defaultParticle=function(t,e){void 0===t&&(t=8),void 0===e&&(e=8);var i=Qn.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 Ln(0,this.getBounds().width)},e.prototype.getRandomPointY=function(){return Ln(0,this.getBounds().height)},e.prototype.addParticles=function(t){for(var e=0;e<t;e++)this.addChild(Qn.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&&(Qn.push(this._defaultParticle),this._defaultParticle=void 0),this.settings.image=void 0,this.settings=void 0},e}(Kl),Dp=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=Qn.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?(Ln(0,2)-1)*t.settings.angleVariation:0),o=t.settings.speed+(t.settings.speedVariation>0?(Ln(0,2)-1)*t.settings.speedVariation:0);this.vel.set(o*Math.cos(i),-o*Math.sin(i)),this.life=Ln(t.settings.minLife,t.settings.maxLife),this.startLife=this.life,this.startScale=Bn(Ln(t.settings.minStartScale,t.settings.maxStartScale),t.settings.minStartScale,t.settings.maxStartScale),this.endScale=Bn(Ln(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=Jc.maxfps/1e3,t.settings.followTrajectory||(this.angle=Ln(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}(Il),Lp=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 yc(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=Qn.pull("Polygon",0,0,[Qn.pull("Vector2d",0,0),Qn.pull("Vector2d",this.width,0),Qn.pull("Vector2d",this.width,this.height),Qn.pull("Vector2d",0,this.height)])),this.body=new Yl(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}(Il);function zp(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()}Object.defineProperty(ih.prototype,"Texture",{get:function(){return zp("me.video.renderer.Texture","me.TextureAtlas","10.4.0"),vc}});var Fp=function(t){function e(e,i,o){zp("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}(Ip),jp=function(t){function e(e,i,o){zp("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}(kp);ih.prototype.getScreenCanvas=function(){return zp("getScreenCanvas","getCanvas","13.1.0"),this.getCanvas()},ih.prototype.getScreenContext=function(){return zp("getScreenContext","getContext","13.1.0"),this.getContext()};var Vp="13.3.0";t.initialized=!1;function Up(){!0!==t.initialized&&(Qn.register("me.Entity",Lp),Qn.register("me.Collectable",Mp),Qn.register("me.Trigger",Pp),Qn.register("me.Light2d",Op),Qn.register("me.Tween",ap,!0),Qn.register("me.Color",ar,!0),Qn.register("me.Particle",Dp,!0),Qn.register("me.Sprite",yc),Qn.register("me.NineSliceSprite",Sp),Qn.register("me.Renderable",Il),Qn.register("me.Text",vp,!0),Qn.register("me.BitmapText",mp),Qn.register("me.BitmapTextData",Tp,!0),Qn.register("me.ImageLayer",Ep),Qn.register("me.ColorLayer",Ap,!0),Qn.register("me.Vector2d",Jn,!0),Qn.register("me.Vector3d",bh,!0),Qn.register("me.ObservableVector2d",_h,!0),Qn.register("me.ObservableVector3d",wh,!0),Qn.register("me.Matrix2d",cr,!0),Qn.register("me.Matrix3d",lr,!0),Qn.register("me.Rect",qa,!0),Qn.register("me.RoundRect",Ka,!0),Qn.register("me.Polygon",Wa,!0),Qn.register("me.Line",Qa,!0),Qn.register("me.Point",eh,!0),Qn.register("me.Ellipse",Za,!0),Qn.register("me.Bounds",Ja,!0),Qn.register("Entity",Lp),Qn.register("Collectable",Mp),Qn.register("Trigger",Pp),Qn.register("Light2d",Op),Qn.register("Tween",ap,!0),Qn.register("Color",ar,!0),Qn.register("Particle",Dp,!0),Qn.register("Sprite",yc),Qn.register("NineSliceSprite",Sp),Qn.register("Renderable",Il),Qn.register("Text",vp,!0),Qn.register("BitmapText",mp),Qn.register("BitmapTextData",Tp,!0),Qn.register("ImageLayer",Ep),Qn.register("ColorLayer",Ap,!0),Qn.register("Vector2d",Jn,!0),Qn.register("Vector3d",bh,!0),Qn.register("ObservableVector2d",_h,!0),Qn.register("ObservableVector3d",wh,!0),Qn.register("Matrix2d",cr,!0),Qn.register("Matrix3d",lr,!0),Qn.register("Rect",qa,!0),Qn.register("RoundRect",Ka,!0),Qn.register("Polygon",Wa,!0),Qn.register("Line",Qa,!0),Qn.register("Point",eh,!0),Qn.register("Ellipse",Za,!0),Qn.register("Bounds",Ja,!0),Qn.register("CanvasTexture",up,!0),Zr(gr),fc.setNocache(Kc.getUriFragment().nocache||!1),kh(),t.initialized=!0)}ta((function(){Up()})),t.BitmapText=mp,t.BitmapTextData=Tp,t.Body=Yl,t.Bounds=Ja,t.Camera2d=au,t.CanvasRenderer=ku,t.Collectable=Mp,t.Color=ar,t.ColorLayer=Ap,t.Container=Kl,t.Draggable=Ip,t.DraggableEntity=Fp,t.DropTarget=kp,t.DroptargetEntity=jp,t.Ellipse=Za,t.Entity=Lp,t.GLShader=ga,t.GUI_Object=Cp,t.ImageLayer=Ep,t.Light2d=Op,t.Line=Qa,t.Math=jn,t.Matrix2d=cr,t.Matrix3d=lr,t.NineSliceSprite=Sp,t.ObservableVector2d=_h,t.ObservableVector3d=wh,t.Particle=Dp,t.ParticleEmitter=Bp,t.ParticleEmitterSettings=Rp,t.Point=eh,t.Pointer=zh,t.Polygon=Wa,t.QuadTree=$l,t.Rect=qa,t.Renderable=Il,t.Renderer=ih,t.RoundRect=Ka,t.Sprite=yc,t.Stage=lu,t.TMXHexagonalRenderer=Vu,t.TMXIsometricRenderer=zu,t.TMXLayer=Bu,t.TMXOrthogonalRenderer=Lu,t.TMXRenderer=Du,t.TMXStaggeredRenderer=Uu,t.TMXTileMap=Wu,t.TMXTileset=Nu,t.TMXTilesetGroup=Gu,t.Text=vp,t.TextureAtlas=vc,t.Tile=Iu,t.Trigger=Pp,t.Tween=ap,t.Vector2d=Jn,t.Vector3d=bh,t.WebGLCompositor=xa,t.WebGLRenderer=Bc,t.World=tu,t.audio=xh,t.boot=Up,t.collision=Hl,t.device=ca,t.event=ts,t.game=iu,t.input=Ol,t.level=Ju,t.loader=fc,t.plugin=np,t.plugins=op,t.pool=Qn,t.save=ns,t.skipAutoInit=!1,t.state=Au,t.timer=Jc,t.utils=Kc,t.version=Vp,t.video=Yc,t.warning=zp,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
29
|
+
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)}}()}(ah);var hh={},lh=null,uh=0,ch=[],ph=function(t,e){if(uh++>3)throw new Error("melonJS: failed loading "+t);hh[t].load()};function dh(){return!ah.Howler.noAudio}function fh(t,e,i,o){var n=[];if(0===ch.length)throw new Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");if(!0===An(t.src))n.push(t.src);else for(var r=0;r<ch.length;r++)n.push(t.src+t.name+"."+ch[r]+mc.nocache);return hh[t.name]=new ah.Howl({src:n,volume:ah.Howler.volume(),html5:!0===e,xhrWithCredentials:mc.withCredentials,onloaderror:function(){ph.call(this,t.name,o)},onload:function(){uh=0,i&&i()}}),1}function yh(t,e,i,o){void 0===e&&(e=!1);var n=hh[t];if(n&&void 0!==n){var r=n.play();return"boolean"==typeof e&&n.loop(e,r),n.volume("number"==typeof o?Fn(o,0,1):ah.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 gh(){null!==lh&&hh[lh].pause()}function vh(){null!==lh&&hh[lh].play()}function mh(t,e,i){i=void 0===i||!!i;var o=hh[t];if(!o||void 0===o)throw new Error("audio clip "+t+" does not exist");o.mute(i,e)}function xh(){ah.Howler.mute(!0)}function _h(){ah.Howler.mute(!1)}function bh(t){return t in hh&&(hh[t].unload(),delete hh[t],!0)}function wh(){for(var t in hh)hh.hasOwnProperty(t)&&bh(t)}var Th=Object.freeze({__proto__:null,stopOnAudioError:!0,init:function(t){return void 0===t&&(t="mp3"),ch=t.split(","),!ah.Howler.noAudio},hasFormat:function(t){return dh()&&ah.Howler.codecs(t)},hasAudio:dh,enable:function(){_h()},disable:function(){xh()},load:fh,play:yh,fade:function(t,e,i,o,n){var r=hh[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=hh[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=hh[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=hh[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 ah.Howler.stop()},pause:function(t,e){var i=hh[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.pause(e)},resume:function(t,e){var i=hh[t];if(!i||void 0===i)throw new Error("audio clip "+t+" does not exist");i.play(e)},playTrack:function(t,e){return yh(lh=t,!0,null,e)},stopTrack:function(){null!==lh&&(hh[lh].stop(),lh=null)},pauseTrack:gh,resumeTrack:vh,getCurrentTrack:function(){return lh},setVolume:function(t){ah.Howler.volume(t)},getVolume:function(){return ah.Howler.volume()},mute:mh,unmute:function(t,e){mh(t,e,!1)},muteAll:xh,unmuteAll:_h,muted:function(){return ah.Howler._muted},unload:bh,unloadAll:wh}),Ah=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(Fn(this.x,t,i),Fn(this.y,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(Fn(this._x,t,e),Fn(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._set(this._x+(t.x-this._x)*e,this._y+(t.y-this._y)*e)},e.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this._y,t.x-this._x),o=this.distance(t);return 0===o||e>=0&&o<=e*e?t:(this._x+=Math.cos(i)*e,this._y+=Math.sin(i)*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 er.pull("ObservableVector2d",this._x,this._y,{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.toVector2d=function(){return er.pull("Vector2d",this._x,this._y)},e.prototype.toString=function(){return"x:"+this._x+",y:"+this._y},Object.defineProperties(e.prototype,i),e}(ir),Eh=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.onResetEvent(t,e,i)};Eh.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},Eh.prototype._set=function(t,e,i){return void 0===i&&(i=0),this.x=t,this.y=e,this.z=i,this},Eh.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)},Eh.prototype.setZero=function(){return this.set(0,0,0)},Eh.prototype.setV=function(t){return this._set(t.x,t.y,t.z)},Eh.prototype.add=function(t){return this._set(this.x+t.x,this.y+t.y,this.z+(t.z||0))},Eh.prototype.sub=function(t){return this._set(this.x-t.x,this.y-t.y,this.z-(t.z||0))},Eh.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))},Eh.prototype.scaleV=function(t){return this.scale(t.x,t.y,t.z)},Eh.prototype.toIso=function(){return this._set(this.x-this.y,.5*(this.x+this.y),this.z)},Eh.prototype.to2d=function(){return this._set(this.y+this.x/2,this.y-this.x/2,this.z)},Eh.prototype.div=function(t){return this._set(this.x/t,this.y/t,this.z/t)},Eh.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)},Eh.prototype.clamp=function(t,e){return new Eh(Fn(this.x,t,e),Fn(this.y,t,e),Fn(this.z,t,e))},Eh.prototype.clampSelf=function(t,e){return this._set(Fn(this.x,t,e),Fn(this.y,t,e),Fn(this.z,t,e))},Eh.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)},Eh.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)},Eh.prototype.floor=function(){return new Eh(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},Eh.prototype.floorSelf=function(){return this._set(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},Eh.prototype.ceil=function(){return new Eh(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},Eh.prototype.ceilSelf=function(){return this._set(Math.ceil(this.x),Math.ceil(this.y),Math.ceil(this.z))},Eh.prototype.negate=function(){return new Eh(-this.x,-this.y,-this.z)},Eh.prototype.negateSelf=function(){return this._set(-this.x,-this.y,-this.z)},Eh.prototype.copy=function(t){return this._set(t.x,t.y,t.z||0)},Eh.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},Eh.prototype.normalize=function(){return this.div(this.length()||1)},Eh.prototype.perp=function(){return this._set(this.y,-this.x,this.z)},Eh.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)},Eh.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*(void 0!==t.z?t.z:this.z)},Eh.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},Eh.prototype.length2=function(){return this.dot(this)},Eh.prototype.length=function(){return Math.sqrt(this.length2())},Eh.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},Eh.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this.y,t.x-this.x),o=this.x-t.x,n=this.y-t.y,r=Math.sqrt(o*o+n*n);return 0===r||e>=0&&r<=e*e?t:(this.x+=Math.cos(i)*e,this.y+=Math.sin(i)*e,this)},Eh.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)},Eh.prototype.angle=function(t){return Math.acos(Fn(this.dot(t)/(this.length()*t.length()),-1,1))},Eh.prototype.project=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},Eh.prototype.projectN=function(t){var e=this.dot(t)/t.length2();return this.scale(e,e,e)},Eh.prototype.clone=function(){return er.pull("Vector3d",this.x,this.y,this.z)},Eh.prototype.toString=function(){return"x:"+this.x+",y:"+this.y+",z:"+this.z};var Sh=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(Fn(this._x,t,i),Fn(this._y,t,i),Fn(this._z,t,i),{onUpdate:this.onUpdate,scope:this.scope})},e.prototype.clampSelf=function(t,e){return this._set(Fn(this._x,t,e),Fn(this._y,t,e),Fn(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._set(this._x+(t.x-this._x)*e,this._y+(t.y-this._y)*e,this._z+(t.z-this._z)*e)},e.prototype.moveTowards=function(t,e){var i=Math.atan2(t.y-this._y,t.x-this._x),o=this._x-t.x,n=this._y-t.y,r=Math.sqrt(o*o+n*n);return 0===r||e>=0&&r<=e*e?t:this._set(this._x+Math.cos(i)*e,this._y+Math.sin(i)*e,this._z)},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 er.pull("ObservableVector3d",this._x,this._y,this._z,{onUpdate:this.onUpdate})},e.prototype.toVector3d=function(){return er.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}(Eh),Ch={},Mh={},Ph={},Oh={},Ih={},kh={},Rh=function(t,e,i){e=e||t.keyCode||t.button;var o=kh[e];if(ts(zr,o,e,!o||!Ph[o]),o){if(!Ph[o]){var n=void 0!==i?i:e;Oh[o][n]||(Ch[o]++,Oh[o][n]=!0)}return!Ih[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},Bh=function(t,e,i){e=e||t.keyCode||t.button;var o=kh[e];if(ts(Fr,o,e),o){var n=void 0!==i?i:e;return Oh[o][n]=void 0,Ch[o]>0&&Ch[o]--,Ph[o]=!1,!Ih[e]||"function"!=typeof t.preventDefault||t.preventDefault()}return!0},Dh=null;function Lh(){null===Dh&&!1===As&&"function"==typeof(Dh=globalThis).addEventListener&&(Dh.addEventListener("keydown",Rh,!1),Dh.addEventListener("keyup",Bh,!1))}function zh(t,e,i){!0===e?Rh({},t,i):Bh({},t,i)}function Fh(t){return kh[t]}var jh,Vh=new ir,Uh=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,ml(this.pageX,this.pageY,Vh),this.gameScreenX=this.x=Vh.x,this.gameScreenY=this.y=Vh.y,this.isNormalized=void 0!==globalThis.PointerEvent&&!(t instanceof globalThis.PointerEvent),this.locked=vl,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!==su.viewport&&su.viewport.localToWorld(this.gameScreenX,this.gameScreenY,Vh),this.gameWorldX=Vh.x,this.gameWorldY=Vh.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}(ih),Nh=[],Gh=new Map,Xh=!1,Hh=0,Yh=[],Wh=["wheel"],qh=["pointermove","mousemove","touchmove"],Kh=["pointerdown","mousedown","touchstart"],Zh=["pointerup","mouseup","touchend"],Qh=["pointercancel","mousecancel","touchcancel"],Jh=["pointerenter","mouseenter","touchenter"],$h=["pointerover","mouseover","touchover"],tl=["pointerleave","mouseleave","touchleave"],el=[Wh[0],qh[0],Kh[0],Zh[0],Qh[0],Jh[0],$h[0],tl[0]],il=[Wh[0],qh[1],Kh[1],Zh[1],Qh[1],Jh[1],$h[1],tl[1]],ol=[qh[2],Kh[2],Zh[2],Qh[2],Jh[2],$h[2],tl[2]],nl={wheel:Wh,pointermove:qh,pointerdown:Kh,pointerup:Zh,pointercancel:Qh,pointerenter:Jh,pointerover:$h,pointerleave:tl},rl=[];function sl(){if(!Xh){jh=new Ja(0,0,1,1);for(var t=0;t<Ls;t++)Nh.push(new Uh);var e;null===yl&&(yl=Yc.getCanvas()),Yh=Bs?el:il,Ds&&!Bs&&(Yh=Yh.concat(ol)),function(t,e){for(var i=0;i<t.length;i++)-1===qh.indexOf(t[i])&&yl.addEventListener(t[i],e,{passive:!1===Rl})}(Yh,dl),void 0===fl&&(fl=~~(1e3/ip.maxfps)),fa(),yl.addEventListener(Yh[2],(function(){fa()}),{passive:!1===Rl});var i=hl(Yh,qh);if(fl<17)for(e=0;e<i.length;e++)-1!==Yh.indexOf(i[e])&&yl.addEventListener(i[e],pl,{passive:!0});else for(e=0;e<i.length;e++)-1!==Yh.indexOf(i[e])&&yl.addEventListener(i[e],Jn(pl,fl,!1),{passive:!0});xl(yl),Fs&&document.addEventListener("pointerlockchange",(function(){vl=document.pointerLockElement===qc(),ts(Gr,vl)}),!0),Xh=!0}}function al(t,e){for(var i=0;i<e.length;i++){if(-1!==t.indexOf(e[i]))return e[i]}}function hl(t,e){for(var i=[],o=0;o<e.length;o++){-1!==t.indexOf(e[o])&&i.push(e[o])}return i}function ll(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 ul(t){for(var e=!1;t.length>0;){var i=t.pop();if(Nh.push(i),!0===i.isNormalized&&void 0!==i.event.timeStamp){if(i.event.timeStamp<Hh)continue;Hh=i.event.timeStamp}jh.setShape(i.gameWorldX,i.gameWorldY,i.width,i.height),qh.includes(i.type)&&(i.gameX=i.gameLocalX=i.gameScreenX,i.gameY=i.gameLocalY=i.gameScreenY,ts(Nr,i));for(var o,n=su.world.broadphase.retrieve(jh,$l.prototype._sortReverseZ),r=(n=n.concat([su.viewport])).length;o=n[--r];){if(Gh.has(o)&&!0!==o.isKinematic){var s,a=Gh.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(er.pull("Vector2d",p,d));p=f.x,d=f.y,er.push(f)}switch(s=u.contains(p,d),i.type){case qh[0]:case qh[1]:case qh[2]:case qh[3]:if(a.pointerId!==i.pointerId||s){if(null===a.pointerId&&s&&ll(a,al(Yh,Jh),i,i.pointerId)){e=!0;break}}else if(ll(a,al(Yh,tl),i,null)){e=!0;break}if(s&&ll(a,i.type,i,i.pointerId)){e=!0;break}break;case Zh[0]:case Zh[1]:case Zh[2]:case Zh[3]:if(a.pointerId===i.pointerId&&s&&ll(a,i.type,i,null)){e=!0;break}break;case Qh[0]:case Qh[1]:case Qh[2]:case Qh[3]:if(a.pointerId===i.pointerId&&ll(a,i.type,i,null)){e=!0;break}break;default:if(s&&ll(a,i.type,i,i.pointerId)){e=!0;break}}}if(!0===e)break}}return e}function cl(t){var e;if(Rs&&t.changedTouches)for(var i=0,o=t.changedTouches.length;i<o;i++){var n=t.changedTouches[i];(e=Nh.pop()).setEvent(t,n.pageX,n.pageY,n.clientX,n.clientY,n.identifier),rl.push(e)}else(e=Nh.pop()).setEvent(t,t.pageX,t.pageY,t.clientX,t.clientY,t.pointerId),rl.push(e);return!1===t.isPrimary||(rl[0].isPrimary=!0,Object.assign(gl,rl[0])),rl}function pl(t){ul(cl(t))}function dl(t){cl(t);var e=rl[0].button;(ul(rl)||"wheel"===t.type)&&t.preventDefault();var i=gl.bind[e];i&&zh(i,Kh.includes(t.type),e+1)}var fl,yl=null,gl=new Uh(0,0,1,1),vl=!1;function ml(t,e,i){i=i||er.pull("Vector2d");var o=ua(Yc.getCanvas()),n=globalThis.devicePixelRatio||1;t-=o.left+(globalThis.pageXOffset||0),e-=o.top+(globalThis.pageYOffset||0);var r=Hc;return 1===r.x&&1===r.y||(t/=r.x,e/=r.y),i.set(t*n,e*n)}function xl(t,e){t.style["touch-action"]=e||"none"}function _l(t,e,i){if(sl(),-1===el.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=hl(Yh,nl[t]);Gh.has(e)||Gh.set(e,{region:e,callbacks:{},pointerId:null});for(var n=Gh.get(e),r=0;r<o.length;r++)t=o[r],n.callbacks[t]?n.callbacks[t].push(i):n.callbacks[t]=[i]}function bl(t,e,i){if(-1===el.indexOf(t))throw new Error("invalid event type : "+t);var o=hl(Yh,nl[t]),n=Gh.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)Xn(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&&Gh.delete(e)}}function wl(t){if(Gh.has(t))for(var e=0;e<el.length;e++)bl(el[e],t)}var Tl=.1;function Al(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 El=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-/i,Sl=/^0+/;function Cl(t,e){var i=t.replace(El,(function(t,e,i){return"000".slice(e.length-1)+e+"-"+"000".slice(i.length-1)+i+"-"})),o=t.replace(El,(function(t,e,i){return e.replace(Sl,"")+"-"+i.replace(Sl,"")+"-"}));e.analog=e.analog||e.buttons.map((function(){return-1})),e.normalize_fn=e.normalize_fn||function(t){return t},Ol.set(i,e),Ol.set(o,e)}var Ml,Pl={},Ol=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:Al}],["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:Al}]].forEach((function(t){Cl(t[0],t[1])}));var Il=function(){var t=navigator.getGamepads();Object.keys(Pl).forEach((function(e){var i=t[e];if(i){var o=null;"standard"!==i.mapping&&(o=Ol.get(i.id));var n=Pl[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)>=Tl}}ts(Ur,e,"buttons",+t,h),!r.pressed&&h.pressed?zh(r.keyCode,!0,s+256):r.pressed&&!h.pressed&&zh(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)>=Tl+Math.abs(r[h].threshold);ts(Ur,e,"axes",+t,a),!r[h].pressed&&l?(r[-h].pressed&&(zh(r[-h].keyCode,!1,s+256),r[-h].value=0,r[-h].pressed=!1),zh(r[h].keyCode,!0,s+256)):!r[h].pressed&&!r[-h].pressed||l||zh(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){ts(jr,t.gamepad)}),!1),globalThis.addEventListener("gamepaddisconnected",(function(t){ts(Vr,t.gamepad)}),!1));for(var kl=Cl,Rl=!0,Bl=Object.freeze({__proto__:null,preventDefault:Rl,get pointerEventTarget(){return yl},pointer:gl,get locked(){return vl},get throttlingInterval(){return fl},globalToLocal:ml,setTouchAction:xl,bindPointer:function(){var t=arguments.length<2?gl.LEFT:arguments[0],e=arguments.length<2?arguments[0]:arguments[1];if(sl(),!Fh(e))throw new Error("no action defined for keycode "+e);gl.bind[t]=e},unbindPointer:function(t){gl.bind[void 0===t?gl.LEFT:t]=null},registerPointerEvent:_l,releasePointerEvent:bl,releaseAllPointerEvents:wl,requestPointerLock:function(){return!!Fs&&(qc().requestPointerLock(),!0)},exitPointerLock:function(){return!!Fs&&(document.exitPointerLock(),!0)},get keyBoardEventTarget(){return Dh},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:Lh,isKeyPressed:function(t){return!(!Ch[t]||Ph[t])&&(Mh[t]&&(Ph[t]=!0),!0)},keyStatus:function(t){return Ch[t]>0},triggerKeyEvent:zh,bindKey:function(t,e,i,o){void 0===o&&(o=Rl),kh[t]=e,Ih[t]=o,Ch[e]=0,Mh[e]=i||!1,Ph[e]=!1,Oh[e]={}},getBindingKey:Fh,unlockKey:function(t){Ph[t]=!1},unbindKey:function(t){var e=kh[t];Ch[e]=0,Mh[e]=!1,Oh[e]={},kh[t]=null,Ih[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(!Fh(i))throw new Error("no action defined for keycode "+i);void 0===Ml&&"function"==typeof navigator.getGamepads&&(Ml=es(Pr,Il)),Pl[t]||(Pl[t]={axes:{},buttons:{}});var o={keyCode:i,value:0,pressed:!1,threshold:e.threshold},n=Pl[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(!Pl[t])throw new Error("no bindings for gamepad "+t);Pl[t].buttons[e]={}},setGamepadDeadzone:function(t){Tl=t},setGamepadMapping:kl}),Dl=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=er.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 Ah?this.anchorPoint.setMuted(.5,.5).setCallback(this.onAnchorUpdate,this):this.anchorPoint=er.pull("ObservableVector2d",.5,.5,{onUpdate:this.onAnchorUpdate,scope:this}),this.autoTransform=!0,this.alpha=1,this.ancestor=void 0,this.mask=void 0,this.blendMode="normal",this.name="",this.pos instanceof Sh?this.pos.setMuted(e,i,0).setCallback(this.updateBoundsPos,this):this.pos=er.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},tint:{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.tint.get=function(){return void 0===this._tint&&(this._tint=er.pull("Color",255,255,255,1)),this._tint},i.tint.set=function(t){void 0===this._tint&&(this._tint=er.pull("Color",255,255,255,1)),t instanceof cr?this._tint.copy(t):this._tint.parseCSS(t)},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=Fn(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 $l&&!0!==this.floating&&i.translate(this.ancestor.getAbsolutePosition()),this.isDirty=!0},e.prototype.getAbsolutePosition=function(){return void 0===this._absPos&&(this._absPos=er.pull("Vector2d")),this._absPos.set(this.pos.x,this.pos.y),this.ancestor instanceof $l&&!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(){er.push(this.currentTransform),this.currentTransform=void 0,er.push(this.anchorPoint),this.anchorPoint=void 0,er.push(this.pos),this.pos=void 0,void 0!==this._absPos&&(er.push(this._absPos),this._absPos=void 0),er.push(this._bounds),this._bounds=void 0,this.onVisibilityChange=void 0,void 0!==this.mask&&(er.push(this.mask),this.mask=void 0),void 0!==this._tint&&(er.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),wl(this),this.onDestroyEvent.apply(this,arguments)},e.prototype.onDestroyEvent=function(){},Object.defineProperties(e.prototype,i),e}(Ja),Ll=[],zl=0;zl<10;zl++)Ll.push(new ir);for(var Fl=[],jl=0;jl<5;jl++)Fl.push([]);function Vl(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 Ul(t,e,i,o,n,r){var s=Fl.pop(),a=Fl.pop(),h=Ll.pop().copy(e).sub(t),l=h.dot(n);if(Vl(i,n,s),Vl(o,n,a),a[0]+=l,a[1]+=l,s[0]>a[1]||a[0]>s[1])return Ll.push(h),Fl.push(s),Fl.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 Ll.push(h),Fl.push(s),Fl.push(a),!1}function Nl(t,e){var i=t.length2(),o=e.dot(t);return o<0?-1:o>i?1:0}function Gl(t,e,i,o,n){for(var r=Ll.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=Ll.pop(),p=Ll.pop(),d=Ll.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,x=null;c.copy(l[y]),d.copy(r).sub(h[y]),n&&d.length2()>a&&(n.aInB=!1);var _=Nl(c,d),b=!0;if(-1===_){var w=null;if(u>1&&(c.copy(l[v]),1!==(_=Nl(c,w=Ll.pop().copy(r).sub(h[v])))&&(b=!1)),b){if((f=d.length())>s)return Ll.push(r),Ll.push(c),Ll.push(p),Ll.push(d),w&&Ll.push(w),!1;n&&(n.bInA=!1,x=d.normalize(),m=s-f)}w&&Ll.push(w)}else if(1===_){if(u>1&&(c.copy(l[g]),d.copy(r).sub(h[g]),-1!==(_=Nl(c,d))&&(b=!1)),b){if((f=d.length())>s)return Ll.push(r),Ll.push(c),Ll.push(p),Ll.push(d),!1;n&&(n.bInA=!1,x=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 Ll.push(r),Ll.push(c),Ll.push(p),Ll.push(d),!1;n&&(x=p,m=s-f,(f>=0||m<2*s)&&(n.bInA=!1))}x&&n&&Math.abs(m)<Math.abs(n.overlap)&&(n.overlap=m,n.overlapN.copy(x))}return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),Ll.push(r),Ll.push(c),Ll.push(p),Ll.push(d),!0}var Xl=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=Ll.pop().copy(t.pos).add(t.ancestor.getAbsolutePosition()).add(e.pos),d=Ll.pop().copy(i.pos).add(i.ancestor.getAbsolutePosition()).add(o.pos);for(r=0;r<h;r++)if(Ul(p,d,s,l,a[r],n))return Ll.push(p),Ll.push(d),!1;for(r=0;r<c;r++)if(Ul(p,d,s,l,u[r],n))return Ll.push(p),Ll.push(d),!1;return n&&(n.a=t,n.b=i,n.overlapV.copy(n.overlapN).scale(n.overlap)),Ll.push(p),Ll.push(d),!0},testEllipseEllipse:function(t,e,i,o,n){var r=Ll.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 Ll.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 Ll.push(r),!0},testPolygonEllipse:Gl,testEllipsePolygon:function(t,e,i,o,n){var r=Gl(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}}),Hl=function(){this.a=null,this.b=null,this.overlapN=new ir,this.overlapV=new ir,this.aInB=!0,this.bInA=!0,this.indexShapeA=-1,this.indexShapeB=-1,this.overlap=Number.MAX_VALUE};Hl.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this.indexShapeA=-1,this.indexShapeB=-1,this};var Yl={pos:new ir(0,0),ancestor:{_absPos:new ir(0,0),getAbsolutePosition:function(){return this._absPos}}},Wl=new Hl;function ql(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 Kl={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=su.world.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);Xl["test"+a.shapeType+l.shapeType].call(this,Yl,a,i,l)&&(e[o]=i,o++),h++}while(h<s)}return e.length=o,e}(t,e)}},Zl=function(t,e,i){if(this.ancestor=t,void 0===this.bounds&&(this.bounds=er.pull("Bounds")),void 0===this.shapes&&(this.shapes=[]),this.collisionMask=Kl.types.ALL_OBJECT,this.collisionType=Kl.types.ENEMY_OBJECT,void 0===this.vel&&(this.vel=er.pull("Vector2d")),this.vel.set(0,0),void 0===this.force&&(this.force=er.pull("Vector2d")),this.force.set(0,0),void 0===this.friction&&(this.friction=er.pull("Vector2d")),this.friction.set(0,0),this.bounce=0,this.mass=1,void 0===this.maxVel&&(this.maxVel=er.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};Zl.prototype.setStatic=function(t){void 0===t&&(t=!0),this.isStatic=!0===t},Zl.prototype.addShape=function(t){if(t instanceof Ja||t instanceof ih){var e=t.toPolygon();this.shapes.push(e),this.bounds.add(e.points),this.bounds.translate(e.pos)}else t instanceof th?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addBounds(t.getBounds()),this.bounds.translate(t.getBounds().x,t.getBounds().y)):t instanceof Qa?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.add(t.points),this.bounds.translate(t.pos)):t instanceof rh?(this.shapes.includes(t)||this.shapes.push(t),this.bounds.addPoint(t)):this.fromJSON(t);return"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this),this.shapes.length},Zl.prototype.setVertices=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=!0);var o=this.getShape(e);o instanceof Qa?o.setShape(0,0,t):this.shapes[e]=er.pull("Polygon",0,0,t),this.bounds.add(this.shapes[e].points,i),"function"==typeof this.onBodyUpdate&&this.onBodyUpdate(this)},Zl.prototype.addVertices=function(t,e){void 0===e&&(e=0),this.setVertices(t,e,!1)},Zl.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},Zl.prototype.getShape=function(t){return this.shapes[t||0]},Zl.prototype.getBounds=function(){return this.bounds},Zl.prototype.removeShape=function(t){this.bounds.clear(),Xn(this.shapes,t);for(var e=0;e<this.shapes.length;e++)this.addShape(this.shapes[e]);return this.shapes.length},Zl.prototype.removeShapeAt=function(t){return this.removeShape(this.getShape(t))},Zl.prototype.setCollisionMask=function(t){void 0===t&&(t=Kl.types.ALL_OBJECT),this.collisionMask=t},Zl.prototype.setCollisionType=function(t){if(void 0!==t){if(void 0===Kl.types[t])throw new Error("Invalid value for the collisionType property");this.collisionType=Kl.types[t]}},Zl.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),!this.ignoreGravity)){var i=!0===this.falling?1:!0===this.jumping?-1:0;this.falling=e.y>=i,this.jumping=e.y<=-i}},Zl.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++},Zl.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},Zl.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 th?i.bounds.translate(o.getBounds().x,o.getBounds().y):i.bounds.translate(o.pos)})),this},Zl.prototype.setMaxVelocity=function(t,e){this.maxVel.x=t,this.maxVel.y=e},Zl.prototype.setFriction=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.friction.x=t,this.friction.y=e},Zl.prototype.update=function(t){var e=ip.tick;if(0!==this.force.x&&(this.vel.x+=this.force.x*e),0!==this.force.y&&(this.vel.y+=this.force.y*e),this.friction.x>0){var i=this.friction.x*e,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*e,s=this.vel.y+r,a=this.vel.y-r;this.vel.y=s<0?s:a>0?a:0}return 0!==this.vel.y&&(this.vel.y=Fn(this.vel.y,-this.maxVel.y,this.maxVel.y)),0!==this.vel.x&&(this.vel.x=Fn(this.vel.x,-this.maxVel.x,this.maxVel.x)),this.falling=this.vel.y*Math.sign(this.force.y)>0,this.jumping=!this.falling&&this.jumping,this.ancestor.pos.add(this.vel),0!==this.vel.x||0!==this.vel.y},Zl.prototype.destroy=function(){er.push(this.bounds),er.push(this.vel),er.push(this.force),er.push(this.friction),er.push(this.maxVel),this.shapes.forEach((function(t){er.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 Ql=function(t,e){this.removeChildNow(t,e)},Jl=0,$l=function(t){function e(e,i,o,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===o&&(o=su.viewport.width),void 0===n&&(n=su.viewport.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=su.sortOn,this.autoSort=!0,this.autoDepth=!0,this.clipping=!1,this.onChildChange=function(t){},this.enableChildBoundsUpdate=!1,this.backgroundColor=er.pull("Color",0,0,0,0),this.drawCount=0,this.autoTransform=!0,this.isKinematic=!1,this.anchorPoint.set(0,0),!0===this.root&&es(Wr,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=$c.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()&&su.repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Zl&&su.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=$c.createGUID()),t.ancestor=this,this.getChildren().splice(i,0,t),"function"==typeof t.onActivateEvent&&this.isAttachedToRoot()&&t.onActivateEvent(),!0===this.isAttachedToRoot()&&su.repaint(),this.enableChildBoundsUpdate&&this.updateBounds(!0),t.body instanceof Zl&&su.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,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.");$c.function.defer(Ql,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 Zl&&su.world.removeBody(t.body),e||!1===er.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()&&su.repaint(),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=$c.function.defer((function(){this.getChildren().sort(this["_sort"+this.sortOn.toUpperCase()]),this.pendingSort=null,su.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,n=Mu.isPaused(),r=this.getChildren(),s=r.length;s--,i=r[s];)n&&!i.updateWhenPaused||(i.isRenderable?((o=Jl>0||i.floating)&&Jl++,i.inViewport=!1,Mu.current().cameras.forEach((function(t){t.isVisible(i,o)&&(i.inViewport=!0)})),this.isDirty|=(i.inViewport||i.alwaysUpdate)&&i.update(e),Jl>0&&Jl--):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}(Dl),tu=[];function eu(t,e,i,o,n){if(void 0===i&&(i=4),void 0===o&&(o=4),void 0===n&&(n=0),tu.length>0){var r=tu.pop();return r.world=t,r.bounds=e,r.max_objects=i,r.max_levels=o,r.level=n,r}return new ou(t,e,i,o,n)}var iu=new ir,ou=function(t,e,i,o,n){void 0===i&&(i=4),void 0===o&&(o=4),void 0===n&&(n=0),this.world=t,this.bounds=e,this.max_objects=i,this.max_levels=o,this.level=n,this.bounds=e,this.objects=[],this.nodes=[]};ou.prototype.split=function(){this.level;var t=this.bounds.width/2,e=this.bounds.height/2,i=this.bounds.left,o=this.bounds.top;this.nodes[0]=eu(this.world,this.bounds,{left:i+t,top:o,width:t,height:e},this.max_objects,this.max_levels),this.nodes[1]=eu(this.world,this.bounds,{left:i,top:o,width:t,height:e},this.max_objects,this.max_levels),this.nodes[2]=eu(this.world,this.bounds,{left:i,top:o+e,width:t,height:e},this.max_objects,this.max_levels),this.nodes[3]=eu(this.world,this.bounds,{left:i+t,top:o+e,width:t,height:e},this.max_objects,this.max_levels)},ou.prototype.getIndex=function(t){var e,i=t.getBounds(),o=-1,n=(e=!0===t.isFloating?this.world.app.viewport.localToWorld(i.left,i.top,iu):iu.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},ou.prototype.insertContainer=function(t){for(var e,i=t.children.length;i--,e=t.children[i];)!0!==e.isKinematic&&(e instanceof $l?("rootContainer"!==e.name&&this.insert(e),this.insertContainer(e)):"function"==typeof e.getBounds&&this.insert(e))},ou.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}},ou.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},ou.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=Xn(this.nodes[i],t))&&this.nodes[i].isPrunable()&&this.nodes.splice(i,1)}return!1===e&&-1!==this.objects.indexOf(t)&&(Xn(this.objects,t),e=!0),e},ou.prototype.isPrunable=function(){return!(this.hasChildren()||this.objects.length>0)},ou.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},ou.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],tu.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 nu=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.app=null,this.fps=60,this.gravity=new ir(0,.98),this.preRender=!1,this.bodies=new Set,this.broadphase=new ou(this,this.getBounds().clone(),Kl.maxChildren,Kl.maxDepth),es(Mr,this.reset,this),es(Br,(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.bodyApplyGravity=function(t){if(!t.ignoreGravity&&0!==t.gravityScale){var e=this.gravity;t.force.x+=t.mass*e.x*t.gravityScale,t.force.y+=t.mass*e.y*t.gravityScale}},e.prototype.update=function(e){var i=this,o=Mu.isPaused();return this.broadphase.clear(),this.broadphase.insertContainer(this),this.bodies.forEach((function(t){if(!t.isStatic){var n=t.ancestor;o&&!n.updateWhenPaused||!n.inViewport&&!n.alwaysUpdate||(i.bodyApplyGravity(t),!0===t.update(e)&&(n.isDirty=!0),function(t,e){void 0===e&&(e=Wl);for(var i,o=0,n=su.world.broadphase.retrieve(t),r=n.length;i=n[--r];)if(i!==t&&ql(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===Xl["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)}}(n),t.force.set(0,0))}})),t.prototype.update.call(this,e)},e}($l),ru=function(){this.viewport=null,this.world=null,this.mergeGroup=!0,this.sortOn="z",this.lastUpdate=0,this.isDirty=!0,this.isAlwaysDirty=!1,this.frameCounter=0,this.frameRate=1,this.accumulator=0,this.accumulatorMax=0,this.accumulatorUpdateDelta=0,this.stepSize=1e3/60,this.updateDelta=0,this.lastUpdateStart=null,this.updateAverageDelta=0};ru.prototype.init=function(){this.world=new nu,this.world.app=this,this.lastUpdate=globalThis.performance.now(),ts(Cr,this)},ru.prototype.reset=function(){var t=Mu.get();void 0!==t&&(this.viewport=t.cameras.get("default")),ts(Mr),this.updateFrameRate()},ru.prototype.onLevelLoaded=function(){},ru.prototype.updateFrameRate=function(){this.frameCounter=0,this.frameRate=~~(.5+60/ip.maxfps),this.stepSize=1e3/this.world.fps,this.accumulator=0,this.accumulatorMax=10*this.stepSize,this.isAlwaysDirty=ip.maxfps>this.world.fps},ru.prototype.getParentContainer=function(t){return t.ancestor},ru.prototype.repaint=function(){this.isDirty=!0},ru.prototype.update=function(t,e){if(++this.frameCounter%this.frameRate==0){for(this.frameCounter=0,ts(Pr,t),this.accumulator+=ip.getDelta(),this.accumulator=Math.min(this.accumulator,this.accumulatorMax),this.updateDelta=ip.interpolation?ip.getDelta():this.stepSize,this.accumulatorUpdateDelta=ip.interpolation?this.updateDelta:Math.max(this.updateDelta,this.updateAverageDelta);this.accumulator>=this.accumulatorUpdateDelta||ip.interpolation;)if(this.lastUpdateStart=globalThis.performance.now(),!0!==Mu.isPaused()&&ts(Ir,t),this.isDirty=e.update(this.updateDelta)||this.isDirty,this.lastUpdate=globalThis.performance.now(),this.updateAverageDelta=this.lastUpdate-this.lastUpdateStart,this.accumulator-=this.accumulatorUpdateDelta,ip.interpolation){this.accumulator=0;break}ts(Or,this.lastUpdate)}},ru.prototype.draw=function(t){!0===Yc.isContextValid&&(this.isDirty||this.isAlwaysDirty)&&(ts(kr,globalThis.performance.now()),Yc.clear(),t.draw(Yc),this.isDirty=!1,Yc.flush(),ts(Rr,globalThis.performance.now()))};var su=new ru;es(_r,(function(){su.init()}));var au,hu=Math.min,lu=Math.max,uu=new ir,cu=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=er.pull("Bounds"),this.smoothFollow=!0,this.damping=1,this.near=-1e3,this.far=1e3,this.projectionMatrix=new dr,this.invCurrentTransform=new yr,this.offset=new ir,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(),es(Mr,this.reset,this),es(Wr,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=hu(t.x-this.deadzone.right,this.bounds.width-this.width):t.x-this.pos.x<this.deadzone.pos.x&&(e=lu(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=hu(t.y-this.deadzone.bottom,this.bounds.height-this.height):t.y-this.pos.y<this.deadzone.pos.y&&(e=lu(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 Ja(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(),ts(qr,this.width,this.height,this),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 ir||e instanceof Eh||e instanceof Ah||e instanceof Sh))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:Fn(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=Fn(t,this.bounds.left,this.bounds.width),this.pos.y=Fn(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(uu.setV(this.pos),this.follow_axis){case this.AXIS.NONE:break;case this.AXIS.HORIZONTAL:uu.x=this._followH(this.target);break;case this.AXIS.VERTICAL:uu.y=this._followV(this.target);break;case this.AXIS.BOTH:uu.x=this._followH(this.target),uu.y=this._followV(this.target)}if(!this.pos.equals(uu)){if(!0===this.smoothFollow&&this.damping<1){if(Nn(uu.x,this.pos.x,2)&&Nn(uu.y,this.pos.y,2))return void this.pos.setV(uu);this.pos.lerp(uu,this.damping)}else this.pos.setV(uu);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&&ts(Qr,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=er.pull("Color").copy(t),this._fadeOut.tween=er.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=er.pull("Color").copy(t);var o=this._fadeIn.color.alpha;this._fadeIn.color.alpha=0,this._fadeIn.tween=er.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?Yc.overlaps(t.getBounds()):t.getBounds().overlaps(this)},e.prototype.localToWorld=function(t,e,i){return(i=i||er.pull("Vector2d")).set(t,e).add(this.pos).sub(su.world.pos),this.currentTransform.isIdentity()||this.invCurrentTransform.apply(i),i},e.prototype.worldToLocal=function(t,e,i){return(i=i||er.pull("Vector2d")).set(t,e),this.currentTransform.isIdentity()||this.currentTransform.apply(i),i.sub(this.pos).add(su.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,er.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,er.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,this),e.draw(t,this),this.drawFX(t),e.postDraw(t,this),this.postDraw(t),e.currentTransform.translate(i,o)},e}(Dl),pu={cameras:[]},du=function(t){this.cameras=new Map,this.lights=new Map,this.ambientLight=new cr(0,0,0,0),this.settings=Object.assign(pu,t||{})};du.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===au){var e=Yc.getWidth(),i=Yc.getHeight();au=new cu(0,0,e,i)}this.cameras.set("default",au)}su.reset(),this.onResetEvent.apply(this,arguments)},du.prototype.update=function(t){var e=su.world.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},du.prototype.draw=function(t){var e=this;this.cameras.forEach((function(i){i.draw(t,su.world),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,su.world),e.draw(t,su.world),e.postDraw(t,su.world)}))}))},du.prototype.destroy=function(){this.cameras.clear(),this.lights.forEach((function(t){t.destroy()})),this.lights.clear(),this.onDestroyEvent.apply(this,arguments)},du.prototype.onResetEvent=function(){"function"==typeof this.settings.onResetEvent&&this.settings.onResetEvent.apply(this,arguments)},du.prototype.onDestroyEvent=function(){"function"==typeof this.settings.onDestroyEvent&&this.settings.onDestroyEvent.apply(this,arguments)};var fu=function(t){function e(e,i,o,n){t.call(this,e,i,o,n),this.barHeight=n,this.anchorPoint.set(0,0),es(Lr,this.onProgressUpdate,this),es(qr,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,e){t.setColor("black"),t.fillRect(this.pos.x,e.centerY,t.getWidth(),this.barHeight/2),t.setColor("#55aa00"),t.fillRect(this.pos.x,e.centerY,this.progress,this.barHeight/2)},e.prototype.onDestroyEvent=function(){os(Lr,this.onProgressUpdate),os(qr,this.resize)},e}(Dl),yu=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(){su.world.backgroundColor.parseCSS("#202020"),su.world.addChild(new fu(0,Yc.getHeight()/2,Yc.getWidth(),8),1),mc.load({name:"melonjs_logo",type:"image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAA8FBMVEUgICBrqDHRZVtqpzEhJCAjKCBurTIfHyDQZFptrDEWAB8OAB7VZ1wtIiIAEhYlISDYaF4SAB4pIiEAFhkcFh8eGyBopDAMAB5noS8kKyAAGhtjmy4bEB9lni8ZBR/HYFdPeim/XFQ9XCUaCh9flS1VhCtSfyorOSEVHh4HHB1EZyatVExhmC5ajCxHbSc0SyMuQCInMiFKcSgxRSI6VSRBYiWdTUZdki09JyZ8PzpYiSs3UCRlNjK1WE9ckC1MdShbjywyJCONRkDKYliUSUNeMzBDKShXMC2kUEl1PDeEQj1OLStnNjNxOjZsODQAAAcMh1CFAAAU4UlEQVR42uyaa3fSMBjHk5EQkgClkBZKoXblNhlswIooc2N6pp7jUb//x/FpRbnt4JWwzv7eraQvfs/zby7tUEpKSkpKSkpKSkpKSkpKSkqKTsg30P8E+FIArJllqQaglMXQt6tPuhogGSlaLWFKKU2hEB33eqPRqDemRAlhRhdbVjwIBj8xogajhpBSkNH1dOJ37mYDt1mr2UCt1mwOZned7qQfjhxPVs0WovTpRIFFNkpIU42CSWfm2phnIzjHP+DLS9hutjuL4IqZUigC9yU/CWDBhBROOJkPbBxL4swKjDf/jEvBbXe4CMeiKixKEx0EAq03JbqeDJs4Ul9a7mE5AqqAazM/pJCb5JaAUmWa42nHBflYDf8y8WC4qznv9yRKZAUIRUKO+/Maz/J1+d8ugu0rK3kVoNSTVhDZr8v/WRGyQw8lC0KJMK989+/sVzXILiRNzmrACGXSC4Z2lsf2f08GN2lyHgJCLUn6bRw1/2dim+A9hIKiJMAQ6NOJu7f5a7r8B+u/7N7BAzMZBaBIkkkz0t83sfMsgDHsgN1BOybaFNvww2qblMgEUGKqi2aU/X3u2HZnHf8iuL4aO0S1PKDVQM54dBn0F50718bfq5CwOYBQIaaDVfd37MG91u5MwhER8WHQU8qC2wCEmFJefEYUrBdedGe15b4xQasAtaqXt/wh/W87W1679YNeCxQbjNCItTchBFheRErAmHEYb575ch/Qeuz9ByXpdHH2QX2wx4NuMBbSbJCfn3IJWZ4dndBvZ6Bytt949A8AbZjT6OHftQeDTHtx2VgebhFj6KfAmGisJaS46k+mj/4sELW/N+QP6UOIXf/Sqwq0p/F7okA8KU312BcAqmTf3k1/1Hx7HlgyskfsL96h7b3XMNCRcYQzz+KH9N3FSC57fxiYUTDOWLmAjgcjpBo2d9oPKxdv95Fs0UPGl5XPinWDVYqGwdBxYFQJH/Mdfc5nQUuyw77KYYXKm/ub09PzV/Xn5SNVAOJ/B/Hf0W8HwiQUHRTwf/2slM/nS6WbN/XjZIDK6534w8zv9r1In6GDUq6/y+VzMaVTdGYg7cDj38/wHX17YknQPzSGUb8p5U5icqX7ovaZkBFk+nw7/hx3epIdvPtAufIpf7Ikl39W0B0BRpToQPy32j8IZUPPW+xC8S0E4Afv6noLwGgL3WZ32u8roetbTqF4v1aA/JdKGWmEUc8ZgP/m0j+4riKKNFEoflwrQO6D1gQwKnrulj/mXUto048XgZV+/vQMaYQ5otfc8s/Wpprav5oFz5cRgHXwo85VgFHw55nN+Ld7UvMnPOP5y2elXMRJ6VzDA7DPH2e7XstBemHl+vubfAk4efGc6SsAo9542x9fVJH+D/lQgfrnF+fn9++KWv0bdHP+z3A7rFKC9MMMo1KsVIr1ssYHgFiqvemfdUemg45EuVAuFMpIH4SI4ZZ/2xEOQ8eCAUgjVHa3/G+txuN/Z/+vYE51suU/9NT/5G8GIL3uPxfsCfwf11fyrW1FgRiGTkna0vZpYHQUXRHdVZBhvCMorP7/V+3oyprgPiy2Dxk2HzA06TknpyHz19CjVfcpf9kj+6SBtqgcMPz/q/vPdPgwLP/DsCM1f2vTf7Ifap5/hYXQ/FGnX7S16LdABADc23oqVP91kYfgrU5b1GxKHSCo7tILzR/z9eJ8nliv0zqAMZ8ATEJfaP6+7jlj3CDlXpHVfsfnH+eyn4kMzMdGQRNO7fNkGEXbGTigBkDq1lZzU07BnaXzIab6LCMAuEEmdWcD8+ax9uNTckxFqyWxwKBgKXZrzerHtAbcPhFQ0R8oAExdChXADIt1Tz0KkGi9TjML1CBLqgA0YZGIFZhZqVNUtf9GCdBbF0IF4Be/vvQYz6pyxhRwH+QC4CpXoAgELvE6iKMtfwJLzv+5YU2iDasOR0MJMBdMgFsMK6ICrppGY+rELGAdhFpAYoXYgRdBRzsLUtB3L/z+7zpITFvHYhQAdorGyQudAdCuNe8qoJjVNgYAF0M+9iFbAe9tK2w4BKIIdVJ0CLASv7jeBFo7cBwCrxcgP1IAjEv5ALipwII1gmGGMR4A2uEB+blJK4x4E1kdZhQA5xYowPe58z3lwKfH199WbQRAc/LpuwPWu17k0qaFCnANAgHSvKJcZdMCxJtgOsQuKsexG2uCwMxa8O8aUa/axHZCe/OUZA42ag0Avqi5ll2nYSAaRQEbZI+NrbKwEFFYJURCiEcpqEE0aZOmBfH/f4PLQ+OEttwxLKg3jq5Or3TG9jyOJ/FjgSIGZvBRLhB1oFvi7/3X5CIDhZHodOLtfyyEXUlh0IGzyDoQM+rbGljFRNaE2ZOXj0MT3pALxGQo8v1z1ILRBb6+hTJoZgLvBoMYRjZAeALuv/v/hZCzeTxWRIu/iwEvbqQMmKcxUekwHqF/KQSo74OCVX8rCyQoC9C/QYBZENZTcYMlRkqjWFlVZfn9OWGXwcoDVFKewD+fo33v9AwQD3HGFqH5XsXHACWVA7BObfp+YyoL4BKpLvb+MuvBlVn1q03iwIONVNFy1jPUBvGyPOaGJT4GGOPAHd9v66bIuy7Pi3p5GKoTrYSdeRXaQrk7LD02P2Gbejv2FqrYdugFxgHM5ChBEFNpIn/czxaObdMJrcXP4Z94sdxZUGZmAZmA+7ws0im4a9oenFQsKg58uE8NhBgE43+LlBysa65FmvJweIppMzobsmJKWve+EFrMsUJ3+wEqGaUKPA9XkSYNhj0xUd8xYkbBsU516lnMhv+LFs1nKCX7BZYVjIUQZ8FC830PRjG6LnSqBzCSPcloP0U9IaLZhknntlynSGhOS+yV/bWuEla1EPwSONXdAc0VKYv4ZcyoWQBGEDp/2zdI/zyrYgfyR6CAL7nm18BC18pJFnlLhuUMsScgvs9CwjrXyOgCq/Q9yIQpBa0Q/DqW6+JoJSNX9AGNT4S2uezhx8B9kBvu2AZGjpQubwLRglHKLnX6Z7DodmgBQjDHkji7O3+MoFFZgITx+pLiMdiChL1G7DUL8DWQLBDPw3dGh5Yjn38YT+TuMrhuvy71HbGiGyzRAg8DVYQQzO49evYg7ArLiP7v82/7n3OcZ8u6F36+IzjfVCqivwkTetqNCHpP2nvdfS74PJTr7zH+NM9pTflPwTMbcN1YkgEwFcL7EXIddf85LQ1SrtZ8FsO6uh13w7Abt02nZ7tjbiuR1+2Xn2COYPxaCCM3+KCqQz86fnpDSgOkPQg+i/dtb8E6P/zUt8Vln+/pF4fVD7D103Gbz8B8cIbULeJlHXqLM2ZQZDHEuGMnpsF+m0Alpfk+pKmAtZdCJNf5wUGJYAervRB8eggotSH2SlAy2myBchi14VbCxKlzka+BScWCqofBUASYCbsVKAQzD65g7CbmEl9OCTQtocEm74ysiPsq6imhilLVxANyUfR2o9i0SN7YstH8DP+9db+DYcD/iFsgqnXWd02SXAc9CrLpx124yFd2w35HlQ4tEPCHxPwO9haY7oG1NbQbMnLPYPbw2YNIMYAlxeTIDlP+WP0axAUhTrGzefUXEeK+kXetvU3DUDQtqdxKSQwJG1romIbQSLWhfuChFRioG92rsP//c3AiwbErxfKxBMoFf/am5cyPc+899/hDkTOJHZ4IKMQQrC6irDZTh+YVa9VHlsbuyK6uEe7tINCdK9hVutGkUgL/S0pox5cEchPX2X9qrXVfuIQIoAcsDN2sj+yb5XuVU8JZlgkpZ+PMzMbhvG0AwKqfteh6O3VZbqL8J4tNhggAluxxBgaNEIK7A/BNWvkWC7DCV/X+3qsMU0+LkqiS75NyMUhD+LqqrjdT51TPlQeAVTZ11nXpW1nm1sDOWhA1blBBcGEincwV1crqwV7Vq6r0U8ZxiCEevONwtzaaKnGS6X3lCGRHSwaAuyzU4Uyr5tjaLv4wL6+cm3BbxwFw9pSujJsfowBY2UfAutHeyRftZGwXb4RxY2+XDQHAgQGAlblMHI382xeRABwnSicBpyDYjS/HADYILhiYFAMA6k8DUDgANCQAfue0bPy3AeC3QD48AGK2gHLOgJFwAKhDENfgvwkArkGGCH0SDcAuEeKp8MhQYcEAtFT4EU2Fn9nB0HvJAExQHEMwRIfDogFgw2GI7eGXIhkANyESlxITvQLc/2UwAO+cLILgW4BMikIg46TF01QwAGxaHOwBuoI9uQBwhRGMPbs09nouFwCo3fAlLG6GCooFAMVRrGVaXTUz5XGxAHjK44xAQioArUBiZgskYiUyUrcAKhygdDEiqT2xPACZDS6qSe2+y04hIROAFM5aSO6F2qe5pmxDAMBJivJCydFhqsiOK9SHhQLQNb/ahTHFycsglh7EFogB4IQUSyORsqT841Aay8aBxR7VqYlQHPfK33SysAUVwY/qzF/ZO5kRfKLljAkidJMfZaEPgJXVD+ubNnUZqL0yS0upwKAOWidW7ZY++UhSIRQxp79KmAvth8sIha5Q8VZJ0B6YdquFaZlBTjyl7UMQEQcXyG8fZ93TN+MHCJv75l4bzWQ3+RhlRI8A2UzGozpEdpvjgSDRYALh7TY6qS+PWpHvBcT9nmdizk+nmQHsNq+xAHoRuLkYt21k32qlQ/01D0es0gVUCIcAZUimdbG+u7z/XOP7PQgsiu395WpbNKUKaEKqNmbyeZFoNiEKOscrDHkf1bxpmz91GdZY2HWHhjWHlt3kRc6bS/I2IoijIkyadZ7nJTNZU5PpByHAAmhXvkgfGqXUACY77fOc5h2SeXRciTNQ2Gkef56oOAsNtF1KQwCRIN/9CxqFZII8E5WXFpdFiZeW2oNHyRrIhSAfGrMHUCUfrKN8yAI+oYyUkFK2HaVFW2khtR/rPzDal+UkZGjwzOMAwRSJkReScwyi5QGdEvxI2wqZSEdNeGryRNYl018dT9X/zlIzndt0eHR4MNSnVXyPgoAGR3tKYidJ8dOa4PRCTTD2eRl7CUyEmAqirIHqbuxveuOcAjIuApwAHjNFKqmC5lsZIdH8zGuuzp8mYJQCTgGo/FARix7KMSQzYzn8vAAU8gFGcPQS+DJ8AH4rndH8PqQ3S35yd2U7isNAMFHasWw/WcopQhRBIBICQsggJCIx/P9XrTMcDWbZY5YQs36Yh4EZXNXl7vJB3Hkjd7fCkCfc3/ZGbgh4zp5xwYbuBdBWGr00pF2OrT0E6p/sIH6V1uRHTANeDv1NE/j4rB1mFYMHgTYJsJtnrGORL1W9w107NA4/u+gqjL+cFXprU2+cbSvA828GxFKImwRmLpDiji6WwCdvsuDjOU1MA7iI+WzXBj4MmfFpQKuAeC7wOdss6n8afe8qjaUaqNdRWoeEPt1g4wPGpFkMUJKuIruDAaA/ahsToVmXr4NnYanq4GI4eq4waLKJZxADYF12MvFIEO3EZKPLTMxxhADo1ztK0zgtxIND3JhieKnTeKEEhacT4F9OHOB+qRkMXHZwcCOzgwxFv76IfKszMxgg4bqNDDa26cSs01hsmKMtDlj9X8La4sfAdHkvHn6vHhngtGcGAJT+EX+3RxnwDDV+GPf7rIYUQGQa/tyj3RFA063GwN4f98cAJT6f3HaIDaukO1FS8GCuMTCveGz10yhJvIWGP+rWolKSFkMtEw7LvuaGMa/yW/y208iO8GMxXEXslnRnE8LrUyEFIpqhht8edb5aRWNeawzYLJMvnxhQsMKZw16KHw2RzoC7iF+dCOJ0PGX2a/Hj0sNFA5gIPl4zDFD+KzX8dfzhoyh0zwCzP/nrREA8MQu0HtjOSHTeAcwDxcDVPt/d1iGQVygQiKx2rq1FIPh4BX7MA/G5AOEwCNZKBN3PjuJEbCLX0cZgVL90kY6SxFcW5E4EZegTq9N+ECssdszWyZ8X/DX4UYc+n+oydFx7SgR0Z4sogEzWgc684x6s9PV1GMS6DbsmguGMc9IRBUC4HM3d+w+d9jIlAxKOIi0R2A5z85HkHWRDCiQV5YIxR8PP7KWAfiblsSxyV++P6tDhQz5dBS38emLfhV9ZkKa/Q8xknKAdu04Fiw/OLfKssFCLAJf1xEH4PZpQ3ZBvMCdddcvejxLhE3hO8KnkzQ7hX8t/LfvdnwAiiz327IoCli9jwUFxQP8l9kBgLKzNvhX/Pc/zpo+JqD4M+NpBEVzlAjeaNqkYA4Hv00s8wetswJDj6/BPfQNOKlCAsN7+rIPtSMjXKy4SIH8rBGoBEPCkqGYHx8XMfx3+wUdombE9RzhfBg8ocIPDUnHAfULgr0JP1R8Vs13kovZvEq2TqfCbsC1xMkXFzsY46RxsPxuQioRWCQC/RA5AFPhUCL9cL6JW+j+Dz1rXTfuXPzaSiNEcY3XHgT3YLRvCheSeBQR5oKpdIQfLS6WQUM4mA8e9Qa/7TWPCf/FpfLwcIgU6B0zBGe6zWVklMlQ8jD2/BX0mg3pjLkUo07jcZIsWPEP0OvwgA9l78r9vBAT5jB5QcESjYDlRvpsuN01dES/lnEupfqQeVKtmtMx2+dBhJ/APmHSdaWGW+rERPyymAVKgtRMq5rYIg2g4z/P9YbFY7PN8PoyC4wuI/QH8yUokxDIu/Ofk7YVFFmllSyfhjJCxFvIXaqa99Ah+MKnF2KzBf0dBElbrAdNk8IAKbL9/txJIlK1EajT8Yzb0hTXb2pjC/7k5X55qvqzCxHT458mL4M10iDL4bsMSEuxGifDeAv5RBcBFPDsEWMq/H3vmOttlIbhFzKt8v5SBL/hquW85QBL+Xvmuk3+W/H2CfyuDccvBIrKxsP859jb0LNqvy1RweK/gYwMCiZDVKMsDdlLCr2m4vEWBD+bTTcFFCu8XfI0Dr53XjbL9yeRh/dNgo0+yo+10s1LcJW+O/ryo05IQ8ricZYt5pGg4Wr6bxo6/taP5YTprKh624AmYavn+urVgfC6F9KpSef7JYTtQ7jcInLYFyhcP8sMkW27KwudCcA/I+4f+Tgnn+a5CKCT3SVWs6ros63q1qgg9/do7vY3+L6H/0a4dqgAAg1AULYPBsjax+P//uA3TwuJAxj3RJiYf7xJ5rBVVLNzHcA8T7fkZl6iePpchSDvs8b9XBwAAAAAAqGQCc31B4/xqSwwAAAAASUVORK5CYII="},(function(){su.world.addChild(new xc(Yc.getWidth()/2,Yc.getHeight()/2,{image:"melonjs_logo",framewidth:256,frameheight:256}),2)}))},e.prototype.onDestroyEvent=function(){mc.unload({name:"melonjs_logo",type:"image"})},e}(du),gu=-1,vu=-1,mu=!1,xu={},_u={color:"",duration:0},bu=null,wu=null,Tu=0;function Au(){-1===vu&&-1!==gu&&(vu=globalThis.requestAnimationFrame(Eu))}function Eu(t){var e=xu[gu].stage;su.update(t,e),su.draw(e),-1!==vu&&(vu=globalThis.requestAnimationFrame(Eu))}function Su(){globalThis.cancelAnimationFrame(vu),vu=-1}function Cu(t){Su(),xu[gu]&&xu[gu].stage.destroy(),xu[t]&&(xu[gu=t].stage.reset.apply(xu[gu].stage,wu),Au(),ts(Er),bu&&bu(),su.repaint())}es(_r,(function(){Mu.set(Mu.LOADING,new yu),Mu.set(Mu.DEFAULT,new du),es(Sr,(function(){Mu.change(Mu.DEFAULT,!0)})),"function"==typeof globalThis.addEventListener&&(globalThis.addEventListener("blur",(function(){Mu.pause(!0)}),!1),globalThis.addEventListener("focus",(function(){Mu.resume(!0),fa()}),!1)),void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener&&globalThis.document.addEventListener("visibilitychange",(function(){"visible"===globalThis.document.visibilityState?Mu.resume(!0):Mu.pause(!0)}),!1)}));var Mu={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),gu!==this.LOADING&&this.isRunning()&&(Su(),!0===t&&t(),Tu=globalThis.performance.now(),ts(Tr))},pause:function(t){void 0===t&&(t=!1),gu===this.LOADING||this.isPaused()||(mu=!0,!0===t&&gh(),Tu=globalThis.performance.now(),ts(br))},restart:function(t){void 0===t&&(t=!1),this.isRunning()||(Au(),!0===t&&vh(),Tu=globalThis.performance.now()-Tu,su.repaint(),ts(Ar,Tu))},resume:function(t){void 0===t&&(t=!1),this.isPaused()&&(mu&&-1!==gu&&(mu=!1),!0===t&&vh(),Tu=globalThis.performance.now()-Tu,ts(wr,Tu))},isRunning:function(){return-1!==vu},isPaused:function(){return mu},set:function(t,e,i){if(void 0===i&&(i=!1),!(e instanceof du))throw new Error(e+" is not an instance of me.Stage");xu[t]={},xu[t].stage=e,xu[t].transition=!0,!0===i&&this.change(t)},get:function(t){return void 0===t&&(t=gu),void 0!==xu[t]?xu[t].stage:void 0},current:function(){return this.get()},transition:function(t,e,i){"fade"===t&&(_u.color=e,_u.duration=i)},setTransition:function(t,e){xu[t].transition=e},change:function(t,e){if(void 0===xu[t])throw new Error("Undefined Stage for state '"+t+"'");this.isCurrent(t)||(wu=null,arguments.length>1&&(wu=Array.prototype.slice.call(arguments,1)),_u.duration&&xu[t].transition?(bu=function(){su.viewport.fadeOut(_u.color,_u.duration)},su.viewport.fadeIn(_u.color,_u.duration,(function(){Qn(Cu,this,t)}))):!0===e?Cu(t):Qn(Cu,this,t))},isCurrent:function(t){return gu===t}};function Pu(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||wn(i))i=!i||"true"===i;else if(bn(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 Ou(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 Iu(t,e){var i=e.nodeName;switch(i){case"data":var o=ku(e);o.text=o.text||o.chunk.text,o.encoding=o.encoding||"xml",t.data=Ou(o.text,o.encoding,o.compression),t.encoding="none";break;case"imagelayer":case"layer":case"objectgroup":case"group":var n=ku(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=ku(e).frames;break;case"frame":case"object":var r=i+"s";t[r]=t[r]||[],t[r].push(ku(e));break;case"tile":var s=ku(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=ku(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=ku(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=ku(e);break;case"property":var c=ku(e),p=void 0!==c.value?c.value:c.text;t[c.name]=Pu(c.name,c.type||"string",p);break;default:t[i]=ku(e)}}function ku(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:Iu(e,n);break;case 3:i+=n.nodeValue.trim()}}return i&&(e.text=i),e}function Ru(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]=Pu(s,r,a)}}var Bu=536870911,Du=function(t){function e(e,i,o,n){var r,s;if(t.call(this),n.isCollection){var a=n.getTileImage(o&Bu);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 yr),this.setTileTransform(this.currentTransform.identity())),this.tileId&=Bu}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 xc(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}(ih),Lu=function(t){function e(e){var i=this;t.call(this,e),this.context=this.getContext2d(this.getCanvas(),this.settings.transparent),this.setBlendMode(this.settings.blendMode),this.setColor(this.currentColor),this.cache=new zc,!1===this.settings.textureSeamFix||this.settings.antiAlias||(this.uvOffset=1),this.getCanvas().addEventListener("contextlost",(function(t){t.preventDefault(),i.isContextValid=!1,ts(Jr,i)}),!1),this.getCanvas().addEventListener("contextrestored",(function(){i.isContextValid=!0,ts($r,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.getContext().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"}},e.prototype.clear=function(){if(!1===this.settings.transparent){var t=this.getCanvas();this.getContext().clearRect(0,0,t.width,t.height)}},e.prototype.clearColor=function(t,e){void 0===t&&(t="#000000"),void 0===e&&(e=!1);var i=this.getCanvas(),o=this.getContext();this.save(),this.resetTransform(),o.globalAlpha=1,o.globalCompositeOperation=!0===e?"copy":"source-over",o.fillStyle=t instanceof cr?t.toRGBA():t,this.fillRect(0,0,i.width,i.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.strokePoint=function(t,e){this.strokeLine(t,e,t+1,e+1)},e.prototype.fillPoint=function(t,e){this.strokePoint(t,e)},e.prototype.getFontContext=function(){return this.getContext()},e.prototype.save=function(){this.getContext().save()},e.prototype.restore=function(){this.getContext().restore(),this.currentColor.glArray[3]=this.getGlobalAlpha(),this.currentScissor[0]=0,this.currentScissor[1]=0,this.currentScissor[2]=this.getCanvas().width,this.currentScissor[3]=this.getCanvas().height},e.prototype.rotate=function(t){this.getContext().rotate(t)},e.prototype.scale=function(t,e){this.getContext().scale(t,e)},e.prototype.setColor=function(t){var e=this.getContext();e.strokeStyle=e.fillStyle=t instanceof cr?t.toRGBA():t},e.prototype.setGlobalAlpha=function(t){this.getContext().globalAlpha=this.currentColor.glArray[3]=t},e.prototype.getGlobalAlpha=function(){return this.getContext().globalAlpha},e.prototype.setLineWidth=function(t){this.getContext().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.getContext().transform(i,o,n,r,s,a)},e.prototype.translate=function(t,e){!1===this.settings.subPixel?this.getContext().translate(~~t,~~e):this.getContext().translate(t,e)},e.prototype.clipRect=function(t,e,i,o){var n=this.getCanvas();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.getContext();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()),t instanceof $a)i.roundRect(t.top,t.left,t.width,t.height,t.radius);else if(t instanceof Ja||t instanceof ih)i.rect(t.top,t.left,t.width,t.height);else if(t instanceof th){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,x=t.pos.y;i.moveTo(m+t.points[0].x,x+t.points[0].y);for(var _=1;_<t.points.length;_++)v=t.points[_],i.lineTo(m+v.x,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}(sh);function zu(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 Fu=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.class=i.class,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),Ru(this,i),void 0===this.preRender&&(this.preRender=su.world.preRender),this.setRenderer(e.getRenderer()),zu(this,Ou(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 Lu({canvas:Wc(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 Du&&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,er.pull("Vector2d"));i=this.cellAt(o.x,o.y),er.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 Du(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}(Dl),ju=function(t,e,i,o){this.cols=t,this.rows=e,this.tilewidth=i,this.tileheight=o,this.bounds=new ih};ju.prototype.canRender=function(t){return this.tilewidth===t.tilewidth&&this.tileheight===t.tileheight},ju.prototype.getBounds=function(t){var e=t instanceof Fu?er.pull("Bounds"):this.bounds;return e.setMinMax(0,0,this.cols*this.tilewidth,this.rows*this.tileheight),e},ju.prototype.pixelToTileCoords=function(t,e,i){return i},ju.prototype.tileToPixelCoords=function(t,e,i){return i},ju.prototype.drawTile=function(t,e,i,o){},ju.prototype.drawTileLayer=function(t,e,i){};var Vu=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 ir).set(t/this.tilewidth,e/this.tileheight)},e.prototype.tileToPixelCoords=function(t,e,i){return(i||new ir).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),er.pull("Vector2d")).floorSelf(),s=this.pixelToTileCoords(i.pos.x+i.width+this.tilewidth,i.pos.y+i.height+this.tileheight,er.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)}er.push(r),er.push(s)},e}(ju),Uu=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 Fu?er.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 ir).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 ir).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=er.pull("Vector2d");this.tileToPixelCoords(e,i,o),t.x=o.x,t.y=o.y,er.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,er.pull("Vector2d")).floorSelf(),r=this.pixelToTileCoords(i.pos.x+i.width+o.tilewidth,i.pos.y+i.height+o.tileheight,er.pull("Vector2d")).ceilSelf(),s=this.tileToPixelCoords(r.x,r.y,er.pull("Vector2d")),a=this.tileToPixelCoords(n.x,n.y,er.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)}er.push(c),er.push(n),er.push(r),er.push(s),er.push(a)},e}(ju),Nu=[{x:0,y:0},{x:1,y:-1},{x:1,y:0},{x:2,y:0}],Gu=[{x:0,y:0},{x:-1,y:1},{x:0,y:1},{x:0,y:2}],Xu=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 ir,new ir,new ir,new ir]}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 Fu?er.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 ir;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 ir;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 ir;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 ir;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 ir;this.staggerX?t-=this.staggerEven?this.tilewidth:this.sideoffsetx:e-=this.staggerEven?this.tileheight:this.sideoffsety;var n,r,s,a,h=er.pull("Vector2d",Math.floor(t/(2*this.columnwidth)),Math.floor(e/(2*this.rowheight))),l=er.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?Nu:Gu;return o.set(h.x+f[u].x,h.y+f[u].y),er.push(h),er.push(l),o},e.prototype.tileToPixelCoords=function(t,e,i){var o=Math.floor(t),n=Math.floor(e),r=i||new ir;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,er.pull("Vector2d"));n.drawTile(t,n.tileoffset.x+r.x,n.tileoffset.y+r.y+(this.tileheight-n.tileheight),o),er.push(r)},e.prototype.drawTileLayer=function(t,e,i){var o,n=this.pixelToTileCoords(i.pos.x,i.pos.y,er.pull("Vector2d"));n.sub(e.pos);var r=this.tileToPixelCoords(n.x+e.pos.x,n.y+e.pos.y,er.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}er.push(s),er.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}er.push(s),er.push(a)}er.push(n),er.push(r)},e}(ju),Hu=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 ir,n=t,r=e;this.staggerX?n-=this.staggerEven?this.sideoffsetx:0:r-=this.staggerEven?this.sideoffsety:0;var s=er.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=er.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(zn(-45)).add(s),er.push(s),er.push(a),o},e}(Xu),Yu=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=Kn(i);if(("tsx"===o||"json"===o)&&!(t=mc.getTMX(qn(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 ir,this.isAnimated=!1,this.isCollection=!1,this.class=t.class,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=mc.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=mc.getImage(t.image),!this.image)throw new Error("melonJS: '"+t.image+"' file for tileset '"+this.name+"' not found!");this.texture=Yc.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+")")}};Yu.prototype.getTileImage=function(t){return this.imageCollection[t]},Yu.prototype.setTileProperty=function(t,e){this.TileProperties[t]=e},Yu.prototype.contains=function(t){return t>=this.firstgid&&t<=this.lastgid},Yu.prototype.getViewTileId=function(t){var e=t-this.firstgid;return this.animations.has(e)?this.animations.get(e).cur.tileid:e},Yu.prototype.getTileProperties=function(t){return this.TileProperties[t]},Yu.prototype.update=function(t){var e=0,i=ip.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},Yu.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 Wu=function(){this.tilesets=[],this.length=0};Wu.prototype.add=function(t){this.tilesets.push(t),this.length++},Wu.prototype.getTilesetByIndex=function(t){return this.tilesets[t]},Wu.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 qu=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.class=void 0!==e.class?e.class:e.type,this.text=void 0,this.rotation=zn(+e.rotation||0),this.id=+e.id||void 0,this.orientation=t.orientation,this.shapes=void 0,this.isEllipse=!1,this.isPoint=!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.point?this.isPoint=!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,Ru(this.text,e)):(Ru(this,e),this.shapes||(this.shapes=this.parseTMXShapes())),t.isEditor||t.getRenderer().adjustPosition(this)};qu.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 Du(this.x,this.y,this.gid,e)},qu.prototype.parseTMXShapes=function(){var t=0,e=[];if(!0===this.isEllipse)e.push(er.pull("Ellipse",this.width/2,this.height/2,this.width,this.height).rotate(this.rotation));else if(!0===this.isPoint)e.push(er.pull("Point",this.x,this.y));else if(!0===this.isPolygon){var i=er.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=er.pull("Vector2d",r[t].x,r[t].y),n=er.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(er.pull("Line",0,0,[o,n]))}else e.push(er.pull("Polygon",0,0,[er.pull("Vector2d"),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height),er.pull("Vector2d",0,this.height)]).rotate(this.rotation));if("isometric"===this.orientation)for(t=0;t<e.length;t++)"function"==typeof e[t].toIso&&e[t].toIso();return e},qu.prototype.getObjectPropertyByName=function(t){return this[t]};var Ku=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.class=e.class,this.z=i,this.objects=[];var n=void 0===e.visible||e.visible;this.opacity=!0===n?Fn(+e.opacity||1,0,1):0,Ru(this,e),e.objects&&e.objects.forEach((function(e){e.tintcolor=o.tintcolor,o.objects.push(new qu(t,e,i))})),e.layers&&e.layers.forEach((function(e){var n=new Fu(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)}))};Ku.prototype.destroy=function(){this.objects=null},Ku.prototype.getObjectCount=function(){return this.objects.length},Ku.prototype.getObjectByIndex=function(t){return this.objects[t]};function Zu(t,e,i){return new Ku(t,e,i)}var Qu=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.class=e.class,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,Ru(this,e),this.initialized=!1,1===this.infinite)throw new Error("Tiled Infinite Map not supported!")};Qu.prototype.getRenderer=function(){return void 0!==this.renderer&&this.renderer.canRender(this)||(this.renderer=function(t){switch(t.orientation){case"orthogonal":return new Vu(t);case"isometric":return new Uu(t);case"hexagonal":return new Xu(t);case"staggered":return new Hu(t);default:throw new Error(t.orientation+" type TMX Tile Map not supported!")}}(this)),this.renderer},Qu.prototype.getBounds=function(){return this.bounds},Qu.prototype.readMapObjects=function(t){var e=this;if(!0!==this.initialized){var i=0;if(this.tilesets||(this.tilesets=new Wu),void 0!==t.tilesets)t.tilesets.forEach((function(t){e.tilesets.add(function(t){return new Yu(t)}(t))}));this.background_image&&this.layers.push(er.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){Ru(e.properties,e);var o=er.pull("ImageLayer",+e.offsetx||+e.x||0,+e.offsety||+e.y||0,Object.assign({name:e.name,image:e.image,ratio:er.pull("Vector2d",+e.parallaxx||1,+e.parallaxy||1),tint:void 0!==e.tintcolor?er.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 Fu(t,e,t.tilewidth,t.tileheight,t.orientation,t.tilesets,i)}(e,t,i++));break;case"objectgroup":case"group":e.objectGroups.push(Zu(e,t,i++))}})),this.initialized=!0}},Qu.prototype.addTo=function(t,e,i){var o=t.autoSort,n=t.autoDepth,r=this.getBounds();function s(e,i){su.viewport.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&&(os(qr,s),s(su.viewport.width,su.viewport.height),es(qr,s,this)),t.autoSort=o,t.autoDepth=n},Qu.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 $l(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=er.pull("Color"),l.tint.parseHex(l.tintcolor,!0)),l instanceof Fu?a=l:"object"==typeof l.text?(void 0===l.text.anchorPoint&&(l.text.anchorPoint=l.anchorPoint),(a=!0===l.text.bitmap?er.pull("BitmapText",l.x,l.y,l.text):er.pull("Text",l.x,l.y,l.text)).pos.z=l.z):"object"==typeof l.tile?(void 0===(h=l.shapes)&&(h=er.pull("Polygon",0,0,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height)])),(a=l.tile.getRenderable(l)).body=new Zl(a,h),a.body.setStatic(!0),a.pos.setMuted(l.x,l.y,l.z)):(void 0!==l.name&&""!==l.name?a=er.pull(l.name,l.x,l.y,l):(a=er.pull("Renderable",l.x,l.y,l.width,l.height),void 0===(h=l.shapes)&&(h=er.pull("Polygon",0,0,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height)])),a.anchorPoint.set(0,0),a.name=l.name,a.type=l.type,a.class=l.class||l.type,a.id=l.id,a.body=new Zl(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=Kl.types.WORLD_SHAPE,a.body.isStatic=!0),!1!==t?(!0===a.isRenderable&&(a.setOpacity(a.getOpacity()*r.opacity),a.renderable instanceof Dl&&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},Qu.prototype.getLayers=function(){return this.readMapObjects(this.data),this.layers},Qu.prototype.destroy=function(){this.tilesets=void 0,this.layers.length=0,this.objectGroups.length=0,this.initialized=!1};var Ju={},$u=[],tc=0;function ec(t,e,i){e.container.reset(),su.reset(),Ju[ic.getCurrentLevelId()]&&Ju[ic.getCurrentLevelId()].destroy(),tc=$u.indexOf(t),function(t,e,i,o){var n=Ju[t];$c.resetGUID(t,n.nextobjectid),e.anchorPoint.set(0,0),n.addTo(e,i,o)}(t,e.container,e.flatten,e.setViewportBounds),ts(Br,t),e.onLoaded(t),i&&Mu.restart()}var ic={add:function(t,e,i){if("tmx"===t)return null==Ju[e]&&(Ju[e]=new Qu(e,mc.getTMX(e)),$u.push(e),i&&i(),!0);throw new Error("no level loader defined for format "+t)},load:function(t,e){if(e=Object.assign({container:su.world,onLoaded:su.onLevelLoaded,flatten:su.mergeGroup,setViewportBounds:!0},e||{}),void 0===Ju[t])throw new Error("level "+t+" not found");if(!(Ju[t]instanceof Qu))throw new Error("no level loader defined");return Mu.isRunning()?(Mu.stop(),$c.function.defer(ec,this,t,e,!0)):ec(t,e),!0},getCurrentLevelId:function(){return $u[tc]},getCurrentLevel:function(){return Ju[this.getCurrentLevelId()]},reload:function(t){return this.load(this.getCurrentLevelId(),t)},next:function(t){return tc+1<$u.length&&this.load($u[tc+1],t)},previous:function(t){return tc-1>=0&&this.load($u[tc-1],t)},levelCount:function(){return $u.length}},oc={},nc={},rc={},sc={},ac={},hc=0,lc=0,uc=0;function cc(t){if(lc===hc){if("function"!=typeof t&&!mc.onload)throw new Error("no load callback defined");clearTimeout(uc);var e=t||mc.onload;setTimeout((function(){e(),ts(Dr)}),300)}else uc=setTimeout((function(){cc(t)}),100)}function pc(t,e,i){oc[t.name]=new Image,"function"==typeof e&&(oc[t.name].onload=e),"function"==typeof i&&(oc[t.name].onerror=i),"string"==typeof mc.crossOrigin&&(oc[t.name].crossOrigin=mc.crossOrigin),oc[t.name].src=t.src+mc.nocache}function dc(t,e,i){!0===An(t.src)&&(t.src.startsWith("url(")||(t.src="url("+t.src+")"));var o=new FontFace(t.name,t.src);o.load().then((function(){document.fonts.add(o),document.body.style.fontFamily=t.name,"function"==typeof e&&e()}),(function(){"function"==typeof i&&i(t.name)}))}function fc(t,e,i){function o(e){nc[t.name]=e,"tmx"===t.type&&ic.add(t.type,t.name)}if(t.data)return o(t.data),void("function"==typeof e&&e());var n=new XMLHttpRequest,r=Kn(t.src);n.overrideMimeType&&("json"===r?n.overrideMimeType("application/json"):n.overrideMimeType("text/xml")),n.open("GET",t.src+mc.nocache,!0),n.withCredentials=mc.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(ps.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=ku(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),"function"==typeof e&&e()}else"function"==typeof i&&i(t.name)},n.send()}function yc(t,e,i){var o=new XMLHttpRequest;o.overrideMimeType&&o.overrideMimeType("application/json"),o.open("GET",t.src+mc.nocache,!0),o.withCredentials=mc.withCredentials,o.ontimeout=i,o.onreadystatechange=function(){4===o.readyState&&(200===o.status||0===o.status&&o.responseText?(sc[t.name]=JSON.parse(o.responseText),"function"==typeof e&&e()):"function"==typeof i&&i(t.name))},o.send()}function gc(t,e,i){var o=new XMLHttpRequest;o.open("GET",t.src+mc.nocache,!0),o.withCredentials=mc.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]);rc[t.name]=r.join(""),"function"==typeof e&&e()}},o.send()}function vc(t,e,i){var o=document.createElement("script");o.src=t.src,o.type="text/javascript","string"==typeof mc.crossOrigin&&(o.crossOrigin=mc.crossOrigin),o.defer=!0,"function"==typeof e&&(o.onload=function(){e()}),"function"==typeof i&&(o.onerror=function(){i(t.name)}),document.getElementsByTagName("body")[0].appendChild(o)}var mc={nocache:"",onload:void 0,onProgress:void 0,crossOrigin:void 0,withCredentials:!1,onResourceLoaded:function(t){var e=++lc/hc;this.onProgress&&this.onProgress(e,t),ts(Lr,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?ac[t]=e:(ac.audio=e,ac.binary=e,ac.image=e,ac.json=e,ac.js=e,ac.tmx=e,ac.tsx=e)},preload:function(t,e,i){void 0===i&&(i=!0);for(var o=0;o<t.length;o++)hc+=this.load(t[o],this.onResourceLoaded.bind(this,t[o]),this.onLoadingError.bind(this,t[o]));void 0!==e&&(this.onload=e),!0===i&&Mu.change(Mu.LOADING),cc(e)},load:function(t,e,i){switch(void 0!==ac[t.type]&&(t.src=ac[t.type]+t.src),t.type){case"binary":return gc.call(this,t,e,i),1;case"image":return pc.call(this,t,e,i),1;case"json":return yc.call(this,t,e,i),1;case"js":return vc.call(this,t,e,i),1;case"tmx":case"tsx":return fc.call(this,t,e,i),1;case"audio":return fh(t,!!t.stream,e,i),1;case"fontface":return dc.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 rc&&(delete rc[t.name],!0);case"image":return t.name in oc&&(delete oc[t.name],!0);case"json":return t.name in sc&&(delete sc[t.name],!0);case"js":case"fontface":return!0;case"tmx":case"tsx":return t.name in nc&&(delete nc[t.name],!0);case"audio":return bh(t.name);default:throw new Error("unload : unknown or invalid resource type : "+t.type)}},unloadAll:function(){var t;for(t in rc)rc.hasOwnProperty(t)&&this.unload({name:t,type:"binary"});for(t in oc)oc.hasOwnProperty(t)&&this.unload({name:t,type:"image"});for(t in nc)nc.hasOwnProperty(t)&&this.unload({name:t,type:"tmx"});for(t in sc)sc.hasOwnProperty(t)&&this.unload({name:t,type:"json"});wh()},getTMX:function(t){return(t=""+t)in nc?nc[t]:null},getBinary:function(t){return(t=""+t)in rc?rc[t]:null},getImage:function(t){return(t=qn(""+t))in oc?oc[t]:null},getJSON:function(t){return(t=""+t)in sc?sc[t]:null}},xc=function(t){function e(e,i,o){if(t.call(this,e,i,0,0),this.animationpause=!1,this.animationspeed=100,this.offset=er.pull("Vector2d",0,0),this.source=null,this.anim={},this.resetAnim=void 0,this.current={name:"default",length:0,offset:er.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 bc){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:mc.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=Yc.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&&(o.tint instanceof cr?this.tint.copy(o.tint):this.tint.parseCSS(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(){er.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}(Dl);function _c(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}}]}}var bc=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=mc.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?mc.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?mc.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?mc.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?mc.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 zc?i.set(t,o):Yc.cache.set(t,o)}))};bc.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 ir(s.x,s.y),anchorPoint:a?new ir(n/s.w,r/s.h):null,trimmed:!!o.trimmed,width:s.w,height:s.h,angle:!0===o.rotated?-Rn:0},e.addUVs(i,o.filename,t.meta.size.w,t.meta.size.h)}})),i},bc.prototype.parseFromSpriteSheet=function(t){var e={},i=t.image,o=t.spacing||0,n=t.margin||0,r=i.width,s=i.height,a=er.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 ir(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 er.push(a),e},bc.prototype.getAtlas=function(t){return"string"==typeof t?this.atlases.get(t):this.atlases.values().next().value},bc.prototype.getFormat=function(){return this.format},bc.prototype.getTexture=function(t){return"object"==typeof t&&"string"==typeof t.texture?this.sources.get(t.texture):this.sources.values().next().value},bc.prototype.addRegion=function(t,e,i,o,n){!0===Yc.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 ir(e,i),width:o,height:n,angle:0},this.addUVs(s,t,a,h),s[t]},bc.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},bc.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},bc.prototype.addUVs=function(t,e,i,o){if(Yc instanceof Fc){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},bc.prototype.createSpriteFromName=function(t,e,i){return void 0===i&&(i=!1),er.pull(!0===i?"me.NineSliceSprite":"me.Sprite",0,0,Object.assign({image:this,region:t},e||{}))},bc.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 xc(0,0,Object.assign({image:this,framewidth:r,frameheight:s,margin:0,spacing:0,atlas:o,atlasIndices:n},e||{}))};var wc={},Tc={},Ac={},Ec=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])}}},Sc=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.")},Cc=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(Ac,"__esModule",{value:!0}),Ac.Multimap=void 0;var Mc=function(){function t(t,e){var i,o;if(this.size_=0,this.map=new Map,this.operator=t,e)try{for(var n=Sc(e),r=n.next();!r.done;r=n.next()){var s=Cc(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=Sc(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=Sc(e.entries()),f=d.next();!f.done;f=d.next()){var y=Cc(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 Ec(this,(function(y){switch(y.label){case 0:y.trys.push([0,11,12,13]),e=Sc(t.map.entries()),i=e.next(),y.label=1;case 1:if(i.done)return[3,10];o=Cc(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=Sc(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 Ec(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=Sc(t.entries()),i=e.next(),a.label=1;case 1:return i.done?[3,4]:(o=Cc(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=Sc(this.entries()),r=n.next();!r.done;r=n.next()){var s=Cc(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=Sc(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}();Ac.Multimap=Mc;var Pc,Oc=e&&e.__extends||(Pc=function(t,e){return Pc=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])},Pc(t,e)},function(t,e){function i(){this.constructor=t}Pc(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(Tc,"__esModule",{value:!0}),Tc.ArrayMultimap=void 0;var Ic=function(t){function e(e){return t.call(this,new kc,e)||this}return Oc(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"ArrayMultimap"},enumerable:!1,configurable:!0}),e}(Ac.Multimap);Tc.ArrayMultimap=Ic;var kc=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}(),Rc={},Bc=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(Rc,"__esModule",{value:!0}),Rc.SetMultimap=void 0;var Dc=function(t){function e(e){return t.call(this,new Lc,e)||this}return Bc(e,t),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"SetMultimap"},enumerable:!1,configurable:!0}),e}(Ac.Multimap);Rc.SetMultimap=Dc;var Lc=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=Tc;Object.defineProperty(t,"ArrayMultimap",{enumerable:!0,get:function(){return e.ArrayMultimap}});var i=Rc;Object.defineProperty(t,"SetMultimap",{enumerable:!0,get:function(){return i.SetMultimap}})}(wc);var zc=function(t){this.cache=new wc.ArrayMultimap,this.tinted=new Map,this.units=new Map,this.max_size=t||1/0,this.clear()};zc.prototype.clear=function(){this.cache.clear(),this.tinted.clear(),this.units.clear(),this.length=0},zc.prototype.validate=function(){if(this.length>=this.max_size)throw new Error("Texture cache overflow: "+this.max_size+" texture units available for this GPU.")},zc.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=_c(t.width,t.height,t.src?qn(t.src):void 0)),i=new bc(e,t,!1),this.set(t,i)),i},zc.prototype.delete=function(t){this.cache.has(t)||this.cache.delete(t)},zc.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,Yc.tint(t,e,"multiply")),i.get(e)},zc.prototype.set=function(t,e){var i=t.width,o=t.height;if(!(1!==Yc.WebGLVersion||Dn(i)&&Dn(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)},zc.prototype.getUnit=function(t){return this.units.has(t)||(this.validate(),this.units.set(t,this.length++)),this.units.get(t)};var Fc=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.getCanvas(),e.transparent),this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this._colorStack=[],this._matrixStack=[],this._scissorStack=[],this._blendStack=[],this.currentTransform=new yr,this.currentCompositor=null,this.compositors=new Map;var o=new(this.settings.compositor||Ta)(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 zc(this.maxTextures),this.getCanvas().addEventListener("webglcontextlost",(function(t){t.preventDefault(),i.isContextValid=!1,ts(Jr,i)}),!1),this.getCanvas().addEventListener("webglcontextrestored",(function(){i.reset(),i.isContextValid=!0,ts($r,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.getCanvas(),i=e.width,o=e.height;1===this.WebGLVersion&&(Dn(i)||(i=Ln(e.width)),Dn(o)||(o=Ln(e.height)));var n=Wc(i,o,!0);this.fontContext2D=this.getContext2d(n),this.fontTexture=new bc(_c(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!==Yc.WebGLVersion||Dn(t.width)&&Dn(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 bc(_c(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.clear=function(){this.currentCompositor.clear(this.settings.transparent?0:1)},e.prototype.clearColor=function(t,e){var i;if(void 0===t&&(t="#000000"),void 0===e&&(e=!1),t instanceof cr)i=t.toArray();else{var o=er.pull("me.Color");i=o.parseCSS(t).toArray(),er.push(o)}this.currentCompositor.clearColor(i[0],i[1],i[2],!0===e?1:i[3])},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(this.getGlobalAlpha())),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(this.getGlobalAlpha()))},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(this.getGlobalAlpha()))},e.prototype.getContextGL=function(t,e){if(void 0===e&&(e=!1),null==t)throw new Error("You must pass a canvas element in order to create a GL context");var i,o={alpha:e,antialias:this.settings.antiAlias,depth:!1,stencil:!0,preserveDrawingBuffer:!1,premultipliedAlpha:!!e&&this.settings.premultipliedAlpha,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()),er.push(t),er.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.getCanvas().width,this.currentScissor[3]=this.getCanvas().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.getContext().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.strokePoint=function(t,e){this.strokeLine(t,e,t+1,e+1)},e.prototype.fillPoint=function(t,e){this.strokePoint(t,e)},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.getCanvas(),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}(sh),jc=1,Vc=0,Uc=0,Nc={parent:void 0,renderer:2,autoScale:!1,scale:1,scaleMethod:"manual",transparent:!1,premultipliedAlpha:!0,blendMode:"normal",antiAlias:!1,failIfMajorPerformanceCaveat:!0,subPixel:!1,preferWebGL1:!1,powerPreference:"default",verbose:!1,consoleHeader:!0};function Gc(){var t=Yc.settings,e=1,i=1;if(t.autoScale){var o=1/0,n=1/0;if(globalThis.getComputedStyle){var r=globalThis.getComputedStyle(Yc.getCanvas(),null);o=parseInt(r.maxWidth,10)||1/0,n=parseInt(r.maxHeight,10)||1/0}var s=ca(qc()),a=Math.min(o,s.width),h=Math.min(n,s.height),l=a/h;if("fill-min"===t.scaleMethod&&l>jc||"fill-max"===t.scaleMethod&&l<jc||"flex-width"===t.scaleMethod){var u=Math.min(o,Uc*l);e=i=a/u,Yc.resize(Math.floor(u),Uc)}else if("fill-min"===t.scaleMethod&&l<jc||"fill-max"===t.scaleMethod&&l>jc||"flex-height"===t.scaleMethod){var c=Math.min(n,Vc*(h/a));e=i=h/c,Yc.resize(Vc,Math.floor(c))}else"flex"===t.scaleMethod?Yc.resize(Math.floor(a),Math.floor(h)):"stretch"===t.scaleMethod?(e=a/Vc,i=h/Uc):e=i=l<jc?a/Vc:h/Uc;Kc(e,i)}else Kc(t.scale,t.scale)}var Xc=null,Hc=new ir(1,1),Yc=null;function Wc(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===Ws&&!0===i?void 0===(o=new globalThis.OffscreenCanvas(0,0)).style&&(o.style={}):o=document.createElement("canvas"),o.width=t,o.height=e,o}function qc(){return Xc}function Kc(t,e){var i=Yc.getCanvas(),o=Yc.getContext(),n=Yc.settings,r=Zs,s=n.zoomX=i.width*t*r,a=n.zoomY=i.height*e*r;Hc.set(t*r,e*r),i.style.width=s/r+"px",i.style.height=a/r+"px",Yc.setAntiAlias(o,n.antiAlias),Yc.setBlendMode(n.blendMode,o),su.repaint()}var Zc=Object.freeze({__proto__:null,CANVAS:0,WEBGL:1,AUTO:2,get parent(){return Xc},scaleRatio:Hc,get renderer(){return Yc},init:function(e,i,o){if(!t.initialized)throw new Error("me.video.init() called before engine initialization.");(Nc=Object.assign(Nc,o||{})).width=e,Nc.height=i,Nc.transparent=!!Nc.transparent,Nc.antiAlias=!!Nc.antiAlias,Nc.failIfMajorPerformanceCaveat=!!Nc.failIfMajorPerformanceCaveat,Nc.subPixel=!!Nc.subPixel,Nc.verbose=!!Nc.verbose,-1!==Nc.scaleMethod.search(/^(fill-(min|max)|fit|flex(-(width|height))?|stretch)$/)?Nc.autoScale="auto"===Nc.scale||!0:(Nc.scaleMethod="fit",Nc.autoScale="auto"===Nc.scale||!1),!1!==Nc.consoleHeader&&console.log("melonJS 2 (v"+Xp+") | http://melonjs.org");var n=$c.getUriFragment();!0===n.webgl||!0===n.webgl1||!0===n.webgl2?(Nc.renderer=1,!0===n.webgl1&&(Nc.preferWebGL1=!0)):!0===n.canvas&&(Nc.renderer=0),Nc.scale=Nc.autoScale?1:+Nc.scale||1,Hc.set(Nc.scale,Nc.scale),jc=e/i,Vc=e,Uc=i,Nc.zoomX=e*Hc.x,Nc.zoomY=i*Hc.y,globalThis.addEventListener("resize",$c.function.throttle((function(t){ts(Yr,t)}),100),!1),globalThis.addEventListener("orientationchange",(function(t){ts(Kr,t)}),!1),globalThis.addEventListener("onmozorientationchange",(function(t){ts(Kr,t)}),!1),!0===Vs&&(globalThis.screen.orientation.onchange=function(t){ts(Kr,t)}),globalThis.addEventListener("scroll",$c.function.throttle((function(t){ts(Zr,t)}),100),!1),es(Yr,Gc,this),es(Kr,Gc,this);try{switch(Nc.renderer){case 2:case 1:Yc=function(t){try{if(pa(t))return new Fc(t)}catch(t){console.log("Error creating WebGL renderer :"+t.message)}return new Lu(t)}(Nc);break;default:Yc=new Lu(Nc)}}catch(t){return console(t.message),!1}if((Xc=la(void 0!==Nc.parent?Nc.parent:document.body)).appendChild(Yc.getCanvas()),ks.isMobile&&ra(!1),Gc(),"MutationObserver"in globalThis&&new MutationObserver(Gc.bind(this)).observe(Xc,{attributes:!1,childList:!0,subtree:!0}),!1!==Nc.consoleHeader){var r=Yc instanceof Lu?"CANVAS":"WebGL"+Yc.WebGLVersion,s=Gs?"Web Audio":"HTML5 Audio",a="string"==typeof Yc.GPURenderer?" ("+Yc.GPURenderer+")":"";console.log(r+" renderer"+a+" | "+s+" | pixel ratio "+Zs+" | "+(ks.nodeJS?"node.js":ks.isMobile?"mobile":"desktop")+" | "+aa()+" | "+Ks),console.log("resolution: requested "+e+"x"+i+", got "+Yc.getWidth()+"x"+Yc.getHeight())}return ts(Sr),!0},createCanvas:Wc,getParent:qc,scale:Kc}),Qc="",Jc=0,$c={agent:Pn,array:Hn,file:Zn,string:En,function:$n,getPixels:function(t){if(t instanceof HTMLImageElement){var e=Lu.getContext2d(Wc(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=Xp);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),Qc=Tn(t.toString().toUpperCase()),Jc=e},createGUID:function(t){return void 0===t&&(t=1),Jc+=t,Qc+"-"+(t||Jc)}},tp=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,es(_r,(function(){t.reset(),t.now=t.last=0,es(Pr,t.update.bind(t))})),es(wr,(function(){t.reset()})),es(Ar,(function(){t.reset()})),es(Er,(function(){t.reset()}))};tp.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},tp.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},tp.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},tp.prototype.clearTimeout=function(t){$c.function.defer(this.clearTimer.bind(this),this,t)},tp.prototype.clearInterval=function(t){$c.function.defer(this.clearTimer.bind(this),this,t)},tp.prototype.getTime=function(){return this.now},tp.prototype.getDelta=function(){return this.delta},tp.prototype.countFPS=function(){this.framecount++,this.framedelta+=this.delta,this.framecount%10==0&&(this.fps=Fn(Math.round(1e3*this.framecount/this.framedelta),0,this.maxfps),this.framedelta=0,this.framecount=0)},tp.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()},tp.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}},tp.prototype.updateTimers=function(){for(var t=0,e=this.timers.length;t<e;t++){var i=this.timers[t];i.pauseable&&Mu.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 ep,ip=new tp,op=0,np=["ms","moz","webkit","o"],rp=globalThis.requestAnimationFrame,sp=globalThis.cancelAnimationFrame;for(ep=0;ep<np.length&&!rp;++ep)rp=globalThis[np[ep]+"RequestAnimationFrame"];for(ep=0;ep<np.length&&!sp;++ep)sp=globalThis[np[ep]+"CancelAnimationFrame"]||globalThis[np[ep]+"CancelRequestAnimationFrame"];rp&&sp||(rp=function(t){var e=globalThis.performance.now(),i=Math.max(0,1e3/ip.maxfps-(e-op)),o=globalThis.setTimeout((function(){t(e+i)}),i);return op=e+i,o},sp=function(t){globalThis.clearTimeout(t)},globalThis.requestAnimationFrame=rp,globalThis.cancelAnimationFrame=sp),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 ap={},hp={Base:function(){this.version="13.4.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(ap[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 hp.Base))throw new Error("Plugin should extend the me.plugin.Base Class !");if($c.checkVersion(o.version)>0)throw new Error("Plugin version mismatch, expected: "+o.version+", got: "+Xp);ap[e]=o}},lp={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-lp.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*lp.Bounce.In(2*t):.5*lp.Bounce.Out(2*t-1)+.5}}},up={Linear:function(t,e){var i=t.length-1,o=i*e,n=Math.floor(o),r=up.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=up.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=up.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=up.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}}},cp=function(t){this.setProperties(t)},pp={Easing:{configurable:!0},Interpolation:{configurable:!0}};cp.prototype.onResetEvent=function(t){this.setProperties(t)},cp.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=lp.Linear.None,this._interpolationFunction=up.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._tweenTimeTracker=su.lastUpdate,this.isPersistent=!1,this.updateWhenPaused=!1,this.isRenderable=!1,t)"object"!=typeof t&&(this._valuesStart[e]=parseFloat(t[e]))},cp.prototype._resumeCallback=function(t){this._startTime&&(this._startTime+=t)},cp.prototype.onActivateEvent=function(){es(wr,this._resumeCallback,this)},cp.prototype.onDeactivateEvent=function(){os(wr,this._resumeCallback)},cp.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},cp.prototype.start=function(t){for(var e in void 0===t&&(t=ip.getTime()),this._onStartCallbackFired=!1,su.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},cp.prototype.stop=function(){return su.world.removeChildNow(this),this},cp.prototype.delay=function(t){return this._delayTime=t,this},cp.prototype.repeat=function(t){return this._repeat=t,this},cp.prototype.yoyo=function(t){return this._yoyo=t,this},cp.prototype.easing=function(t){if("function"!=typeof t)throw new Error("invalid easing function for me.Tween.easing()");return this._easingFunction=t,this},cp.prototype.interpolation=function(t){return this._interpolationFunction=t,this},cp.prototype.chain=function(){return this._chainedTweens=arguments,this},cp.prototype.onStart=function(t){return this._onStartCallback=t,this},cp.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},cp.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},cp.prototype.update=function(t){this._tweenTimeTracker=su.lastUpdate>this._tweenTimeTracker?su.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 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}su.world.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},pp.Easing.get=function(){return lp},pp.Interpolation.get=function(){return up},Object.defineProperties(cp,pp);var dp={offscreenCanvas:!1,willReadFrequently:!1,antiAlias:!1,context:"2d"},fp=function(t,e,i){void 0===i&&(i=dp),i=Object.assign(dp,i||{}),this.canvas=Wc(t,e,i.offscreenCanvas),this.context=this.canvas.getContext("2d",{willReadFrequently:i.willReadFrequently}),this.setAntiAlias(i.antiAlias)},yp={width:{configurable:!0},height:{configurable:!0}};function gp(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}fp.prototype.onResetEvent=function(t,e){this.clear(),this.resize(t,e)},fp.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},fp.prototype.setAntiAlias=function(t){void 0===t&&(t=!1);var e=this.canvas;Mn("imageSmoothingEnabled",t,this.context),void 0!==e.style&&(!0!==t?(e.style["image-rendering"]="optimizeSpeed",e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-o-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="optimize-contrast",e.style["image-rendering"]="crisp-edges",e.style["image-rendering"]="pixelated",e.style.msInterpolationMode="nearest-neighbor"):e.style["image-rendering"]="auto")},fp.prototype.resize=function(t,e){this.canvas.width=Math.round(t),this.canvas.height=Math.round(e)},fp.prototype.destroy=function(){this.context=void 0,this.canvas=void 0},yp.width.get=function(){return this.canvas.width},yp.width.set=function(t){this.canvas.width=Math.round(t)},yp.height.get=function(){return this.canvas.height},yp.height.set=function(t){this.canvas.height=Math.round(t)},Object.defineProperties(fp.prototype,yp);var vp=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 bp?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 bp)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];if(void 0!==a){var 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(),gp(e,this.ancestor)),this.width=this.height=0;for(var o=0;o<i.length;o++)this.width=Math.max(this.lineWidth(i[o].trimEnd(),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(),gp(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}(ih),mp=["ex","em","pt","px"],xp=[12,24,.75,1],_p=function(t,e){return!0===e.offScreenCanvas?e.canvasTexture.context:(void 0===t&&(t=Yc),t.getFontContext())},bp=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 cr?this.fillStyle=i.fillStyle:this.fillStyle=er.pull("Color").parseCSS(i.fillStyle):this.fillStyle=er.pull("Color",0,0,0),void 0!==i.strokeStyle?i.strokeStyle instanceof cr?this.strokeStyle=i.strokeStyle:this.strokeStyle=er.pull("Color").parseCSS(i.strokeStyle):this.strokeStyle=er.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=er.pull("CanvasTexture",2,2,{offscreenCanvas:!0})),this.metrics=new vp(this),this.setText(i.text)},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*=xp[mp.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,_p(Yc,this))),e.addBounds(this.metrics.measureText(this._text,_p(Yc,this)),!0),!0===this.offScreenCanvas){var i=Math.ceil(this.metrics.width),o=Math.ceil(this.metrics.height);Yc instanceof Fc&&(this.glTextureUnit=Yc.cache.getUnit(Yc.cache.get(this.canvasTexture.canvas)),Yc.currentCompositor.unbindTexture2D(null,this.glTextureUnit),1===Yc.WebGLVersion&&(i=Ln(this.metrics.width),o=Ln(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,_p(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),gp(t,this,n);for(var r=0;r<e.length;r++){var s=e[r].trimEnd();t[n?"strokeText":"fillText"](s,i,o),o+=this.metrics.lineHeight()}return this.metrics},e.prototype.destroy=function(){!0===this.offScreenCanvas&&(Yc instanceof Fc&&(Yc.currentCompositor.deleteTexture2D(Yc.currentCompositor.getTexture2D(this.glTextureUnit)),this.glTextureUnit=void 0),Yc.cache.delete(this.canvasTexture.canvas),er.push(this.canvasTexture),this.canvasTexture=void 0),er.push(this.fillStyle),er.push(this.strokeStyle),this.fillStyle=this.strokeStyle=void 0,this.metrics=void 0,this._text.length=0,t.prototype.destroy.call(this)},e}(Dl),wp=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=er.pull("Vector2d",1,1),this.fontImage="object"==typeof o.font?o.font:mc.getImage(o.font),"string"!=typeof o.fontData?this.fontData=er.pull("BitmapTextData",mc.getBinary(o.font)):this.fontData=er.pull("BitmapTextData",o.fontData.includes("info face")?o.fontData:mc.getBinary(o.fontData)),void 0!==o.floating&&(this.floating=!!o.floating),void 0!==o.fillStyle&&(this.fillStyle=o.fillStyle),void 0!==o.anchorPoint?this.anchorPoint.set(o.anchorPoint.x,o.anchorPoint.y):this.anchorPoint.set(0,0),this.metrics=new vp(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){t instanceof cr?this.tint.copy(t):this.tint.parseCSS(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=this._text[h].trimEnd(),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];if(void 0!==y){var g=y.width,v=y.height,m=c&&c.kerning?c.getKerning(f):0,x=this.fontScale.x,_=this.fontScale.y;0!==g&&0!==v&&t.drawImage(this.fontImage,y.x,y.y,g,v,i+y.xoffset*x,o+y.yoffset*_,g*x,v*_),i+=(y.xadvance+m)*x,c=y}else console.warn("BitmapText: no defined Glyph in for "+String.fromCharCode(f))}o+=s}void 0===this.ancestor&&t.setGlobalAlpha(n),this.isDirty=!1},e.prototype.destroy=function(){er.push(this.fontScale),this.fontScale=void 0,er.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}(Dl),Tp=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};Tp.prototype.getKerning=function(t){if(this.kerning){var e=this.kerning[t>>>9];if(e)return e[511&t]||0}return 0},Tp.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 Ap=["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 Ep(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 Sp(t){var e=" ".charCodeAt(0),i=t[e];i||((i=new Tp).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 Cp=function(t){this.onResetEvent(t)};Cp.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)},Cp.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(Ep(e[1],/lineHeight\=\d+/g));var n,r=parseFloat(Ep(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 Tp;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,Sp(this.glyphs);var f=null;for(n=0;n<Ap.length;n++){var y=Ap[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 Mp=function(t){function e(e,i,o){t.call(this,0,0,1/0,1/0),this.color=er.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(){er.push(this.color),this.color=void 0,t.prototype.destroy.call(this)},e}(Dl),Pp=function(t){function e(e,i,o){t.call(this,e,i,o),this.floating=!0,this.offset.set(e,i),this.ratio=er.pull("Vector2d",1,1),void 0!==o.ratio&&(bn(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",es($r,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(su.viewport.width,su.viewport.height),this.createPattern()},e.prototype.onActivateEvent=function(){var t=this;es(Qr,this.updateLayer,this),es(qr,this.resize,this),is(Br,(function(){t.updateLayer(su.viewport.pos)})),!0!==this.ancestor.root&&this.updateLayer(su.viewport.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=Yc.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=su.viewport.bounds.width,s=su.viewport.bounds.height,a=this.anchorPoint.x,h=this.anchorPoint.y,l=a*(e-1)*(r-su.viewport.width)+this.offset.x-e*t.x,u=h*(i-1)*(s-su.viewport.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(){os(Qr,this.updateLayer),os(qr,this.resize)},e.prototype.destroy=function(){er.push(this.ratio),this.ratio=void 0,os($r,this.createPattern),t.prototype.destroy.call(this)},Object.defineProperties(e.prototype,i),e}(xc),Op=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}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={width:{configurable:!0},height:{configurable:!0}};return i.width.get=function(){return t.prototype.width},i.width.set=function(e){t.prototype.width=this.nss_width=e},i.height.get=function(){return t.prototype.height},i.height.set=function(e){t.prototype.height=this.nss_height=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)},Object.defineProperties(e.prototype,i),e}(xc),Ip=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&&ip.clearTimeout(this.holdTimeout),this.holdTimeout=ip.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,ip.clearTimeout(this.holdTimeout),this.onRelease(t)},e.prototype.onRelease=function(){return!1},e.prototype.hold=function(){ip.clearTimeout(this.holdTimeout),this.dirty=!0,this.released||this.onHold()},e.prototype.onHold=function(){},e.prototype.onActivateEvent=function(){_l("pointerdown",this,this.clicked.bind(this)),_l("pointerup",this,this.release.bind(this)),_l("pointercancel",this,this.release.bind(this)),_l("pointerenter",this,this.enter.bind(this)),_l("pointerleave",this,this.leave.bind(this))},e.prototype.onDeactivateEvent=function(){bl("pointerdown",this),bl("pointerup",this),bl("pointercancel",this),bl("pointerenter",this),bl("pointerleave",this),ip.clearTimeout(this.holdTimeout)},e}(xc),kp=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=er.pull("Polygon",0,0,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height)])),this.body=new Zl(this,n),this.body.collisionType=Kl.types.COLLECTABLE_OBJECT,this.body.setCollisionMask(Kl.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}(xc),Rp=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=er.pull("Polygon",0,0,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height)])),this.body=new Zl(this,n),this.body.collisionType=Kl.types.ACTION_OBJECT,this.body.setCollisionMask(Kl.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=su.world.getChildByName(this.triggerSettings.container)[0]),this.triggerSettings},e.prototype.onFadeComplete=function(){ic.load(this.gotolevel,this.getTriggerSettings()),su.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,su.viewport.fadeIn(this.fade,this.duration,this.onFadeComplete.bind(this))):ic.load(this.gotolevel,t)},e.prototype.onCollision=function(t,e){return"Trigger"===this.name&&this.triggerEvent.apply(this),!1},e}(Dl);var Bp=function(t){function e(e,i,o,n,r,s){void 0===n&&(n=o),void 0===r&&(r="#FFF"),void 0===s&&(s=.7),t.call(this,e,i,2*o,2*n),this.color=er.pull("Color").parseCSS(r),this.radiusX=o,this.radiusY=n,this.intensity=s,this.blendMode="lighter",this.visibleArea=er.pull("Ellipse",this.centerX,this.centerY,this.width,this.height),this.texture=er.pull("CanvasTexture",this.width,this.height,{offscreenCanvas:!1}),this.anchorPoint.set(0,0),function(t){var e,i,o,n,r,s=t.texture.context,a=t.texture.width/2,h=t.texture.height/2,l=t.radiusX,u=t.radiusY;t.texture.clear(),l>=u?(e=1,o=1,i=u/l,n=l/u,r=s.createRadialGradient(a,h*n,0,a,u*n,l)):(i=1,n=1,e=l/u,o=u/l,r=s.createRadialGradient(a*o,h,0,a*o,h,u)),r.addColorStop(0,t.color.toRGBA(t.intensity)),r.addColorStop(1,t.color.toRGBA(0)),s.fillStyle=r,s.setTransform(e,0,0,i,0,0),s.fillRect(0,0,t.texture.width*o,t.texture.height*n)}(this)}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(){er.push(this.color),this.color=void 0,er.push(this.texture),this.texture=void 0,er.push(this.visibleArea),this.visibleArea=void 0,t.prototype.destroy.call(this)},e}(Dl),Dp=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 ir(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;_l("pointerdown",this,(function(e){ts(Xr,e,t)})),_l("pointerup",this,(function(e){ts(Hr,e,t)})),_l("pointercancel",this,(function(e){ts(Hr,e,t)})),es(Nr,this.dragMove.bind(this)),es(Xr,(function(e,i){i===t&&t.dragStart(e)})),es(Hr,(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(){os(Nr,this.dragMove),os(Xr,this.dragStart),os(Hr,this.dragEnd),bl("pointerdown",this),bl("pointerup",this),bl("pointercancel",this),t.prototype.destroy.call(this)},e}(Dl),Lp=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,es(Hr,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(){os(Hr,this.checkOnMe),t.prototype.destroy.call(this)},e}(Dl),zp={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 Fp=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,zp,t),void 0===this.settings.image&&(this._defaultParticle=function(t,e){void 0===t&&(t=8),void 0===e&&(e=8);var i=er.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 Vn(0,this.getBounds().width)},e.prototype.getRandomPointY=function(){return Vn(0,this.getBounds().height)},e.prototype.addParticles=function(t){for(var e=0;e<t;e++)this.addChild(er.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&&(er.push(this._defaultParticle),this._defaultParticle=void 0),this.settings.image=void 0,this.settings=void 0},e}($l),jp=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=er.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?(Vn(0,2)-1)*t.settings.angleVariation:0),o=t.settings.speed+(t.settings.speedVariation>0?(Vn(0,2)-1)*t.settings.speedVariation:0);this.vel.set(o*Math.cos(i),-o*Math.sin(i)),this.life=Vn(t.settings.minLife,t.settings.maxLife),this.startLife=this.life,this.startScale=Fn(Vn(t.settings.minStartScale,t.settings.maxStartScale),t.settings.minStartScale,t.settings.maxStartScale),this.endScale=Fn(Vn(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=ip.maxfps/1e3,t.settings.followTrajectory||(this.angle=Vn(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}(Dl),Vp=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 xc(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=er.pull("Polygon",0,0,[er.pull("Vector2d",0,0),er.pull("Vector2d",this.width,0),er.pull("Vector2d",this.width,this.height),er.pull("Vector2d",0,this.height)])),this.body=new Zl(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}(Dl);function Up(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()}Object.defineProperty(sh.prototype,"Texture",{get:function(){return Up("me.video.renderer.Texture","me.TextureAtlas","10.4.0"),bc}});var Np=function(t){function e(e,i,o){Up("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}(Dp),Gp=function(t){function e(e,i,o){Up("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}(Lp);sh.prototype.getScreenCanvas=function(){return Up("getScreenCanvas","getCanvas","13.1.0"),this.getCanvas()},sh.prototype.getScreenContext=function(){return Up("getScreenContext","getContext","13.1.0"),this.getContext()};var Xp="13.4.0";t.initialized=!1;function Hp(){!0!==t.initialized&&(er.register("me.Entity",Vp),er.register("me.Collectable",kp),er.register("me.Trigger",Rp),er.register("me.Light2d",Bp),er.register("me.Tween",cp,!0),er.register("me.Color",cr,!0),er.register("me.Particle",jp,!0),er.register("me.Sprite",xc),er.register("me.NineSliceSprite",Op),er.register("me.Renderable",Dl),er.register("me.Text",bp,!0),er.register("me.BitmapText",wp),er.register("me.BitmapTextData",Cp,!0),er.register("me.ImageLayer",Pp),er.register("me.ColorLayer",Mp,!0),er.register("me.Vector2d",ir,!0),er.register("me.Vector3d",Eh,!0),er.register("me.ObservableVector2d",Ah,!0),er.register("me.ObservableVector3d",Sh,!0),er.register("me.Matrix2d",yr,!0),er.register("me.Matrix3d",dr,!0),er.register("me.Rect",Ja,!0),er.register("me.RoundRect",$a,!0),er.register("me.Polygon",Qa,!0),er.register("me.Line",eh,!0),er.register("me.Point",rh,!0),er.register("me.Ellipse",th,!0),er.register("me.Bounds",ih,!0),er.register("Entity",Vp),er.register("Collectable",kp),er.register("Trigger",Rp),er.register("Light2d",Bp),er.register("Tween",cp,!0),er.register("Color",cr,!0),er.register("Particle",jp,!0),er.register("Sprite",xc),er.register("NineSliceSprite",Op),er.register("Renderable",Dl),er.register("Text",bp,!0),er.register("BitmapText",wp),er.register("BitmapTextData",Cp,!0),er.register("ImageLayer",Pp),er.register("ColorLayer",Mp,!0),er.register("Vector2d",ir,!0),er.register("Vector3d",Eh,!0),er.register("ObservableVector2d",Ah,!0),er.register("ObservableVector3d",Sh,!0),er.register("Matrix2d",yr,!0),er.register("Matrix3d",dr,!0),er.register("Rect",Ja,!0),er.register("RoundRect",$a,!0),er.register("Polygon",Qa,!0),er.register("Line",eh,!0),er.register("Point",rh,!0),er.register("Ellipse",th,!0),er.register("Bounds",ih,!0),er.register("CanvasTexture",fp,!0),ts(_r),mc.setNocache($c.getUriFragment().nocache||!1),Lh(),t.initialized=!0)}na((function(){Hp()})),t.BitmapText=wp,t.BitmapTextData=Cp,t.Body=Zl,t.Bounds=ih,t.Camera2d=cu,t.CanvasRenderer=Lu,t.Collectable=kp,t.Color=cr,t.ColorLayer=Mp,t.Container=$l,t.Draggable=Dp,t.DraggableEntity=Np,t.DropTarget=Lp,t.DroptargetEntity=Gp,t.Ellipse=th,t.Entity=Vp,t.GLShader=_a,t.GUI_Object=Ip,t.ImageLayer=Pp,t.Light2d=Bp,t.Line=eh,t.Math=Gn,t.Matrix2d=yr,t.Matrix3d=dr,t.NineSliceSprite=Op,t.ObservableVector2d=Ah,t.ObservableVector3d=Sh,t.Particle=jp,t.ParticleEmitter=Fp,t.ParticleEmitterSettings=zp,t.Point=rh,t.Pointer=Uh,t.Polygon=Qa,t.QuadTree=ou,t.Rect=Ja,t.Renderable=Dl,t.Renderer=sh,t.RoundRect=$a,t.Sprite=xc,t.Stage=du,t.TMXHexagonalRenderer=Xu,t.TMXIsometricRenderer=Uu,t.TMXLayer=Fu,t.TMXOrthogonalRenderer=Vu,t.TMXRenderer=ju,t.TMXStaggeredRenderer=Hu,t.TMXTileMap=Qu,t.TMXTileset=Yu,t.TMXTilesetGroup=Wu,t.Text=bp,t.TextureAtlas=bc,t.Tile=Du,t.Trigger=Rp,t.Tween=cp,t.Vector2d=ir,t.Vector3d=Eh,t.WebGLCompositor=Ta,t.WebGLRenderer=Fc,t.World=nu,t.audio=Th,t.boot=Hp,t.collision=Kl,t.device=ya,t.event=ns,t.game=su,t.input=Bl,t.level=ic,t.loader=mc,t.plugin=hp,t.plugins=ap,t.pool=er,t.save=hs,t.skipAutoInit=!1,t.state=Mu,t.timer=ip,t.utils=$c,t.version=Xp,t.video=Zc,t.warning=Up,Object.defineProperty(t,"__esModule",{value:!0})}));
|