text: !function(t){if("object"==typeof exports)module.exports=t();else{var e;"undefined"==typeof window?"undefined"==typeof global?"undefined"!=typeof self&&(e=self):e=global:e=window,e.p2=t()}}(function(){var e=Math.PI,t=Math.ceil,a=Math.floor,o=Math.pow,n=Math.max,s=Math.min,r=Math.sin,d=Math.cos,l=Math.abs,u=Number.MAX_VALUE,p=Math.sqrt;return function d(l,e,t){function a(i,o){if(!e[i]){if(!l[i]){var n="function"==typeof require&&require;if(!o&&n)return n(i,!0);if(r)return r(i,!0);throw new Error("Cannot find module '"+i+"'")}var s=e[i]={exports:{}};l[i][0].call(s.exports,function(t){var e=l[i][1][t];return a(e?e:t)},s,s.exports,d,l,e,t)}return e[i].exports}for(var r="function"==typeof require&&require,n=0;n<t.length;n++)a(t[n]);return a}({1:[function(e,t){function a(){}var o=e("./Scalar");t.exports=a;a.lineInt=function(e,t,a){a=a||0;var r=[0,0],n,i,s,d,l,p,c;return n=e[1][1]-e[0][1],i=e[0][0]-e[1][0],s=n*e[0][0]+i*e[0][1],d=t[1][1]-t[0][1],l=t[0][0]-t[1][0],p=d*t[0][0]+l*t[0][1],c=n*l-d*i,o.eq(c,0,a)||(r[0]=(l*s-i*p)/c,r[1]=(n*p-d*s)/c),r},a.segmentsIntersect=function(e,a,o,r){var n=a[0]-e[0],i=a[1]-e[1],d=r[0]-o[0],l=r[1]-o[1];if(0==d*i-l*n)return!1;var p=(n*(o[1]-e[1])+i*(e[0]-o[0]))/(d*i-l*n),s=(d*(e[1]-o[1])+l*(o[0]-e[0]))/(l*n-d*i);return 0<=p&&1>=p&&0<=s&&1>=s}},{"./Scalar":4}],2:[function(e,t){function o(){}t.exports=o;o.area=function(e,t,a){return(t[0]-e[0])*(a[1]-e[1])-(a[0]-e[0])*(t[1]-e[1])},o.left=function(e,t,a){return 0<o.area(e,t,a)},o.leftOn=function(e,t,a){return 0<=o.area(e,t,a)},o.right=function(e,t,a){return 0>o.area(e,t,a)},o.rightOn=function(e,t,a){return 0>=o.area(e,t,a)};var r=[],n=[];o.collinear=function(e,t,a,i){if(!i)return 0==o.area(e,t,a);var s=r,d=n;s[0]=t[0]-e[0],s[1]=t[1]-e[1],d[0]=a[0]-t[0],d[1]=a[1]-t[1];var l=s[0]*d[0]+s[1]*d[1],c=p(s[0]*s[0]+s[1]*s[1]),u=p(d[0]*d[0]+d[1]*d[1]),h=Math.acos(l/(c*u));return h<i},o.sqdist=function(e,t){var a=t[0]-e[0],o=t[1]-e[1];return a*a+o*o}},{}],3:[function(e,t){function a(){this.vertices=[]}function o(e,t,a,o,r){r=r||0;var n=t[1]-e[1],s=e[0]-t[0],d=n*e[0]+s*e[1],l=o[1]-a[1],p=a[0]-o[0],c=l*a[0]+p*a[1],u=n*p-l*s;return i.eq(u,0,r)?[0,0]:[(p*d-s*c)/u,(n*c-l*d)/u]}var r=e("./Line"),n=e("./Point"),i=e("./Scalar");t.exports=a,a.prototype.at=function(e){var t=this.vertices,a=t.length;return t[0>e?e%a+a:e%a]},a.prototype.first=function(){return this.vertices[0]},a.prototype.last=function(){return this.vertices[this.vertices.length-1]},a.prototype.clear=function(){this.vertices.length=0},a.prototype.append=function(e,t,a){if("undefined"==typeof t)throw new Error("From is not given!");if("undefined"==typeof a)throw new Error("To is not given!");if(a-1<t)throw new Error("lol1");if(a>e.vertices.length)throw new Error("lol2");if(0>t)throw new Error("lol3");for(var o=t;o<a;o++)this.vertices.push(e.vertices[o])},a.prototype.makeCCW=function(){for(var e=0,t=this.vertices,a=1;a<this.vertices.length;++a)(t[a][1]<t[e][1]||t[a][1]==t[e][1]&&t[a][0]>t[e][0])&&(e=a);n.left(this.at(e-1),this.at(e),this.at(e+1))||this.reverse()},a.prototype.reverse=function(){for(var e=[],t=0,a=this.vertices.length;t!==a;t++)e.push(this.vertices.pop());this.vertices=e},a.prototype.isReflex=function(e){return n.right(this.at(e-1),this.at(e),this.at(e+1))};var s=[],d=[];a.prototype.canSee=function(e,t){var a=s,o=d,l,p;if(n.leftOn(this.at(e+1),this.at(e),this.at(t))&&n.rightOn(this.at(e-1),this.at(e),this.at(t)))return!1;p=n.sqdist(this.at(e),this.at(t));for(var c=0;c!==this.vertices.length;++c)if((c+1)%this.vertices.length!==e&&c!==e&&n.leftOn(this.at(e),this.at(t),this.at(c+1))&&n.rightOn(this.at(e),this.at(t),this.at(c))&&(a[0]=this.at(e),a[1]=this.at(t),o[0]=this.at(c),o[1]=this.at(c+1),l=r.lineInt(a,o),n.sqdist(this.at(e),l)<p))return!1;return!0},a.prototype.copy=function(e,t,o){var r=o||new a;if(r.clear(),e<t)for(var n=e;n<=t;n++)r.vertices.push(this.vertices[n]);else{for(var n=0;n<=t;n++)r.vertices.push(this.vertices[n]);for(var n=e;n<this.vertices.length;n++)r.vertices.push(this.vertices[n])}return r},a.prototype.getCutEdges=function(){for(var e=[],t=[],o=[],r=new a,n=u,s=0;s<this.vertices.length;++s)if(this.isReflex(s))for(var i=0;i<this.vertices.length;++i)if(this.canSee(s,i)){t=this.copy(s,i,r).getCutEdges(),o=this.copy(i,s,r).getCutEdges();for(var d=0;d<o.length;d++)t.push(o[d]);t.length<n&&(e=t,n=t.length,e.push([this.at(s),this.at(i)]))}return e},a.prototype.decomp=function(){var e=this.getCutEdges();return 0<e.length?this.slice(e):[this]},a.prototype.slice=function(e){if(0==e.length)return[this];if(e instanceof Array&&e.length&&e[0]instanceof Array&&2==e[0].length&&e[0][0]instanceof Array){for(var t=[this],a=0,o;a<e.length;a++){o=e[a];for(var r=0;r<t.length;r++){var n=t[r],i=n.slice(o);if(i){t.splice(r,1),t.push(i[0],i[1]);break}}}return t}var o=e,a=this.vertices.indexOf(o[0]),r=this.vertices.indexOf(o[1]);return-1!=a&&-1!=r&&[this.copy(a,r),this.copy(r,a)]},a.prototype.isSimple=function(){for(var e=this.vertices,t=0;t<e.length-1;t++)for(var a=0;a<t-1;a++)if(r.segmentsIntersect(e[t],e[t+1],e[a],e[a+1]))return!1;for(var t=1;t<e.length-2;t++)if(r.segmentsIntersect(e[0],e[e.length-1],e[t],e[t+1]))return!1;return!0},a.prototype.quickDecomp=function(e,t,r,s,l,c){l=l||100,c=c||0,s=s||25,e="undefined"==typeof e?[]:e,t=t||[],r=r||[];var h=[0,0],g=[0,0],m=[0,0],p=0,y=0,f=0,d=0,x=0,b=0,_=0,T=new a,C=new a,P=this,S=this.vertices;if(3>S.length)return e;if(c++,c>l)return console.warn("quickDecomp: max level ("+l+") reached."),e;for(var v=0;v<this.vertices.length;++v)if(P.isReflex(v)){t.push(P.vertices[v]),p=y=u;for(var i=0;i<this.vertices.length;++i)n.left(P.at(v-1),P.at(v),P.at(i))&&n.rightOn(P.at(v-1),P.at(v),P.at(i-1))&&(m=o(P.at(v-1),P.at(v),P.at(i),P.at(i-1)),n.right(P.at(v+1),P.at(v),m)&&(f=n.sqdist(P.vertices[v],m),f<y&&(y=f,g=m,b=i))),n.left(P.at(v+1),P.at(v),P.at(i+1))&&n.rightOn(P.at(v+1),P.at(v),P.at(i))&&(m=o(P.at(v+1),P.at(v),P.at(i),P.at(i+1)),n.left(P.at(v-1),P.at(v),m)&&(f=n.sqdist(P.vertices[v],m),f<p&&(p=f,h=m,x=i)));if(b==(x+1)%this.vertices.length)m[0]=(g[0]+h[0])/2,m[1]=(g[1]+h[1])/2,r.push(m),v<x?(T.append(P,v,x+1),T.vertices.push(m),C.vertices.push(m),0!=b&&C.append(P,b,P.vertices.length),C.append(P,0,v+1)):(0!=v&&T.append(P,v,P.vertices.length),T.append(P,0,x+1),T.vertices.push(m),C.vertices.push(m),C.append(P,b,v+1));else{if(b>x&&(x+=this.vertices.length),d=u,x<b)return e;for(var i=b;i<=x;++i)n.leftOn(P.at(v-1),P.at(v),P.at(i))&&n.rightOn(P.at(v+1),P.at(v),P.at(i))&&(f=n.sqdist(P.at(v),P.at(i)),f<d&&(d=f,_=i%this.vertices.length));v<_?(T.append(P,v,_+1),0!=_&&C.append(P,_,S.length),C.append(P,0,v+1)):(0!=v&&T.append(P,v,S.length),T.append(P,0,_+1),C.append(P,_,v+1))}return T.vertices.length<C.vertices.length?(T.quickDecomp(e,t,r,s,l,c),C.quickDecomp(e,t,r,s,l,c)):(C.quickDecomp(e,t,r,s,l,c),T.quickDecomp(e,t,r,s,l,c)),e}return e.push(this),e},a.prototype.removeCollinearPoints=function(e){for(var t=0,a=this.vertices.length-1;3<this.vertices.length&&0<=a;--a)n.collinear(this.at(a-1),this.at(a),this.at(a+1),e)&&(this.vertices.splice(a%this.vertices.length,1),a--,t++);return t}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(e,t){function a(){}t.exports=a,a.eq=function(e,t,a){return a=a||0,l(e-t)<a}},{}],5:[function(e,t){t.exports={Polygon:e("./Polygon"),Point:e("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(e,t){t.exports={name:"p2",version:"0.7.1",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.1"}}},{}],7:[function(e,t){function a(e){this.lowerBound=o.create(),e&&e.lowerBound&&o.copy(this.lowerBound,e.lowerBound),this.upperBound=o.create(),e&&e.upperBound&&o.copy(this.upperBound,e.upperBound)}var o=e("../math/vec2"),i=e("../utils/Utils");t.exports=a;var l=o.create();a.prototype.setFromPoints=function(e,t,a,n){var s=this.lowerBound,c=this.upperBound;"number"!=typeof a&&(a=0),0===a?o.copy(s,e[0]):o.rotate(s,e[0],a),o.copy(c,s);for(var u=d(a),h=r(a),g=1,i;g<e.length;g++){if(i=e[g],0!==a){var p=i[0],m=i[1];l[0]=u*p-h*m,l[1]=h*p+u*m,i=l}for(var y=0;2>y;y++)i[y]>c[y]&&(c[y]=i[y]),i[y]<s[y]&&(s[y]=i[y])}t&&(o.add(this.lowerBound,this.lowerBound,t),o.add(this.upperBound,this.upperBound,t)),n&&(this.lowerBound[0]-=n,this.lowerBound[1]-=n,this.upperBound[0]+=n,this.upperBound[1]+=n)},a.prototype.copy=function(e){o.copy(this.lowerBound,e.lowerBound),o.copy(this.upperBound,e.upperBound)},a.prototype.extend=function(e){for(var t=2;t--;){var a=e.lowerBound[t];this.lowerBound[t]>a&&(this.lowerBound[t]=a);var o=e.upperBound[t];this.upperBound[t]<o&&(this.upperBound[t]=o)}},a.prototype.overlaps=function(e){var t=this.lowerBound,a=this.upperBound,o=e.lowerBound,r=e.upperBound;return(o[0]<=a[0]&&a[0]<=r[0]||t[0]<=r[0]&&r[0]<=a[0])&&(o[1]<=a[1]&&a[1]<=r[1]||t[1]<=r[1]&&r[1]<=a[1])},a.prototype.containsPoint=function(e){var t=this.lowerBound,a=this.upperBound;return t[0]<=e[0]&&e[0]<=a[0]&&t[1]<=e[1]&&e[1]<=a[1]},a.prototype.overlapsRay=function(e){var t=1/e.direction[0],a=1/e.direction[1],o=(this.lowerBound[0]-e.from[0])*t,r=(this.upperBound[0]-e.from[0])*t,i=(this.lowerBound[1]-e.from[1])*a,d=(this.upperBound[1]-e.from[1])*a,l=n(n(s(o,r),s(i,d))),p=s(s(n(o,r),n(i,d)));return 0>p?-1:l>p?-1:l}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(e,t){function a(e){this.type=e,this.result=[],this.world=null,this.boundingVolumeType=a.AABB}var o=e("../math/vec2"),r=e("../objects/Body");t.exports=a,a.AABB=1,a.BOUNDING_CIRCLE=2,a.prototype.setWorld=function(e){this.world=e},a.prototype.getCollisionPairs=function(){};var n=o.create();a.boundingRadiusCheck=function(e,t){o.sub(n,e.position,t.position);var a=o.squaredLength(n),i=e.boundingRadius+t.boundingRadius;return a<=i*i},a.aabbCheck=function(e,t){return e.getAABB().overlaps(t.getAABB())},a.prototype.boundingVolumeCheck=function(e,t){var o;switch(this.boundingVolumeType){case a.BOUNDING_CIRCLE:o=a.boundingRadiusCheck(e,t);break;case a.AABB:o=a.aabbCheck(e,t);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType);}return o},a.canCollide=function(e,t){var a=r.KINEMATIC,o=r.STATIC;return e.type===o&&t.type===o?!1:e.type===a&&t.type===o||e.type===o&&t.type===a?!1:e.type===a&&t.type===a?!1:e.sleepState===r.SLEEPING&&t.sleepState===r.SLEEPING?!1:e.sleepState===r.SLEEPING&&t.type===o||t.sleepState===r.SLEEPING&&e.type===o?!1:!0},a.NAIVE=1,a.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(e,t){function a(){s.call(this,s.NAIVE)}var o=e("../shapes/Circle"),r=e("../shapes/Plane"),n=e("../shapes/Shape"),i=e("../shapes/Particle"),s=e("../collision/Broadphase"),d=e("../math/vec2");t.exports=a,a.prototype=new s,a.prototype.constructor=a,a.prototype.getCollisionPairs=function(e){var t=e.bodies,a=this.result;a.length=0;for(var o=0,r=t.length,n;o!==r;o++){n=t[o];for(var i=0,d;i<o;i++)d=t[i],s.canCollide(n,d)&&this.boundingVolumeCheck(n,d)&&a.push(n,d)}return a},a.prototype.aabbQuery=function(e,t,a){a=a||[];for(var o=e.bodies,r=0,n;r<o.length;r++)n=o[r],n.aabbNeedsUpdate&&n.updateAABB(),n.aabb.overlaps(t)&&a.push(n);return a}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(r,n){function s(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.enabledEquations=!0,this.slipForce=10,this.frictionCoefficient=0.3,this.surfaceVelocity=0,this.contactEquationPool=new c({size:32}),this.frictionEquationPool=new f({size:64}),this.restitution=0,this.stiffness=b.DEFAULT_STIFFNESS,this.relaxation=b.DEFAULT_RELAXATION,this.frictionStiffness=b.DEFAULT_STIFFNESS,this.frictionRelaxation=b.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new x,this.contactSkinSize=0.01}function d(e,t){h.set(e.vertices[0],0.5*-t.length,-t.radius),h.set(e.vertices[1],0.5*t.length,-t.radius),h.set(e.vertices[2],0.5*t.length,t.radius),h.set(e.vertices[3],0.5*-t.length,t.radius)}function p(e,t,a,o){for(var r=ee,n=te,s=ae,d=oe,l=e,p=t.vertices,c=null,u=0;u!==p.length+1;u++){var i=p[u%p.length],y=p[(u+1)%p.length];h.rotate(r,i,o),h.rotate(n,y,o),m(r,r,a),m(n,n,a),g(s,r,l),g(d,n,l);var f=h.crossLength(s,d);if(null==c&&(c=f),0>=f*c)return!1;c=f}return!0}var h=r("../math/vec2"),g=h.sub,m=h.add,y=h.dot,i=r("../utils/Utils"),c=r("../utils/ContactEquationPool"),f=r("../utils/FrictionEquationPool"),x=r("../utils/TupleDictionary"),b=r("../equations/Equation"),_=r("../equations/ContactEquation"),v=r("../equations/FrictionEquation"),T=r("../shapes/Circle"),C=r("../shapes/Convex"),P=r("../shapes/Shape"),S=r("../objects/Body"),w=r("../shapes/Box");n.exports=s;var A=h.fromValues(0,1),E=h.fromValues(0,0),R=h.fromValues(0,0),L=h.fromValues(0,0),B=h.fromValues(0,0),F=h.fromValues(0,0),k=h.fromValues(0,0),D=h.fromValues(0,0),M=h.fromValues(0,0),O=h.fromValues(0,0),I=h.fromValues(0,0),U=h.fromValues(0,0),G=h.fromValues(0,0),N=h.fromValues(0,0),W=h.fromValues(0,0),X=h.fromValues(0,0),V=h.fromValues(0,0),H=h.fromValues(0,0),q=h.fromValues(0,0),j=[],Y=h.create(),z=h.create();s.prototype.bodiesOverlap=function(e,t){for(var a=Y,o=z,r=0,n=e.shapes.length,i;r!==n;r++){i=e.shapes[r],e.toWorldFrame(a,i.position);for(var s=0,d=t.shapes.length,l;s!==d;s++)if(l=t.shapes[s],t.toWorldFrame(o,l.position),this[i.type|l.type](e,i,a,i.angle+e.angle,t,l,o,l.angle+t.angle,!0))return!0}return!1},s.prototype.collidedLastStep=function(e,t){var a=0|e.id,o=0|t.id;return!!this.collidingBodiesLastStep.get(a,o)},s.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var e=this.contactEquations,t=e.length;t--;){var a=e[t],o=a.bodyA.id,r=a.bodyB.id;this.collidingBodiesLastStep.set(o,r,!0)}for(var n=this.contactEquations,s=this.frictionEquations,d=0;d<n.length;d++)this.contactEquationPool.release(n[d]);for(var d=0;d<s.length;d++)this.frictionEquationPool.release(s[d]);this.contactEquations.length=this.frictionEquations.length=0},s.prototype.createContactEquation=function(e,t,a,o){var r=this.contactEquationPool.get();return r.bodyA=e,r.bodyB=t,r.shapeA=a,r.shapeB=o,r.restitution=this.restitution,r.firstImpact=!this.collidedLastStep(e,t),r.stiffness=this.stiffness,r.relaxation=this.relaxation,r.needsUpdate=!0,r.enabled=this.enabledEquations,r.offset=this.contactSkinSize,r},s.prototype.createFrictionEquation=function(e,t,a,o){var r=this.frictionEquationPool.get();return r.bodyA=e,r.bodyB=t,r.shapeA=a,r.shapeB=o,r.setSlipForce(this.slipForce),r.frictionCoefficient=this.frictionCoefficient,r.relativeVelocity=this.surfaceVelocity,r.enabled=this.enabledEquations,r.needsUpdate=!0,r.stiffness=this.frictionStiffness,r.relaxation=this.frictionRelaxation,r.contactEquations.length=0,r},s.prototype.createFrictionFromContact=function(e){var t=this.createFrictionEquation(e.bodyA,e.bodyB,e.shapeA,e.shapeB);return h.copy(t.contactPointA,e.contactPointA),h.copy(t.contactPointB,e.contactPointB),h.rotate90cw(t.t,e.normalA),t.contactEquations.push(e),t},s.prototype.createFrictionFromAverage=function(e){var t=this.contactEquations[this.contactEquations.length-1],a=this.createFrictionEquation(t.bodyA,t.bodyB,t.shapeA,t.shapeB),o=t.bodyA,r=t.bodyB;h.set(a.contactPointA,0,0),h.set(a.contactPointB,0,0),h.set(a.t,0,0);for(var n=0;n!==e;n++)t=this.contactEquations[this.contactEquations.length-1-n],t.bodyA===o?(h.add(a.t,a.t,t.normalA),h.add(a.contactPointA,a.contactPointA,t.contactPointA),h.add(a.contactPointB,a.contactPointB,t.contactPointB)):(h.sub(a.t,a.t,t.normalA),h.add(a.contactPointA,a.contactPointA,t.contactPointB),h.add(a.contactPointB,a.contactPointB,t.contactPointA)),a.contactEquations.push(t);var i=1/e;return h.scale(a.contactPointA,a.contactPointA,i),h.scale(a.contactPointB,a.contactPointB,i),h.normalize(a.t,a.t),h.rotate90cw(a.t,a.t),a},s.prototype[P.LINE|P.CONVEX]=s.prototype.convexLine=function(e,t,a,o,r,n,i,s,d){return!d&&0},s.prototype[P.LINE|P.BOX]=s.prototype.lineBox=function(e,t,a,o,r,n,i,s,d){return!d&&0};var K=new w({width:1,height:1}),J=h.create();s.prototype[P.CAPSULE|P.CONVEX]=s.prototype[P.CAPSULE|P.BOX]=s.prototype.convexCapsule=function(e,t,a,o,n,i,s,l,p){var c=J;h.set(c,i.length/2,0),h.rotate(c,c,l),h.add(c,c,s);var u=this.circleConvex(n,i,c,l,e,t,a,o,p,i.radius);h.set(c,-i.length/2,0),h.rotate(c,c,l),h.add(c,c,s);var g=this.circleConvex(n,i,c,l,e,t,a,o,p,i.radius);if(p&&(u||g))return!0;var m=K;d(m,i);var r=this.convexConvex(e,t,a,o,n,m,s,l,p);return r+u+g},s.prototype[P.CAPSULE|P.LINE]=s.prototype.lineCapsule=function(e,t,a,o,r,n,i,s,d){return!d&&0};var Q=h.create(),Z=h.create(),$=new w({width:1,height:1});s.prototype[P.CAPSULE|P.CAPSULE]=s.prototype.capsuleCapsule=function(e,t,a,o,r,n,s,l,p){for(var c=Q,u=Z,g=0,m=0,i;2>m;m++){h.set(c,(0===m?-1:1)*t.length/2,0),h.rotate(c,c,o),h.add(c,c,a);for(var y=0;2>y;y++){h.set(u,(0===y?-1:1)*n.length/2,0),h.rotate(u,u,l),h.add(u,u,s),this.enableFrictionReduction&&(i=this.enableFriction,this.enableFriction=!1);var f=this.circleCircle(e,t,c,o,r,n,u,l,p,t.radius,n.radius);if(this.enableFrictionReduction&&(this.enableFriction=i),p&&f)return!0;g+=f}}this.enableFrictionReduction&&(i=this.enableFriction,this.enableFriction=!1);var x=$;d(x,t);var b=this.convexCapsule(e,x,a,o,r,n,s,l,p);if(this.enableFrictionReduction&&(this.enableFriction=i),p&&b)return!0;if(g+=b,this.enableFrictionReduction){var i=this.enableFriction;this.enableFriction=!1}d(x,n);var _=this.convexCapsule(r,x,s,l,e,t,a,o,p);return!(this.enableFrictionReduction&&(this.enableFriction=i),!(p&&_))||(g+=_,this.enableFrictionReduction&&g&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(g)),g)},s.prototype[P.LINE|P.LINE]=s.prototype.lineLine=function(e,t,a,o,r,n,i,s,d){return!d&&0},s.prototype[P.PLANE|P.LINE]=s.prototype.planeLine=function(e,t,a,o,r,n,s,l,p){var u=E,f=R,x=L,b=B,_=F,T=k,C=D,P=M,S=j,w=0;h.set(u,-n.length/2,0),h.set(f,n.length/2,0),h.rotate(x,u,l),h.rotate(b,f,l),m(x,x,s),m(b,b,s),h.copy(u,x),h.copy(f,b),g(_,f,u),h.normalize(T,_),h.rotate90cw(O,T),h.rotate(P,A,o),S[0]=u,S[1]=f;for(var I=0,i;I<S.length;I++){i=S[I],g(C,i,a);var v=y(C,P);if(0>v){if(p)return!0;var d=this.createContactEquation(e,r,t,n);w++,h.copy(d.normalA,P),h.normalize(d.normalA,d.normalA),h.scale(C,P,v),g(d.contactPointA,i,C),g(d.contactPointA,d.contactPointA,e.position),g(d.contactPointB,i,s),m(d.contactPointB,d.contactPointB,s),g(d.contactPointB,d.contactPointB,r.position),this.contactEquations.push(d),!this.enableFrictionReduction&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d))}}return!p&&(!this.enableFrictionReduction&&w&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(w)),w)},s.prototype[P.PARTICLE|P.CAPSULE]=s.prototype.particleCapsule=function(e,t,a,o,r,n,i,s,d){return this.circleLine(e,t,a,o,r,n,i,s,d,n.radius,0)},s.prototype[P.CIRCLE|P.LINE]=s.prototype.circleLine=function(e,t,a,r,n,s,p,u,f,x,b){var x=x||0,b="undefined"==typeof b?t.radius:b,_=E,T=R,C=L,P=F,S=k,w=D,A=M,X=O,V=I,H=U,q=G,Y=N,z=W,K=j;h.set(A,-s.length/2,0),h.set(X,s.length/2,0),h.rotate(V,A,u),h.rotate(H,X,u),m(V,V,p),m(H,H,p),h.copy(A,V),h.copy(X,H),g(S,X,A),h.normalize(w,S),h.rotate90cw(P,w),g(q,a,A);var J=y(q,P);g(B,A,p),g(Y,a,p);var d=b+x;if(l(J)<d){h.scale(_,P,J),g(C,a,_),h.scale(T,P,y(P,Y)),h.normalize(T,T),h.scale(T,T,x),m(C,C,T);var Q=y(w,C),Z=y(w,A),$=y(w,X);if(Q>Z&&Q<$){if(f)return!0;var ee=this.createContactEquation(e,n,t,s);return h.scale(ee.normalA,_,-1),h.normalize(ee.normalA,ee.normalA),h.scale(ee.contactPointA,ee.normalA,b),m(ee.contactPointA,ee.contactPointA,a),g(ee.contactPointA,ee.contactPointA,e.position),g(ee.contactPointB,C,p),m(ee.contactPointB,ee.contactPointB,p),g(ee.contactPointB,ee.contactPointB,n.position),this.contactEquations.push(ee),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(ee)),1}}K[0]=A,K[1]=X;for(var c=0,i;c<K.length;c++)if(i=K[c],g(q,i,a),h.squaredLength(q)<o(d,2)){if(f)return!0;var ee=this.createContactEquation(e,n,t,s);return h.copy(ee.normalA,q),h.normalize(ee.normalA,ee.normalA),h.scale(ee.contactPointA,ee.normalA,b),m(ee.contactPointA,ee.contactPointA,a),g(ee.contactPointA,ee.contactPointA,e.position),g(ee.contactPointB,i,p),h.scale(z,ee.normalA,-x),m(ee.contactPointB,ee.contactPointB,z),m(ee.contactPointB,ee.contactPointB,p),g(ee.contactPointB,ee.contactPointB,n.position),this.contactEquations.push(ee),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(ee)),1}return 0},s.prototype[P.CIRCLE|P.CAPSULE]=s.prototype.circleCapsule=function(e,t,a,o,r,n,i,s,d){return this.circleLine(e,t,a,o,r,n,i,s,d,n.radius)},s.prototype[P.CIRCLE|P.CONVEX]=s.prototype[P.CIRCLE|P.BOX]=s.prototype.circleConvex=function(e,t,a,r,n,s,d,y,f,x){for(var x="number"==typeof x?x:t.radius,b=E,_=R,v=L,T=B,C=F,P=I,S=U,w=N,A=W,k=X,D=V,M=!1,O=u,G=s.vertices,H=0;H!==G.length+1;H++){var i=G[H%G.length],q=G[(H+1)%G.length];if(h.rotate(b,i,y),h.rotate(_,q,y),m(b,b,d),m(_,_,d),g(v,_,b),h.normalize(T,v),h.rotate90cw(C,T),h.scale(A,C,-t.radius),m(A,A,a),p(A,s,d,y)){h.sub(k,b,A);var j=l(h.dot(k,C));j<O&&(h.copy(D,A),O=j,h.scale(w,C,j),h.add(w,w,A),M=!0)}}if(M){if(f)return!0;var Y=this.createContactEquation(e,n,t,s);return h.sub(Y.normalA,D,a),h.normalize(Y.normalA,Y.normalA),h.scale(Y.contactPointA,Y.normalA,x),m(Y.contactPointA,Y.contactPointA,a),g(Y.contactPointA,Y.contactPointA,e.position),g(Y.contactPointB,w,d),m(Y.contactPointB,Y.contactPointB,d),g(Y.contactPointB,Y.contactPointB,n.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}if(0<x)for(var H=0,c;H<G.length;H++)if(c=G[H],h.rotate(S,c,y),m(S,S,d),g(P,S,a),h.squaredLength(P)<o(x,2)){if(f)return!0;var Y=this.createContactEquation(e,n,t,s);return h.copy(Y.normalA,P),h.normalize(Y.normalA,Y.normalA),h.scale(Y.contactPointA,Y.normalA,x),m(Y.contactPointA,Y.contactPointA,a),g(Y.contactPointA,Y.contactPointA,e.position),g(Y.contactPointB,S,d),m(Y.contactPointB,Y.contactPointB,d),g(Y.contactPointB,Y.contactPointB,n.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}return 0};var ee=h.create(),te=h.create(),ae=h.create(),oe=h.create();s.prototype[P.PARTICLE|P.CONVEX]=s.prototype[P.PARTICLE|P.BOX]=s.prototype.particleConvex=function(e,t,a,o,r,n,s,d,f){var x=E,b=R,_=L,v=B,T=F,C=I,P=N,S=H,w=q,A=u,M=!1,O=n.vertices;if(!p(a,n,s,d))return 0;if(f)return!0;for(var U=0;U!==O.length+1;U++){var i=O[U%O.length],G=O[(U+1)%O.length];h.rotate(x,i,d),h.rotate(b,G,d),m(x,x,s),m(b,b,s),g(_,b,x),h.normalize(v,_),h.rotate90cw(T,v),g(C,a,x);y(C,T);g(k,x,s),g(D,a,s),h.sub(S,x,a);var W=l(h.dot(S,T));W<A&&(A=W,h.scale(P,T,W),h.add(P,P,a),h.copy(w,T),M=!0)}if(M){var X=this.createContactEquation(e,r,t,n);return h.scale(X.normalA,w,-1),h.normalize(X.normalA,X.normalA),h.set(X.contactPointA,0,0),m(X.contactPointA,X.contactPointA,a),g(X.contactPointA,X.contactPointA,e.position),g(X.contactPointB,P,s),m(X.contactPointB,X.contactPointB,s),g(X.contactPointB,X.contactPointB,r.position),this.contactEquations.push(X),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(X)),1}return 0},s.prototype[P.CIRCLE]=s.prototype.circleCircle=function(e,t,a,r,n,i,s,d,l,p,u){var y=E,p=p||t.radius,u=u||i.radius;g(y,a,s);if(h.squaredLength(y)>o(p+u,2))return 0;if(l)return!0;var f=this.createContactEquation(e,n,t,i);return g(f.normalA,s,a),h.normalize(f.normalA,f.normalA),h.scale(f.contactPointA,f.normalA,p),h.scale(f.contactPointB,f.normalA,-u),m(f.contactPointA,f.contactPointA,a),g(f.contactPointA,f.contactPointA,e.position),m(f.contactPointB,f.contactPointB,s),g(f.contactPointB,f.contactPointB,n.position),this.contactEquations.push(f),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(f)),1},s.prototype[P.PLANE|P.CONVEX]=s.prototype[P.PLANE|P.BOX]=s.prototype.planeConvex=function(e,t,a,o,r,n,s,l,p){var u=E,f=R,x=L,b=0;h.rotate(f,A,o);for(var _=0,i;_!==n.vertices.length;_++)if(i=n.vertices[_],h.rotate(u,i,l),m(u,u,s),g(x,u,a),0>=y(x,f)){if(p)return!0;b++;var v=this.createContactEquation(e,r,t,n);g(x,u,a),h.copy(v.normalA,f);var c=y(x,v.normalA);h.scale(x,v.normalA,c),g(v.contactPointB,u,r.position),g(v.contactPointA,u,x),g(v.contactPointA,v.contactPointA,e.position),this.contactEquations.push(v),!this.enableFrictionReduction&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v))}return this.enableFrictionReduction&&this.enableFriction&&b&&this.frictionEquations.push(this.createFrictionFromAverage(b)),b},s.prototype[P.PARTICLE|P.PLANE]=s.prototype.particlePlane=function(e,t,a,o,r,n,i,s,l){var p=E,u=R;s=s||0,g(p,a,i),h.rotate(u,A,s);var m=y(p,u);if(0<m)return 0;if(l)return!0;var d=this.createContactEquation(r,e,n,t);return h.copy(d.normalA,u),h.scale(p,d.normalA,m),g(d.contactPointA,a,p),g(d.contactPointA,d.contactPointA,r.position),g(d.contactPointB,a,e.position),this.contactEquations.push(d),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d)),1},s.prototype[P.CIRCLE|P.PARTICLE]=s.prototype.circleParticle=function(e,t,a,r,n,i,s,d,l){var p=E;if(g(p,s,a),h.squaredLength(p)>o(t.radius,2))return 0;if(l)return!0;var u=this.createContactEquation(e,n,t,i);return h.copy(u.normalA,p),h.normalize(u.normalA,u.normalA),h.scale(u.contactPointA,u.normalA,t.radius),m(u.contactPointA,u.contactPointA,a),g(u.contactPointA,u.contactPointA,e.position),g(u.contactPointB,s,n.position),this.contactEquations.push(u),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(u)),1};var re=new T({radius:1}),ne=h.create(),ie=h.create(),se=h.create();s.prototype[P.PLANE|P.CAPSULE]=s.prototype.planeCapsule=function(e,t,a,o,r,n,i,s,d){var l=ne,p=ie,c=re;h.set(l,-n.length/2,0),h.rotate(l,l,s),m(l,l,i),h.set(p,n.length/2,0),h.rotate(p,p,s),m(p,p,i),c.radius=n.radius;var u;this.enableFrictionReduction&&(u=this.enableFriction,this.enableFriction=!1);var g=this.circlePlane(r,c,l,0,e,t,a,o,d),y=this.circlePlane(r,c,p,0,e,t,a,o,d);if(this.enableFrictionReduction&&(this.enableFriction=u),d)return g||y;var f=g+y;return this.enableFrictionReduction&&f&&this.frictionEquations.push(this.createFrictionFromAverage(f)),f},s.prototype[P.CIRCLE|P.PLANE]=s.prototype.circlePlane=function(e,t,a,o,r,n,i,s,l){var p=e,c=t,u=a,f=r,x=i,b=s;b=b||0;var _=E,v=R,T=L;g(_,u,x),h.rotate(v,A,b);var C=y(v,_);if(C>c.radius)return 0;if(l)return!0;var d=this.createContactEquation(f,p,n,t);return h.copy(d.normalA,v),h.scale(d.contactPointB,d.normalA,-c.radius),m(d.contactPointB,d.contactPointB,u),g(d.contactPointB,d.contactPointB,p.position),h.scale(T,d.normalA,C),g(d.contactPointA,_,T),m(d.contactPointA,d.contactPointA,x),g(d.contactPointA,d.contactPointA,f.position),this.contactEquations.push(d),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d)),1},s.prototype[P.CONVEX]=s.prototype[P.CONVEX|P.BOX]=s.prototype[P.BOX]=s.prototype.convexConvex=function(e,t,a,o,r,n,l,p,u,f){var x=E,b=R,_=L,T=B,C=F,P=D,S=M,w=O,A=0,f="number"==typeof f?f:0,I=s.findSeparatingAxis(t,a,o,n,l,p,x);if(!I)return 0;g(S,l,a),0<y(x,S)&&h.scale(x,x,-1);var U=s.getClosestEdge(t,o,x,!0),G=s.getClosestEdge(n,p,x);if(-1===U||-1===G)return 0;for(var N=0;2>N;N++){var k=U,W=G,X=t,V=n,H=a,q=l,Y=o,z=p,K=e,J=r;if(0===N){var Q;Q=k,k=W,W=Q,Q=X,X=V,V=Q,Q=H,H=q,q=Q,Q=Y,Y=z,z=Q,Q=K,K=J,J=Q}for(var Z=W,j;Z<W+2;Z++){j=V.vertices[(Z+V.vertices.length)%V.vertices.length],h.rotate(b,j,z),m(b,b,q);for(var v=0,$=k-1;$<k+2;$++){var i=X.vertices[($+X.vertices.length)%X.vertices.length],ee=X.vertices[($+1+X.vertices.length)%X.vertices.length];h.rotate(_,i,Y),h.rotate(T,ee,Y),m(_,_,H),m(T,T,H),g(C,T,_),h.rotate90cw(w,C),h.normalize(w,w),g(S,b,_);var te=y(w,S);($===k&&te<=f||$!==k&&0>=te)&&v++}if(3<=v){if(u)return!0;var d=this.createContactEquation(K,J,X,V);A++;var i=X.vertices[k%X.vertices.length],ee=X.vertices[(k+1)%X.vertices.length];h.rotate(_,i,Y),h.rotate(T,ee,Y),m(_,_,H),m(T,T,H),g(C,T,_),h.rotate90cw(d.normalA,C),h.normalize(d.normalA,d.normalA),g(S,b,_);var te=y(d.normalA,S);h.scale(P,d.normalA,te),g(d.contactPointA,b,H),g(d.contactPointA,d.contactPointA,P),m(d.contactPointA,d.contactPointA,H),g(d.contactPointA,d.contactPointA,K.position),g(d.contactPointB,b,q),m(d.contactPointB,d.contactPointB,q),g(d.contactPointB,d.contactPointB,J.position),this.contactEquations.push(d),!this.enableFrictionReduction&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d))}}}return this.enableFrictionReduction&&this.enableFriction&&A&&this.frictionEquations.push(this.createFrictionFromAverage(A)),A};var de=h.fromValues(0,0);s.projectConvexOntoAxis=function(e,a,o,r,n){var s=null,d=null,l=de,p,c;h.rotate(l,r,-o);for(var u=0;u<e.vertices.length;u++)p=e.vertices[u],c=y(p,l),(null==s||c>s)&&(s=c),(null==d||c<d)&&(d=c);if(d>s){var i=d;d=s,s=i}var t=y(a,r);h.set(n,d+t,s+t)};var le=h.fromValues(0,0),pe=h.fromValues(0,0),ce=h.fromValues(0,0),ue=h.fromValues(0,0),he=h.fromValues(0,0),ge=h.fromValues(0,0);s.findSeparatingAxis=function(e,t,o,r,n,d,l){var p=null,u=!1,m=!1,y=le,f=pe,x=ce,_=ue,v=he,T=ge;if(e instanceof w&&r instanceof w)for(var C=0;2!==C;C++){var P=e,c=o;1===C&&(P=r,c=d);for(var S=0;2!==S;S++){0===S?h.set(_,0,1):1===S&&h.set(_,1,0),0!==c&&h.rotate(_,_,c),s.projectConvexOntoAxis(e,t,o,_,v),s.projectConvexOntoAxis(r,n,d,_,T);var i=v,a=T,b=!1;v[0]>T[0]&&(a=v,i=T,b=!0);var A=a[0]-i[1];u=0>=A,(null==p||A>p)&&(h.copy(l,_),p=A,m=u)}}else for(var C=0;2!==C;C++){var P=e,c=o;1===C&&(P=r,c=d);for(var S=0;S!==P.vertices.length;S++){h.rotate(f,P.vertices[S],c),h.rotate(x,P.vertices[(S+1)%P.vertices.length],c),g(y,x,f),h.rotate90cw(_,y),h.normalize(_,_),s.projectConvexOntoAxis(e,t,o,_,v),s.projectConvexOntoAxis(r,n,d,_,T);var i=v,a=T,b=!1;v[0]>T[0]&&(a=v,i=T,b=!0);var A=a[0]-i[1];u=0>=A,(null==p||A>p)&&(h.copy(l,_),p=A,m=u)}}return m};var me=h.fromValues(0,0),ye=h.fromValues(0,0),fe=h.fromValues(0,0);s.getClosestEdge=function(e,t,a,o){var r=me,n=ye,s=fe;h.rotate(r,a,-t),o&&h.scale(r,r,-1);for(var l=-1,p=e.vertices.length,c=-1,u=0;u!==p;u++){g(n,e.vertices[(u+1)%p],e.vertices[u%p]),h.rotate90cw(s,n),h.normalize(s,s);var i=y(s,r);(-1==l||i>c)&&(l=u%p,c=i)}return l};var xe=h.create(),be=h.create(),_e=h.create(),ve=h.create(),Te=h.create(),Ce=h.create(),Pe=h.create();s.prototype[P.CIRCLE|P.HEIGHTFIELD]=s.prototype.circleHeightfield=function(r,n,s,l,p,u,y,f,x,b){var _=u.heights,b=b||n.radius,v=u.elementWidth,T=be,C=xe,P=Te,S=Pe,w=Ce,A=_e,E=ve,R=a((s[0]-b-y[0])/v),L=t((s[0]+b-y[0])/v);0>R&&(R=0),L>=_.length&&(L=_.length-1);for(var B=_[R],k=_[L],F=R;F<L;F++)_[F]<k&&(k=_[F]),_[F]>B&&(B=_[F]);if(!(s[1]-b>B)){for(var i=!1,F=R;F<L;F++){h.set(A,F*v,_[F]),h.set(E,(F+1)*v,_[F+1]),h.add(A,A,y),h.add(E,E,y),h.sub(w,E,A),h.rotate(w,w,e/2),h.normalize(w,w),h.scale(C,w,-b),h.add(C,C,s),h.sub(T,C,A);var D=h.dot(T,w);if(C[0]>=A[0]&&C[0]<E[0]&&0>=D){if(x)return!0;i=!0,h.scale(T,w,-D),h.add(P,C,T),h.copy(S,w);var M=this.createContactEquation(p,r,u,n);h.copy(M.normalA,S),h.scale(M.contactPointB,M.normalA,-b),m(M.contactPointB,M.contactPointB,s),g(M.contactPointB,M.contactPointB,r.position),h.copy(M.contactPointA,P),h.sub(M.contactPointA,M.contactPointA,p.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}if(i=!1,0<b)for(var F=R;F<=L;F++)if(h.set(A,F*v,_[F]),h.add(A,A,y),h.sub(T,s,A),h.squaredLength(T)<o(b,2)){if(x)return!0;i=!0;var M=this.createContactEquation(p,r,u,n);h.copy(M.normalA,T),h.normalize(M.normalA,M.normalA),h.scale(M.contactPointB,M.normalA,-b),m(M.contactPointB,M.contactPointB,s),g(M.contactPointB,M.contactPointB,r.position),g(M.contactPointA,A,y),m(M.contactPointA,M.contactPointA,y),g(M.contactPointA,M.contactPointA,p.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}return i?1:0}};var Se=h.create(),we=h.create(),Ae=h.create(),Ee=new C({vertices:[h.create(),h.create(),h.create(),h.create()]});s.prototype[P.BOX|P.HEIGHTFIELD]=s.prototype[P.CONVEX|P.HEIGHTFIELD]=s.prototype.convexHeightfield=function(e,o,r,n,s,d,l,p,c){var u=d.heights,g=d.elementWidth,m=Se,y=we,f=Ae,x=Ee,b=a((e.aabb.lowerBound[0]-l[0])/g),_=t((e.aabb.upperBound[0]-l[0])/g);0>b&&(b=0),_>=u.length&&(_=u.length-1);for(var v=u[b],T=u[_],C=b;C<_;C++)u[C]<T&&(T=u[C]),u[C]>v&&(v=u[C]);if(!(e.aabb.lowerBound[1]>v)){for(var i=0,C=b;C<_;C++){h.set(m,C*g,u[C]),h.set(y,(C+1)*g,u[C+1]),h.add(m,m,l),h.add(y,y,l);var P=100;h.set(f,0.5*(y[0]+m[0]),0.5*(y[1]+m[1]-P)),h.sub(x.vertices[0],y,f),h.sub(x.vertices[1],m,f),h.copy(x.vertices[2],x.vertices[1]),h.copy(x.vertices[3],x.vertices[0]),x.vertices[2][1]-=P,x.vertices[3][1]-=P,i+=this.convexConvex(e,o,r,n,s,x,f,0,c)}return i}}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(e,t){function a(e){e=e||{},this.from=e.from?r.fromValues(e.from[0],e.from[1]):r.create(),this.to=e.to?r.fromValues(e.to[0],e.to[1]):r.create(),this.checkCollisionResponse=!(e.checkCollisionResponse!==void 0)||e.checkCollisionResponse,this.skipBackfaces=!!e.skipBackfaces,this.collisionMask=e.collisionMask===void 0?-1:e.collisionMask,this.collisionGroup=e.collisionGroup===void 0?-1:e.collisionGroup,this.mode=e.mode===void 0?a.ANY:e.mode,this.callback=e.callback||function(){},this.direction=r.create(),this.length=1,this.update()}function o(e,t,a){r.sub(c,a,e);var o=r.dot(c,t);return r.scale(u,t,o),r.add(u,u,e),r.squaredDistance(a,u)}t.exports=a;var r=e("../math/vec2"),i=e("../collision/RaycastResult"),d=e("../shapes/Shape"),l=e("../collision/AABB");a.prototype.constructor=a,a.CLOSEST=1,a.ANY=2,a.ALL=4,a.prototype.update=function(){var e=this.direction;r.sub(e,this.to,this.from),this.length=r.length(e),r.normalize(e,e)},a.prototype.intersectBodies=function(e,t){for(var a=0,o=t.length;!e.shouldStop(this)&&a<o;a++){var r=t[a],n=r.getAABB();(0<=n.overlapsRay(this)||n.containsPoint(this.from))&&this.intersectBody(e,r)}};var p=r.create();a.prototype.intersectBody=function(e,t){var a=this.checkCollisionResponse;if(!a||t.collisionResponse)for(var o=p,n=0,i=t.shapes.length,s;n<i;n++)if((s=t.shapes[n],!a||s.collisionResponse)&&0!=(this.collisionGroup&s.collisionMask)&&0!=(s.collisionGroup&this.collisionMask)){r.rotate(o,s.position,t.angle),r.add(o,o,t.position);var d=s.angle+t.angle;if(this.intersectShape(e,s,d,o,t),e.shouldStop(this))break}},a.prototype.intersectShape=function(e,t,a,r,n){var i=this.from,s=o(i,this.direction,r);s>t.boundingRadius*t.boundingRadius||(this._currentBody=n,this._currentShape=t,t.raycast(e,this,r,a),this._currentBody=this._currentShape=null)},a.prototype.getAABB=function(e){var t=this.to,a=this.from;r.set(e.lowerBound,s(t[0],a[0]),s(t[1],a[1])),r.set(e.upperBound,n(t[0],a[0]),n(t[1],a[1]))};r.create();a.prototype.reportIntersection=function(e,t,o,n){var i=this.from,s=this.to,d=this._currentShape,l=this._currentBody;if(!(this.skipBackfaces&&0<r.dot(o,this.direction)))switch(this.mode){case a.ALL:e.set(o,d,l,t,n),this.callback(e);break;case a.CLOSEST:(t<e.fraction||!e.hasHit())&&e.set(o,d,l,t,n);break;case a.ANY:e.set(o,d,l,t,n);}};var c=r.create(),u=r.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(e,t){function a(){this.normal=o.create(),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1}var o=e("../math/vec2"),r=e("../collision/Ray");t.exports=a,a.prototype.reset=function(){o.set(this.normal,0,0),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1},a.prototype.getHitDistance=function(e){return o.distance(e.from,e.to)*this.fraction},a.prototype.hasHit=function(){return-1!==this.fraction},a.prototype.getHitPoint=function(e,t){o.lerp(e,t.from,t.to,this.fraction)},a.prototype.stop=function(){this.isStopped=!0},a.prototype.shouldStop=function(e){return this.isStopped||-1!==this.fraction&&e.mode===r.ANY},a.prototype.set=function(e,t,a,r,n){o.copy(this.normal,e),this.shape=t,this.body=a,this.fraction=r,this.faceIndex=n}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(e,t){function a(){r.call(this,r.SAP),this.axisList=[],this.axisIndex=0;var t=this;this._addBodyHandler=function(a){t.axisList.push(a.body)},this._removeBodyHandler=function(a){var e=t.axisList.indexOf(a.body);-1!==e&&t.axisList.splice(e,1)}}var o=e("../utils/Utils"),r=e("../collision/Broadphase");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.setWorld=function(e){this.axisList.length=0,o.appendArray(this.axisList,e.bodies),e.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),e.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=e},a.sortAxisList=function(e,t){t|=0;for(var a=1,o=e.length,r;a<o;a++){r=e[a];for(var n=a-1;0<=n&&!(e[n].aabb.lowerBound[t]<=r.aabb.lowerBound[t]);n--)e[n+1]=e[n];e[n+1]=r}return e},a.prototype.sortList=function(){var e=this.axisList,t=this.axisIndex;a.sortAxisList(e,t)},a.prototype.getCollisionPairs=function(){var e=this.axisList,t=this.result,a=this.axisIndex;t.length=0;for(var o=e.length;o--;){var n=e[o];n.aabbNeedsUpdate&&n.updateAABB()}this.sortList();for(var s=0,i=0|e.length,d;s!==i;s++){d=e[s];for(var l=s+1;l<i;l++){var p=e[l],c=p.aabb.lowerBound[a]<=d.aabb.upperBound[a];if(!c)break;r.canCollide(d,p)&&this.boundingVolumeCheck(d,p)&&t.push(d,p)}}return t},a.prototype.aabbQuery=function(e,t,a){a=a||[],this.sortList();var o=this.axisIndex,r="x";1===o&&(r="y"),2===o&&(r="z");for(var n=this.axisList,s=t.lowerBound[r],d=t.upperBound[r],l=0,i;l<n.length;l++)i=n[l],i.aabbNeedsUpdate&&i.updateAABB(),i.aabb.overlaps(t)&&a.push(i);return a}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(e,t){function a(e,t,a,r){this.type=a,r=o.defaults(r,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=e,this.bodyB=t,this.collideConnected=r.collideConnected,r.wakeUpBodies&&(e&&e.wakeUp(),t&&t.wakeUp())}t.exports=a;var o=e("../utils/Utils");a.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},a.DISTANCE=1,a.GEAR=2,a.LOCK=3,a.PRISMATIC=4,a.REVOLUTE=5,a.prototype.setStiffness=function(e){for(var t=this.equations,a=0,o;a!==t.length;a++)o=t[a],o.stiffness=e,o.needsUpdate=!0},a.prototype.setRelaxation=function(e){for(var t=this.equations,a=0,o;a!==t.length;a++)o=t[a],o.relaxation=e,o.needsUpdate=!0}},{"../utils/Utils":57}],15:[function(e,t){function a(e,t,a){a=d.defaults(a,{localAnchorA:[0,0],localAnchorB:[0,0]}),o.call(this,e,t,o.DISTANCE,a),this.localAnchorA=s.fromValues(a.localAnchorA[0],a.localAnchorA[1]),this.localAnchorB=s.fromValues(a.localAnchorB[0],a.localAnchorB[1]);var n=this.localAnchorA,l=this.localAnchorB;if(this.distance=0,"number"==typeof a.distance)this.distance=a.distance;else{var p=s.create(),c=s.create(),h=s.create();s.rotate(p,n,e.angle),s.rotate(c,l,t.angle),s.add(h,t.position,c),s.sub(h,h,p),s.sub(h,h,e.position),this.distance=s.length(h)}var r="undefined"==typeof a.maxForce?u:a.maxForce;var g=new i(e,t,-r,r);this.equations=[g],this.maxForce=r;var h=s.create(),m=s.create(),y=s.create(),f=this;g.computeGq=function(){var e=this.bodyA,t=this.bodyB,a=e.position,o=t.position;return s.rotate(m,n,e.angle),s.rotate(y,l,t.angle),s.add(h,o,y),s.sub(h,h,m),s.sub(h,h,a),s.length(h)-f.distance},this.setMaxForce(r),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var o=e("./Constraint"),i=e("../equations/Equation"),s=e("../math/vec2"),d=e("../utils/Utils");t.exports=a,a.prototype=new o,a.prototype.constructor=a;var r=s.create(),n=s.create(),l=s.create();a.prototype.update=function(){var e=this.equations[0],t=this.bodyA,a=this.bodyB,o=this.distance,i=t.position,d=a.position,p=this.equations[0],c=e.G;s.rotate(n,this.localAnchorA,t.angle),s.rotate(l,this.localAnchorB,a.angle),s.add(r,d,l),s.sub(r,r,n),s.sub(r,r,i),this.position=s.length(r);var u=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(p.maxForce=0,p.minForce=-this.maxForce,this.distance=this.upperLimit,u=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(p.maxForce=this.maxForce,p.minForce=0,this.distance=this.lowerLimit,u=!0),(this.lowerLimitEnabled||this.upperLimitEnabled)&&!u)return void(p.enabled=!1);p.enabled=!0,s.normalize(r,r);var h=s.crossLength(n,r),g=s.crossLength(l,r);c[0]=-r[0],c[1]=-r[1],c[2]=-h,c[3]=r[0],c[4]=r[1],c[5]=g},a.prototype.setMaxForce=function(e){var t=this.equations[0];t.minForce=-e,t.maxForce=e},a.prototype.getMaxForce=function(){var e=this.equations[0];return e.maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(e,t){function a(e,t,a){a=a||{},o.call(this,e,t,o.GEAR,a),this.ratio=a.ratio===void 0?1:a.ratio,this.angle=a.angle===void 0?t.angle-this.ratio*e.angle:a.angle,a.angle=this.angle,a.ratio=this.ratio,this.equations=[new n(e,t,a)],a.maxTorque!==void 0&&this.setMaxTorque(a.maxTorque)}var o=e("./Constraint"),r=e("../equations/Equation"),n=e("../equations/AngleLockEquation"),i=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a,a.prototype.update=function(){var e=this.equations[0];e.ratio!==this.ratio&&e.setRatio(this.ratio),e.angle=this.angle},a.prototype.setMaxTorque=function(e){this.equations[0].setMaxTorque(e)},a.prototype.getMaxTorque=function(){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(a,o){function n(a,o,n){n=n||{},i.call(this,a,o,i.LOCK,n);var p="undefined"==typeof n.maxForce?u:n.maxForce,c=n.localAngleB||0,h=new d(a,o,-p,p),m=new d(a,o,-p,p),y=new d(a,o,-p,p),f=s.create(),l=s.create(),g=this;h.computeGq=function(){return s.rotate(f,g.localOffsetB,a.angle),s.sub(l,o.position,a.position),s.sub(l,l,f),l[0]},m.computeGq=function(){return s.rotate(f,g.localOffsetB,a.angle),s.sub(l,o.position,a.position),s.sub(l,l,f),l[1]};var x=s.create(),r=s.create();y.computeGq=function(){return s.rotate(x,g.localOffsetB,o.angle-g.localAngleB),s.scale(x,x,-1),s.sub(l,a.position,o.position),s.add(l,l,x),s.rotate(r,x,-e/2),s.normalize(r,r),s.dot(l,r)},this.localOffsetB=s.create(),n.localOffsetB?s.copy(this.localOffsetB,n.localOffsetB):(s.sub(this.localOffsetB,o.position,a.position),s.rotate(this.localOffsetB,this.localOffsetB,-a.angle)),this.localAngleB=0,this.localAngleB="number"==typeof n.localAngleB?n.localAngleB:o.angle-a.angle,this.equations.push(h,m,y),this.setMaxForce(p)}var i=a("./Constraint"),s=a("../math/vec2"),d=a("../equations/Equation");o.exports=n,n.prototype=new i,n.prototype.constructor=n,n.prototype.setMaxForce=function(e){for(var t=this.equations,a=0;a<this.equations.length;a++)t[a].maxForce=e,t[a].minForce=-e},n.prototype.getMaxForce=function(){return this.equations[0].maxForce};var p=s.create(),l=s.create(),r=s.create(),t=s.fromValues(1,0),c=s.fromValues(0,1);n.prototype.update=function(){var a=this.equations[0],o=this.equations[1],n=this.equations[2],i=this.bodyA,d=this.bodyB;s.rotate(p,this.localOffsetB,i.angle),s.rotate(l,this.localOffsetB,d.angle-this.localAngleB),s.scale(l,l,-1),s.rotate(r,l,e/2),s.normalize(r,r),a.G[0]=-1,a.G[1]=0,a.G[2]=-s.crossLength(p,t),a.G[3]=1,o.G[0]=0,o.G[1]=-1,o.G[2]=-s.crossLength(p,c),o.G[4]=1,n.G[0]=-r[0],n.G[1]=-r[1],n.G[3]=r[0],n.G[4]=r[1],n.G[5]=s.crossLength(l,r)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(t,a){function o(a,o,l){l=l||{},r.call(this,a,o,r.PRISMATIC,l);var p=s.fromValues(0,0),c=s.fromValues(1,0),h=s.fromValues(0,0);l.localAnchorA&&s.copy(p,l.localAnchorA),l.localAxisA&&s.copy(c,l.localAxisA),l.localAnchorB&&s.copy(h,l.localAnchorB),this.localAnchorA=p,this.localAnchorB=h,this.localAxisA=c;var g=this.maxForce="undefined"==typeof l.maxForce?u:l.maxForce,m=new i(a,o,-g,g),y=new s.create,f=new s.create,x=new s.create,b=new s.create;if(m.computeGq=function(){return s.dot(x,b)},m.updateJacobian=function(){var t=this.G,r=a.position,n=o.position;s.rotate(y,p,a.angle),s.rotate(f,h,o.angle),s.add(x,n,f),s.sub(x,x,r),s.sub(x,x,y),s.rotate(b,c,a.angle+e/2),t[0]=-b[0],t[1]=-b[1],t[2]=-s.crossLength(y,b)+s.crossLength(b,x),t[3]=b[0],t[4]=b[1],t[5]=s.crossLength(f,b)},this.equations.push(m),!l.disableRotationalLock){var t=new d(a,o,-g,g);this.equations.push(t)}this.position=0,this.velocity=0,this.lowerLimitEnabled="undefined"!=typeof l.lowerLimit,this.upperLimitEnabled="undefined"!=typeof l.upperLimit,this.lowerLimit="undefined"==typeof l.lowerLimit?0:l.lowerLimit,this.upperLimit="undefined"==typeof l.upperLimit?1:l.upperLimit,this.upperLimitEquation=new n(a,o),this.lowerLimitEquation=new n(a,o),this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0,this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=g,this.motorEquation=new i(a,o),this.motorEnabled=!1,this.motorSpeed=0;var _=this,v=this.motorEquation,T=v.computeGW;v.computeGq=function(){return 0},v.computeGW=function(){var e=this.G,t=this.bodyA,a=this.bodyB,o=t.velocity,r=a.velocity,n=t.angularVelocity,i=a.angularVelocity;return this.gmult(e,o,n,r,i)+_.motorSpeed}}var r=t("./Constraint"),n=t("../equations/ContactEquation"),i=t("../equations/Equation"),s=t("../math/vec2"),d=t("../equations/RotationalLockEquation");a.exports=o,o.prototype=new r,o.prototype.constructor=o;var l=s.create(),p=s.create(),c=s.create(),h=s.create(),g=s.create(),m=s.create();o.prototype.update=function(){var e=this.equations,t=e[0],a=this.upperLimit,o=this.lowerLimit,r=this.upperLimitEquation,n=this.lowerLimitEquation,i=this.bodyA,d=this.bodyB,u=this.localAxisA,y=this.localAnchorA,f=this.localAnchorB;t.updateJacobian(),s.rotate(l,u,i.angle),s.rotate(h,y,i.angle),s.add(p,h,i.position),s.rotate(g,f,d.angle),s.add(c,g,d.position);var x=this.position=s.dot(c,l)-s.dot(p,l);if(this.motorEnabled){var b=this.motorEquation.G;b[0]=l[0],b[1]=l[1],b[2]=s.crossLength(l,g),b[3]=-l[0],b[4]=-l[1],b[5]=-s.crossLength(l,h)}if(this.upperLimitEnabled&&x>a)s.scale(r.normalA,l,-1),s.sub(r.contactPointA,p,i.position),s.sub(r.contactPointB,c,d.position),s.scale(m,l,a),s.add(r.contactPointA,r.contactPointA,m),-1===e.indexOf(r)&&e.push(r);else{var _=e.indexOf(r);-1!==_&&e.splice(_,1)}if(this.lowerLimitEnabled&&x<o)s.scale(n.normalA,l,1),s.sub(n.contactPointA,p,i.position),s.sub(n.contactPointB,c,d.position),s.scale(m,l,o),s.sub(n.contactPointB,n.contactPointB,m),-1===e.indexOf(n)&&e.push(n);else{var _=e.indexOf(n);-1!==_&&e.splice(_,1)}},o.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},o.prototype.disableMotor=function(){if(this.motorEnabled){var e=this.equations.indexOf(this.motorEquation);this.equations.splice(e,1),this.motorEnabled=!1}},o.prototype.setLimits=function(e,t){"number"==typeof e?(this.lowerLimit=e,this.lowerLimitEnabled=!0):(this.lowerLimit=e,this.lowerLimitEnabled=!1),"number"==typeof t?(this.upperLimit=t,this.upperLimitEnabled=!0):(this.upperLimit=t,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(e,t){function a(e,t,a){a=a||{},o.call(this,e,t,o.REVOLUTE,a);var g=this.maxForce="undefined"==typeof a.maxForce?u:a.maxForce;this.pivotA=s.create(),this.pivotB=s.create(),a.worldPivot?(s.sub(this.pivotA,a.worldPivot,e.position),s.sub(this.pivotB,a.worldPivot,t.position),s.rotate(this.pivotA,this.pivotA,-e.angle),s.rotate(this.pivotB,this.pivotB,-t.angle)):(s.copy(this.pivotA,a.localPivotA),s.copy(this.pivotB,a.localPivotB));var m=this.equations=[new r(e,t,-g,g),new r(e,t,-g,g)],f=m[0],x=m[1],y=this;f.computeGq=function(){return s.rotate(d,y.pivotA,e.angle),s.rotate(l,y.pivotB,t.angle),s.add(h,t.position,l),s.sub(h,h,e.position),s.sub(h,h,d),s.dot(h,p)},x.computeGq=function(){return s.rotate(d,y.pivotA,e.angle),s.rotate(l,y.pivotB,t.angle),s.add(h,t.position,l),s.sub(h,h,e.position),s.sub(h,h,d),s.dot(h,c)},x.minForce=f.minForce=-g,x.maxForce=f.maxForce=g,this.motorEquation=new n(e,t),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new i(e,t),this.lowerLimitEquation=new i(e,t),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var o=e("./Constraint"),r=e("../equations/Equation"),n=e("../equations/RotationalVelocityEquation"),i=e("../equations/RotationalLockEquation"),s=e("../math/vec2");t.exports=a;var d=s.create(),l=s.create(),p=s.fromValues(1,0),c=s.fromValues(0,1),h=s.create();a.prototype=new o,a.prototype.constructor=a,a.prototype.setLimits=function(e,t){"number"==typeof e?(this.lowerLimit=e,this.lowerLimitEnabled=!0):(this.lowerLimit=e,this.lowerLimitEnabled=!1),"number"==typeof t?(this.upperLimit=t,this.upperLimitEnabled=!0):(this.upperLimit=t,this.upperLimitEnabled=!1)},a.prototype.update=function(){var e=this.bodyA,t=this.bodyB,a=this.pivotA,o=this.pivotB,r=this.equations,n=r[0],i=r[1],u=r[0],h=r[1],g=this.upperLimit,m=this.lowerLimit,y=this.upperLimitEquation,f=this.lowerLimitEquation,x=this.angle=t.angle-e.angle;if(this.upperLimitEnabled&&x>g)y.angle=g,-1===r.indexOf(y)&&r.push(y);else{var b=r.indexOf(y);-1!==b&&r.splice(b,1)}if(this.lowerLimitEnabled&&x<m)f.angle=m,-1===r.indexOf(f)&&r.push(f);else{var b=r.indexOf(f);-1!==b&&r.splice(b,1)}s.rotate(d,a,e.angle),s.rotate(l,o,t.angle),u.G[0]=-1,u.G[1]=0,u.G[2]=-s.crossLength(d,p),u.G[3]=1,u.G[4]=0,u.G[5]=s.crossLength(l,p),h.G[0]=0,h.G[1]=-1,h.G[2]=-s.crossLength(d,c),h.G[3]=0,h.G[4]=1,h.G[5]=s.crossLength(l,c)},a.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},a.prototype.disableMotor=function(){if(this.motorEnabled){var e=this.equations.indexOf(this.motorEquation);this.equations.splice(e,1),this.motorEnabled=!1}},a.prototype.motorIsEnabled=function(){return!!this.motorEnabled},a.prototype.setMotorSpeed=function(e){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations[t].relativeVelocity=e}},a.prototype.getMotorSpeed=function(){return!!this.motorEnabled&&this.motorEquation.relativeVelocity}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(e,t){function a(e,t,a){a=a||{},o.call(this,e,t,-u,Number.MAX_VALUE),this.angle=a.angle||0,this.ratio="number"==typeof a.ratio?a.ratio:1,this.setRatio(this.ratio)}var o=e("./Equation"),r=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a,a.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},a.prototype.setRatio=function(e){var t=this.G;t[2]=e,t[5]=-1,this.ratio=e},a.prototype.setMaxTorque=function(e){this.maxForce=e,this.minForce=-e}},{"../math/vec2":30,"./Equation":22}],21:[function(e,t){function a(e,t){o.call(this,e,t,0,Number.MAX_VALUE),this.contactPointA=r.create(),this.penetrationVec=r.create(),this.contactPointB=r.create(),this.normalA=r.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var o=e("./Equation"),r=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a,a.prototype.computeB=function(e,t,a){var o=this.bodyA,i=this.bodyB,s=this.contactPointA,d=this.contactPointB,l=o.position,p=i.position,c=this.penetrationVec,u=this.normalA,n=this.G,h=r.crossLength(s,u),g=r.crossLength(d,u);n[0]=-u[0],n[1]=-u[1],n[2]=-h,n[3]=u[0],n[4]=u[1],n[5]=g,r.add(c,p,d),r.sub(c,c,l),r.sub(c,c,s);var m,y;this.firstImpact&&0!==this.restitution?(y=0,m=1/t*(1+this.restitution)*this.computeGW()):(y=r.dot(u,c)+this.offset,m=this.computeGW());var f=this.computeGiMf(),x=-y*e-m*t-a*f;return x};var n=r.create(),i=r.create(),s=r.create();a.prototype.getVelocityAlongNormal=function(){return this.bodyA.getVelocityAtPoint(n,this.contactPointA),this.bodyB.getVelocityAtPoint(i,this.contactPointB),r.subtract(s,n,i),r.dot(this.normalA,s)}},{"../math/vec2":30,"./Equation":22}],22:[function(e,t){function a(e,t,o,n){this.minForce="undefined"==typeof o?-u:o,this.maxForce="undefined"==typeof n?u:n,this.bodyA=e,this.bodyB=t,this.stiffness=a.DEFAULT_STIFFNESS,this.relaxation=a.DEFAULT_RELAXATION,this.G=new r.ARRAY_TYPE(6);for(var s=0;6>s;s++)this.G[s]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}t.exports=a;var o=e("../math/vec2"),r=e("../utils/Utils"),n=e("../objects/Body");a.prototype.constructor=a,a.DEFAULT_STIFFNESS=1e6,a.DEFAULT_RELAXATION=4,a.prototype.update=function(){var e=this.stiffness,t=this.relaxation,a=this.timeStep;this.a=4/(a*(1+4*t)),this.b=4*t/(1+4*t),this.epsilon=4/(a*a*e*(1+4*t)),this.needsUpdate=!1},a.prototype.gmult=function(e,t,a,o,r){return e[0]*t[0]+e[1]*t[1]+e[2]*a+e[3]*o[0]+e[4]*o[1]+e[5]*r},a.prototype.computeB=function(e,t,a){var o=this.computeGW(),r=this.computeGq(),n=this.computeGiMf();return-r*e-o*t-n*a};var i=o.create(),s=o.create();a.prototype.computeGq=function(){var e=this.G,t=this.bodyA,a=this.bodyB,o=t.position,r=a.position,n=t.angle,d=a.angle;return this.gmult(e,i,n,s,d)+this.offset},a.prototype.computeGW=function(){var e=this.G,t=this.bodyA,a=this.bodyB,o=t.velocity,r=a.velocity,n=t.angularVelocity,i=a.angularVelocity;return this.gmult(e,o,n,r,i)+this.relativeVelocity},a.prototype.computeGWlambda=function(){var e=this.G,t=this.bodyA,a=this.bodyB,o=t.vlambda,r=a.vlambda,n=t.wlambda,i=a.wlambda;return this.gmult(e,o,n,r,i)};var d=o.create(),l=o.create();a.prototype.computeGiMf=function(){var e=this.bodyA,t=this.bodyB,a=e.force,r=e.angularForce,n=t.force,i=t.angularForce,s=e.invMassSolve,p=t.invMassSolve,c=e.invInertiaSolve,u=t.invInertiaSolve,h=this.G;return o.scale(d,a,s),o.multiply(d,e.massMultiplier,d),o.scale(l,n,p),o.multiply(l,t.massMultiplier,l),this.gmult(h,d,r*c,l,i*u)},a.prototype.computeGiMGt=function(){var e=this.bodyA,t=this.bodyB,a=e.invMassSolve,o=t.invMassSolve,r=e.invInertiaSolve,n=t.invInertiaSolve,i=this.G;return i[0]*i[0]*a*e.massMultiplier[0]+i[1]*i[1]*a*e.massMultiplier[1]+i[2]*i[2]*r+i[3]*i[3]*o*t.massMultiplier[0]+i[4]*i[4]*o*t.massMultiplier[1]+i[5]*i[5]*n};var p=o.create(),c=o.create(),h=o.create(),g=o.create(),m=o.create(),y=o.create();a.prototype.addToWlambda=function(e){var t=this.bodyA,a=this.bodyB,r=p,n=c,i=h,s=t.invMassSolve,d=a.invMassSolve,l=t.invInertiaSolve,u=a.invInertiaSolve,g=this.G;n[0]=g[0],n[1]=g[1],i[0]=g[3],i[1]=g[4],o.scale(r,n,s*e),o.multiply(r,r,t.massMultiplier),o.add(t.vlambda,t.vlambda,r),t.wlambda+=l*g[2]*e,o.scale(r,i,d*e),o.multiply(r,r,a.massMultiplier),o.add(a.vlambda,a.vlambda,r),a.wlambda+=u*g[5]*e},a.prototype.computeInvC=function(e){return 1/(this.computeGiMGt()+e)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(e,t){function a(e,t,a){r.call(this,e,t,-a,a),this.contactPointA=o.create(),this.contactPointB=o.create(),this.t=o.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=0.3}var o=e("../math/vec2"),r=e("./Equation"),n=e("../utils/Utils");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.setSlipForce=function(e){this.maxForce=e,this.minForce=-e},a.prototype.getSlipForce=function(){return this.maxForce},a.prototype.computeB=function(e,a,r){var n=this.bodyA,i=this.bodyB,s=this.contactPointA,d=this.contactPointB,l=this.t,t=this.G;t[0]=-l[0],t[1]=-l[1],t[2]=-o.crossLength(s,l),t[3]=l[0],t[4]=l[1],t[5]=o.crossLength(d,l);var p=this.computeGW(),c=this.computeGiMf();return-p*a-r*c}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(e,t){function a(e,t,a){a=a||{},o.call(this,e,t,-u,Number.MAX_VALUE),this.angle=a.angle||0;var r=this.G;r[2]=1,r[5]=-1}var o=e("./Equation"),r=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a;var n=r.create(),i=r.create(),s=r.fromValues(1,0),d=r.fromValues(0,1);a.prototype.computeGq=function(){return r.rotate(n,s,this.bodyA.angle+this.angle),r.rotate(i,d,this.bodyB.angle),r.dot(n,i)}},{"../math/vec2":30,"./Equation":22}],25:[function(e,t){function a(e,t){o.call(this,e,t,-u,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var o=e("./Equation"),r=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a,a.prototype.computeB=function(e,t,a){var o=this.G;o[2]=-1,o[5]=this.ratio;var r=this.computeGiMf(),n=this.computeGW();return-n*t-a*r}},{"../math/vec2":30,"./Equation":22}],26:[function(e,t){var a=function(){};t.exports=a,a.prototype={constructor:a,on:function(e,t,a){t.context=a||this,void 0===this._listeners&&(this._listeners={});var o=this._listeners;return void 0===o[e]&&(o[e]=[]),-1===o[e].indexOf(t)&&o[e].push(t),this},has:function(e,t){if(this._listeners===void 0)return!1;var a=this._listeners;if(t){if(void 0!==a[e]&&-1!==a[e].indexOf(t))return!0;}else if(void 0!==a[e])return!0;return!1},off:function(e,t){if(void 0===this._listeners)return this;var a=this._listeners,o=a[e].indexOf(t);return-1!==o&&a[e].splice(o,1),this},emit:function(e){if(this._listeners===void 0)return this;var t=this._listeners,a=t[e.type];if(a!==void 0){e.target=this;for(var o=0,r=a.length,n;o<r;o++)n=a[o],n.call(n.context,e)}return this}}},{}],27:[function(e,t){function a(e,t,n){if(n=n||{},!(e instanceof o)||!(t instanceof o))throw new Error("First two arguments must be Material instances.");this.id=a.idCounter++,this.materialA=e,this.materialB=t,this.friction="undefined"==typeof n.friction?0.3:+n.friction,this.restitution="undefined"==typeof n.restitution?0:+n.restitution,this.stiffness="undefined"==typeof n.stiffness?r.DEFAULT_STIFFNESS:+n.stiffness,this.relaxation="undefined"==typeof n.relaxation?r.DEFAULT_RELAXATION:+n.relaxation,this.frictionStiffness="undefined"==typeof n.frictionStiffness?r.DEFAULT_STIFFNESS:+n.frictionStiffness,this.frictionRelaxation="undefined"==typeof n.frictionRelaxation?r.DEFAULT_RELAXATION:+n.frictionRelaxation,this.surfaceVelocity="undefined"==typeof n.surfaceVelocity?0:+n.surfaceVelocity,this.contactSkinSize=5e-3}var o=e("./Material"),r=e("../equations/Equation");t.exports=a,a.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(e,t){function a(e){this.id=e||a.idCounter++}t.exports=a,a.idCounter=0},{}],29:[function(e,t){var a={};a.GetArea=function(e){if(6>e.length)return 0;for(var t=e.length-2,a=0,o=0;o<t;o+=2)a+=(e[o+2]-e[o])*(e[o+1]+e[o+3]);return a+=(e[0]-e[t])*(e[t+1]+e[1]),0.5*-a},a.Triangulate=function(e){var t=e.length>>1;if(3>t)return[];for(var o=[],r=[],n=0;n<t;n++)r.push(n);for(var n=0,i=t;3<i;){var s=r[(n+0)%i],d=r[(n+1)%i],l=r[(n+2)%i],p=e[2*s],c=e[2*s+1],u=e[2*d],h=e[2*d+1],g=e[2*l],m=e[2*l+1],y=!1;if(a._convex(p,c,u,h,g,m)){y=!0;for(var f=0,x;f<i;f++)if(x=r[f],x!=s&&x!=d&&x!=l&&a._PointInTriangle(e[2*x],e[2*x+1],p,c,u,h,g,m)){y=!1;break}}if(y)o.push(s,d,l),r.splice((n+1)%i,1),i--,n=0;else if(n++>3*i)break}return o.push(r[0],r[1],r[2]),o},a._PointInTriangle=function(e,t,a,o,r,n,i,s){var d=i-a,l=s-o,p=r-a,c=n-o,h=e-a,g=t-o,m=d*d+l*l,y=d*p+l*c,f=d*h+l*g,x=p*p+c*c,b=p*h+c*g,_=1/(m*x-y*y),T=(x*f-y*b)*_,u=(m*b-y*f)*_;return 0<=T&&0<=u&&1>T+u},a._convex=function(e,t,a,o,r,n){return 0<=(t-o)*(r-a)+(a-e)*(n-o)},t.exports=a},{}],30:[function(t,a){var o=a.exports={},n=t("../utils/Utils");o.crossLength=function(e,t){return e[0]*t[1]-e[1]*t[0]},o.crossVZ=function(t,a,r){return o.rotate(t,a,-e/2),o.scale(t,t,r),t},o.crossZV=function(t,a,r){return o.rotate(t,r,e/2),o.scale(t,t,a),t},o.rotate=function(e,t,a){if(0!==a){var o=d(a),n=r(a),i=t[0],s=t[1];e[0]=o*i-n*s,e[1]=n*i+o*s}else e[0]=t[0],e[1]=t[1]},o.rotate90cw=function(e,t){var a=t[0],o=t[1];e[0]=o,e[1]=-a},o.toLocalFrame=function(e,t,a,r){o.copy(e,t),o.sub(e,e,a),o.rotate(e,e,-r)},o.toGlobalFrame=function(e,t,a,r){o.copy(e,t),o.rotate(e,e,r),o.add(e,e,a)},o.vectorToLocalFrame=function(e,t,a){o.rotate(e,t,-a)},o.vectorToGlobalFrame=function(e,t,a){o.rotate(e,t,a)},o.centroid=function(e,t,a,r){return o.add(e,t,a),o.add(e,e,r),o.scale(e,e,1/3),e},o.create=function(){var e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e},o.clone=function(e){var t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},o.fromValues=function(e,t){var a=new n.ARRAY_TYPE(2);return a[0]=e,a[1]=t,a},o.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},o.set=function(e,t,a){return e[0]=t,e[1]=a,e},o.add=function(e,t,a){return e[0]=t[0]+a[0],e[1]=t[1]+a[1],e},o.subtract=function(e,t,a){return e[0]=t[0]-a[0],e[1]=t[1]-a[1],e},o.sub=o.subtract,o.multiply=function(e,t,a){return e[0]=t[0]*a[0],e[1]=t[1]*a[1],e},o.mul=o.multiply,o.divide=function(e,t,a){return e[0]=t[0]/a[0],e[1]=t[1]/a[1],e},o.div=o.divide,o.scale=function(e,t,a){return e[0]=t[0]*a,e[1]=t[1]*a,e},o.distance=function(e,t){var a=t[0]-e[0],o=t[1]-e[1];return p(a*a+o*o)},o.dist=o.distance,o.squaredDistance=function(e,t){var a=t[0]-e[0],o=t[1]-e[1];return a*a+o*o},o.sqrDist=o.squaredDistance,o.length=function(e){var t=e[0],a=e[1];return p(t*t+a*a)},o.len=o.length,o.squaredLength=function(e){var t=e[0],a=e[1];return t*t+a*a},o.sqrLen=o.squaredLength,o.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},o.normalize=function(e,t){var a=t[0],o=t[1],r=a*a+o*o;return 0<r&&(r=1/p(r),e[0]=t[0]*r,e[1]=t[1]*r),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},o.lerp=function(e,o,a,r){var t=o[0],n=o[1];return e[0]=t+r*(a[0]-t),e[1]=n+r*(a[1]-n),e},o.reflect=function(e,t,a){var o=t[0]*a[0]+t[1]*a[1];e[0]=t[0]-2*a[0]*o,e[1]=t[1]-2*a[1]*o},o.getLineSegmentsIntersection=function(e,a,r,n,i){var s=o.getLineSegmentsIntersectionFraction(a,r,n,i);return!(0>s)&&(e[0]=a[0]+s*(r[0]-a[0]),e[1]=a[1]+s*(r[1]-a[1]),!0)},o.getLineSegmentsIntersectionFraction=function(e,a,o,r){var n=a[0]-e[0],i=a[1]-e[1],d=r[0]-o[0],l=r[1]-o[1],p,s;return p=(-i*(e[0]-o[0])+n*(e[1]-o[1]))/(-d*i+n*l),s=(d*(e[1]-o[1])-l*(e[0]-o[0]))/(-d*i+n*l),0<=p&&1>=p&&0<=s&&1>=s?s:-1}},{"../utils/Utils":57}],31:[function(e,t){function a(e){e=e||{},p.call(this),this.id=e.id||++a._idCounter,this.world=null,this.shapes=[],this.mass=e.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!e.fixedRotation,this.fixedX=!!e.fixedX,this.fixedY=!!e.fixedY,this.massMultiplier=n.create(),this.position=n.fromValues(0,0),e.position&&n.copy(this.position,e.position),this.interpolatedPosition=n.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=n.fromValues(0,0),this.previousAngle=0,this.velocity=n.fromValues(0,0),e.velocity&&n.copy(this.velocity,e.velocity),this.vlambda=n.fromValues(0,0),this.wlambda=0,this.angle=e.angle||0,this.angularVelocity=e.angularVelocity||0,this.force=n.create(),e.force&&n.copy(this.force,e.force),this.angularForce=e.angularForce||0,this.damping="number"==typeof e.damping?e.damping:0.1,this.angularDamping="number"==typeof e.angularDamping?e.angularDamping:0.1,this.type=a.STATIC,this.type="undefined"==typeof e.type?e.mass?a.DYNAMIC:a.STATIC:e.type,this.boundingRadius=0,this.aabb=new l,this.aabbNeedsUpdate=!0,this.allowSleep=!(e.allowSleep!==void 0)||e.allowSleep,this.wantsToSleep=!1,this.sleepState=a.AWAKE,this.sleepSpeedLimit=e.sleepSpeedLimit===void 0?0.2:e.sleepSpeedLimit,this.sleepTimeLimit=e.sleepTimeLimit===void 0?1:e.sleepTimeLimit,this.gravityScale=e.gravityScale===void 0?1:e.gravityScale,this.collisionResponse=!(e.collisionResponse!==void 0)||e.collisionResponse,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=e.ccdSpeedThreshold===void 0?-1:e.ccdSpeedThreshold,this.ccdIterations=e.ccdIterations===void 0?10:e.ccdIterations,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var n=e("../math/vec2"),r=e("poly-decomp"),s=e("../shapes/Convex"),i=e("../collision/RaycastResult"),d=e("../collision/Ray"),l=e("../collision/AABB"),p=e("../events/EventEmitter");t.exports=a,a.prototype=new p,a.prototype.constructor=a,a._idCounter=0,a.prototype.updateSolveMassProperties=function(){this.sleepState===a.SLEEPING||this.type===a.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},a.prototype.setDensity=function(e){var t=this.getArea();this.mass=t*e,this.updateMassProperties()},a.prototype.getArea=function(){for(var e=0,t=0;t<this.shapes.length;t++)e+=this.shapes[t].area;return e},a.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};var c=new l,h=n.create();a.prototype.updateAABB=function(){for(var e=this.shapes,t=e.length,a=h,o=this.angle,r=0;r!==t;r++){var i=e[r],s=i.angle+o;n.rotate(a,i.position,o),n.add(a,a,this.position),i.computeAABB(c,a,s),0===r?this.aabb.copy(c):this.aabb.extend(c)}this.aabbNeedsUpdate=!1},a.prototype.updateBoundingRadius=function(){for(var e=this.shapes,t=e.length,a=0,o=0;o!==t;o++){var i=e[o],s=n.length(i.position),d=i.boundingRadius;s+d>a&&(a=s+d)}this.boundingRadius=a},a.prototype.addShape=function(e,t,a){if(e.body)throw new Error("A shape can only be added to one body.");e.body=this,t?n.copy(e.position,t):n.set(e.position,0,0),e.angle=a||0,this.shapes.push(e),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},a.prototype.removeShape=function(e){var t=this.shapes.indexOf(e);return-1!==t&&(this.shapes.splice(t,1),this.aabbNeedsUpdate=!0,e.body=null,!0)},a.prototype.updateMassProperties=function(){if(this.type===a.STATIC||this.type===a.KINEMATIC)this.mass=u,this.invMass=0,this.inertia=u,this.invInertia=0;else{var e=this.shapes,t=e.length,o=this.mass/t,r=0;if(!this.fixedRotation){for(var s=0;s<t;s++){var i=e[s],d=n.squaredLength(i.position),l=i.computeMomentOfInertia(o);r+=l+o*d}this.inertia=r,this.invInertia=0<r?1/r:0}else this.inertia=u,this.invInertia=0;this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};n.create();a.prototype.applyForce=function(e,t){if(n.add(this.force,this.force,e),t){var a=n.crossLength(t,e);this.angularForce+=a}};var g=n.create(),m=n.create(),y=n.create();a.prototype.applyForceLocal=function(e,t){t=t||y;var a=g,o=m;this.vectorToWorldFrame(a,e),this.vectorToWorldFrame(o,t),this.applyForce(a,o)};var f=n.create();a.prototype.applyImpulse=function(e,t){if(this.type===a.DYNAMIC){var o=f;if(n.scale(o,e,this.invMass),n.multiply(o,this.massMultiplier,o),n.add(this.velocity,o,this.velocity),t){var r=n.crossLength(t,e);r*=this.invInertia,this.angularVelocity+=r}}};var x=n.create(),b=n.create(),_=n.create();a.prototype.applyImpulseLocal=function(e,t){t=t||_;var a=x,o=b;this.vectorToWorldFrame(a,e),this.vectorToWorldFrame(o,t),this.applyImpulse(a,o)},a.prototype.toLocalFrame=function(e,t){n.toLocalFrame(e,t,this.position,this.angle)},a.prototype.toWorldFrame=function(e,t){n.toGlobalFrame(e,t,this.position,this.angle)},a.prototype.vectorToLocalFrame=function(e,t){n.vectorToLocalFrame(e,t,this.angle)},a.prototype.vectorToWorldFrame=function(e,t){n.vectorToGlobalFrame(e,t,this.angle)},a.prototype.fromPolygon=function(e,t){t=t||{};for(var a=this.shapes.length;0<=a;--a)this.removeShape(this.shapes[a]);var o=new r.Polygon;if(o.vertices=e,o.makeCCW(),"number"==typeof t.removeCollinearPoints&&o.removeCollinearPoints(t.removeCollinearPoints),"undefined"==typeof t.skipSimpleCheck&&!o.isSimple())return!1;this.concavePath=o.vertices.slice(0);for(var a=0,i;a<this.concavePath.length;a++)i=[0,0],n.copy(i,this.concavePath[a]),this.concavePath[a]=i;var d=t.optimalDecomp?o.decomp():o.quickDecomp();for(var l=n.create(),a=0,p;a!==d.length;a++){p=new s({vertices:d[a].vertices});for(var c=0,i;c!==p.vertices.length;c++)i=p.vertices[c],n.sub(i,i,p.centerOfMass);n.scale(l,p.centerOfMass,1),p.updateTriangles(),p.updateCenterOfMass(),p.updateBoundingRadius(),this.addShape(p,l)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0,!0};var v=n.fromValues(0,0),T=n.fromValues(0,0),C=n.fromValues(0,0),P=n.fromValues(0,0);a.prototype.adjustCenterOfMass=function(){var e=T,t=C,a=P,o=0;n.set(t,0,0);for(var r=0,i;r!==this.shapes.length;r++)i=this.shapes[r],n.scale(e,i.position,i.area),n.add(t,t,e),o+=i.area;n.scale(a,t,1/o);for(var r=0,i;r!==this.shapes.length;r++)i=this.shapes[r],n.sub(i.position,i.position,a);n.add(this.position,this.position,a);for(var r=0;this.concavePath&&r<this.concavePath.length;r++)n.sub(this.concavePath[r],this.concavePath[r],a);this.updateMassProperties(),this.updateBoundingRadius()},a.prototype.setZeroForce=function(){n.set(this.force,0,0),this.angularForce=0},a.prototype.resetConstraintVelocity=function(){var e=this,t=e.vlambda;n.set(t,0,0),e.wlambda=0},a.prototype.addConstraintVelocity=function(){var e=this,t=e.velocity;n.add(t,t,e.vlambda),e.angularVelocity+=e.wlambda},a.prototype.applyDamping=function(e){if(this.type===a.DYNAMIC){var t=this.velocity;n.scale(t,t,o(1-this.damping,e)),this.angularVelocity*=o(1-this.angularDamping,e)}},a.prototype.wakeUp=function(){var e=this.sleepState;this.sleepState=a.AWAKE,this.idleTime=0,e!==a.AWAKE&&this.emit(a.wakeUpEvent)},a.prototype.sleep=function(){this.sleepState=a.SLEEPING,this.angularVelocity=0,this.angularForce=0,n.set(this.velocity,0,0),n.set(this.force,0,0),this.emit(a.sleepEvent)},a.prototype.sleepTick=function(e,t,r){if(this.allowSleep&&this.type!==a.SLEEPING){this.wantsToSleep=!1;var i=this.sleepState,s=n.squaredLength(this.velocity)+o(this.angularVelocity,2),d=o(this.sleepSpeedLimit,2);s>=d?(this.idleTime=0,this.sleepState=a.AWAKE):(this.idleTime+=r,this.sleepState=a.SLEEPY),this.idleTime>this.sleepTimeLimit&&(t?this.wantsToSleep=!0:this.sleep())}},a.prototype.overlaps=function(e){return this.world.overlapKeeper.bodiesAreOverlapping(this,e)};var S=n.create(),w=n.create();a.prototype.integrate=function(e){var t=this.invMass,a=this.force,o=this.position,r=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*e),n.scale(S,a,e*t),n.multiply(S,this.massMultiplier,S),n.add(r,S,r),this.integrateToTimeOfImpact(e)||(n.scale(w,r,e),n.add(o,o,w),!this.fixedRotation&&(this.angle+=this.angularVelocity*e)),this.aabbNeedsUpdate=!0};var A=new i,E=new d({mode:d.ALL}),R=n.create(),L=n.create(),B=n.create(),k=n.create();a.prototype.integrateToTimeOfImpact=function(e){if(0>this.ccdSpeedThreshold||n.squaredLength(this.velocity)<o(this.ccdSpeedThreshold,2))return!1;n.normalize(R,this.velocity),n.scale(L,this.velocity,e),n.add(L,L,this.position),n.sub(B,L,this.position);var t=this.angularVelocity*e,a=n.length(B),r=1,i=this,s;if(A.reset(),E.callback=function(e){e.body===i||(s=e.body,e.getHitPoint(L,E),n.sub(B,L,i.position),r=n.length(B)/a,e.stop())},n.copy(E.from,this.position),n.copy(E.to,L),E.update(),this.world.raycast(A,E),!s)return!1;var d=this.angle;n.copy(k,this.position);for(var l=0,p=0,c=0,u=r;u>=p&&l<this.ccdIterations;){l++,c=(u-p)/2,n.scale(w,B,r),n.add(this.position,k,w),this.angle=d+t*r,this.updateAABB();var h=this.aabb.overlaps(s.aabb)&&this.world.narrowphase.bodiesOverlap(this,s);h?p=c:u=c}return r=c,n.copy(this.position,k),this.angle=d,n.scale(w,B,r),n.add(this.position,this.position,w),this.fixedRotation||(this.angle+=t*r),!0},a.prototype.getVelocityAtPoint=function(e,t){return n.crossVZ(e,t,this.angularVelocity),n.subtract(e,this.velocity,e),e},a.sleepyEvent={type:"sleepy"},a.sleepEvent={type:"sleep"},a.wakeUpEvent={type:"wakeup"},a.DYNAMIC=1,a.STATIC=2,a.KINEMATIC=4,a.AWAKE=0,a.SLEEPY=1,a.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(e,t){function a(e,t,a){a=a||{},r.call(this,e,t,a),this.localAnchorA=o.fromValues(0,0),this.localAnchorB=o.fromValues(0,0),a.localAnchorA&&o.copy(this.localAnchorA,a.localAnchorA),a.localAnchorB&&o.copy(this.localAnchorB,a.localAnchorB),a.worldAnchorA&&this.setWorldAnchorA(a.worldAnchorA),a.worldAnchorB&&this.setWorldAnchorB(a.worldAnchorB);var n=o.create(),i=o.create();this.getWorldAnchorA(n),this.getWorldAnchorB(i);var s=o.distance(n,i);this.restLength="number"==typeof a.restLength?a.restLength:s}var o=e("../math/vec2"),r=e("./Spring"),n=e("../utils/Utils");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.setWorldAnchorA=function(e){this.bodyA.toLocalFrame(this.localAnchorA,e)},a.prototype.setWorldAnchorB=function(e){this.bodyB.toLocalFrame(this.localAnchorB,e)},a.prototype.getWorldAnchorA=function(e){this.bodyA.toWorldFrame(e,this.localAnchorA)},a.prototype.getWorldAnchorB=function(e){this.bodyB.toWorldFrame(e,this.localAnchorB)};var i=o.create(),s=o.create(),p=o.create(),c=o.create(),h=o.create(),g=o.create(),m=o.create(),y=o.create(),x=o.create();a.prototype.applyForce=function(){var e=this.stiffness,t=this.damping,a=this.restLength,n=this.bodyA,d=this.bodyB,l=i,r=s,b=p,u=c,f=x,_=h,v=g,T=m,C=y;this.getWorldAnchorA(_),this.getWorldAnchorB(v),o.sub(T,_,n.position),o.sub(C,v,d.position),o.sub(l,v,_);var P=o.len(l);o.normalize(r,l),o.sub(b,d.velocity,n.velocity),o.crossZV(f,d.angularVelocity,C),o.add(b,b,f),o.crossZV(f,n.angularVelocity,T),o.sub(b,b,f),o.scale(u,r,-e*(P-a)-t*o.dot(b,r)),o.sub(n.force,n.force,u),o.add(d.force,d.force,u);var S=o.crossLength(T,u),w=o.crossLength(C,u);n.angularForce-=S,d.angularForce+=w}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(e,t){function a(e,t,a){a=a||{},r.call(this,e,t,a),this.restAngle="number"==typeof a.restAngle?a.restAngle:t.angle-e.angle}var o=e("../math/vec2"),r=e("./Spring");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.applyForce=function(){var e=this.stiffness,t=this.damping,a=this.restAngle,o=this.bodyA,r=this.bodyB,n=r.angle-o.angle,i=r.angularVelocity-o.angularVelocity,s=-e*(n-a)-0*(t*i);o.angularForce-=s,r.angularForce+=s}},{"../math/vec2":30,"./Spring":34}],34:[function(e,t){function a(e,t,a){a=r.defaults(a,{stiffness:100,damping:1}),this.stiffness=a.stiffness,this.damping=a.damping,this.bodyA=e,this.bodyB=t}var o=e("../math/vec2"),r=e("../utils/Utils");t.exports=a,a.prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(t,a){function o(e,t){t=t||{},this.chassisBody=e,this.wheels=[],this.groundBody=new l({mass:0}),this.world=null;var a=this;this.preStepCallback=function(){a.update()}}function r(e,t){t=t||{},this.vehicle=e,this.forwardEquation=new d(e.chassisBody,e.groundBody),this.sideEquation=new d(e.chassisBody,e.groundBody),this.steerValue=0,this.engineForce=0,this.setSideFriction(t.sideFriction===void 0?5:t.sideFriction),this.localForwardVector=n.fromValues(0,1),t.localForwardVector&&n.copy(this.localForwardVector,t.localForwardVector),this.localPosition=n.fromValues(0,0),t.localPosition&&n.copy(this.localPosition,t.localPosition),s.apply(this,e.chassisBody,e.groundBody),this.equations.push(this.forwardEquation,this.sideEquation),this.setBrakeForce(0)}var n=t("../math/vec2"),i=t("../utils/Utils"),s=t("../constraints/Constraint"),d=t("../equations/FrictionEquation"),l=t("../objects/Body");a.exports=o,o.prototype.addToWorld=function(e){this.world=e,e.addBody(this.groundBody),e.on("preStep",this.preStepCallback);for(var t=0,a;t<this.wheels.length;t++)a=this.wheels[t],e.addConstraint(a)},o.prototype.removeFromWorld=function(){var e=this.world;e.removeBody(this.groundBody),e.off("preStep",this.preStepCallback);for(var t=0,a;t<this.wheels.length;t++)a=this.wheels[t],e.removeConstraint(a);this.world=null},o.prototype.addWheel=function(e){var t=new r(this,e);return this.wheels.push(t),t},o.prototype.update=function(){for(var e=0;e<this.wheels.length;e++)this.wheels[e].update()},r.prototype=new s,r.prototype.setBrakeForce=function(e){this.forwardEquation.setSlipForce(e)},r.prototype.setSideFriction=function(e){this.sideEquation.setSlipForce(e)};var p=n.create(),c=n.create();r.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(c,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(p,c),n.dot(p,c)};var u=n.create();r.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector),n.rotate(this.sideEquation.t,this.localForwardVector,e/2),this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t),n.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue),n.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue),this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition),n.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB),this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition),n.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA),n.normalize(u,this.forwardEquation.t),n.scale(u,u,this.engineForce),this.vehicle.chassisBody.applyForce(u,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(e,t){var a=t.exports={AABB:e("./collision/AABB"),AngleLockEquation:e("./equations/AngleLockEquation"),Body:e("./objects/Body"),Broadphase:e("./collision/Broadphase"),Capsule:e("./shapes/Capsule"),Circle:e("./shapes/Circle"),Constraint:e("./constraints/Constraint"),ContactEquation:e("./equations/ContactEquation"),ContactEquationPool:e("./utils/ContactEquationPool"),ContactMaterial:e("./material/ContactMaterial"),Convex:e("./shapes/Convex"),DistanceConstraint:e("./constraints/DistanceConstraint"),Equation:e("./equations/Equation"),EventEmitter:e("./events/EventEmitter"),FrictionEquation:e("./equations/FrictionEquation"),FrictionEquationPool:e("./utils/FrictionEquationPool"),GearConstraint:e("./constraints/GearConstraint"),GSSolver:e("./solver/GSSolver"),Heightfield:e("./shapes/Heightfield"),Line:e("./shapes/Line"),LockConstraint:e("./constraints/LockConstraint"),Material:e("./material/Material"),Narrowphase:e("./collision/Narrowphase"),NaiveBroadphase:e("./collision/NaiveBroadphase"),Particle:e("./shapes/Particle"),Plane:e("./shapes/Plane"),Pool:e("./utils/Pool"),RevoluteConstraint:e("./constraints/RevoluteConstraint"),PrismaticConstraint:e("./constraints/PrismaticConstraint"),Ray:e("./collision/Ray"),RaycastResult:e("./collision/RaycastResult"),Box:e("./shapes/Box"),RotationalVelocityEquation:e("./equations/RotationalVelocityEquation"),SAPBroadphase:e("./collision/SAPBroadphase"),Shape:e("./shapes/Shape"),Solver:e("./solver/Solver"),Spring:e("./objects/Spring"),TopDownVehicle:e("./objects/TopDownVehicle"),LinearSpring:e("./objects/LinearSpring"),RotationalSpring:e("./objects/RotationalSpring"),Utils:e("./utils/Utils"),World:e("./world/World"),vec2:e("./math/vec2"),version:e("../package.json").version};Object.defineProperty(a,"Rectangle",{get:function(){return console.warn("The Rectangle class has been renamed to Box."),this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(e,t){function a(e){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(e={width:arguments[0],height:arguments[1]},console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")),e=e||{};var t=this.width=e.width||1,a=this.height=e.height||1,i=[o.fromValues(-t/2,-a/2),o.fromValues(t/2,-a/2),o.fromValues(t/2,a/2),o.fromValues(-t/2,a/2)],s=[o.fromValues(1,0),o.fromValues(0,1)];e.vertices=i,e.axes=s,e.type=r.BOX,n.call(this,e)}var o=e("../math/vec2"),r=e("./Shape"),n=e("./Convex");t.exports=a,a.prototype=new n,a.prototype.constructor=a,a.prototype.computeMomentOfInertia=function(e){var t=this.width,a=this.height;return e*(a*a+t*t)/12},a.prototype.updateBoundingRadius=function(){var e=this.width,t=this.height;this.boundingRadius=p(e*e+t*t)/2};var i=o.create(),s=o.create(),d=o.create(),l=o.create();a.prototype.computeAABB=function(e,t,a){e.setFromPoints(this.vertices,t,a,0)},a.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(t,a){function i(e){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(e={length:arguments[0],radius:arguments[1]},console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")),e=e||{},this.length=e.length||1,this.radius=e.radius||1,e.type=d.CAPSULE,d.call(this,e)}var d=t("./Shape"),l=t("../math/vec2");a.exports=i,i.prototype=new d,i.prototype.constructor=i,i.prototype.computeMomentOfInertia=function(e){var t=this.radius,a=this.length+t,o=2*t;return e*(o*o+a*a)/12},i.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},i.prototype.updateArea=function(){this.area=e*this.radius*this.radius+2*this.radius*this.length};var c=l.create();i.prototype.computeAABB=function(e,t,a){var o=this.radius;l.set(c,this.length/2,0),0!==a&&l.rotate(c,c,a),l.set(e.upperBound,n(c[0]+o,-c[0]+o),n(c[1]+o,-c[1]+o)),l.set(e.lowerBound,s(c[0]-o,-c[0]-o),s(c[1]-o,-c[1]-o)),l.add(e.lowerBound,e.lowerBound,t),l.add(e.upperBound,e.upperBound,t)};var r=l.create(),u=l.create(),h=l.create(),g=l.create(),m=l.fromValues(0,1);i.prototype.raycast=function(e,t,n,s){for(var d=t.from,f=t.to,x=t.direction,_=r,v=u,T=h,C=g,P=this.length/2,S=0,i;2>S;S++){i=this.radius*(2*S-1),l.set(T,-P,i),l.set(C,P,i),l.toGlobalFrame(T,T,n,s),l.toGlobalFrame(C,C,n,s);var y=l.getLineSegmentsIntersectionFraction(d,f,T,C);if(0<=y&&(l.rotate(v,m,s),l.scale(v,v,2*S-1),t.reportIntersection(e,y,v,-1),e.shouldStop(t)))return}for(var w=o(this.radius,2)+o(P,2),S=0;2>S;S++){l.set(T,P*(2*S-1),0),l.toGlobalFrame(T,T,n,s);var A=o(f[0]-d[0],2)+o(f[1]-d[1],2),a=2*((f[0]-d[0])*(d[0]-T[0])+(f[1]-d[1])*(d[1]-T[1])),E=o(d[0]-T[0],2)+o(d[1]-T[1],2)-o(this.radius,2),y=o(a,2)-4*A*E;if(0>y)continue;else if(0!==y){var c=p(y),R=1/(2*A),L=(-a-c)*R,B=(-a+c)*R;if(0<=L&&1>=L&&(l.lerp(_,d,f,L),l.squaredDistance(_,n)>w&&(l.sub(v,_,T),l.normalize(v,v),t.reportIntersection(e,L,v,-1),e.shouldStop(t))))return;if(0<=B&&1>=B&&(l.lerp(_,d,f,B),l.squaredDistance(_,n)>w&&(l.sub(v,_,T),l.normalize(v,v),t.reportIntersection(e,B,v,-1),e.shouldStop(t))))return}else if(l.lerp(_,d,f,y),l.squaredDistance(_,n)>w&&(l.sub(v,_,T),l.normalize(v,v),t.reportIntersection(e,y,v,-1),e.shouldStop(t)))return}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,a){function r(e){"number"==typeof arguments[0]&&(e={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),e=e||{},this.radius=e.radius||1,e.type=n.CIRCLE,n.call(this,e)}var n=t("./Shape"),i=t("../math/vec2");a.exports=r,r.prototype=new n,r.prototype.constructor=r,r.prototype.computeMomentOfInertia=function(e){var t=this.radius;return e*t*t/2},r.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},r.prototype.updateArea=function(){this.area=e*this.radius*this.radius},r.prototype.computeAABB=function(e,t){var a=this.radius;i.set(e.upperBound,a,a),i.set(e.lowerBound,-a,-a),t&&(i.add(e.lowerBound,e.lowerBound,t),i.add(e.upperBound,e.upperBound,t))};var s=i.create(),d=i.create();r.prototype.raycast=function(e,t,n){var l=t.from,u=t.to,h=this.radius,r=o(u[0]-l[0],2)+o(u[1]-l[1],2),a=2*((u[0]-l[0])*(l[0]-n[0])+(u[1]-l[1])*(l[1]-n[1])),g=o(l[0]-n[0],2)+o(l[1]-n[1],2)-o(h,2),c=o(a,2)-4*r*g,m=s,y=d;if(!(0>c))if(0==c)i.lerp(m,l,u,c),i.sub(y,m,n),i.normalize(y,y),t.reportIntersection(e,c,y,-1);else{var f=p(c),x=1/(2*r),_=(-a-f)*x,v=(-a+f)*x;if(0<=_&&1>=_&&(i.lerp(m,l,u,_),i.sub(y,m,n),i.normalize(y,y),t.reportIntersection(e,_,y,-1),e.shouldStop(t)))return;0<=v&&1>=v&&(i.lerp(m,l,u,v),i.sub(y,m,n),i.normalize(y,y),t.reportIntersection(e,v,y,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,a){function o(e){Array.isArray(arguments[0])&&(e={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),e=e||{},this.vertices=[];for(var t=void 0===e.vertices?[]:e.vertices,a=0,o;a<t.length;a++)o=s.create(),s.copy(o,t[a]),this.vertices.push(o);if(this.axes=[],e.axes)for(var a=0,n;a<e.axes.length;a++)n=s.create(),s.copy(n,e.axes[a]),this.axes.push(n);else for(var a=0;a<this.vertices.length;a++){var i=this.vertices[a],d=this.vertices[(a+1)%this.vertices.length],l=s.create();s.sub(l,d,i),s.rotate90cw(l,l),s.normalize(l,l),this.axes.push(l)}if(this.centerOfMass=s.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,e.type=r.CONVEX,r.call(this,e),this.updateBoundingRadius(),this.updateArea(),0>this.area)throw new Error("Convex vertices must be given in conter-clockwise winding.")}var r=t("./Shape"),s=t("../math/vec2"),n=t("../math/polyk"),i=t("poly-decomp");a.exports=o,o.prototype=new r,o.prototype.constructor=o;var d=s.create(),c=s.create();o.prototype.projectOntoLocalAxis=function(e,a){for(var o=null,r=null,n=0,i,l;n<this.vertices.length;n++)i=this.vertices[n],l=s.dot(i,d),(null==o||l>o)&&(o=l),(null==r||l<r)&&(r=l);if(r>o){var p=r;r=o,o=p}s.set(a,r,o)},o.prototype.projectOntoWorldAxis=function(e,t,a,o){var r=c;this.projectOntoLocalAxis(e,o),0===a?r=e:s.rotate(r,e,a);var n=s.dot(t,r);s.set(o,o[0]+n,o[1]+n)},o.prototype.updateTriangles=function(){this.triangles.length=0;for(var e=[],t=0,a;t<this.vertices.length;t++)a=this.vertices[t],e.push(a[0],a[1]);for(var o=n.Triangulate(e),t=0;t<o.length;t+=3){var r=o[t],i=o[t+1],s=o[t+2];this.triangles.push([r,i,s])}};var u=s.create(),h=s.create(),g=s.create(),y=s.create(),f=s.create(),m=s.create(),x=s.create(),b=s.create(),_=s.create();o.prototype.updateCenterOfMass=function(){var e=this.triangles,r=this.vertices,n=this.centerOfMass,d=u,l=g,a=y,p=f,c=h;s.set(n,0,0);for(var x=0,b=0;b!==e.length;b++){var i=e[b],l=r[i[0]],a=r[i[1]],p=r[i[2]];s.centroid(d,l,a,p);var t=o.triangleArea(l,a,p);x+=t,s.scale(c,d,t),s.add(n,n,c)}s.scale(n,n,1/x)},o.prototype.computeMomentOfInertia=function(e){for(var t=0,o=0,r=this.vertices.length,n=r-1,d=0;d<r;n=d,d++){var i=this.vertices[n],p=this.vertices[d],c=l(s.crossLength(i,p)),a=s.dot(p,p)+s.dot(p,i)+s.dot(i,i);t+=c*a,o+=c}return e/6*(t/o)},o.prototype.updateBoundingRadius=function(){for(var e=this.vertices,t=0,a=0,o;a!==e.length;a++)o=s.squaredLength(e[a]),o>t&&(t=o);this.boundingRadius=p(t)},o.triangleArea=function(e,t,a){return 0.5*((t[0]-e[0])*(a[1]-e[1])-(a[0]-e[0])*(t[1]-e[1]))},o.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var e=this.triangles,r=this.vertices,n=0;n!==e.length;n++){var i=e[n],t=r[i[0]],a=r[i[1]],s=r[i[2]],d=o.triangleArea(t,a,s);this.area+=d}},o.prototype.computeAABB=function(e,t,a){e.setFromPoints(this.vertices,t,a,0)};var v=s.create(),T=s.create(),C=s.create();o.prototype.raycast=function(t,a,o,r){var d=v,l=T,p=C,c=this.vertices;s.toLocalFrame(d,a.from,o,r),s.toLocalFrame(l,a.to,o,r);for(var u=c.length,n=0;n<u&&!t.shouldStop(a);n++){var i=c[n],h=c[(n+1)%u],g=s.getLineSegmentsIntersectionFraction(d,l,i,h);0<=g&&(s.sub(p,h,i),s.rotate(p,p,-e/2+r),s.normalize(p,p),a.reportIntersection(t,g,p,n))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,o){function r(e){if(Array.isArray(arguments[0])){if(e={heights:arguments[0]},"object"==typeof arguments[1])for(var t in arguments[1])e[t]=arguments[1][t];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}e=e||{},this.heights=e.heights?e.heights.slice(0):[],this.maxValue=e.maxValue||null,this.minValue=e.minValue||null,this.elementWidth=e.elementWidth||0.1,(e.maxValue===void 0||e.minValue===void 0)&&this.updateMaxMinValues(),e.type=i.HEIGHTFIELD,i.call(this,e)}var i=t("./Shape"),d=t("../math/vec2"),l=t("../utils/Utils");o.exports=r,r.prototype=new i,r.prototype.constructor=r,r.prototype.updateMaxMinValues=function(){for(var e=this.heights,t=e[0],a=e[0],o=0,r;o!==e.length;o++)r=e[o],r>t&&(t=r),r<a&&(a=r);this.maxValue=t,this.minValue=a},r.prototype.computeMomentOfInertia=function(){return u},r.prototype.updateBoundingRadius=function(){this.boundingRadius=u},r.prototype.updateArea=function(){for(var e=this.heights,t=0,a=0;a<e.length-1;a++)t+=(e[a]+e[a+1])/2*this.elementWidth;this.area=t};var p=[d.create(),d.create(),d.create(),d.create()];r.prototype.computeAABB=function(e,t,a){d.set(p[0],0,this.maxValue),d.set(p[1],this.elementWidth*this.heights.length,this.maxValue),d.set(p[2],this.elementWidth*this.heights.length,this.minValue),d.set(p[3],0,this.minValue),e.setFromPoints(p,t,a)},r.prototype.getLineSegment=function(e,t,a){var o=this.heights,r=this.elementWidth;d.set(e,a*r,o[a]),d.set(t,(a+1)*r,o[a+1])},r.prototype.getSegmentIndex=function(e){return a(e[0]/this.elementWidth)},r.prototype.getClampedSegmentIndex=function(e){var t=this.getSegmentIndex(e);return t=s(this.heights.length,n(t,0)),t};var c=d.create(),h=d.create(),g=d.create(),m=d.create(),y=d.create(),f=d.create(),x=d.fromValues(0,1);r.prototype.raycast=function(a,o,r,n){var s=o.from,l=o.to,p=o.direction,c=h,u=g,x=m,b=y,_=f;d.toLocalFrame(b,s,r,n),d.toLocalFrame(_,l,r,n);var v=this.getClampedSegmentIndex(b),T=this.getClampedSegmentIndex(_);if(v>T){var C=v;v=T,T=C}for(var P=0;P<this.heights.length-1;P++){this.getLineSegment(u,x,P);var i=d.getLineSegmentsIntersectionFraction(b,_,u,x);if(0<=i&&(d.sub(c,x,u),d.rotate(c,c,n+e/2),d.normalize(c,c),o.reportIntersection(a,i,c,-1),a.shouldStop(o)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(e,t){function a(e){"number"==typeof arguments[0]&&(e={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),e=e||{},this.length=e.length||1,e.type=r.LINE,r.call(this,e)}var r=e("./Shape"),n=e("../math/vec2");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.computeMomentOfInertia=function(e){return e*o(this.length,2)/12},a.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var i=[n.create(),n.create()];a.prototype.computeAABB=function(e,t,a){var o=this.length/2;n.set(i[0],-o,0),n.set(i[1],o,0),e.setFromPoints(i,t,a,0)};var s=n.create(),d=n.create(),l=n.create(),p=n.create(),c=n.fromValues(0,1);a.prototype.raycast=function(e,t,a,o){var r=t.from,i=t.to,s=l,u=p,h=this.length/2;n.set(s,-h,0),n.set(u,h,0),n.toGlobalFrame(s,s,a,o),n.toGlobalFrame(u,u,a,o);var g=n.getLineSegmentsIntersectionFraction(s,u,r,i);if(0<=g){var m=d;n.rotate(m,c,o),t.reportIntersection(e,g,m,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(e,t){function a(e){e=e||{},e.type=o.PARTICLE,o.call(this,e)}var o=e("./Shape"),r=e("../math/vec2");t.exports=a,a.prototype=new o,a.prototype.constructor=a,a.prototype.computeMomentOfInertia=function(){return 0},a.prototype.updateBoundingRadius=function(){this.boundingRadius=0},a.prototype.computeAABB=function(e,t){r.copy(e.lowerBound,t),r.copy(e.upperBound,t)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,a){function o(e){e=e||{},e.type=r.PLANE,r.call(this,e)}var r=t("./Shape"),n=t("../math/vec2"),i=t("../utils/Utils");a.exports=o,o.prototype=new r,o.prototype.constructor=o,o.prototype.computeMomentOfInertia=function(){return 0},o.prototype.updateBoundingRadius=function(){this.boundingRadius=u},o.prototype.computeAABB=function(t,o,r){var i=r%(2*e),a=n.set,s=1e7,d=t.lowerBound,l=t.upperBound;a(d,-s,-s),a(l,s,s),0==i?l[1]=0:i==e/2?d[0]=0:i===e?d[1]=0:i==3*e/2&&(l[0]=0)},o.prototype.updateArea=function(){this.area=u};var s=n.create(),d=n.create(),l=n.create(),p=n.create(),c=n.create();o.prototype.raycast=function(e,a,o,r){var i=a.from,d=a.to,l=a.direction,u=s,h=p,g=c;n.set(h,0,1),n.rotate(h,h,r),n.sub(g,i,o);var m=n.dot(g,h);n.sub(g,d,o);var y=n.dot(g,h);if(!(0<m*y)&&!(n.squaredDistance(i,d)<m*m)){var f=n.dot(h,l);n.sub(u,i,o);var x=-n.dot(h,u)/f/a.length;a.reportIntersection(e,x,h,-1)}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(e,t){function a(e){e=e||{},this.body=null,this.position=o.fromValues(0,0),e.position&&o.copy(this.position,e.position),this.angle=e.angle||0,this.type=e.type||0,this.id=a.idCounter++,this.boundingRadius=0,this.collisionGroup=e.collisionGroup===void 0?1:e.collisionGroup,this.collisionResponse=!(e.collisionResponse!==void 0)||e.collisionResponse,this.collisionMask=e.collisionMask===void 0?1:e.collisionMask,this.material=e.material||null,this.area=0,this.sensor=e.sensor!==void 0&&e.sensor,this.type&&this.updateBoundingRadius(),this.updateArea()}t.exports=a;var o=e("../math/vec2");a.idCounter=0,a.CIRCLE=1,a.PARTICLE=2,a.PLANE=4,a.CONVEX=8,a.LINE=16,a.BOX=32,Object.defineProperty(a,"RECTANGLE",{get:function(){return console.warn("Shape.RECTANGLE is deprecated, use Shape.BOX instead."),a.BOX}}),a.CAPSULE=64,a.HEIGHTFIELD=128,a.prototype.computeMomentOfInertia=function(){},a.prototype.updateBoundingRadius=function(){},a.prototype.updateArea=function(){},a.prototype.computeAABB=function(){},a.prototype.raycast=function(){}},{"../math/vec2":30}],46:[function(e,t){function a(e){i.call(this,e,i.GS),e=e||{},this.iterations=e.iterations||10,this.tolerance=e.tolerance||1e-7,this.arrayStep=30,this.lambda=new s.ARRAY_TYPE(this.arrayStep),this.Bs=new s.ARRAY_TYPE(this.arrayStep),this.invCs=new s.ARRAY_TYPE(this.arrayStep),this.useZeroRHS=!1,this.frictionIterations=e.frictionIterations===void 0?e.frictionIterations:0,this.usedIterations=0}function r(e){for(var t=e.length;t--;)e[t]=0}var n=e("../math/vec2"),i=e("./Solver"),s=e("../utils/Utils"),d=e("../equations/FrictionEquation");t.exports=a,a.prototype=new i,a.prototype.constructor=a,a.prototype.solve=function(e,t){this.sortEquations();var p=0,u=this.iterations,h=this.frictionIterations,g=this.equations,m=g.length,y=o(this.tolerance*m,2),x=t.bodies,_=t.bodies.length,v=n.add,T=n.set,C=this.useZeroRHS,P=this.lambda;if(this.usedIterations=0,m)for(var S=0,i;S!==_;S++)i=x[S],i.updateSolveMassProperties();P.length<m&&(P=this.lambda=new s.ARRAY_TYPE(m+this.arrayStep),this.Bs=new s.ARRAY_TYPE(m+this.arrayStep),this.invCs=new s.ARRAY_TYPE(m+this.arrayStep)),r(P);for(var b=this.invCs,w=this.Bs,P=this.lambda,S=0,A;S!==g.length;S++)A=g[S],(A.timeStep!==e||A.needsUpdate)&&(A.timeStep=e,A.update()),w[S]=A.computeB(A.a,A.b,e),b[S]=A.computeInvC(A.epsilon);var A,c,S,E;if(0!==m){for(S=0;S!==_;S++){var i=x[S];i.resetConstraintVelocity()}if(h){for(p=0;p!==h;p++){for(c=0,E=0;E!==m;E++){A=g[E];var R=a.iterateEquation(E,A,A.epsilon,w,b,P,C,e,p);c+=l(R)}if(this.usedIterations++,c*c<=y)break}for(a.updateMultipliers(g,P,1/e),E=0;E!==m;E++){var L=g[E];if(L instanceof d){for(var B=0,F=0;F!==L.contactEquations.length;F++)B+=L.contactEquations[F].multiplier;B*=L.frictionCoefficient/L.contactEquations.length,L.maxForce=B,L.minForce=-B}}}for(p=0;p!==u;p++){for(c=0,E=0;E!==m;E++){A=g[E];var R=a.iterateEquation(E,A,A.epsilon,w,b,P,C,e,p);c+=l(R)}if(this.usedIterations++,c*c<=y)break}for(S=0;S!==_;S++)x[S].addConstraintVelocity();a.updateMultipliers(g,P,1/e)}},a.updateMultipliers=function(e,t,a){for(var o=e.length;o--;)e[o].multiplier=t[o]*a},a.iterateEquation=function(e,t,a,o,r,n,i,s){var d=o[e],l=r[e],p=n[e],c=t.computeGWlambda(),u=t.maxForce,h=t.minForce;i&&(d=0);var g=l*(d-c-a*p),m=p+g;return m<h*s?g=h*s-p:m>u*s&&(g=u*s-p),n[e]+=g,t.addToWlambda(g),g}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(e,t){function a(e,t){e=e||{},r.call(this),this.type=t,this.equations=[],this.equationSortFunction=e.equationSortFunction||!1}var o=e("../utils/Utils"),r=e("../events/EventEmitter");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.solve=function(){throw new Error("Solver.solve should be implemented by subclasses!")};var n={bodies:[]};a.prototype.solveIsland=function(e,t){this.removeAllEquations(),t.equations.length&&(this.addEquations(t.equations),n.bodies.length=0,t.getBodies(n.bodies),n.bodies.length&&this.solve(e,n))},a.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},a.prototype.addEquation=function(e){e.enabled&&this.equations.push(e)},a.prototype.addEquations=function(e){for(var t=0,a=e.length,o;t!==a;t++)o=e[t],o.enabled&&this.equations.push(o)},a.prototype.removeEquation=function(e){var t=this.equations.indexOf(e);-1!==t&&this.equations.splice(t,1)},a.prototype.removeAllEquations=function(){this.equations.length=0},a.GS=1,a.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(e,t){function a(){r.apply(this,arguments)}var o=e("../equations/ContactEquation"),r=e("./Pool");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.create=function(){return new o},a.prototype.destroy=function(e){return e.bodyA=e.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(e,t){function a(){r.apply(this,arguments)}var o=e("../equations/FrictionEquation"),r=e("./Pool");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.create=function(){return new o},a.prototype.destroy=function(e){return e.bodyA=e.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(e,t){function a(){r.apply(this,arguments)}var o=e("../world/IslandNode"),r=e("./Pool");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.create=function(){return new o},a.prototype.destroy=function(e){return e.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(e,t){function a(){r.apply(this,arguments)}var o=e("../world/Island"),r=e("./Pool");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.create=function(){return new o},a.prototype.destroy=function(e){return e.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(e,t){function a(){this.overlappingShapesLastState=new o,this.overlappingShapesCurrentState=new o,this.recordPool=new n({size:16}),this.tmpDict=new o,this.tmpArray1=[]}var o=e("./TupleDictionary"),r=e("./OverlapKeeperRecord"),n=e("./OverlapKeeperRecordPool"),i=e("./Utils");t.exports=a,a.prototype.tick=function(){for(var e=this.overlappingShapesLastState,t=this.overlappingShapesCurrentState,a=e.keys.length;a--;){var o=e.keys[a],r=e.getByKey(o),n=t.getByKey(o);r&&this.recordPool.release(r)}e.reset(),e.copy(t),t.reset()},a.prototype.setOverlapping=function(e,t,a,o){var r=this.overlappingShapesLastState,n=this.overlappingShapesCurrentState;if(!n.get(t.id,o.id)){var i=this.recordPool.get();i.set(e,t,a,o),n.set(t.id,o.id,i)}},a.prototype.getNewOverlaps=function(e){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,e)},a.prototype.getEndOverlaps=function(e){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,e)},a.prototype.bodiesAreOverlapping=function(e,t){for(var a=this.overlappingShapesCurrentState,o=a.keys.length;o--;){var r=a.keys[o],n=a.data[r];if(n.bodyA===e&&n.bodyB===t||n.bodyA===t&&n.bodyB===e)return!0}return!1},a.prototype.getDiff=function(e,t,a){var a=a||[],o=t;a.length=0;for(var r=o.keys.length;r--;){var n=o.keys[r],i=o.data[n];if(!i)throw new Error("Key "+n+" had no data!");var s=e.data[n];s||a.push(i)}return a},a.prototype.isNewOverlap=function(e,t){var a=0|e.id,o=0|t.id,r=this.overlappingShapesLastState,n=this.overlappingShapesCurrentState;return!!!r.get(a,o)&&!!n.get(a,o)},a.prototype.getNewBodyOverlaps=function(e){this.tmpArray1.length=0;var t=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(t,e)},a.prototype.getEndBodyOverlaps=function(e){this.tmpArray1.length=0;var t=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(t,e)},a.prototype.getBodyDiff=function(e,t){t=t||[];for(var a=this.tmpDict,o=e.length,r;o--;)r=e[o],a.set(0|r.bodyA.id,0|r.bodyB.id,r);for(o=a.keys.length;o--;){var r=a.getByKey(a.keys[o]);r&&t.push(r.bodyA,r.bodyB)}return a.reset(),t}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(e,t){function a(e,t,a,o){this.shapeA=t,this.shapeB=o,this.bodyA=e,this.bodyB=a}t.exports=a,a.prototype.set=function(e,t,o,r){a.call(this,e,t,o,r)}},{}],54:[function(e,t){function a(){r.apply(this,arguments)}var o=e("./OverlapKeeperRecord"),r=e("./Pool");t.exports=a,a.prototype=new r,a.prototype.constructor=a,a.prototype.create=function(){return new o},a.prototype.destroy=function(e){return e.bodyA=e.bodyB=e.shapeA=e.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(e,t){function a(e){e=e||{},this.objects=[],e.size!==void 0&&this.resize(e.size)}t.exports=a,a.prototype.resize=function(e){for(var t=this.objects;t.length>e;)t.pop();for(;t.length<e;)t.push(this.create());return this},a.prototype.get=function(){var e=this.objects;return e.length?e.pop():this.create()},a.prototype.release=function(e){return this.destroy(e),this.objects.push(e),this}},{}],56:[function(e,t){function a(){this.data={},this.keys=[]}var o=e("./Utils");t.exports=a,a.prototype.getKey=function(e,t){return e|=0,t|=0,(0|e)==(0|t)?-1:0|((0|e)>(0|t)?e<<16|65535&t:t<<16|65535&e)},a.prototype.getByKey=function(e){return e|=0,this.data[e]},a.prototype.get=function(e,t){return this.data[this.getKey(e,t)]},a.prototype.set=function(e,t,a){if(!a)throw new Error("No data!");var o=this.getKey(e,t);return this.data[o]||this.keys.push(o),this.data[o]=a,o},a.prototype.reset=function(){for(var e=this.data,t=this.keys,a=t.length;a--;)delete e[t[a]];t.length=0},a.prototype.copy=function(e){this.reset(),o.appendArray(this.keys,e.keys);for(var t=e.keys.length;t--;){var a=e.keys[t];this.data[a]=e.data[a]}}},{"./Utils":57}],57:[function(e,t){function a(){}t.exports=a,a.appendArray=function(e,t){if(1.5e5>t.length)e.push.apply(e,t);else for(var a=0,o=t.length;a!==o;++a)e.push(t[a])},a.splice=function(e,t,a){a=a||1;for(var o=t,r=e.length-a;o<r;o++)e[o]=e[o+a];e.length=r},a.ARRAY_TYPE="undefined"==typeof P2_ARRAY_TYPE?"undefined"==typeof Float32Array?Array:Float32Array:P2_ARRAY_TYPE,a.extend=function(e,t){for(var a in t)e[a]=t[a]},a.defaults=function(e,t){for(var a in e=e||{},t)a in e||(e[a]=t[a]);return e}},{}],58:[function(e,t){function a(){this.equations=[],this.bodies=[]}var o=e("../objects/Body");t.exports=a,a.prototype.reset=function(){this.equations.length=this.bodies.length=0};var r=[];a.prototype.getBodies=function(e){var t=e||[],a=this.equations;r.length=0;for(var o=0,n;o!==a.length;o++)n=a[o],-1===r.indexOf(n.bodyA.id)&&(t.push(n.bodyA),r.push(n.bodyA.id)),-1===r.indexOf(n.bodyB.id)&&(t.push(n.bodyB),r.push(n.bodyB.id));return t},a.prototype.wantsToSleep=function(){for(var e=0,t;e<this.bodies.length;e++)if(t=this.bodies[e],t.type===o.DYNAMIC&&!t.wantsToSleep)return!1;return!0},a.prototype.sleep=function(){for(var e=0,t;e<this.bodies.length;e++)t=this.bodies[e],t.sleep();return!0}},{"../objects/Body":31}],59:[function(e,t){function a(){this.nodePool=new i({size:16}),this.islandPool=new s({size:8}),this.equations=[],this.islands=[],this.nodes=[],this.queue=[]}var o=e("../math/vec2"),r=e("./Island"),n=e("./IslandNode"),i=e("./../utils/IslandNodePool"),s=e("./../utils/IslandPool"),d=e("../objects/Body");t.exports=a,a.getUnvisitedNode=function(e){for(var t=e.length,a=0,o;a!==t;a++)if(o=e[a],!o.visited&&o.body.type===d.DYNAMIC)return o;return!1},a.prototype.visit=function(e,t,a){t.push(e.body);for(var o=e.equations.length,r=0,n;r!==o;r++)n=e.equations[r],-1===a.indexOf(n)&&a.push(n)},a.prototype.bfs=function(e,t,o){var r=this.queue;for(r.length=0,r.push(e),e.visited=!0,this.visit(e,t,o);r.length;)for(var n=r.pop(),i;i=a.getUnvisitedNode(n.neighbors);)i.visited=!0,this.visit(i,t,o),i.body.type===d.DYNAMIC&&r.push(i)},a.prototype.split=function(e){for(var t=e.bodies,o=this.nodes,r=this.equations;o.length;)this.nodePool.release(o.pop());for(var n=0,i;n!==t.length;n++)i=this.nodePool.get(),i.body=t[n],o.push(i);for(var s=0;s!==r.length;s++){var d=r[s],n=t.indexOf(d.bodyA),l=t.indexOf(d.bodyB),p=o[n],c=o[l];p.neighbors.push(c),c.neighbors.push(p),p.equations.push(d),c.equations.push(d)}for(var u=this.islands,n=0;n<u.length;n++)this.islandPool.release(u[n]);u.length=0;for(var h;h=a.getUnvisitedNode(o);){var g=this.islandPool.get();this.bfs(h,g.bodies,g.equations),u.push(g)}return u}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(e,t){function a(e){this.body=e,this.neighbors=[],this.equations=[],this.visited=!1}t.exports=a,a.prototype.reset=function(){this.equations.length=0,this.neighbors.length=0,this.visited=!1,this.body=null}},{}],61:[function(e,t){function a(e){g.apply(this),e=e||{},this.springs=[],this.bodies=[],this.disabledBodyCollisionPairs=[],this.solver=e.solver||new r,this.narrowphase=new L(this),this.islandManager=new F,this.gravity=d.fromValues(0,-9.78),e.gravity&&d.copy(this.gravity,e.gravity),this.frictionGravity=d.length(this.gravity)||10,this.useWorldGravityAsFrictionGravity=!0,this.useFrictionGravityOnZeroGravity=!0,this.broadphase=e.broadphase||new R,this.broadphase.setWorld(this),this.constraints=[],this.defaultMaterial=new x,this.defaultContactMaterial=new b(this.defaultMaterial,this.defaultMaterial),this.lastTimeStep=1/60,this.applySpringForces=!0,this.applyDamping=!0,this.applyGravity=!0,this.solveConstraints=!0,this.contactMaterials=[],this.time=0,this.accumulator=0,this.stepping=!1,this.bodiesToBeRemoved=[],this.islandSplit=!("undefined"!=typeof e.islandSplit)||!!e.islandSplit,this.emitImpactEvent=!0,this._constraintIdCounter=0,this._bodyIdCounter=0,this.postStepEvent={type:"postStep"},this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.addSpringEvent={type:"addSpring",spring:null},this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null},this.postBroadphaseEvent={type:"postBroadphase",pairs:null},this.sleepMode=a.NO_SLEEPING,this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]},this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null},this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null},this.overlappingShapesLastState={keys:[]},this.overlappingShapesCurrentState={keys:[]},this.overlapKeeper=new k}var r=e("../solver/GSSolver"),n=e("../solver/Solver"),i=e("../collision/Ray"),d=e("../math/vec2"),l=e("../shapes/Circle"),p=e("../shapes/Convex"),s=e("../shapes/Line"),c=e("../shapes/Plane"),u=e("../shapes/Capsule"),h=e("../shapes/Particle"),g=e("../events/EventEmitter"),m=e("../objects/Body"),y=e("../shapes/Shape"),f=e("../objects/LinearSpring"),x=e("../material/Material"),b=e("../material/ContactMaterial"),_=e("../constraints/DistanceConstraint"),v=e("../constraints/Constraint"),T=e("../constraints/LockConstraint"),C=e("../constraints/RevoluteConstraint"),P=e("../constraints/PrismaticConstraint"),S=e("../constraints/GearConstraint"),w=e("../../package.json"),A=e("../collision/Broadphase"),E=e("../collision/AABB"),R=e("../collision/SAPBroadphase"),L=e("../collision/Narrowphase"),B=e("../utils/Utils"),k=e("../utils/OverlapKeeper"),F=e("./IslandManager"),D=e("../objects/RotationalSpring");t.exports=a,a.prototype=Object(g.prototype),a.prototype.constructor=a,a.NO_SLEEPING=1,a.BODY_SLEEPING=2,a.ISLAND_SLEEPING=4,a.prototype.addConstraint=function(e){this.constraints.push(e)},a.prototype.addContactMaterial=function(e){this.contactMaterials.push(e)},a.prototype.removeContactMaterial=function(e){var t=this.contactMaterials.indexOf(e);-1!==t&&B.splice(this.contactMaterials,t,1)},a.prototype.getContactMaterial=function(e,t){for(var a=this.contactMaterials,o=0,r=a.length,n;o!==r;o++)if(n=a[o],n.materialA.id===e.id&&n.materialB.id===t.id||n.materialA.id===t.id&&n.materialB.id===e.id)return n;return!1},a.prototype.removeConstraint=function(e){var t=this.constraints.indexOf(e);-1!==t&&B.splice(this.constraints,t,1)};var M=d.create(),O=d.create(),I=d.create(),U=d.create(),G=d.create(),N=d.create(),W=d.create(),X=d.fromValues(0,0),V=d.fromValues(0,0),H=d.fromValues(0,0),q=d.fromValues(0,0);a.prototype.step=function(e,a,o){if(o=o||10,a=a||0,0===a)this.internalStep(e),this.time+=e;else{this.accumulator+=a;for(var r=0;this.accumulator>=e&&r<o;)this.internalStep(e),this.time+=e,this.accumulator-=e,r++;for(var n=this.accumulator%e/e,t=0,i;t!==this.bodies.length;t++)i=this.bodies[t],d.lerp(i.interpolatedPosition,i.previousPosition,i.position,n),i.interpolatedAngle=i.previousAngle+n*(i.angle-i.previousAngle)}};var j=[];a.prototype.internalStep=function(t){this.stepping=!0;var o=this,r=this.springs.length,n=this.springs,p=this.bodies,u=this.gravity,h=this.solver,g=this.bodies.length,y=this.broadphase,f=this.narrowphase,x=this.constraints,_=W,v=d.scale,T=d.add,C=d.rotate,P=this.islandManager;if(this.overlapKeeper.tick(),this.lastTimeStep=t,this.useWorldGravityAsFrictionGravity){var S=d.length(this.gravity);0===S&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=S)}if(this.applyGravity)for(var w=0;w!==g;w++){var i=p[w],b=i.force;i.type===m.DYNAMIC&&i.sleepState!==m.SLEEPING&&(d.scale(_,u,i.mass*i.gravityScale),T(b,b,_))}if(this.applySpringForces)for(var w=0,A;w!==r;w++)A=n[w],A.applyForce();if(this.applyDamping)for(var w=0,i;w!==g;w++)i=p[w],i.type===m.DYNAMIC&&i.applyDamping(t);for(var s=y.getCollisionPairs(this),E=this.disabledBodyCollisionPairs,w=E.length-2;0<=w;w-=2)for(var R=s.length-2;0<=R;R-=2)(E[w]===s[R]&&E[w+1]===s[R+1]||E[w+1]===s[R]&&E[w]===s[R+1])&&s.splice(R,2);var L=x.length;for(w=0;w!==L;w++){var F=x[w];if(!F.collideConnected)for(var R=s.length-2;0<=R;R-=2)(F.bodyA===s[R]&&F.bodyB===s[R+1]||F.bodyB===s[R]&&F.bodyA===s[R+1])&&s.splice(R,2)}this.postBroadphaseEvent.pairs=s,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,f.reset(this);for(var w=0,c=s.length;w!==c;w+=2)for(var D=s[w],M=s[w+1],O=0,k=D.shapes.length;O!==k;O++)for(var I=D.shapes[O],U=I.position,G=I.angle,N=0,l=M.shapes.length;N!==l;N++){var X=M.shapes[N],V=X.position,H=X.angle,q=this.defaultContactMaterial;if(I.material&&X.material){var Y=this.getContactMaterial(I.material,X.material);Y&&(q=Y)}this.runNarrowphase(f,D,I,U,G,M,X,V,H,q,this.frictionGravity)}for(var w=0,z;w!==g;w++)z=p[w],z._wakeUpAfterNarrowphase&&(z.wakeUp(),z._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(j);for(var K=this.endContactEvent,N=j.length,e;N--;)e=j[N],K.shapeA=e.shapeA,K.shapeB=e.shapeB,K.bodyA=e.bodyA,K.bodyB=e.bodyB,this.emit(K);j.length=0}var J=this.preSolveEvent;J.contactEquations=f.contactEquations,J.frictionEquations=f.frictionEquations,this.emit(J),J.contactEquations=J.frictionEquations=null;var L=x.length;for(w=0;w!==L;w++)x[w].update();if(f.contactEquations.length||f.frictionEquations.length||L)if(this.islandSplit){for(P.equations.length=0,B.appendArray(P.equations,f.contactEquations),B.appendArray(P.equations,f.frictionEquations),w=0;w!==L;w++)B.appendArray(P.equations,x[w].equations);P.split(this);for(var w=0,Q;w!==P.islands.length;w++)Q=P.islands[w],Q.equations.length&&h.solveIsland(t,Q)}else{for(h.addEquations(f.contactEquations),h.addEquations(f.frictionEquations),w=0;w!==L;w++)h.addEquations(x[w].equations);this.solveConstraints&&h.solve(t,this),h.removeAllEquations()}for(var w=0,z;w!==g;w++)z=p[w],z.integrate(t);for(var w=0;w!==g;w++)p[w].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var Z=this.impactEvent,w=0,$;w!==f.contactEquations.length;w++)$=f.contactEquations[w],$.firstImpact&&(Z.bodyA=$.bodyA,Z.bodyB=$.bodyB,Z.shapeA=$.shapeA,Z.shapeB=$.shapeB,Z.contactEquation=$,this.emit(Z));if(this.sleepMode===a.BODY_SLEEPING)for(w=0;w!==g;w++)p[w].sleepTick(this.time,!1,t);else if(this.sleepMode===a.ISLAND_SLEEPING&&this.islandSplit){for(w=0;w!==g;w++)p[w].sleepTick(this.time,!0,t);for(var w=0,Q;w<this.islandManager.islands.length;w++)Q=this.islandManager.islands[w],Q.wantsToSleep()&&Q.sleep()}this.stepping=!1;for(var ee=this.bodiesToBeRemoved,w=0;w!==ee.length;w++)this.removeBody(ee[w]);ee.length=0,this.emit(this.postStepEvent)},a.prototype.runNarrowphase=function(t,a,r,n,s,l,p,c,u,h,g){if(0!=(r.collisionGroup&p.collisionMask)&&0!=(p.collisionGroup&r.collisionMask)){d.rotate(X,n,a.angle),d.rotate(V,c,l.angle),d.add(X,X,a.position),d.add(V,V,l.position);var y=s+a.angle,x=u+l.angle;t.enableFriction=0<h.friction,t.frictionCoefficient=h.friction;var b;b=a.type===m.STATIC||a.type===m.KINEMATIC?l.mass:l.type===m.STATIC||l.type===m.KINEMATIC?a.mass:a.mass*l.mass/(a.mass+l.mass),t.slipForce=h.friction*g*b,t.restitution=h.restitution,t.surfaceVelocity=h.surfaceVelocity,t.frictionStiffness=h.frictionStiffness,t.frictionRelaxation=h.frictionRelaxation,t.stiffness=h.stiffness,t.relaxation=h.relaxation,t.contactSkinSize=h.contactSkinSize,t.enabledEquations=a.collisionResponse&&l.collisionResponse&&r.collisionResponse&&p.collisionResponse;var _=t[r.type|p.type],v=0;if(_){var T=r.sensor||p.sensor,C=t.frictionEquations.length;v=r.type<p.type?_.call(t,a,r,X,y,l,p,V,x,T):_.call(t,l,p,V,x,a,r,X,y,T);var P=t.frictionEquations.length-C;if(v){if(a.allowSleep&&a.type===m.DYNAMIC&&a.sleepState===m.SLEEPING&&l.sleepState===m.AWAKE&&l.type!==m.STATIC){var S=d.squaredLength(l.velocity)+o(l.angularVelocity,2),w=o(l.sleepSpeedLimit,2);S>=2*w&&(a._wakeUpAfterNarrowphase=!0)}if(l.allowSleep&&l.type===m.DYNAMIC&&l.sleepState===m.SLEEPING&&a.sleepState===m.AWAKE&&a.type!==m.STATIC){var A=d.squaredLength(a.velocity)+o(a.angularVelocity,2),E=o(a.sleepSpeedLimit,2);A>=2*E&&(l._wakeUpAfterNarrowphase=!0)}if(this.overlapKeeper.setOverlapping(a,r,l,p),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(r,p)){var R=this.beginContactEvent;if(R.shapeA=r,R.shapeB=p,R.bodyA=a,R.bodyB=l,R.contactEquations.length=0,"number"==typeof v)for(var e=t.contactEquations.length-v;e<t.contactEquations.length;e++)R.contactEquations.push(t.contactEquations[e]);this.emit(R)}if("number"==typeof v&&1<P)for(var e=t.frictionEquations.length-P,i;e<t.frictionEquations.length;e++)i=t.frictionEquations[e],i.setSlipForce(i.getSlipForce()/P)}}}},a.prototype.addSpring=function(e){this.springs.push(e);var t=this.addSpringEvent;t.spring=e,this.emit(t),t.spring=null},a.prototype.removeSpring=function(e){var t=this.springs.indexOf(e);-1!==t&&B.splice(this.springs,t,1)},a.prototype.addBody=function(e){if(-1===this.bodies.indexOf(e)){this.bodies.push(e),e.world=this;var t=this.addBodyEvent;t.body=e,this.emit(t),t.body=null}},a.prototype.removeBody=function(e){if(this.stepping)this.bodiesToBeRemoved.push(e);else{e.world=null;var t=this.bodies.indexOf(e);-1!==t&&(B.splice(this.bodies,t,1),this.removeBodyEvent.body=e,e.resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}},a.prototype.getBodyById=function(e){for(var t=this.bodies,a=0,o;a<t.length;a++)if(o=t[a],o.id===e)return o;return!1},a.prototype.disableBodyCollision=function(e,t){this.disabledBodyCollisionPairs.push(e,t)},a.prototype.enableBodyCollision=function(e,t){for(var a=this.disabledBodyCollisionPairs,o=0;o<a.length;o+=2)if(a[o]===e&&a[o+1]===t||a[o+1]===e&&a[o]===t)return void a.splice(o,2)},a.prototype.clear=function(){this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(var e=this.constraints,t=e.length-1;0<=t;t--)this.removeConstraint(e[t]);for(var o=this.bodies,t=o.length-1;0<=t;t--)this.removeBody(o[t]);for(var r=this.springs,t=r.length-1;0<=t;t--)this.removeSpring(r[t]);for(var n=this.contactMaterials,t=n.length-1;0<=t;t--)this.removeContactMaterial(n[t]);a.apply(this)};var Y=d.create(),z=d.fromValues(0,0),K=d.fromValues(0,0);a.prototype.hitTest=function(e,t,o){o=o||0;var r=new m({position:e}),g=new h,y=e,f=0,_=Y;r.addShape(g);for(var x=this.narrowphase,n=[],v=0,i=t.length,T;v!==i;v++){T=t[v];for(var b=0,C=T.shapes.length,P;b!==C;b++){P=T.shapes[b],d.rotate(_,P.position,T.angle),d.add(_,_,T.position);var s=P.angle+T.angle;(P instanceof l&&x.circleParticle(T,P,_,s,r,g,y,f,!0)||P instanceof p&&x.particleConvex(r,g,y,f,T,P,_,s,!0)||P instanceof c&&x.particlePlane(r,g,y,f,T,P,_,s,!0)||P instanceof u&&x.particleCapsule(r,g,y,f,T,P,_,s,!0)||P instanceof h&&d.squaredLength(d.sub(K,_,e))<o*o)&&n.push(T)}}return n},a.prototype.setGlobalStiffness=function(e){for(var t=this.constraints,a=0,o;a!==t.length;a++){o=t[a];for(var r=0,n;r!==o.equations.length;r++)n=o.equations[r],n.stiffness=e,n.needsUpdate=!0}for(var i=this.contactMaterials,a=0,o;a!==i.length;a++)o=i[a],o.stiffness=o.frictionStiffness=e;var o=this.defaultContactMaterial;o.stiffness=o.frictionStiffness=e},a.prototype.setGlobalRelaxation=function(e){for(var t=0,a;t!==this.constraints.length;t++){a=this.constraints[t];for(var o=0,r;o!==a.equations.length;o++)r=a.equations[o],r.relaxation=e,r.needsUpdate=!0}for(var t=0,a;t!==this.contactMaterials.length;t++)a=this.contactMaterials[t],a.relaxation=a.frictionRelaxation=e;var a=this.defaultContactMaterial;a.relaxation=a.frictionRelaxation=e};var J=new E,Q=[];a.prototype.raycast=function(e,t){return t.getAABB(J),this.broadphase.aabbQuery(this,J,Q),t.intersectBodies(e,Q),Q.length=0,e.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){function e(e,t,a,o){var r=e.createTexture();return e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o===l.scaleModes.LINEAR?e.LINEAR:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o===l.scaleModes.LINEAR?e.LINEAR:e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,a,0,e.RGBA,e.UNSIGNED_BYTE,null),r}function t(t,a,o,r,n){var i=t.createFramebuffer(),s=t.createRenderbuffer(),l=null,p=0;return t.activeTexture(t.TEXTURE0+n),t.bindFramebuffer(t.FRAMEBUFFER,i),t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.renderBuffer),l=e(t,a,o,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),p=t.checkFramebufferStatus(t.FRAMEBUFFER),p!==t.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",d[p]),i.width=a,i.height=o,i.targetTexture=l,i.renderBuffer=s,i}var a=Math.ceil,o=Math.floor,r=Math.max,n=Math.acos,i=Math.sqrt,s=this,l=l||{};l.DisplayObject=function(){this.position=new l.Point(0,0),this.scale=new l.Point(1,1),this.pivot=new l.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new Phaser.Matrix,this.worldPosition=new l.Point(0,0),this.worldScale=new l.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new l.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},l.DisplayObject.prototype={constructor:l.DisplayObject,destroy:function(){if(this.children){for(var e=this.children.length;e--;)this.children[e].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite()},updateTransform:function(e){if(!e&&!this.parent&&!this.game)return this;var t=this.parent;e?t=e:!this.parent&&(t=this.game.world);var o=t.worldTransform,l=this.worldTransform,p,a,u,h,d,g;this.rotation%Phaser.Math.PI2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),p=this._cr*this.scale.x,a=this._sr*this.scale.x,u=-this._sr*this.scale.y,h=this._cr*this.scale.y,d=this.position.x,g=this.position.y,(this.pivot.x||this.pivot.y)&&(d-=this.pivot.x*p+this.pivot.y*u,g-=this.pivot.x*a+this.pivot.y*h),l.a=p*o.a+a*o.c,l.b=p*o.b+a*o.d,l.c=u*o.a+h*o.c,l.d=u*o.b+h*o.d,l.tx=d*o.a+g*o.c+o.tx,l.ty=d*o.b+g*o.d+o.ty):(p=this.scale.x,a=0,u=0,h=this.scale.y,d=this.position.x-this.pivot.x*p,g=this.position.y-this.pivot.y*h,l.a=p*o.a,l.b=p*o.b,l.c=h*o.c,l.d=h*o.d,l.tx=d*o.a+g*o.c+o.tx,l.ty=d*o.b+g*o.d+o.ty),p=l.a,a=l.b,u=l.c,h=l.d;var m=p*h-a*u;if(p||a){var y=i(p*p+a*a);this.worldRotation=0<a?n(p/y):-n(p/y),this.worldScale.x=y,this.worldScale.y=m/y}else if(u||h){var r=i(u*u+h*h);this.worldRotation=Phaser.Math.HALF_PI-(0<h?n(-u/r):-n(u/r)),this.worldScale.x=m/r,this.worldScale.y=r}else this.worldScale.x=0,this.worldScale.y=0;return this.worldAlpha=this.alpha*t.worldAlpha,this.worldPosition.x=l.tx,this.worldPosition.y=l.ty,this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,l,o),this},preUpdate:function(){},generateTexture:function(e,t,a){var o=this.getLocalBounds(),r=new Phaser.RenderTexture(this.game,0|o.width,0|o.height,a,t,e);return l.DisplayObject._tempMatrix.tx=-o.x,l.DisplayObject._tempMatrix.ty=-o.y,r.render(this,l.DisplayObject._tempMatrix),r},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(e){return this.updateTransform(),this.worldTransform.apply(e)},toLocal:function(e,t){return t&&(e=t.toGlobal(e)),this.updateTransform(),this.worldTransform.applyInverse(e)},_renderCachedSprite:function(e){this._cachedSprite.worldAlpha=this.worldAlpha,e.gl?l.Sprite.prototype._renderWebGL.call(this._cachedSprite,e):l.Sprite.prototype._renderCanvas.call(this._cachedSprite,e)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var e=this.getLocalBounds();if(e.width=r(1,a(e.width)),e.height=r(1,a(e.height)),this.updateTransform(),!this._cachedSprite){var t=0;this.texture&&this.texture.baseTexture&&l._enableMultiTextureToggle&&(t=this.texture.baseTexture.textureIndex);var o=new Phaser.RenderTexture(this.game,e.width,e.height,void 0,void 0,void 0,void 0,t);this._cachedSprite=new l.Sprite(o),this._cachedSprite.worldTransform=this.worldTransform}else this._cachedSprite.texture.resize(e.width,e.height);var n=this._filters;this._filters=null,this._cachedSprite.filters=n,l.DisplayObject._tempMatrix.tx=-e.x,l.DisplayObject._tempMatrix.ty=-e.y,this._cachedSprite.texture.render(this,l.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-(e.x/e.width),this._cachedSprite.anchor.y=-(e.y/e.height),this._filters=n,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},l.DisplayObject.prototype.displayObjectUpdateTransform=l.DisplayObject.prototype.updateTransform,Object.defineProperties(l.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(e){this.position.x=e}},y:{get:function(){return this.position.y},set:function(e){this.position.y=e}},worldVisible:{get:function(){if(!this.visible)return!1;var e=this.parent;if(!e)return this.visible;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}},mask:{get:function(){return this._mask},set:function(e){this._mask&&(this._mask.isMask=!1),this._mask=e,e&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(e){if(Array.isArray(e)){for(var t=[],a=0,o;a<e.length;a++){o=e[a].passes;for(var r=0;r<o.length;r++)t.push(o[r])}this._filterBlock={target:this,filterPasses:t}}this._filters=e,this.blendMode&&this.blendMode===l.blendModes.MULTIPLY&&(this.blendMode=l.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(e){this._cacheAsBitmap===e||(e?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=e)}}}),l.DisplayObjectContainer=function(){l.DisplayObject.call(this),this.children=[],this.ignoreChildInput=!1},l.DisplayObjectContainer.prototype=Object.create(l.DisplayObject.prototype),l.DisplayObjectContainer.prototype.constructor=l.DisplayObjectContainer,l.DisplayObjectContainer.prototype.addChild=function(e){return this.addChildAt(e,this.children.length)},l.DisplayObjectContainer.prototype.addChildAt=function(e,t){if(0<=t&&t<=this.children.length)return e.parent&&e.parent.removeChild(e),e.parent=this,this.children.splice(t,0,e),e;throw new Error(e+"addChildAt: The index "+t+" supplied is out of bounds "+this.children.length)},l.DisplayObjectContainer.prototype.swapChildren=function(e,t){if(e!==t){var a=this.getChildIndex(e),o=this.getChildIndex(t);if(0>a||0>o)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[a]=t,this.children[o]=e}},l.DisplayObjectContainer.prototype.getChildIndex=function(e){var t=this.children.indexOf(e);if(-1===t)throw new Error("The supplied DisplayObject must be a child of the caller");return t},l.DisplayObjectContainer.prototype.setChildIndex=function(e,t){if(0>t||t>=this.children.length)throw new Error("The supplied index is out of bounds");var a=this.getChildIndex(e);this.children.splice(a,1),this.children.splice(t,0,e)},l.DisplayObjectContainer.prototype.getChildAt=function(e){if(0>e||e>=this.children.length)throw new Error("getChildAt: Supplied index "+e+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[e]},l.DisplayObjectContainer.prototype.removeChild=function(e){var t=this.children.indexOf(e);return-1===t?void 0:this.removeChildAt(t)},l.DisplayObjectContainer.prototype.removeChildAt=function(e){var t=this.getChildAt(e);return t&&(t.parent=void 0,this.children.splice(e,1)),t},l.DisplayObjectContainer.prototype.removeChildren=function(e,t){void 0===e&&(e=0),void 0===t&&(t=this.children.length);var a=t-e;if(0<a&&a<=t){for(var o=this.children.splice(e,a),r=0,n;r<o.length;r++)n=o[r],n.parent=void 0;return o}if(0==a&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},l.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var e=0;e<this.children.length;e++)this.children[e].updateTransform()},l.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=l.DisplayObjectContainer.prototype.updateTransform,l.DisplayObjectContainer.prototype.getBounds=function(e){var t=e&&e instanceof l.DisplayObject,o=!0;t?e instanceof l.DisplayObjectContainer?o=e.contains(this):o=!1:e=this;var r;if(t){var n=e.worldTransform;for(e.worldTransform=Phaser.identityMatrix,r=0;r<e.children.length;r++)e.children[r].updateTransform()}var i=Infinity,s=Infinity,p=-Infinity,u=-Infinity,h=!1,g,m,y;for(r=0;r<this.children.length;r++){var f=this.children[r];f.visible&&(h=!0,g=this.children[r].getBounds(),i=i<g.x?i:g.x,s=s<g.y?s:g.y,m=g.width+g.x,y=g.height+g.y,p=p>m?p:m,u=u>y?u:y)}var x=this._bounds;if(!h){x=new l.Rectangle;var _=x.x,v=x.width+x.x,T=x.y,C=x.height+x.y,P=this.worldTransform,S=P.a,a=P.b,b=P.c,c=P.d,d=P.tx,w=P.ty,A=S*v+b*C+d,E=c*C+a*v+w,R=S*_+b*C+d,L=c*C+a*_+w,B=S*_+b*T+d,k=c*T+a*_+w,F=S*v+b*T+d,D=c*T+a*v+w;p=A,u=E,i=A,s=E,i=R<i?R:i,i=B<i?B:i,i=F<i?F:i,s=L<s?L:s,s=k<s?k:s,s=D<s?D:s,p=R>p?R:p,p=B>p?B:p,p=F>p?F:p,u=L>u?L:u,u=k>u?k:u,u=D>u?D:u}if(x.x=i,x.y=s,x.width=p-i,x.height=u-s,t)for(e.worldTransform=n,r=0;r<e.children.length;r++)e.children[r].updateTransform();if(!o){var M=e.getBounds();x.x-=M.x,x.y-=M.y}return x},l.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},l.DisplayObjectContainer.prototype.contains=function(e){return!!e&&(e===this||this.contains(e.parent))},l.DisplayObjectContainer.prototype._renderWebGL=function(e){if(this.visible&&!(0>=this.alpha)){if(this._cacheAsBitmap)return void this._renderCachedSprite(e);var t;if(this._mask||this._filters){for(this._filters&&(e.spriteBatch.flush(),e.filterManager.pushFilter(this._filterBlock)),this._mask&&(e.spriteBatch.stop(),e.maskManager.pushMask(this.mask,e),e.spriteBatch.start()),t=0;t<this.children.length;t++)this.children[t]._renderWebGL(e);e.spriteBatch.stop(),this._mask&&e.maskManager.popMask(this._mask,e),this._filters&&e.filterManager.popFilter(),e.spriteBatch.start()}else for(t=0;t<this.children.length;t++)this.children[t]._renderWebGL(e)}},l.DisplayObjectContainer.prototype._renderCanvas=function(e){if(!1!==this.visible&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(e);this._mask&&e.maskManager.pushMask(this._mask,e);for(var t=0;t<this.children.length;t++)this.children[t]._renderCanvas(e);this._mask&&e.maskManager.popMask(e)}},Object.defineProperty(l.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(e){var t=this.getLocalBounds().width;this.scale.x=0===t?1:e/t,this._width=e}}),Object.defineProperty(l.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(e){var t=this.getLocalBounds().height;this.scale.y=0===t?1:e/t,this._height=e}}),l.Sprite=function(e){l.DisplayObjectContainer.call(this),this.anchor=new l.Point(l.Sprite.defaultAnchor.x,l.Sprite.defaultAnchor.y),this.texture=e||l.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=l.blendModes.NORMAL,this.shader=null,this.exists=!0,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},l.Sprite.defaultAnchor={x:0,y:0},l.Sprite.prototype=Object.create(l.DisplayObjectContainer.prototype),l.Sprite.prototype.constructor=l.Sprite,Object.defineProperty(l.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(e){this.scale.x=e/this.texture.frame.width,this._width=e}}),Object.defineProperty(l.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(e){this.scale.y=e/this.texture.frame.height,this._height=e}}),l.Sprite.prototype.setTexture=function(e,t){t&&this.texture.baseTexture.destroy(),this.texture.baseTexture.skipRender=!1,this.texture=e,this.texture.valid=!0,this.cachedTint=-1},l.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},l.Sprite.prototype.getBounds=function(e){var t=this.texture.frame.width,o=this.texture.frame.height,r=t*(1-this.anchor.x),n=t*-this.anchor.x,i=o*(1-this.anchor.y),s=o*-this.anchor.y,l=e||this.worldTransform,p=l.a,a=l.b,u=l.c,c=l.d,d=l.tx,h=l.ty,g=-Infinity,m=-Infinity,y=Infinity,f=Infinity;if(0===a&&0===u){if(0>p){p*=-1;var x=r;r=-n,n=-x}if(0>c){c*=-1;var x=i;i=-s,s=-x}y=p*n+d,g=p*r+d,f=c*s+h,m=c*i+h}else{var b=p*n+u*s+d,_=c*s+a*n+h,v=p*r+u*s+d,T=c*s+a*r+h,C=p*r+u*i+d,P=c*i+a*r+h,S=p*n+u*i+d,w=c*i+a*n+h;y=b<y?b:y,y=v<y?v:y,y=C<y?C:y,y=S<y?S:y,f=_<f?_:f,f=T<f?T:f,f=P<f?P:f,f=w<f?w:f,g=b>g?b:g,g=v>g?v:g,g=C>g?C:g,g=S>g?S:g,m=_>m?_:m,m=T>m?T:m,m=P>m?P:m,m=w>m?w:m}var A=this._bounds;return A.x=y,A.width=g-y,A.y=f,A.height=m-f,this._currentBounds=A,A},l.Sprite.prototype.getLocalBounds=function(){var e=this.worldTransform;this.worldTransform=Phaser.identityMatrix;for(var t=0;t<this.children.length;t++)this.children[t].updateTransform();var a=this.getBounds();for(this.worldTransform=e,t=0;t<this.children.length;t++)this.children[t].updateTransform();return a},l.Sprite.prototype._renderWebGL=function(e,t){if(this.visible&&!(0>=this.alpha)&&this.renderable){var a=this.worldTransform;if(t&&(a=t),this._mask||this._filters){var o=e.spriteBatch;this._filters&&(o.flush(),e.filterManager.pushFilter(this._filterBlock)),this._mask&&(o.stop(),e.maskManager.pushMask(this.mask,e),o.start()),o.render(this);for(var r=0;r<this.children.length;r++)this.children[r]._renderWebGL(e);o.stop(),this._mask&&e.maskManager.popMask(this._mask,e),this._filters&&e.filterManager.popFilter(),o.start()}else{e.spriteBatch.render(this);for(var r=0;r<this.children.length;r++)this.children[r]._renderWebGL(e,a)}}},l.Sprite.prototype._renderCanvas=function(t,r){if(this.visible&&0!==this.alpha&&this.renderable&&!(0>=this.texture.crop.width)&&!(0>=this.texture.crop.height)){var n=this.worldTransform;if(r&&(n=r),this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=l.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t),!this.texture.valid){for(var s=0;s<this.children.length;s++)this.children[s]._renderCanvas(t);return void(this._mask&&t.maskManager.popMask(t))}var i=this.texture.baseTexture.resolution/t.resolution;t.context.globalAlpha=this.worldAlpha,t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===l.scaleModes.LINEAR);var p=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,u=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,h=n.tx*t.resolution+t.shakeX,g=n.ty*t.resolution+t.shakeY,m=this.texture.crop.width,y=this.texture.crop.height;if(this.texture.rotated){var f=n.a,a=n.b,x=n.c,b=n.d,_=m;h=n.c*y+h,g=n.d*y+g,n.a=6.123233995736766e-17*f+-x,n.b=6.123233995736766e-17*a+-b,n.c=f+6.123233995736766e-17*x,n.d=a+6.123233995736766e-17*b,m=y,y=_}if(t.roundPixels?(t.context.setTransform(n.a,n.b,n.c,n.d,0|h,0|g),p|=0,u|=0):t.context.setTransform(n.a,n.b,n.c,n.d,h,g),p/=i,u/=i,16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=l.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),t.context.drawImage(this.tintedTexture,0,0,m,y,p,u,m/i,y/i);else{var e=this.texture.crop.x,v=this.texture.crop.y;m=o(m),y=o(y),t.context.drawImage(this.texture.baseTexture.source,e,v,m,y,p,u,m/i,y/i)}for(var s=0;s<this.children.length;s++)this.children[s]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},l.initDefaultShaders=function(){},l.CompileVertexShader=function(e,t){return l._CompileShader(e,t,e.VERTEX_SHADER)},l.CompileFragmentShader=function(e,t){return l._CompileShader(e,t,e.FRAGMENT_SHADER)},l._CompileShader=function(e,t,a){var o=t;Array.isArray(t)&&(o=t.join("\n"));var r=e.createShader(a);return e.shaderSource(r,o),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(window.console.log(e.getShaderInfoLog(r)),null)},l.compileProgram=function(e,t,a){var o=l.CompileFragmentShader(e,a),r=l.CompileVertexShader(e,t),n=e.createProgram();return e.attachShader(n,r),e.attachShader(n,o),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)||(window.console.log(e.getProgramInfoLog(n)),window.console.log("Could not initialise shaders")),n},l.PixiShader=function(e){this._UID=Phaser._UID++,this.gl=e,this.program=null,this.fragmentSrc=null,this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},l.PixiShader.prototype.constructor=l.PixiShader,l.PixiShader.prototype.initMultitexShader=function(){var e=this.gl;this.MAX_TEXTURES=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(var t="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",a=1;a<this.MAX_TEXTURES;++a)t+="\tif (vTextureIndex == "+a+".0) {gl_FragColor = texture2D(uSamplerArray["+a+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiShader Fragment Shader.","precision lowp float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",t,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];var o=l.compileProgram(e,this.vertexSrc||l.PixiShader.defaultVertexSrc,this.fragmentSrc);e.useProgram(o),this.uSamplerArray=e.getUniformLocation(o,"uSamplerArray[0]"),this.projectionVector=e.getUniformLocation(o,"projectionVector"),this.offsetVector=e.getUniformLocation(o,"offsetVector"),this.dimensions=e.getUniformLocation(o,"dimensions"),this.aVertexPosition=e.getAttribLocation(o,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(o,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(o,"aColor"),this.aTextureIndex=e.getAttribLocation(o,"aTextureIndex");var r=[],n=e.createTexture();e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGB,1,1,0,e.RGB,e.UNSIGNED_BYTE,null);for(var s=0;s<this.MAX_TEXTURES;++s)e.activeTexture(e.TEXTURE0+s),e.bindTexture(e.TEXTURE_2D,n),r.push(s);for(var i in e.activeTexture(e.TEXTURE0),e.uniform1iv(this.uSamplerArray,r),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.uniforms)this.uniforms[i].uniformLocation=e.getUniformLocation(o,i);this.initUniforms(),this.program=o},l.PixiShader.prototype.initDefaultShader=function(){null===this.fragmentSrc&&(this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"]);var e=this.gl,t=l.compileProgram(e,this.vertexSrc||l.PixiShader.defaultVertexSrc,this.fragmentSrc);for(var a in e.useProgram(t),this.uSampler=e.getUniformLocation(t,"uSampler"),this.projectionVector=e.getUniformLocation(t,"projectionVector"),this.offsetVector=e.getUniformLocation(t,"offsetVector"),this.dimensions=e.getUniformLocation(t,"dimensions"),this.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(t,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(t,"aColor"),this.aTextureIndex=e.getAttribLocation(t,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.uniforms)this.uniforms[a].uniformLocation=e.getUniformLocation(t,a);this.initUniforms(),this.program=t},l.PixiShader.prototype.init=function(e){l._enableMultiTextureToggle&&!e?this.initMultitexShader():this.initDefaultShader()},l.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var e=this.gl,t;for(var a in this.uniforms){t=this.uniforms[a];var o=t.type;"sampler2D"===o?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===o||"mat3"===o||"mat4"===o?(t.glMatrix=!0,t.glValueLength=1,"mat2"===o?t.glFunc=e.uniformMatrix2fv:"mat3"===o?t.glFunc=e.uniformMatrix3fv:"mat4"===o&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+o],t.glValueLength="2f"===o||"2i"===o?2:"3f"===o||"3i"===o?3:"4f"===o||"4i"===o?4:1)}},l.PixiShader.prototype.initSampler2D=function(e){if(e.value&&e.value.baseTexture&&e.value.baseTexture.hasLoaded){var t=this.gl;if(t.activeTexture(t.TEXTURE0+this.textureCount),t.bindTexture(t.TEXTURE_2D,e.value.baseTexture._glTextures[t.id]),e.textureData){var a=e.textureData,o=a.magFilter?a.magFilter:t.LINEAR,r=a.minFilter?a.minFilter:t.LINEAR,n=a.wrapS?a.wrapS:t.CLAMP_TO_EDGE,i=a.wrapT?a.wrapT:t.CLAMP_TO_EDGE,s=a.luminance?t.LUMINANCE:t.RGBA;if(a.repeat&&(n=t.REPEAT,i=t.REPEAT),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!!a.flipY),a.width){var d=a.width?a.width:512,l=a.height?a.height:2,p=a.border?a.border:0;t.texImage2D(t.TEXTURE_2D,0,s,d,l,p,s,t.UNSIGNED_BYTE,null)}else t.texImage2D(t.TEXTURE_2D,0,s,t.RGBA,t.UNSIGNED_BYTE,e.value.baseTexture.source);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i)}t.uniform1i(e.uniformLocation,this.textureCount),e._init=!0,this.textureCount++}},l.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var e=this.gl,t;for(var a in this.uniforms)t=this.uniforms[a],1===t.glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?l.instances[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},l.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},l.PixiShader.defaultVertexSrc=["// PixiShader Vertex Shader","// With multi-texture rendering","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   if (aTextureIndex > 0.0) gl_Position = vec4(0.0);","   gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vColor = vec4(aColor.rgb * aColor.a, aColor.a);","   vTextureIndex = aTextureIndex;","}"],l.PixiFastShader=function(e){if(this._UID=Phaser._UID++,this.gl=e,this.program=null,l._enableMultiTextureToggle){var e=this.gl;this.MAX_TEXTURES=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(var t="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",a=1;a<this.MAX_TEXTURES;++a)t+="\tif (vTextureIndex == "+a+".0) { gl_FragColor = texture2D(uSamplerArray["+a+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",t,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   vec2 v;","   vec2 sv = aVertexPosition * aScale;","   v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);","   v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);","   v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;","   gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vTextureIndex = aTextureIndex;","   vColor = aColor;","}"],this.textureCount=0,this.init()},l.PixiFastShader.prototype.constructor=l.PixiFastShader,l.PixiFastShader.prototype.init=function(){var e=this.gl,t=l.compileProgram(e,this.vertexSrc,this.fragmentSrc);if(e.useProgram(t),this.uSampler=l._enableMultiTextureToggle?e.getUniformLocation(t,"uSamplerArray[0]"):e.getUniformLocation(t,"uSampler"),l._enableMultiTextureToggle){var a=[],o=e.createTexture();e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGB,1,1,0,e.RGB,e.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,o),a.push(r);e.activeTexture(e.TEXTURE0),e.uniform1iv(this.uSampler,a)}this.projectionVector=e.getUniformLocation(t,"projectionVector"),this.offsetVector=e.getUniformLocation(t,"offsetVector"),this.dimensions=e.getUniformLocation(t,"dimensions"),this.uMatrix=e.getUniformLocation(t,"uMatrix"),this.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),this.aPositionCoord=e.getAttribLocation(t,"aPositionCoord"),this.aScale=e.getAttribLocation(t,"aScale"),this.aRotation=e.getAttribLocation(t,"aRotation"),this.aTextureCoord=e.getAttribLocation(t,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(t,"aColor"),this.aTextureIndex=e.getAttribLocation(t,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.program=t},l.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},l.StripShader=function(e){if(this._UID=Phaser._UID++,this.gl=e,this.program=null,l._enableMultiTextureToggle){var e=this.gl;this.MAX_TEXTURES=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(var t="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord);return;}\n",a=1;a<this.MAX_TEXTURES;++a)t+="\tif (vTextureIndex == "+a+".0) { gl_FragColor = texture2D(uSamplerArray["+a+"], vTextureCoord) ;return;}\n";this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",t,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vTextureIndex;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vTextureIndex = aTextureIndex;","}"],this.init()},l.StripShader.prototype.constructor=l.StripShader,l.StripShader.prototype.init=function(){var e=this.gl,t=l.compileProgram(e,this.vertexSrc,this.fragmentSrc);if(e.useProgram(t),this.uSampler=l._enableMultiTextureToggle?e.getUniformLocation(t,"uSamplerArray[0]"):e.getUniformLocation(t,"uSampler"),l._enableMultiTextureToggle){var a=[],o=e.createTexture();e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGB,1,1,0,e.RGB,e.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,o),a.push(r);e.activeTexture(e.TEXTURE0),e.uniform1iv(this.uSampler,a)}this.projectionVector=e.getUniformLocation(t,"projectionVector"),this.offsetVector=e.getUniformLocation(t,"offsetVector"),this.colorAttribute=e.getAttribLocation(t,"aColor"),this.aTextureIndex=e.getAttribLocation(t,"aTextureIndex"),this.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(t,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.aTextureIndex],this.translationMatrix=e.getUniformLocation(t,"translationMatrix"),this.alpha=e.getUniformLocation(t,"alpha"),this.program=t},l.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},l.PrimitiveShader=function(e){this._UID=Phaser._UID++,this.gl=e,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);","   vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},l.PrimitiveShader.prototype.constructor=l.PrimitiveShader,l.PrimitiveShader.prototype.init=function(){var e=this.gl,t=l.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(t),this.projectionVector=e.getUniformLocation(t,"projectionVector"),this.offsetVector=e.getUniformLocation(t,"offsetVector"),this.tintColor=e.getUniformLocation(t,"tint"),this.flipY=e.getUniformLocation(t,"flipY"),this.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),this.colorAttribute=e.getAttribLocation(t,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=e.getUniformLocation(t,"translationMatrix"),this.alpha=e.getUniformLocation(t,"alpha"),this.program=t},l.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},l.ComplexPrimitiveShader=function(e){this._UID=Phaser._UID++,this.gl=e,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);","   vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},l.ComplexPrimitiveShader.prototype.constructor=l.ComplexPrimitiveShader,l.ComplexPrimitiveShader.prototype.init=function(){var e=this.gl,t=l.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(t),this.projectionVector=e.getUniformLocation(t,"projectionVector"),this.offsetVector=e.getUniformLocation(t,"offsetVector"),this.tintColor=e.getUniformLocation(t,"tint"),this.color=e.getUniformLocation(t,"color"),this.flipY=e.getUniformLocation(t,"flipY"),this.aVertexPosition=e.getAttribLocation(t,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=e.getUniformLocation(t,"translationMatrix"),this.alpha=e.getUniformLocation(t,"alpha"),this.program=t},l.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},l.glContexts=[],l.instances=[],l._enableMultiTextureToggle=!1,l.WebGLRenderer=function(e){this.game=e,l.defaultRenderer||(l.defaultRenderer=this),this.extensions={},this.type=Phaser.WEBGL,this.resolution=e.resolution,this.transparent=e.transparent,this.autoResize=!1,this.preserveDrawingBuffer=e.preserveDrawingBuffer,this.clearBeforeRender=e.clearBeforeRender,this.width=e.width,this.height=e.height,this.view=e.canvas,this._contextOptions={alpha:this.transparent,antialias:e.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer},this.projection=new l.Point,this.offset=new l.Point,this.shaderManager=new l.WebGLShaderManager,this.spriteBatch=new l.WebGLSpriteBatch(e),this.maskManager=new l.WebGLMaskManager,this.filterManager=new l.WebGLFilterManager,this.stencilManager=new l.WebGLStencilManager,this.blendModeManager=new l.WebGLBlendModeManager,this.renderSession={},this.currentBatchedTextures=[],this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.renderSession.roundPixels=!1,this.renderSession.maxTextureAvailableSpace=null,this.initContext(),this.mapBlendModes()},l.WebGLRenderer.prototype.constructor=l.WebGLRenderer,l.WebGLRenderer.prototype.initContext=function(){var e=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=e,!e)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=this.gl.getParameter(e.MAX_TEXTURE_SIZE),this.glContextId=e.id=l.WebGLRenderer.glContextId++,l.glContexts[this.glContextId]=e,l.instances[this.glContextId]=this,e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.enable(e.BLEND),this.shaderManager.setContext(e),this.spriteBatch.setContext(e),this.maskManager.setContext(e),this.filterManager.setContext(e),this.blendModeManager.setContext(e),this.stencilManager.setContext(e),this.renderSession.gl=this.gl,this.resize(this.width,this.height),this.extensions.compression={};var t=e.getExtension("WEBGL_compressed_texture_etc1")||e.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),a=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),o=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");t&&(this.extensions.compression.ETC1=t),a&&(this.extensions.compression.PVRTC=a),o&&(this.extensions.compression.S3TC=o)},l.WebGLRenderer.prototype.setTexturePriority=function(e){if(!l._enableMultiTextureToggle)return void console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.");for(var t=function(e){return--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},a=this.gl,o=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),n=a.getParameter(a.MAX_TEXTURE_SIZE),s=this.game.cache._cache.image,d=null,p=0;p<this.currentBatchedTextures.length;p++){if(d=this.currentBatchedTextures[p],!(d in s)){console.warn("setTexturePriority: There is no image \"%s\" in the image cache.",d);continue}s[d].base.textureIndex=0}var i=n-t(r(this.width,this.height));this.currentBatchedTextures.length=0;for(var c=0;c<e.length;++c){if(d=e[c],!(d in s)){console.warn("setTexturePriority: There is no image \"%s\" in the image cache.",d);continue}var u=s[d].base;i-=t(r(u.width,u.height)),0>=i?(u.textureIndex=0,console.warn("setTexturePriority: Image \"%s\" was given textureIndex=0 because there is no available texture space (%s).",d,i)):u.textureIndex=1+c%(o-1),this.currentBatchedTextures.push(d)}return this.renderSession.maxTextureAvailableSpace=i,this.currentBatchedTextures},l.WebGLRenderer.prototype.render=function(e){if(!this.contextLost){var t=this.gl;t.viewport(0,0,this.width,this.height),t.bindFramebuffer(t.FRAMEBUFFER,null),this.game.clearBeforeRender&&(t.clearColor(e._bgColor.r,e._bgColor.g,e._bgColor.b,e._bgColor.a),t.clear(t.COLOR_BUFFER_BIT)),this.offset.x=this.game.camera._shake.x,this.offset.y=this.game.camera._shake.y,this.renderDisplayObject(e,this.projection)}},l.WebGLRenderer.prototype.renderDisplayObject=function(e,t,a,o){this.renderSession.blendModeManager.setBlendMode(l.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=a?-1:1,this.renderSession.projection=t,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,a),e._renderWebGL(this.renderSession,o),this.spriteBatch.end()},l.WebGLRenderer.prototype.resize=function(e,t){this.width=e*this.resolution,this.height=t*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},l.WebGLRenderer.prototype.updateCompressedTexture=function(e){if(!e.hasLoaded)return!1;var t=this.gl,a=e.source;return e._glTextures[t.id]||(e._glTextures[t.id]=t.createTexture()),t.activeTexture(t.TEXTURE0+e.textureIndex),t.bindTexture(t.TEXTURE_2D,e._glTextures[t.id]),t.compressedTexImage2D(t.TEXTURE_2D,0,a.glExtensionFormat,a.width,a.height,0,a.textureData),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR:t.NEAREST),e.mipmap&&Phaser.Math.isPowerOfTwo(e.width,e.height)?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR_MIPMAP_LINEAR:t.NEAREST_MIPMAP_NEAREST),t.generateMipmap(t.TEXTURE_2D)):t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR:t.NEAREST),e._powerOf2?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),e._dirty[t.id]=!1,!0},l.WebGLRenderer.prototype.updateTexture=function(e){if(!e.hasLoaded)return!1;if(e.source.compressionAlgorithm)return this.updateCompressedTexture(e);var t=this.gl;return e._glTextures[t.id]||(e._glTextures[t.id]=t.createTexture()),t.activeTexture(t.TEXTURE0+e.textureIndex),t.bindTexture(t.TEXTURE_2D,e._glTextures[t.id]),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultipliedAlpha),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.source),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR:t.NEAREST),e.mipmap&&Phaser.Math.isPowerOfTwo(e.width,e.height)?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR_MIPMAP_LINEAR:t.NEAREST_MIPMAP_NEAREST),t.generateMipmap(t.TEXTURE_2D)):t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e.scaleMode===l.scaleModes.LINEAR?t.LINEAR:t.NEAREST),e._powerOf2?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),e._dirty[t.id]=!1,!0},l.WebGLRenderer.prototype.destroy=function(){l.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,Phaser.CanvasPool.remove(this),l.instances[this.glContextId]=null,l.WebGLRenderer.glContextId--},l.WebGLRenderer.prototype.mapBlendModes=function(){var e=this.gl;if(!l.blendModesWebGL){var t=[],a=l.blendModes;t[a.NORMAL]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.ADD]=[e.SRC_ALPHA,e.DST_ALPHA],t[a.MULTIPLY]=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA],t[a.SCREEN]=[e.SRC_ALPHA,e.ONE],t[a.OVERLAY]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.DARKEN]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.LIGHTEN]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.COLOR_DODGE]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.COLOR_BURN]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.HARD_LIGHT]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.SOFT_LIGHT]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.DIFFERENCE]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.EXCLUSION]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.HUE]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.SATURATION]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.COLOR]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t[a.LUMINOSITY]=[e.ONE,e.ONE_MINUS_SRC_ALPHA],l.blendModesWebGL=t}},l.WebGLRenderer.prototype.getMaxTextureUnit=function(){var e=this.gl;return e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)},l.enableMultiTexture=function(){l._enableMultiTextureToggle=!0},l.WebGLRenderer.glContextId=0,l.WebGLRenderer.textureArray=[],l.WebGLBlendModeManager=function(){this.currentBlendMode=99999},l.WebGLBlendModeManager.prototype.constructor=l.WebGLBlendModeManager,l.WebGLBlendModeManager.prototype.setContext=function(e){this.gl=e},l.WebGLBlendModeManager.prototype.setBlendMode=function(e){if(this.currentBlendMode===e)return!1;this.currentBlendMode=e;var t=l.blendModesWebGL[this.currentBlendMode];return t&&this.gl.blendFunc(t[0],t[1]),!0},l.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},l.WebGLMaskManager=function(){},l.WebGLMaskManager.prototype.constructor=l.WebGLMaskManager,l.WebGLMaskManager.prototype.setContext=function(e){this.gl=e},l.WebGLMaskManager.prototype.pushMask=function(e,t){var a=t.gl;e.dirty&&l.WebGLGraphics.updateGraphics(e,a),void 0===e._webGL[a.id]||void 0===e._webGL[a.id].data||0===e._webGL[a.id].data.length||t.stencilManager.pushStencil(e,e._webGL[a.id].data[0],t)},l.WebGLMaskManager.prototype.popMask=function(e,t){var a=this.gl;void 0===e._webGL[a.id]||void 0===e._webGL[a.id].data||0===e._webGL[a.id].data.length||t.stencilManager.popStencil(e,e._webGL[a.id].data[0],t)},l.WebGLMaskManager.prototype.destroy=function(){this.gl=null},l.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},l.WebGLStencilManager.prototype.setContext=function(e){this.gl=e},l.WebGLStencilManager.prototype.pushStencil=function(e,t,a){var o=this.gl;this.bindGraphics(e,t,a),0===this.stencilStack.length&&(o.enable(o.STENCIL_TEST),o.clear(o.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(t);var r=this.count;o.colorMask(!1,!1,!1,!1),o.stencilFunc(o.ALWAYS,0,255),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),1===t.mode?(o.drawElements(o.TRIANGLE_FAN,t.indices.length-4,o.UNSIGNED_SHORT,0),this.reverse?(o.stencilFunc(o.EQUAL,255-r,255),o.stencilOp(o.KEEP,o.KEEP,o.DECR)):(o.stencilFunc(o.EQUAL,r,255),o.stencilOp(o.KEEP,o.KEEP,o.INCR)),o.drawElements(o.TRIANGLE_FAN,4,o.UNSIGNED_SHORT,2*(t.indices.length-4)),this.reverse?o.stencilFunc(o.EQUAL,255-(r+1),255):o.stencilFunc(o.EQUAL,r+1,255),this.reverse=!this.reverse):(this.reverse?(o.stencilFunc(o.EQUAL,r,255),o.stencilOp(o.KEEP,o.KEEP,o.INCR)):(o.stencilFunc(o.EQUAL,255-r,255),o.stencilOp(o.KEEP,o.KEEP,o.DECR)),o.drawElements(o.TRIANGLE_STRIP,t.indices.length,o.UNSIGNED_SHORT,0),this.reverse?o.stencilFunc(o.EQUAL,r+1,255):o.stencilFunc(o.EQUAL,255-(r+1),255)),o.colorMask(!0,!0,!0,!0),o.stencilOp(o.KEEP,o.KEEP,o.KEEP),this.count++},l.WebGLStencilManager.prototype.bindGraphics=function(e,t,a){this._currentGraphics=e;var o=this.gl,r=a.projection,n=a.offset,i;1===t.mode?(i=a.shaderManager.complexPrimitiveShader,a.shaderManager.setShader(i),o.uniform1f(i.flipY,a.flipY),o.uniformMatrix3fv(i.translationMatrix,!1,e.worldTransform.toArray(!0)),o.uniform2f(i.projectionVector,r.x,-r.y),o.uniform2f(i.offsetVector,-n.x,-n.y),o.uniform3fv(i.tintColor,Phaser.Color.hexToRGBArray(e.tint)),o.uniform3fv(i.color,t.color),o.uniform1f(i.alpha,e.worldAlpha*t.alpha),o.bindBuffer(o.ARRAY_BUFFER,t.buffer),o.vertexAttribPointer(i.aVertexPosition,2,o.FLOAT,!1,8,0),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.indexBuffer)):(i=a.shaderManager.primitiveShader,a.shaderManager.setShader(i),o.uniformMatrix3fv(i.translationMatrix,!1,e.worldTransform.toArray(!0)),o.uniform1f(i.flipY,a.flipY),o.uniform2f(i.projectionVector,r.x,-r.y),o.uniform2f(i.offsetVector,-n.x,-n.y),o.uniform3fv(i.tintColor,Phaser.Color.hexToRGBArray(e.tint)),o.uniform1f(i.alpha,e.worldAlpha),o.bindBuffer(o.ARRAY_BUFFER,t.buffer),o.vertexAttribPointer(i.aVertexPosition,2,o.FLOAT,!1,24,0),o.vertexAttribPointer(i.colorAttribute,4,o.FLOAT,!1,24,8),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.indexBuffer))},l.WebGLStencilManager.prototype.popStencil=function(e,t,a){var o=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)o.disable(o.STENCIL_TEST);else{var r=this.count;this.bindGraphics(e,t,a),o.colorMask(!1,!1,!1,!1),1===t.mode?(this.reverse=!this.reverse,this.reverse?(o.stencilFunc(o.EQUAL,255-(r+1),255),o.stencilOp(o.KEEP,o.KEEP,o.INCR)):(o.stencilFunc(o.EQUAL,r+1,255),o.stencilOp(o.KEEP,o.KEEP,o.DECR)),o.drawElements(o.TRIANGLE_FAN,4,o.UNSIGNED_SHORT,2*(t.indices.length-4)),o.stencilFunc(o.ALWAYS,0,255),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),o.drawElements(o.TRIANGLE_FAN,t.indices.length-4,o.UNSIGNED_SHORT,0),this.reverse?o.stencilFunc(o.EQUAL,r,255):o.stencilFunc(o.EQUAL,255-r,255)):(this.reverse?(o.stencilFunc(o.EQUAL,r+1,255),o.stencilOp(o.KEEP,o.KEEP,o.DECR)):(o.stencilFunc(o.EQUAL,255-(r+1),255),o.stencilOp(o.KEEP,o.KEEP,o.INCR)),o.drawElements(o.TRIANGLE_STRIP,t.indices.length,o.UNSIGNED_SHORT,0),this.reverse?o.stencilFunc(o.EQUAL,r,255):o.stencilFunc(o.EQUAL,255-r,255)),o.colorMask(!0,!0,!0,!0),o.stencilOp(o.KEEP,o.KEEP,o.KEEP)}},l.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},l.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var e=0;e<this.maxAttibs;e++)this.attribState[e]=!1;this.stack=[]},l.WebGLShaderManager.prototype.constructor=l.WebGLShaderManager,l.WebGLShaderManager.prototype.setContext=function(e){this.gl=e,this.primitiveShader=new l.PrimitiveShader(e),this.complexPrimitiveShader=new l.ComplexPrimitiveShader(e),this.defaultShader=new l.PixiShader(e),this.fastShader=new l.PixiFastShader(e),this.stripShader=new l.StripShader(e),this.creatureShader=l.CreatureShader?new l.CreatureShader(e):null,this.setShader(this.defaultShader)},l.WebGLShaderManager.prototype.setAttribs=function(e){var t;for(t=0;t<this.tempAttribState.length;t++)this.tempAttribState[t]=!1;for(t=0;t<e.length;t++){var a=e[t];this.tempAttribState[a]=!0}var o=this.gl;for(t=0;t<this.attribState.length;t++)this.attribState[t]!==this.tempAttribState[t]&&(this.attribState[t]=this.tempAttribState[t],this.tempAttribState[t]?o.enableVertexAttribArray(t):o.disableVertexAttribArray(t))},l.WebGLShaderManager.prototype.setShader=function(e){return this._currentId!==e._UID&&(this._currentId=e._UID,this.currentShader=e,this.gl.useProgram(e.program),this.setAttribs(e.attributes),!0)},l.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.creatureShader&&this.creatureShader.destroy(),this.gl=null},l.WebGLSpriteBatch=function(e){this.game=e,this.vertSize=5,this.size=2e3,this.vertexSize=24;var t=4*(this.vertexSize*this.size),a=6*this.size;this.vertices=new ArrayBuffer(t),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(a),this.lastIndexCount=0;for(var o=0,r=0;o<a;o+=6,r+=4)this.indices[o+0]=r+0,this.indices[o+1]=r+1,this.indices[o+2]=r+2,this.indices[o+3]=r+0,this.indices[o+4]=r+2,this.indices[o+5]=r+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=null},l.WebGLSpriteBatch.prototype.setContext=function(e){if(this.MAX_TEXTURES=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.gl=e,l._enableMultiTextureToggle){for(var t="\tif (vTextureIndex == 0.0) {gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",a=1;a<this.MAX_TEXTURES;++a)t+="\tif (vTextureIndex == "+a+".0) {gl_FragColor = texture2D(uSamplerArray["+a+"], vTextureCoord) * vColor;return;}\n";this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","void main(void) {",t,"\tgl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;","}"])}else this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]);this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),this.currentBlendMode=99999;var o=new l.PixiShader(e);o.fragmentSrc=this.defaultShader.fragmentSrc,o.uniforms={},o.init(),this.defaultShader.shaders[e.id]=o},l.WebGLSpriteBatch.prototype.begin=function(e){this.renderSession=e,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},l.WebGLSpriteBatch.prototype.end=function(){this.flush()},l.WebGLSpriteBatch.prototype.render=function(e,t){var o=e.texture,r=o.baseTexture,n=this.gl;l.WebGLRenderer.textureArray[r.textureIndex]!=r&&(this.flush(),n.activeTexture(n.TEXTURE0+r.textureIndex),n.bindTexture(n.TEXTURE_2D,r._glTextures[n.id]),l.WebGLRenderer.textureArray[r.textureIndex]=r);var s=e.worldTransform;t&&(s=t),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=o.baseTexture);var p=o._uvs;if(p){var u=e.anchor.x,h=e.anchor.y,g,m,y,f;if(o.trim){var x=o.trim;m=x.x-u*x.width,g=m+o.crop.width,f=x.y-h*x.height,y=f+o.crop.height}else g=o.frame.width*(1-u),m=o.frame.width*-u,y=o.frame.height*(1-h),f=o.frame.height*-h;var _=this.currentBatchSize*this.vertexSize,i=4*this.currentBatchSize,v=o.baseTexture.resolution,T=o.baseTexture.textureIndex,C=s.a/v,a=s.b/v,b=s.c/v,c=s.d/v,d=s.tx,P=s.ty,S=o.crop.width,w=o.crop.height;if(o.rotated){var A=s.a,E=s.b,R=s.c,L=s.d,B=m,k=g;d=s.c*w+d,P=s.d*w+P,C=6.123233995736766e-17*A+-R,a=6.123233995736766e-17*E+-L,b=A+6.123233995736766e-17*R,c=E+6.123233995736766e-17*L,o._updateUvsInverted(),g=y,m=f,y=k,f=B}var F=this.colors,D=this.positions,M=e.tint,O=(M>>16)+(65280&M)+((255&M)<<16)+(255*e.worldAlpha<<24);this.renderSession.roundPixels?(D[_++]=0|C*m+b*f+d,D[_++]=0|c*f+a*m+P,D[_++]=p.x0,D[_++]=p.y0,F[_++]=O,D[_++]=T,D[_++]=0|C*g+b*f+d,D[_++]=0|c*f+a*g+P,D[_++]=p.x1,D[_++]=p.y1,F[_++]=O,D[_++]=T,D[_++]=0|C*g+b*y+d,D[_++]=0|c*y+a*g+P,D[_++]=p.x2,D[_++]=p.y2,F[_++]=O,D[_++]=T,D[_++]=0|C*m+b*y+d,D[_++]=0|c*y+a*m+P,D[_++]=p.x3,D[_++]=p.y3,F[_++]=O,D[_++]=T):(D[_++]=C*m+b*f+d,D[_++]=c*f+a*m+P,D[_++]=p.x0,D[_++]=p.y0,F[_++]=O,D[_++]=T,D[_++]=C*g+b*f+d,D[_++]=c*f+a*g+P,D[_++]=p.x1,D[_++]=p.y1,F[_++]=O,D[_++]=T,D[_++]=C*g+b*y+d,D[_++]=c*y+a*g+P,D[_++]=p.x2,D[_++]=p.y2,F[_++]=O,D[_++]=T,D[_++]=C*m+b*y+d,D[_++]=c*y+a*m+P,D[_++]=p.x3,D[_++]=p.y3,F[_++]=O,D[_++]=T),this.sprites[this.currentBatchSize++]=e}},l.WebGLSpriteBatch.prototype.renderTilingSprite=function(e){var t=e.tilingTexture,o=t.baseTexture,r=this.gl,n=e.texture.baseTexture.textureIndex;l.WebGLRenderer.textureArray[n]!=o&&(this.flush(),r.activeTexture(r.TEXTURE0+n),r.bindTexture(r.TEXTURE_2D,o._glTextures[r.id]),l.WebGLRenderer.textureArray[n]=o),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=t.baseTexture),e._uvs||(e._uvs=new l.TextureUvs);var s=e._uvs,p=t.baseTexture.width,u=t.baseTexture.height;e.tilePosition.x%=p*e.tileScaleOffset.x,e.tilePosition.y%=u*e.tileScaleOffset.y;var h=e.tilePosition.x/(p*e.tileScaleOffset.x),g=e.tilePosition.y/(u*e.tileScaleOffset.y),m=e.width/p/(e.tileScale.x*e.tileScaleOffset.x),y=e.height/u/(e.tileScale.y*e.tileScaleOffset.y);s.x0=0-h,s.y0=0-g,s.x1=1*m-h,s.y1=0-g,s.x2=1*m-h,s.y2=1*y-g,s.x3=0-h,s.y3=1*y-g;var f=e.tint,x=(f>>16)+(65280&f)+((255&f)<<16)+(255*e.worldAlpha<<24),_=this.positions,v=this.colors,T=e.width,C=e.height,P=e.anchor.x,S=e.anchor.y,w=T*(1-P),A=T*-P,E=C*(1-S),R=C*-S,L=this.currentBatchSize*this.vertexSize,i=t.baseTexture.resolution,B=e.worldTransform,k=B.a/i,a=B.b/i,b=B.c/i,c=B.d/i,d=B.tx,F=B.ty;_[L++]=k*A+b*R+d,_[L++]=c*R+a*A+F,_[L++]=s.x0,_[L++]=s.y0,v[L++]=x,_[L++]=n,_[L++]=k*w+b*R+d,_[L++]=c*R+a*w+F,_[L++]=s.x1,_[L++]=s.y1,v[L++]=x,_[L++]=n,_[L++]=k*w+b*E+d,_[L++]=c*E+a*w+F,_[L++]=s.x2,_[L++]=s.y2,v[L++]=x,_[L++]=n,_[L++]=k*A+b*E+d,_[L++]=c*E+a*A+F,_[L++]=s.x3,_[L++]=s.y3,v[L++]=x,_[L++]=n,this.sprites[this.currentBatchSize++]=e},l.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var e=this.gl,t;if(this.dirty){this.dirty=!1,t=this.defaultShader.shaders[e.id],e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var a=this.vertexSize;e.vertexAttribPointer(t.aVertexPosition,2,e.FLOAT,!1,a,0),e.vertexAttribPointer(t.aTextureCoord,2,e.FLOAT,!1,a,8),e.vertexAttribPointer(t.colorAttribute,4,e.UNSIGNED_BYTE,!0,a,16),e.vertexAttribPointer(t.aTextureIndex,1,e.FLOAT,!1,a,20)}if(this.currentBatchSize>0.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer);var o=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);e.bufferSubData(e.ARRAY_BUFFER,0,o)}for(var r=0,n=0,s=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,c=!1,u=!1,h=0,i=this.currentBatchSize,g,m,y,f;h<i;h++){f=this.sprites[h],g=f.tilingTexture?f.tilingTexture.baseTexture:f.texture.baseTexture,m=f.blendMode,y=f.shader||this.defaultShader,c=d!==m,u=p!==y;var x=g.skipRender;if(x&&0<f.children.length&&(x=!1),(c||u)&&(this.renderBatch(s,r,n),n=h,r=0,s=g,c&&(d=m,this.renderSession.blendModeManager.setBlendMode(d)),u)){p=y,t=p.shaders[e.id],t||(t=new l.PixiShader(e),t.fragmentSrc=p.fragmentSrc,t.uniforms=p.uniforms,t.init(),p.shaders[e.id]=t),this.renderSession.shaderManager.setShader(t),t.dirty&&t.syncUniforms();var b=this.renderSession.projection;e.uniform2f(t.projectionVector,b.x,b.y);var _=this.renderSession.offset;e.uniform2f(t.offsetVector,_.x,_.y)}r++}this.renderBatch(s,r,n),this.currentBatchSize=0}},l.WebGLSpriteBatch.prototype.renderBatch=function(e,t,a){if(0!==t){var o=this.gl;if(!e._dirty[o.id])o.bindTexture(o.TEXTURE_2D,e._glTextures[o.id]);else if(!this.renderSession.renderer.updateTexture(e))return;o.drawElements(o.TRIANGLES,6*t,o.UNSIGNED_SHORT,2*(6*a)),this.renderSession.drawCount++}},l.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},l.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},l.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},l.WebGLFastSpriteBatch=function(e){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var t=4*this.size*this.vertSize,a=6*this.maxSize;this.vertices=new Float32Array(t),this.indices=new Uint16Array(a),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var o=0,r=0;o<a;o+=6,r+=4)this.indices[o+0]=r+0,this.indices[o+1]=r+1,this.indices[o+2]=r+2,this.indices[o+3]=r+0,this.indices[o+4]=r+2,this.indices[o+5]=r+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(e)},l.WebGLFastSpriteBatch.prototype.constructor=l.WebGLFastSpriteBatch,l.WebGLFastSpriteBatch.prototype.setContext=function(e){this.gl=e,this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW)},l.WebGLFastSpriteBatch.prototype.begin=function(e,t){this.renderSession=t,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=e.worldTransform.toArray(!0),this.start()},l.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},l.WebGLFastSpriteBatch.prototype.render=function(e){var t=e.children,a=t[0];if(a.texture._uvs){this.currentBaseTexture=a.texture.baseTexture,a.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(a.blendMode));for(var o=0,r=t.length;o<r;o++)this.renderSprite(t[o]);this.flush()}},l.WebGLFastSpriteBatch.prototype.renderSprite=function(e){var t=e.texture,a=t.baseTexture,o=this.gl,r=e.texture.baseTexture.textureIndex;if(!(l.WebGLRenderer.textureArray[r]!=a&&a._glTextures[o.id]&&!e.texture.baseTexture.skipRender&&(this.flush(),o.activeTexture(o.TEXTURE0+r),o.bindTexture(o.TEXTURE_2D,a._glTextures[o.id]),l.WebGLRenderer.textureArray[r]=a,!e.texture._uvs))&&e.visible){var n=this.vertices,i,s,d,p,c,u,h,g;if(i=e.texture._uvs,s=e.texture.frame.width,d=e.texture.frame.height,e.texture.trim){var m=e.texture.trim;c=m.x-e.anchor.x*m.width,p=c+e.texture.crop.width,h=m.y-e.anchor.y*m.height,u=h+e.texture.crop.height}else p=e.texture.frame.width*(1-e.anchor.x),c=e.texture.frame.width*-e.anchor.x,u=e.texture.frame.height*(1-e.anchor.y),h=e.texture.frame.height*-e.anchor.y;g=4*this.currentBatchSize*this.vertSize,n[g++]=c,n[g++]=h,n[g++]=e.position.x,n[g++]=e.position.y,n[g++]=e.scale.x,n[g++]=e.scale.y,n[g++]=e.rotation,n[g++]=i.x0,n[g++]=i.y1,n[g++]=e.alpha,n[g++]=r,n[g++]=p,n[g++]=h,n[g++]=e.position.x,n[g++]=e.position.y,n[g++]=e.scale.x,n[g++]=e.scale.y,n[g++]=e.rotation,n[g++]=i.x1,n[g++]=i.y1,n[g++]=e.alpha,n[g++]=r,n[g++]=p,n[g++]=u,n[g++]=e.position.x,n[g++]=e.position.y,n[g++]=e.scale.x,n[g++]=e.scale.y,n[g++]=e.rotation,n[g++]=i.x2,n[g++]=i.y2,n[g++]=e.alpha,n[g++]=r,n[g++]=c,n[g++]=u,n[g++]=e.position.x,n[g++]=e.position.y,n[g++]=e.scale.x,n[g++]=e.scale.y,n[g++]=e.rotation,n[g++]=i.x3,n[g++]=i.y3,n[g++]=e.alpha,n[g++]=r,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},l.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var e=this.gl;if(!this.currentBaseTexture._glTextures[e.id])return void this.renderSession.renderer.updateTexture(this.currentBaseTexture,e);if(this.currentBatchSize>0.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var t=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,t)}e.drawElements(e.TRIANGLES,6*this.currentBatchSize,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},l.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},l.WebGLFastSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var t=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,t.x,t.y),e.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var a=4*this.vertSize;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,a,0),e.vertexAttribPointer(this.shader.aPositionCoord,2,e.FLOAT,!1,a,8),e.vertexAttribPointer(this.shader.aScale,2,e.FLOAT,!1,a,16),e.vertexAttribPointer(this.shader.aRotation,1,e.FLOAT,!1,a,24),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,a,28),e.vertexAttribPointer(this.shader.colorAttribute,1,e.FLOAT,!1,a,36),e.vertexAttribPointer(this.shader.aTextureIndex,1,e.FLOAT,!1,a,40)},l.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},l.WebGLFilterManager.prototype.constructor=l.WebGLFilterManager,l.WebGLFilterManager.prototype.setContext=function(e){this.gl=e,this.texturePool=[],this.initShaderBuffers()},l.WebGLFilterManager.prototype.begin=function(e,t){this.renderSession=e,this.defaultShader=e.shaderManager.defaultShader;var a=this.renderSession.projection;this.width=2*a.x,this.height=2*-a.y,this.buffer=t},l.WebGLFilterManager.prototype.pushFilter=function(e){var t=this.gl,a=this.renderSession.projection,o=this.renderSession.offset;e._filterArea=e.target.filterArea||e.target.getBounds(),e._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new l.WebGLStencilManager,this.renderSession.stencilManager.setContext(t),t.disable(t.STENCIL_TEST),this.filterStack.push(e);var r=e.filterPasses[0];this.offsetX+=e._filterArea.x,this.offsetY+=e._filterArea.y;var n=this.texturePool.pop();n?n.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):n=new l.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindTexture(t.TEXTURE_2D,n.texture);var i=e._filterArea,s=r.padding;i.x-=s,i.y-=s,i.width+=2*s,i.height+=2*s,0>i.x&&(i.x=0),i.width>this.width&&(i.width=this.width),0>i.y&&(i.y=0),i.height>this.height&&(i.height=this.height),t.bindFramebuffer(t.FRAMEBUFFER,n.frameBuffer),t.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution),a.x=i.width/2,a.y=-i.height/2,o.x=-i.x,o.y=-i.y,t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),e._glFilterTexture=n},l.WebGLFilterManager.prototype.popFilter=function(){var e=this.gl,t=this.filterStack.pop(),a=t._filterArea,o=t._glFilterTexture,r=this.renderSession.projection,n=this.renderSession.offset;if(1<t.filterPasses.length){e.viewport(0,0,a.width*this.renderSession.resolution,a.height*this.renderSession.resolution),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=a.height,this.vertexArray[2]=a.width,this.vertexArray[3]=a.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=a.width,this.vertexArray[7]=0,e.bufferSubData(e.ARRAY_BUFFER,0,this.vertexArray),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=a.width/this.width,this.uvArray[5]=a.height/this.height,this.uvArray[6]=a.width/this.width,this.uvArray[7]=a.height/this.height,e.bufferSubData(e.ARRAY_BUFFER,0,this.uvArray);var s=o,d=this.texturePool.pop();d||(d=new l.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),d.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),e.bindFramebuffer(e.FRAMEBUFFER,d.frameBuffer),e.clear(e.COLOR_BUFFER_BIT),e.disable(e.BLEND);for(var p=0,i;p<t.filterPasses.length-1;p++){i=t.filterPasses[p],e.bindFramebuffer(e.FRAMEBUFFER,d.frameBuffer),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,s.texture),this.applyFilterPass(i,a,a.width,a.height);var c=s;s=d,d=c}e.enable(e.BLEND),o=s,this.texturePool.push(d)}var u=t.filterPasses[t.filterPasses.length-1];this.offsetX-=a.x,this.offsetY-=a.y;var h=this.width,g=this.height,m=0,f=0,b=this.buffer;if(0===this.filterStack.length)e.colorMask(!0,!0,!0,!0);else{var _=this.filterStack[this.filterStack.length-1];a=_._filterArea,h=a.width,g=a.height,m=a.x,f=a.y,b=_._glFilterTexture.frameBuffer}r.x=h/2,r.y=-g/2,n.x=m,n.y=f,a=t._filterArea;var v=a.x-m,x=a.y-f;e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=v,this.vertexArray[1]=x+a.height,this.vertexArray[2]=v+a.width,this.vertexArray[3]=x+a.height,this.vertexArray[4]=v,this.vertexArray[5]=x,this.vertexArray[6]=v+a.width,this.vertexArray[7]=x,e.bufferSubData(e.ARRAY_BUFFER,0,this.vertexArray),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=a.width/this.width,this.uvArray[5]=a.height/this.height,this.uvArray[6]=a.width/this.width,this.uvArray[7]=a.height/this.height,e.bufferSubData(e.ARRAY_BUFFER,0,this.uvArray),e.viewport(0,0,h*this.renderSession.resolution,g*this.renderSession.resolution),e.bindFramebuffer(e.FRAMEBUFFER,b),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o.texture),this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy(),this.renderSession.stencilManager=t._previous_stencil_mgr,t._previous_stencil_mgr=null,0<this.renderSession.stencilManager.count?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.applyFilterPass(u,a,h,g),this.texturePool.push(o),t._glFilterTexture=null},l.WebGLFilterManager.prototype.applyFilterPass=function(e,t,a,o){var r=this.gl,n=e.shaders[r.id];n||(n=new l.PixiShader(r),n.fragmentSrc=e.fragmentSrc,n.uniforms=e.uniforms,n.init(!0),e.shaders[r.id]=n),this.renderSession.shaderManager.setShader(n),r.uniform2f(n.projectionVector,a/2,-o/2),r.uniform2f(n.offsetVector,0,0),e.uniforms.dimensions&&(e.uniforms.dimensions.value[0]=this.width,e.uniforms.dimensions.value[1]=this.height,e.uniforms.dimensions.value[2]=this.vertexArray[0],e.uniforms.dimensions.value[3]=this.vertexArray[5]),n.syncUniforms(),r.bindBuffer(r.ARRAY_BUFFER,this.vertexBuffer),r.vertexAttribPointer(n.aVertexPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.uvBuffer),r.vertexAttribPointer(n.aTextureCoord,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.colorBuffer),r.vertexAttribPointer(n.colorAttribute,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this.indexBuffer),r.drawElements(r.TRIANGLES,6,r.UNSIGNED_SHORT,0),this.renderSession.drawCount++},l.WebGLFilterManager.prototype.initShaderBuffers=function(){var e=this.gl;this.vertexBuffer=e.createBuffer(),this.uvBuffer=e.createBuffer(),this.colorBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexArray,e.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvArray,e.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),e.bindBuffer(e.ARRAY_BUFFER,this.colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colorArray,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),e.STATIC_DRAW)},l.WebGLFilterManager.prototype.destroy=function(){var e=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var t=0;t<this.texturePool.length;t++)this.texturePool[t].destroy();this.texturePool=null,e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.uvBuffer),e.deleteBuffer(this.colorBuffer),e.deleteBuffer(this.indexBuffer)};var d={36054:"Incomplete attachment",36055:"Missing attachment",36057:"Incomplete dimensions",36061:"Framebuffer unsupported"};return l.FilterTexture=function(e,a,o,r,n){n="number"==typeof n?n:0,this.gl=e,this.frameBuffer=t(e,a,o,r||l.scaleModes.DEFAULT,n),this.texture=this.frameBuffer.targetTexture,this.width=a,this.height=o,this.renderBuffer=this.frameBuffer.renderBuffer},l.FilterTexture.prototype.constructor=l.FilterTexture,l.FilterTexture.prototype.clear=function(){var e=this.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},l.FilterTexture.prototype.resize=function(e,t){if(this.width!==e||this.height!==t){this.width=e,this.height=t;var a=this.gl;a.bindTexture(a.TEXTURE_2D,this.texture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,e,t,0,a.RGBA,a.UNSIGNED_BYTE,null),a.bindRenderbuffer(a.RENDERBUFFER,this.renderBuffer),a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,e,t)}},l.FilterTexture.prototype.destroy=function(){var e=this.gl;e.deleteFramebuffer(this.frameBuffer),e.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},l.CanvasBuffer=function(e,t){this.width=e,this.height=t,this.canvas=Phaser.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=e,this.canvas.height=t},l.CanvasBuffer.prototype.constructor=l.CanvasBuffer,l.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},l.CanvasBuffer.prototype.resize=function(e,t){this.width=this.canvas.width=e,this.height=this.canvas.height=t},l.CanvasBuffer.prototype.destroy=function(){Phaser.CanvasPool.remove(this)},l.CanvasMaskManager=function(){},l.CanvasMaskManager.prototype.constructor=l.CanvasMaskManager,l.CanvasMaskManager.prototype.pushMask=function(e,t){var a=t.context;a.save();var o=e.alpha,r=e.worldTransform,n=t.resolution;a.setTransform(r.a*n,r.b*n,r.c*n,r.d*n,r.tx*n,r.ty*n),l.CanvasGraphics.renderGraphicsMask(e,a),a.clip(),e.worldAlpha=o},l.CanvasMaskManager.prototype.popMask=function(e){e.context.restore()},l.CanvasTinter=function(){},l.CanvasTinter.getTintedTexture=function(e,t){var a=e.tintedTexture||Phaser.CanvasPool.create(this);return l.CanvasTinter.tintMethod(e.texture,t,a),a},l.CanvasTinter.tintWithMultiply=function(e,t,a){var o=a.getContext("2d"),r=e.crop,n=r.width,i=r.height;e.rotated&&(n=i,i=r.width),(a.width!==n||a.height!==i)&&(a.width=n,a.height=i),o.clearRect(0,0,n,i),o.fillStyle="#"+("00000"+(0|t).toString(16)).substr(-6),o.fillRect(0,0,n,i),o.globalCompositeOperation="multiply",o.drawImage(e.baseTexture.source,r.x,r.y,n,i,0,0,n,i),o.globalCompositeOperation="destination-atop",o.drawImage(e.baseTexture.source,r.x,r.y,n,i,0,0,n,i)},l.CanvasTinter.tintWithPerPixel=function(e,t,a){var o=a.getContext("2d"),n=e.crop,s=n.width,d=n.height;e.rotated&&(s=d,d=n.width),(a.width!==s||a.height!==d)&&(a.width=s,a.height=d),o.globalCompositeOperation="copy",o.drawImage(e.baseTexture.source,n.x,n.y,s,d,0,0,s,d);for(var p=Phaser.Color.hexToRGBArray(t),c=p[0],r=p[1],u=p[2],h=o.getImageData(0,0,s,d),g=h.data,m=0;m<g.length;m+=4)if(g[m+0]*=c,g[m+1]*=r,g[m+2]*=u,!l.CanvasTinter.canHandleAlpha){var i=g[m+3];g[m+0]/=255/i,g[m+1]/=255/i,g[m+2]/=255/i}o.putImageData(h,0,0)},l.CanvasRenderer=function(e){this.game=e,l.defaultRenderer||(l.defaultRenderer=this),this.type=Phaser.CANVAS,this.resolution=e.resolution,this.clearBeforeRender=e.clearBeforeRender,this.transparent=e.transparent,this.autoResize=!1,this.width=e.width*this.resolution,this.height=e.height*this.resolution,this.view=e.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.count=0,this.maskManager=new l.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)},l.CanvasRenderer.prototype.constructor=l.CanvasRenderer,l.CanvasRenderer.prototype.render=function(e){this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=this.game.camera._shake.x,this.renderSession.shakeY=this.game.camera._shake.y,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):e._bgColor&&(this.context.fillStyle=e._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(e)},l.CanvasRenderer.prototype.setTexturePriority=function(){},l.CanvasRenderer.prototype.destroy=function(e){void 0===e&&(e=!0),e&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},l.CanvasRenderer.prototype.resize=function(e,t){this.width=e*this.resolution,this.height=t*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===l.scaleModes.LINEAR)},l.CanvasRenderer.prototype.renderDisplayObject=function(e,t,a){this.renderSession.context=t||this.context,this.renderSession.resolution=this.resolution,e._renderCanvas(this.renderSession,a)},l.CanvasRenderer.prototype.mapBlendModes=function(){if(!l.blendModesCanvas){var e=[],t=l.blendModes,a=this.game.device.canUseMultiply;e[t.NORMAL]="source-over",e[t.ADD]="lighter",e[t.MULTIPLY]=a?"multiply":"source-over",e[t.SCREEN]=a?"screen":"source-over",e[t.OVERLAY]=a?"overlay":"source-over",e[t.DARKEN]=a?"darken":"source-over",e[t.LIGHTEN]=a?"lighten":"source-over",e[t.COLOR_DODGE]=a?"color-dodge":"source-over",e[t.COLOR_BURN]=a?"color-burn":"source-over",e[t.HARD_LIGHT]=a?"hard-light":"source-over",e[t.SOFT_LIGHT]=a?"soft-light":"source-over",e[t.DIFFERENCE]=a?"difference":"source-over",e[t.EXCLUSION]=a?"exclusion":"source-over",e[t.HUE]=a?"hue":"source-over",e[t.SATURATION]=a?"saturation":"source-over",e[t.COLOR]=a?"color":"source-over",e[t.LUMINOSITY]=a?"luminosity":"source-over",l.blendModesCanvas=e}},l.BaseTexture=function(e,t,a){this.resolution=a||1,this.width=100,this.height=100,this.scaleMode=t||l.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=e,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.textureIndex=0,this._dirty=[!0,!0,!0,!0],e&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},l.BaseTexture.prototype.constructor=l.BaseTexture,l.BaseTexture.prototype.forceLoaded=function(e,t){this.hasLoaded=!0,this.width=e,this.height=t,this.dirty()},l.BaseTexture.prototype.destroy=function(){this.source&&Phaser.CanvasPool.removeByCanvas(this.source),this.source=null,this.unloadFromGPU()},l.BaseTexture.prototype.updateSourceImage=function(){console.warn("PIXI.BaseTexture.updateSourceImage is deprecated. Use Phaser.Sprite.loadTexture instead.")},l.BaseTexture.prototype.dirty=function(){for(var e=0;e<this._glTextures.length;e++)this._dirty[e]=!0},l.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var e=this._glTextures.length-1;0<=e;e--){var t=this._glTextures[e],a=l.glContexts[e];a&&t&&a.deleteTexture(t)}this._glTextures.length=0,this.dirty()},l.BaseTexture.fromCanvas=function(e,t,a){return 0===e.width&&(e.width=1),0===e.height&&(e.height=1),a=a||1,new l.BaseTexture(e,t,a)},l.TextureSilentFail=!1,l.Texture=function(e,t,a,o){this.noFrame=!1,t||(this.noFrame=!0,t=new l.Rectangle(0,0,1,1)),e instanceof l.Texture&&(e=e.baseTexture),this.baseTexture=e,this.frame=t,this.trim=o,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=a||new l.Rectangle(0,0,1,1),this.rotated=!1,e.hasLoaded&&(this.noFrame&&(t=new l.Rectangle(0,0,e.width,e.height)),this.setFrame(t))},l.Texture.prototype.constructor=l.Texture,l.Texture.prototype.onBaseTextureLoaded=function(){var e=this.baseTexture;this.noFrame&&(this.frame=new l.Rectangle(0,0,e.width,e.height)),this.setFrame(this.frame)},l.Texture.prototype.destroy=function(e){e&&this.baseTexture.destroy(),this.valid=!1},l.Texture.prototype.setFrame=function(e){if(this.noFrame=!1,this.frame=e,this.width=e.width,this.height=e.height,this.crop.x=e.x,this.crop.y=e.y,this.crop.width=e.width,this.crop.height=e.height,!this.trim&&(e.x+e.width>this.baseTexture.width||e.y+e.height>this.baseTexture.height)){if(!l.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);return void(this.valid=!1)}this.valid=e&&e.width&&e.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},l.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new l.TextureUvs);var e=this.crop,t=this.baseTexture.width,a=this.baseTexture.height;this._uvs.x0=e.x/t,this._uvs.y0=e.y/a,this._uvs.x1=(e.x+e.width)/t,this._uvs.y1=e.y/a,this._uvs.x2=(e.x+e.width)/t,this._uvs.y2=(e.y+e.height)/a,this._uvs.x3=e.x/t,this._uvs.y3=(e.y+e.height)/a},l.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new l.TextureUvs);var e=this.crop,t=this.baseTexture.width,a=this.baseTexture.height;this._uvs.x0=e.x/t,this._uvs.y0=e.y/a,this._uvs.x1=(e.x+e.height)/t,this._uvs.y1=e.y/a,this._uvs.x2=(e.x+e.height)/t,this._uvs.y2=(e.y+e.width)/a,this._uvs.x3=e.x/t,this._uvs.y3=(e.y+e.width)/a},l.Texture.fromCanvas=function(e,t){var a=l.BaseTexture.fromCanvas(e,t);return new l.Texture(a)},l.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},"undefined"==typeof exports?"undefined"!=typeof define&&define.amd?define("PIXI",function(){return s.PIXI=l}()):s.PIXI=l:("undefined"!=typeof module&&module.exports&&(exports=module.exports=l),exports.PIXI=l),l}.call(this),function(){function e(e,t){this._scaleFactor=e,this._deltaMode=t,this.originalEvent=null}var t=Math.asin,a=String.fromCharCode,o=Number.POSITIVE_INFINITY,r=Math.atan2,n=Math.round,i=Math.trunc,d=Math.PI,l=Math.ceil,c=Math.floor,u=Math.pow,s=Math.max,p=Math.min,h=Math.sin,m=Math.cos,f=Math.abs,g=Number.MAX_VALUE,_=Math.sqrt,y=this,T=T||{VERSION:"2.9.1",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0};if(i||(i=function(e){return 0>e?l(e):c(e)}),Function.prototype.bind||(Function.prototype.bind=function(){var e=Array.prototype.slice;return function(t){function a(){var n=r.concat(e.call(arguments));o.apply(this instanceof a?this:t,n)}var o=this,r=e.call(arguments,1);if("function"!=typeof o)throw new TypeError;return a.prototype=function e(t){if(t&&(e.prototype=t),!(this instanceof e))return new e}(o.prototype),a}}()),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Array.prototype.forEach||(Array.prototype.forEach=function(e){"use strict";if(void 0===this||null===this)throw new TypeError;var a=Object(this),t=a.length>>>0;if("function"!=typeof e)throw new TypeError;for(var o=2<=arguments.length?arguments[1]:void 0,r=0;r<t;r++)r in a&&e.call(o,a[r],r,a)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var x=function(e){window[e]=function(e){if("number"==typeof e){Array.call(this,e),this.length=e;for(var t=0;t<this.length;t++)this[t]=0}else{Array.call(this,e.length),this.length=e.length;for(var t=0;t<this.length;t++)this[t]=e[t]}},window[e].prototype=[],window[e].constructor=window[e]};x("Float32Array"),x("Uint32Array"),x("Uint16Array"),x("Int16Array"),x("ArrayBuffer")}for(var b in window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),Object.assign||(Object.assign=function(e){"use strict";if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),a=Object.prototype.hasOwnProperty,o=1,r;o<arguments.length;o++)if(r=arguments[o],null!=r)for(var n in r)a.call(r,n)&&(t[n]=r[n]);return t}),T.Utils={reverseString:function(e){return e.split("").reverse().join("")},getProperty:function(e,t){for(var a=t.split("."),o=a.length,r=0,n=e,i;r<o;)if(i=a[r],null!=n)n=n[i],r++;else return;return n},setProperties:function(e,t){for(var a in t)this.setProperty(e,a,t[a]);return e},setProperty:function(e,t,a){var o=t.split(".");switch(o.length){case 1:e[t]=a;break;case 2:e[o[0]][o[1]]=a;break;case 3:e[o[0]][o[1]][o[2]]=a;break;case 4:e[o[0]][o[1]][o[2]][o[3]]=a;break;default:this._setProperty(e,t,a);}},_setProperty:function(e,t,a){var o=t.split("."),r=o.length,n=0,i=e,s=o[0];if(1===r)e[t]=a;else{for(;n<r-1;)i=i[s],n++,s=o[n];i[s]=a}return e},chanceRoll:function(e){return void 0===e&&(e=50),0<e&&100*Math.random()<=e},randomChoice:function(e,t){return 0.5>Math.random()?e:t},parseDimension:function(e,t){var a=0,o=0;return"string"==typeof e?"%"===e.substr(-1)?(a=parseInt(e,10)/100,o=0===t?window.innerWidth*a:window.innerHeight*a):o=parseInt(e,10):o=e,o},pad:function(e,t,a,o){if(void 0===t)var t=0;if(void 0===a)var a=" ";if(void 0===o)var o=3;e=e.toString();var r=0;if(t+1>=e.length)switch(o){case 1:e=Array(t+1-e.length).join(a)+e;break;case 3:var n=l((r=t-e.length)/2),i=r-n;e=Array(i+1).join(a)+e+Array(n+1).join(a);break;default:e+=Array(t+1-e.length).join(a);}return e},isPlainObject:function(e){if("object"!=typeof e||e.nodeType||e===e.window)return!1;try{if(e.constructor&&!{}.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var e=arguments[0]||{},t=1,a=arguments.length,o=!1,r,n,i,s,d,l;for("boolean"==typeof e&&(o=e,e=arguments[1]||{},t=2),a===t&&(e=this,--t);t<a;t++)if(null!=(r=arguments[t]))for(n in r)(i=e[n],s=r[n],e!==s)&&(o&&s&&(T.Utils.isPlainObject(s)||(d=Array.isArray(s)))?(d?(d=!1,l=i&&Array.isArray(i)?i:[]):l=i&&T.Utils.isPlainObject(i)?i:{},e[n]=T.Utils.extend(o,l,s)):void 0!==s&&(e[n]=s));return e},mixinPrototype:function(e,t,a){void 0===a&&(a=!1);for(var o=Object.keys(t),r=0;r<o.length;r++){var n=o[r],i=t[n];if(!a&&n in e)continue;else i&&("function"==typeof i.get||"function"==typeof i.set)?"function"==typeof i.clone?e[n]=i.clone():Object.defineProperty(e,n,i):e[n]=i}},mixin:function(e,t){if(!e||"object"!=typeof e)return t;for(var a in e){var r=e[a];if(!(r.childNodes||r.cloneNode)){var o=typeof e[a];t[a]=e[a]&&"object"==o?typeof t[a]==o?T.Utils.mixin(e[a],t[a]):T.Utils.mixin(e[a],new r.constructor):e[a]}}return t}},T.Circle=function(e,t,a){e=e||0,t=t||0,a=a||0,this.x=e,this.y=t,this._diameter=a,this._radius=0,0<a&&(this._radius=0.5*a),this.type=T.CIRCLE},T.Circle.prototype={circumference:function(){return 2*(d*this._radius)},random:function(e){void 0===e&&(e=new T.Point);var a=2*d*Math.random(),t=Math.random()+Math.random(),o=1<t?2-t:t,r=o*m(a),n=o*h(a);return e.x=this.x+r*this.radius,e.y=this.y+n*this.radius,e},getBounds:function(){return new T.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(e,t,a){return this.x=e,this.y=t,this._diameter=a,this._radius=0.5*a,this},copyFrom:function(e){return this.setTo(e.x,e.y,e.diameter)},copyTo:function(e){return e.x=this.x,e.y=this.y,e.diameter=this._diameter,e},distance:function(e,t){var a=T.Math.distance(this.x,this.y,e.x,e.y);return t?n(a):a},clone:function(e){return void 0===e||null===e?e=new T.Circle(this.x,this.y,this.diameter):e.setTo(this.x,this.y,this.diameter),e},contains:function(e,t){return T.Circle.contains(this,e,t)},circumferencePoint:function(e,t,a){return T.Circle.circumferencePoint(this,e,t,a)},sample:function(e,t,a,o,r){e||(e=60),null==t&&(t=0),null==a&&(a=T.Math.PI2),r||(r=[]);for(var n=0;n<e;)this.circumferencePoint(T.Math.linear(t,a,n/e),o,r[n]||(r[n]=new T.Point)),n+=1;return r},offset:function(e,t){return this.x+=e,this.y+=t,this},offsetPoint:function(e){return this.offset(e.x,e.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},T.Circle.prototype.constructor=T.Circle,Object.defineProperty(T.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(e){0<e&&(this._diameter=e,this._radius=0.5*e)}}),Object.defineProperty(T.Circle.prototype,"radius",{get:function(){return this._radius},set:function(e){0<e&&(this._radius=e,this._diameter=2*e)}}),Object.defineProperty(T.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(e){e>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-e}}),Object.defineProperty(T.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(e){e<this.x?(this._radius=0,this._diameter=0):this.radius=e-this.x}}),Object.defineProperty(T.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(e){e>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-e}}),Object.defineProperty(T.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(e){e<this.y?(this._radius=0,this._diameter=0):this.radius=e-this.y}}),Object.defineProperty(T.Circle.prototype,"area",{get:function(){return 0<this._radius?d*this._radius*this._radius:0}}),Object.defineProperty(T.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(e){!0===e&&this.setTo(0,0,0)}}),T.Circle.contains=function(e,t,a){if(0<e.radius&&t>=e.left&&t<=e.right&&a>=e.top&&a<=e.bottom){var o=(e.x-t)*(e.x-t),r=(e.y-a)*(e.y-a);return o+r<=e.radius*e.radius}return!1},T.Circle.equals=function(e,t){return e.x===t.x&&e.y===t.y&&e.diameter===t.diameter},T.Circle.intersects=function(e,t){return T.Math.distance(e.x,e.y,t.x,t.y)<=e.radius+t.radius},T.Circle.circumferencePoint=function(e,t,a,o){return void 0===a&&(a=!1),void 0===o&&(o=new T.Point),!0===a&&(t=T.Math.degToRad(t)),o.x=e.x+e.radius*m(t),o.y=e.y+e.radius*h(t),o},T.Circle.intersectsRectangle=function(e,t){var a=f(e.x-t.x-t.halfWidth),o=t.halfWidth+e.radius;if(a>o)return!1;var r=f(e.y-t.y-t.halfHeight),n=t.halfHeight+e.radius;if(r>n)return!1;if(a<=t.halfWidth||r<=t.halfHeight)return!0;var i=a-t.halfWidth,s=r-t.halfHeight,d=e.radius*e.radius;return i*i+s*s<=d},T.Circle.intersectsLine=function(e,t,o){var r=e.x,i=e.y,s=(t.end.y-t.start.y)/(t.end.x-t.start.x),d=t.end.y-s*t.end.x,n=e.radius,a=e.radius,l=d+s*r,p=(r*(a*a)-s*(n*n)*(d-i)+n*a*_(n*n*(s*s)+a*a-l*l-i*i+2*l*i))/(n*n*(s*s)+a*a),c=(r*(a*a)-s*(n*n)*(d-i)-n*a*_(n*n*(s*s)+a*a-l*l-i*i+2*l*i))/(n*n*(s*s)+a*a),u=new T.Point(p,s*p+d),h=new T.Point(c,s*c+d),g=t.pointOnSegment(u.x,u.y,0.01),m=t.pointOnSegment(h.x,h.y,0.01);return g&&m?!o||[u,h]:g?!o||[u]:m?!o||[h]:!!o&&[]},PIXI.Circle=T.Circle,T.Ellipse=function(e,t,a,o){e=e||0,t=t||0,a=a||0,o=o||0,this.x=e,this.y=t,this.width=a,this.height=o,this.type=T.ELLIPSE},T.Ellipse.prototype={setTo:function(e,t,a,o){return this.x=e,this.y=t,this.width=a,this.height=o,this},getBounds:function(){return new T.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(e){return this.setTo(e.x,e.y,e.width,e.height)},copyTo:function(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e},clone:function(e){return void 0===e||null===e?e=new T.Ellipse(this.x,this.y,this.width,this.height):e.setTo(this.x,this.y,this.width,this.height),e},contains:function(e,t){return T.Ellipse.contains(this,e,t)},random:function(e){void 0===e&&(e=new T.Point);var t=2*(Math.random()*d),a=Math.random();return e.x=_(a)*m(t),e.y=_(a)*h(t),e.x=this.x+e.x*this.width/2,e.y=this.y+e.y*this.height/2,e},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},T.Ellipse.prototype.constructor=T.Ellipse,Object.defineProperty(T.Ellipse.prototype,"left",{get:function(){return this.x},set:function(e){this.x=e}}),Object.defineProperty(T.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(e){this.width=e<this.x?0:e-this.x}}),Object.defineProperty(T.Ellipse.prototype,"top",{get:function(){return this.y},set:function(e){this.y=e}}),Object.defineProperty(T.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(e){this.height=e<this.y?0:e-this.y}}),Object.defineProperty(T.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(e){!0===e&&this.setTo(0,0,0,0)}}),T.Ellipse.contains=function(e,t,a){if(0>=e.width||0>=e.height)return!1;var o=(t-e.x)/e.width-0.5,r=(a-e.y)/e.height-0.5;return o*=o,r*=r,0.25>o+r},T.Ellipse.intersectsLine=function(t,e,o){var r=t.x,i=t.y,s=(e.end.y-e.start.y)/(e.end.x-e.start.x),d=e.end.y-s*e.end.x,n=t.width/2,a=t.height/2,l=d+s*r,p=(r*(a*a)-s*(n*n)*(d-i)+n*a*_(n*n*(s*s)+a*a-l*l-i*i+2*l*i))/(n*n*(s*s)+a*a),c=(r*(a*a)-s*(n*n)*(d-i)-n*a*_(n*n*(s*s)+a*a-l*l-i*i+2*l*i))/(n*n*(s*s)+a*a),u=new T.Point(p,s*p+d),h=new T.Point(c,s*c+d),g=e.pointOnSegment(u.x,u.y,0.01),m=e.pointOnSegment(h.x,h.y,0.01);return g&&m?!o||[u,h]:g?!o||[u]:m?!o||[h]:!!o&&[]},PIXI.Ellipse=T.Ellipse,T.Line=function(e,t,a,o){e=e||0,t=t||0,a=a||0,o=o||0,this.start=new T.Point(e,t),this.end=new T.Point(a,o),this.type=T.LINE},T.Line.prototype={setTo:function(e,t,a,o){return this.start.setTo(e,t),this.end.setTo(a,o),this},fromSprite:function(e,t,a){return void 0===a&&(a=!1),a?this.setTo(e.centerX,e.centerY,t.centerX,t.centerY):this.setTo(e.x,e.y,t.x,t.y)},fromAngle:function(e,t,a,o){return this.start.setTo(e,t),this.end.setTo(e+m(a)*o,t+h(a)*o),this},rotate:function(e,t){var a=(this.start.x+this.end.x)/2,o=(this.start.y+this.end.y)/2;return this.start.rotate(a,o,e,t),this.end.rotate(a,o,e,t),this},rotateAround:function(e,t,a,o){return this.start.rotate(e,t,a,o),this.end.rotate(e,t,a,o),this},intersects:function(e,t,a){return T.Line.intersectsPoints(this.start,this.end,e.start,e.end,t,a)},reflect:function(e){return T.Line.reflect(this,e)},midPoint:function(e){return void 0===e&&(e=new T.Point),e.x=(this.start.x+this.end.x)/2,e.y=(this.start.y+this.end.y)/2,e},centerOn:function(e,t){var a=(this.start.x+this.end.x)/2,o=(this.start.y+this.end.y)/2,r=e-a,n=t-o;this.start.add(r,n),this.end.add(r,n)},pointOnLine:function(e,t,a){return T.Math.fuzzyEqual((e-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(t-this.start.y),a||0)},pointOnSegment:function(e,t,a){var o=p(this.start.x,this.end.x),r=s(this.start.x,this.end.x),n=p(this.start.y,this.end.y),i=s(this.start.y,this.end.y);return this.pointOnLine(e,t,a)&&e>=o&&e<=r&&t>=n&&t<=i},random:function(e){void 0===e&&(e=new T.Point);var a=Math.random();return e.x=this.start.x+a*(this.end.x-this.start.x),e.y=this.start.y+a*(this.end.y-this.start.y),e},coordinatesOnLine:function(e,t){void 0===e&&(e=1),void 0===t&&(t=[]);var a=n(this.start.x),o=n(this.start.y),r=n(this.end.x),s=n(this.end.y),d=f(r-a),l=f(s-o),p=a<r?1:-1,c=o<s?1:-1,u=d-l;t.push([a,o]);for(var h=1,i;a!==r||o!==s;)i=u<<1,i>-l&&(u-=l,a+=p),i<d&&(u+=d,o+=c),0==h%e&&t.push([a,o]),h++;return t},clone:function(e){return void 0===e||null===e?e=new T.Line(this.start.x,this.start.y,this.end.x,this.end.y):e.setTo(this.start.x,this.start.y,this.end.x,this.end.y),e}},Object.defineProperty(T.Line.prototype,"length",{get:function(){return _((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(T.Line.prototype,"angle",{get:function(){return r(this.end.y-this.start.y,this.end.x-this.start.x)}}),Object.defineProperty(T.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(T.Line.prototype,"perpSlope",{get:function(){return-((this.end.x-this.start.x)/(this.end.y-this.start.y))}}),Object.defineProperty(T.Line.prototype,"x",{get:function(){return p(this.start.x,this.end.x)}}),Object.defineProperty(T.Line.prototype,"y",{get:function(){return p(this.start.y,this.end.y)}}),Object.defineProperty(T.Line.prototype,"left",{get:function(){return p(this.start.x,this.end.x)}}),Object.defineProperty(T.Line.prototype,"right",{get:function(){return s(this.start.x,this.end.x)}}),Object.defineProperty(T.Line.prototype,"top",{get:function(){return p(this.start.y,this.end.y)}}),Object.defineProperty(T.Line.prototype,"bottom",{get:function(){return s(this.start.y,this.end.y)}}),Object.defineProperty(T.Line.prototype,"width",{get:function(){return f(this.start.x-this.end.x)}}),Object.defineProperty(T.Line.prototype,"height",{get:function(){return f(this.start.y-this.end.y)}}),Object.defineProperty(T.Line.prototype,"normalX",{get:function(){return m(this.angle-1.5707963267948966)}}),Object.defineProperty(T.Line.prototype,"normalY",{get:function(){return h(this.angle-1.5707963267948966)}}),Object.defineProperty(T.Line.prototype,"normalAngle",{get:function(){return T.Math.wrap(this.angle-1.5707963267948966,-d,Math.PI)}}),T.Line.intersectsPoints=function(t,a,o,e,r,n){void 0===r&&(r=!0),void 0===n&&(n=new T.Point);var i=a.y-t.y,s=e.y-o.y,d=t.x-a.x,l=o.x-e.x,p=a.x*t.y-t.x*a.y,c=e.x*o.y-o.x*e.y,u=i*l-s*d;if(0==u)return null;if(n.x=(d*c-l*p)/u,n.y=(s*p-i*c)/u,r){var h=(e.y-o.y)*(a.x-t.x)-(e.x-o.x)*(a.y-t.y),g=((e.x-o.x)*(t.y-o.y)-(e.y-o.y)*(t.x-o.x))/h,m=((a.x-t.x)*(t.y-o.y)-(a.y-t.y)*(t.x-o.x))/h;return 0<=g&&1>=g&&0<=m&&1>=m?n:null}return n},T.Line.intersects=function(e,t,a,o){return T.Line.intersectsPoints(e.start,e.end,t.start,t.end,a,o)},T.Line.intersectsRectangle=function(e,a){if(0===e.length||a.empty)return!1;var o=e.start.x,r=e.start.y,n=e.end.x,i=e.end.y,s=a.x,d=a.y,l=a.right,p=a.bottom,c=0;if(o>=s&&o<=l&&r>=d&&r<=p||n>=s&&n<=l&&i>=d&&i<=p)return!0;if(o<s&&n>=s){if(c=r+(i-r)*(s-o)/(n-o),c>d&&c<=p)return!0;}else if(o>l&&n<=l&&(c=r+(i-r)*(l-o)/(n-o),c>=d&&c<=p))return!0;if(r<d&&i>=d){if(c=o+(n-o)*(d-r)/(i-r),c>=s&&c<=l)return!0;}else if(r>p&&i<=p&&(c=o+(n-o)*(p-r)/(i-r),c>=s&&c<=l))return!0;return!1},T.Line.intersectionWithRectangle=function(e,t,a){var o=T.Line.intersectionWithRectangle;a||(a=new T.Point),o.edges||(o.edges=[new T.Line,new T.Line,new T.Line,new T.Line]),o.edgeIntersection||(o.edgeIntersection=new T.Point);var r=o.edges,n=o.edgeIntersection.set(0),s=t.x,d=t.y,l=t.right,p=t.bottom,c=Infinity;r[0].setTo(s,d,l,d),r[1].setTo(s,p,l,p),r[2].setTo(s,d,s,p),r[3].setTo(l,d,l,p);for(var u=0,i;i=r[u];u++)if(e.intersects(i,!0,n)){var h=e.start.distance(n);h<c&&(c=h,a.copyFrom(n))}return null==h?null:a},T.Line.reflect=function(e,t){return 2*t.normalAngle-3.141592653589793-e.angle},T.Matrix=function(e,t,a,o,r,n){(void 0===e||null===e)&&(e=1),(void 0===t||null===t)&&(t=0),(void 0===a||null===a)&&(a=0),(void 0===o||null===o)&&(o=1),(void 0===r||null===r)&&(r=0),(void 0===n||null===n)&&(n=0),this.a=e,this.b=t,this.c=a,this.d=o,this.tx=r,this.ty=n,this.type=T.MATRIX},T.Matrix.prototype={fromArray:function(e){return this.setTo(e[0],e[1],e[3],e[4],e[2],e[5])},setTo:function(e,t,a,o,r,n){return this.a=e,this.b=t,this.c=a,this.d=o,this.tx=r,this.ty=n,this},clone:function(e){return void 0===e||null===e?e=new T.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty),e},copyTo:function(e){return e.copyFrom(this),e},copyFrom:function(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this},toArray:function(e,t){return void 0===t&&(t=new Float32Array(9)),e?(t[0]=this.a,t[1]=this.b,t[2]=0,t[3]=this.c,t[4]=this.d,t[5]=0,t[6]=this.tx,t[7]=this.ty,t[8]=1):(t[0]=this.a,t[1]=this.c,t[2]=this.tx,t[3]=this.b,t[4]=this.d,t[5]=this.ty,t[6]=0,t[7]=0,t[8]=1),t},apply:function(e,t){return void 0===t&&(t=new T.Point),t.x=this.a*e.x+this.c*e.y+this.tx,t.y=this.b*e.x+this.d*e.y+this.ty,t},applyInverse:function(e,t){void 0===t&&(t=new T.Point);var a=1/(this.a*this.d+this.c*-this.b),o=e.x,r=e.y;return t.x=this.d*a*o+-this.c*a*r+(this.ty*this.c-this.tx*this.d)*a,t.y=this.a*a*r+-this.b*a*o+(-this.ty*this.a+this.tx*this.b)*a,t},translate:function(e,t){return this.tx+=e,this.ty+=t,this},scale:function(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this},rotate:function(e){var t=m(e),a=h(e),o=this.a,r=this.c,n=this.tx;return this.a=o*t-this.b*a,this.b=o*a+this.b*t,this.c=r*t-this.d*a,this.d=r*a+this.d*t,this.tx=n*t-this.ty*a,this.ty=n*a+this.ty*t,this},append:function(e){var t=this.a,a=this.b,o=this.c,r=this.d;return this.a=e.a*t+e.b*o,this.b=e.a*a+e.b*r,this.c=e.c*t+e.d*o,this.d=e.c*a+e.d*r,this.tx=e.tx*t+e.ty*o+this.tx,this.ty=e.tx*a+e.ty*r+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},T.identityMatrix=new T.Matrix,T.Point=function(e,t){e=e||0,t=t||0,this.x=e,this.y=t,this.type=T.POINT},T.Point.prototype={copyFrom:function(e){return this.setTo(e.x,e.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(e,t){return T.Point.set(this,e,t)},set:function(e,t){return T.Point.set(this,e,t)},setToPolar:function(e,t,a){return null==t&&(t=1),a&&(e=T.Math.degToRad(e)),this.setTo(m(e)*t,h(e)*t)},add:function(e,t){return this.x+=e,this.y+=t,this},subtract:function(e,t){return this.x-=e,this.y-=t,this},multiply:function(e,t){return this.x*=e,this.y*=t,this},divide:function(e,t){return this.x/=e,this.y/=t,this},clampX:function(e,t){return this.x=T.Math.clamp(this.x,e,t),this},clampY:function(e,t){return this.y=T.Math.clamp(this.y,e,t),this},clamp:function(e,t){return this.x=T.Math.clamp(this.x,e,t),this.y=T.Math.clamp(this.y,e,t),this},clip:function(e){var t=e.left,a=e.top,o=e.right,r=e.bottom;return this.x<t?this.x=t:this.x>o&&(this.x=o),this.y<a?this.y=a:this.y>r&&(this.y=r),this},clone:function(e){return void 0===e||null===e?e=new T.Point(this.x,this.y):e.setTo(this.x,this.y),e},copyTo:function(e){return e.x=this.x,e.y=this.y,e},distance:function(e,t){return T.Point.distance(this,e,t)},equals:function(e){return e.x===this.x&&e.y===this.y},equalsXY:function(e,t){return this.x===e&&this.y===t},fuzzyEquals:function(e,t){return T.Point.fuzzyEquals(this,e,t)},fuzzyEqualsXY:function(e,t,a){return T.Point.fuzzyEqualsXY(this,e,t,a)},angle:function(e,t){return void 0===t&&(t=!1),t?T.Math.radToDeg(r(e.y-this.y,e.x-this.x)):r(e.y-this.y,e.x-this.x)},rotate:function(e,t,a,o,r){return T.Point.rotate(this,e,t,a,o,r)},getMagnitude:function(){return _(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(e){return this.normalize().multiply(e,e)},normalize:function(){if(!this.isZero()){var e=this.getMagnitude();this.x/=e,this.y/=e}return this},limit:function(e){return this.getMagnitudeSq()>e*e&&this.setMagnitude(e),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(c(this.x),c(this.y))},ceil:function(){return this.setTo(l(this.x),l(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},T.Point.prototype.constructor=T.Point,T.Point.add=function(e,t,a){return void 0===a&&(a=new T.Point),a.x=e.x+t.x,a.y=e.y+t.y,a},T.Point.subtract=function(e,t,a){return void 0===a&&(a=new T.Point),a.x=e.x-t.x,a.y=e.y-t.y,a},T.Point.multiply=function(e,t,a){return void 0===a&&(a=new T.Point),a.x=e.x*t.x,a.y=e.y*t.y,a},T.Point.divide=function(e,t,a){return void 0===a&&(a=new T.Point),a.x=e.x/t.x,a.y=e.y/t.y,a},T.Point.equals=function(e,t){return e.x===t.x&&e.y===t.y},T.Point.equalsXY=function(e,t,a){return e.x===t&&e.y===a},T.Point.fuzzyEquals=function(e,t,a){return T.Math.fuzzyEquals(e.x,t.x,a)&&T.Math.fuzzyEquals(e.y,t.y,a)},T.Point.fuzzyEqualsXY=function(e,t,a,o){return T.Math.fuzzyEquals(e.x,t,o)&&T.Math.fuzzyEquals(e.y,a,o)},T.Point.angle=function(e,t){return r(e.y-t.y,e.x-t.x)},T.Point.negative=function(e,t){return void 0===t&&(t=new T.Point),t.setTo(-e.x,-e.y)},T.Point.multiplyAdd=function(e,t,a,o){return void 0===o&&(o=new T.Point),o.setTo(e.x+t.x*a,e.y+t.y*a)},T.Point.interpolate=function(e,t,a,o){return void 0===o&&(o=new T.Point),o.setTo(e.x+(t.x-e.x)*a,e.y+(t.y-e.y)*a)},T.Point.perp=function(e,t){return void 0===t&&(t=new T.Point),t.setTo(-e.y,e.x)},T.Point.rperp=function(e,t){return void 0===t&&(t=new T.Point),t.setTo(e.y,-e.x)},T.Point.distance=function(e,t,a){var o=T.Math.distance(e.x,e.y,t.x,t.y);return a?n(o):o},T.Point.project=function(e,t,a){void 0===a&&(a=new T.Point);var o=e.dot(t)/t.getMagnitudeSq();return 0!=o&&a.setTo(o*t.x,o*t.y),a},T.Point.projectUnit=function(e,t,a){void 0===a&&(a=new T.Point);var o=e.dot(t);return 0!==o&&a.setTo(o*t.x,o*t.y),a},T.Point.normalRightHand=function(e,t){return void 0===t&&(t=new T.Point),t.setTo(-1*e.y,e.x)},T.Point.normalize=function(e,t){void 0===t&&(t=new T.Point);var a=e.getMagnitude();return 0!==a&&t.setTo(e.x/a,e.y/a),t},T.Point.rotate=function(e,a,o,n,i,d){if(i&&(n=T.Math.degToRad(n)),void 0===d){e.subtract(a,o);var l=h(n),s=m(n),p=s*e.x-l*e.y,c=l*e.x+s*e.y;e.x=p+a,e.y=c+o}else{var u=n+r(e.y-o,e.x-a);e.x=a+d*m(u),e.y=o+d*h(u)}return e},T.Point.centroid=function(e,t){if(void 0===t&&(t=new T.Point),"[object Array]"!==Object.prototype.toString.call(e))throw new Error("Phaser.Point. Parameter 'points' must be an array");var a=e.length;if(1>a)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===a)return t.copyFrom(e[0]),t;for(var o=0;o<a;o++)T.Point.add(t,e[o],t);return t.divide(a,a),t},T.Point.parse=function(e,t,a){t=t||"x",a=a||"y";var o=new T.Point;return e[t]&&(o.x=parseInt(e[t],10)),e[a]&&(o.y=parseInt(e[a],10)),o},T.Point.isPoint=function(e){return null!=e&&"number"==typeof e.x&&"number"==typeof e.y},T.Point.set=function(e,t,a){return e.x=t||0,e.y=a||(0===a?0:e.x),e},PIXI.Point=T.Point,T.Polygon=function(){this.area=0,this._points=[],0<arguments.length&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=T.POLYGON},T.Polygon.prototype={toNumberArray:function(e){void 0===e&&(e=[]);for(var t=0;t<this._points.length;t++)"number"==typeof this._points[t]?(e.push(this._points[t]),e.push(this._points[t+1]),t++):(e.push(this._points[t].x),e.push(this._points[t].y));return e},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(e){var t=this._points.slice();return void 0===e||null===e?e=new T.Polygon(t):e.setTo(t),e},contains:function(e,t){var a=!1;if(this.flattened)for(var o=-2,r=this._points.length-2;(o+=2)<this._points.length;r=o){var n=this._points[o],i=this._points[o+1],s=this._points[r],d=this._points[r+1];(i<=t&&t<d||d<=t&&t<i)&&e<(s-n)*(t-i)/(d-i)+n&&(a=!a)}else for(var o=-1,r=this._points.length-1;++o<this._points.length;r=o){var n=this._points[o].x,i=this._points[o].y,s=this._points[r].x,d=this._points[r].y;(i<=t&&t<d||d<=t&&t<i)&&e<(s-n)*(t-i)/(d-i)+n&&(a=!a)}return a},setTo:function(e){if(this.area=0,this._points=[],0<arguments.length){Array.isArray(e)||(e=Array.prototype.slice.call(arguments));for(var t=g,a=0,o=e.length;a<o;a++){if("number"==typeof e[a]){var r=new PIXI.Point(e[a],e[a+1]);a++}else if(Array.isArray(e[a]))var r=new PIXI.Point(e[a][0],e[a][1]);else var r=new PIXI.Point(e[a].x,e[a].y);this._points.push(r),r.y<t&&(t=r.y)}this.calculateArea(t)}return this},calculateArea:function(e){for(var t=0,a=this._points.length,o,r,n,i;t<a;t++)o=this._points[t],r=t===a-1?this._points[0]:this._points[t+1],n=(o.y-e+(r.y-e))/2,i=o.x-r.x,this.area+=n*i;return this.area}},T.Polygon.prototype.constructor=T.Polygon,Object.defineProperty(T.Polygon.prototype,"points",{get:function(){return this._points},set:function(e){null==e?this.setTo():this.setTo(e)}}),PIXI.Polygon=T.Polygon,T.Rectangle=function(e,t,a,o){e=e||0,t=t||0,a=a||0,o=o||0,this.x=e,this.y=t,this.width=a,this.height=o,this.type=T.RECTANGLE},T.Rectangle.prototype={offset:function(e,t){return this.x+=e,this.y+=t,this},offsetPoint:function(e){return this.offset(e.x,e.y)},setTo:function(e,t,a,o){return this.x=e,this.y=t,this.width=a,this.height=o,this},scale:function(e,t){return void 0===t&&(t=e),this.width*=e,this.height*=t,this},centerOn:function(e,t){return this.centerX=e,this.centerY=t,this},floor:function(){this.x=c(this.x),this.y=c(this.y)},floorAll:function(){this.x=c(this.x),this.y=c(this.y),this.width=c(this.width),this.height=c(this.height)},ceil:function(){this.x=l(this.x),this.y=l(this.y)},ceilAll:function(){this.x=l(this.x),this.y=l(this.y),this.width=l(this.width),this.height=l(this.height)},copyFrom:function(e){return this.setTo(e.x,e.y,e.width,e.height)},copyFromBounds:function(e){return this.setTo(e.left,e.top,e.width,e.height)},copyTo:function(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e},inflate:function(e,t){return T.Rectangle.inflate(this,e,t)},size:function(e){return T.Rectangle.size(this,e)},resize:function(e,t){return this.width=e,this.height=t,this},clone:function(e){return T.Rectangle.clone(this,e)},contains:function(e,t){return T.Rectangle.contains(this,e,t)},containsRect:function(e){return T.Rectangle.containsRect(e,this)},equals:function(e){return T.Rectangle.equals(this,e)},intersection:function(e,t){return T.Rectangle.intersection(this,e,t)},intersects:function(e){return T.Rectangle.intersects(this,e)},intersectsRaw:function(e,t,a,o,r){return T.Rectangle.intersectsRaw(this,e,t,a,o,r)},union:function(e,t){return T.Rectangle.union(this,e,t)},random:function(e){return void 0===e&&(e=new T.Point),e.x=this.randomX,e.y=this.randomY,e},getPoint:function(e,t){switch(void 0===t&&(t=new T.Point),e){default:case T.TOP_LEFT:return t.set(this.x,this.y);case T.TOP_CENTER:return t.set(this.centerX,this.y);case T.TOP_RIGHT:return t.set(this.right,this.y);case T.LEFT_CENTER:return t.set(this.x,this.centerY);case T.CENTER:return t.set(this.centerX,this.centerY);case T.RIGHT_CENTER:return t.set(this.right,this.centerY);case T.BOTTOM_LEFT:return t.set(this.x,this.bottom);case T.BOTTOM_CENTER:return t.set(this.centerX,this.bottom);case T.BOTTOM_RIGHT:return t.set(this.right,this.bottom);}},sides:function(e,t,a,o){arguments.length||(e=new T.Line,t=new T.Line,a=new T.Line,o=new T.Line);var r=this.x,n=this.y,i=this.right,s=this.bottom;return e.setTo(r,n,i,n),t.setTo(i,n,i,s),a.setTo(r,s,i,s),o.setTo(r,n,r,s),arguments.length?null:[e,t,a,o]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(T.Rectangle.prototype,"halfWidth",{get:function(){return n(this.width/2)}}),Object.defineProperty(T.Rectangle.prototype,"halfHeight",{get:function(){return n(this.height/2)}}),Object.defineProperty(T.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(e){this.height=e<=this.y?0:e-this.y}}),Object.defineProperty(T.Rectangle.prototype,"bottomLeft",{get:function(){return new T.Point(this.x,this.bottom)},set:function(e){this.x=e.x,this.bottom=e.y}}),Object.defineProperty(T.Rectangle.prototype,"bottomRight",{get:function(){return new T.Point(this.right,this.bottom)},set:function(e){this.right=e.x,this.bottom=e.y}}),Object.defineProperty(T.Rectangle.prototype,"left",{get:function(){return this.x},set:function(e){this.width=e>=this.right?0:this.right-e,this.x=e}}),Object.defineProperty(T.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(e){this.width=e<=this.x?0:e-this.x}}),Object.defineProperty(T.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(T.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(T.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(e){this.x=e-this.halfWidth}}),Object.defineProperty(T.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(e){this.y=e-this.halfHeight}}),Object.defineProperty(T.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(T.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(T.Rectangle.prototype,"top",{get:function(){return this.y},set:function(e){e>=this.bottom?(this.height=0,this.y=e):this.height=this.bottom-e}}),Object.defineProperty(T.Rectangle.prototype,"topLeft",{get:function(){return new T.Point(this.x,this.y)},set:function(e){this.x=e.x,this.y=e.y}}),Object.defineProperty(T.Rectangle.prototype,"topRight",{get:function(){return new T.Point(this.x+this.width,this.y)},set:function(e){this.right=e.x,this.y=e.y}}),Object.defineProperty(T.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(e){!0===e&&this.setTo(0,0,0,0)}}),T.Rectangle.prototype.constructor=T.Rectangle,T.Rectangle.inflate=function(e,t,a){return e.x-=t,e.width+=2*t,e.y-=a,e.height+=2*a,e},T.Rectangle.inflatePoint=function(e,t){return T.Rectangle.inflate(e,t.x,t.y)},T.Rectangle.size=function(e,t){return void 0===t||null===t?t=new T.Point(e.width,e.height):t.setTo(e.width,e.height),t},T.Rectangle.clone=function(e,t){return void 0===t||null===t?t=new T.Rectangle(e.x,e.y,e.width,e.height):t.setTo(e.x,e.y,e.width,e.height),t},T.Rectangle.createFromBounds=function(e,t){return(void 0===t||null===t)&&(t=new T.Rectangle(e.x,e.y,e.width,e.height)),t.copyFromBounds(e)},T.Rectangle.contains=function(e,t,a){return 0>=e.width||0>=e.height?!1:t>=e.x&&t<e.right&&a>=e.y&&a<e.bottom},T.Rectangle.containsRaw=function(e,t,a,o,r,n){return r>=e&&r<e+a&&n>=t&&n<t+o},T.Rectangle.containsPoint=function(e,t){return T.Rectangle.contains(e,t.x,t.y)},T.Rectangle.containsRect=function(e,t){return!(e.volume>t.volume)&&e.x>=t.x&&e.y>=t.y&&e.right<t.right&&e.bottom<t.bottom},T.Rectangle.equals=function(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height},T.Rectangle.sameDimensions=function(e,t){return e.width===t.width&&e.height===t.height},T.Rectangle.intersection=function(e,t,a){return void 0===a&&(a=new T.Rectangle),T.Rectangle.intersects(e,t)&&(a.x=s(e.x,t.x),a.y=s(e.y,t.y),a.width=p(e.right,t.right)-a.x,a.height=p(e.bottom,t.bottom)-a.y),a},T.Rectangle.intersects=function(e,t){return 0>=e.width||0>=e.height||0>=t.width||0>=t.height?!1:!(e.right<t.x||e.bottom<t.y||e.x>t.right||e.y>t.bottom)},T.Rectangle.intersectsRaw=function(e,t,a,o,r,n){return void 0===n&&(n=0),!(t>e.right+n||a<e.left-n||o>e.bottom+n||r<e.top-n)},T.Rectangle.union=function(e,t,a){return void 0===a&&(a=new T.Rectangle),a.setTo(p(e.x,t.x),p(e.y,t.y),s(e.right,t.right)-p(e.left,t.left),s(e.bottom,t.bottom)-p(e.top,t.top))},T.Rectangle.aabb=function(e,t){var a=Number.NEGATIVE_INFINITY;void 0===t&&(t=new T.Rectangle);var r=a,n=o,i=a,s=o;return e.forEach(function(e){e.x>r&&(r=e.x),e.x<n&&(n=e.x),e.y>i&&(i=e.y),e.y<s&&(s=e.y)}),t.setTo(n,s,r-n,i-s),t},PIXI.Rectangle=T.Rectangle,PIXI.EmptyRectangle=new T.Rectangle(0,0,0,0),T.RoundedRectangle=function(e,t,a,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===r&&(r=20),this.x=e,this.y=t,this.width=a,this.height=o,this.radius=r||20,this.type=T.ROUNDEDRECTANGLE},T.RoundedRectangle.prototype={clone:function(){return new T.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(e,t){if(0>=this.width||0>=this.height)return!1;var a=this.x;if(e>=a&&e<=a+this.width){var o=this.y;if(t>=o&&t<=o+this.height)return!0}return!1}},T.RoundedRectangle.prototype.constructor=T.RoundedRectangle,PIXI.RoundedRectangle=T.RoundedRectangle,T.Camera=function(e,t,a,o,r,n){this.game=e,this.world=e.world,this.id=0,this.view=new T.Rectangle(a,o,r,n),this.bounds=new T.Rectangle(a,o,r,n),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new T.Point(1,1),this.onShakeComplete=new T.Signal,this.onFlashComplete=new T.Signal,this.onFadeComplete=new T.Signal,this.fx=null,this._targetPosition=new T.Point,this._edge=0,this._position=new T.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0,this._fixedView=new T.Rectangle},T.Camera.FOLLOW_LOCKON=0,T.Camera.FOLLOW_PLATFORMER=1,T.Camera.FOLLOW_TOPDOWN=2,T.Camera.FOLLOW_TOPDOWN_TIGHT=3,T.Camera.SHAKE_BOTH=4,T.Camera.SHAKE_HORIZONTAL=5,T.Camera.SHAKE_VERTICAL=6,T.Camera.ENABLE_FX=!0,T.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,T.Graphics&&T.Camera.ENABLE_FX&&(this.fx=new T.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(e,t,a,o){void 0===t&&(t=T.Camera.FOLLOW_LOCKON),void 0===a&&(a=1),void 0===o&&(o=1),this.target=e,this.lerp.set(a,o);var r;switch(t){case T.Camera.FOLLOW_PLATFORMER:var n=this.width/8,i=this.height/3;this.deadzone=new T.Rectangle((this.width-n)/2,(this.height-i)/2-0.25*i,n,i);break;case T.Camera.FOLLOW_TOPDOWN:r=s(this.width,this.height)/4,this.deadzone=new T.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case T.Camera.FOLLOW_TOPDOWN_TIGHT:r=s(this.width,this.height)/8,this.deadzone=new T.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case T.Camera.FOLLOW_LOCKON:this.deadzone=null;break;default:this.deadzone=null;}},unfollow:function(){this.target=null},focusOn:function(e){this.setPosition(n(e.x-this.view.halfWidth),n(e.y-this.view.halfHeight))},focusOnXY:function(e,t){this.setPosition(n(e-this.view.halfWidth),n(t-this.view.halfHeight))},shake:function(e,t,a,o,r){return(void 0===e&&(e=0.05),void 0===t&&(t=500),void 0===a&&(a=!0),void 0===o&&(o=T.Camera.SHAKE_BOTH),void 0===r&&(r=!0),a||!(0<this._shake.duration))&&(this._shake.intensity=e,this._shake.duration=t,this._shake.shakeBounds=r,this._shake.x=0,this._shake.y=0,this._shake.horizontal=o===T.Camera.SHAKE_BOTH||o===T.Camera.SHAKE_HORIZONTAL,this._shake.vertical=o===T.Camera.SHAKE_BOTH||o===T.Camera.SHAKE_VERTICAL,!0)},flash:function(e,t,a,o){return(void 0===e&&(e=16777215),void 0===t&&(t=500),void 0===a&&(a=!1),void 0===o&&(o=1),this.fx&&(a||!(0<this._fxDuration)))&&(this.fx.clear(),this.fx.beginFill(e,o),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=t,this._fxType=0,!0)},fade:function(e,t,a,o){return(void 0===e&&(e=0),void 0===t&&(t=500),void 0===a&&(a=!1),void 0===o&&(o=1),this.fx&&(a||!(0<this._fxDuration)))&&(this.fx.clear(),this.fx.beginFill(e,o),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=t,this._fxType=1,!0)},update:function(){0<this._fxDuration&&this.updateFX(),0<this._shake.duration&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=c(this._shake.x),this._shake.y=c(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,0>=this.fx.alpha&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,1<=this.fx.alpha&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS,0>=this._shake.duration?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=2*(this.game.rnd.frac()*this._shake.intensity*this.view.width)-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=2*(this.game.rnd.frac()*this._shake.intensity*this.view.height)-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var e=this.view.x+this._shake.x,t=this.view.right+this._shake.x,a=this.view.y+this._shake.y,o=this.view.bottom+this._shake.y;e<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,!this._shake.shakeBounds&&(this._shake.x=0)):t>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,!this._shake.shakeBounds&&(this._shake.x=0)),a<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,!this._shake.shakeBounds&&(this._shake.y=0)):o>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,!this._shake.shakeBounds&&(this._shake.y=0))},setPosition:function(e,t){this.view.x=e,this.view.y=t,this.bounds&&this.checkBounds()},setSize:function(e,t){this.view.width=e,this.view.height=t},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},T.Camera.prototype.constructor=T.Camera,Object.defineProperty(T.Camera.prototype,"x",{get:function(){return this.view.x},set:function(e){this.view.x=e,this.bounds&&this.checkBounds()}}),Object.defineProperty(T.Camera.prototype,"y",{get:function(){return this.view.y},set:function(e){this.view.y=e,this.bounds&&this.checkBounds()}}),Object.defineProperty(T.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(e){"undefined"!=typeof e.x&&(this.view.x=e.x),"undefined"!=typeof e.y&&(this.view.y=e.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(T.Camera.prototype,"width",{get:function(){return this.view.width},set:function(e){this.view.width=e}}),Object.defineProperty(T.Camera.prototype,"height",{get:function(){return this.view.height},set:function(e){this.view.height=e}}),Object.defineProperty(T.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(e){this._shake.intensity=e}}),Object.defineProperty(T.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),T.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},T.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},T.State.prototype.constructor=T.State,T.StateManager=function(e,t){this.game=e,this.states={},this._pendingState=null,"undefined"!=typeof t&&null!==t&&(this._pendingState=t),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new T.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},T.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(e,t,a){void 0===a&&(a=!1);var o;return t instanceof T.State?o=t:"object"==typeof t?(o=t,o.game=this.game):"function"==typeof t&&(o=new t(this.game)),this.states[e]=o,a&&(this.game.isBooted?this.start(e):this._pendingState=e),o},remove:function(e){this.current===e&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[e]},start:function(e,t,a){void 0===t&&(t=!0),void 0===a&&(a=!1),this.checkState(e)&&(this._pendingState=e,this._clearWorld=t,this._clearCache=a,3<arguments.length&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!1),this._pendingState=this.current,this._clearWorld=e,this._clearCache=t,2<arguments.length&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var e=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,e),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(e){var t=this.states[e];return t?t.preload||t.create||t.update||t.render||(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+e),!1)},link:function(e){this.states[e].game=this.game,this.states[e].add=this.game.add,this.states[e].make=this.game.make,this.states[e].camera=this.game.camera,this.states[e].cache=this.game.cache,this.states[e].input=this.game.input,this.states[e].load=this.game.load,this.states[e].math=this.game.math,this.states[e].sound=this.game.sound,this.states[e].scale=this.game.scale,this.states[e].state=this,this.states[e].stage=this.game.stage,this.states[e].time=this.game.time,this.states[e].tweens=this.game.tweens,this.states[e].world=this.game.world,this.states[e].particles=this.game.particles,this.states[e].rnd=this.game.rnd,this.states[e].physics=this.game.physics,this.states[e].key=e},unlink:function(e){this.states[e]&&(this.states[e].game=null,this.states[e].add=null,this.states[e].make=null,this.states[e].camera=null,this.states[e].cache=null,this.states[e].input=null,this.states[e].load=null,this.states[e].math=null,this.states[e].sound=null,this.states[e].scale=null,this.states[e].state=null,this.states[e].stage=null,this.states[e].time=null,this.states[e].tweens=null,this.states[e].world=null,this.states[e].particles=null,this.states[e].rnd=null,this.states[e].physics=null)},setCurrentState:function(e){this.callbackContext=this.states[e],this.link(e),this.onInitCallback=this.states[e].init||this.dummy,this.onPreloadCallback=this.states[e].preload||null,this.onLoadRenderCallback=this.states[e].loadRender||null,this.onLoadUpdateCallback=this.states[e].loadUpdate||null,this.onCreateCallback=this.states[e].create||null,this.onUpdateCallback=this.states[e].update||null,this.onPreRenderCallback=this.states[e].preRender||null,this.onRenderCallback=this.states[e].render||null,this.onResizeCallback=this.states[e].resize||null,this.onPausedCallback=this.states[e].paused||null,this.onResumedCallback=this.states[e].resumed||null,this.onPauseUpdateCallback=this.states[e].pauseUpdate||null,this.onShutDownCallback=this.states[e].shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=e,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),e===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game),!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(e){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,e)},resize:function(e,t){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,e,t)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===T.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},T.StateManager.prototype.constructor=T.StateManager,Object.defineProperty(T.StateManager.prototype,"created",{get:function(){return this._created}}),T.Signal=function(){},T.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(e,t){if("function"!=typeof e)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))},_registerListener:function(e,t,a,o,r){var n=this._indexOfListener(e,a),i;if(-1===n)i=new T.SignalBinding(this,e,t,a,o,r),this._addBinding(i);else if(i=this._bindings[n],i.isOnce()!==t)throw new Error("You cannot add"+(t?"":"Once")+"() then add"+(t?"Once":"")+"() the same listener without removing the relationship first.");return this.memorize&&this._prevParams&&i.execute(this._prevParams),i},_addBinding:function(e){this._bindings||(this._bindings=[]);var t=this._bindings.length;do t--;while(this._bindings[t]&&e._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,e)},_indexOfListener:function(e,t){if(!this._bindings)return-1;void 0===t&&(t=null);for(var a=this._bindings.length,o;a--;)if(o=this._bindings[a],o._listener===e&&o.context===t)return a;return-1},has:function(e,t){return-1!==this._indexOfListener(e,t)},add:function(e,t,a){this.validateListener(e,"add");var o=[];if(3<arguments.length)for(var r=3;r<arguments.length;r++)o.push(arguments[r]);return this._registerListener(e,!1,t,a,o)},addOnce:function(e,t,a){this.validateListener(e,"addOnce");var o=[];if(3<arguments.length)for(var r=3;r<arguments.length;r++)o.push(arguments[r]);return this._registerListener(e,!0,t,a,o)},remove:function(e,t){this.validateListener(e,"remove");var a=this._indexOfListener(e,t);return-1!==a&&(this._bindings[a]._destroy(),this._bindings.splice(a,1)),e},removeAll:function(e){if(void 0===e&&(e=null),!!this._bindings){for(var t=this._bindings.length;t--;)e?this._bindings[t].context===e&&(this._bindings[t]._destroy(),this._bindings.splice(t,1)):this._bindings[t]._destroy();e||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&this._bindings){var e=Array.prototype.slice.call(arguments),t=this._bindings.length,a;if(this.memorize&&(this._prevParams=e),!!t){a=this._bindings.slice(),this._shouldPropagate=!0;do t--;while(a[t]&&this._shouldPropagate&&!1!==a[t].execute(e))}}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll(),this._bindings=null,this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},Object.defineProperty(T.Signal.prototype,"boundDispatch",{get:function(){var e=this;return this._boundDispatch||(this._boundDispatch=function(){return e.dispatch.apply(e,arguments)})}}),T.Signal.prototype.constructor=T.Signal,T.SignalBinding=function(e,t,a,o,r,n){this._listener=t,a&&(this._isOnce=!0),null!=o&&(this.context=o),this._signal=e,r&&(this._priority=r),n&&n.length&&(this._args=n)},T.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(e){var t,a;return this.active&&!!this._listener&&(a=this.params?this.params.concat(e):e,this._args&&(a=a.concat(this._args)),t=this._listener.apply(this.context,a),this.callCount++,this._isOnce&&this.detach()),t},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},T.SignalBinding.prototype.constructor=T.SignalBinding,T.Filter=function(e,t,a){this.game=e,this.type=T.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new T.Point;var o=new Date;if(this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[o.getFullYear(),o.getMonth(),o.getDate(),60*(60*o.getHours())+60*o.getMinutes()+o.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},t)for(var r in t)this.uniforms[r]=t[r];"string"==typeof a&&(a=a.split("\n")),this.fragmentSrc=a||[]},T.Filter.prototype={init:function(){},setResolution:function(e,t){this.uniforms.resolution.value.x=e,this.uniforms.resolution.value.y=t},update:function(e){if(e){var t=e.x/this.game.width,a=1-e.y/this.game.height;(t!==this.prevPoint.x||a!==this.prevPoint.y)&&(this.uniforms.mouse.value.x=t.toFixed(2),this.uniforms.mouse.value.y=a.toFixed(2),this.prevPoint.set(t,a))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(e,t,a,o,r,n){void 0===r&&(r=0),void 0===n&&(n=0),void 0!==a&&null!==a?this.width=a:a=this.width,void 0!==o&&null!==o?this.height=o:o=this.height;var i=this.game.add.image(e,t,T.Cache.DEFAULT);return i.width=a,i.height=o,i.anchor.set(r,n),i.filters=[this],i},syncUniforms:function(){for(var e=0;e<this.shaders.length;e++)this.shaders[e].dirty=!0},destroy:function(){this.passes.length=0,this.shaders.length=0,this.fragmentSrc.length=0,this.game=null,this.uniforms=null,this.prevPoint=null}},T.Filter.prototype.constructor=T.Filter,Object.defineProperty(T.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(e){this.uniforms.resolution.value.x=e}}),Object.defineProperty(T.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(e){this.uniforms.resolution.value.y=e}}),T.Plugin=function(e,t){void 0===t&&(t=null),this.game=e,this.parent=t,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},T.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},T.Plugin.prototype.constructor=T.Plugin,T.PluginManager=function(e){this.game=e,this.plugins=[],this._len=0,this._i=0},T.PluginManager.prototype={add:function(e){var t=Array.prototype.slice.call(arguments,1),a=!1;return"function"==typeof e?e=new e(this.game,this):(e.game=this.game,e.parent=this),"function"==typeof e.preUpdate&&(e.hasPreUpdate=!0,a=!0),"function"==typeof e.update&&(e.hasUpdate=!0,a=!0),"function"==typeof e.postUpdate&&(e.hasPostUpdate=!0,a=!0),"function"==typeof e.render&&(e.hasRender=!0,a=!0),"function"==typeof e.postRender&&(e.hasPostRender=!0,a=!0),a?((e.hasPreUpdate||e.hasUpdate||e.hasPostUpdate)&&(e.active=!0),(e.hasRender||e.hasPostRender)&&(e.visible=!0),this._len=this.plugins.push(e),"function"==typeof e.init&&e.init.apply(e,t),e):null},remove:function(e,t){for(void 0===t&&(t=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===e)return t&&e.destroy(),this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0,this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll(),this.game=null}},T.PluginManager.prototype.constructor=T.PluginManager,T.Stage=function(e){this.game=e,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new T.Matrix,this.stage=this,this.currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},this.game.transparent||(this._bgColor.a=1),e.config&&this.parseConfig(e.config)},T.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),T.Stage.prototype.constructor=T.Stage,T.Stage.prototype.parseConfig=function(e){e.disableVisibilityChange&&(this.disableVisibilityChange=e.disableVisibilityChange),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor)},T.Stage.prototype.boot=function(){T.DOM.getOffset(this.game.canvas,this.offset),T.Canvas.setUserSelect(this.game.canvas,"none"),T.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},T.Stage.prototype.preUpdate=function(){this.currentRenderOrderID=0;for(var e=0,t;e<this.children.length;)t=this.children[e],t.preUpdate(),this===t.parent&&e++},T.Stage.prototype.update=function(){for(var e=this.children.length;e--;)this.children[e].update()},T.Stage.prototype.postUpdate=function(){this.game.camera.update(),this.game.camera.target&&(this.game.camera.target.postUpdate(),this.updateTransform(),this.game.camera.updateTarget());for(var e=0;e<this.children.length;e++)this.children[e].postUpdate();this.updateTransform()},T.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var e=0;e<this.children.length;e++)this.children[e].updateTransform()},T.Stage.prototype.checkVisibility=function(){this._hiddenVar=void 0===document.hidden?void 0===document.webkitHidden?void 0===document.mozHidden?void 0===document.msHidden?null:"msvisibilitychange":"mozvisibilitychange":"webkitvisibilitychange":"visibilitychange";var e=this;this._onChange=function(t){return e.visibilityChange(t)},this._onClick=function(t){void 0===document.hasFocus||document.hasFocus()||e.visibilityChange(t)},this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1),window.onblur=this._onChange,window.onfocus=this._onChange,window.onpagehide=this._onChange,window.onpageshow=this._onChange,window.addEventListener("click",this._onClick),this.game.device.cocoonJSApp&&(CocoonJS.App.onSuspended.addEventListener(function(){T.Stage.prototype.visibilityChange.call(e,{type:"pause"})}),CocoonJS.App.onActivated.addEventListener(function(){T.Stage.prototype.visibilityChange.call(e,{type:"resume"})}))},T.Stage.prototype.visibilityChange=function(e){switch(e.type){case"blur":case"pagehide":return void this.game.focusLoss(e);case"click":case"focus":case"pageshow":return void this.game.focusGain(e);}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===e.type?this.game.gamePaused(e):this.game.gameResumed(e))},T.Stage.prototype.setBackgroundColor=function(e){this.game.transparent||(T.Color.valueToColor(e,this._bgColor),T.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},T.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1),window.onpagehide=null,window.onpageshow=null,window.onblur=null,window.onfocus=null,window.removeEventListener("click",this._onClick)},Object.defineProperty(T.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(e){this.setBackgroundColor(e)}}),Object.defineProperty(T.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(e){PIXI.scaleModes.DEFAULT=e?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}}),T.Group=function(e,t,a,o,r,n){void 0===o&&(o=!1),void 0===r&&(r=!1),void 0===n&&(n=T.Physics.ARCADE),this.game=e,void 0===t&&(t=e.world),this.name=a||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),o?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):t&&(t.addChild(this),this.z=t.children.length),this.type=T.GROUP,this.physicsType=T.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=T.Sprite,this.cursor=null,this.inputEnableChildren=!1,this.updateOnlyExistingChildren=!1,this.onChildInputDown=new T.Signal,this.onChildInputUp=new T.Signal,this.onChildInputOver=new T.Signal,this.onChildInputOut=new T.Signal,this.enableBody=r,this.enableBodyDebug=!1,this.physicsBodyType=n,this.physicsSortDirection=null,this.onDestroy=new T.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new T.Point,this.hash=[],this._sortProperty="z"},T.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),T.Group.prototype.constructor=T.Group,T.Group.RETURN_NONE=0,T.Group.RETURN_TOTAL=1,T.Group.RETURN_CHILD=2,T.Group.RETURN_ALL=3,T.Group.SORT_ASCENDING=-1,T.Group.SORT_DESCENDING=1,T.Group.prototype.add=function(e,t,a){return(void 0===t&&(t=!1),e.parent===this)?e:(e.body&&e.parent&&e.parent.hash&&e.parent.removeFromHash(e),void 0===a?(e.z=this.children.length,this.addChild(e)):(this.addChildAt(e,a),this.updateZ()),this.enableBody&&e.hasOwnProperty("body")&&null===e.body?this.game.physics.enable(e,this.physicsBodyType):e.body&&this.addToHash(e),this.inputEnableChildren&&(!e.input||e.inputEnabled)&&(e.inputEnabled=!0),!t&&e.events&&e.events.onAddedToGroup$dispatch(e,this),null===this.cursor&&(this.cursor=e),e)},T.Group.prototype.addAt=function(e,t,a){return this.add(e,a,t)},T.Group.prototype.addToHash=function(e){if(e.parent===this){var t=this.hash.indexOf(e);if(-1===t)return this.hash.push(e),!0}return!1},T.Group.prototype.removeFromHash=function(e){if(e){var t=this.hash.indexOf(e);if(-1!==t)return this.hash.splice(t,1),!0}return!1},T.Group.prototype.addMultiple=function(e,t){if(e instanceof T.Group)e.moveAll(this,t);else if(Array.isArray(e))for(var a=0;a<e.length;a++)this.add(e[a],t);return e},T.Group.prototype.getAt=function(e){return 0>e||e>=this.children.length?-1:this.getChildAt(e)},T.Group.prototype.create=function(e,t,a,o,r,n){void 0===r&&(r=!0);var i=new this.classType(this.game,e,t,a,o);return i.exists=r,i.visible=r,i.alive=r,this.add(i,!1,n)},T.Group.prototype.createMultiple=function(e,t,a,o,r,n){void 0===a&&(a=0),void 0===o&&(o=!1),Array.isArray(t)||(t=[t]),Array.isArray(a)||(a=[a]);var s=this,d=[];return t.forEach(function(t){a.forEach(function(a){for(var l=0,i;l<e;l++)i=s.create(0,0,t,a,o),r&&r.call(n||i,i,l),d.push(i)})}),d},T.Group.prototype.updateZ=function(){for(var e=this.children.length;e--;)this.children[e].z=e},T.Group.prototype.align=function(e,t,a,o,n,s){if(void 0===n&&(n=T.TOP_LEFT),void 0===s&&(s=0),0===this.children.length||s>this.children.length||-1===e&&-1===t)return!1;for(var d=new T.Rectangle(0,0,a,o),r=e*a,l=t*o,p=s,i;p<this.children.length;p++){if(i=this.children[p],i.alignIn)i.alignIn(d,n);else continue;if(-1===e)d.y+=o,d.y===l&&(d.x+=a,d.y=0);else if(-1===t)d.x+=a,d.x===r&&(d.x=0,d.y+=o);else if(d.x+=a,d.x===r&&(d.x=0,d.y+=o,d.y===l))return!0}return!0},T.Group.prototype.resetCursor=function(e){if(void 0===e&&(e=0),e>this.children.length-1&&(e=0),this.cursor)return this.cursorIndex=e,this.cursor=this.children[this.cursorIndex],this.cursor},T.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor},T.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor},T.Group.prototype.swap=function(e,t){this.swapChildren(e,t),this.updateZ()},T.Group.prototype.bringToTop=function(e){return e.parent===this&&this.getIndex(e)<this.children.length&&(this.remove(e,!1,!0),this.add(e,!0)),e},T.Group.prototype.sendToBack=function(e){return e.parent===this&&0<this.getIndex(e)&&(this.remove(e,!1,!0),this.addAt(e,0,!0)),e},T.Group.prototype.moveUp=function(e){if(e.parent===this&&this.getIndex(e)<this.children.length-1){var t=this.getIndex(e),a=this.getAt(t+1);a&&this.swap(e,a)}return e},T.Group.prototype.moveDown=function(e){if(e.parent===this&&0<this.getIndex(e)){var t=this.getIndex(e),a=this.getAt(t-1);a&&this.swap(e,a)}return e},T.Group.prototype.xy=function(e,t,a){return 0>e||e>this.children.length?-1:void(this.getChildAt(e).x=t,this.getChildAt(e).y=a)},T.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},T.Group.prototype.getIndex=function(e){return this.children.indexOf(e)},T.Group.prototype.getByName=function(e){for(var t=0;t<this.children.length;t++)if(this.children[t].name===e)return this.children[t];return null},T.Group.prototype.replace=function(e,t){var a=this.getIndex(e);if(-1!==a)return t.parent&&(t.parent instanceof T.Group?t.parent.remove(t):t.parent.removeChild(t)),this.remove(e),this.addAt(t,a),e},T.Group.prototype.hasProperty=function(e,t){var a=t.length;return 1===a&&t[0]in e||2===a&&t[0]in e&&t[1]in e[t[0]]||3===a&&t[0]in e&&t[1]in e[t[0]]&&t[2]in e[t[0]][t[1]]||4===a&&t[0]in e&&t[1]in e[t[0]]&&t[2]in e[t[0]][t[1]]&&t[3]in e[t[0]][t[1]][t[2]]},T.Group.prototype.setProperty=function(e,t,a,o,r){if(void 0===r&&(r=!1),o=o||0,!this.hasProperty(e,t)&&(!r||0<o))return!1;var n=t.length;return 1===n?0===o?e[t[0]]=a:1===o?e[t[0]]+=a:2===o?e[t[0]]-=a:3===o?e[t[0]]*=a:4===o&&(e[t[0]]/=a):2===n?0===o?e[t[0]][t[1]]=a:1===o?e[t[0]][t[1]]+=a:2===o?e[t[0]][t[1]]-=a:3===o?e[t[0]][t[1]]*=a:4===o&&(e[t[0]][t[1]]/=a):3===n?0===o?e[t[0]][t[1]][t[2]]=a:1===o?e[t[0]][t[1]][t[2]]+=a:2===o?e[t[0]][t[1]][t[2]]-=a:3===o?e[t[0]][t[1]][t[2]]*=a:4===o&&(e[t[0]][t[1]][t[2]]/=a):4===n&&(0===o?e[t[0]][t[1]][t[2]][t[3]]=a:1===o?e[t[0]][t[1]][t[2]][t[3]]+=a:2===o?e[t[0]][t[1]][t[2]][t[3]]-=a:3===o?e[t[0]][t[1]][t[2]][t[3]]*=a:4===o&&(e[t[0]][t[1]][t[2]][t[3]]/=a)),!0},T.Group.prototype.checkProperty=function(e,t,a,o){if(void 0===o&&(o=!1),this!==e.parent)return!1;var r=T.Utils.getProperty(e,t);return void 0===r&&o||r!==a?!1:!0},T.Group.prototype.set=function(e,t,a,o,r,n,i){if(void 0===i&&(i=!1),t=t.split("."),void 0===o&&(o=!1),void 0===r&&(r=!1),(!1===o||o&&e.alive)&&(!1===r||r&&e.visible))return this.setProperty(e,t,a,n,i)},T.Group.prototype.setAll=function(e,t,a,o,r,n){void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===n&&(n=!1),e=e.split("."),r=r||0;for(var s=0;s<this.children.length;s++)(!a||a&&this.children[s].alive)&&(!o||o&&this.children[s].visible)&&this.setProperty(this.children[s],e,t,r,n)},T.Group.prototype.setAllChildren=function(e,t,a,o,r,n){void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===n&&(n=!1),r=r||0;for(var s=0;s<this.children.length;s++)(!a||a&&this.children[s].alive)&&(!o||o&&this.children[s].visible)&&(this.children[s]instanceof T.Group?this.children[s].setAllChildren(e,t,a,o,r,n):this.setProperty(this.children[s],e.split("."),t,r,n))},T.Group.prototype.checkAll=function(e,t,a,o,r){void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===r&&(r=!1);for(var n=0,i;n<this.children.length;n++)if(i=this.children[n],(!a||a&&i.alive)&&(!o||o&&i.visible)&&!this.checkProperty(i,e,t,r))return!1;return!0},T.Group.prototype.checkAny=function(e,t,a,o){void 0===a&&(a=!1),void 0===o&&(o=!1);for(var r=0,n;r<this.children.length;r++)if(n=this.children[r],(!a||a&&n.alive)&&(!o||o&&n.visible)&&this.checkProperty(n,e,t))return!0;return!1},T.Group.prototype.addAll=function(e,t,a,o){this.setAll(e,t,a,o,1)},T.Group.prototype.subAll=function(e,t,a,o){this.setAll(e,t,a,o,2)},T.Group.prototype.multiplyAll=function(e,t,a,o){this.setAll(e,t,a,o,3)},T.Group.prototype.divideAll=function(e,t,a,o){this.setAll(e,t,a,o,4)},T.Group.prototype.kill=function(){this.alive=!1,this.exists=!1,this.visible=!1},T.Group.prototype.killAll=function(){this.callAllExists("kill",!0)},T.Group.prototype.revive=function(){this.alive=!0,this.exists=!0,this.visible=!0},T.Group.prototype.reviveAll=function(){this.callAllExists("revive",!1)},T.Group.prototype.resetAll=function(e,t,a,o,r){this.forEach(this.resetChild,this,r,e,t,a,o)},T.Group.prototype.callAllExists=function(e,t){var a;if(2<arguments.length){a=[];for(var o=2;o<arguments.length;o++)a.push(arguments[o])}for(var o=0;o<this.children.length;o++)this.children[o].exists===t&&this.children[o][e]&&this.children[o][e].apply(this.children[o],a)},T.Group.prototype.callbackFromArray=function(e,t,a){if(1===a){if(e[t[0]])return e[t[0]];}else if(2===a){if(e[t[0]][t[1]])return e[t[0]][t[1]];}else if(3===a){if(e[t[0]][t[1]][t[2]])return e[t[0]][t[1]][t[2]];}else if(4===a){if(e[t[0]][t[1]][t[2]][t[3]])return e[t[0]][t[1]][t[2]][t[3]];}else if(e[t])return e[t];return!1},T.Group.prototype.callAll=function(e,t){if(void 0!==e){e=e.split(".");var a=e.length;if(void 0===t||null===t||""===t)t=null;else if("string"==typeof t){t=t.split(".");var o=t.length}var r;if(2<arguments.length){r=[];for(var n=2;n<arguments.length;n++)r.push(arguments[n])}for(var i=null,s=null,n=0;n<this.children.length;n++)i=this.callbackFromArray(this.children[n],e,a),t&&i?(s=this.callbackFromArray(this.children[n],t,o),i&&i.apply(s,r)):i&&i.apply(this.children[n],r)}},T.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(var e=0,t;e<this.children.length;)t=this.children[e],t.preUpdate(),this===t.parent&&e++;return!0},T.Group.prototype.update=function(){for(var e=this.children.length,t;e--;){t=this.children.length,e>=t&&(e=t-1);var a=this.children[e];(!this.updateOnlyExistingChildren||a.exists)&&a.update()}},T.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);for(var e=0;e<this.children.length;e++)this.children[e].postUpdate()},T.Group.prototype.filter=function(e,t){for(var a=-1,o=this.children.length,r=[],n;++a<o;)n=this.children[a],(!t||t&&n.exists)&&e(n,a,this.children)&&r.push(n);return new T.ArraySet(r)},T.Group.prototype.forEach=function(e,t,a){if(void 0===a&&(a=!1),3>=arguments.length)for(var o=0;o<this.children.length;o++)(!a||a&&this.children[o].exists)&&e.call(t,this.children[o]);else{for(var r=[null],o=3;o<arguments.length;o++)r.push(arguments[o]);for(var o=0;o<this.children.length;o++)(!a||a&&this.children[o].exists)&&(r[0]=this.children[o],e.apply(t,r))}},T.Group.prototype.forEachExists=function(e,t){var a;if(2<arguments.length){a=[null];for(var o=2;o<arguments.length;o++)a.push(arguments[o])}this.iterate("exists",!0,T.Group.RETURN_TOTAL,e,t,a)},T.Group.prototype.forEachAlive=function(e,t){var a;if(2<arguments.length){a=[null];for(var o=2;o<arguments.length;o++)a.push(arguments[o])}this.iterate("alive",!0,T.Group.RETURN_TOTAL,e,t,a)},T.Group.prototype.forEachDead=function(e,t){var a;if(2<arguments.length){a=[null];for(var o=2;o<arguments.length;o++)a.push(arguments[o])}this.iterate("alive",!1,T.Group.RETURN_TOTAL,e,t,a)},T.Group.prototype.sort=function(e,t){2>this.children.length||(void 0===e&&(e="z"),void 0===t&&(t=T.Group.SORT_ASCENDING),this._sortProperty=e,t===T.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},T.Group.prototype.customSort=function(e,t){2>this.children.length||(this.children.sort(e.bind(t)),this.updateZ())},T.Group.prototype.ascendingSortHandler=function(e,t){return e[this._sortProperty]<t[this._sortProperty]?-1:e[this._sortProperty]>t[this._sortProperty]?1:e.z<t.z?-1:1},T.Group.prototype.descendingSortHandler=function(e,t){return e[this._sortProperty]<t[this._sortProperty]?1:e[this._sortProperty]>t[this._sortProperty]?-1:0},T.Group.prototype.iterate=function(e,t,a,o,r,n){if(0===this.children.length){if(a===T.Group.RETURN_TOTAL)return 0;if(a===T.Group.RETURN_ALL)return[]}var s=0;if(a===T.Group.RETURN_ALL)var d=[];for(var l=0;l<this.children.length;l++)if(this.children[l][e]===t){if(s++,o&&(n?(n[0]=this.children[l],o.apply(r,n)):o.call(r,this.children[l])),a===T.Group.RETURN_CHILD)return this.children[l];a===T.Group.RETURN_ALL&&d.push(this.children[l])}return a===T.Group.RETURN_TOTAL?s:a===T.Group.RETURN_ALL?d:null},T.Group.prototype.getFirst=function(e,t){return this.iterate(e,t,T.Group.RETURN_CHILD)},T.Group.prototype.getFirstExists=function(e,t,a,o,r,n){void 0===t&&(t=!1),"boolean"!=typeof e&&(e=!0);var i=this.getFirst("exists",e);return null===i&&t?this.create(a,o,r,n):this.resetChild(i,a,o,r,n)},T.Group.prototype.getFirstAlive=function(e,t,a,o,r){void 0===e&&(e=!1);var n=this.getFirst("alive",!0);return null===n&&e?this.create(t,a,o,r):this.resetChild(n,t,a,o,r)},T.Group.prototype.getFirstDead=function(e,t,a,o,r){void 0===e&&(e=!1);var n=this.getFirst("alive",!1);return null===n&&e?this.create(t,a,o,r):this.resetChild(n,t,a,o,r)},T.Group.prototype.resetChild=function(e,t,a,o,r){return null===e?null:(void 0===t&&(t=null),void 0===a&&(a=null),null!==t&&null!==a&&e.reset(t,a),void 0!==o&&e.loadTexture(o,r),e)},T.Group.prototype.getTop=function(){if(0<this.children.length)return this.children[this.children.length-1]},T.Group.prototype.getBottom=function(){if(0<this.children.length)return this.children[0]},T.Group.prototype.getClosestTo=function(e,t,a){for(var o=g,r=0,n=null,s=0,i;s<this.children.length;s++)i=this.children[s],i.exists&&(r=f(T.Point.distance(e,i)),r<o&&(!t||t.call(a,i,r))&&(o=r,n=i));return n},T.Group.prototype.getFurthestFrom=function(e,t,a){for(var o=0,r=0,n=null,s=0,i;s<this.children.length;s++)i=this.children[s],i.exists&&(r=f(T.Point.distance(e,i)),r>o&&(!t||t.call(a,i,r))&&(o=r,n=i));return n},T.Group.prototype.count=function(e,t){return this.iterate(e,t,T.Group.RETURN_TOTAL)},T.Group.prototype.countLiving=function(){return this.count("alive",!0)},T.Group.prototype.countDead=function(){return this.count("alive",!1)},T.Group.prototype.getRandom=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.children.length),0===t?null:T.ArrayUtils.getRandomItem(this.children,e,t)},T.Group.prototype.getRandomExists=function(e,t){var a=this.getAll("exists",!0,e,t);return this.game.rnd.pick(a)},T.Group.prototype.getAll=function(e,t,a,o){void 0===a&&(a=0),void 0===o&&(o=this.children.length);for(var r=[],n=a,i;n<o;n++)i=this.children[n],e?i[e]===t&&r.push(i):r.push(i);return r},T.Group.prototype.remove=function(e,t,a){if(void 0===t&&(t=!1),void 0===a&&(a=!1),0===this.children.length||-1===this.children.indexOf(e))return!1;a||!e.events||e.destroyPhase||e.events.onRemovedFromGroup$dispatch(e,this);var o=this.removeChild(e);return this.removeFromHash(e),this.updateZ(),this.cursor===e&&this.next(),t&&o&&o.destroy(!0),!0},T.Group.prototype.moveAll=function(e,t){if(void 0===t&&(t=!1),0<this.children.length&&e instanceof T.Group){do e.add(this.children[0],t);while(0<this.children.length);this.hash=[],this.cursor=null}return e},T.Group.prototype.removeAll=function(e,t,a){if(void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===a&&(a=!1),0!==this.children.length){do{!t&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var o=this.removeChild(this.children[0]);this.removeFromHash(o),e&&o&&o.destroy(!0,a)}while(0<this.children.length);this.hash=[],this.cursor=null}},T.Group.prototype.removeBetween=function(e,t,a,o){if(void 0===t&&(t=this.children.length-1),void 0===a&&(a=!1),void 0===o&&(o=!1),0!==this.children.length){if(e>t||0>e||t>this.children.length)return!1;for(var r=t;r>=e;){!o&&this.children[r].events&&this.children[r].events.onRemovedFromGroup$dispatch(this.children[r],this);var n=this.removeChild(this.children[r]);this.removeFromHash(n),a&&n&&n.destroy(!0),this.cursor===this.children[r]&&(this.cursor=null),r--}this.updateZ()}},T.Group.prototype.scatter=function(e,t){null==e&&(e=this.game.world.bounds),this.forEach(function(t){t.position.set(e.randomX,e.randomY)},null,t)},T.Group.prototype.shuffle=function(){T.ArrayUtils.shuffle(this.children),this.updateZ()},T.Group.prototype.destroy=function(e,t){null===this.game||this.ignoreDestroy||(void 0===e&&(e=!0),void 0===t&&(t=!1),this.onDestroy.dispatch(this,e,t),this.removeAll(e),this.cursor=null,this.filters=null,this.pendingDestroy=!1,!t&&(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(T.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,T.Group.RETURN_TOTAL)}}),Object.defineProperty(T.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(T.Group.prototype,"angle",{get:function(){return T.Math.radToDeg(this.rotation)},set:function(e){this.rotation=T.Math.degToRad(e)}}),Object.defineProperty(T.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(e){var t=this.getBounds(this.parent),a=this.x-t.x;this.x=e+a-t.halfWidth}}),Object.defineProperty(T.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(e){var t=this.getBounds(this.parent),a=this.y-t.y;this.y=e+a-t.halfHeight}}),Object.defineProperty(T.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(e){var t=this.getBounds(this.parent),a=this.x-t.x;this.x=e+a}}),Object.defineProperty(T.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(e){var t=this.getBounds(this.parent),a=this.x-t.x;this.x=e+a-t.width}}),Object.defineProperty(T.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(e){var t=this.getBounds(this.parent),a=this.y-t.y;this.y=e+a}}),Object.defineProperty(T.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(e){var t=this.getBounds(this.parent),a=this.y-t.y;this.y=e+a-t.height}}),T.World=function(e){T.Group.call(this,e,null,"__world",!1),this.bounds=new T.Rectangle(0,0,e.width,e.height),this.camera=null,this._definedSize=!1,this._width=e.width,this._height=e.height,this.game.state.onStateChange.add(this.stateChange,this)},T.World.prototype=Object.create(T.Group.prototype),T.World.prototype.constructor=T.World,T.World.prototype.boot=function(){this.camera=new T.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},T.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},T.World.prototype.setBounds=function(e,t,a,o){this._definedSize=!0,this._width=a,this._height=o,this.bounds.setTo(e,t,a,o),this.x=e,this.y=t,this.camera.bounds&&this.camera.bounds.setTo(e,t,s(a,this.game.width),s(o,this.game.height)),this.game.physics.setBoundsToWorld()},T.World.prototype.resize=function(e,t){this._definedSize&&(e<this._width&&(e=this._width),t<this._height&&(t=this._height)),this.bounds.width=e,this.bounds.height=t,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},T.World.prototype.shutdown=function(){this.destroy(!0,!0)},T.World.prototype.wrap=function(e,t,a,o,r){void 0===t&&(t=0),void 0===a&&(a=!1),void 0===o&&(o=!0),void 0===r&&(r=!0),a?(e.getBounds(),o&&(e.x+e._currentBounds.width<this.bounds.x?e.x=this.bounds.right:e.x>this.bounds.right&&(e.x=this.bounds.left)),r&&(e.y+e._currentBounds.height<this.bounds.top?e.y=this.bounds.bottom:e.y>this.bounds.bottom&&(e.y=this.bounds.top))):(o&&e.x+t<this.bounds.x?e.x=this.bounds.right+t:o&&e.x-t>this.bounds.right&&(e.x=this.bounds.left-t),r&&e.y+t<this.bounds.top?e.y=this.bounds.bottom+t:r&&e.y-t>this.bounds.bottom&&(e.y=this.bounds.top-t))},Object.defineProperty(T.World.prototype,"width",{get:function(){return this.bounds.width},set:function(e){e<this.game.width&&(e=this.game.width),this.bounds.width=e,this._width=e,this._definedSize=!0}}),Object.defineProperty(T.World.prototype,"height",{get:function(){return this.bounds.height},set:function(e){e<this.game.height&&(e=this.game.height),this.bounds.height=e,this._height=e,this._definedSize=!0}}),Object.defineProperty(T.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}}),Object.defineProperty(T.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}}),Object.defineProperty(T.World.prototype,"randomX",{get:function(){return 0>this.bounds.x?this.game.rnd.between(this.bounds.x,this.bounds.width-f(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}}),Object.defineProperty(T.World.prototype,"randomY",{get:function(){return 0>this.bounds.y?this.game.rnd.between(this.bounds.y,this.bounds.height-f(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}}),T.Game=function(e,t,a,o,r,n,i,s){return this.id=T.GAMES.push(this)-1,this.config=null,this.physicsConfig=s,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.multiTexture=!1,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=T.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=T.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new T.Signal,this.forceSingleUpdate=!0,this._nextFpsNotification=0,1===arguments.length&&"object"==typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},"undefined"!=typeof e&&(this._width=e),"undefined"!=typeof t&&(this._height=t),"undefined"!=typeof a&&(this.renderType=a),"undefined"!=typeof o&&(this.parent=o),"undefined"!=typeof n&&(this.transparent=n),"undefined"!=typeof i&&(this.antialias=i),this.rnd=new T.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new T.StateManager(this,r)),this.device.whenReady(this.boot,this),this},T.Game.prototype={parseConfig:function(e){this.config=e,void 0===e.enableDebug&&(this.config.enableDebug=!0),e.width&&(this._width=e.width),e.height&&(this._height=e.height),e.renderer&&(this.renderType=e.renderer),e.parent&&(this.parent=e.parent),void 0!==e.transparent&&(this.transparent=e.transparent),void 0!==e.antialias&&(this.antialias=e.antialias),void 0!==e.multiTexture&&(this.multiTexture=e.multiTexture),e.resolution&&(this.resolution=e.resolution),void 0!==e.preserveDrawingBuffer&&(this.preserveDrawingBuffer=e.preserveDrawingBuffer),e.physicsConfig&&(this.physicsConfig=e.physicsConfig);var t=[(Date.now()*Math.random()).toString()];e.seed&&(t=e.seed),this.rnd=new T.RandomDataGenerator(t);var a=null;e.state&&(a=e.state),this.state=new T.StateManager(this,a)},boot:function(){this.isBooted||(this.onPause=new T.Signal,this.onResume=new T.Signal,this.onBlur=new T.Signal,this.onFocus=new T.Signal,this.isBooted=!0,PIXI.game=this,this.math=T.Math,this.scale=new T.ScaleManager(this,this._width,this._height),this.stage=new T.Stage(this),this.setUpRenderer(),this.world=new T.World(this),this.add=new T.GameObjectFactory(this),this.make=new T.GameObjectCreator(this),this.cache=new T.Cache(this),this.load=new T.Loader(this),this.time=new T.Time(this),this.tweens=new T.TweenManager(this),this.input=new T.Input(this),this.sound=new T.SoundManager(this),this.physics=new T.Physics(this,this.physicsConfig),this.particles=new T.Particles(this),this.create=new T.Create(this),this.plugins=new T.PluginManager(this),this.net=new T.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.config.enableDebug?(this.debug=new T.Utils.Debug(this),this.debug.boot()):this.debug={preUpdate:function(){},update:function(){},reset:function(){},isDisabled:!0},this.showDebugHeader(),this.isRunning=!0,this.raf=this.config&&this.config.forceSetTimeOut?new T.RequestAnimationFrame(this,this.config.forceSetTimeOut):new T.RequestAnimationFrame(this,!1),this._kickstart=!0,window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus(),this.cache.isReady?this.raf.start():this.cache.onReady.addOnce(function(){this.raf.start()},this))},showDebugHeader:function(){if(!(window.PhaserGlobal&&window.PhaserGlobal.hideBanner)){var e=T.VERSION,t="Canvas",o="HTML Audio",a=1;if(this.renderType===T.WEBGL?(t="WebGL",a++):this.renderType===T.HEADLESS&&(t="Headless"),this.device.webAudio&&(o="WebAudio",a++),!this.device.ie){for(var r=["%c %c %c Phaser CE v"+e+" | Pixi.js | "+t+" | "+o+"  %c %c %c http://phaser.io %c\u2665%c\u2665%c\u2665","background: #fb8cb3","background: #d44a52","color: #ffffff; background: #871905;","background: #d44a52","background: #fb8cb3","background: #ffffff"],n=0;3>n;n++)n<a?r.push("color: #ff2424; background: #fff"):r.push("color: #959595; background: #fff");console.log.apply(console,r)}else window.console&&console.log("Phaser v"+e+" | Pixi.js | "+t+" | "+o+" | http://phaser.io")}},setUpRenderer:function(){if(this.canvas=this.config.canvas?this.config.canvas:T.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.renderType!==T.HEADLESS&&this.renderType!==T.CANVAS&&(this.renderType!==T.AUTO||this.device.webGL))(this.multiTexture||this.renderType===T.WEBGL_MULTI)&&(PIXI.enableMultiTexture(),this.multiTexture=!0),this.renderType=T.WEBGL,this.renderer=new PIXI.WebGLRenderer(this),this.context=null,this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1);else if(this.device.canvas)this.renderer=new PIXI.CanvasRenderer(this),this.context=this.renderer.context,this.renderType===T.AUTO&&(this.renderType=T.CANVAS);else throw new Error("Phaser.Game - Cannot create Canvas or WebGL context, aborting.");this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===T.CANVAS),this.renderType!==T.HEADLESS&&(this.stage.smoothed=this.antialias,T.Canvas.addToDOM(this.canvas,this.parent,!1),T.Canvas.setTouchAction(this.canvas))},contextLost:function(e){e.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(e){if(this.time.update(e),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(1<this._spiraling&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.updateRender(this.time.slowMotion*this.time.desiredFps);else{var t=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=s(p(3*t,this.time.elapsed),0);var a=0;for(this.updatesThisFrame=c(this._deltaTime/t),this.forceSingleUpdate&&(this.updatesThisFrame=p(1,this.updatesThisFrame));this._deltaTime>=t&&(this._deltaTime-=t,this.currentUpdateID=a,this.updateLogic(this.time.desiredFpsMult),a++,!(this.forceSingleUpdate&&1==a));)this.time.refresh();a>this._lastCount?this._spiraling++:a<this._lastCount&&(this._spiraling=0),this._lastCount=a,this.updateRender(this._deltaTime/t)}},updateLogic:function(e){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(e),this.debug.preUpdate()):(this.stepping&&(this.pendingStep=!0),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(e),this.plugins.preUpdate(e),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.plugins.update(),this.stage.postUpdate(),this.plugins.postUpdate()),this.stage.updateTransform()},updateRender:function(e){this.lockRender||(this.state.preRender(e),this.renderType!==T.HEADLESS&&(this.renderer.render(this.stage),this.plugins.render(e),this.state.render(e)),this.plugins.postRender(e))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.debug.destroy&&this.debug.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.plugins.destroy(),this.debug=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.physics=null,this.plugins=null,this.cache=null,this.load=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),T.Canvas.removeFromDOM(this.canvas),PIXI.defaultRenderer=null,T.GAMES[this.id]=null},gamePaused:function(e){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(e),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(e){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(e),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(e){this.onBlur.dispatch(e),this.stage.disableVisibilityChange||this.gamePaused(e)},focusGain:function(e){this.onFocus.dispatch(e),this.stage.disableVisibilityChange||this.gameResumed(e)}},T.Game.prototype.constructor=T.Game,Object.defineProperty(T.Game.prototype,"paused",{get:function(){return this._paused},set:function(e){!0===e?(!1===this._paused&&(this._paused=!0,this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),T.Input=function(e){this.game=e,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=T.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.touchLockCallbacks=[],this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new T.ArraySet,this._localPoint=new T.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},T.Input.MOUSE_OVERRIDES_TOUCH=0,T.Input.TOUCH_OVERRIDES_MOUSE=1,T.Input.MOUSE_TOUCH_COMBINE=2,T.Input.MAX_POINTERS=10,T.Input.prototype={boot:function(){this.mousePointer=new T.Pointer(this.game,0,T.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new T.Mouse(this.game),this.touch=new T.Touch(this.game),this.mspointer=new T.MSPointer(this.game),T.Keyboard&&(this.keyboard=new T.Keyboard(this.game)),T.Gamepad&&(this.gamepad=new T.Gamepad(this.game)),this.onDown=new T.Signal,this.onUp=new T.Signal,this.onTap=new T.Signal,this.onHold=new T.Signal,this.scale=new T.Point(1,1),this.speed=new T.Point,this.position=new T.Point,this._oldPosition=new T.Point,this.circle=new T.Circle(0,0,44),this.activePointer=this.mousePointer,this.hitCanvas=T.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.game.device.mspointer||this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0,this.keyboard&&this.keyboard.start();var e=this;this._onClickTrampoline=function(t){e.onClickTrampoline(t)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.touch.stop(),this.mspointer.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],T.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(e,t){this.customCandidateHandler=e,this.customCandidateHandlerContext=t},addMoveCallback:function(e,t){this.moveCallbacks.push({callback:e,context:t})},addTouchLockCallback:function(e,t,a){void 0===a&&(a=!1),this.touchLockCallbacks.push({callback:e,context:t,onEnd:a})},removeTouchLockCallback:function(e,t){for(var a=this.touchLockCallbacks.length;a--;)if(this.touchLockCallbacks[a].callback===e&&this.touchLockCallbacks[a].context===t)return this.touchLockCallbacks.splice(a,1),!0;return!1},executeTouchLockCallbacks:function(e,t){for(var a=this.touchLockCallbacks.length,o;a--;)o=this.touchLockCallbacks[a],o.onEnd===e&&o.callback.call(o.context,this,t)&&this.touchLockCallbacks.splice(a,1)},deleteMoveCallback:function(e,t){for(var a=this.moveCallbacks.length;a--;)if(this.moveCallbacks[a].callback===e&&this.moveCallbacks[a].context===t)return void this.moveCallbacks.splice(a,1)},addPointer:function(){if(this.pointers.length>=T.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+T.Input.MAX_POINTERS+" pointers reached."),null;var e=this.pointers.length+1,t=new T.Pointer(this.game,e,T.PointerMode.TOUCH);return this.pointers.push(t),this["pointer"+e]=t,t},update:function(){if(this.keyboard&&this.keyboard.update(),0<this.pollRate&&this._pollCounter<this.pollRate)return void this._pollCounter++;this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update(),this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var e=0;e<this.pointers.length;e++)this.pointers[e].update();this._pollCounter=0},reset:function(e){if(this.game.isBooted&&!this.resetLocked){void 0===e&&(e=!1),this.mousePointer.reset(),this.keyboard&&this.keyboard.reset(e),this.gamepad&&this.gamepad.reset();for(var t=0;t<this.pointers.length;t++)this.pointers[t].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor=""),e&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new T.Signal,this.onUp=new T.Signal,this.onTap=new T.Signal,this.onHold=new T.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(e,t){this._oldPosition.setTo(e,t),this.speed.setTo(0,0)},startPointer:function(e){if(0<=this.maxPointers&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(e);if(!this.pointer2.active)return this.pointer2.start(e);for(var t=2,a;t<this.pointers.length;t++)if(a=this.pointers[t],!a.active)return a.start(e);return null},updatePointer:function(e){if(this.pointer1.active&&this.pointer1.identifier===e.identifier)return this.pointer1.move(e);if(this.pointer2.active&&this.pointer2.identifier===e.identifier)return this.pointer2.move(e);for(var t=2,a;t<this.pointers.length;t++)if(a=this.pointers[t],a.active&&a.identifier===e.identifier)return a.move(e);return null},stopPointer:function(e){if(this.pointer1.active&&this.pointer1.identifier===e.identifier)return this.pointer1.stop(e);if(this.pointer2.active&&this.pointer2.identifier===e.identifier)return this.pointer2.stop(e);for(var t=2,a;t<this.pointers.length;t++)if(a=this.pointers[t],a.active&&a.identifier===e.identifier)return a.stop(e);return null},countActivePointers:function(e){void 0===e&&(e=this.pointers.length);for(var t=e,a=0,o;a<this.pointers.length&&0<t;a++)o=this.pointers[a],o.active&&t--;return e-t},getPointer:function(e){void 0===e&&(e=!1);for(var t=0,a;t<this.pointers.length;t++)if(a=this.pointers[t],a.active===e)return a;return null},getPointerFromIdentifier:function(e){for(var t=0,a;t<this.pointers.length;t++)if(a=this.pointers[t],a.identifier===e)return a;return null},getPointerFromId:function(e){for(var t=0,a;t<this.pointers.length;t++)if(a=this.pointers[t],a.pointerId===e)return a;return null},getLocalPosition:function(e,t,a){void 0===a&&(a=new T.Point);var o=e.worldTransform,r=1/(o.a*o.d+o.c*-o.b);return a.setTo(o.d*r*t.x+-o.c*r*t.y+(o.ty*o.c-o.tx*o.d)*r,o.a*r*t.y+-o.b*r*t.x+(-o.ty*o.a+o.tx*o.b)*r)},hitTest:function(e,t,a){if(!e.worldVisible)return!1;if(this.getLocalPosition(e,t,this._localPoint),a.copyFrom(this._localPoint),e.hitArea&&e.hitArea.contains)return e.hitArea.contains(this._localPoint.x,this._localPoint.y);if(T.Creature&&e instanceof T.Creature){var o=f(e.width),r=f(e.height),n=e.x-o*e.anchorX;if(this.game.camera.x+t.x>=n&&this.game.camera.x+t.x<n+o){var s=e.y-r*e.anchorY;if(this.game.camera.y+t.y>=s&&this.game.camera.y+t.y<s+r)return!0}}else if(e instanceof T.TileSprite){var o=e.width,r=e.height,n=-o*e.anchor.x;if(this._localPoint.x>=n&&this._localPoint.x<n+o){var s=-r*e.anchor.y;if(this._localPoint.y>=s&&this._localPoint.y<s+r)return!0}}else if(e instanceof PIXI.Sprite){var o=e.texture.frame.width/e.texture.baseTexture.resolution,r=e.texture.frame.height/e.texture.baseTexture.resolution,n=-o*e.anchor.x;if(this._localPoint.x>=n&&this._localPoint.x<n+o){var s=-r*e.anchor.y;if(this._localPoint.y>=s&&this._localPoint.y<s+r)return!0}}else if(e instanceof T.Graphics)for(var d=0,i;d<e.graphicsData.length;d++)if((i=e.graphicsData[d],!!i.fill)&&i.shape&&i.shape.contains(this._localPoint.x,this._localPoint.y))return!0;for(var d=0;d<e.children.length;d++)if(this.hitTest(e.children[d],t,a))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()}},T.Input.prototype.constructor=T.Input,Object.defineProperty(T.Input.prototype,"x",{get:function(){return this._x},set:function(e){this._x=c(e)}}),Object.defineProperty(T.Input.prototype,"y",{get:function(){return this._y},set:function(e){this._y=c(e)}}),Object.defineProperty(T.Input.prototype,"pollLocked",{get:function(){return 0<this.pollRate&&this._pollCounter<this.pollRate}}),Object.defineProperty(T.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(T.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(T.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(T.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),T.Mouse=function(e){this.game=e,this.input=e.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.mouseWheelCallback=null,this.capture=!1,this.button=-1,this.wheelDelta=0,this.enabled=!0,this.locked=!1,this.stopOnGameOut=!1,this.pointerLock=new T.Signal,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null,this._onMouseWheel=null,this._wheelEvent=null},T.Mouse.NO_BUTTON=-1,T.Mouse.LEFT_BUTTON=0,T.Mouse.MIDDLE_BUTTON=1,T.Mouse.RIGHT_BUTTON=2,T.Mouse.BACK_BUTTON=3,T.Mouse.FORWARD_BUTTON=4,T.Mouse.WHEEL_UP=1,T.Mouse.WHEEL_DOWN=-1,T.Mouse.prototype={start:function(){if(!(this.game.device.android&&!1===this.game.device.chrome)&&null===this._onMouseDown){var t=this;this._onMouseDown=function(e){return t.onMouseDown(e)},this._onMouseMove=function(e){return t.onMouseMove(e)},this._onMouseUp=function(e){return t.onMouseUp(e)},this._onMouseUpGlobal=function(e){return t.onMouseUpGlobal(e)},this._onMouseOutGlobal=function(e){return t.onMouseOutGlobal(e)},this._onMouseOut=function(e){return t.onMouseOut(e)},this._onMouseOver=function(e){return t.onMouseOver(e)},this._onMouseWheel=function(e){return t.onMouseWheel(e)};var a=this.game.canvas;a.addEventListener("mousedown",this._onMouseDown,!0),a.addEventListener("mousemove",this._onMouseMove,!0),a.addEventListener("mouseup",this._onMouseUp,!0),this.game.device.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),a.addEventListener("mouseover",this._onMouseOver,!0),a.addEventListener("mouseout",this._onMouseOut,!0));var o=this.game.device.wheelEvent;o&&(a.addEventListener(o,this._onMouseWheel,!0),"mousewheel"===o?this._wheelEvent=new e(-1/40,1):"DOMMouseScroll"===o&&(this._wheelEvent=new e(1,1)))}},onMouseDown:function(e){this.event=e,this.capture&&e.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=0,this.input.mousePointer.start(e))},onMouseMove:function(e){this.event=e,this.capture&&e.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=0,this.input.mousePointer.move(e))},onMouseUp:function(e){this.event=e,this.capture&&e.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=0,this.input.mousePointer.stop(e))},onMouseUpGlobal:function(e){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,e),e.identifier=0,this.input.mousePointer.stop(e))},onMouseOutGlobal:function(e){this.event=e,this.capture&&e.preventDefault(),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(e),this.input.mousePointer.resetButtons())},onMouseOut:function(e){this.event=e,this.capture&&e.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(!this.stopOnGameOut||(e.identifier=0,this.input.mousePointer.stop(e)))},onMouseOver:function(e){this.event=e,this.capture&&e.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,e)},onMouseWheel:function(e){this._wheelEvent&&(e=this._wheelEvent.bindEvent(e)),this.event=e,this.capture&&e.preventDefault(),this.wheelDelta=T.Math.clamp(-e.deltaY,-1,1),this.mouseWheelCallback&&this.mouseWheelCallback.call(this.callbackContext,e)},requestPointerLock:function(){if(this.game.device.pointerLock){var e=this.game.canvas;e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock();var t=this;this._pointerLockChange=function(e){return t.pointerLockChange(e)},document.addEventListener("pointerlockchange",this._pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},pointerLockChange:function(e){var t=this.game.canvas;document.pointerLockElement===t||document.mozPointerLockElement===t||document.webkitPointerLockElement===t?(this.locked=!0,this.pointerLock.dispatch(!0,e)):(this.locked=!1,this.pointerLock.dispatch(!1,e))},releasePointerLock:function(){document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock(),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)},stop:function(){var e=this.game.canvas;e.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("mousemove",this._onMouseMove,!0),e.removeEventListener("mouseup",this._onMouseUp,!0),e.removeEventListener("mouseover",this._onMouseOver,!0),e.removeEventListener("mouseout",this._onMouseOut,!0);var t=this.game.device.wheelEvent;t&&e.removeEventListener(t,this._onMouseWheel,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},T.Mouse.prototype.constructor=T.Mouse,e.prototype={},e.prototype.constructor=e,e.prototype.bindEvent=function(t){if(!e._stubsGenerated&&t){var a=function(e){return function(){var t=this.originalEvent[e];return"function"==typeof t?t.bind(this.originalEvent):t}};for(var o in t)o in e.prototype||Object.defineProperty(e.prototype,o,{get:a(o)});e._stubsGenerated=!0}return this.originalEvent=t,this},Object.defineProperties(e.prototype,{type:{value:"wheel"},deltaMode:{get:function(){return this._deltaMode}},deltaY:{get:function(){return this._scaleFactor*(this.originalEvent.wheelDelta||this.originalEvent.detail)||0}},deltaX:{get:function(){return this._scaleFactor*this.originalEvent.wheelDeltaX||0}},deltaZ:{value:0}}),T.MSPointer=function(e){this.game=e,this.input=e.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.capture=!0,this.button=-1,this.event=null,this.enabled=!0,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null},T.MSPointer.prototype={start:function(){if(null===this._onMSPointerDown){var e=this;if(this.game.device.mspointer){this._onMSPointerDown=function(t){return e.onPointerDown(t)},this._onMSPointerMove=function(t){return e.onPointerMove(t)},this._onMSPointerUp=function(t){return e.onPointerUp(t)},this._onMSPointerUpGlobal=function(t){return e.onPointerUpGlobal(t)},this._onMSPointerOut=function(t){return e.onPointerOut(t)},this._onMSPointerOver=function(t){return e.onPointerOver(t)};var t=this.game.canvas;t.addEventListener("MSPointerDown",this._onMSPointerDown,!1),t.addEventListener("MSPointerMove",this._onMSPointerMove,!1),t.addEventListener("MSPointerUp",this._onMSPointerUp,!1),t.addEventListener("pointerdown",this._onMSPointerDown,!1),t.addEventListener("pointermove",this._onMSPointerMove,!1),t.addEventListener("pointerup",this._onMSPointerUp,!1),t.style["-ms-content-zooming"]="none",t.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.addEventListener("MSPointerOver",this._onMSPointerOver,!0),t.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.addEventListener("pointerover",this._onMSPointerOver,!0),t.addEventListener("pointerout",this._onMSPointerOut,!0))}}},onPointerDown:function(e){this.game.input.executeTouchLockCallbacks(!1,e),this.event=e,this.capture&&e.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=e.pointerId,"mouse"===e.pointerType||4===e.pointerType?this.input.mousePointer.start(e):this.input.startPointer(e))},onPointerMove:function(e){this.event=e,this.capture&&e.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=e.pointerId,"mouse"===e.pointerType||4===e.pointerType?this.input.mousePointer.move(e):this.input.updatePointer(e))},onPointerUp:function(e){this.game.input.executeTouchLockCallbacks(!0,e),this.event=e,this.capture&&e.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,e),this.input.enabled&&this.enabled&&(e.identifier=e.pointerId,"mouse"===e.pointerType||4===e.pointerType?this.input.mousePointer.stop(e):this.input.stopPointer(e))},onPointerUpGlobal:function(e){if(("mouse"===e.pointerType||4===e.pointerType)&&!this.input.mousePointer.withinGame)this.onPointerUp(e);else{var t=this.input.getPointerFromIdentifier(e.identifier);t&&t.withinGame&&this.onPointerUp(e)}},onPointerOut:function(e){if(this.event=e,this.capture&&e.preventDefault(),"mouse"===e.pointerType||4===e.pointerType)this.input.mousePointer.withinGame=!1;else{var t=this.input.getPointerFromIdentifier(e.identifier);t&&(t.withinGame=!1)}this.input.mouse.mouseOutCallback&&this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext,e),this.input.enabled&&this.enabled&&(!this.input.mouse.stopOnGameOut||(e.identifier=0,t?t.stop(e):this.input.mousePointer.stop(e)))},onPointerOver:function(e){if(this.event=e,this.capture&&e.preventDefault(),"mouse"===e.pointerType||4===e.pointerType)this.input.mousePointer.withinGame=!0;else{var t=this.input.getPointerFromIdentifier(e.identifier);t&&(t.withinGame=!0)}this.input.mouse.mouseOverCallback&&this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext,e)},stop:function(){var e=this.game.canvas;e.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),e.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),e.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),e.removeEventListener("pointerdown",this._onMSPointerDown,!1),e.removeEventListener("pointermove",this._onMSPointerMove,!1),e.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),e.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.removeEventListener("pointerover",this._onMSPointerOver,!0),e.removeEventListener("pointerout",this._onMSPointerOut,!0)}},T.MSPointer.prototype.constructor=T.MSPointer,T.DeviceButton=function(e,t){this.parent=e,this.game=e.game,this.event=null,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1,this.value=0,this.buttonCode=t,this.onDown=new T.Signal,this.onUp=new T.Signal,this.onFloat=new T.Signal},T.DeviceButton.prototype={start:function(e,t){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=e,this.value=t,e&&(this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.ctrlKey=e.ctrlKey),this.onDown.dispatch(this,t))},stop:function(e,t){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=e,this.value=t,e&&(this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.ctrlKey=e.ctrlKey),this.onUp.dispatch(this,t))},startStop:function(e,t,a){e?this.start(t,a):this.stop(t,a)},padFloat:function(e){this.isDown=!1,this.isUp=!1,this.value=e,this.onFloat.dispatch(this,e)},justPressed:function(e){return e=e||250,this.isDown&&this.timeDown+e>this.game.time.time},justReleased:function(e){return e=e||250,this.isUp&&this.timeUp+e>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},T.DeviceButton.prototype.constructor=T.DeviceButton,Object.defineProperty(T.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),T.Pointer=function(e,t,a){this.game=e,this.id=t,this.type=T.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=a||T.PointerMode.CURSOR|T.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new T.DeviceButton(this,T.Pointer.LEFT_BUTTON),this.middleButton=new T.DeviceButton(this,T.Pointer.MIDDLE_BUTTON),this.rightButton=new T.DeviceButton(this,T.Pointer.RIGHT_BUTTON),this.backButton=new T.DeviceButton(this,T.Pointer.BACK_BUTTON),this.forwardButton=new T.DeviceButton(this,T.Pointer.FORWARD_BUTTON),this.eraserButton=new T.DeviceButton(this,T.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===t,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=g,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new T.Point,this.positionDown=new T.Point,this.positionUp=new T.Point,this.circle=new T.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},T.Pointer.NO_BUTTON=0,T.Pointer.LEFT_BUTTON=1,T.Pointer.RIGHT_BUTTON=2,T.Pointer.MIDDLE_BUTTON=4,T.Pointer.BACK_BUTTON=8,T.Pointer.FORWARD_BUTTON=16,T.Pointer.ERASER_BUTTON=32,T.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(e,t){e===T.Mouse.LEFT_BUTTON&&this.leftButton.start(t),e===T.Mouse.RIGHT_BUTTON&&this.rightButton.start(t),e===T.Mouse.MIDDLE_BUTTON&&this.middleButton.start(t),e===T.Mouse.BACK_BUTTON&&this.backButton.start(t),e===T.Mouse.FORWARD_BUTTON&&this.forwardButton.start(t)},processButtonsUp:function(e,t){e===T.Mouse.LEFT_BUTTON&&this.leftButton.stop(t),e===T.Mouse.RIGHT_BUTTON&&this.rightButton.stop(t),e===T.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(t),e===T.Mouse.BACK_BUTTON&&this.backButton.stop(t),e===T.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(t)},processButtonsUpDown:function(e,t){var a="down"===t.type.toLowerCase().substr(-4),o="move"===t.type.toLowerCase().substr(-4);void 0===e?void 0===t.button?a?t.ctrlKey?this.rightButton.start(t):this.leftButton.start(t):(this.leftButton.stop(t),this.rightButton.stop(t)):a&&t.ctrlKey&&0===t.button?this.rightButton.start(t):a?this.processButtonsDown(t.button,t):!o&&this.processButtonsUp(t.button,t):(a&&1===e&&t.ctrlKey&&(e=2),this.leftButton.startStop(T.Pointer.LEFT_BUTTON&e,t),this.rightButton.startStop(T.Pointer.RIGHT_BUTTON&e,t),this.middleButton.startStop(T.Pointer.MIDDLE_BUTTON&e,t),this.backButton.startStop(T.Pointer.BACK_BUTTON&e,t),this.forwardButton.startStop(T.Pointer.FORWARD_BUTTON&e,t),this.eraserButton.startStop(T.Pointer.ERASER_BUTTON&e,t))},updateButtons:function(e){this.button=e.button,this.processButtonsUpDown(e.buttons,e),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(e){var t=this.game.input;return e.pointerId&&(this.pointerId=e.pointerId),this.identifier=e.identifier,this.target=e.target,this.isMouse?this.updateButtons(e):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(e,!0),this.positionDown.setTo(this.x,this.y),(t.multiInputOverride===T.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===T.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===T.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&(t.x=this.x,t.y=this.y,t.position.setTo(this.x,this.y),t.onDown.dispatch(this,e),t.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var e=this.game.input;this.active&&(this.dirty&&(0<e.interactiveItems.total&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=e.holdRate&&((e.multiInputOverride===T.Input.MOUSE_OVERRIDES_TOUCH||e.multiInputOverride===T.Input.MOUSE_TOUCH_COMBINE||e.multiInputOverride===T.Input.TOUCH_OVERRIDES_MOUSE&&0===e.totalActivePointers)&&e.onHold.dispatch(this),this._holdSent=!0),e.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+e.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>e.recordLimit&&this._history.shift()))},move:function(e,t){var a=this.game.input;if(!a.pollLocked){void 0===t&&(t=!1),void 0!==e.button&&(this.button=e.button),this.isMouse&&this.updateButtons(e),this.clientX=e.clientX,this.clientY=e.clientY,this.pageX=e.pageX,this.pageY=e.pageY,this.screenX=e.screenX,this.screenY=e.screenY,this.isMouse&&a.mouse.locked&&!t&&(this.rawMovementX=e.movementX||e.mozMovementX||e.webkitMovementX||0,this.rawMovementY=e.movementY||e.mozMovementY||e.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*a.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*a.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(a.multiInputOverride===T.Input.MOUSE_OVERRIDES_TOUCH||a.multiInputOverride===T.Input.MOUSE_TOUCH_COMBINE||a.multiInputOverride===T.Input.TOUCH_OVERRIDES_MOUSE&&0===a.totalActivePointers)&&(a.activePointer=this,a.x=this.x,a.y=this.y,a.position.setTo(a.x,a.y),a.circle.x=a.x,a.circle.y=a.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var o=a.moveCallbacks.length;o--;)a.moveCallbacks[o].callback.call(a.moveCallbacks[o].context,this,this.x,this.y,t);return null!==this.targetObject&&(!this.game.paused||this.targetObject.noPause)&&!0===this.targetObject.isDragged?!1===this.targetObject.update(this)&&(this.targetObject=null):0<a.interactiveItems.total&&this.processInteractiveObjects(t),this}},processInteractiveObjects:function(e){var t=0,a=-1,o=null,r=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];r;)r.checked=!1,r.validForInput(a,t,!1)&&(!this.game.paused||r.sprite.noPause)&&(r.checked=!0,(e&&r.checkPointerDown(this,!0)||!e&&r.checkPointerOver(this,!0))&&(t=r.sprite.renderOrderID,a=r.priorityID,o=r,this.interactiveCandidates.push(r))),r=this.game.input.interactiveItems.next;for(r=this.game.input.interactiveItems.first;r;)!r.checked&&r.validForInput(a,t,!0)&&(e&&r.checkPointerDown(this,!1)||!e&&r.checkPointerOver(this,!1))&&(t=r.sprite.renderOrderID,a=r.priorityID,o=r,this.interactiveCandidates.push(r)),r=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(o=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,o)),this.swapTarget(o,!1),null!==this.targetObject},swapTarget:function(e,t){void 0===t&&(t=!1),null===e?this.targetObject&&(this.targetObject._pointerOutHandler(this,t),this.targetObject=null):null===this.targetObject?(this.targetObject=e,e._pointerOverHandler(this,t)):this.targetObject===e?!1===e.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,t),this.targetObject=e,this.targetObject._pointerOverHandler(this,t))},leave:function(e){this.withinGame=!1,this.move(e,!1)},stop:function(e){var t=this.game.input;return this._stateReset&&this.withinGame?void e.preventDefault():(this.timeUp=this.game.time.time,(t.multiInputOverride===T.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===T.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===T.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&(t.onUp.dispatch(this,e),0<=this.duration&&this.duration<=t.tapRate&&(this.timeUp-this.previousTapTime<t.doubleTapRate?t.onTap.dispatch(this,!0):t.onTap.dispatch(this,!1),this.previousTapTime=this.timeUp)),this.isMouse?this.updateButtons(e):(this.isDown=!1,this.isUp=!0),0<this.id&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(e.pageX,e.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&t.currentPointers--,t.interactiveItems.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this)},justPressed:function(e){return e=e||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+e>this.game.time.time},justReleased:function(e){return e=e||this.game.input.justReleasedRate,this.isUp&&this.timeUp+e>this.game.time.time},addClickTrampoline:function(e,t,a,o){if(this.isDown){for(var r=this._clickTrampolines=this._clickTrampolines||[],n=0;n<r.length;n++)if(r[n].name===e){r.splice(n,1);break}r.push({name:e,targetObject:this.targetObject,callback:t,callbackContext:a,callbackArgs:o})}},processClickTrampolines:function(){var e=this._clickTrampolines;if(e){for(var t=0,a;t<e.length;t++)a=e[t],a.targetObject===this._trampolineTargetObject&&a.callback.apply(a.callbackContext,a.callbackArgs);this._clickTrampolines=null,this._trampolineTargetObject=null}},reset:function(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},resetMovement:function(){this.movementX=0,this.movementY=0}},T.Pointer.prototype.constructor=T.Pointer,Object.defineProperty(T.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(T.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(T.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),T.PointerMode={CURSOR:1,CONTACT:2},T.Touch=function(e){this.game=e,this.enabled=!0,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},T.Touch.prototype={start:function(){if(null===this._onTouchStart){var e=this;this.game.device.touch&&(this._onTouchStart=function(t){return e.onTouchStart(t)},this._onTouchMove=function(t){return e.onTouchMove(t)},this._onTouchEnd=function(t){return e.onTouchEnd(t)},this._onTouchEnter=function(t){return e.onTouchEnter(t)},this._onTouchLeave=function(t){return e.onTouchLeave(t)},this._onTouchCancel=function(t){return e.onTouchCancel(t)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),!this.game.device.cocoonJS&&(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1))),this.addTouchLockCallback=this.game.input.addTouchLockCallback.bind(this.game.input),this.removeTouchLockCallback=this.game.input.removeTouchLockCallback.bind(this.game.input)}},consumeDocumentTouches:function(){this._documentTouchMove=function(e){e.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(e){if(this.game.input.executeTouchLockCallbacks(!1,e),this.event=e,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,e),this.preventDefault&&e.preventDefault();for(var t=0;t<e.changedTouches.length;t++)this.game.input.startPointer(e.changedTouches[t])}},onTouchCancel:function(e){if(this.event=e,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,e),this.game.input.enabled&&this.enabled){this.preventDefault&&e.preventDefault();for(var t=0;t<e.changedTouches.length;t++)this.game.input.stopPointer(e.changedTouches[t])}},onTouchEnter:function(e){this.event=e,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,e),this.game.input.enabled&&this.enabled&&(!this.preventDefault||e.preventDefault())},onTouchLeave:function(e){this.event=e,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,e),this.preventDefault&&e.preventDefault()},onTouchMove:function(e){this.event=e,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,e),this.preventDefault&&e.preventDefault();for(var t=0;t<e.changedTouches.length;t++)this.game.input.updatePointer(e.changedTouches[t])},onTouchEnd:function(e){this.game.input.executeTouchLockCallbacks(!0,e),this.event=e,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,e),this.preventDefault&&e.preventDefault();for(var t=0;t<e.changedTouches.length;t++)this.game.input.stopPointer(e.changedTouches[t])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel))}},T.Touch.prototype.constructor=T.Touch,T.InputHandler=function(e){this.sprite=e,this.game=e.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new T.Point,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new T.Point,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new T.Point,this.snapPoint=new T.Point,this._dragPoint=new T.Point,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new T.Point,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})},T.InputHandler.prototype={start:function(e,t){if(e=e||0,void 0===t&&(t=!1),!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=t,this.priorityID=e;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new T.Point,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1;for(var e=0;10>e;e++)this._pointerData[e]={id:e,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){!1===this.enabled||(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(e,t,a){return void 0===a&&(a=!0),!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput?!1:!a&&(this.pixelPerfectClick||this.pixelPerfectOver)?!1:this.priorityID>e||this.priorityID===e&&this.sprite.renderOrderID>t},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(e){return e=e||0,this._pointerData[e].x},pointerY:function(e){return e=e||0,this._pointerData[e].y},pointerDown:function(e){return e=e||0,this._pointerData[e].isDown},pointerUp:function(e){return e=e||0,this._pointerData[e].isUp},pointerTimeDown:function(e){return e=e||0,this._pointerData[e].timeDown},pointerTimeUp:function(e){return e=e||0,this._pointerData[e].timeUp},pointerOver:function(e){if(!this.enabled)return!1;if(void 0===e){for(var t=0;10>t;t++)if(this._pointerData[t].isOver)return!0;return!1}return this._pointerData[e].isOver},pointerOut:function(e){if(!this.enabled)return!1;if(void 0===e){for(var t=0;10>t;t++)if(this._pointerData[t].isOut)return!0;}else return this._pointerData[e].isOut},pointerTimeOver:function(e){return e=e||0,this._pointerData[e].timeOver},pointerTimeOut:function(e){return e=e||0,this._pointerData[e].timeOut},pointerDragged:function(e){return e=e||0,this._pointerData[e].isDragged},checkPointerDown:function(e,t){return e.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y&&!!this.game.input.hitTest(this.sprite,e,this._tempPoint)&&(void 0===t&&(t=!1),!t&&this.pixelPerfectClick?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0)},checkPointerOver:function(e,t){return this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y&&!!this.game.input.hitTest(this.sprite,e,this._tempPoint)&&(void 0===t&&(t=!1),!t&&this.pixelPerfectOver?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0)},checkPixel:function(e,t,a){if(this.sprite.texture.baseTexture.source){if(null===e&&null===t){this.game.input.getLocalPosition(this.sprite,a,this._tempPoint);var e=this._tempPoint.x,t=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(e-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(t-=-this.sprite.texture.frame.height*this.sprite.anchor.y),e+=this.sprite.texture.frame.x,t+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(e-=this.sprite.texture.trim.x,t-=this.sprite.texture.trim.y,e<this.sprite.texture.crop.x||e>this.sprite.texture.crop.right||t<this.sprite.texture.crop.y||t>this.sprite.texture.crop.bottom))return this._dx=e,this._dy=t,!1;this._dx=e,this._dy=t,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,e,t,1,1,0,0,1,1);var o=this.game.input.hitContext.getImageData(0,0,1,1);if(o.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(e){return null===this.sprite||void 0===this.sprite.parent?void 0:this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=T.Math.distance(e.x,e.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(e),!0):this.draggable&&this._draggedPointerID===e.id?this.updateDrag(e,!1):this._pointerData[e.id].isOver?this.checkPointerOver(e)?(this._pointerData[e.id].x=e.x-this.sprite.x,this._pointerData[e.id].y=e.y-this.sprite.y,!0):(this._pointerOutHandler(e),!1):void 0:(this._pointerOutHandler(e),!1)},_pointerOverHandler:function(e,t){if(null!==this.sprite){var a=this._pointerData[e.id];if(!1===a.isOver||e.dirty){var o=!1===a.isOver;a.isOver=!0,a.isOut=!1,a.timeOver=this.game.time.time,a.x=e.x-this.sprite.x,a.y=e.y-this.sprite.y,this.useHandCursor&&!1===a.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!t&&o&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,e),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,e)}}},_pointerOutHandler:function(e,t){if(null!==this.sprite){var a=this._pointerData[e.id];a.isOver=!1,a.isOut=!0,a.timeOut=this.game.time.time,this.useHandCursor&&!1===a.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),!t&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,e),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,e))}},_touchedHandler:function(e){if(null!==this.sprite){var t=this._pointerData[e.id];if(!t.isDown&&t.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,e))return;if(t.isDown=!0,t.isUp=!1,t.timeDown=this.game.time.time,this.downPoint.set(e.x,e.y),e.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,e),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,e),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(e):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,0<this.dragTimeThreshold?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,e)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(e){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(e)},_releasedHandler:function(e){if(null!==this.sprite){var t=this._pointerData[e.id];if(t.isDown&&e.isUp){t.isDown=!1,t.isUp=!0,t.timeUp=this.game.time.time,t.downDuration=t.timeUp-t.timeDown;var a=this.checkPointerOver(e);this.sprite&&this.sprite.events&&((!this.dragStopBlocksInputUp||this.dragStopBlocksInputUp&&!(this.draggable&&this.isDragged&&this._draggedPointerID===e.id))&&this.sprite.events.onInputUp$dispatch(this.sprite,e,a),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,e,a),a&&(a=this.checkPointerOver(e))),t.isOver=a,!a&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),e.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===e.id&&this.stopDrag(e)}}},updateDrag:function(e,t){if(void 0===t&&(t=!1),e.isUp)return this.stopDrag(e),!1;var a=this.globalToLocal(e),o=a.x+this._dragPoint.x+this.dragOffset.x,r=a.y+this._dragPoint.y+this.dragOffset.y;if(this.sprite.fixedToCamera)this.allowHorizontalDrag&&(this.sprite.cameraOffset.x=o-this.game.camera.x),this.allowVerticalDrag&&(this.sprite.cameraOffset.y=r-this.game.camera.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.cameraOffset.x=n((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=n((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.cameraOffset.x,this.sprite.cameraOffset.y));else{var i=this.game.camera.x-this._pointerData[e.id].camX,s=this.game.camera.y-this._pointerData[e.id].camY;this.allowHorizontalDrag&&(this.sprite.x=o+i),this.allowVerticalDrag&&(this.sprite.y=r+s),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=n((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=n((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y))}return this.sprite.events.onDragUpdate.dispatch(this.sprite,e,o,r,this.snapPoint,t),!0},justOver:function(e,t){return e=e||0,t=t||500,this._pointerData[e].isOver&&this.overDuration(e)<t},justOut:function(e,t){return e=e||0,t=t||500,this._pointerData[e].isOut&&this.game.time.time-this._pointerData[e].timeOut<t},justPressed:function(e,t){return e=e||0,t=t||500,this._pointerData[e].isDown&&this.downDuration(e)<t},justReleased:function(e,t){return e=e||0,t=t||500,this._pointerData[e].isUp&&this.game.time.time-this._pointerData[e].timeUp<t},overDuration:function(e){return e=e||0,this._pointerData[e].isOver?this.game.time.time-this._pointerData[e].timeOver:-1},downDuration:function(e){return e=e||0,this._pointerData[e].isDown?this.game.time.time-this._pointerData[e].timeDown:-1},enableDrag:function(e,t,a,o,r,n){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===a&&(a=!1),void 0===o&&(o=255),void 0===r&&(r=null),void 0===n&&(n=null),this._dragPoint=new T.Point,this.draggable=!0,this.bringToTop=t,this.dragOffset=new T.Point,this.dragFromCenter=e,this.pixelPerfectClick=a,this.pixelPerfectAlpha=o,r&&(this.boundsRect=r),n&&(this.boundsSprite=n)},disableDrag:function(){if(this._pointerData)for(var e=0;10>e;e++)this._pointerData[e].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1},startDrag:function(e){var t=this.sprite.x,a=this.sprite.y,o=this.globalToLocal(e);if(this.isDragged=!0,this._draggedPointerID=e.id,this._pointerData[e.id].camX=this.game.camera.x,this._pointerData[e.id].camY=this.game.camera.y,this._pointerData[e.id].isDragged=!0,this.sprite.fixedToCamera){if(this.dragFromCenter){var r=this.sprite.getBounds(),n=this.globalToLocal(new T.Point(r.centerX,r.centerY));this.sprite.cameraOffset.x=o.x+(this.sprite.cameraOffset.x-n.x),this.sprite.cameraOffset.y=o.y+(this.sprite.cameraOffset.y-n.y)}this._dragPoint.setTo(this.sprite.cameraOffset.x-e.x,this.sprite.cameraOffset.y-e.y)}else{if(this.dragFromCenter){var r=this.sprite.getBounds(),n=this.globalToLocal(new T.Point(r.centerX,r.centerY));this.sprite.x=o.x+(this.sprite.x-n.x),this.sprite.y=o.y+(this.sprite.y-n.y)}this._dragPoint.setTo(this.sprite.x-o.x,this.sprite.y-o.y)}this.updateDrag(e,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(t,a),this.sprite.events.onDragStart$dispatch(this.sprite,e,t,a),this._pendingDrag=!1},globalToLocalX:function(e){return this.scaleLayer&&(e-=this.game.scale.grid.boundsFluid.x,e*=this.game.scale.grid.scaleFluidInversed.x),e},globalToLocalY:function(e){return this.scaleLayer&&(e-=this.game.scale.grid.boundsFluid.y,e*=this.game.scale.grid.scaleFluidInversed.y),e},globalToLocal:function(e){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:e.x,y:e.y}):e},stopDrag:function(e){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[e.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=n((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=n((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=n((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=n((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY)),this.sprite.events.onDragStop$dispatch(this.sprite,e),!1===this.checkPointerOver(e)&&this._pointerOutHandler(e)},setDragLock:function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this.allowHorizontalDrag=e,this.allowVerticalDrag=t},enableSnap:function(e,t,a,o,r,n){void 0===a&&(a=!0),void 0===o&&(o=!1),void 0===r&&(r=0),void 0===n&&(n=0),this.snapX=e,this.snapY=t,this.snapOffsetX=r,this.snapOffsetY=n,this.snapOnDrag=a,this.snapOnRelease=o},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},T.InputHandler.prototype.constructor=T.InputHandler,T.Gamepad=function(e){this.game=e,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new T.SinglePad(e,this),new T.SinglePad(e,this),new T.SinglePad(e,this),new T.SinglePad(e,this)]},T.Gamepad.prototype={addCallbacks:function(e,t){"undefined"!=typeof t&&(this.onConnectCallback="function"==typeof t.onConnect?t.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof t.onDisconnect?t.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof t.onDown?t.onDown:this.onDownCallback,this.onUpCallback="function"==typeof t.onUp?t.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof t.onAxis?t.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof t.onFloat?t.onFloat:this.onFloatCallback,this.callbackContext=e)},start:function(){if(!this._active){this._active=!0;var e=this;this._onGamepadConnected=function(t){return e.onGamepadConnected(t)},this._onGamepadDisconnected=function(t){return e.onGamepadDisconnected(t)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(e){var t=e.gamepad;this._rawPads.push(t),this._gamepads[t.index].connect(t)},onGamepadDisconnected:function(e){var t=e.gamepad;for(var a in this._rawPads)this._rawPads[a].index===t.index&&this._rawPads.splice(a,1);this._gamepads[t.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)var e=navigator.getGamepads();else if(navigator.webkitGetGamepads)var e=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var e=navigator.webkitGamepads();if(e){this._rawPads=[];for(var t=!1,a=0;a<e.length&&(typeof e[a]!==this._prevRawGamepadTypes[a]&&(t=!0,this._prevRawGamepadTypes[a]=typeof e[a]),e[a]&&this._rawPads.push(e[a]),3!==a);a++);for(var o=0;o<this._gamepads.length;o++)this._gamepads[o]._rawPad=this._rawPads[o];if(t){for(var r={rawIndices:{},padIndices:{}},n=0,i;n<this._gamepads.length;n++)if(i=this._gamepads[n],i.connected)for(var s=0;s<this._rawPads.length;s++)this._rawPads[s].index===i.index&&(r.rawIndices[i.index]=!0,r.padIndices[n]=!0);for(var d=0;d<this._gamepads.length;d++)if(i=this._gamepads[d],!r.padIndices[d]){1>this._rawPads.length&&i.disconnect();for(var l=0,p;l<this._rawPads.length&&!r.padIndices[d];l++)if(p=this._rawPads[l],!p)i.disconnect();else if(r.rawIndices[p.index]){i.disconnect();continue}else i.connect(p),r.rawIndices[p.index]=!0,r.padIndices[d]=!0}}}}},setDeadZones:function(e){for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].deadZone=e},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var e=0;e<this._gamepads.length;e++)this._gamepads[e].reset()},justPressed:function(e,t){for(var a=0;a<this._gamepads.length;a++)if(!0===this._gamepads[a].justPressed(e,t))return!0;return!1},justReleased:function(e,t){for(var a=0;a<this._gamepads.length;a++)if(!0===this._gamepads[a].justReleased(e,t))return!0;return!1},isDown:function(e){for(var t=0;t<this._gamepads.length;t++)if(!0===this._gamepads[t].isDown(e))return!0;return!1},destroy:function(){this.stop();for(var e=0;e<this._gamepads.length;e++)this._gamepads[e].destroy()}},T.Gamepad.prototype.constructor=T.Gamepad,Object.defineProperty(T.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(T.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(T.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(T.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(T.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(T.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(T.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),T.Gamepad.BUTTON_0=0,T.Gamepad.BUTTON_1=1,T.Gamepad.BUTTON_2=2,T.Gamepad.BUTTON_3=3,T.Gamepad.BUTTON_4=4,T.Gamepad.BUTTON_5=5,T.Gamepad.BUTTON_6=6,T.Gamepad.BUTTON_7=7,T.Gamepad.BUTTON_8=8,T.Gamepad.BUTTON_9=9,T.Gamepad.BUTTON_10=10,T.Gamepad.BUTTON_11=11,T.Gamepad.BUTTON_12=12,T.Gamepad.BUTTON_13=13,T.Gamepad.BUTTON_14=14,T.Gamepad.BUTTON_15=15,T.Gamepad.AXIS_0=0,T.Gamepad.AXIS_1=1,T.Gamepad.AXIS_2=2,T.Gamepad.AXIS_3=3,T.Gamepad.AXIS_4=4,T.Gamepad.AXIS_5=5,T.Gamepad.AXIS_6=6,T.Gamepad.AXIS_7=7,T.Gamepad.AXIS_8=8,T.Gamepad.AXIS_9=9,T.Gamepad.XBOX360_A=0,T.Gamepad.XBOX360_B=1,T.Gamepad.XBOX360_X=2,T.Gamepad.XBOX360_Y=3,T.Gamepad.XBOX360_LEFT_BUMPER=4,T.Gamepad.XBOX360_RIGHT_BUMPER=5,T.Gamepad.XBOX360_LEFT_TRIGGER=6,T.Gamepad.XBOX360_RIGHT_TRIGGER=7,T.Gamepad.XBOX360_BACK=8,T.Gamepad.XBOX360_START=9,T.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,T.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,T.Gamepad.XBOX360_DPAD_LEFT=14,T.Gamepad.XBOX360_DPAD_RIGHT=15,T.Gamepad.XBOX360_DPAD_UP=12,T.Gamepad.XBOX360_DPAD_DOWN=13,T.Gamepad.XBOX360_STICK_LEFT_X=0,T.Gamepad.XBOX360_STICK_LEFT_Y=1,T.Gamepad.XBOX360_STICK_RIGHT_X=2,T.Gamepad.XBOX360_STICK_RIGHT_Y=3,T.Gamepad.PS3XC_X=0,T.Gamepad.PS3XC_CIRCLE=1,T.Gamepad.PS3XC_SQUARE=2,T.Gamepad.PS3XC_TRIANGLE=3,T.Gamepad.PS3XC_L1=4,T.Gamepad.PS3XC_R1=5,T.Gamepad.PS3XC_L2=6,T.Gamepad.PS3XC_R2=7,T.Gamepad.PS3XC_SELECT=8,T.Gamepad.PS3XC_START=9,T.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,T.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,T.Gamepad.PS3XC_DPAD_UP=12,T.Gamepad.PS3XC_DPAD_DOWN=13,T.Gamepad.PS3XC_DPAD_LEFT=14,T.Gamepad.PS3XC_DPAD_RIGHT=15,T.Gamepad.PS3XC_STICK_LEFT_X=0,T.Gamepad.PS3XC_STICK_LEFT_Y=1,T.Gamepad.PS3XC_STICK_RIGHT_X=2,T.Gamepad.PS3XC_STICK_RIGHT_Y=3,T.SinglePad=function(e,t){this.game=e,this.index=null,this.connected=!1,this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this.deadZone=0.26,this._padParent=t,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},T.SinglePad.prototype={addCallbacks:function(e,t){"undefined"!=typeof t&&(this.onConnectCallback="function"==typeof t.onConnect?t.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof t.onDisconnect?t.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof t.onDown?t.onDown:this.onDownCallback,this.onUpCallback="function"==typeof t.onUp?t.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof t.onAxis?t.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof t.onFloat?t.onFloat:this.onFloatCallback,this.callbackContext=e)},getButton:function(e){return this._buttons[e]?this._buttons[e]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var e=0,t;e<this._buttonsLen;e++)t=isNaN(this._rawPad.buttons[e])?this._rawPad.buttons[e].value:this._rawPad.buttons[e],t!==this._buttons[e].value&&(1===t?this.processButtonDown(e,t):0===t?this.processButtonUp(e,t):this.processButtonFloat(e,t));for(var a=0,o;a<this._axesLen;a++)o=this._rawPad.axes[a],0<o&&o>this.deadZone||0>o&&o<-this.deadZone?this.processAxisChange(a,o):this.processAxisChange(a,0);this._prevTimestamp=this._rawPad.timestamp}},connect:function(e){var t=!this.connected;this.connected=!0,this.index=e.index,this._rawPad=e,this._buttons=[],this._buttonsLen=e.buttons.length,this._axes=[],this._axesLen=e.axes.length;for(var o=0;o<this._axesLen;o++)this._axes[o]=e.axes[o];for(var a in e.buttons)a=parseInt(a,10),this._buttons[a]=new T.DeviceButton(this,a);t&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),t&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var e=this.connected,t=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var a=0;a<this._buttonsLen;a++)this._buttons[a].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,e&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,t),e&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var e=0;e<this._buttonsLen;e++)this._buttons[e].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null},processAxisChange:function(e,t){this._axes[e]===t||(this._axes[e]=t,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,e,t),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,e,t))},processButtonDown:function(e,t){this._buttons[e]&&this._buttons[e].start(null,t),this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,e,t,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,e,t)},processButtonUp:function(e,t){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,e,t,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,e,t),this._buttons[e]&&this._buttons[e].stop(null,t)},processButtonFloat:function(e,t){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,e,t,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,e,t),this._buttons[e]&&this._buttons[e].padFloat(t)},axis:function(e){return!!this._axes[e]&&this._axes[e]},isDown:function(e){return!!this._buttons[e]&&this._buttons[e].isDown},isUp:function(e){return!!this._buttons[e]&&this._buttons[e].isUp},justReleased:function(e,t){if(this._buttons[e])return this._buttons[e].justReleased(t)},justPressed:function(e,t){if(this._buttons[e])return this._buttons[e].justPressed(t)},buttonValue:function(e){return this._buttons[e]?this._buttons[e].value:null},reset:function(){for(var e=0;e<this._axes.length;e++)this._axes[e]=0}},T.SinglePad.prototype.constructor=T.SinglePad,T.Key=function(e,t){this.game=e,this._enabled=!0,this.event=null,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=-2500,this.durationUp=-2500,this.repeats=0,this.keyCode=t,this.onDown=new T.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new T.Signal,this._justDown=!1,this._justUp=!1},T.Key.prototype={update:function(){this._enabled&&(this.isDown?(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this)):this.durationUp=this.game.time.time-this.timeUp)},processKeyDown:function(e){this._enabled&&(this.event=e,this.isDown||(this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.durationUp=this.game.time.time-this.timeUp,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(e){this._enabled&&(this.event=e,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this.durationUp=0,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(e){void 0===e&&(e=!0),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=0,this.durationUp=-2500,this._enabled=!0,this._justDown=!1,this._justUp=!1,e&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(e){return void 0===e&&(e=50),this.isDown&&this.duration<e},upDuration:function(e){return void 0===e&&(e=50),!this.isDown&&this.game.time.time-this.timeUp<e},justPressed:function(){return this.isDown&&0===this.duration},justReleased:function(){return!this.isDown&&0===this.durationUp}},Object.defineProperty(T.Key.prototype,"justDown",{get:function(){var e=this._justDown;return this._justDown=!1,e}}),Object.defineProperty(T.Key.prototype,"justUp",{get:function(){var e=this._justUp;return this._justUp=!1,e}}),Object.defineProperty(T.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(e){e=!!e,e!==this._enabled&&(!e&&this.reset(!1),this._enabled=e)}}),T.Key.prototype.constructor=T.Key,T.Keyboard=function(e){this.game=e,this.enabled=!0,this.event=null,this.pressEvent=null,this.callbackContext=this,this.onDownCallback=null,this.onPressCallback=null,this.onUpCallback=null,this._keys=[],this._capture=[],this._onKeyDown=null,this._onKeyPress=null,this._onKeyUp=null,this._i=0,this._k=0},T.Keyboard.prototype={addCallbacks:function(e,t,a,o){this.callbackContext=e,void 0!==t&&null!==t&&(this.onDownCallback=t),void 0!==a&&null!==a&&(this.onUpCallback=a),void 0!==o&&null!==o&&(this.onPressCallback=o)},addKey:function(e){return this._keys[e]||(this._keys[e]=new T.Key(this.game,e),this.addKeyCapture(e)),this._keys[e]},addKeys:function(e){var t={};for(var a in e)t[a]=this.addKey(e[a]);return t},removeKey:function(e){this._keys[e]&&(this._keys[e]=null,this.removeKeyCapture(e))},createCursorKeys:function(){return this.addKeys({up:T.KeyCode.UP,down:T.KeyCode.DOWN,left:T.KeyCode.LEFT,right:T.KeyCode.RIGHT})},start:function(){if(!this.game.device.cocoonJS&&null===this._onKeyDown){var e=this;this._onKeyDown=function(t){return e.processKeyDown(t)},this._onKeyUp=function(t){return e.processKeyUp(t)},this._onKeyPress=function(t){return e.processKeyPress(t)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1)}},stop:function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("keypress",this._onKeyPress),this._onKeyDown=null,this._onKeyUp=null,this._onKeyPress=null},destroy:function(){this.stop(),this.clearCaptures(),this._keys.length=0,this._i=0},addKeyCapture:function(e){if("object"==typeof e)for(var t in e)this._capture[e[t]]=!0;else this._capture[e]=!0},removeKeyCapture:function(e){delete this._capture[e]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(e){if(this.event=e,this.game.input.enabled&&this.enabled){var t=e.keyCode;this._capture[t]&&e.preventDefault(),this._keys[t]||(this._keys[t]=new T.Key(this.game,t)),this._keys[t].processKeyDown(e),this._k=t,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,e)}},processKeyPress:function(e){this.pressEvent=e,this.game.input.enabled&&this.enabled&&(!this.onPressCallback||this.onPressCallback.call(this.callbackContext,a(e.charCode),e))},processKeyUp:function(e){if(this.event=e,this.game.input.enabled&&this.enabled){var t=e.keyCode;this._capture[t]&&e.preventDefault(),this._keys[t]||(this._keys[t]=new T.Key(this.game,t)),this._keys[t].processKeyUp(e),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,e)}},reset:function(e){void 0===e&&(e=!0),this.event=null;for(var t=this._keys.length;t--;)this._keys[t]&&this._keys[t].reset(e)},downDuration:function(e,t){return this._keys[e]?this._keys[e].downDuration(t):null},upDuration:function(e,t){return this._keys[e]?this._keys[e].upDuration(t):null},justPressed:function(e){return this._keys[e]?this._keys[e].justPressed():null},justReleased:function(e){return this._keys[e]?this._keys[e].justReleased():null},isDown:function(e){return this._keys[e]?this._keys[e].isDown:null}},Object.defineProperty(T.Keyboard.prototype,"lastChar",{get:function(){return this.event&&32===this.event.charCode?"":this.pressEvent?a(this.pressEvent.charCode):null}}),Object.defineProperty(T.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),T.Keyboard.prototype.constructor=T.Keyboard,T.KeyCode={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,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_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,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144},T.KeyCode)T.KeyCode.hasOwnProperty(b)&&!b.match(/[a-z]/)&&(T.Keyboard[b]=T.KeyCode[b]);for(var v in T.Component=function(){},T.Component.Angle=function(){},T.Component.Angle.prototype={angle:{get:function(){return T.Math.wrapAngle(T.Math.radToDeg(this.rotation))},set:function(e){this.rotation=T.Math.degToRad(T.Math.wrapAngle(e))}}},T.Component.Animation=function(){},T.Component.Animation.prototype={play:function(e,t,a,o){if(this.animations)return this.animations.play(e,t,a,o)}},T.Component.AutoCull=function(){},T.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}},T.Component.Bounds=function(){},T.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},centerX:{get:function(){return this.x-this.offsetX+0.5*this.width},set:function(e){this.x=e+this.offsetX-0.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+0.5*this.height},set:function(e){this.y=e+this.offsetY-0.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(e){this.x=e+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(e){this.x=e-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(e){this.y=e+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(e){this.y=e-this.height+this.offsetY}},alignIn:function(e,t,a,o){switch(void 0===a&&(a=0),void 0===o&&(o=0),t){default:case T.TOP_LEFT:this.left=e.left-a,this.top=e.top-o;break;case T.TOP_CENTER:this.centerX=e.centerX+a,this.top=e.top-o;break;case T.TOP_RIGHT:this.right=e.right+a,this.top=e.top-o;break;case T.LEFT_CENTER:this.left=e.left-a,this.centerY=e.centerY+o;break;case T.CENTER:this.centerX=e.centerX+a,this.centerY=e.centerY+o;break;case T.RIGHT_CENTER:this.right=e.right+a,this.centerY=e.centerY+o;break;case T.BOTTOM_LEFT:this.left=e.left-a,this.bottom=e.bottom+o;break;case T.BOTTOM_CENTER:this.centerX=e.centerX+a,this.bottom=e.bottom+o;break;case T.BOTTOM_RIGHT:this.right=e.right+a,this.bottom=e.bottom+o;}return this},alignTo:function(e,t,a,o){switch(void 0===a&&(a=0),void 0===o&&(o=0),t){default:case T.TOP_LEFT:this.left=e.left-a,this.bottom=e.top-o;break;case T.TOP_CENTER:this.centerX=e.centerX+a,this.bottom=e.top-o;break;case T.TOP_RIGHT:this.right=e.right+a,this.bottom=e.top-o;break;case T.LEFT_TOP:this.right=e.left-a,this.top=e.top-o;break;case T.LEFT_CENTER:this.right=e.left-a,this.centerY=e.centerY+o;break;case T.LEFT_BOTTOM:this.right=e.left-a,this.bottom=e.bottom+o;break;case T.RIGHT_TOP:this.left=e.right+a,this.top=e.top-o;break;case T.RIGHT_CENTER:this.left=e.right+a,this.centerY=e.centerY+o;break;case T.RIGHT_BOTTOM:this.left=e.right+a,this.bottom=e.bottom+o;break;case T.BOTTOM_LEFT:this.left=e.left-a,this.top=e.bottom+o;break;case T.BOTTOM_CENTER:this.centerX=e.centerX+a,this.top=e.bottom+o;break;case T.BOTTOM_RIGHT:this.right=e.right+a,this.top=e.bottom+o;}return this}},T.Group.prototype.alignIn=T.Component.Bounds.prototype.alignIn,T.Group.prototype.alignTo=T.Component.Bounds.prototype.alignTo,T.Component.BringToTop=function(){},T.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringToTop(this),this},T.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendToBack(this),this},T.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},T.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},T.Component.Core=function(){},T.Component.Core.skipTypeChecks=!1,T.Component.Core.install=function(e){T.Utils.mixinPrototype(this,T.Component.Core.prototype),this.components={};for(var t=0;t<e.length;t++){var a=e[t],o=!1;"Destroy"===a&&(o=!0),T.Utils.mixinPrototype(this,T.Component[a].prototype,o),this.components[a]=!0}},T.Component.Core.init=function(e,t,a,o,r){if(!T.Component.Core.skipTypeChecks){if(!(e instanceof T.Game))throw new Error("The value passed as the `game` argument ("+e+") is not an instance of Phaser.Game.");"number"!=typeof t&&(console.warn("The `x` argument value (%s) should be a number.",t),t=0),"number"!=typeof a&&(console.warn("The `y` argument value (%s) should be a number.",a),a=0)}this.game=e,this.key=o,this.data={},this.position.set(t,a),this.world=new T.Point(t,a),this.previousPosition=new T.Point(t,a),this.events=new T.Events(this),this._bounds=new T.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new T.AnimationManager(this)),this.components.LoadTexture&&null!==o&&this.loadTexture(o,r),this.components.FixedToCamera&&(this.cameraOffset=new T.Point(t,a))},T.Component.Core.preUpdate=function(){return this.pendingDestroy?void this.destroy():(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!this.exists||!this.parent.exists)?(this.renderOrderID=-1,!1):(this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.animations&&this.animations.update(),this.body&&this.body.preUpdate(),this.preUpdateChildren(),!0)},T.Component.Core.prototype={game:null,name:"",data:{},components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(e){e?(this._exists=!0,this.body&&this.body.type===T.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===T.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},preUpdateChildren:function(){for(var e=0,t;e<this.children.length;)t=this.children[e],t.preUpdate(),this===t.parent&&e++},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&T.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&T.Component.FixedToCamera.postUpdate.call(this);for(var e=0;e<this.children.length;e++)this.children[e].postUpdate()}},T.Component.Crop=function(){},T.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(e,t){void 0===t&&(t=!1),e?(t&&null!==this.cropRect?this.cropRect.setTo(e.x,e.y,e.width,e.height):t&&null===this.cropRect?this.cropRect=new T.Rectangle(e.x,e.y,e.width,e.height):this.cropRect=e,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var e=this.texture.crop.x,t=this.texture.crop.y,a=this.texture.crop.width,o=this.texture.crop.height;this._crop=T.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var r=s(this._frame.x,this._crop.x),n=s(this._frame.y,this._crop.y),i=p(this._frame.right,this._crop.right)-r,d=p(this._frame.bottom,this._crop.bottom)-n;this.texture.crop.x=r,this.texture.crop.y=n,this.texture.crop.width=i,this.texture.crop.height=d,this.texture.frame.width=p(i,this.cropRect.width),this.texture.frame.height=p(d,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215!==this.tint&&(e!==r||t!==n||a!==i||o!==d)&&(this.texture.requiresReTint=!0)}}},T.Component.Delta=function(){},T.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}},T.Component.Destroy=function(){},T.Component.Destroy.prototype={destroyPhase:!1,destroy:function(e,t){if(!(null===this.game||this.destroyPhase)){void 0===e&&(e=!0),void 0===t&&(t=!1),this.destroyPhase=!0,this.events&&this.events.onDestroy$dispatch(this),this.parent&&(this.parent instanceof T.Group?this.parent.remove(this):this.parent.removeChild(this)),this.input&&this.input.destroy(),this.animations&&this.animations.destroy(),this.body&&this.body.destroy(),this.events&&this.events.destroy(),this.game.tweens.removeFrom(this);var a=this.children.length;if(e)for(;a--;)this.children[a].destroy(e);else for(;a--;)this.removeChild(this.children[a]);this._crop&&(this._crop=null,this.cropRect=null),this._frame&&(this._frame=null),T.Video&&this.key instanceof T.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),T.BitmapText&&this._glyphs&&(this._glyphs=[]),this.alive=!1,this.exists=!1,this.visible=!1,this.filters=null,this.mask=null,this.game=null,this.data={},this.renderable=!1,this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null),this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),t&&this.texture.destroy(!0),this.destroyPhase=!1,this.pendingDestroy=!1}}},T.Events=function(e){this.parent=e},T.Events.prototype={destroy:function(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onKilled&&this._onKilled.dispose(),this._onRevived&&this._onRevived.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null},T.Events.prototype.constructor=T.Events,T.Events.prototype)T.Events.prototype.hasOwnProperty(v)&&0===v.indexOf("on")&&null===T.Events.prototype[v]&&function(e,t){"use strict";Object.defineProperty(T.Events.prototype,e,{get:function(){return this[t]||(this[t]=new T.Signal)}}),T.Events.prototype[e+"$dispatch"]=function(){return this[t]?this[t].dispatch.apply(this[t],arguments):null}}(v,"_"+v);T.Component.FixedToCamera=function(){},T.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},T.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(e){e?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new T.Point},T.Component.Health=function(){},T.Component.Health.prototype={health:1,maxHealth:100,damage:function(e){return this.alive&&(this.health-=e,0>=this.health&&this.kill()),this},setHealth:function(e){return this.health=e,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(e){return this.alive&&(this.health+=e,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},T.Component.InCamera=function(){},T.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},T.Component.InputEnabled=function(){},T.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(e){e?null===this.input?(this.input=new T.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},T.Component.InWorld=function(){},T.Component.InWorld.preUpdate=function(){if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},T.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},T.Component.LifeSpan=function(){},T.Component.LifeSpan.preUpdate=function(){return 0<this.lifespan&&(this.lifespan-=this.game.time.physicsElapsedMS,0>=this.lifespan)?(this.kill(),!1):!0},T.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(e){return void 0===e&&(e=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(e),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},T.Component.LoadTexture=function(){},T.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(e,t,a){e===T.PENDING_ATLAS?(e=t,t=0):t=t||0,(a||void 0===a)&&this.animations&&this.animations.stop(),this.key=e,this.customRender=!1;var o=this.game.cache,r=!0,n=!this.texture.baseTexture.scaleMode;if(T.RenderTexture&&e instanceof T.RenderTexture)this.key=e.key,this.setTexture(e);else if(T.BitmapData&&e instanceof T.BitmapData)this.customRender=!0,this.setTexture(e.texture),r=o.hasFrameData(e.key,T.Cache.BITMAPDATA)?!this.animations.loadFrameData(o.getFrameData(e.key,T.Cache.BITMAPDATA),t):!this.animations.loadFrameData(e.frameData,0);else if(T.Video&&e instanceof T.Video){this.customRender=!0;var i=e.texture.valid;this.setTexture(e.texture),this.setFrame(e.texture.frame.clone()),e.onChangeSource.add(this.resizeFrame,this),this.texture.valid=i}else if(T.Tilemap&&e instanceof T.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(e.canvas));else if(e instanceof PIXI.Texture)this.setTexture(e);else{var s=o.getImage(e,!0);this.key=s.key,this.setTexture(new PIXI.Texture(s.base)),this.texture.baseTexture.skipRender="__default"===e,r=!this.animations.loadFrameData(s.frameData,t)}r&&(this._frame=T.Rectangle.clone(this.texture.frame)),n||(this.texture.baseTexture.scaleMode=1)},setFrame:function(e){this._frame=e,this.texture.frame.x=e.x,this.texture.frame.y=e.y,this.texture.frame.width=e.width,this.texture.frame.height=e.height,this.texture.crop.x=e.x,this.texture.crop.y=e.y,this.texture.crop.width=e.width,this.texture.crop.height=e.height,e.trimmed?(this.texture.trim?(this.texture.trim.x=e.spriteSourceSizeX,this.texture.trim.y=e.spriteSourceSizeY,this.texture.trim.width=e.sourceSizeW,this.texture.trim.height=e.sourceSizeH):this.texture.trim={x:e.spriteSourceSizeX,y:e.spriteSourceSizeY,width:e.sourceSizeW,height:e.sourceSizeH},this.texture.width=e.sourceSizeW,this.texture.height=e.sourceSizeH,this.texture.frame.width=e.sourceSizeW,this.texture.frame.height=e.sourceSizeH):!e.trimmed&&this.texture.trim&&(this.texture.trim=null),e.rotated&&(this.texture.rotated=!0),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(e,t,a){this.texture.frame.resize(t,a),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(e){this.animations.frame=e}},frameName:{get:function(){return this.animations.frameName},set:function(e){this.animations.frameName=e}}},T.Component.Overlap=function(){},T.Component.Overlap.prototype={overlap:function(e){return T.Rectangle.intersects(this.getBounds(),e.getBounds())}},T.Component.PhysicsBody=function(){},T.Component.PhysicsBody.preUpdate=function(){return this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,this.preUpdateChildren(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this._exists&&this.parent.exists||(this.renderOrderID=-1,!1))},T.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},T.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(e){this.position.x=e,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(e){this.position.y=e,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},T.Component.Reset=function(){},T.Component.Reset.prototype.reset=function(e,t,a){return void 0===a&&(a=1),this.world.set(e,t),this.position.set(e,t),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=a),this.components.PhysicsBody&&this.body&&this.body.reset(e,t,!1,!1),this},T.Component.ScaleMinMax=function(){},T.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(e){this.scaleMin&&(e.a<this.scaleMin.x&&(e.a=this.scaleMin.x),e.d<this.scaleMin.y&&(e.d=this.scaleMin.y)),this.scaleMax&&(e.a>this.scaleMax.x&&(e.a=this.scaleMax.x),e.d>this.scaleMax.y&&(e.d=this.scaleMax.y))},setScaleMinMax:function(e,t,a,o){void 0===t?t=a=o=e:void 0===a&&(a=o=t,t=e),null===e?this.scaleMin=null:this.scaleMin?this.scaleMin.set(e,t):this.scaleMin=new T.Point(e,t),null===a?this.scaleMax=null:this.scaleMax?this.scaleMax.set(a,o):this.scaleMax=new T.Point(a,o),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},T.Component.Smoothed=function(){},T.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(e){e?this.texture&&(this.texture.baseTexture.scaleMode=0):this.texture&&(this.texture.baseTexture.scaleMode=1)}}},T.GameObjectFactory=function(e){this.game=e,this.world=this.game.world},T.GameObjectFactory.prototype={existing:function(e){return this.world.add(e)},weapon:function(e,t,a,o,r){var n=this.game.plugins.add(T.Weapon);return r&&(n.bulletClass=r),n.createBullets(e,t,a,o),n},image:function(e,t,a,o,r){return void 0===r&&(r=this.world),r.add(new T.Image(this.game,e,t,a,o))},sprite:function(e,t,a,o,r){return void 0===r&&(r=this.world),r.create(e,t,a,o)},creature:function(e,t,a,o,r){void 0===r&&(r=this.world);var n=new T.Creature(this.game,e,t,a,o);return r.add(n),n},tween:function(e){return this.game.tweens.create(e)},group:function(e,t,a,o,r){return new T.Group(this.game,e,t,a,o,r)},physicsGroup:function(e,t,a,o){return new T.Group(this.game,t,a,o,!0,e)},spriteBatch:function(e,t,a){return void 0===e&&(e=null),void 0===t&&(t="group"),void 0===a&&(a=!1),new T.SpriteBatch(this.game,e,t,a)},audio:function(e,t,a,o){return this.game.sound.add(e,t,a,o)},sound:function(e,t,a,o){return this.game.sound.add(e,t,a,o)},audioSprite:function(e){return this.game.sound.addSprite(e)},tileSprite:function(e,t,a,o,r,n,i){return void 0===i&&(i=this.world),i.add(new T.TileSprite(this.game,e,t,a,o,r,n))},rope:function(e,t,a,o,r,n){return void 0===n&&(n=this.world),n.add(new T.Rope(this.game,e,t,a,o,r))},text:function(e,t,a,o,r){return void 0===r&&(r=this.world),r.add(new T.Text(this.game,e,t,a,o))},button:function(e,t,a,o,r,n,i,s,d,l){return void 0===l&&(l=this.world),l.add(new T.Button(this.game,e,t,a,o,r,n,i,s,d))},graphics:function(e,t,a){return void 0===a&&(a=this.world),a.add(new T.Graphics(this.game,e,t))},emitter:function(e,t,a){return this.game.particles.add(new T.Particles.Arcade.Emitter(this.game,e,t,a))},retroFont:function(e,t,a,o,r,n,i,s,d){return new T.RetroFont(this.game,e,t,a,o,r,n,i,s,d)},bitmapText:function(e,t,a,o,r,n){return void 0===n&&(n=this.world),n.add(new T.BitmapText(this.game,e,t,a,o,r))},tilemap:function(e,t,a,o,r){return new T.Tilemap(this.game,e,t,a,o,r)},renderTexture:function(e,t,a,o){(void 0===a||""===a)&&(a=this.game.rnd.uuid()),void 0===o&&(o=!1);var r=new T.RenderTexture(this.game,e,t,a);return o&&this.game.cache.addRenderTexture(a,r),r},video:function(e,t){return new T.Video(this.game,e,t)},bitmapData:function(e,t,a,o){void 0===o&&(o=!1),(void 0===a||""===a)&&(a=this.game.rnd.uuid());var r=new T.BitmapData(this.game,a,e,t);return o&&this.game.cache.addBitmapData(a,r),r},filter:function(e){var t=Array.prototype.slice.call(arguments,1),e=new T.Filter[e](this.game);return e.init.apply(e,t),e},plugin:function(e){return this.game.plugins.add(e)}},T.GameObjectFactory.prototype.constructor=T.GameObjectFactory,T.GameObjectCreator=function(e){this.game=e,this.world=this.game.world},T.GameObjectCreator.prototype={image:function(e,t,a,o){return new T.Image(this.game,e,t,a,o)},sprite:function(e,t,a,o){return new T.Sprite(this.game,e,t,a,o)},tween:function(e){return new T.Tween(e,this.game,this.game.tweens)},group:function(e,t,a,o,r){return new T.Group(this.game,e,t,a,o,r)},spriteBatch:function(e,t,a){return void 0===t&&(t="group"),void 0===a&&(a=!1),new T.SpriteBatch(this.game,e,t,a)},audio:function(e,t,a,o){return this.game.sound.add(e,t,a,o)},audioSprite:function(e){return this.game.sound.addSprite(e)},sound:function(e,t,a,o){return this.game.sound.add(e,t,a,o)},tileSprite:function(e,t,a,o,r,n){return new T.TileSprite(this.game,e,t,a,o,r,n)},rope:function(e,t,a,o,r){return new T.Rope(this.game,e,t,a,o,r)},text:function(e,t,a,o){return new T.Text(this.game,e,t,a,o)},button:function(e,t,a,o,r,n,i,s,d){return new T.Button(this.game,e,t,a,o,r,n,i,s,d)},graphics:function(e,t){return new T.Graphics(this.game,e,t)},emitter:function(e,t,a){return new T.Particles.Arcade.Emitter(this.game,e,t,a)},retroFont:function(e,t,a,o,r,n,i,s,d){return new T.RetroFont(this.game,e,t,a,o,r,n,i,s,d)},bitmapText:function(e,t,a,o,r,n){return new T.BitmapText(this.game,e,t,a,o,r,n)},tilemap:function(e,t,a,o,r){return new T.Tilemap(this.game,e,t,a,o,r)},renderTexture:function(e,t,a,o){(void 0===a||""===a)&&(a=this.game.rnd.uuid()),void 0===o&&(o=!1);var r=new T.RenderTexture(this.game,e,t,a);return o&&this.game.cache.addRenderTexture(a,r),r},bitmapData:function(e,t,a,o){void 0===o&&(o=!1),(void 0===a||""===a)&&(a=this.game.rnd.uuid());var r=new T.BitmapData(this.game,a,e,t);return o&&this.game.cache.addBitmapData(a,r),r},filter:function(e){var t=Array.prototype.slice.call(arguments,1),e=new T.Filter[e](this.game);return e.init.apply(e,t),e}},T.GameObjectCreator.prototype.constructor=T.GameObjectCreator,T.Sprite=function(e,t,a,o,r){t=t||0,a=a||0,o=o||null,r=r||null,this.type=T.SPRITE,this.physicsType=T.SPRITE,PIXI.Sprite.call(this,T.Cache.DEFAULT),T.Component.Core.init.call(this,e,t,a,o,r)},T.Sprite.prototype=Object.create(PIXI.Sprite.prototype),T.Sprite.prototype.constructor=T.Sprite,T.Component.Core.install.call(T.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),T.Sprite.prototype.preUpdatePhysics=T.Component.PhysicsBody.preUpdate,T.Sprite.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.Sprite.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.Sprite.prototype.preUpdateCore=T.Component.Core.preUpdate,T.Sprite.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.Image=function(e,t,a,o,r){t=t||0,a=a||0,o=o||null,r=r||null,this.type=T.IMAGE,PIXI.Sprite.call(this,T.Cache.DEFAULT),T.Component.Core.init.call(this,e,t,a,o,r)},T.Image.prototype=Object.create(PIXI.Sprite.prototype),T.Image.prototype.constructor=T.Image,T.Component.Core.install.call(T.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),T.Image.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.Image.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.Image.prototype.preUpdateCore=T.Component.Core.preUpdate,T.Image.prototype.preUpdate=function(){return this.preUpdateInWorld()&&this.preUpdateLifeSpan()&&this.preUpdateCore()},T.Button=function(e,t,a,o,r,n,i,s,d,l){t=t||0,a=a||0,o=o||null,r=r||null,n=n||this,T.Image.call(this,e,t,a,o,s),this.type=T.BUTTON,this.physicsType=T.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new T.Signal,this.onInputOut=new T.Signal,this.onInputDown=new T.Signal,this.onInputUp=new T.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=T.PointerMode.TOUCH,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(i,s,d,l),null!==r&&this.onInputUp.add(r,n),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},T.Button.prototype=Object.create(T.Image.prototype),T.Button.prototype.constructor=T.Button;var C="Over",P="Out",S="Down",w="Up";return T.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},T.Button.prototype.setStateFrame=function(e,t,a){var o="_on"+e+"Frame";null===t?this[o]=null:(this[o]=t,a&&this.changeStateFrame(e))},T.Button.prototype.changeStateFrame=function(e){if(this.freezeFrames)return!1;var t=this["_on"+e+"Frame"];return"string"==typeof t?(this.frameName=t,!0):"number"==typeof t&&(this.frame=t,!0)},T.Button.prototype.setFrames=function(e,t,a,o){this.setStateFrame(C,e,this.input.pointerOver()),this.setStateFrame(P,t,!this.input.pointerOver()),this.setStateFrame(S,a,this.input.pointerDown()),this.setStateFrame(w,o,this.input.pointerUp())},T.Button.prototype.setStateSound=function(e,t,a){var o="on"+e+"Sound",r="on"+e+"SoundMarker";t instanceof T.Sound||t instanceof T.AudioSprite?(this[o]=t,this[r]="string"==typeof a?a:""):(this[o]=null,this[r]="")},T.Button.prototype.playStateSound=function(e){var t=this["on"+e+"Sound"];if(t){var a=this["on"+e+"SoundMarker"];return t.play(a),!0}return!1},T.Button.prototype.setSounds=function(e,t,a,o,r,n,i,s){this.setStateSound(C,e,t),this.setStateSound(P,r,n),this.setStateSound(S,a,o),this.setStateSound(w,i,s)},T.Button.prototype.setOverSound=function(e,t){this.setStateSound(C,e,t)},T.Button.prototype.setOutSound=function(e,t){this.setStateSound(P,e,t)},T.Button.prototype.setDownSound=function(e,t){this.setStateSound(S,e,t)},T.Button.prototype.setUpSound=function(e,t){this.setStateSound(w,e,t)},T.Button.prototype.onInputOverHandler=function(e,t){t.justReleased()&&(this.justReleasedPreventsOver&t.pointerMode)===t.pointerMode||(this.changeStateFrame(C),this.onOverMouseOnly&&!t.isMouse||(this.playStateSound(C),this.onInputOver&&this.onInputOver.dispatch(this,t)))},T.Button.prototype.onInputOutHandler=function(e,t){this.changeStateFrame(P),this.playStateSound(P),this.onInputOut&&this.onInputOut.dispatch(this,t)},T.Button.prototype.onInputDownHandler=function(e,t){this.changeStateFrame(S),this.playStateSound(S),this.onInputDown&&this.onInputDown.dispatch(this,t)},T.Button.prototype.onInputUpHandler=function(e,t,a){if(this.playStateSound(w),this.onInputUp&&this.onInputUp.dispatch(this,t,a),!this.freezeFrames)if(!0===this.forceOut||(this.forceOut&t.pointerMode)===t.pointerMode)this.changeStateFrame(P);else{var o=this.changeStateFrame(w);o||(a?this.changeStateFrame(C):this.changeStateFrame(P))}},T.SpriteBatch=function(e,t,a,o){(void 0===t||null===t)&&(t=e.world),T.Group.call(this,e,t,a,o),this.type=T.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},T.SpriteBatch.prototype=Object.create(T.Group.prototype),T.SpriteBatch.prototype.constructor=T.SpriteBatch,T.SpriteBatch.prototype._renderWebGL=function(e){this.visible&&!(0>=this.alpha)&&this.children.length&&(!this.ready&&(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(e.gl),this.ready=!0),this.fastSpriteBatch.gl!==e.gl&&this.fastSpriteBatch.setContext(e.gl),e.spriteBatch.stop(),e.shaderManager.setShader(e.shaderManager.fastShader),this.fastSpriteBatch.begin(this,e),this.fastSpriteBatch.render(this),e.spriteBatch.start())},T.SpriteBatch.prototype._renderCanvas=function(e){if(this.visible&&!(0>=this.alpha)&&this.children.length){var t=e.context;t.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var a=this.worldTransform,o=!0,r=0,n;r<this.children.length;r++)if(n=this.children[r],!!n.visible){var i=n.texture,s=i.frame;if(t.globalAlpha=this.worldAlpha*n.alpha,0==n.rotation%(2*d))o&&(t.setTransform(a.a,a.b,a.c,a.d,a.tx,a.ty),o=!1),t.drawImage(i.baseTexture.source,s.x,s.y,s.width,s.height,0|n.anchor.x*(-s.width*n.scale.x)+n.position.x+0.5+e.shakeX,0|n.anchor.y*(-s.height*n.scale.y)+n.position.y+0.5+e.shakeY,s.width*n.scale.x,s.height*n.scale.y);else{o||(o=!0),n.displayObjectUpdateTransform();var l=n.worldTransform,p=l.tx*e.resolution+e.shakeX,c=l.ty*e.resolution+e.shakeY;e.roundPixels?t.setTransform(l.a,l.b,l.c,l.d,0|p,0|c):t.setTransform(l.a,l.b,l.c,l.d,p,c),t.drawImage(i.baseTexture.source,s.x,s.y,s.width,s.height,0|n.anchor.x*-s.width+0.5,0|n.anchor.y*-s.height+0.5,s.width,s.height)}}}},T.BitmapData=function(e,t,a,o,r){(void 0===a||0===a)&&(a=256),(void 0===o||0===o)&&(o=256),void 0===r&&(r=!1),this.game=e,this.key=t,this.width=a,this.height=o,this.canvas=T.Canvas.create(this,a,o,null,r),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=e.renderType===T.CANVAS?e.renderer.renderSession.smoothProperty:T.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,a,o),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas,null,this.game.resolution),this.texture=new PIXI.Texture(this.baseTexture),this.frameData=new T.FrameData,this.textureFrame=this.frameData.addFrame(new T.Frame(0,0,0,a,o,"bitmapData")),this.texture.frame=this.textureFrame,this.type=T.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new T.Point,this._size=new T.Point,this._scale=new T.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new T.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new T.Circle,this._swapCanvas=void 0},T.BitmapData.prototype={move:function(e,t,a){return 0!==e&&this.moveH(e,a),0!==t&&this.moveV(t,a),this},moveH:function(e,t){void 0===t&&(t=!0),void 0===this._swapCanvas&&(this._swapCanvas=T.CanvasPool.create(this,this.width,this.height));var a=this._swapCanvas,o=a.getContext("2d"),r=this.height,n=this.canvas;if(o.clearRect(0,0,this.width,this.height),0>e){e=f(e);var i=this.width-e;t&&o.drawImage(n,0,0,e,r,i,0,e,r),o.drawImage(n,e,0,i,r,0,0,i,r)}else{var i=this.width-e;t&&o.drawImage(n,i,0,e,r,0,0,e,r),o.drawImage(n,0,0,i,r,e,0,i,r)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(e,t){void 0===t&&(t=!0),void 0===this._swapCanvas&&(this._swapCanvas=T.CanvasPool.create(this,this.width,this.height));var a=this._swapCanvas,o=a.getContext("2d"),r=this.width,n=this.canvas;if(o.clearRect(0,0,this.width,this.height),0>e){e=f(e);var i=this.height-e;t&&o.drawImage(n,0,0,r,e,0,i,r,e),o.drawImage(n,0,e,r,i,0,0,r,i)}else{var i=this.height-e;t&&o.drawImage(n,0,i,r,e,0,0,r,e),o.drawImage(n,0,0,r,i,0,e,r,i)}return this.clear(),this.copy(this._swapCanvas)},add:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)e[t].loadTexture&&e[t].loadTexture(this);else e.loadTexture(this);return this},load:function(e){if("string"==typeof e&&(e=this.game.cache.getImage(e)),e)this.resize(e.width,e.height),this.cls();else return;return this.draw(e),this.update(),this},clear:function(e,t,a,o){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=this.width),void 0===o&&(o=this.height),this.context.clearRect(e,t,a,o),this.dirty=!0,this},fill:function(e,t,o,r){return void 0===r&&(r=1),this.context.fillStyle="rgba("+e+","+t+","+o+","+r+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(e,t,a){var o=this.game.cache,r=new Image;if(t&&(r.onload=function(){var n=o.addImage(e,"",r),i=new PIXI.Texture(n.base);t.call(a||null,i),r.onload=null}),r.src=this.canvas.toDataURL("image/png"),!t){var n=o.addImage(e,"",r);return new PIXI.Texture(n.base)}return null},resize:function(e,t){return(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvas.width=e,this.canvas.height=t,void 0!==this._swapCanvas&&(this._swapCanvas.width=e,this._swapCanvas.height=t),this.baseTexture.width=e,this.baseTexture.height=t,this.textureFrame.width=e,this.textureFrame.height=t,this.texture.width=e,this.texture.height=t,this.texture.crop.width=e,this.texture.crop.height=t,this.update(),this.dirty=!0),this},update:function(e,t,a,o){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=s(1,this.width)),void 0===o&&(o=s(1,this.height)),this.imageData=this.context.getImageData(e,t,a,o),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(e,t,a,o,r,n){void 0===a&&(a=0),void 0===o&&(o=0),void 0===r&&(r=this.width),void 0===n&&(n=this.height);for(var i=a+r,s=o+n,d=T.Color.createColor(),l={r:0,g:0,b:0,a:0},p=!1,c=o;c<s;c++)for(var u=a;u<i;u++)T.Color.unpackPixel(this.getPixel32(u,c),d),l=e.call(t,d,u,c),!1!==l&&null!==l&&void 0!==l&&(this.setPixel32(u,c,l.r,l.g,l.b,l.a,!1),p=!0);return p&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(e,t,a,o,r,n){void 0===a&&(a=0),void 0===o&&(o=0),void 0===r&&(r=this.width),void 0===n&&(n=this.height);for(var i=a+r,s=o+n,d=0,l=0,p=!1,c=o;c<s;c++)for(var u=a;u<i;u++)d=this.getPixel32(u,c),l=e.call(t,d,u,c),l!==d&&(this.pixels[c*this.width+u]=l,p=!0);return p&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(e,t,a,o,r,n,i,s,d){var l=0,p=0,c=this.width,u=this.height,h=T.Color.packPixel(e,t,a,o);void 0!==d&&d instanceof T.Rectangle&&(l=d.x,p=d.y,c=d.width,u=d.height);for(var g=0;g<u;g++)for(var m=0;m<c;m++)this.getPixel32(l+m,p+g)===h&&this.setPixel32(l+m,p+g,r,n,i,s,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(e,t,a,o){var r=e||0===e,n=t||0===t,i=a||0===a;if(r||n||i){void 0===o&&(o=new T.Rectangle(0,0,this.width,this.height));for(var s=T.Color.createColor(),d=o.y;d<o.bottom;d++)for(var l=o.x;l<o.right;l++)T.Color.unpackPixel(this.getPixel32(l,d),s,!0),r&&(s.h=e),n&&(s.s=t),i&&(s.l=a),T.Color.HSLtoRGB(s.h,s.s,s.l,s),this.setPixel32(l,d,s.r,s.g,s.b,s.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(e,t,a,o){if((void 0===e||null===e)&&(e=!1),(void 0===t||null===t)&&(t=!1),(void 0===a||null===a)&&(a=!1),e||t||a){void 0===o&&(o=new T.Rectangle(0,0,this.width,this.height));for(var r=T.Color.createColor(),n=o.y;n<o.bottom;n++)for(var i=o.x;i<o.right;i++)T.Color.unpackPixel(this.getPixel32(i,n),r,!0),e&&(r.h=this.game.math.wrap(r.h+e,0,1)),t&&(r.s=this.game.math.clamp(r.s+t,0,1)),a&&(r.l=this.game.math.clamp(r.l+a,0,1)),T.Color.HSLtoRGB(r.h,r.s,r.l,r),this.setPixel32(i,n,r.r,r.g,r.b,r.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(e,t,a,o,r,n,i){return void 0===i&&(i=!0),0<=e&&e<=this.width&&0<=t&&t<=this.height&&(this.pixels[t*this.width+e]=T.Device.LITTLE_ENDIAN?n<<24|r<<16|o<<8|a:a<<24|o<<16|r<<8|n,i&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(e,t,a,o,r,n){return this.setPixel32(e,t,a,o,r,255,n)},getPixel:function(e,t,a){a||(a=T.Color.createColor());var o=~~(e+t*this.width);return o*=4,a.r=this.data[o],a.g=this.data[++o],a.b=this.data[++o],a.a=this.data[++o],a},getPixel32:function(e,t){if(0<=e&&e<=this.width&&0<=t&&t<=this.height)return this.pixels[t*this.width+e]},getPixelRGB:function(e,t,a,o,r){return T.Color.unpackPixel(this.getPixel32(e,t),a,o,r)},getPixels:function(e){return this.context.getImageData(e.x,e.y,e.width,e.height)},getFirstPixel:function(e){void 0===e&&(e=0);var t=T.Color.createColor(),a=0,o=0,r=1,n=!1;1===e?(r=-1,o=this.height):3===e&&(r=-1,a=this.width);do T.Color.unpackPixel(this.getPixel32(a,o),t),0===e||1===e?(a++,a===this.width&&(a=0,o+=r,(o>=this.height||0>=o)&&(n=!0))):(2===e||3===e)&&(o++,o===this.height&&(o=0,a+=r,(a>=this.width||0>=a)&&(n=!0)));while(0===t.a&&!n);return t.x=a,t.y=o,t},getBounds:function(e){return(void 0===e&&(e=new T.Rectangle),e.x=this.getFirstPixel(2).x,e.x===this.width)?e.setTo(0,0,0,0):(e.y=this.getFirstPixel(0).y,e.width=this.getFirstPixel(3).x-e.x+1,e.height=this.getFirstPixel(1).y-e.y+1,e)},addToWorld:function(e,t,a,o,r,n){r=r||1,n=n||1;var i=this.game.add.image(e,t,this);return i.anchor.set(a,o),i.scale.set(r,n),i},copy:function(e,t,a,o,r,n,i,s,d,l,p,c,u,h,g,m,y){if((void 0===e||null===e)&&(e=this),e instanceof T.RenderTexture&&(e=e.getCanvas()),this._image=e,e instanceof T.Sprite||e instanceof T.Image||e instanceof T.Text||e instanceof PIXI.Sprite)this._pos.set(e.texture.crop.x,e.texture.crop.y),this._size.set(e.texture.crop.width,e.texture.crop.height),this._scale.set(e.scale.x,e.scale.y),this._anchor.set(e.anchor.x,e.anchor.y),this._rotate=e.rotation,this._alpha.current=e.alpha,this._image=e.texture instanceof T.RenderTexture?e.texture.getCanvas():e.texture.baseTexture.source,(void 0===n||null===n)&&(n=e.x),(void 0===i||null===i)&&(i=e.y),e.texture.trim&&(n+=e.texture.trim.x-e.anchor.x*e.texture.trim.width,i+=e.texture.trim.y-e.anchor.y*e.texture.trim.height),16777215!==e.tint&&(e.cachedTint!==e.tint&&(e.cachedTint=e.tint,e.tintedTexture=PIXI.CanvasTinter.getTintedTexture(e,e.tint)),this._image=e.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,e instanceof T.BitmapData)this._image=e.canvas;else if("string"==typeof e){if(e=this.game.cache.getImage(e),null===e)return;this._image=e}this._size.set(this._image.width,this._image.height)}if((void 0===t||null===t)&&(t=0),(void 0===a||null===a)&&(a=0),o&&(this._size.x=o),r&&(this._size.y=r),(void 0===n||null===n)&&(n=t),(void 0===i||null===i)&&(i=a),(void 0===s||null===s)&&(s=this._size.x),(void 0===d||null===d)&&(d=this._size.y),"number"==typeof l&&(this._rotate=l),"number"==typeof p&&(this._anchor.x=p),"number"==typeof c&&(this._anchor.y=c),"number"==typeof u&&(this._scale.x=u),"number"==typeof h&&(this._scale.y=h),"number"==typeof g&&(this._alpha.current=g),void 0===m&&(m=null),void 0===y&&(y=!1),!(0>=this._alpha.current||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)){var f=this.context;return this._alpha.prev=f.globalAlpha,f.save(),f.globalAlpha=this._alpha.current,m&&(this.op=m),y&&(n|=0,i|=0),f.translate(n,i),f.scale(this._scale.x,this._scale.y),f.rotate(this._rotate),f.drawImage(this._image,this._pos.x+t,this._pos.y+a,this._size.x,this._size.y,-s*this._anchor.x,-d*this._anchor.y,s,d),f.restore(),f.globalAlpha=this._alpha.prev,this.dirty=!0,this}},copyTransform:function(e,t,a){if(void 0===t&&(t=null),void 0===a&&(a=!1),!e.hasOwnProperty("worldTransform")||!e.worldVisible||0===e.worldAlpha)return this;var o=e.worldTransform;if(this._pos.set(e.texture.crop.x,e.texture.crop.y),this._size.set(e.texture.crop.width,e.texture.crop.height),0===o.a||0===o.d||0===this._size.x||0===this._size.y)return this;this._image=e.texture instanceof T.RenderTexture?e.texture.getCanvas():e.texture.baseTexture.source;var r=o.tx,n=o.ty;e.texture.trim&&(r+=e.texture.trim.x-e.anchor.x*e.texture.trim.width,n+=e.texture.trim.y-e.anchor.y*e.texture.trim.height),16777215!==e.tint&&(e.cachedTint!==e.tint&&(e.cachedTint=e.tint,e.tintedTexture=PIXI.CanvasTinter.getTintedTexture(e,e.tint)),this._image=e.tintedTexture,this._pos.set(0)),a&&(r|=0,n|=0);var i=this.context;return this._alpha.prev=i.globalAlpha,i.save(),i.globalAlpha=this._alpha.current,t&&(this.op=t),i[this.smoothProperty]=e.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,i.setTransform(o.a,o.b,o.c,o.d,r,n),i.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*e.anchor.x,-this._size.y*e.anchor.y,this._size.x,this._size.y),i.restore(),i.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(e,t,a,o,r,n,i){return this.copy(e,t.x,t.y,t.width,t.height,a,o,t.width,t.height,0,0,0,1,1,r,n,i)},draw:function(e,t,a,o,r,n,i){return this.copy(e,null,null,null,null,t,a,o,r,null,null,null,null,null,null,n,i)},drawGroup:function(e,t,a){return 0<e.total&&e.forEachExists(this.drawGroupProxy,this,t,a),this},drawGroupProxy:function(e,t,a){if(e.hasOwnProperty("texture")&&this.copyTransform(e,t,a),e.type===T.GROUP&&e.exists)this.drawGroup(e,t,a);else if(e.hasOwnProperty("children")&&0<e.children.length)for(var o=0;o<e.children.length;o++)e.children[o].exists&&this.copyTransform(e.children[o],t,a)},drawFull:function(e,t,a){if(!1===e.worldVisible||0===e.worldAlpha||e.hasOwnProperty("exists")&&!1===e.exists)return this;if(e.type!==T.GROUP&&e.type!==T.EMITTER&&e.type!==T.BITMAPTEXT)if(e.type===T.GRAPHICS){var o=e.getBounds();this.ctx.save(),this.ctx.translate(o.x,o.y),PIXI.CanvasGraphics.renderGraphics(e,this.ctx),this.ctx.restore()}else this.copy(e,null,null,null,null,e.worldPosition.x,e.worldPosition.y,null,null,e.worldRotation,null,null,e.worldScale.x,e.worldScale.y,e.worldAlpha,t,a);if(e.children)for(var r=0;r<e.children.length;r++)this.drawFull(e.children[r],t,a);return this},shadow:function(e,t,a,o){var r=this.context;return void 0===e||null===e?r.shadowColor="rgba(0,0,0,0)":(r.shadowColor=e,r.shadowBlur=t||5,r.shadowOffsetX=a||10,r.shadowOffsetY=o||10),this},alphaMask:function(e,t,a,o){return void 0===o||null===o?this.draw(t).blendSourceAtop():this.draw(t,o.x,o.y,o.width,o.height).blendSourceAtop(),void 0===a||null===a?this.draw(e).blendReset():this.draw(e,a.x,a.y,a.width,a.height).blendReset(),this},extract:function(e,t,o,r,n,a,i,s,d){return void 0===n&&(n=255),void 0===a&&(a=!1),void 0===i&&(i=t),void 0===s&&(s=o),void 0===d&&(d=r),a&&e.resize(this.width,this.height),this.processPixelRGB(function(a,l,p){return a.r===t&&a.g===o&&a.b===r&&e.setPixel32(l,p,i,s,d,n,!1),!1},this),e.context.putImageData(e.imageData,0,0),e.dirty=!0,e},rect:function(e,t,a,o,r){return"undefined"!=typeof r&&(this.context.fillStyle=r),this.context.fillRect(e,t,a,o),this},text:function(e,t,a,o,r,n){void 0===t&&(t=0),void 0===a&&(a=0),void 0===o&&(o="14px Courier"),void 0===r&&(r="rgb(255,255,255)"),void 0===n&&(n=!0);var i=this.context,s=i.font;return i.font=o,n&&(i.fillStyle="rgb(0,0,0)",i.fillText(e,t+1,a+1)),i.fillStyle=r,i.fillText(e,t,a),i.font=s,this},circle:function(e,t,a,o){var r=this.context;return void 0!==o&&(r.fillStyle=o),r.beginPath(),r.arc(e,t,a,0,2*d,!1),r.closePath(),r.fill(),this},line:function(e,t,a,o,r,n){void 0===r&&(r="#fff"),void 0===n&&(n=1);var i=this.context;return i.beginPath(),i.moveTo(e,t),i.lineTo(a,o),i.lineWidth=n,i.strokeStyle=r,i.stroke(),i.closePath(),this},textureLine:function(e,t,a){if(void 0===a&&(a="repeat-x"),!("string"==typeof t&&(t=this.game.cache.getImage(t),!t))){var o=e.length;"no-repeat"===a&&o>t.width&&(o=t.width);var r=this.context;return r.fillStyle=r.createPattern(t,a),this._circle=new T.Circle(e.start.x,e.start.y,t.height),this._circle.circumferencePoint(e.angle-1.5707963267948966,!1,this._pos),r.save(),r.translate(this._pos.x,this._pos.y),r.rotate(e.angle),r.fillRect(0,0,o,t.height),r.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),T.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(e,t,a){e.update();for(var o=0,r;o<e.height;o++){r=(a+o)*this.width+t;for(var n=0;n<e.width;n++)this.pixels[r+n]=e.pixels[o*e.width+n]}return this}},Object.defineProperty(T.BitmapData.prototype,"smoothed",{get:function(){T.Canvas.getSmoothingEnabled(this.context)},set:function(e){T.Canvas.setSmoothingEnabled(this.context,e)}}),Object.defineProperty(T.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(e){this.context.globalCompositeOperation=e}}),T.BitmapData.getTransform=function(e,t,a,o,r,n){return"number"!=typeof e&&(e=0),"number"!=typeof t&&(t=0),"number"!=typeof a&&(a=1),"number"!=typeof o&&(o=1),"number"!=typeof r&&(r=0),"number"!=typeof n&&(n=0),{sx:a,sy:o,scaleX:a,scaleY:o,skewX:r,skewY:n,translateX:e,translateY:t,tx:e,ty:t}},T.BitmapData.prototype.constructor=T.BitmapData,T.EarCut={},T.EarCut.Triangulate=function(e,t,a){a=a||2;var o=t&&t.length,r=o?t[0]*a:e.length,n=T.EarCut.linkedList(e,0,r,a,!0),d=[];if(!n)return d;var l,p,c,u,h,g,m;if(o&&(n=T.EarCut.eliminateHoles(e,t,n,a)),e.length>80*a){l=c=e[0],p=u=e[1];for(var y=a;y<r;y+=a)h=e[y],g=e[y+1],h<l&&(l=h),g<p&&(p=g),h>c&&(c=h),g>u&&(u=g);m=s(c-l,u-p)}return T.EarCut.earcutLinked(n,d,a,l,p,m),d},T.EarCut.linkedList=function(e,t,a,o,r){var n=0,s,i,d;for(s=t,i=a-o;s<a;s+=o)n+=(e[i]-e[s])*(e[s+1]+e[i+1]),i=s;if(r===0<n)for(s=t;s<a;s+=o)d=T.EarCut.insertNode(s,e[s],e[s+1],d);else for(s=a-o;s>=t;s-=o)d=T.EarCut.insertNode(s,e[s],e[s+1],d);return d},T.EarCut.filterPoints=function(e,t){if(!e)return e;t||(t=e);var a=e,o;do if(o=!1,!a.steiner&&(T.EarCut.equals(a,a.next)||0===T.EarCut.area(a.prev,a,a.next))){if(T.EarCut.removeNode(a),a=t=a.prev,a===a.next)return null;o=!0}else a=a.next;while(o||a!==t);return t},T.EarCut.earcutLinked=function(e,t,a,o,r,n,i){if(e){!i&&n&&T.EarCut.indexCurve(e,o,r,n);for(var s=e,d,l;e.prev!==e.next;){if(d=e.prev,l=e.next,n?T.EarCut.isEarHashed(e,o,r,n):T.EarCut.isEar(e)){t.push(d.i/a),t.push(e.i/a),t.push(l.i/a),T.EarCut.removeNode(e),e=l.next,s=l.next;continue}if(e=l,e===s){i?1===i?(e=T.EarCut.cureLocalIntersections(e,t,a),T.EarCut.earcutLinked(e,t,a,o,r,n,2)):2===i&&T.EarCut.splitEarcut(e,t,a,o,r,n):T.EarCut.earcutLinked(T.EarCut.filterPoints(e),t,a,o,r,n,1);break}}}},T.EarCut.isEar=function(e){var t=e.prev,a=e,o=e.next;if(0<=T.EarCut.area(t,a,o))return!1;for(var r=e.next.next;r!==e.prev;){if(T.EarCut.pointInTriangle(t.x,t.y,a.x,a.y,o.x,o.y,r.x,r.y)&&0<=T.EarCut.area(r.prev,r,r.next))return!1;r=r.next}return!0},T.EarCut.isEarHashed=function(e,t,o,r){var n=e.prev,a=e,i=e.next;if(0<=T.EarCut.area(n,a,i))return!1;for(var s=n.x<a.x?n.x<i.x?n.x:i.x:a.x<i.x?a.x:i.x,d=n.y<a.y?n.y<i.y?n.y:i.y:a.y<i.y?a.y:i.y,l=n.x>a.x?n.x>i.x?n.x:i.x:a.x>i.x?a.x:i.x,c=n.y>a.y?n.y>i.y?n.y:i.y:a.y>i.y?a.y:i.y,u=T.EarCut.zOrder(s,d,t,o,r),h=T.EarCut.zOrder(l,c,t,o,r),g=e.nextZ;g&&g.z<=h;){if(g!==e.prev&&g!==e.next&&T.EarCut.pointInTriangle(n.x,n.y,a.x,a.y,i.x,i.y,g.x,g.y)&&0<=T.EarCut.area(g.prev,g,g.next))return!1;g=g.nextZ}for(g=e.prevZ;g&&g.z>=u;){if(g!==e.prev&&g!==e.next&&T.EarCut.pointInTriangle(n.x,n.y,a.x,a.y,i.x,i.y,g.x,g.y)&&0<=T.EarCut.area(g.prev,g,g.next))return!1;g=g.prevZ}return!0},T.EarCut.cureLocalIntersections=function(e,t,o){var r=e;do{var n=r.prev,a=r.next.next;T.EarCut.intersects(n,r,r.next,a)&&T.EarCut.locallyInside(n,a)&&T.EarCut.locallyInside(a,n)&&(t.push(n.i/o),t.push(r.i/o),t.push(a.i/o),T.EarCut.removeNode(r),T.EarCut.removeNode(r.next),r=e=a),r=r.next}while(r!==e);return r},T.EarCut.splitEarcut=function(e,t,o,r,n,i){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&T.EarCut.isValidDiagonal(s,a)){var d=T.EarCut.splitPolygon(s,a);return s=T.EarCut.filterPoints(s,s.next),d=T.EarCut.filterPoints(d,d.next),T.EarCut.earcutLinked(s,t,o,r,n,i),void T.EarCut.earcutLinked(d,t,o,r,n,i)}a=a.next}s=s.next}while(s!==e)},T.EarCut.eliminateHoles=function(e,t,a,o){var r=[],n,i,s,d,l;for(n=0,i=t.length;n<i;n++)s=t[n]*o,d=n<i-1?t[n+1]*o:e.length,l=T.EarCut.linkedList(e,s,d,o,!1),l===l.next&&(l.steiner=!0),r.push(T.EarCut.getLeftmost(l));for(r.sort(compareX),n=0;n<r.length;n++)T.EarCut.eliminateHole(r[n],a),a=T.EarCut.filterPoints(a,a.next);return a},T.EarCut.compareX=function(e,t){return e.x-t.x},T.EarCut.eliminateHole=function(e,t){if(t=T.EarCut.findHoleBridge(e,t),t){var a=T.EarCut.splitPolygon(t,e);T.EarCut.filterPoints(a,a.next)}},T.EarCut.findHoleBridge=function(e,t){var a=t,o=e.x,r=e.y,n=-Infinity,i;do{if(r<=a.y&&r>=a.next.y){var s=a.x+(r-a.y)*(a.next.x-a.x)/(a.next.y-a.y);s<=o&&s>n&&(n=s,i=a.x<a.next.x?a:a.next)}a=a.next}while(a!==t);if(!i)return null;if(e.x===i.x)return i.prev;var d=i,l=Infinity,p;for(a=i.next;a!==d;)o>=a.x&&a.x>=i.x&&T.EarCut.pointInTriangle(r<i.y?o:n,r,i.x,i.y,r<i.y?n:o,r,a.x,a.y)&&(p=f(r-a.y)/(o-a.x),(p<l||p===l&&a.x>i.x)&&T.EarCut.locallyInside(a,e)&&(i=a,l=p)),a=a.next;return i},T.EarCut.indexCurve=function(e,t,a,o){var r=e;do null===r.z&&(r.z=T.EarCut.zOrder(r.x,r.y,t,a,o)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,T.EarCut.sortLinked(r)},T.EarCut.sortLinked=function(t){var a=1,o,r,n,i,e,s,d,l;do{for(r=t,t=null,e=null,s=0;r;){for(s++,n=r,d=0,o=0;o<a&&(d++,n=n.nextZ,!!n);o++);for(l=a;0<d||0<l&&n;)0===d?(i=n,n=n.nextZ,l--):0!==l&&n?r.z<=n.z?(i=r,r=r.nextZ,d--):(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,d--),e?e.nextZ=i:t=i,i.prevZ=e,e=i;r=n}e.nextZ=null,a*=2}while(1<s);return t},T.EarCut.zOrder=function(e,t,a,o,r){return e=32767*(e-a)/r,t=32767*(t-o)/r,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1},T.EarCut.getLeftmost=function(e){var t=e,a=e;do t.x<a.x&&(a=t),t=t.next;while(t!==e);return a},T.EarCut.pointInTriangle=function(e,t,a,o,r,n,i,s){return 0<=(r-i)*(t-s)-(e-i)*(n-s)&&0<=(e-i)*(o-s)-(a-i)*(t-s)&&0<=(a-i)*(n-s)-(r-i)*(o-s)},T.EarCut.isValidDiagonal=function(e,t){return T.EarCut.equals(e,t)||e.next.i!==t.i&&e.prev.i!==t.i&&!T.EarCut.intersectsPolygon(e,t)&&T.EarCut.locallyInside(e,t)&&T.EarCut.locallyInside(t,e)&&T.EarCut.middleInside(e,t)},T.EarCut.area=function(e,t,a){return(t.y-e.y)*(a.x-t.x)-(t.x-e.x)*(a.y-t.y)},T.EarCut.equals=function(e,t){return e.x===t.x&&e.y===t.y},T.EarCut.intersects=function(e,t,a,o){return 0<T.EarCut.area(e,t,a)!=0<T.EarCut.area(e,t,o)&&0<T.EarCut.area(a,o,e)!=0<T.EarCut.area(a,o,t)},T.EarCut.intersectsPolygon=function(e,t){var a=e;do{if(a.i!==e.i&&a.next.i!==e.i&&a.i!==t.i&&a.next.i!==t.i&&T.EarCut.intersects(a,a.next,e,t))return!0;a=a.next}while(a!==e);return!1},T.EarCut.locallyInside=function(e,t){return 0>T.EarCut.area(e.prev,e,e.next)?0<=T.EarCut.area(e,t,e.next)&&0<=T.EarCut.area(e,e.prev,t):0>T.EarCut.area(e,t,e.prev)||0>T.EarCut.area(e,e.next,t)},T.EarCut.middleInside=function(e,t){var a=e,o=!1,r=(e.x+t.x)/2,n=(e.y+t.y)/2;do a.y>n!=a.next.y>n&&r<(a.next.x-a.x)*(n-a.y)/(a.next.y-a.y)+a.x&&(o=!o),a=a.next;while(a!==e);return o},T.EarCut.splitPolygon=function(e,t){var a=new T.EarCut.Node(e.i,e.x,e.y),o=new T.EarCut.Node(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,a.next=r,r.prev=a,o.next=a,a.prev=o,n.next=o,o.prev=n,o},T.EarCut.insertNode=function(e,t,a,o){var r=new T.EarCut.Node(e,t,a);return o?(r.next=o.next,r.prev=o,o.next.prev=r,o.next=r):(r.prev=r,r.next=r),r},T.EarCut.removeNode=function(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)},T.EarCut.Node=function(e,t,a){this.i=e,this.x=t,this.y=a,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(e,t){var a=t.gl,o=t.projection,r=t.offset,n=t.shaderManager.primitiveShader,s;e.dirty&&PIXI.WebGLGraphics.updateGraphics(e,a);var d=e._webGL[a.id];if(d)for(var l=0;l<d.data.length;l++)1===d.data[l].mode?(s=d.data[l],t.stencilManager.pushStencil(e,s,t),a.drawElements(a.TRIANGLE_FAN,4,a.UNSIGNED_SHORT,2*(s.indices.length-4)),t.stencilManager.popStencil(e,s,t)):(s=d.data[l],t.shaderManager.setShader(n),n=t.shaderManager.primitiveShader,a.uniformMatrix3fv(n.translationMatrix,!1,e.worldTransform.toArray(!0)),a.uniform1f(n.flipY,1),a.uniform2f(n.projectionVector,o.x,-o.y),a.uniform2f(n.offsetVector,-r.x,-r.y),a.uniform3fv(n.tintColor,T.Color.hexToRGBArray(e.tint)),a.uniform1f(n.alpha,e.worldAlpha),a.bindBuffer(a.ARRAY_BUFFER,s.buffer),a.vertexAttribPointer(n.aVertexPosition,2,a.FLOAT,!1,24,0),a.vertexAttribPointer(n.colorAttribute,4,a.FLOAT,!1,24,8),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,s.indexBuffer),a.drawElements(a.TRIANGLE_STRIP,s.indices.length,a.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(e,t){var a=e._webGL[t.id];a||(a=e._webGL[t.id]={lastIndex:0,data:[],gl:t}),e.dirty=!1;var o;if(e.clearDirty){for(e.clearDirty=!1,o=0;o<a.data.length;o++){var r=a.data[o];r.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(r)}a.data=[],a.lastIndex=0}var n;for(o=a.lastIndex;o<e.graphicsData.length;o++){var i=e.graphicsData[o];if(i.type===T.POLYGON){if(i.points=i.shape.points.slice(),i.shape.closed&&(i.points[0]!==i.points[i.points.length-2]||i.points[1]!==i.points[i.points.length-1])&&i.points.push(i.points[0],i.points[1]),i.fill&&i.points.length>=PIXI.WebGLGraphics.stencilBufferLimit)if(i.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit){n=PIXI.WebGLGraphics.switchMode(a,0);var s=PIXI.WebGLGraphics.buildPoly(i,n);s||(n=PIXI.WebGLGraphics.switchMode(a,1),PIXI.WebGLGraphics.buildComplexPoly(i,n))}else n=PIXI.WebGLGraphics.switchMode(a,1),PIXI.WebGLGraphics.buildComplexPoly(i,n);0<i.lineWidth&&(n=PIXI.WebGLGraphics.switchMode(a,0),PIXI.WebGLGraphics.buildLine(i,n))}else n=PIXI.WebGLGraphics.switchMode(a,0),i.type===T.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(i,n):i.type===T.CIRCLE||i.type===T.ELLIPSE?PIXI.WebGLGraphics.buildCircle(i,n):i.type===T.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(i,n);a.lastIndex++}for(o=0;o<a.data.length;o++)n=a.data[o],n.dirty&&n.upload()},PIXI.WebGLGraphics.switchMode=function(e,t){var a;return e.data.length?(a=e.data[e.data.length-1],(a.mode!==t||1===t)&&(a=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(e.gl),a.mode=t,e.data.push(a))):(a=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(e.gl),a.mode=t,e.data.push(a)),a.dirty=!0,a},PIXI.WebGLGraphics.buildRectangle=function(e,t){var a=e.shape,o=a.x,n=a.y,i=a.width,s=a.height;if(e.fill){var d=T.Color.hexToRGBArray(e.fillColor),l=e.fillAlpha,p=d[0]*l,r=d[1]*l,c=d[2]*l,u=t.points,h=t.indices,g=u.length/6;u.push(o,n),u.push(p,r,c,l),u.push(o+i,n),u.push(p,r,c,l),u.push(o,n+s),u.push(p,r,c,l),u.push(o+i,n+s),u.push(p,r,c,l),h.push(g,g,g+1,g+2,g+3,g+3)}if(e.lineWidth){var m=e.points;e.points=[o,n,o+i,n,o+i,n+s,o,n+s,o,n],PIXI.WebGLGraphics.buildLine(e,t),e.points=m}},PIXI.WebGLGraphics.buildRoundedRectangle=function(e,t){var a=e.shape,o=a.x,n=a.y,s=a.width,d=a.height,l=a.radius,p=[];if(p.push(o,n+l),p=p.concat(PIXI.WebGLGraphics.quadraticBezierCurve(o,n+d-l,o,n+d,o+l,n+d)),p=p.concat(PIXI.WebGLGraphics.quadraticBezierCurve(o+s-l,n+d,o+s,n+d,o+s,n+d-l)),p=p.concat(PIXI.WebGLGraphics.quadraticBezierCurve(o+s,n+l,o+s,n,o+s-l,n)),p=p.concat(PIXI.WebGLGraphics.quadraticBezierCurve(o+l,n,o,n,o,n+l)),e.fill){var c=T.Color.hexToRGBArray(e.fillColor),u=e.fillAlpha,h=c[0]*u,r=c[1]*u,g=c[2]*u,m=t.points,y=t.indices,f=m.length/6,x=T.EarCut.Triangulate(p,null,2),b=0;for(b=0;b<x.length;b+=3)y.push(x[b]+f),y.push(x[b]+f),y.push(x[b+1]+f),y.push(x[b+2]+f),y.push(x[b+2]+f);for(b=0;b<p.length;b++)m.push(p[b],p[++b],h,r,g,u)}if(e.lineWidth){var i=e.points;e.points=p,PIXI.WebGLGraphics.buildLine(e,t),e.points=i}},PIXI.WebGLGraphics.quadraticBezierCurve=function(e,t,a,o,r,s){function d(e,t,a){return e+(t-e)*a}for(var l=20,n=[],p=0,c=0,i,u,h,g,m,f;c<=l;c++)p=c/l,i=d(e,a,p),u=d(t,o,p),h=d(a,r,p),g=d(o,s,p),m=d(i,h,p),f=d(u,g,p),n.push(m,f);return n},PIXI.WebGLGraphics.buildCircle=function(e,t){var a=e.shape,o=a.x,n=a.y,s,l;e.type===T.CIRCLE?(s=a.radius,l=a.radius):(s=a.width,l=a.height);var p=40,c=2*d/p,u=0;if(e.fill){var i=T.Color.hexToRGBArray(e.fillColor),y=e.fillAlpha,f=i[0]*y,r=i[1]*y,g=i[2]*y,x=t.points,b=t.indices,_=x.length/6;for(b.push(_),u=0;u<p+1;u++)x.push(o,n,f,r,g,y),x.push(o+h(c*u)*s,n+m(c*u)*l,f,r,g,y),b.push(_++,_++);b.push(_-1)}if(e.lineWidth){var v=e.points;for(e.points=[],u=0;u<p+1;u++)e.points.push(o+h(c*u)*s,n+m(c*u)*l);PIXI.WebGLGraphics.buildLine(e,t),e.points=v}},PIXI.WebGLGraphics.buildLine=function(e,t){var a=0,o=e.points;if(0!==o.length){if(e.lineWidth%2)for(a=0;a<o.length;a++)o[a]+=0.5;var n=new PIXI.Point(o[0],o[1]),i=new PIXI.Point(o[o.length-2],o[o.length-1]);if(n.x===i.x&&n.y===i.y){o=o.slice(),o.pop(),o.pop(),i=new PIXI.Point(o[o.length-2],o[o.length-1]);var s=i.x+0.5*(n.x-i.x),d=i.y+0.5*(n.y-i.y);o.unshift(s,d),o.push(s,d)}var l=t.points,p=t.indices,c=o.length/2,u=o.length,h=l.length/6,m=e.lineWidth/2,y=T.Color.hexToRGBArray(e.lineColor),x=e.lineAlpha,v=y[0]*x,r=y[1]*x,g=y[2]*x,b,C,P,S,w,A,E,R,L,B,k,F,D,M,O,I,U,G,N,W,X,V,H;for(P=o[0],S=o[1],w=o[2],A=o[3],L=-(S-A),B=P-w,H=_(L*L+B*B),L/=H,B/=H,L*=m,B*=m,l.push(P-L,S-B,v,r,g,x),l.push(P+L,S+B,v,r,g,x),a=1;a<c-1;a++){if(P=o[2*(a-1)],S=o[2*(a-1)+1],w=o[2*a],A=o[2*a+1],E=o[2*(a+1)],R=o[2*(a+1)+1],L=-(S-A),B=P-w,H=_(L*L+B*B),L/=H,B/=H,L*=m,B*=m,k=-(A-R),F=w-E,H=_(k*k+F*F),k/=H,F/=H,k*=m,F*=m,O=-B+S-(-B+A),I=-L+w-(-L+P),U=(-L+P)*(-B+A)-(-L+w)*(-B+S),G=-F+R-(-F+A),N=-k+w-(-k+E),W=(-k+E)*(-F+A)-(-k+w)*(-F+R),X=O*N-G*I,0.1>f(X)){X+=10.1,l.push(w-L,A-B,v,r,g,x),l.push(w+L,A+B,v,r,g,x);continue}b=(I*W-N*U)/X,C=(G*U-O*W)/X,V=(b-w)*(b-w)+(C-A)+(C-A),19600<V?(D=L-k,M=B-F,H=_(D*D+M*M),D/=H,M/=H,D*=m,M*=m,l.push(w-D,A-M),l.push(v,r,g,x),l.push(w+D,A+M),l.push(v,r,g,x),l.push(w-D,A-M),l.push(v,r,g,x),u++):(l.push(b,C),l.push(v,r,g,x),l.push(w-(b-w),A-(C-A)),l.push(v,r,g,x))}for(P=o[2*(c-2)],S=o[2*(c-2)+1],w=o[2*(c-1)],A=o[2*(c-1)+1],L=-(S-A),B=P-w,H=_(L*L+B*B),L/=H,B/=H,L*=m,B*=m,l.push(w-L,A-B),l.push(v,r,g,x),l.push(w+L,A+B),l.push(v,r,g,x),p.push(h),a=0;a<u;a++)p.push(h++);p.push(h-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(e,t){var a=e.points.slice();if(!(6>a.length)){var o=t.indices;t.points=a,t.alpha=e.fillAlpha,t.color=T.Color.hexToRGBArray(e.fillColor);for(var r=Infinity,n=-Infinity,s=Infinity,d=-Infinity,l=0,i,p;l<a.length;l+=2)i=a[l],p=a[l+1],r=i<r?i:r,n=i>n?i:n,s=p<s?p:s,d=p>d?p:d;a.push(r,s,n,s,n,d,r,d);var c=a.length/2;for(l=0;l<c;l++)o.push(l)}},PIXI.WebGLGraphics.buildPoly=function(e,t){var a=e.points;if(!(6>a.length)){var o=t.points,n=t.indices,s=a.length/2,d=T.Color.hexToRGBArray(e.fillColor),l=e.fillAlpha,p=d[0]*l,r=d[1]*l,c=d[2]*l,u=T.EarCut.Triangulate(a,null,2);if(!u)return!1;var h=o.length/6,g=0;for(g=0;g<u.length;g+=3)n.push(u[g]+h),n.push(u[g]+h),n.push(u[g+1]+h),n.push(u[g+2]+h),n.push(u[g+2]+h);for(g=0;g<s;g++)o.push(a[2*g],a[2*g+1],p,r,c,l);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(e){this.gl=e,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var e=this.gl;this.glPoints=new Float32Array(this.points),e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,this.glPoints,e.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.glIndicies,e.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(e,t){var a=e.worldAlpha;e.dirty&&(this.updateGraphicsTint(e),e.dirty=!1);for(var o=0;o<e.graphicsData.length;o++){var r=e.graphicsData[o],n=r.shape,i=r._fillTint,s=r._lineTint;if(t.lineWidth=r.lineWidth,r.type===T.POLYGON){t.beginPath();var l=n.points;t.moveTo(l[0],l[1]);for(var c=1;c<l.length/2;c++)t.lineTo(l[2*c],l[2*c+1]);n.closed&&t.lineTo(l[0],l[1]),l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&t.closePath(),r.fill&&(t.globalAlpha=r.fillAlpha*a,t.fillStyle="#"+("00000"+(0|i).toString(16)).substr(-6),t.fill()),r.lineWidth&&(t.globalAlpha=r.lineAlpha*a,t.strokeStyle="#"+("00000"+(0|s).toString(16)).substr(-6),t.stroke())}else if(r.type===T.RECTANGLE)(r.fillColor||0===r.fillColor)&&(t.globalAlpha=r.fillAlpha*a,t.fillStyle="#"+("00000"+(0|i).toString(16)).substr(-6),t.fillRect(n.x,n.y,n.width,n.height)),r.lineWidth&&(t.globalAlpha=r.lineAlpha*a,t.strokeStyle="#"+("00000"+(0|s).toString(16)).substr(-6),t.strokeRect(n.x,n.y,n.width,n.height));else if(r.type===T.CIRCLE)t.beginPath(),t.arc(n.x,n.y,n.radius,0,2*d),t.closePath(),r.fill&&(t.globalAlpha=r.fillAlpha*a,t.fillStyle="#"+("00000"+(0|i).toString(16)).substr(-6),t.fill()),r.lineWidth&&(t.globalAlpha=r.lineAlpha*a,t.strokeStyle="#"+("00000"+(0|s).toString(16)).substr(-6),t.stroke());else if(r.type===T.ELLIPSE){var u=2*n.width,g=2*n.height,h=n.x-u/2,m=n.y-g/2;t.beginPath();var y=0.5522848,f=u/2*y,x=g/2*y,b=h+u,_=m+g,v=h+u/2,C=m+g/2;t.moveTo(h,C),t.bezierCurveTo(h,C-x,v-f,m,v,m),t.bezierCurveTo(v+f,m,b,C-x,b,C),t.bezierCurveTo(b,C+x,v+f,_,v,_),t.bezierCurveTo(v-f,_,h,C+x,h,C),t.closePath(),r.fill&&(t.globalAlpha=r.fillAlpha*a,t.fillStyle="#"+("00000"+(0|i).toString(16)).substr(-6),t.fill()),r.lineWidth&&(t.globalAlpha=r.lineAlpha*a,t.strokeStyle="#"+("00000"+(0|s).toString(16)).substr(-6),t.stroke())}else if(r.type===T.ROUNDEDRECTANGLE){var P=n.x,S=n.y,w=n.width,A=n.height,E=n.radius,R=0|p(w,A)/2;E=E>R?R:E,t.beginPath(),t.moveTo(P,S+E),t.lineTo(P,S+A-E),t.quadraticCurveTo(P,S+A,P+E,S+A),t.lineTo(P+w-E,S+A),t.quadraticCurveTo(P+w,S+A,P+w,S+A-E),t.lineTo(P+w,S+E),t.quadraticCurveTo(P+w,S,P+w-E,S),t.lineTo(P+E,S),t.quadraticCurveTo(P,S,P,S+E),t.closePath(),(r.fillColor||0===r.fillColor)&&(t.globalAlpha=r.fillAlpha*a,t.fillStyle="#"+("00000"+(0|i).toString(16)).substr(-6),t.fill()),r.lineWidth&&(t.globalAlpha=r.lineAlpha*a,t.strokeStyle="#"+("00000"+(0|s).toString(16)).substr(-6),t.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(e,t){var a=e.graphicsData.length;if(0!==a){t.beginPath();for(var o=0;o<a;o++){var r=e.graphicsData[o],n=r.shape;if(r.type===T.POLYGON){var i=n.points;t.moveTo(i[0],i[1]);for(var s=1;s<i.length/2;s++)t.lineTo(i[2*s],i[2*s+1]);i[0]===i[i.length-2]&&i[1]===i[i.length-1]&&t.closePath()}else if(r.type===T.RECTANGLE)t.rect(n.x,n.y,n.width,n.height),t.closePath();else if(r.type===T.CIRCLE)t.arc(n.x,n.y,n.radius,0,2*d),t.closePath();else if(r.type===T.ELLIPSE){var l=2*n.width,c=2*n.height,u=n.x-l/2,h=n.y-c/2,g=0.5522848,m=l/2*g,y=c/2*g,f=u+l,x=h+c,b=u+l/2,_=h+c/2;t.moveTo(u,_),t.bezierCurveTo(u,_-y,b-m,h,b,h),t.bezierCurveTo(b+m,h,f,_-y,f,_),t.bezierCurveTo(f,_+y,b+m,x,b,x),t.bezierCurveTo(b-m,x,u,_+y,u,_),t.closePath()}else if(r.type===T.ROUNDEDRECTANGLE){var v=n.x,C=n.y,P=n.width,S=n.height,w=n.radius,A=0|p(P,S)/2;w=w>A?A:w,t.moveTo(v,C+w),t.lineTo(v,C+S-w),t.quadraticCurveTo(v,C+S,v+w,C+S),t.lineTo(v+P-w,C+S),t.quadraticCurveTo(v+P,C+S,v+P,C+S-w),t.lineTo(v+P,C+w),t.quadraticCurveTo(v+P,C,v+P-w,C),t.lineTo(v+w,C),t.quadraticCurveTo(v,C,v,C+w),t.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(e){if(16777215!==e.tint)for(var t=(255&e.tint>>16)/255,a=(255&e.tint>>8)/255,o=(255&e.tint)/255,r=0;r<e.graphicsData.length;r++){var n=e.graphicsData[r],i=0|n.fillColor,s=0|n.lineColor;n._fillTint=(255*((255&i>>16)/255*t)<<16)+(255*((255&i>>8)/255*a)<<8)+255*((255&i)/255*o),n._lineTint=(255*((255&s>>16)/255*t)<<16)+(255*((255&s>>8)/255*a)<<8)+255*((255&s)/255*o)}},T.GraphicsData=function(e,t,a,o,r,n,i){this.lineWidth=e,this.lineColor=t,this.lineAlpha=a,this._lineTint=t,this.fillColor=o,this.fillAlpha=r,this._fillTint=o,this.fill=n,this.shape=i,this.type=i.type},T.GraphicsData.prototype.constructor=T.GraphicsData,T.GraphicsData.prototype.clone=function(){return new T.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},T.Graphics=function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=0),this.type=T.GRAPHICS,this.physicsType=T.SPRITE,this.anchor=new T.Point,PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new T.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,T.Component.Core.init.call(this,e,t,a,"",null)},T.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),T.Graphics.prototype.constructor=T.Graphics,T.Component.Core.install.call(T.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),T.Graphics.prototype.preUpdatePhysics=T.Component.PhysicsBody.preUpdate,T.Graphics.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.Graphics.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.Graphics.prototype.preUpdateCore=T.Component.Core.preUpdate,T.Graphics.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.Graphics.prototype.postUpdate=function(){T.Component.PhysicsBody.postUpdate.call(this),T.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var e=0;e<this.children.length;e++)this.children[e].postUpdate()},T.Graphics.prototype.destroy=function(e){this.clear(),T.Component.Destroy.prototype.destroy.call(this,e)},T.Graphics.prototype.drawTriangle=function(e,t){void 0===t&&(t=!1);var a=new T.Polygon(e);if(t){var o=new T.Point(this.game.camera.x-e[0].x,this.game.camera.y-e[0].y),r=new T.Point(e[1].x-e[0].x,e[1].y-e[0].y),n=new T.Point(e[1].x-e[2].x,e[1].y-e[2].y),i=n.cross(r);0<o.dot(i)&&this.drawPolygon(a)}else this.drawPolygon(a)},T.Graphics.prototype.drawTriangles=function(e,t,a){void 0===a&&(a=!1);var o=new T.Point,r=new T.Point,n=new T.Point,s=[],d;if(!t){if(e[0]instanceof T.Point)for(d=0;d<e.length/3;d++)this.drawTriangle([e[3*d],e[3*d+1],e[3*d+2]],a);else for(d=0;d<e.length/6;d++)o.x=e[6*d+0],o.y=e[6*d+1],r.x=e[6*d+2],r.y=e[6*d+3],n.x=e[6*d+4],n.y=e[6*d+5],this.drawTriangle([o,r,n],a);}else if(e[0]instanceof T.Point)for(d=0;d<t.length/3;d++)s.push(e[t[3*d]]),s.push(e[t[3*d+1]]),s.push(e[t[3*d+2]]),3===s.length&&(this.drawTriangle(s,a),s=[]);else for(d=0;d<t.length;d++)o.x=e[2*t[d]],o.y=e[2*t[d]+1],s.push(o.copyTo({})),3===s.length&&(this.drawTriangle(s,a),s=[])},T.Graphics.prototype.lineStyle=function(e,t,a){return this.lineWidth=e||0,this.lineColor=t||0,this.lineAlpha=void 0===a?1:a,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new T.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},T.Graphics.prototype.moveTo=function(e,t){return this.drawShape(new T.Polygon([e,t])),this},T.Graphics.prototype.lineTo=function(e,t){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(e,t),this.dirty=!0,this._boundsDirty=!0,this},T.Graphics.prototype.quadraticCurveTo=function(e,t,a,o){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var r=20,n=this.currentPath.shape.points,s,d;0===n.length&&this.moveTo(0,0);for(var l=n[n.length-2],p=n[n.length-1],c=0,u=1;u<=r;++u)c=u/r,s=l+(e-l)*c,d=p+(t-p)*c,n.push(s+(e+(a-e)*c-s)*c,d+(t+(o-t)*c-d)*c);return this.dirty=!0,this._boundsDirty=!0,this},T.Graphics.prototype.bezierCurveTo=function(e,t,a,o,r,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var d=20,n=this.currentPath.shape.points,l=n[n.length-2],p=n[n.length-1],c=0,u=1,i,h,g,m,y;u<=d;++u)c=u/d,i=1-c,h=i*i,g=h*i,m=c*c,y=m*c,n.push(g*l+3*h*c*e+3*i*m*a+y*r,g*p+3*h*c*t+3*i*m*o+y*s);return this.dirty=!0,this._boundsDirty=!0,this},T.Graphics.prototype.arcTo=function(e,t,a,o,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(e,t):this.moveTo(e,t);var i=this.currentPath.shape.points,s=i[i.length-2],d=i[i.length-1],l=d-t,p=s-e,c=o-t,u=a-e,h=f(l*u-p*c);if(1e-8>h||0===n)(i[i.length-2]!==e||i[i.length-1]!==t)&&i.push(e,t);else{var g=l*l+p*p,m=c*c+u*u,y=l*c+p*u,x=n*_(g)/h,b=n*_(m)/h,v=x*y/g,T=b*y/m,C=x*u+b*p,P=x*c+b*l,S=r(l*(b+v)-P,p*(b+v)-C),w=r(c*(x+T)-P,u*(x+T)-C);this.arc(C+e,P+t,n,S,w,p*c>u*l)}return this.dirty=!0,this._boundsDirty=!0,this},T.Graphics.prototype.arc=function(e,t,a,o,r,n,p){if(o===r)return this;void 0===n&&(n=!1),void 0===p&&(p=40),!n&&r<=o?r+=2*d:n&&o<=r&&(o+=2*d);var u=n?-1*(o-r):r-o,g=l(f(u)/(2*d))*p;if(0==u)return this;var y=e+m(o)*a,x=t+h(o)*a;n&&this.filling?this.moveTo(e,t):this.moveTo(y,x);for(var b=this.currentPath.shape.points,_=u/(2*g),v=m(_),T=h(_),C=g-1,P=0;P<=C;P++){var i=P+C%1/C*P,S=_+o+2*_*i,w=m(S),c=-h(S);b.push((v*w+T*c)*a+e,(v*-c+T*w)*a+t)}return this.dirty=!0,this._boundsDirty=!0,this},T.Graphics.prototype.beginFill=function(e,t){return this.filling=!0,this.fillColor=e||0,this.fillAlpha=void 0===t?1:t,this.currentPath&&2>=this.currentPath.shape.points.length&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},T.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},T.Graphics.prototype.drawRect=function(e,t,a,o){return this.drawShape(new T.Rectangle(e,t,a,o)),this},T.Graphics.prototype.drawRoundedRect=function(e,t,a,o,r){return this.drawShape(new T.RoundedRectangle(e,t,a,o,r)),this},T.Graphics.prototype.drawCircle=function(e,t,a){return this.drawShape(new T.Circle(e,t,a)),this},T.Graphics.prototype.drawEllipse=function(e,t,a,o){return this.drawShape(new T.Ellipse(e,t,a,o)),this},T.Graphics.prototype.drawPolygon=function(e){e instanceof T.Polygon&&(e=e.points);var t=e;if(!Array.isArray(t)){t=Array(arguments.length);for(var a=0;a<t.length;++a)t[a]=arguments[a]}return this.drawShape(new T.Polygon(t)),this},T.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this},T.Graphics.prototype.generateTexture=function(e,t,a){void 0===e&&(e=1),void 0===t&&(t=PIXI.scaleModes.DEFAULT),void 0===a&&(a=0);var o=this.getBounds();o.width+=a,o.height+=a;var r=new PIXI.CanvasBuffer(o.width*e,o.height*e),n=PIXI.Texture.fromCanvas(r.canvas,t);return n.baseTexture.resolution=e,r.context.scale(e,e),r.context.translate(-o.x,-o.y),PIXI.CanvasGraphics.renderGraphics(this,r.context),n},T.Graphics.prototype._renderWebGL=function(e){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,e);if(e.spriteBatch.stop(),e.blendModeManager.setBlendMode(this.blendMode),this._mask&&e.maskManager.pushMask(this._mask,e),this._filters&&e.filterManager.pushFilter(this._filterBlock),this.blendMode!==e.spriteBatch.currentBlendMode){e.spriteBatch.currentBlendMode=this.blendMode;var t=PIXI.blendModesWebGL[e.spriteBatch.currentBlendMode];e.spriteBatch.gl.blendFunc(t[0],t[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,e),this.children.length){e.spriteBatch.start();for(var a=0;a<this.children.length;a++)this.children[a]._renderWebGL(e);e.spriteBatch.stop()}this._filters&&e.filterManager.popFilter(),this._mask&&e.maskManager.popMask(this.mask,e),e.drawCount++,e.spriteBatch.start()}},T.Graphics.prototype._renderCanvas=function(e){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,e);var t=e.context,a=this.worldTransform;this.blendMode!==e.currentBlendMode&&(e.currentBlendMode=this.blendMode,t.globalCompositeOperation=PIXI.blendModesCanvas[e.currentBlendMode]),this._mask&&e.maskManager.pushMask(this._mask,e);var o=e.resolution,r=a.tx*e.resolution+e.shakeX,n=a.ty*e.resolution+e.shakeY;t.setTransform(a.a*o,a.b*o,a.c*o,a.d*o,r,n),PIXI.CanvasGraphics.renderGraphics(this,t);for(var s=0;s<this.children.length;s++)this.children[s]._renderCanvas(e);this._mask&&e.maskManager.popMask(e)}},T.Graphics.prototype.getBounds=function(e){if(this._currentBounds)return this._currentBounds;if(!this.renderable)return T.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var t=this._localBounds,o=t.x,r=t.width+t.x,n=t.y,i=t.height+t.y,s=e||this.worldTransform,l=s.a,a=s.b,p=s.c,c=s.d,d=s.tx,u=s.ty,h=l*r+p*i+d,g=c*i+a*r+u,m=l*o+p*i+d,y=c*i+a*o+u,f=l*o+p*n+d,x=c*n+a*o+u,b=l*r+p*n+d,_=c*n+a*r+u,v=h,C=g,P=h,S=g;return P=m<P?m:P,P=f<P?f:P,P=b<P?b:P,S=y<S?y:S,S=x<S?x:S,S=_<S?_:S,v=m>v?m:v,v=f>v?f:v,v=b>v?b:v,C=y>C?y:C,C=x>C?x:C,C=_>C?_:C,this._bounds.x=P,this._bounds.width=v-P,this._bounds.y=S,this._bounds.height=C-S,this._currentBounds=this._bounds,this._currentBounds},T.Graphics.prototype.getLocalBounds=function(){var e=this.worldTransform;this.worldTransform=T.identityMatrix;for(var t=0;t<this.children.length;t++)this.children[t].updateTransform();var a=this.getBounds();for(this.worldTransform=e,t=0;t<this.children.length;t++)this.children[t].updateTransform();return a},T.Graphics.prototype.containsPoint=function(e,t){void 0===t&&(t=new T.Point),this.worldTransform.applyInverse(e,t);for(var a=this.graphicsData,o=0,r;o<a.length;o++)if((r=a[o],!!r.fill)&&r.shape&&r.shape.contains(t.x,t.y))return!0;return!1},T.Graphics.prototype.updateLocalBounds=function(){var e=Infinity,t=-Infinity,a=Infinity,o=-Infinity;if(this.graphicsData.length)for(var r=0,n,i,s,d,l,p;r<this.graphicsData.length;r++){var c=this.graphicsData[r],u=c.type,h=c.lineWidth;if(n=c.shape,u===T.RECTANGLE||u===T.ROUNDEDRECTANGLE)s=n.x-h/2,d=n.y-h/2,l=n.width+h,p=n.height+h,e=s<e?s:e,t=s+l>t?s+l:t,a=d<a?d:a,o=d+p>o?d+p:o;else if(u===T.CIRCLE)s=n.x,d=n.y,l=n.radius+h/2,p=n.radius+h/2,e=s-l<e?s-l:e,t=s+l>t?s+l:t,a=d-p<a?d-p:a,o=d+p>o?d+p:o;else if(u===T.ELLIPSE)s=n.x,d=n.y,l=n.width+h/2,p=n.height+h/2,e=s-l<e?s-l:e,t=s+l>t?s+l:t,a=d-p<a?d-p:a,o=d+p>o?d+p:o;else{i=n.points;for(var g=0;g<i.length;g++)i[g]instanceof T.Point?(s=i[g].x,d=i[g].y):(s=i[g],d=i[g+1],g<i.length-1&&g++),e=s-h<e?s-h:e,t=s+h>t?s+h:t,a=d-h<a?d-h:a,o=d+h>o?d+h:o}}else e=0,t=0,a=0,o=0;var m=this.boundsPadding;this._localBounds.x=e-m,this._localBounds.width=t-e+2*m,this._localBounds.y=a-m,this._localBounds.height=o-a+2*m},T.Graphics.prototype._generateCachedSprite=function(){var e=this.getLocalBounds();if(!this._cachedSprite){var t=new PIXI.CanvasBuffer(e.width,e.height),a=PIXI.Texture.fromCanvas(t.canvas);this._cachedSprite=new PIXI.Sprite(a),this._cachedSprite.buffer=t,this._cachedSprite.worldTransform=this.worldTransform}else this._cachedSprite.buffer.resize(e.width,e.height);this._cachedSprite.anchor.x=-(e.x/e.width),this._cachedSprite.anchor.y=-(e.y/e.height),this._cachedSprite.buffer.context.translate(-e.x,-e.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},T.Graphics.prototype.updateCachedSpriteTexture=function(){var e=this._cachedSprite,t=e.texture,a=e.buffer.canvas;t.baseTexture.width=a.width,t.baseTexture.height=a.height,t.crop.width=t.frame.width=a.width,t.crop.height=t.frame.height=a.height,e._width=a.width,e._height=a.height,t.baseTexture.dirty()},T.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},T.Graphics.prototype.drawShape=function(e){this.currentPath&&2>=this.currentPath.shape.points.length&&this.graphicsData.pop(),this.currentPath=null,e instanceof T.Polygon&&(e=e.clone(),e.flatten());var t=new T.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,e);return this.graphicsData.push(t),t.type===T.POLYGON&&(t.shape.closed=this.filling,this.currentPath=t),this.dirty=!0,this._boundsDirty=!0,t},Object.defineProperty(T.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(e){this._cacheAsBitmap=e,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),T.RenderTexture=function(e,t,a,o,r,n,i,s){if(void 0===t&&(t=100),void 0===a&&(a=100),void 0===o&&(o=""),void 0===r&&(r=T.scaleModes.DEFAULT),void 0===n&&(n=1),void 0===i&&(i=PIXI.defaultRenderer),void 0===s&&(s=0),this.game=e,this.key=o,this.type=T.RENDERTEXTURE,this._tempMatrix=new T.Matrix,this.width=t,this.height=a,this.resolution=n,this.frame=new T.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=this.frame.clone(),this.baseTexture=new PIXI.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=r,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=i,this.renderer.type===T.WEBGL){var d=this.renderer.gl;this.baseTexture.textureIndex=s,this.baseTexture._dirty[d.id]=!1,this.textureBuffer=new PIXI.FilterTexture(d,this.width,this.height,this.baseTexture.scaleMode,s),this.baseTexture._glTextures[d.id]=this.textureBuffer.texture,this.projection=new T.Point(0.5*this.width,0.5*-this.height)}else this.textureBuffer=new PIXI.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new T.Matrix,this._updateUvs()},T.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),T.RenderTexture.prototype.constructor=T.RenderTexture,T.RenderTexture.prototype.renderXY=function(e,t,a,o){e.updateTransform(),this._tempMatrix.copyFrom(e.worldTransform),this._tempMatrix.tx=t,this._tempMatrix.ty=a,this.renderer.type===T.WEBGL?this._renderWebGL(e,this._tempMatrix,o):this._renderCanvas(e,this._tempMatrix,o)},T.RenderTexture.prototype.renderRawXY=function(e,t,a,o){this._tempMatrix.identity().translate(t,a),this.renderer.type===T.WEBGL?this._renderWebGL(e,this._tempMatrix,o):this._renderCanvas(e,this._tempMatrix,o)},T.RenderTexture.prototype.render=function(e,t,a){void 0===t||null===t?this._tempMatrix.copyFrom(e.worldTransform):this._tempMatrix.copyFrom(t),this.renderer.type===T.WEBGL?this._renderWebGL(e,this._tempMatrix,a):this._renderCanvas(e,this._tempMatrix,a)},T.RenderTexture.prototype.resize=function(e,t,a){(e!==this.width||t!==this.height)&&(this.valid=0<e&&0<t,this.width=e,this.height=t,this.frame.width=this.crop.width=e*this.resolution,this.frame.height=this.crop.height=t*this.resolution,a&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===T.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},T.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===T.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},T.RenderTexture.prototype._renderWebGL=function(e,t,a){if(this.valid&&0!==e.alpha){var o=e.worldTransform;o.identity(),o.translate(0,2*this.projection.y),t&&o.append(t),o.scale(1,-1);for(var r=0;r<e.children.length;r++)e.children[r].updateTransform();var n=this.renderer.gl;n.viewport(0,0,this.width*this.resolution,this.height*this.resolution),n.bindFramebuffer(n.FRAMEBUFFER,this.textureBuffer.frameBuffer),a&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(e,this.projection,this.textureBuffer.frameBuffer,t),this.renderer.spriteBatch.dirty=!0,n.bindFramebuffer(n.FRAMEBUFFER,null)}},T.RenderTexture.prototype._renderCanvas=function(e,t,a){if(this.valid&&0!==e.alpha){var o=e.worldTransform;o.identity(),t&&o.append(t);for(var r=0;r<e.children.length;r++)e.children[r].updateTransform();a&&this.textureBuffer.clear();var n=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(e,this.textureBuffer.context,t),this.renderer.resolution=n}},T.RenderTexture.prototype.getImage=function(){var e=new Image;return e.src=this.getBase64(),e},T.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},T.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===T.WEBGL){var e=this.renderer.gl,t=this.textureBuffer.width,a=this.textureBuffer.height,o=new Uint8Array(4*t*a);e.bindFramebuffer(e.FRAMEBUFFER,this.textureBuffer.frameBuffer),e.readPixels(0,0,t,a,e.RGBA,e.UNSIGNED_BYTE,o),e.bindFramebuffer(e.FRAMEBUFFER,null);var r=new PIXI.CanvasBuffer(t,a),n=r.context.getImageData(0,0,t,a);return n.data.set(o),r.context.putImageData(n,0,0),r.canvas}return this.textureBuffer.canvas},T.Text=function(e,t,a,o,r){t=t||0,a=a||0,o=void 0===o||null===o?"":o.toString(),r=T.Utils.extend({},r),this.type=T.TEXT,this.physicsType=T.SPRITE,this.padding=new T.Point,this.textBounds=null,this.canvas=T.CanvasPool.create(this),this.context=this.canvas.getContext("2d"),this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this.splitRegExp=/(?:\r\n|\r|\n)/,this.characterLimitSize=-1,this.characterLimitSuffix="",this._res=e.renderer.resolution,this._text=o,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,T.Sprite.call(this,e,t,a,PIXI.Texture.fromCanvas(this.canvas)),this.setStyle(r),""!==o&&this.updateText()},T.Text.prototype=Object.create(T.Sprite.prototype),T.Text.prototype.constructor=T.Text,T.Text.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.Text.prototype.update=function(){},T.Text.prototype.destroy=function(e){this.texture.destroy(!0),T.Component.Destroy.prototype.destroy.call(this,e)},T.Text.prototype.setShadow=function(e,t,a,o,r,n){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a="rgba(0, 0, 0, 1)"),void 0===o&&(o=0),void 0===r&&(r=!0),void 0===n&&(n=!0),this.style.shadowOffsetX=e,this.style.shadowOffsetY=t,this.style.shadowColor=a,this.style.shadowBlur=o,this.style.shadowStroke=r,this.style.shadowFill=n,this.dirty=!0,this},T.Text.prototype.setStyle=function(e,t){void 0===t&&(t=!1);var a=Object.assign({},e);a.font=e.font||"bold 20pt Arial",a.backgroundColor=e.backgroundColor||null,a.fill=e.fill||"black",a.align=(e.align||"left").toLowerCase(),a.boundsAlignH=(e.boundsAlignH||"left").toLowerCase(),a.boundsAlignV=(e.boundsAlignV||"top").toLowerCase(),a.stroke=e.stroke||"black",a.strokeThickness=+e.strokeThickness||0,a.wordWrap=e.wordWrap||!1,a.wordWrapWidth=e.wordWrapWidth||100,a.maxLines=e.maxLines||0,a.shadowOffsetX=e.shadowOffsetX||0,a.shadowOffsetY=e.shadowOffsetY||0,a.shadowColor=e.shadowColor||"rgba(0,0,0,0)",a.shadowBlur=e.shadowBlur||0,a.tabs=e.tabs||0;var o=this.fontToComponents(a.font);return a.fontStyle&&(o.fontStyle=a.fontStyle),a.fontVariant&&(o.fontVariant=a.fontVariant),a.fontWeight&&(o.fontWeight=a.fontWeight),a.fontSize&&("number"==typeof a.fontSize&&(a.fontSize+="px"),o.fontSize=a.fontSize),this._fontComponents=o,a.font=this.componentsToFont(this._fontComponents),this.style=a,this.dirty=!0,t&&this.updateText(),this},T.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var e=this.text;-1<this.characterLimitSize&&this.characterLimitSize<e.length&&(e=this.text.substring(0,this.characterLimitSize)+this.characterLimitSuffix),this.style.wordWrap&&(e=this.runWordWrap(this.text));var t=e.split(this.splitRegExp),a=this.style.tabs,o=[],r=0,d=this.determineFontProperties(this.style.font),p=t.length;0<this.style.maxLines&&this.style.maxLines<t.length&&(p=this.style.maxLines),this._charCount=0;for(var u=0;u<p;u++){if(0===a){var i=this.style.strokeThickness+this.padding.x;i+=0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.measureLine(t[u]):this.context.measureText(t[u]).width,this.style.wordWrap&&(i-=this.context.measureText(" ").width)}else{var h=t[u].split(/(?:\t)/),i=this.padding.x+this.style.strokeThickness;if(Array.isArray(a))for(var g=0,m=0,c;m<h.length;m++)c=0,c=0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.measureLine(h[m]):l(this.context.measureText(h[m]).width),0<m&&(g+=a[m-1]),i=g+c;else for(var m=0;m<h.length;m++){i+=0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.measureLine(h[m]):l(this.context.measureText(h[m]).width);var y=this.game.math.snapToCeil(i,a)-i;i+=y}}o[u]=l(i),r=s(r,o[u])}this.canvas.width=r*this._res;var x=d.fontSize+this.style.strokeThickness+this.padding.y,b=x*p,_=this._lineSpacing;0>_&&f(_)>x&&(_=-x),0!==_&&(b+=0<_?_*t.length:_*(t.length-1)),this.canvas.height=b*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var v,T;for(this._charCount=0,u=0;u<p;u++)v=this.style.strokeThickness/2,T=this.style.strokeThickness/2+u*x+d.ascent,0<u&&(T+=_*u),"right"===this.style.align?v+=r-o[u]:"center"===this.style.align&&(v+=(r-o[u])/2),this.autoRound&&(v=n(v),T=n(T)),0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.updateLine(t[u],v,T):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===a?this.context.strokeText(t[u],v,T):this.renderTabLine(t[u],v,T,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===a?this.context.fillText(t[u],v,T):this.renderTabLine(t[u],v,T,!0)));this.updateTexture(),this.dirty=!1},T.Text.prototype.renderTabLine=function(e,t,a,o){var r=e.split(/(?:\t)/),n=this.style.tabs,i=0;if(Array.isArray(n))for(var s=0,d=0;d<r.length;d++)0<d&&(s+=n[d-1]),i=t+s,o?this.context.fillText(r[d],i,a):this.context.strokeText(r[d],i,a);else for(var d=0,p;d<r.length;d++)p=l(this.context.measureText(r[d]).width),i=this.game.math.snapToCeil(t,n),o?this.context.fillText(r[d],i,a):this.context.strokeText(r[d],i,a),t=i+p},T.Text.prototype.updateShadow=function(e){e?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},T.Text.prototype.measureLine=function(e){for(var t=0,a=0,o;a<e.length;a++){if(o=e[a],0<this.fontWeights.length||0<this.fontStyles.length){var r=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(r.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(r.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(r)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),t+=this.context.measureText(o).width,this._charCount++}return l(t)},T.Text.prototype.updateLine=function(e,t,a){for(var o=0,r;o<e.length;o++){if(r=e[o],0<this.fontWeights.length||0<this.fontStyles.length){var n=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(n.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(n.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(n)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(r,t,a)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(r,t,a)),t+=this.context.measureText(r).width,this._charCount++}},T.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},T.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},T.Text.prototype.addColor=function(e,t){return this.colors[t]=e,this.dirty=!0,this},T.Text.prototype.addStrokeColor=function(e,t){return this.strokeColors[t]=e,this.dirty=!0,this},T.Text.prototype.addFontStyle=function(e,t){return this.fontStyles[t]=e,this.dirty=!0,this},T.Text.prototype.addFontWeight=function(e,t){return this.fontWeights[t]=e,this.dirty=!0,this},T.Text.prototype.precalculateWordWrap=function(e){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var t=this.runWordWrap(e);return t.split(/(?:\r\n|\r|\n)/)},T.Text.prototype.runWordWrap=function(e){return this.useAdvancedWrap?this.advancedWordWrap(e):this.basicWordWrap(e)},T.Text.prototype.advancedWordWrap=function(e){for(var t=this.context,a=this.style.wordWrapWidth,o="",r=e.replace(/ +/gi," ").split(/\r?\n/gi),n=r.length,s=0;s<n;s++){var i=r[s],d="";i=i.replace(/^ *|\s*$/gi,"");var l=t.measureText(i).width;if(l<a){o+=i+"\n";continue}for(var p=a,c=i.split(" "),u=0;u<c.length;u++){var h=c[u],g=h+" ",m=t.measureText(g).width;if(m>p){if(0===u){for(var y=g;y.length&&(y=y.slice(0,-1),m=t.measureText(y).width,!(m<=p)););if(!y.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var f=h.substr(y.length);c[u]=f,d+=y}var x=c[u].length?u:u+1,b=c.slice(x).join(" ").replace(/[ \n]*$/gi,"");r[s+1]=b+" "+(r[s+1]||""),n=r.length;break}else d+=g,p-=m}o+=d.replace(/[ \n]*$/gi,"")+"\n"}return o=o.replace(/[\s|\n]*$/gi,""),o},T.Text.prototype.basicWordWrap=function(e){for(var t="",a=e.split("\n"),o=0;o<a.length;o++){for(var r=this.style.wordWrapWidth,n=a[o].split(" "),i=0;i<n.length;i++){var s=this.context.measureText(n[i]).width,d=s+this.context.measureText(" ").width;d>r?(0<i&&(t+="\n"),t+=n[i]+" ",r=this.style.wordWrapWidth-s):(r-=d,t+=n[i]+" ")}o<a.length-1&&(t+="\n")}return t},T.Text.prototype.updateFont=function(e){var t=this.componentsToFont(e);this.style.font!==t&&(this.style.font=t,this.dirty=!0,this.parent&&this.updateTransform())},T.Text.prototype.fontToComponents=function(e){var t=e.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(t){var a=t[5].trim();return /^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(a)||/['",]/.exec(a)||(a="'"+a+"'"),{font:e,fontStyle:t[1]||"normal",fontVariant:t[2]||"normal",fontWeight:t[3]||"normal",fontSize:t[4]||"medium",fontFamily:a}}return console.warn("Phaser.Text - unparsable CSS font: "+e),{font:e}},T.Text.prototype.componentsToFont=function(e){var t=[],a;return a=e.fontStyle,a&&"normal"!==a&&t.push(a),a=e.fontVariant,a&&"normal"!==a&&t.push(a),a=e.fontWeight,a&&"normal"!==a&&t.push(a),a=e.fontSize,a&&"medium"!==a&&t.push(a),a=e.fontFamily,a&&t.push(a),t.length||t.push(e.font),t.join(" ")},T.Text.prototype.setText=function(e,t){return void 0===t&&(t=!1),this.text=e.toString()||"",t?this.updateText():this.dirty=!0,this},T.Text.prototype.parseList=function(e){if(!Array.isArray(e))return this;for(var t="",a=0;a<e.length;a++)Array.isArray(e[a])?(t+=e[a].join("\t"),a<e.length-1&&(t+="\n")):(t+=e[a],a<e.length-1&&(t+="\t"));return this.text=t,this.dirty=!0,this},T.Text.prototype.setTextBounds=function(e,t,a,o){return void 0===e?this.textBounds=null:(this.textBounds?this.textBounds.setTo(e,t,a,o):this.textBounds=new T.Rectangle(e,t,a,o),this.style.wordWrapWidth>a&&(this.style.wordWrapWidth=a)),this.updateTexture(),this},T.Text.prototype.updateTexture=function(){var e=this.texture.baseTexture,t=this.texture.crop,a=this.texture.frame,o=this.canvas.width,r=this.canvas.height;if(e.width=o,e.height=r,t.width=o,t.height=r,a.width=o,a.height=r,this.texture.width=o,this.texture.height=r,this._width=o,this._height=r,this.textBounds){var n=this.textBounds.x,i=this.textBounds.y;"right"===this.style.boundsAlignH?n+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(n+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?i+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(i+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-n,this.pivot.y=-i}this.renderable=0!==o&&0!==r,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},T.Text.prototype._renderWebGL=function(e){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,e)},T.Text.prototype._renderCanvas=function(e){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,e)},T.Text.prototype.determineFontProperties=function(e){var t=T.Text.fontPropertiesCache[e];if(!t){t={};var a=T.Text.fontPropertiesCanvas,o=T.Text.fontPropertiesContext;o.font=e;var r=l(o.measureText("|M\xC9q").width),n=l(o.measureText("|M\xC9q").width),s=2*n;if(n=0|1.4*n,a.width=r,a.height=s,o.fillStyle="#f00",o.fillRect(0,0,r,s),o.font=e,o.textBaseline="alphabetic",o.fillStyle="#000",o.fillText("|M\xC9q",0,n),!o.getImageData(0,0,r,s))return t.ascent=n,t.descent=n+6,t.fontSize=t.ascent+t.descent,T.Text.fontPropertiesCache[e]=t,t;var d=o.getImageData(0,0,r,s).data,p=d.length,c=4*r,u=0,h=!1,g,i;for(g=0;g<n;g++){for(i=0;i<c;i+=4)if(255!==d[u+i]){h=!0;break}if(!h)u+=c;else break}for(t.ascent=n-g,u=p-c,h=!1,g=s;g>n;g--){for(i=0;i<c;i+=4)if(255!==d[u+i]){h=!0;break}if(!h)u-=c;else break}t.descent=g-n,t.descent+=6,t.fontSize=t.ascent+t.descent,T.Text.fontPropertiesCache[e]=t}return t},T.Text.prototype.getBounds=function(e){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,e)},T.Text.prototype.setCharacterLimit=function(e,t){this.characterLimitSuffix=void 0===t?"":t,this.characterLimitSize=e,this.updateText()},Object.defineProperty(T.Text.prototype,"text",{get:function(){return this._text},set:function(e){e!==this._text&&(this._text=e.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(T.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(e){e=e||"bold 20pt Arial",this._fontComponents=this.fontToComponents(e),this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(e){e=e||"Arial",e=e.trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(e)||/['",]/.exec(e)||(e="'"+e+"'"),this._fontComponents.fontFamily=e,this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"fontSize",{get:function(){var e=this._fontComponents.fontSize;return e&&/(?:^0$|px$)/.exec(e)?parseInt(e,10):e},set:function(e){e=e||"0","number"==typeof e&&(e+="px"),this._fontComponents.fontSize=e,this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(e){e=e||"normal",this._fontComponents.fontWeight=e,this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(e){e=e||"normal",this._fontComponents.fontStyle=e,this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(e){e=e||"normal",this._fontComponents.fontVariant=e,this.updateFont(this._fontComponents)}}),Object.defineProperty(T.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(e){e!==this.style.fill&&(this.style.fill=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"align",{get:function(){return this.style.align},set:function(e){e=e.toLowerCase(),e!==this.style.align&&(this.style.align=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"resolution",{get:function(){return this._res},set:function(e){e!==this._res&&(this._res=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(e){e!==this.style.tabs&&(this.style.tabs=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(e){e=e.toLowerCase(),e!==this.style.boundsAlignH&&(this.style.boundsAlignH=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(e){e=e.toLowerCase(),e!==this.style.boundsAlignV&&(this.style.boundsAlignV=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(e){e!==this.style.stroke&&(this.style.stroke=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(e){e!==this.style.strokeThickness&&(this.style.strokeThickness=+e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(e){e!==this.style.wordWrap&&(this.style.wordWrap=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(e){e!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(e){e!==this._lineSpacing&&(this._lineSpacing=parseFloat(e),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(T.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(e){e!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(e){e!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(e){e!==this.style.shadowColor&&(this.style.shadowColor=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(e){e!==this.style.shadowBlur&&(this.style.shadowBlur=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(e){e!==this.style.shadowStroke&&(this.style.shadowStroke=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(e){e!==this.style.shadowFill&&(this.style.shadowFill=e,this.dirty=!0)}}),Object.defineProperty(T.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(e){this.scale.x=e/this.texture.frame.width,this._width=e}}),Object.defineProperty(T.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(e){this.scale.y=e/this.texture.frame.height,this._height=e}}),T.Text.fontPropertiesCache={},T.Text.fontPropertiesCanvas=document.createElement("canvas"),T.Text.fontPropertiesContext=T.Text.fontPropertiesCanvas.getContext("2d"),T.BitmapText=function(e,t,a,o,r,n,i){t=t||0,a=a||0,o=o||"",r=r||"",n=n||32,i=i||"left",PIXI.DisplayObjectContainer.call(this),this.type=T.BITMAPTEXT,this.physicsType=T.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new T.Point,this._prevAnchor=new T.Point,this._glyphs=[],this._maxWidth=0,this._text=r.toString()||"",this._data=e.cache.getBitmapFont(o),this._font=o,this._fontSize=n,this._align=i,this._tint=16777215,this.updateText(),this.dirty=!1,T.Component.Core.init.call(this,e,t,a,"",null)},T.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),T.BitmapText.prototype.constructor=T.BitmapText,T.Component.Core.install.call(T.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),T.BitmapText.prototype.preUpdatePhysics=T.Component.PhysicsBody.preUpdate,T.BitmapText.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.BitmapText.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.BitmapText.prototype.preUpdateCore=T.Component.Core.preUpdate,T.BitmapText.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.BitmapText.prototype.postUpdate=function(){T.Component.PhysicsBody.postUpdate.call(this),T.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===T.Physics.ARCADE&&(this.textWidth!==this.body.sourceWidth||this.textHeight!==this.body.sourceHeight)&&this.body.setSize(this.textWidth,this.textHeight)},T.BitmapText.prototype.setText=function(e){this.text=e},T.BitmapText.prototype.scanLine=function(e,t,a){for(var o=0,r=0,n=-1,s=0,d=null,l=0<this._maxWidth?this._maxWidth:null,p=[],u=0,i;u<a.length;u++){if(i=u===a.length-1,/(?:\r\n|\r|\n)/.test(a.charAt(u)))return{width:r,text:a.substr(0,u),end:i,chars:p};var h=a.charCodeAt(u),g=e.chars[h],m=0;void 0===g&&(h=32,g=e.chars[h]);var c=d&&g.kerning[d]?g.kerning[d]:0;if(/(\s)/.test(a.charAt(u))&&(n=u,s=r),m=(c+g.texture.width+g.xOffset)*t,l&&r+m>=l&&-1<n)return{width:s||r,text:a.substr(0,u-(u-n)),end:i,chars:p};r+=(g.xAdvance+c)*t,p.push(o+(g.xOffset+c)*t),o+=(g.xAdvance+c)*t,d=h}return{width:r,text:a,end:i,chars:p}},T.BitmapText.prototype.cleanText=function(e,t){void 0===t&&(t="");var a=this._data.font;if(!a)return"";for(var o=/\r\n|\n\r|\n|\r/g,r=e.replace(o,"\n").split("\n"),n=0;n<r.length;n++){for(var i="",s=r[n],d=0;d<s.length;d++)i=a.chars[s.charCodeAt(d)]?i.concat(s[d]):i.concat(t);r[n]=i}return r.join("\n")},T.BitmapText.prototype.updateText=function(){var e=this._data.font;if(e){var a=this.text,o=this._fontSize/e.size,r=[],n=0;this.textWidth=0;do{var s=this.scanLine(e,o,a);s.y=n,r.push(s),s.width>this.textWidth&&(this.textWidth=s.width),n+=e.lineHeight*o,a=a.substr(s.text.length+1)}while(!1===s.end);this.textHeight=n;for(var d=0,t=0,l=this.textWidth*this.anchor.x,p=this.textHeight*this.anchor.y,u=0,s;u<r.length;u++){s=r[u],"right"===this._align?t=this.textWidth-s.width:"center"===this._align&&(t=(this.textWidth-s.width)/2);for(var i=0;i<s.text.length;i++){var c=s.text.charCodeAt(i),h=e.chars[c];void 0===h&&(c=32,h=e.chars[c]);var m=this._glyphs[d];m?m.texture=h.texture:(m=new PIXI.Sprite(h.texture),m.name=s.text[i],this._glyphs.push(m)),m.position.x=s.chars[i]+t-l,m.position.y=s.y+h.yOffset*o-p,m.scale.set(o),m.tint=this.tint,m.texture.requiresReTint=!0,m.cachedTint=16777215,m.parent||this.addChild(m),d++}}for(u=d;u<this._glyphs.length;u++)this.removeChild(this._glyphs[u])}},T.BitmapText.prototype.purgeGlyphs=function(){for(var e=this._glyphs.length,t=[],a=0;a<this._glyphs.length;a++)this._glyphs[a].parent===this?t.push(this._glyphs[a]):this._glyphs[a].destroy();return this._glyphs=[],this._glyphs=t,this.updateText(),e-t.length},T.BitmapText.prototype.updateTransform=function(){(this.dirty||!this.anchor.equals(this._prevAnchor))&&(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(T.BitmapText.prototype,"align",{get:function(){return this._align},set:function(e){e!==this._align&&("left"===e||"center"===e||"right"===e)&&(this._align=e,this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(e){e!==this._tint&&(this._tint=e,this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"font",{get:function(){return this._font},set:function(e){e!==this._font&&(this._font=e.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(e){e=parseInt(e,10),e!==this._fontSize&&0<e&&(this._fontSize=e,this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"text",{get:function(){return this._text},set:function(e){e!==this._text&&(this._text=e.toString()||"",this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(e){e!==this._maxWidth&&(this._maxWidth=e,this.updateText())}}),Object.defineProperty(T.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(e){this._data.base.scaleMode=e?0:1}}),T.RetroFont=function(e,t,a,o,n,i,s,d,l,p){if(!e.cache.checkImageKey(t))return!1;(void 0===i||null===i)&&(i=e.cache.getImage(t).width/a),this.characterWidth=a,this.characterHeight=o,this.characterSpacingX=s||0,this.characterSpacingY=d||0,this.characterPerRow=i,this.offsetX=l||0,this.offsetY=p||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=e.cache.getImage(t),this._text="",this.grabData=[],this.frameData=new T.FrameData;for(var u=this.offsetX,h=this.offsetY,g=0,r=0,c;r<n.length;r++)c=this.frameData.addFrame(new T.Frame(r,u,h,this.characterWidth,this.characterHeight)),this.grabData[n.charCodeAt(r)]=c.index,g++,g===this.characterPerRow?(g=0,u=this.offsetX,h+=this.characterHeight+this.characterSpacingY):u+=this.characterWidth+this.characterSpacingX;e.cache.updateFrameData(t,this.frameData),this.stamp=new T.Image(e,0,0,t,0),T.RenderTexture.call(this,e,100,100,"",T.scaleModes.NEAREST),this.type=T.RETROFONT},T.RetroFont.prototype=Object.create(T.RenderTexture.prototype),T.RetroFont.prototype.constructor=T.RetroFont,T.RetroFont.ALIGN_LEFT="left",T.RetroFont.ALIGN_RIGHT="right",T.RetroFont.ALIGN_CENTER="center",T.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",T.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",T.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",T.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",T.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",T.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",T.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",T.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",T.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",T.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",T.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",T.RetroFont.prototype.setFixedWidth=function(e,t){void 0===t&&(t="left"),this.fixedWidth=e,this.align=t},T.RetroFont.prototype.setText=function(e,t,a,o,r,n){this.multiLine=t||!1,this.customSpacingX=a||0,this.customSpacingY=o||0,this.align=r||"left",this.autoUpperCase=!n,0<e.length&&(this.text=e)},T.RetroFont.prototype.buildRetroFontText=function(){var e=0,t=0;if(this.clear(),this.multiLine){var a=this._text.split("\n");0<this.fixedWidth?this.resize(this.fixedWidth,a.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),a.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var o=0;o<a.length;o++)e=0,this.align===T.RetroFont.ALIGN_RIGHT?e=this.width-a[o].length*(this.characterWidth+this.customSpacingX):this.align===T.RetroFont.ALIGN_CENTER&&(e=this.width/2-a[o].length*(this.characterWidth+this.customSpacingX)/2,e+=this.customSpacingX/2),0>e&&(e=0),this.pasteLine(a[o],e,t,this.customSpacingX),t+=this.characterHeight+this.customSpacingY}else 0<this.fixedWidth?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),e=0,this.align===T.RetroFont.ALIGN_RIGHT?e=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===T.RetroFont.ALIGN_CENTER&&(e=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,e+=this.customSpacingX/2),0>e&&(e=0),this.pasteLine(this._text,e,0,this.customSpacingX);this.requiresReTint=!0},T.RetroFont.prototype.pasteLine=function(e,t,a,o){for(var r=0;r<e.length;r++)if(" "===e.charAt(r))t+=this.characterWidth+o;else if(0<=this.grabData[e.charCodeAt(r)]&&(this.stamp.frame=this.grabData[e.charCodeAt(r)],this.renderXY(this.stamp,t,a,!1),t+=this.characterWidth+o,t>this.width))break},T.RetroFont.prototype.getLongestLine=function(){var e=0;if(0<this._text.length)for(var t=this._text.split("\n"),a=0;a<t.length;a++)t[a].length>e&&(e=t[a].length);return e},T.RetroFont.prototype.removeUnsupportedCharacters=function(e){for(var t="",a=0;a<this._text.length;a++){var o=this._text[a],r=o.charCodeAt(0);(0<=this.grabData[r]||!e&&"\n"===o)&&(t=t.concat(o))}return t},T.RetroFont.prototype.updateOffset=function(e,t){if(this.offsetX!==e||this.offsetY!==t){for(var a=e-this.offsetX,o=t-this.offsetY,r=this.game.cache.getFrameData(this.stamp.key).getFrames(),n=r.length;n--;)r[n].x+=a,r[n].y+=o;this.buildRetroFontText()}},Object.defineProperty(T.RetroFont.prototype,"text",{get:function(){return this._text},set:function(e){var t;t=this.autoUpperCase?e.toUpperCase():e,t!==this._text&&(this._text=t,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(T.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(e){this.stamp.smoothed=e,this.buildRetroFontText()}}),T.Rope=function(e,t,a,o,r,n){this.points=[],this.points=n,this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,t=t||0,a=a||0,o=o||null,r=r||null,this.type=T.ROPE,this.points=n,PIXI.DisplayObjectContainer.call(this),this.texture=T.Cache.DEFAULT,this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new Float32Array([0,0,100,0,100,100,0,100]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3]),n&&(this.vertices=new Float32Array(4*n.length),this.uvs=new Float32Array(4*n.length),this.colors=new Float32Array(2*n.length),this.indices=new Uint16Array(2*n.length)),this.dirty=!0,this.canvasPadding=0,this.drawMode=T.Rope.TRIANGLE_STRIP,T.Component.Core.init.call(this,e,t,a,o,r),this.refresh()},T.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),T.Rope.prototype.constructor=T.Rope,T.Component.Core.install.call(T.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),T.Rope.prototype.preUpdatePhysics=T.Component.PhysicsBody.preUpdate,T.Rope.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.Rope.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.Rope.prototype.preUpdateCore=T.Component.Core.preUpdate,T.Rope.TRIANGLE_STRIP=0,T.Rope.TRIANGLES=1,T.Rope.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},T.Rope.prototype.reset=function(e,t){return T.Component.Reset.prototype.reset.call(this,e,t),this},T.Rope.prototype.refresh=function(){var e=this.points;if(!(1>e.length)){var t=this.uvs,a=this.indices,o=this.colors;this.count-=0.2,t[0]=0,t[1]=0,t[2]=0,t[3]=1,o[0]=1,o[1]=1,a[0]=0,a[1]=1;for(var r=e.length,n=1,i,s;n<r;n++)i=4*n,s=n/(r-1),n%2?(t[i]=s,t[i+1]=0,t[i+2]=s,t[i+3]=1):(t[i]=s,t[i+1]=0,t[i+2]=s,t[i+3]=1),i=2*n,o[i]=1,o[i+1]=1,i=2*n,a[i]=i,a[i+1]=i+1}},T.Rope.prototype.updateTransform=function(){var e=this.points;if(!(1>e.length)){var t=e[0],a={x:0,y:0},o;this.count-=0.2;for(var r=this.vertices,n=e.length,s=0,i,d,l,p,c;s<n;s++)i=e[s],d=4*s,o=s<e.length-1?e[s+1]:i,a.y=-(o.x-t.x),a.x=o.y-t.y,l=10*(1-s/(n-1)),1<l&&(l=1),p=_(a.x*a.x+a.y*a.y),c=this.texture.height/2,a.x/=p,a.y/=p,a.x*=c,a.y*=c,r[d]=i.x+a.x,r[d+1]=i.y+a.y,r[d+2]=i.x-a.x,r[d+3]=i.y-a.y,t=i;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},T.Rope.prototype.setTexture=function(e){this.texture=e},T.Rope.prototype._renderWebGL=function(e){!this.visible||0>=this.alpha||(e.spriteBatch.stop(),!this._vertexBuffer&&this._initWebGL(e),e.shaderManager.setShader(e.shaderManager.stripShader),this._renderStrip(e),e.spriteBatch.start())},T.Rope.prototype._initWebGL=function(e){var t=e.gl;this._vertexBuffer=t.createBuffer(),this._indexBuffer=t.createBuffer(),this._uvBuffer=t.createBuffer(),this._colorBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this._uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvs,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this._colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colors,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW)},T.Rope.prototype._renderStrip=function(e){var t=e.gl,a=e.projection,o=e.offset,r=e.shaderManager.stripShader,n=this.drawMode===T.Rope.TRIANGLE_STRIP?t.TRIANGLE_STRIP:t.TRIANGLES;e.blendModeManager.setBlendMode(this.blendMode),t.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0)),t.uniform2f(r.projectionVector,a.x,-a.y),t.uniform2f(r.offsetVector,-o.x,-o.y),t.uniform1f(r.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.STATIC_DRAW),t.vertexAttribPointer(r.aVertexPosition,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvs,t.STATIC_DRAW),t.vertexAttribPointer(r.aTextureCoord,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),this.texture.baseTexture._dirty[t.id]?e.renderer.updateTexture(this.texture.baseTexture):t.bindTexture(t.TEXTURE_2D,this.texture.baseTexture._glTextures[t.id]),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW)):(t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices),t.vertexAttribPointer(r.aVertexPosition,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this._uvBuffer),t.vertexAttribPointer(r.aTextureCoord,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),this.texture.baseTexture._dirty[t.id]?e.renderer.updateTexture(this.texture.baseTexture):t.bindTexture(t.TEXTURE_2D,this.texture.baseTexture._glTextures[t.id]),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),t.drawElements(n,this.indices.length,t.UNSIGNED_SHORT,0)},T.Rope.prototype._renderCanvas=function(e){var t=e.context,a=this.worldTransform,o=a.tx*e.resolution+e.shakeX,r=a.ty*e.resolution+e.shakeY;e.roundPixels?t.setTransform(a.a,a.b,a.c,a.d,0|o,0|r):t.setTransform(a.a,a.b,a.c,a.d,o,r),this.drawMode===T.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(t):this._renderCanvasTriangles(t)},T.Rope.prototype._renderCanvasTriangleStrip=function(e){var t=this.vertices,a=this.uvs,o=t.length/2;this.count++;for(var r=0,n;r<o-2;r++)n=2*r,this._renderCanvasDrawTriangle(e,t,a,n,n+2,n+4)},T.Rope.prototype._renderCanvasTriangles=function(e){var t=this.vertices,a=this.uvs,o=this.indices,r=o.length;this.count++;for(var n=0;n<r;n+=3){var i=2*o[n],s=2*o[n+1],d=2*o[n+2];this._renderCanvasDrawTriangle(e,t,a,i,s,d)}},T.Rope.prototype._renderCanvasDrawTriangle=function(e,t,a,o,r,n){var i=this.texture.baseTexture.source,s=this.texture.width,d=this.texture.height,l=t[o],p=t[r],c=t[n],u=t[o+1],h=t[r+1],g=t[n+1],m=a[o]*s,y=a[r]*s,f=a[n]*s,x=a[o+1]*d,b=a[r+1]*d,v=a[n+1]*d;if(0<this.canvasPadding){var T=this.canvasPadding/this.worldTransform.a,C=this.canvasPadding/this.worldTransform.d,P=(l+p+c)/3,S=(u+h+g)/3,w=l-P,A=u-S,E=_(w*w+A*A);l=P+w/E*(E+T),u=S+A/E*(E+C),w=p-P,A=h-S,E=_(w*w+A*A),p=P+w/E*(E+T),h=S+A/E*(E+C),w=c-P,A=g-S,E=_(w*w+A*A),c=P+w/E*(E+T),g=S+A/E*(E+C)}e.save(),e.beginPath(),e.moveTo(l,u),e.lineTo(p,h),e.lineTo(c,g),e.closePath(),e.clip();var R=m*b+x*f+y*v-b*f-x*y-m*v,L=l*b+x*c+p*v-b*c-x*p-l*v,B=m*p+l*f+y*c-p*f-l*y-m*c,k=m*b*c+x*p*f+l*y*v-l*b*f-x*y*c-m*p*v,F=u*b+x*g+h*v-b*g-x*h-u*v,D=m*h+u*f+y*g-h*f-u*y-m*g,M=m*b*g+x*h*f+u*y*v-u*b*f-x*y*g-m*h*v;e.transform(L/R,F/R,B/R,D/R,k/R,M/R),e.drawImage(i,0,0),e.restore()},T.Rope.prototype.renderStripFlat=function(e){var t=this.context,a=e.vertices,o=a.length/2;this.count++,t.beginPath();for(var r=1;r<o-2;r++){var n=2*r,i=a[n],s=a[n+2],d=a[n+4],l=a[n+1],p=a[n+3],c=a[n+5];t.moveTo(i,l),t.lineTo(s,p),t.lineTo(d,c)}t.fillStyle="#FF0000",t.fill(),t.closePath()},T.Rope.prototype.getBounds=function(e){for(var t=e||this.worldTransform,o=t.a,a=t.b,r=t.c,n=t.d,s=t.tx,d=t.ty,l=-Infinity,p=-Infinity,c=Infinity,u=Infinity,h=this.vertices,g=0;g<h.length;g+=2){var i=h[g],m=h[g+1],f=o*i+r*m+s,x=n*m+a*i+d;c=f<c?f:c,u=x<u?x:u,l=f>l?f:l,p=x>p?x:p}if(c===-Infinity||p===Infinity)return PIXI.EmptyRectangle;var y=this._bounds;return y.x=c,y.width=l-c,y.y=u,y.height=p-u,this._currentBounds=y,y},Object.defineProperty(T.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(e){e&&"function"==typeof e?(this._hasUpdateAnimation=!0,this._updateAnimation=e):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(T.Rope.prototype,"segments",{get:function(){for(var e=[],t=0,a,o,r,n,i,s,d,l;t<this.points.length;t++)a=4*t,o=this.vertices[a]*this.scale.x,r=this.vertices[a+1]*this.scale.y,n=this.vertices[a+4]*this.scale.x,i=this.vertices[a+3]*this.scale.y,s=T.Math.difference(o,n),d=T.Math.difference(r,i),o+=this.world.x,r+=this.world.y,l=new T.Rectangle(o,r,s,d),e.push(l);return e}}),T.TileSprite=function(e,t,a,o,r,n,i){t=t||0,a=a||0,o=o||256,r=r||256,n=n||null,i=i||null,PIXI.Sprite.call(this,new PIXI.Texture(T.Cache.DEFAULT.baseTexture),o,r),this.type=T.TILESPRITE,this.physicsType=T.SPRITE,this._scroll=new T.Point,this.tileScale=new T.Point(1,1),this.tileScaleOffset=new T.Point(1,1),this.tilePosition=new T.Point,this.textureDebug=!1,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0,this._width=o,this._height=r,T.Component.Core.init.call(this,e,t,a,n,i)},T.TileSprite.prototype=Object.create(PIXI.Sprite.prototype),T.TileSprite.prototype.constructor=T.TileSprite,T.Component.Core.install.call(T.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),T.TileSprite.prototype.preUpdatePhysics=T.Component.PhysicsBody.preUpdate,T.TileSprite.prototype.preUpdateLifeSpan=T.Component.LifeSpan.preUpdate,T.TileSprite.prototype.preUpdateInWorld=T.Component.InWorld.preUpdate,T.TileSprite.prototype.preUpdateCore=T.Component.Core.preUpdate,T.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()&&this.preUpdateCore()},T.TileSprite.prototype.autoScroll=function(e,t){return this._scroll.set(e,t),this},T.TileSprite.prototype.stopScroll=function(){return this._scroll.set(0,0),this},T.TileSprite.prototype.destroy=function(e){T.Component.Destroy.prototype.destroy.call(this,e),PIXI.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},T.TileSprite.prototype.reset=function(e,t){return T.Component.Reset.prototype.reset.call(this,e,t),this.tilePosition.x=0,this.tilePosition.y=0,this},T.TileSprite.prototype.setTexture=function(e){return this.texture!==e&&(this.texture=e,this.refreshTexture=!0,this.cachedTint=16777215),this},T.TileSprite.prototype._renderWebGL=function(e){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(e.spriteBatch.stop(),e.maskManager.pushMask(this.mask,e),e.spriteBatch.start()),this._filters&&(e.spriteBatch.flush(),e.filterManager.pushFilter(this._filterBlock)),this.refreshTexture)if(this.generateTilingTexture(!0,e),this.tilingTexture)this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,e.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1);else return;e.spriteBatch.renderTilingSprite(this);for(var t=0;t<this.children.length;t++)this.children[t]._renderWebGL(e);var a=!1;this._filters&&(a=!0,e.spriteBatch.stop(),e.filterManager.popFilter()),this._mask&&(!a&&e.spriteBatch.stop(),e.maskManager.popMask(this._mask,e)),a&&e.spriteBatch.start()}},T.TileSprite.prototype._renderCanvas=function(e){if(this.visible&&this.renderable&&0!==this.alpha){var t=e.context;this._mask&&e.maskManager.pushMask(this._mask,e),t.globalAlpha=this.worldAlpha;var a=this.worldTransform,o=e.resolution,r=a.tx*o+e.shakeX,n=a.ty*o+e.shakeY;if(t.setTransform(a.a*o,a.b*o,a.c*o,a.d*o,r,n),16777215!==this.tint&&(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=PIXI.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1,this.refreshTexture=!0),this.refreshTexture)if(this.generateTilingTexture(!1,e),this.tilingTexture)this.tilePattern=t.createPattern(this.tilingTexture.baseTexture.source,"repeat");else return;var s=e.currentBlendMode;this.blendMode!==e.currentBlendMode&&(e.currentBlendMode=this.blendMode,t.globalCompositeOperation=PIXI.blendModesCanvas[e.currentBlendMode]);var d=this.tilePosition,l=this.tileScale;d.x%=this.tilingTexture.baseTexture.width,d.y%=this.tilingTexture.baseTexture.height,t.scale(l.x,l.y),t.translate(d.x+this.anchor.x*-this._width,d.y+this.anchor.y*-this._height),t.fillStyle=this.tilePattern,r=-d.x,n=-d.y;var p=this._width/l.x,c=this._height/l.y;e.roundPixels&&(r|=0,n|=0,p|=0,c|=0),t.fillRect(r,n,p,c),t.scale(1/l.x,1/l.y),t.translate(-d.x+this.anchor.x*this._width,-d.y+this.anchor.y*this._height),this._mask&&e.maskManager.popMask(e);for(var u=0;u<this.children.length;u++)this.children[u]._renderCanvas(e);s!==this.blendMode&&(e.currentBlendMode=s,t.globalCompositeOperation=PIXI.blendModesCanvas[s])}},T.TileSprite.prototype.onTextureUpdate=function(){},T.TileSprite.prototype.generateTilingTexture=function(e){if(this.texture.baseTexture.hasLoaded){var t=this.texture,a=t.frame,o=this._frame.sourceSizeW||this._frame.width,r=this._frame.sourceSizeH||this._frame.height,n=0,i=0;this._frame.trimmed&&(n=this._frame.spriteSourceSizeX,i=this._frame.spriteSourceSizeY),e&&(o=T.Math.getNextPowerOfTwo(o),r=T.Math.getNextPowerOfTwo(r)),this.canvasBuffer?(this.canvasBuffer.resize(o,r),this.tilingTexture.baseTexture.width=o,this.tilingTexture.baseTexture.height=r,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new PIXI.CanvasBuffer(o,r),this.tilingTexture=PIXI.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,this.tilingTexture.needsUpdate=!0),this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,o,r));var s=t.crop.width,d=t.crop.height;(s!==o||d!==r)&&(s=o,d=r);var l=this.tintedTexture?this.tintedTexture:t.baseTexture.source;this.canvasBuffer.context.drawImage(l,t.crop.x,t.crop.y,t.crop.width,t.crop.height,n,i,s,d),this.tileScaleOffset.x=a.width/o,this.tileScaleOffset.y=a.height/r,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},T.TileSprite.prototype.getBounds=function(){var e=this._width,t=this._height,o=e*(1-this.anchor.x),r=e*-this.anchor.x,n=t*(1-this.anchor.y),i=t*-this.anchor.y,s=this.worldTransform,l=s.a,a=s.b,p=s.c,c=s.d,d=s.tx,u=s.ty,h=l*r+p*i+d,g=c*i+a*r+u,m=l*o+p*i+d,y=c*i+a*o+u,f=l*o+p*n+d,x=c*n+a*o+u,b=l*r+p*n+d,_=c*n+a*r+u,v=-Infinity,T=-Infinity,C=Infinity,P=Infinity;C=h<C?h:C,C=m<C?m:C,C=f<C?f:C,C=b<C?b:C,P=g<P?g:P,P=y<P?y:P,P=x<P?x:P,P=_<P?_:P,v=h>v?h:v,v=m>v?m:v,v=f>v?f:v,v=b>v?b:v,T=g>T?g:T,T=y>T?y:T,T=x>T?x:T,T=_>T?_:T;var S=this._bounds;return S.x=C,S.width=v-C,S.y=P,S.height=T-P,this._currentBounds=S,S},Object.defineProperty(T.TileSprite.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(T.TileSprite.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),T.CanvasPool={create:function(e,t,a){var o=T.CanvasPool.getFirst(),r;if(-1===o){var n={parent:e,canvas:document.createElement("canvas")};T.CanvasPool.pool.push(n),r=n.canvas}else T.CanvasPool.pool[o].parent=e,r=T.CanvasPool.pool[o].canvas;return void 0!==t&&(r.width=t,r.height=a),r},getFirst:function(){for(var e=T.CanvasPool.pool,t=0;t<e.length;t++)if(!e[t].parent)return t;return-1},remove:function(e){for(var t=T.CanvasPool.pool,a=0;a<t.length;a++)t[a].parent===e&&(t[a].parent=null,t[a].canvas.width=1,t[a].canvas.height=1)},removeByCanvas:function(e){for(var t=T.CanvasPool.pool,a=0;a<t.length;a++)t[a].canvas===e&&(t[a].parent=null,t[a].canvas.width=1,t[a].canvas.height=1)},getTotal:function(){for(var e=T.CanvasPool.pool,t=0,a=0;a<e.length;a++)e[a].parent&&t++;return t},getFree:function(){for(var e=T.CanvasPool.pool,t=0,a=0;a<e.length;a++)e[a].parent||t++;return t},log:function(){console.log("CanvasPool: %s used, %s free, %s total",this.getTotal(),this.getFree(),this.pool.length)}},T.CanvasPool.pool=[],Object.defineProperty(T.CanvasPool,"length",{get:function(){return this.pool.length}}),T.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.iOSVersion=0,this.cocoonJS=!1,this.cocoonJSApp=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!1,this.electron=!1,this.ejecta=!1,this.crosswalk=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.canvasBitBltShift=null,this.canHandleAlpha=!1,this.canUseMultiply=!1,this.webGL=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.worker=!1,this.css3D=!1,this.pointerLock=!1,this.typedArray=!1,this.vibration=!1,this.getUserMedia=!0,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.chromeVersion=0,this.epiphany=!1,this.firefox=!1,this.firefoxVersion=0,this.ie=!1,this.ieVersion=0,this.trident=!1,this.tridentVersion=0,this.edge=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.safariVersion=0,this.webApp=!1,this.silk=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.oggVideo=!1,this.h264Video=!1,this.mp4Video=!1,this.webmVideo=!1,this.vp9Video=!1,this.hlsVideo=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this.LITTLE_ENDIAN=!1,this.support32bit=!1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1},T.Device=new T.Device,T.Device.onInitialized=new T.Signal,T.Device.whenReady=function(e,t,a){var o=this._readyCheck;if(this.deviceReadyAt||!o)e.call(t,this);else if(o._monitor||a)o._queue=o._queue||[],o._queue.push([e,t]);else{o._monitor=o.bind(this),o._queue=o._queue||[],o._queue.push([e,t]);var r="undefined"!=typeof window.cordova,n=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(o._monitor,0):r&&!n?document.addEventListener("deviceready",o._monitor,!1):(document.addEventListener("DOMContentLoaded",o._monitor,!1),window.addEventListener("load",o._monitor,!1))}},T.Device._readyCheck=function(){var e=this._readyCheck;if(!document.body)window.setTimeout(e._monitor,20);else if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",e._monitor),document.removeEventListener("DOMContentLoaded",e._monitor),window.removeEventListener("load",e._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var t;t=e._queue.shift();){var a=t[0],o=t[1];a.call(o,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}},T.Device._initialize=function(){function e(){var e=new ArrayBuffer(4),t=new Uint8Array(e),a=new Uint32Array(e);return t[0]=161,t[1]=178,t[2]=195,t[3]=212,3569595041===a[0]||2712847316!==a[0]&&null}function t(){if(void 0===Uint8ClampedArray)return!1;var e=T.CanvasPool.create(this,1,1),t=e.getContext("2d");if(!t)return!1;var a=t.createImageData(1,1);return T.CanvasPool.remove(this),a.data instanceof Uint8ClampedArray}var a=this;(function(){var e=navigator.userAgent;/Playstation Vita/.test(e)?a.vita=!0:/Kindle/.test(e)||/\bKF[A-Z][A-Z]+/.test(e)||/Silk.*Mobile Safari/.test(e)?a.kindle=!0:/Android/.test(e)?a.android=!0:/CrOS/.test(e)?a.chromeOS=!0:/iP[ao]d|iPhone/i.test(e)?(a.iOS=!0,navigator.appVersion.match(/OS (\d+)/),a.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(e)?a.linux=!0:/Mac OS/.test(e)?a.macOS=!0:/Windows/.test(e)&&(a.windows=!0),(/Windows Phone/i.test(e)||/IEMobile/i.test(e))&&(a.android=!1,a.iOS=!1,a.macOS=!1,a.windows=!0,a.windowsPhone=!0);var t=/Silk/.test(e);(a.windows||a.macOS||a.linux&&!t||a.chromeOS)&&(a.desktop=!0),(a.windowsPhone||/Windows NT/i.test(e)&&/Touch/i.test(e))&&(a.desktop=!1)})(),function(){var e=navigator.userAgent;if(/Arora/.test(e)?a.arora=!0:/Edge\/\d+/.test(e)?a.edge=!0:/Chrome\/(\d+)/.test(e)&&!a.windowsPhone?(a.chrome=!0,a.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(e)?a.epiphany=!0:/Firefox\D+(\d+)/.test(e)?(a.firefox=!0,a.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(e)&&a.iOS?a.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(e)?(a.ie=!0,a.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(e)?a.midori=!0:/Opera/.test(e)?a.opera=!0:/Safari\/(\d+)/.test(e)&&!a.windowsPhone?(a.safari=!0,/Version\/(\d+)\./.test(e)&&(a.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(e)&&(a.ie=!0,a.trident=!0,a.tridentVersion=parseInt(RegExp.$1,10),a.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(e)&&(a.silk=!0),navigator.standalone&&(a.webApp=!0),"undefined"!=typeof window.cordova&&(a.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(a.node=!0),a.node&&"object"==typeof process.versions&&(a.nodeWebkit=!!process.versions["node-webkit"],a.electron=!!process.versions.electron),navigator.isCocoonJS&&(a.cocoonJS=!0),a.cocoonJS)try{a.cocoonJSApp="undefined"!=typeof CocoonJS}catch(e){a.cocoonJSApp=!1}"undefined"!=typeof window.ejecta&&(a.ejecta=!0),/Crosswalk/.test(e)&&(a.crosswalk=!0)}(),function(){a.audioData=!!window.Audio,a.webAudio=!!(window.AudioContext||window.webkitAudioContext);var e=document.createElement("audio"),t=!1;try{if((t=!!e.canPlayType)&&(e.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/,"")&&(a.ogg=!0),(e.canPlayType("audio/ogg; codecs=\"opus\"").replace(/^no$/,"")||e.canPlayType("audio/opus;").replace(/^no$/,""))&&(a.opus=!0),e.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(a.mp3=!0),e.canPlayType("audio/wav; codecs=\"1\"").replace(/^no$/,"")&&(a.wav=!0),(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/aac;").replace(/^no$/,""))&&(a.m4a=!0),e.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/,"")&&(a.webm=!0),""!==e.canPlayType("audio/mp4;codecs=\"ec-3\"")))if(a.edge)a.dolby=!0;else if(a.safari&&9<=a.safariVersion&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var o=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===o&&11<=r||10<o)&&(a.dolby=!0)}}catch(t){}}(),function(){var e=document.createElement("video"),t=!1;try{(t=!!e.canPlayType)&&(e.canPlayType("video/ogg; codecs=\"theora\"").replace(/^no$/,"")&&(a.oggVideo=!0),e.canPlayType("video/mp4; codecs=\"avc1.42E01E\"").replace(/^no$/,"")&&(a.h264Video=!0,a.mp4Video=!0),e.canPlayType("video/webm; codecs=\"vp8, vorbis\"").replace(/^no$/,"")&&(a.webmVideo=!0),e.canPlayType("video/webm; codecs=\"vp9\"").replace(/^no$/,"")&&(a.vp9Video=!0),e.canPlayType("application/x-mpegURL; codecs=\"avc1.42E01E\"").replace(/^no$/,"")&&(a.hlsVideo=!0))}catch(t){}}(),function(){var e=document.createElement("p"),o={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"},r;for(var n in document.body.insertBefore(e,null),o)void 0!==e.style[n]&&(e.style[n]="translate3d(1px,1px,1px)",r=window.getComputedStyle(e).getPropertyValue(o[n]));document.body.removeChild(e),a.css3D=void 0!==r&&0<r.length&&"none"!==r}(),function(){a.pixelRatio=window.devicePixelRatio||1,a.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),a.iPhone4=2===a.pixelRatio&&a.iPhone,a.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"),a.typedArray="undefined"!=typeof Int8Array,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(a.littleEndian=e(),a.LITTLE_ENDIAN=a.littleEndian),a.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==a.littleEndian&&t(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(a.vibration=!0)}(),function(){a.canvas=!!window.CanvasRenderingContext2D||a.cocoonJS;try{a.localStorage=!!localStorage.getItem}catch(e){a.localStorage=!1}a.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob,a.fileSystem=!!window.requestFileSystem,a.webGL=function(){try{var e=document.createElement("canvas");return e.screencanvas=!1,!!window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl"))}catch(t){return!1}}(),a.webGL=!!a.webGL,a.worker=!!window.Worker,a.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,a.quirksMode="CSS1Compat"!==document.compatMode,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,a.getUserMedia=a.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,a.firefox&&21>a.firefoxVersion&&(a.getUserMedia=!1),!a.iOS&&(a.ie||a.firefox||a.chrome)&&(a.canvasBitBltShift=!0),(a.safari||a.mobileSafari)&&(a.canvasBitBltShift=!1)}(),function(){var e=T.CanvasPool.create(this,6,1),t=e.getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var o=t.getImageData(0,0,1,1);if(o){t.putImageData(o,1,0);var r=t.getImageData(1,0,1,1);a.canHandleAlpha=r.data[0]===o.data[0]&&r.data[1]===o.data[1]&&r.data[2]===o.data[2]&&r.data[3]===o.data[3]}t.globalCompositeOperation="multiply",a.canUseMultiply="multiply"===t.globalCompositeOperation,T.CanvasPool.removeByCanvas(e),PIXI.CanvasTinter.tintMethod=a.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],t=document.createElement("div"),o=0;o<e.length;o++)if(t[e[o]]){a.fullscreen=!0,a.requestFullscreen=e[o];break}var r=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(a.fullscreen)for(var o=0;o<r.length;o++)if(document[r[o]]){a.cancelFullscreen=r[o];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(a.fullscreenKeyboard=!0)}(),function(){("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&1<=window.navigator.maxTouchPoints)&&(a.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(a.mspointer=!0),a.cocoonJS||("onwheel"in window||a.ie&&"WheelEvent"in window?a.wheelEvent="wheel":"onmousewheel"in window?a.wheelEvent="mousewheel":a.firefox&&"MouseScrollEvent"in window&&(a.wheelEvent="DOMMouseScroll"))}()},T.Device.canPlayAudio=function(e){return"mp3"===e&&this.mp3||"ogg"===e&&(this.ogg||this.opus)||"m4a"===e&&this.m4a||"opus"===e&&this.opus||"wav"===e&&this.wav||"webm"===e&&this.webm||"mp4"===e&&this.dolby},T.Device.canPlayVideo=function(e){return"webm"===e&&(this.webmVideo||this.vp9Video)||"mp4"===e&&(this.mp4Video||this.h264Video)||("ogg"===e||"ogv"===e)&&this.oggVideo||"mpeg"===e&&this.hlsVideo},T.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},T.Device.isConsoleOpen=function(){return console.warn("Phaser.Device.isConsoleOpen is deprecated and will be removed."),!1},T.Device.isAndroidStockBrowser=function(){var e=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return e&&537>e[1]},T.Canvas={create:function(e,t,a,o,r){t=t||256,a=a||256;var n=r?document.createElement("canvas"):T.CanvasPool.create(e,t,a);return"string"==typeof o&&""!==o&&(n.id=o),n.width=t,n.height=a,n.style.display="block",n},setBackgroundColor:function(e,t){return t=t||"rgb(0,0,0)",e.style.backgroundColor=t,e},setTouchAction:function(e,t){return t=t||"none",e.style.msTouchAction=t,e.style["ms-touch-action"]=t,e.style["touch-action"]=t,e},setUserSelect:function(e,t){return t=t||"none",e.style["-webkit-touch-callout"]=t,e.style["-webkit-user-select"]=t,e.style["-khtml-user-select"]=t,e.style["-moz-user-select"]=t,e.style["-ms-user-select"]=t,e.style["user-select"]=t,e.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",e},addToDOM:function(e,t,a){var o;return void 0===a&&(a=!0),t&&("string"==typeof t?o=document.getElementById(t):"object"==typeof t&&1===t.nodeType&&(o=t)),o||(o=document.body),a&&o.style&&(o.style.overflow="hidden"),o.appendChild(e),e},removeFromDOM:function(e){e.parentNode&&e.parentNode.removeChild(e)},setTransform:function(e,t,a,o,r,n,i){return e.setTransform(o,n,i,r,t,a),e},setSmoothingEnabled:function(e,t){var a=T.Canvas.getSmoothingPrefix(e);return a&&(e[a]=t),e},getSmoothingPrefix:function(e){var t=["i","webkitI","msI","mozI","oI"];for(var a in t){var o=t[a]+"mageSmoothingEnabled";if(o in e)return o}return null},getSmoothingEnabled:function(e){var t=T.Canvas.getSmoothingPrefix(e);if(t)return e[t]},setImageRenderingCrisp:function(e){for(var t=["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"],a=0;a<t.length;a++)e.style["image-rendering"]=t[a];return e.style.msInterpolationMode="nearest-neighbor",e},setImageRenderingBicubic:function(e){return e.style["image-rendering"]="auto",e.style.msInterpolationMode="bicubic",e}},T.RequestAnimationFrame=function(e,t){void 0===t&&(t=!1),this.game=e,this.isRunning=!1,this.forceSetTimeOut=t;for(var a=["ms","moz","webkit","o"],o=0;o<a.length&&!window.requestAnimationFrame;o++)window.requestAnimationFrame=window[a[o]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[a[o]+"CancelAnimationFrame"]||window[a[o]+"CancelRequestAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},T.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var e=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return e.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(t){return e.updateRAF(t)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(e){this.isRunning&&(this.game.update(c(e)),this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateSetTimeout:function(){this.isRunning&&(this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall))},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID),this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return!1===this._isSetTimeOut}},T.RequestAnimationFrame.prototype.constructor=T.RequestAnimationFrame,T.Math={PI2:2*d,HALF_PI:0.5*d,DEG_TO_RAD:d/180,RAD_TO_DEG:180/d,degToRad:function(e){return e*T.Math.DEG_TO_RAD},radToDeg:function(e){return e*T.Math.RAD_TO_DEG},getNextPowerOfTwo:function(e){if(0<e&&0==(e&e-1))return e;for(var t=1;t<e;)t<<=1;return t},isPowerOfTwo:function(e,t){return 0<e&&0==(e&e-1)&&0<t&&0==(t&t-1)},random:function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=1),e===t)return e;if(e>t){var a=e;e=t,t=a}return Math.random()*(t-e)+e},between:function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=1),e===t)return e;if(e>t){var a=e;e=t,t=a}return e=l(e),t=c(t),c(Math.random()*(t-e+1))+e},fuzzyEqual:function(e,t,a){return void 0===a&&(a=1e-4),f(e-t)<a},fuzzyLessThan:function(e,t,a){return void 0===a&&(a=1e-4),e<t+a},fuzzyGreaterThan:function(e,t,a){return void 0===a&&(a=1e-4),e>t-a},fuzzyCeil:function(e,t){return void 0===t&&(t=1e-4),l(e-t)},fuzzyFloor:function(e,t){return void 0===t&&(t=1e-4),c(e+t)},average:function(){for(var e=0,t=arguments.length,a=0;a<t;a++)e+=+arguments[a];return e/t},shear:function(e){return e%1},snapTo:function(e,t,a){return(void 0===a&&(a=0),0===t)?e:(e-=a,e=t*n(e/t),a+e)},snapToFloor:function(e,t,a){return(void 0===a&&(a=0),0===t)?e:(e-=a,e=t*c(e/t),a+e)},snapToCeil:function(e,t,a){return(void 0===a&&(a=0),0===t)?e:(e-=a,e=t*l(e/t),a+e)},roundTo:function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=10);var o=u(a,-t);return n(e*o)/o},floorTo:function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=10);var o=u(a,-t);return c(e*o)/o},ceilTo:function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=10);var o=u(a,-t);return l(e*o)/o},rotateToAngle:function(e,t,a){return(void 0===a&&(a=0.05),e===t)?e:(f(t-e)<=a||f(t-e)>=T.Math.PI2-a?e=t:(f(t-e)>d&&(t<e?t+=T.Math.PI2:t-=T.Math.PI2),t>e?e+=a:t<e&&(e-=a)),e)},getShortestAngle:function(e,t){var a=t-e;if(0==a)return 0;var o=c((a- -180)/360);return a-360*o},angleBetween:function(e,t,a,o){return r(o-t,a-e)},angleBetweenY:function(e,t,a,o){return r(a-e,o-t)},angleBetweenPoints:function(e,t){return r(t.y-e.y,t.x-e.x)},angleBetweenPointsY:function(e,t){return r(t.x-e.x,t.y-e.y)},reverseAngle:function(e){return this.normalizeAngle(e+d,!0)},normalizeAngle:function(e){return e%=2*d,0<=e?e:e+2*d},maxAdd:function(e,t,a){return p(e+t,a)},minSub:function(e,t,a){return s(e-t,a)},wrap:function(e,t,a){var o=a-t;if(0>=o)return 0;var r=(e-t)%o;return 0>r&&(r+=o),r+t},wrapValue:function(e,t,a){var o;return e=f(e),t=f(t),a=f(a),o=(e+t)%a,o},isOdd:function(e){return!!(1&e)},isEven:function(e){return!(1&e)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])var e=arguments[0];else var e=arguments;for(var t=1,a=0,o=e.length;t<o;t++)e[t]<e[a]&&(a=t);return e[a]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])var e=arguments[0];else var e=arguments;for(var t=1,a=0,o=e.length;t<o;t++)e[t]>e[a]&&(a=t);return e[a]},minProperty:function(e){if(2===arguments.length&&"object"==typeof arguments[1])var t=arguments[1];else var t=arguments.slice(1);for(var a=1,o=0,r=t.length;a<r;a++)t[a][e]<t[o][e]&&(o=a);return t[o][e]},maxProperty:function(e){if(2===arguments.length&&"object"==typeof arguments[1])var t=arguments[1];else var t=arguments.slice(1);for(var a=1,o=0,r=t.length;a<r;a++)t[a][e]>t[o][e]&&(o=a);return t[o][e]},wrapAngle:function(e,t){return t?this.wrap(e,-d,Math.PI):this.wrap(e,-180,180)},linearInterpolation:function(e,t){var a=e.length-1,o=a*t,r=c(o);return 0>t?this.linear(e[0],e[1],o):1<t?this.linear(e[a],e[a-1],a-o):this.linear(e[r],e[r+1>a?a:r+1],o-r)},bezierInterpolation:function(e,t){for(var a=0,o=e.length-1,r=0;r<=o;r++)a+=u(1-t,o-r)*u(t,r)*e[r]*this.bernstein(o,r);return a},catmullRomInterpolation:function(e,t){var a=e.length-1,o=a*t,r=c(o);return e[0]===e[a]?(0>t&&(r=c(o=a*(1+t))),this.catmullRom(e[(r-1+a)%a],e[r],e[(r+1)%a],e[(r+2)%a],o-r)):0>t?e[0]-(this.catmullRom(e[0],e[0],e[1],e[1],-o)-e[0]):1<t?e[a]-(this.catmullRom(e[a],e[a],e[a-1],e[a-1],o-a)-e[a]):this.catmullRom(e[r?r-1:0],e[r],e[a<r+1?a:r+1],e[a<r+2?a:r+2],o-r)},linear:function(e,a,o){return(a-e)*o+e},bernstein:function(e,t){return this.factorial(e)/this.factorial(t)/this.factorial(e-t)},factorial:function(e){if(0===e)return 1;for(var t=e;--e;)t*=e;return t},catmullRom:function(e,a,o,r,n){var t=0.5*(o-e),i=0.5*(r-a),s=n*n;return(2*a-2*o+t+i)*(n*s)+(-3*a+3*o-2*t-i)*s+t*n+a},difference:function(e,t){return f(e-t)},roundAwayFromZero:function(e){return 0<e?l(e):c(e)},sinCosGenerator:function(e,t,a,o){void 0===t&&(t=1),void 0===a&&(a=1),void 0===o&&(o=1);for(var r=t,n=a,i=o*d/e,s=[],l=[],p=0;p<e;p++)n-=r*i,r+=n*i,s[p]=n,l[p]=r;return{sin:l,cos:s,length:e}},hypot:function(e,t){return _(e*e+t*t)},distance:function(e,t,a,o){var r=e-a,n=t-o;return _(r*r+n*n)},distanceSq:function(e,t,a,o){var r=e-a,n=t-o;return r*r+n*n},distancePow:function(e,t,a,o,r){return void 0===r&&(r=2),_(u(a-e,r)+u(o-t,r))},clamp:function(e,t,a){return e<t?t:a<e?a:e},clampBottom:function(e,t){return e<t?t:e},within:function(e,t,a){return f(e-t)<=a},mapLinear:function(e,t,a,o,r){return o+(e-t)*(r-o)/(a-t)},smoothstep:function(e,t,a){return e=s(0,p(1,(e-t)/(a-t))),e*e*(3-2*e)},smootherstep:function(e,t,a){return e=s(0,p(1,(e-t)/(a-t))),e*e*e*(e*(6*e-15)+10)},sign:function(e){return 0>e?-1:0<e?1:0},percent:function(e,t,a){return void 0===a&&(a=0),e>t||a>t?1:e<a||a>e?0:(e-a)/t}},T.RandomDataGenerator=function(e){void 0===e&&(e=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof e?this.state(e):this.sow(e)},T.RandomDataGenerator.prototype={rnd:function(){var e=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|e,this.s0=this.s1,this.s1=this.s2,this.s2=e-this.c,this.s2},sow:function(e){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,!!e)for(var t=0,a;t<e.length&&null!=e[t];t++)a=e[t],this.s0-=this.hash(a),this.s0+=~~(0>this.s0),this.s1-=this.hash(a),this.s1+=~~(0>this.s1),this.s2-=this.hash(a),this.s2+=~~(0>this.s2)},hash:function(e){var t,a,o;for(o=4022871197,e=e.toString(),a=0;a<e.length;a++)o+=e.charCodeAt(a),t=0.02519603282416938*o,o=t>>>0,t-=o,t*=o,o=t>>>0,t-=o,o+=4294967296*t;return 2.3283064365386963e-10*(o>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(e,t){return c(this.realInRange(0,t-e+1)+e)},between:function(e,t){return this.integerInRange(e,t)},realInRange:function(e,t){return this.frac()*(t-e)+e},normal:function(){return 1-2*this.frac()},uuid:function(){var e="",t="";for(t=e="";36>e++;t+=~e%5|4&3*e?(15^e?8^this.frac()*(20^e?16:4):4).toString(16):"-");return t},pick:function(e){return e[this.integerInRange(0,e.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(e){return e[~~(u(this.frac(),2)*(e.length-1)+0.5)]},timestamp:function(e,t){return this.realInRange(e||9.466848e11,t||1.577862e12)},angle:function(){return this.integerInRange(-180,180)},state:function(e){return"string"==typeof e&&e.match(/^!rnd/)&&(e=e.split(","),this.c=parseFloat(e[1]),this.s0=parseFloat(e[2]),this.s1=parseFloat(e[3]),this.s2=parseFloat(e[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},T.RandomDataGenerator.prototype.constructor=T.RandomDataGenerator,T.QuadTree=function(e,t,a,o,r,n,i){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(e,t,a,o,r,n,i)},T.QuadTree.prototype={reset:function(e,t,a,o,r,i,s){this.maxObjects=r||10,this.maxLevels=i||4,this.level=s||0,this.bounds={x:n(e),y:n(t),width:a,height:o,subWidth:c(a/2),subHeight:c(o/2),right:n(e)+c(a/2),bottom:n(t)+c(o/2)},this.objects.length=0,this.nodes.length=0},populate:function(e){e.forEach(this.populateHandler,this,!0)},populateHandler:function(e){e.body&&e.exists&&this.insert(e.body)},split:function(){this.nodes[0]=new T.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new T.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new T.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new T.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(e){var t=0,a;if(null!=this.nodes[0]&&(a=this.getIndex(e),-1!==a))return void this.nodes[a].insert(e);if(this.objects.push(e),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();t<this.objects.length;)a=this.getIndex(this.objects[t]),-1===a?t++:this.nodes[a].insert(this.objects.splice(t,1)[0])},getIndex:function(e){var t=-1;return e.x<this.bounds.right&&e.right<this.bounds.right?e.y<this.bounds.bottom&&e.bottom<this.bounds.bottom?t=1:e.y>this.bounds.bottom&&(t=2):e.x>this.bounds.right&&(e.y<this.bounds.bottom&&e.bottom<this.bounds.bottom?t=0:e.y>this.bounds.bottom&&(t=3)),t},retrieve:function(e){if(e instanceof T.Rectangle)var t=this.objects,a=this.getIndex(e);else{if(!e.body)return this._empty;var t=this.objects,a=this.getIndex(e.body)}return this.nodes[0]&&(-1===a?(t=t.concat(this.nodes[0].retrieve(e)),t=t.concat(this.nodes[1].retrieve(e)),t=t.concat(this.nodes[2].retrieve(e)),t=t.concat(this.nodes[3].retrieve(e))):t=t.concat(this.nodes[a].retrieve(e))),t},clear:function(){this.objects.length=0;for(var e=this.nodes.length;e--;)this.nodes[e].clear(),this.nodes.splice(e,1);this.nodes.length=0}},T.QuadTree.prototype.constructor=T.QuadTree,T.Net=function(e){this.game=e},T.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(e){return-1!==window.location.hostname.indexOf(e)},updateQueryString:function(e,t,a,o){void 0===a&&(a=!1),(void 0===o||""===o)&&(o=window.location.href);var r="",n=new RegExp("([?|&])"+e+"=.*?(&|#|$)(.*)","gi");if(n.test(o))r="undefined"!=typeof t&&null!==t?o.replace(n,"$1"+e+"="+t+"$2$3"):o.replace(n,"$1$3").replace(/(&|\?)$/,"");else if("undefined"!=typeof t&&null!==t){var i=-1===o.indexOf("?")?"?":"&",s=o.split("#");o=s[0]+i+e+"="+t,s[1]&&(o+="#"+s[1]),r=o}else r=o;return a?void(window.location.href=r):r},getQueryString:function(e){void 0===e&&(e="");var t={},a=location.search.substring(1).split("&");for(var o in a){var r=a[o].split("=");if(1<r.length){if(e&&e===this.decodeURI(r[0]))return this.decodeURI(r[1]);t[this.decodeURI(r[0])]=this.decodeURI(r[1])}}return t},decodeURI:function(e){return decodeURIComponent(e.replace(/\+/g," "))}},T.Net.prototype.constructor=T.Net,T.TweenManager=function(e){this.game=e,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:T.Easing.Power0,Power1:T.Easing.Power1,Power2:T.Easing.Power2,Power3:T.Easing.Power3,Power4:T.Easing.Power4,Linear:T.Easing.Linear.None,Quad:T.Easing.Quadratic.Out,Cubic:T.Easing.Cubic.Out,Quart:T.Easing.Quartic.Out,Quint:T.Easing.Quintic.Out,Sine:T.Easing.Sinusoidal.Out,Expo:T.Easing.Exponential.Out,Circ:T.Easing.Circular.Out,Elastic:T.Easing.Elastic.Out,Back:T.Easing.Back.Out,Bounce:T.Easing.Bounce.Out,"Quad.easeIn":T.Easing.Quadratic.In,"Cubic.easeIn":T.Easing.Cubic.In,"Quart.easeIn":T.Easing.Quartic.In,"Quint.easeIn":T.Easing.Quintic.In,"Sine.easeIn":T.Easing.Sinusoidal.In,"Expo.easeIn":T.Easing.Exponential.In,"Circ.easeIn":T.Easing.Circular.In,"Elastic.easeIn":T.Easing.Elastic.In,"Back.easeIn":T.Easing.Back.In,"Bounce.easeIn":T.Easing.Bounce.In,"Quad.easeOut":T.Easing.Quadratic.Out,"Cubic.easeOut":T.Easing.Cubic.Out,"Quart.easeOut":T.Easing.Quartic.Out,"Quint.easeOut":T.Easing.Quintic.Out,"Sine.easeOut":T.Easing.Sinusoidal.Out,"Expo.easeOut":T.Easing.Exponential.Out,"Circ.easeOut":T.Easing.Circular.Out,"Elastic.easeOut":T.Easing.Elastic.Out,"Back.easeOut":T.Easing.Back.Out,"Bounce.easeOut":T.Easing.Bounce.Out,"Quad.easeInOut":T.Easing.Quadratic.InOut,"Cubic.easeInOut":T.Easing.Cubic.InOut,"Quart.easeInOut":T.Easing.Quartic.InOut,"Quint.easeInOut":T.Easing.Quintic.InOut,"Sine.easeInOut":T.Easing.Sinusoidal.InOut,"Expo.easeInOut":T.Easing.Exponential.InOut,"Circ.easeInOut":T.Easing.Circular.InOut,"Elastic.easeInOut":T.Easing.Elastic.InOut,"Back.easeInOut":T.Easing.Back.InOut,"Bounce.easeInOut":T.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},T.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var e=0;e<this._tweens.length;e++)this._tweens[e].pendingDelete=!0;this._add=[]},removeFrom:function(e,t){void 0===t&&(t=!0);var a,o;if(Array.isArray(e))for(a=0,o=e.length;a<o;a++)this.removeFrom(e[a]);else if(e.type===T.GROUP&&t)for(var a=0,o=e.children.length;a<o;a++)this.removeFrom(e.children[a]);else{for(a=0,o=this._tweens.length;a<o;a++)e===this._tweens[a].target&&this.remove(this._tweens[a]);for(a=0,o=this._add.length;a<o;a++)e===this._add[a].target&&this.remove(this._add[a])}},add:function(e){e._manager=this,this._add.push(e)},create:function(e){return new T.Tween(e,this.game,this)},remove:function(e){var t=this._tweens.indexOf(e);-1===t?(t=this._add.indexOf(e),-1!==t&&(this._add[t].pendingDelete=!0)):this._tweens[t].pendingDelete=!0},update:function(){var e=this._add.length,t=this._tweens.length;if(0===t&&0===e)return!1;for(var a=0;a<t;)this._tweens[a].update(this.game.time.time)?a++:(this._tweens.splice(a,1),t--);return 0<e&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(e){return this._tweens.some(function(t){return t.target===e})},_pauseAll:function(){for(var e=this._tweens.length-1;0<=e;e--)this._tweens[e]._pause()},_resumeAll:function(){for(var e=this._tweens.length-1;0<=e;e--)this._tweens[e]._resume()},pauseAll:function(){for(var e=this._tweens.length-1;0<=e;e--)this._tweens[e].pause()},resumeAll:function(){for(var e=this._tweens.length-1;0<=e;e--)this._tweens[e].resume(!0)}},T.TweenManager.prototype.constructor=T.TweenManager,T.Tween=function(e,t,a){this.game=t,this.target=e,this.manager=a,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new T.Signal,this.onLoop=new T.Signal,this.onRepeat=new T.Signal,this.onChildComplete=new T.Signal,this.onComplete=new T.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=a.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},T.Tween.updateColor=function(e){T.Color.updateColor(e.target)},T.Tween.prototype={to:function(e,t,a,o,r,n,i){return((void 0===t||0>=t)&&(t=1e3),(void 0===a||null===a)&&(a=T.Easing.Default),void 0===o&&(o=!1),void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=!1),"string"==typeof a&&this.manager.easeMap[a]&&(a=this.manager.easeMap[a]),this.isRunning)?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new T.TweenData(this).to(e,t,a,r,n,i)),o&&this.start(),this)},from:function(e,t,a,o,r,n,i){return(void 0===t&&(t=1e3),(void 0===a||null===a)&&(a=T.Easing.Default),void 0===o&&(o=!1),void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=!1),"string"==typeof a&&this.manager.easeMap[a]&&(a=this.manager.easeMap[a]),this.isRunning)?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new T.TweenData(this).from(e,t,a,r,n,i)),o&&this.start(),this)},start:function(e){if(void 0===e&&(e=0),null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(var t=0;t<this.timeline.length;t++)for(var a in this.timeline[t].vEnd)this.properties[a]=this.target[a]||0,Array.isArray(this.properties[a])||(this.properties[a]*=1);for(var t=0;t<this.timeline.length;t++)this.timeline[t].loadValues();return this.manager.add(this),this.isRunning=!0,(0>e||e>this.timeline.length-1)&&(e=0),this.current=e,this.timeline[this.current].start(),this},stop:function(e){return void 0===e&&(e=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,e&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(e,t,a){if(0===this.timeline.length)return this;if(void 0===a&&(a=0),-1===a)for(var o=0;o<this.timeline.length;o++)this.timeline[o][e]=t;else this.timeline[a][e]=t;return this},delay:function(e,t){return this.updateTweenData("delay",e,t)},repeat:function(e,t,a){return void 0===t&&(t=0),this.updateTweenData("repeatCounter",e,a),this.updateTweenData("repeatDelay",t,a)},repeatDelay:function(e,t){return this.updateTweenData("repeatDelay",e,t)},yoyo:function(e,t,a){return void 0===t&&(t=0),this.updateTweenData("yoyo",e,a),this.updateTweenData("yoyoDelay",t,a)},yoyoDelay:function(e,t){return this.updateTweenData("yoyoDelay",e,t)},easing:function(e,t){return"string"==typeof e&&this.manager.easeMap[e]&&(e=this.manager.easeMap[e]),this.updateTweenData("easingFunction",e,t)},interpolation:function(e,t,a){return void 0===t&&(t=T.Math),this.updateTweenData("interpolationFunction",e,a),this.updateTweenData("interpolationContext",t,a)},repeatAll:function(e){return void 0===e&&(e=0),this.repeatCounter=e,this},chain:function(){for(var e=arguments.length;e--;)0<e?arguments[e-1].chainedTween=arguments[e]:this.chainedTween=arguments[e];return this},loop:function(e){return void 0===e&&(e=!0),this.repeatCounter=e?-1:0,this},onUpdateCallback:function(e,t){return this._onUpdateCallback=e,this._onUpdateCallbackContext=t,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var e=0;e<this.timeline.length;e++)this.timeline[e].isRunning||(this.timeline[e].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(e){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;var t=this.timeline[this.current].update(e);if(t===T.TweenData.PENDING)return!0;if(t===T.TweenData.RUNNING)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(t===T.TweenData.LOOPED)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(t===T.TweenData.COMPLETE){var a=!1;return this.reverse?(this.current--,0>this.current&&(this.current=this.timeline.length-1,a=!0)):(this.current++,this.current===this.timeline.length&&(this.current=0,a=!0)),a?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):0<this.repeatCounter?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(e,t){if(null===this.game||null===this.target)return null;void 0===e&&(e=60),void 0===t&&(t=[]);for(var a=0;a<this.timeline.length;a++)for(var o in this.timeline[a].vEnd)this.properties[o]=this.target[o]||0,Array.isArray(this.properties[o])||(this.properties[o]*=1);for(var a=0;a<this.timeline.length;a++)this.timeline[a].loadValues();for(var a=0;a<this.timeline.length;a++)t=t.concat(this.timeline[a].generateData(e));return t}},Object.defineProperty(T.Tween.prototype,"totalDuration",{get:function(){for(var e=0,t=0;t<this.timeline.length;t++)e+=this.timeline[t].duration;return e}}),T.Tween.prototype.constructor=T.Tween,T.TweenData=function(e){this.parent=e,this.game=e.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction=T.Easing.Default,this.interpolationFunction=T.Math.linearInterpolation,this.interpolationContext=T.Math,this.isRunning=!1,this.isFrom=!1},T.TweenData.PENDING=0,T.TweenData.RUNNING=1,T.TweenData.LOOPED=2,T.TweenData.COMPLETE=3,T.TweenData.prototype={to:function(e,t,a,o,r,n){return this.vEnd=e,this.duration=t,this.easingFunction=a,this.delay=o,this.repeatTotal=r,this.yoyo=n,this.isFrom=!1,this},from:function(e,t,a,o,r,n){return this.vEnd=e,this.duration=t,this.easingFunction=a,this.delay=o,this.repeatTotal=r,this.yoyo=n,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.dt=this.parent.reverse?this.duration:0,this.isRunning=!(0<this.delay),this.isFrom)for(var e in this.vStartCache)this.vStart[e]=this.vEndCache[e],this.vEnd[e]=this.vStartCache[e],this.parent.target[e]=this.vStart[e];return this.value=0,this.yoyoCounter=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var e in this.parent.properties){if(this.vStart[e]=this.parent.properties[e],Array.isArray(this.vEnd[e])){if(0===this.vEnd[e].length)continue;0===this.percent&&(this.vEnd[e]=[this.vStart[e]].concat(this.vEnd[e]))}"undefined"==typeof this.vEnd[e]?this.vEnd[e]=this.vStart[e]:("string"==typeof this.vEnd[e]&&(this.vEnd[e]=this.vStart[e]+parseFloat(this.vEnd[e],10)),this.parent.properties[e]=this.vEnd[e]),this.vStartCache[e]=this.vStart[e],this.vEndCache[e]=this.vEnd[e]}return this},update:function(e){if(!this.isRunning){if(e>=this.startTime)this.isRunning=!0;else return T.TweenData.PENDING;}else if(e<this.startTime)return T.TweenData.RUNNING;var t=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;for(var a in this.parent.reverse?(this.dt-=t*this.parent.timeScale,this.dt=s(this.dt,0)):(this.dt+=t*this.parent.timeScale,this.dt=p(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent),this.vEnd){var o=this.vStart[a],r=this.vEnd[a];this.parent.target[a]=Array.isArray(r)?this.interpolationFunction.call(this.interpolationContext,r,this.value):o+(r-o)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():T.TweenData.RUNNING},generateData:function(e){this.dt=this.parent.reverse?this.duration:0;var t=[],a=!1,o=1e3*(1/e);do{this.parent.reverse?(this.dt-=o,this.dt=s(this.dt,0)):(this.dt+=o,this.dt=p(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var r={};for(var n in this.vEnd){var i=this.vStart[n],d=this.vEnd[n];r[n]=Array.isArray(d)?this.interpolationFunction.call(this.interpolationContext,d,this.value):i+(d-i)*this.value}t.push(r),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(a=!0)}while(!a);if(this.yoyo){var l=t.slice();l.reverse(),t=t.concat(l)}return t},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var e in this.vStartCache)this.vStart[e]=this.vStartCache[e],this.vEnd[e]=this.vEndCache[e];return this.inReverse=!1,T.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return T.TweenData.COMPLETE;if(this.inReverse)for(var e in this.vStartCache)this.vStart[e]=this.vEndCache[e],this.vEnd[e]=this.vStartCache[e];else{for(var e in this.vStartCache)this.vStart[e]=this.vStartCache[e],this.vEnd[e]=this.vEndCache[e];0<this.repeatCounter&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:!this.inReverse&&(this.startTime+=this.repeatDelay),this.dt=this.parent.reverse?this.duration:0,T.TweenData.LOOPED}},T.TweenData.prototype.constructor=T.TweenData,T.Easing={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return 1>(e*=2)?0.5*e*e:-0.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return 1>(e*=2)?0.5*e*e*e:0.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return 1>(e*=2)?0.5*e*e*e*e:-0.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return 1>(e*=2)?0.5*e*e*e*e*e:0.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 0===e?0:1===e?1:1-m(e*d/2)},Out:function(e){return 0===e?0:1===e?1:h(e*d/2)},InOut:function(e){return 0===e?0:1===e?1:0.5*(1-m(d*e))}},Exponential:{In:function(e){return 0===e?0:u(1024,e-1)},Out:function(e){return 1===e?1:1-u(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:1>(e*=2)?0.5*u(1024,e-1):0.5*(-u(2,-10*(e-1))+2)}},Circular:{In:function(e){return 1-_(1-e*e)},Out:function(e){return _(1- --e*e)},InOut:function(e){return 1>(e*=2)?-0.5*(_(1-e*e)-1):0.5*(_(1-(e-=2)*e)+1)}},Elastic:{In:function(e){var o=0.1,r=0.4,n;return 0===e?0:1===e?1:(!o||1>o?(o=1,n=r/4):n=r*t(1/o)/(2*d),-(o*u(2,10*(e-=1))*h((e-n)*(2*d)/r)))},Out:function(e){var o=0.1,r=0.4,n;return 0===e?0:1===e?1:(!o||1>o?(o=1,n=r/4):n=r*t(1/o)/(2*d),o*u(2,-10*e)*h((e-n)*(2*d)/r)+1)},InOut:function(e){var o=0.1,r=0.4,n;return 0===e?0:1===e?1:(!o||1>o?(o=1,n=r/4):n=r*t(1/o)/(2*d),1>(e*=2)?-0.5*(o*u(2,10*(e-=1))*h((e-n)*(2*d)/r)):0.5*(o*u(2,-10*(e-=1))*h((e-n)*(2*d)/r))+1)}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=1.525*1.70158;return 1>(e*=2)?0.5*(e*e*((t+1)*e-t)):0.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-T.Easing.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+0.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+0.9375:7.5625*(e-=2.625/2.75)*e+0.984375},InOut:function(e){return 0.5>e?0.5*T.Easing.Bounce.In(2*e):0.5*T.Easing.Bounce.Out(2*e-1)+0.5}}},T.Easing.Default=T.Easing.Linear.None,T.Easing.Power0=T.Easing.Linear.None,T.Easing.Power1=T.Easing.Quadratic.Out,T.Easing.Power2=T.Easing.Cubic.Out,T.Easing.Power3=T.Easing.Quartic.Out,T.Easing.Power4=T.Easing.Quintic.Out,T.Time=function(e){this.game=e,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.physicsElapsed=1/60,this.physicsElapsedMS=1e3*(1/60),this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.slowMotion=1,this.advancedTiming=!1,this.frames=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new T.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},T.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(e){return this._timers.push(e),e},create:function(e){void 0===e&&(e=!0);var t=new T.Timer(this.game,e);return this._timers.push(t),t},removeAll:function(){for(var e=0;e<this._timers.length;e++)this._timers[e].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e},update:function(e){var t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t,this.prevTime=this.now,this.now=e,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=c(s(0,1e3/this._desiredFps-(this.timeExpected-e))),this.timeExpected=e+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var e=0,t=this._timers.length;e<t;)this._timers[e].update(this.time)?e++:(this._timers.splice(e,1),t--)},updateAdvancedTiming:function(){this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*c(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=p(this.msMin,this.elapsed),this.msMax=s(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=n(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=p(this.fpsMin,this.fps),this.fpsMax=s(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var e=this._timers.length;e--;)this._timers[e]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var e=this._timers.length;e--;)this._timers[e]._resume()},totalElapsedSeconds:function(){return 1e-3*(this.time-this._started)},elapsedSince:function(e){return this.time-e},elapsedSecondsSince:function(e){return 1e-3*(this.time-e)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(T.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(e){this._desiredFps=e,this.physicsElapsed=1/e,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/e}}),T.Time.prototype.constructor=T.Time,T.Timer=function(e,t){void 0===t&&(t=!0),this.game=e,this.running=!1,this.autoDestroy=t,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new T.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},T.Timer.MINUTE=6e4,T.Timer.SECOND=1e3,T.Timer.HALF=500,T.Timer.QUARTER=250,T.Timer.prototype={create:function(e,t,a,o,r,i){e=n(e);var s=e;s+=0===this._now?this.game.time.time:this._now;var d=new T.TimerEvent(this,e,s,a,t,o,r,i);return this.events.push(d),this.order(),this.expired=!1,d},add:function(e,t,a){return this.create(e,!1,0,t,a,Array.prototype.slice.call(arguments,3))},repeat:function(e,t,a,o){return this.create(e,!1,t,a,o,Array.prototype.slice.call(arguments,4))},loop:function(e,t,a){return this.create(e,!0,0,t,a,Array.prototype.slice.call(arguments,3))},start:function(e){if(!this.running){this._started=this.game.time.time+(e||0),this.running=!0;for(var t=0;t<this.events.length;t++)this.events[t].tick=this.events[t].delay+this._started}},stop:function(e){this.running=!1,void 0===e&&(e=!0),e&&(this.events.length=0)},remove:function(e){for(var t=0;t<this.events.length;t++)if(this.events[t]===e)return this.events[t].pendingDelete=!0,!0;return!1},order:function(){0<this.events.length&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(e,t){return e.tick<t.tick?-1:e.tick>t.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(e){if(this.paused)return!0;if(this.elapsed=e-this._now,this._now=e,this.elapsed>this.timeCap&&this.adjustEvents(e-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&0<this._len){for(;this._i<this._len&&this.running;){var t=this.events[this._i];if(this._now>=t.tick&&!t.pendingDelete)this._newTick=this._now+t.delay-(this._now-t.tick),0>this._newTick&&(this._newTick=this._now+t.delay),!0===t.loop?(t.tick=this._newTick,t.callback.apply(t.callbackContext,t.args)):0<t.repeatCount?(t.repeatCount--,t.tick=this._newTick,t.callback.apply(t.callbackContext,t.args)):(this._marked++,t.pendingDelete=!0,t.callback.apply(t.callbackContext,t.args)),this._i++;else break}this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return this.expired&&this.autoDestroy?!1:!0},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){this.paused||!this.running||(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(e){for(var a=0;a<this.events.length;a++)if(!this.events[a].pendingDelete){var o=this.events[a].tick-e;0>o&&(o=0),this.events[a].tick=this._now+o}var t=this.nextTick-e;this.nextTick=0>t?this._now:this._now+t},resume:function(){if(this.paused){var e=this.game.time.time;this._pauseTotal+=e-this._now,this._now=e,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0},destroy:function(){this.onComplete.removeAll(),this.running=!1,this.expired=!0,this.events=[],this._len=0,this._i=0}},Object.defineProperty(T.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(T.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(T.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(T.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(T.Timer.prototype,"seconds",{get:function(){return this.running?1e-3*this.ms:0}}),T.Timer.prototype.constructor=T.Timer,T.TimerEvent=function(e,t,a,o,r,n,i,s){this.timer=e,this.delay=t,this.tick=a,this.repeatCount=o-1,this.loop=r,this.callback=n,this.callbackContext=i,this.args=s,this.pendingDelete=!1},T.TimerEvent.prototype.constructor=T.TimerEvent,T.AnimationManager=function(e){this.sprite=e,this.game=e.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},T.AnimationManager.prototype={loadFrameData:function(e,t){if(void 0===e)return!1;if(this.isLoaded)for(var a in this._anims)this._anims[a].updateFrameData(e);return this._frameData=e,void 0===t||null===t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0,!0},copyFrameData:function(e,t){if(this._frameData=e.clone(),this.isLoaded)for(var a in this._anims)this._anims[a].updateFrameData(this._frameData);return void 0===t||null===t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0,!0},add:function(e,t,a,o,r){return t=t||[],a=a||60,void 0===o&&(o=!1),void 0===r&&(t&&"number"==typeof t[0]?r=!0:r=!1),this._outputFrames=[],this._frameData.getFrameIndexes(t,r,this._outputFrames),this._anims[e]=new T.Animation(this.game,this.sprite,e,this._frameData,this._outputFrames,a,o),this.currentAnim=this._anims[e],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[e]},validateFrames:function(e,t){void 0===t&&(t=!0);for(var a=0;a<e.length;a++)if(!0===t){if(e[a]>this._frameData.total)return!1;}else if(!1===this._frameData.checkFrameName(e[a]))return!1;return!0},play:function(e,t,a,o){if(this._anims[e])return this.currentAnim===this._anims[e]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(t,a,o)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[e],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(t,a,o))},stop:function(e,t){void 0===t&&(t=!1),this.currentAnim&&("string"!=typeof e||e===this.currentAnim.name)&&this.currentAnim.stop(t)},update:function(){return this.updateIfVisible&&!this.sprite.visible?!1:this.currentAnim&&this.currentAnim.update()&&(this.currentFrame=this.currentAnim.currentFrame,!0)},next:function(e){this.currentAnim&&(this.currentAnim.next(e),this.currentFrame=this.currentAnim.currentFrame)},previous:function(e){this.currentAnim&&(this.currentAnim.previous(e),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(e){return"string"==typeof e&&this._anims[e]?this._anims[e]:null},refreshFrame:function(){},destroy:function(){var e=null;for(var e in this._anims)this._anims.hasOwnProperty(e)&&this._anims[e].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},T.AnimationManager.prototype.constructor=T.AnimationManager,Object.defineProperty(T.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(T.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(T.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(e){this.currentAnim.paused=e}}),Object.defineProperty(T.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}}),Object.defineProperty(T.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},set:function(e){var t;"number"==typeof e&&this._frameData&&(t=this._frameData.getFrame(e))&&(this.currentFrame=t,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(T.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},set:function(e){var t;"string"==typeof e&&this._frameData&&(t=this._frameData.getFrameByName(e))?(this.currentFrame=t,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+e)}}),T.Animation=function(e,t,a,o,r,n,i){void 0===i&&(i=!1),this.game=e,this._parent=t,this._frameData=o,this.name=a,this._frames=[],this._frames=this._frames.concat(r),this.delay=1e3/n,this.loop=i,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new T.Signal,this.onUpdate=null,this.onComplete=new T.Signal,this.onLoop=new T.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},T.Animation.prototype={play:function(e,t,a){return"number"==typeof e&&(this.delay=1e3/e),"boolean"==typeof t&&(this.loop=t),"undefined"!=typeof a&&(this.killOnComplete=a),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(e,t){var a;if(void 0===t&&(t=!1),"string"==typeof e)for(var o=0;o<this._frames.length;o++)this._frameData.getFrame(this._frames[o]).name===e&&(a=o);else if("number"==typeof e)if(t)a=e;else for(var o=0;o<this._frames.length;o++)this._frames[o]===e&&(a=o);if(a){var r=this.isReversed?-1:1;this._frameIndex=a-r,this._timeNextFrame=this.game.time.time,this.update()}},stop:function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,e&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),t&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){return!this.isPaused&&this.isPlaying&&this.game.time.time>=this._timeNextFrame&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay?(this._frameSkip=c(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay):this._frameDiff=0,this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&-1>=this._frameIndex?this.loop?(this._frameIndex=f(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(e,t){if(void 0===t&&(t=!1),!this._frameData)return!1;var a=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(t||!t&&a!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),this.onUpdate&&e?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0},next:function(e){void 0===e&&(e=1);var t=this._frameIndex+e;t>=this._frames.length&&(this.loop?t%=this._frames.length:t=this._frames.length-1),t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},previous:function(e){void 0===e&&(e=1);var t=this._frameIndex-e;0>t&&(this.loop?t=this._frames.length+t:t++),t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},updateFrameData:function(e){this._frameData=e,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},T.Animation.prototype.constructor=T.Animation,Object.defineProperty(T.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(e){this.isPaused=e,e?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(T.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(e){this.isReversed=e}}),Object.defineProperty(T.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(T.Animation.prototype,"frame",{get:function(){return null===this.currentFrame?this._frameIndex:this.currentFrame.index},set:function(e){this.currentFrame=this._frameData.getFrame(this._frames[e]),null!==this.currentFrame&&(this._frameIndex=e,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(T.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(e){0<e&&(this.delay=1e3/e)}}),Object.defineProperty(T.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(e){e&&null===this.onUpdate?this.onUpdate=new T.Signal:!e&&null!==this.onUpdate&&(this.onUpdate.dispose(),this.onUpdate=null)}}),T.Animation.generateFrameNames=function(e,t,a,o,r){void 0===o&&(o="");var n=[],s="";if(t<a)for(var d=t;d<=a;d++)s="number"==typeof r?T.Utils.pad(d.toString(),r,"0",1):d.toString(),s=e+s+o,n.push(s);else for(var d=t;d>=a;d--)s="number"==typeof r?T.Utils.pad(d.toString(),r,"0",1):d.toString(),s=e+s+o,n.push(s);return n},T.Frame=function(e,t,a,o,r,n){this.index=e,this.x=t,this.y=a,this.width=o,this.height=r,(0===this.width||0===this.height)&&console.warn("Phaser.Frame: Frame \""+this.name+"\" has a width or height of zero"),this.name=n,this.centerX=c(o/2),this.centerY=c(r/2),this.distance=T.Math.distance(0,0,o,r),this.rotated=!1,this.trimmed=!1,this.sourceSizeW=o,this.sourceSizeH=r,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},T.Frame.prototype={resize:function(e,t){this.width=e,this.height=t,this.centerX=c(e/2),this.centerY=c(t/2),this.distance=T.Math.distance(0,0,e,t),this.sourceSizeW=e,this.sourceSizeH=t,this.right=this.x+e,this.bottom=this.y+t},setTrim:function(e,t,a,o,r,n,i){this.trimmed=e,e&&(this.sourceSizeW=t,this.sourceSizeH=a,this.centerX=c(t/2),this.centerY=c(a/2),this.spriteSourceSizeX=o,this.spriteSourceSizeY=r,this.spriteSourceSizeW=n,this.spriteSourceSizeH=i)},clone:function(){var e=new T.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},getRect:function(e){return void 0===e?e=new T.Rectangle(this.x,this.y,this.width,this.height):e.setTo(this.x,this.y,this.width,this.height),e}},T.Frame.prototype.constructor=T.Frame,T.FrameData=function(){this._frames=[],this._frameNames=[]},T.FrameData.prototype={addFrame:function(e){return e.index=this._frames.length,this._frames.push(e),""!==e.name&&(this._frameNames[e.name]=e.index),e},getFrame:function(e){return e>=this._frames.length&&(e=0),this._frames[e]},getFrameByName:function(e){return"number"==typeof this._frameNames[e]?this._frames[this._frameNames[e]]:null},checkFrameName:function(e){return null!=this._frameNames[e]},clone:function(){for(var e=new T.FrameData,t=0;t<this._frames.length;t++)e._frames.push(this._frames[t].clone());for(var a in this._frameNames)this._frameNames.hasOwnProperty(a)&&e._frameNames.push(this._frameNames[a]);return e},getFrameRange:function(e,t,a){void 0===a&&(a=[]);for(var o=e;o<=t;o++)a.push(this._frames[o]);return a},getFrames:function(e,t,a){if(void 0===t&&(t=!0),void 0===a&&(a=[]),void 0===e||0===e.length)for(var o=0;o<this._frames.length;o++)a.push(this._frames[o]);else for(var o=0;o<e.length;o++)t?a.push(this.getFrame(e[o])):a.push(this.getFrameByName(e[o]));return a},getFrameIndexes:function(e,t,a){if(void 0===t&&(t=!0),void 0===a&&(a=[]),void 0===e||0===e.length)for(var o=0;o<this._frames.length;o++)a.push(this._frames[o].index);else for(var o=0;o<e.length;o++)t&&this._frames[e[o]]?a.push(this._frames[e[o]].index):this.getFrameByName(e[o])&&a.push(this.getFrameByName(e[o]).index);return a},destroy:function(){this._frames=null,this._frameNames=null}},T.FrameData.prototype.constructor=T.FrameData,Object.defineProperty(T.FrameData.prototype,"total",{get:function(){return this._frames.length}}),T.AnimationParser={spriteSheet:function(e,t,a,o,r,n,s,d){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===s&&(s=0),void 0===d&&(d=0);var l=t;if("string"==typeof t&&(l=e.cache.getImage(t)),null===l)return null;var u=l.width,h=l.height;0>=a&&(a=c(-u/p(-1,a))),0>=o&&(o=c(-h/p(-1,o)));var g=c((u-n)/(a+s)),m=c((h-n)/(o+s)),f=g*m;if(d>f||d<-f)return console.warn("Phaser.AnimationParser.spriteSheet: skipFrames = "+d.toString()+" is larger than total sprite number "+f.toString()),null;if(0>d&&(d=f+d),-1!==r&&(f=d+r),0===u||0===h||u<a||h<o||0===f)return console.warn("Phaser.AnimationParser.spriteSheet: '"+t+"'s width/height zero or width/height < given frameWidth/frameHeight"),null;for(var b=new T.FrameData,_=n,x=n,y=0;y<f;y++)b.addFrame(new T.Frame(y,_,x,a,o,"")),_+=a+s,_+a>u&&(_=n,x+=o+s);return b},JSONData:function(e,t){if(!t.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(t);for(var a=new T.FrameData,o=t.frames,r=0,n;r<o.length;r++)n=a.addFrame(new T.Frame(r,o[r].frame.x,o[r].frame.y,o[r].frame.w,o[r].frame.h,o[r].filename)),o[r].trimmed&&n.setTrim(o[r].trimmed,o[r].sourceSize.w,o[r].sourceSize.h,o[r].spriteSourceSize.x,o[r].spriteSourceSize.y,o[r].spriteSourceSize.w,o[r].spriteSourceSize.h),o[r].rotated&&(n.rotated=!0);return a},JSONDataPyxel:function(e,t){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(e){if(!t[e])return console.warn("Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing \""+e+"\" key."),void console.log(t)}),1!==t.layers.length)return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps."),void console.log(t);for(var a=new T.FrameData,o=t.tileheight,r=t.tilewidth,n=t.layers[0].tiles,s=0,i;s<n.length;s++)i=a.addFrame(new T.Frame(s,n[s].x,n[s].y,r,o,"frame_"+s)),i.setTrim(!1);return a},JSONDataHash:function(e,t){if(!t.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(t);var a=new T.FrameData,o=t.frames,r=0,n;for(var i in o)n=a.addFrame(new T.Frame(r,o[i].frame.x,o[i].frame.y,o[i].frame.w,o[i].frame.h,i)),o[i].trimmed&&n.setTrim(o[i].trimmed,o[i].sourceSize.w,o[i].sourceSize.h,o[i].spriteSourceSize.x,o[i].spriteSourceSize.y,o[i].spriteSourceSize.w,o[i].spriteSourceSize.h),o[i].rotated&&(n.rotated=!0),r++;return a},XMLData:function(e,t){if(!t.getElementsByTagName("TextureAtlas"))return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");for(var a=new T.FrameData,o=t.getElementsByTagName("SubTexture"),r=0,n,i,s,d,l,p,c,u,h,g,m;r<o.length;r++)s=o[r].attributes,i=s.name.value,d=parseInt(s.x.value,10),l=parseInt(s.y.value,10),p=parseInt(s.width.value,10),c=parseInt(s.height.value,10),u=null,h=null,s.frameX&&(u=f(parseInt(s.frameX.value,10)),h=f(parseInt(s.frameY.value,10)),g=parseInt(s.frameWidth.value,10),m=parseInt(s.frameHeight.value,10)),n=a.addFrame(new T.Frame(r,d,l,p,c,i)),(null!==u||null!==h)&&n.setTrim(!0,p,c,u,h,g,m);return a}},T.Cache=function(e){this.game=e,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new T.Signal,this._cacheMap=[],this._cacheMap[T.Cache.CANVAS]=this._cache.canvas,this._cacheMap[T.Cache.IMAGE]=this._cache.image,this._cacheMap[T.Cache.TEXTURE]=this._cache.texture,this._cacheMap[T.Cache.SOUND]=this._cache.sound,this._cacheMap[T.Cache.TEXT]=this._cache.text,this._cacheMap[T.Cache.PHYSICS]=this._cache.physics,this._cacheMap[T.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[T.Cache.BINARY]=this._cache.binary,this._cacheMap[T.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[T.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[T.Cache.JSON]=this._cache.json,this._cacheMap[T.Cache.XML]=this._cache.xml,this._cacheMap[T.Cache.VIDEO]=this._cache.video,this._cacheMap[T.Cache.SHADER]=this._cache.shader,this._cacheMap[T.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._pendingCount=0,this.onReady=new T.Signal,this._addImages()},T.Cache.CANVAS=1,T.Cache.IMAGE=2,T.Cache.TEXTURE=3,T.Cache.SOUND=4,T.Cache.TEXT=5,T.Cache.PHYSICS=6,T.Cache.TILEMAP=7,T.Cache.BINARY=8,T.Cache.BITMAPDATA=9,T.Cache.BITMAPFONT=10,T.Cache.JSON=11,T.Cache.XML=12,T.Cache.VIDEO=13,T.Cache.SHADER=14,T.Cache.RENDER_TEXTURE=15,T.Cache.DEFAULT=null,T.Cache.DEFAULT_KEY="__default",T.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",T.Cache.MISSING=null,T.Cache.MISSING_KEY="__missing",T.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",T.Cache.READY_TIMEOUT=1e3,T.Cache.prototype={addCompressedTextureMetaData:function(e,t,a,o){this.checkImageKey(e)&&this.removeImage(e);var r=a in T.LoaderParser?T.LoaderParser[a](o):o,n={key:e,url:t,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new T.Frame(0,0,0,r.width,r.height,e),frameData:new T.FrameData,fileFormat:a};return n.frameData.addFrame(new T.Frame(0,0,0,r.width,r.height,t)),this._cache.image[e]=n,this._resolveURL(t,n),n},addCanvas:function(e,t,a){void 0===a&&(a=t.getContext("2d")),this._cache.canvas[e]={canvas:t,context:a}},addImage:function(e,t,a){this.checkImageKey(e)&&this.removeImage(e),!1===a.complete&&console.warn("Phaser.Cache.addImage: Image \""+e+"\" hasn't been retrieved yet");var o={key:e,url:t,data:a,base:new PIXI.BaseTexture(a,null,this.game.resolution),frame:new T.Frame(0,0,0,a.width,a.height,e),frameData:new T.FrameData};return o.frameData.addFrame(new T.Frame(0,0,0,a.width,a.height,t)),this._cache.image[e]=o,this._resolveURL(t,o),"__default"===e?T.Cache.DEFAULT=new PIXI.Texture(o.base):"__missing"===e&&(T.Cache.MISSING=new PIXI.Texture(o.base)),o},addImageAsync:function(e,t,a){var o=this,r=new Image;r.onload=function(){a.call(this,o.addImage(e,null,r)),o._removePending(),r.onload=null},this._addPending(),r.src=t},addDefaultImage:function(){this.addImageAsync(T.Cache.DEFAULT_KEY,T.Cache.DEFAULT_SRC,function(e){e.base.skipRender=!0,T.Cache.DEFAULT=new PIXI.Texture(e.base)})},addMissingImage:function(){this.addImageAsync(T.Cache.MISSING_KEY,T.Cache.MISSING_SRC,function(e){T.Cache.MISSING=new PIXI.Texture(e.base)})},addSound:function(e,t,a,o,r){void 0===o&&(o=!0,r=!1),void 0===r&&(o=!1,r=!0);var n=!1;r&&(n=!0),this._cache.sound[e]={url:t,data:a,isDecoding:!1,decoded:n,webAudio:o,audioTag:r,locked:this.game.sound.touchLocked},this._resolveURL(t,this._cache.sound[e])},addText:function(e,t,a){this._cache.text[e]={url:t,data:a},this._resolveURL(t,this._cache.text[e])},addPhysicsData:function(e,t,a,o){this._cache.physics[e]={url:t,data:a,format:o},this._resolveURL(t,this._cache.physics[e])},addTilemap:function(e,t,a,o){this._cache.tilemap[e]={url:t,data:a,format:o},this._resolveURL(t,this._cache.tilemap[e])},addBinary:function(e,t){this._cache.binary[e]=t},addBitmapData:function(e,t,a){return t.key=e,void 0===a&&(a=new T.FrameData,a.addFrame(t.textureFrame)),this._cache.bitmapData[e]={data:t,frameData:a},t},addBitmapFont:function(e,t,a,o,r,n,i){var s={url:t,data:a,font:null,base:new PIXI.BaseTexture(a,null,this.game.resolution)};void 0===n&&(n=0),void 0===i&&(i=0),s.font="json"===r?T.LoaderParser.jsonBitmapFont(o,s.base,n,i,!1,this.game.resolution):T.LoaderParser.xmlBitmapFont(o,s.base,n,i,!1,this.game.resolution),this._cache.bitmapFont[e]=s,this._resolveURL(t,s)},addBitmapFontFromAtlas:function(e,t,a,o,r,n,i){var s=this.getFrameByName(t,a);if(s){var d={font:null,base:this.getBaseTexture(t),frame:s};void 0===n&&(n=0),void 0===i&&(i=0);var l;"json"===r?(l=this.getJSON(o),d.font=T.LoaderParser.jsonBitmapFont(l,d.base,n,i,s,this.game.resolution)):(l=this.getXML(o),d.font=T.LoaderParser.xmlBitmapFont(l,d.base,n,i,s,this.game.resolution)),this._cache.bitmapFont[e]=d}},addJSON:function(e,t,a){this._cache.json[e]={url:t,data:a},this._resolveURL(t,this._cache.json[e])},addXML:function(e,t,a){this._cache.xml[e]={url:t,data:a},this._resolveURL(t,this._cache.xml[e])},addVideo:function(e,t,a,o){this._cache.video[e]={url:t,data:a,isBlob:o,locked:!0},this._resolveURL(t,this._cache.video[e])},addShader:function(e,t,a){this._cache.shader[e]={url:t,data:a},this._resolveURL(t,this._cache.shader[e])},addRenderTexture:function(e,t){this._cache.renderTexture[e]={texture:t,frame:new T.Frame(0,0,0,t.width,t.height,"","")}},addSpriteSheet:function(e,t,a,o,r,n,i,s,d){void 0===n&&(n=-1),void 0===i&&(i=0),void 0===s&&(s=0);var l={key:e,url:t,data:a,frameWidth:o,frameHeight:r,margin:i,spacing:s,base:new PIXI.BaseTexture(a,null,this.game.resolution),frameData:T.AnimationParser.spriteSheet(this.game,a,o,r,n,i,s,d)};this._cache.image[e]=l,this._resolveURL(t,l)},addTextureAtlas:function(e,t,a,o,r){var n={key:e,url:t,data:a,base:new PIXI.BaseTexture(a,null,this.game.resolution)};n.frameData=r===T.Loader.TEXTURE_ATLAS_XML_STARLING?T.AnimationParser.XMLData(this.game,o,e):r===T.Loader.TEXTURE_ATLAS_JSON_PYXEL?T.AnimationParser.JSONDataPyxel(this.game,o,e):Array.isArray(o.frames)?T.AnimationParser.JSONData(this.game,o,e):T.AnimationParser.JSONDataHash(this.game,o,e),this._cache.image[e]=n,this._resolveURL(t,n)},reloadSound:function(e){var t=this,a=this.getSound(e);a&&(a.data.src=a.url,a.data.addEventListener("canplaythrough",function(){return t.reloadSoundComplete(e)},!1),a.data.load())},reloadSoundComplete:function(e){var t=this.getSound(e);t&&(t.locked=!1,this.onSoundUnlock.dispatch(e))},updateSound:function(e,t,a){var o=this.getSound(e);o&&(o[t]=a)},decodedSound:function(e,t){var a=this.getSound(e);a.data=t,a.decoded=!0,a.isDecoding=!1},isSoundDecoded:function(e){var t=this.getItem(e,T.Cache.SOUND,"isSoundDecoded");if(t)return t.decoded},isSoundReady:function(e){var t=this.getItem(e,T.Cache.SOUND,"isSoundDecoded");if(t)return t.decoded&&!this.game.sound.touchLocked},checkKey:function(e,t){return!!this._cacheMap[e][t]},checkURL:function(e){return!!this._urlMap[this._resolveURL(e)]},checkCanvasKey:function(e){return this.checkKey(T.Cache.CANVAS,e)},checkImageKey:function(e){return this.checkKey(T.Cache.IMAGE,e)},checkTextureKey:function(e){return this.checkKey(T.Cache.TEXTURE,e)},checkSoundKey:function(e){return this.checkKey(T.Cache.SOUND,e)},checkTextKey:function(e){return this.checkKey(T.Cache.TEXT,e)},checkPhysicsKey:function(e){return this.checkKey(T.Cache.PHYSICS,e)},checkTilemapKey:function(e){return this.checkKey(T.Cache.TILEMAP,e)},checkBinaryKey:function(e){return this.checkKey(T.Cache.BINARY,e)},checkBitmapDataKey:function(e){return this.checkKey(T.Cache.BITMAPDATA,e)},checkBitmapFontKey:function(e){return this.checkKey(T.Cache.BITMAPFONT,e)},checkJSONKey:function(e){return this.checkKey(T.Cache.JSON,e)},checkXMLKey:function(e){return this.checkKey(T.Cache.XML,e)},checkVideoKey:function(e){return this.checkKey(T.Cache.VIDEO,e)},checkShaderKey:function(e){return this.checkKey(T.Cache.SHADER,e)},checkRenderTextureKey:function(e){return this.checkKey(T.Cache.RENDER_TEXTURE,e)},getItem:function(e,t,a,o){if(!this.checkKey(t,e))a&&console.warn("Phaser.Cache."+a+": Key \""+e+"\" not found in Cache.");else return void 0===o?this._cacheMap[t][e]:this._cacheMap[t][e][o];return null},getCanvas:function(e){return this.getItem(e,T.Cache.CANVAS,"getCanvas","canvas")},getImage:function(e,t){(void 0===e||null===e)&&(e="__default"),void 0===t&&(t=!1);var a=this.getItem(e,T.Cache.IMAGE,"getImage");return null===a&&(a=this.getItem("__missing",T.Cache.IMAGE,"getImage")),t?a:a.data},getTextureFrame:function(e){return this.getItem(e,T.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(e){return this.getItem(e,T.Cache.SOUND,"getSound")},getSoundData:function(e){return this.getItem(e,T.Cache.SOUND,"getSoundData","data")},getText:function(e){return this.getItem(e,T.Cache.TEXT,"getText","data")},getPhysicsData:function(e,t,a){var o=this.getItem(e,T.Cache.PHYSICS,"getPhysicsData","data");if(null===o||void 0===t||null===t)return o;if(o[t]){var r=o[t];if(r&&a){for(var n in r)if(n=r[n],n.fixtureKey===a)return n;console.warn("Phaser.Cache.getPhysicsData: Could not find given fixtureKey: \""+a+" in "+e+"\"")}else return r}else console.warn("Phaser.Cache.getPhysicsData: Invalid key/object: \""+e+" / "+t+"\"");return null},getTilemapData:function(e){return this.getItem(e,T.Cache.TILEMAP,"getTilemapData")},getBinary:function(e){return this.getItem(e,T.Cache.BINARY,"getBinary")},getBitmapData:function(e){return this.getItem(e,T.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(e){return this.getItem(e,T.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(e,t){var a=this.getItem(e,T.Cache.JSON,"getJSON","data");return a?t?T.Utils.extend(!0,Array.isArray(a)?[]:{},a):a:null},getXML:function(e){return this.getItem(e,T.Cache.XML,"getXML","data")},getVideo:function(e){return this.getItem(e,T.Cache.VIDEO,"getVideo")},getShader:function(e){return this.getItem(e,T.Cache.SHADER,"getShader","data")},getRenderTexture:function(e){return this.getItem(e,T.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(e,t){return void 0===t&&(t=T.Cache.IMAGE),this.getItem(e,t,"getBaseTexture","base")},getFrame:function(e,t){return void 0===t&&(t=T.Cache.IMAGE),this.getItem(e,t,"getFrame","frame")},getFrameCount:function(e,t){var a=this.getFrameData(e,t);return a?a.total:0},getFrameData:function(e,t){return void 0===t&&(t=T.Cache.IMAGE),this.getItem(e,t,"getFrameData","frameData")},hasFrameData:function(e,t){return void 0===t&&(t=T.Cache.IMAGE),null!==this.getItem(e,t,"","frameData")},updateFrameData:function(e,t,a){void 0===a&&(a=T.Cache.IMAGE),this._cacheMap[a][e]&&(this._cacheMap[a][e].frameData=t)},getFrameByIndex:function(e,t,a){var o=this.getFrameData(e,a);return o?o.getFrame(t):null},getFrameByName:function(e,t,a){var o=this.getFrameData(e,a);return o?o.getFrameByName(t):null},getURL:function(e){var e=this._resolveURL(e);return e?this._urlMap[e]:(console.warn("Phaser.Cache.getUrl: Invalid url: \""+e+"\" or Cache.autoResolveURL was false"),null)},getKeys:function(e){void 0===e&&(e=T.Cache.IMAGE);var t=[];if(this._cacheMap[e])for(var a in this._cacheMap[e])"__default"!=a&&"__missing"!=a&&t.push(a);return t},removeCanvas:function(e){delete this._cache.canvas[e]},removeImage:function(e,t){void 0===t&&(t=!0);var a=this.getImage(e,!0);t&&a.base&&a.base.destroy(),delete this._cache.image[e]},removeSound:function(e){delete this._cache.sound[e]},removeText:function(e){delete this._cache.text[e]},removePhysics:function(e){delete this._cache.physics[e]},removeTilemap:function(e){delete this._cache.tilemap[e]},removeBinary:function(e){delete this._cache.binary[e]},removeBitmapData:function(e){delete this._cache.bitmapData[e]},removeBitmapFont:function(e){delete this._cache.bitmapFont[e]},removeJSON:function(e){delete this._cache.json[e]},removeXML:function(e){delete this._cache.xml[e]},removeVideo:function(e){delete this._cache.video[e]},removeShader:function(e){delete this._cache.shader[e]},removeRenderTexture:function(e){delete this._cache.renderTexture[e]},removeSpriteSheet:function(e){delete this._cache.spriteSheet[e]},removeTextureAtlas:function(e){delete this._cache.image[e]},clearGLTextures:function(){for(var e in this._cache.image)this._cache.image[e].base._glTextures=[]},_resolveURL:function(e,t){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+e,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",t&&(this._urlMap[this._urlTemp]=t),this._urlTemp):null},destroy:function(){for(var e=0,t;e<this._cacheMap.length;e++)for(var a in t=this._cacheMap[e],t)"__default"!=a&&"__missing"!=a&&(this.destroyItem(t[a]),delete t[a]);this._urlMap=null,this._urlResolver=null,this._urlTemp=null},destroyItem:function(e){e.destroy?e.destroy():(e.base&&e.base.destroy&&e.base.destroy(),e.data&&e.data.destroy&&e.data.destroy(),e.frameData&&e.frameData.destroy&&e.frameData.destroy(),e.texture&&e.texture.destroy&&e.texture.destroy(!0))},_addImages:function(){this._pendingCount=0,this.addDefaultImage(),this.addMissingImage();var e=this,t=T.Cache.READY_TIMEOUT;0<T.Cache.READY_TIMEOUT?setTimeout(function(){e.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",t),e._ready())},T.Cache.READY_TIMEOUT):this._ready()},_addPending:function(){this._pendingCount+=1},_removePending:function(){this._pendingCount-=1,this._checkReady()},_checkReady:function(){this.isReady&&this._ready()},_ready:function(){this._pendingCount=0,this.onReady.dispatch(this)}},T.Cache.prototype.constructor=T.Cache,Object.defineProperty(T.Cache.prototype,"isReady",{get:function(){return 0>=this._pendingCount}}),T.Loader=function(e){this.game=e,this.cache=e.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new T.Signal,this.onLoadComplete=new T.Signal,this.onPackComplete=new T.Signal,this.onFileStart=new T.Signal,this.onFileComplete=new T.Signal,this.onFileError=new T.Signal,this.useXDomainRequest=!1,this._warnedAboutXDomainRequest=!1,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},T.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,T.Loader.TEXTURE_ATLAS_JSON_HASH=1,T.Loader.TEXTURE_ATLAS_XML_STARLING=2,T.Loader.PHYSICS_LIME_CORONA_JSON=3,T.Loader.PHYSICS_PHASER_JSON=4,T.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,T.Loader.prototype={setPreloadSprite:function(e,t){t=t||0,this.preloadSprite={sprite:e,direction:t,width:e.width,height:e.height,rect:null},this.preloadSprite.rect=0===t?new T.Rectangle(0,0,1,e.height):new T.Rectangle(0,0,e.width,1),e.crop(this.preloadSprite.rect),e.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(e,t){return-1<this.getAssetIndex(e,t)},getAssetIndex:function(e,t){for(var a=-1,o=0,r;o<this._fileList.length&&(r=this._fileList[o],!(r.type===e&&r.key===t&&(a=o,!r.loaded&&!r.loading)));o++);return a},getAsset:function(e,t){var a=this.getAssetIndex(e,t);return!!(-1<a)&&{index:a,file:this._fileList[a]}},reset:function(e,t){void 0===t&&(t=!1),this.resetLocked||(e&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,t&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(e,t,a,o,r,n){if(void 0===r&&(r=!1),void 0===t||""===t)return console.warn("Phaser.Loader: Invalid or no key given of type "+e),this;if(void 0===a||null===a)if(n)a=t+n;else return console.warn("Phaser.Loader: No URL given for file type: "+e+" key: "+t),this;var i={type:e,key:t,path:this.path,url:a,syncPoint:0<this._withSyncPointDepth,data:null,loading:!1,loaded:!1,error:!1};if(o)for(var s in o)i[s]=o[s];var d=this.getAssetIndex(e,t);if(r&&-1<d){var l=this._fileList[d];l.loading||l.loaded?(this._fileList.push(i),this._totalFileCount++):this._fileList[d]=i}else-1===d&&(this._fileList.push(i),this._totalFileCount++);return this},replaceInFileList:function(e,t,a,o){return this.addToFileList(e,t,a,o,!0)},pack:function(e,t,a,o){if(void 0===t&&(t=null),void 0===a&&(a=null),void 0===o&&(o=null),!t&&!a)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var r={type:"packfile",key:e,url:t,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:o};a&&("string"==typeof a&&(a=JSON.parse(a)),r.data=a||{},r.loaded=!0);for(var n=0,i;n<this._fileList.length+1;n++)if(i=this._fileList[n],!i||!i.loaded&&!i.loading&&"packfile"!==i.type){this._fileList.splice(n,0,r),this._totalPackCount++;break}return this},image:function(e,t,a){return"object"==typeof t?this.texture(e,t,a):this.addToFileList("image",e,t,void 0,a,".png")},imageFromBitmapData:function(e,t,a){return this.image(e,t.canvas.toDataURL("image/png"),a)},texture:function(e,t,a){if(this.game.renderType===T.WEBGL){var o=this.game.renderer.extensions.compression,r;for(r in t)if(r.toUpperCase()in o)return this.addToFileList("texture",e,t[r],void 0,a,".pvr")}return t.truecolor&&this.addToFileList("image",e,t.truecolor,void 0,a,".png"),this},images:function(e,t){if(Array.isArray(t))for(var a=0;a<e.length;a++)this.image(e[a],t[a]);else for(var a=0;a<e.length;a++)this.image(e[a]);return this},text:function(e,t,a){return this.addToFileList("text",e,t,void 0,a,".txt")},json:function(e,t,a){return this.addToFileList("json",e,t,void 0,a,".json")},shader:function(e,t,a){return this.addToFileList("shader",e,t,void 0,a,".frag")},xml:function(e,t,a){return this.addToFileList("xml",e,t,void 0,a,".xml")},script:function(e,t,a,o){return void 0===a&&(a=!1),!1!==a&&void 0===o&&(o=this),this.addToFileList("script",e,t,{syncPoint:!0,callback:a,callbackContext:o},!1,".js")},binary:function(e,t,a,o){return void 0===a&&(a=!1),!1!==a&&void 0===o&&(o=a),this.addToFileList("binary",e,t,{callback:a,callbackContext:o},!1,".bin")},spritesheet:function(e,t,a,o,r,n,i,s){return void 0===r&&(r=-1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===s&&(s=0),this.addToFileList("spritesheet",e,t,{frameWidth:a,frameHeight:o,frameMax:r,margin:n,spacing:i,skipFrames:s},!1,".png")},audio:function(e,t,a){return this.game.sound.noAudio?this:(void 0===a&&(a=!0),"string"==typeof t&&(t=[t]),this.addToFileList("audio",e,t,{buffer:null,autoDecode:a}))},audioSprite:function(e,t,a,o,r){return this.game.sound.noAudio?this:(void 0===a&&(a=null),void 0===o&&(o=null),void 0===r&&(r=!0),this.audio(e,t,r),a?this.json(e+"-audioatlas",a):o?("string"==typeof o&&(o=JSON.parse(o)),this.cache.addJSON(e+"-audioatlas","",o)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},audiosprite:function(e,t,a,o,r){return this.audioSprite(e,t,a,o,r)},video:function(e,t,a,o){return void 0===a&&(this.game.device.firefox?a="loadeddata":a="canplaythrough"),void 0===o&&(o=!1),"string"==typeof t&&(t=[t]),this.addToFileList("video",e,t,{buffer:null,asBlob:o,loadEvent:a})},tilemap:function(e,t,a,o){if(void 0===t&&(t=null),void 0===a&&(a=null),void 0===o&&(o=T.Tilemap.CSV),t||a||(o===T.Tilemap.CSV?t=e+".csv":t=e+".json"),a){switch(o){case T.Tilemap.CSV:break;case T.Tilemap.TILED_JSON:"string"==typeof a&&(a=JSON.parse(a));}this.cache.addTilemap(e,null,a,o)}else this.addToFileList("tilemap",e,t,{format:o});return this},physics:function(e,t,a,o){return void 0===t&&(t=null),void 0===a&&(a=null),void 0===o&&(o=T.Physics.LIME_CORONA_JSON),t||a||(t=e+".json"),a?("string"==typeof a&&(a=JSON.parse(a)),this.cache.addPhysicsData(e,null,a,o)):this.addToFileList("physics",e,t,{format:o}),this},bitmapFont:function(e,t,a,o,r,n){if((void 0===t||null===t)&&(t=e+".png"),void 0===a&&(a=null),void 0===o&&(o=null),null===a&&null===o&&(a=e+".xml"),void 0===r&&(r=0),void 0===n&&(n=0),a)this.addToFileList("bitmapfont",e,t,{atlasURL:a,xSpacing:r,ySpacing:n});else if("string"==typeof o){var i,s;try{i=JSON.parse(o)}catch(t){s=this.parseXml(o)}if(!s&&!i)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",e,t,{atlasURL:null,atlasData:i||s,atlasType:i?"json":"xml",xSpacing:r,ySpacing:n})}return this},atlasJSONArray:function(e,t,a,o){return this.atlas(e,t,a,o,T.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(e,t,a,o){return this.atlas(e,t,a,o,T.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(e,t,a,o){return void 0===a&&(a=null),void 0===o&&(o=null),a||o||(a=e+".xml"),this.atlas(e,t,a,o,T.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(e,t,a,o,r){if((void 0===t||null===t)&&(t=e+".png"),void 0===a&&(a=null),void 0===o&&(o=null),void 0===r&&(r=T.Loader.TEXTURE_ATLAS_JSON_ARRAY),a||o||(r===T.Loader.TEXTURE_ATLAS_XML_STARLING?a=e+".xml":a=e+".json"),a)this.addToFileList("textureatlas",e,t,{atlasURL:a,format:r});else{switch(r){case T.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof o&&(o=JSON.parse(o));break;case T.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof o){var n=this.parseXml(o);if(!n)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");o=n}}this.addToFileList("textureatlas",e,t,{atlasURL:null,atlasData:o,format:r})}return this},withSyncPoint:function(e,t){this._withSyncPointDepth++;try{e.call(t||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(e,t){var a=this.getAsset(e,t);return a&&(a.file.syncPoint=!0),this},removeFile:function(e,t){var a=this.getAsset(e,t);!a||a.loaded||a.loading||this._fileList.splice(a.index,1)},removeAll:function(){this._fileList.length=0,this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(var e=0,t;e<this._flightQueue.length;e++)t=this._flightQueue[e],(t.loaded||t.error)&&(this._flightQueue.splice(e,1),e--,t.loading=!1,t.requestUrl=null,t.requestObject=null,t.error&&this.onFileError.dispatch(t.key,t),"packfile"===t.type?"packfile"===t.type&&t.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(t.key,!t.error,this._loadedPackCount,this._totalPackCount)):(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,t.key,!t.error,this._loadedFileCount,this._totalFileCount)));for(var a=!1,o=this.enableParallel?s(1,this.maxParallelDownloads):1,e=this._processingHead,t;e<this._fileList.length&&(t=this._fileList[e],"packfile"===t.type&&!t.error&&t.loaded&&e===this._processingHead&&(this.processPack(t),this._loadedPackCount++,this.onPackComplete.dispatch(t.key,!t.error,this._loadedPackCount,this._totalPackCount)),t.loaded||t.error?e===this._processingHead&&(this._processingHead=e+1):!t.loading&&this._flightQueue.length<o&&("packfile"!==t.type||t.data?!a&&(!this._fileLoadStarted&&(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(t),t.loading=!0,this.onFileStart.dispatch(this.progress,t.key,t.url),this.loadFile(t)):(this._flightQueue.push(t),t.loading=!0,this.loadFile(t))),!t.loaded&&t.syncPoint&&(a=!0),!(this._flightQueue.length>=o||a&&this._loadedPackCount===this._totalPackCount));e++);if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var r=this;setTimeout(function(){r.finishedLoading(!0)},2e3)}},finishedLoading:function(e){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,!e&&!this._fileLoadStarted&&(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.reset(),this.onLoadComplete.dispatch(),this.game.state.loadComplete())},asyncComplete:function(e,t){void 0===t&&(t=""),e.loaded=!0,e.error=!!t,t&&(e.errorMessage=t,console.warn("Phaser.Loader - "+e.type+"["+e.key+"]: "+t)),this.processLoadQueue()},processPack:function(e){var t=e.data[e.key];if(!t)return void console.warn("Phaser.Loader - "+e.key+": pack has data, but not for pack key");for(var a=0,o;a<t.length;a++)switch(o=t[a],o.type){case"image":this.image(o.key,o.url,o.overwrite);break;case"text":this.text(o.key,o.url,o.overwrite);break;case"json":this.json(o.key,o.url,o.overwrite);break;case"xml":this.xml(o.key,o.url,o.overwrite);break;case"script":this.script(o.key,o.url,o.callback,e.callbackContext||this);break;case"binary":this.binary(o.key,o.url,o.callback,e.callbackContext||this);break;case"spritesheet":this.spritesheet(o.key,o.url,o.frameWidth,o.frameHeight,o.frameMax,o.margin,o.spacing,o.skipFrames);break;case"video":this.video(o.key,o.urls);break;case"audio":this.audio(o.key,o.urls,o.autoDecode);break;case"audiosprite":this.audiosprite(o.key,o.urls,o.jsonURL,o.jsonData,o.autoDecode);break;case"tilemap":this.tilemap(o.key,o.url,o.data,T.Tilemap[o.format]);break;case"physics":this.physics(o.key,o.url,o.data,T.Loader[o.format]);break;case"bitmapFont":this.bitmapFont(o.key,o.textureURL,o.atlasURL,o.atlasData,o.xSpacing,o.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(o.key,o.textureURL,o.atlasURL,o.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(o.key,o.textureURL,o.atlasURL,o.atlasData);break;case"atlasXML":this.atlasXML(o.key,o.textureURL,o.atlasURL,o.atlasData);break;case"atlas":this.atlas(o.key,o.textureURL,o.atlasURL,o.atlasData,T.Loader[o.format]);break;case"shader":this.shader(o.key,o.url,o.overwrite);}},transformUrl:function(e,t){return!!e&&(e.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?e:this.baseURL+t.path+e)},loadFile:function(e){switch(e.type){case"packfile":this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(e);break;case"audio":e.url=this.getAudioURL(e.url),e.url?this.game.sound.usingWebAudio?this.xhrLoad(e,this.transformUrl(e.url,e),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(e):this.fileError(e,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":e.url=this.getVideoURL(e.url),e.url?e.asBlob?this.xhrLoad(e,this.transformUrl(e.url,e),"blob",this.fileComplete):this.loadVideoTag(e):this.fileError(e,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.xmlLoadComplete);break;case"tilemap":e.format===T.Tilemap.TILED_JSON?this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.jsonLoadComplete):e.format===T.Tilemap.CSV?this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.csvLoadComplete):this.asyncComplete(e,"invalid Tilemap format: "+e.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(e,this.transformUrl(e.url,e),"text",this.fileComplete);break;case"texture":"truecolor"===e.key.split("_").pop()?this.loadImageTag(e):this.xhrLoad(e,this.transformUrl(e.url,e),"arraybuffer",this.fileComplete);break;case"binary":this.xhrLoad(e,this.transformUrl(e.url,e),"arraybuffer",this.fileComplete);}},loadImageTag:function(e){var t=this;e.data=new Image,e.data.name=e.key,this.crossOrigin&&(e.data.crossOrigin=this.crossOrigin),e.data.onload=function(){e.data.onload&&(e.data.onload=null,e.data.onerror=null,t.fileComplete(e))},e.data.onerror=function(){e.data.onload&&(e.data.onload=null,e.data.onerror=null,t.fileError(e))},e.data.src=this.transformUrl(e.url,e),!this.game.device.firefox&&e.data.complete&&e.data.width&&e.data.height&&(e.data.onload=null,e.data.onerror=null,this.fileComplete(e))},loadVideoTag:function(e){var t=this;e.data=document.createElement("video"),e.data.name=e.key,e.data.controls=!1,e.data.autoplay=!1;var a=function(){e.data.removeEventListener(e.loadEvent,a,!1),e.data.onerror=null,e.data.canplay=!0,T.GAMES[t.game.id].load.fileComplete(e)};e.data.onerror=function(){e.data.removeEventListener(e.loadEvent,a,!1),e.data.onerror=null,e.data.canplay=!1,t.fileError(e)},e.data.addEventListener(e.loadEvent,a,!1),e.data.src=this.transformUrl(e.url,e),e.data.load()},loadAudioTag:function(e){var t=this;if(this.game.sound.touchLocked)e.data=new Audio,e.data.name=e.key,e.data.preload="auto",e.data.src=this.transformUrl(e.url,e),this.fileComplete(e);else{e.data=new Audio,e.data.name=e.key;var a=function(){e.data.removeEventListener("canplaythrough",a,!1),e.data.onerror=null,t.fileComplete(e)};e.data.onerror=function(){e.data.removeEventListener("canplaythrough",a,!1),e.data.onerror=null,t.fileError(e)},e.data.preload="auto",e.data.src=this.transformUrl(e.url,e),e.data.addEventListener("canplaythrough",a,!1),e.data.load()}},xhrLoad:function(t,e,a,o,r){if(this.useXDomainRequest&&window.XDomainRequest)return void this.xhrLoadWithXDR(t,e,a,o,r);var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType=a,!1!==this.headers.requestedWith&&n.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&n.setRequestHeader("Accept",this.headers[t.type]),r=r||this.fileError;var i=this;n.onload=function(){try{return 4===n.readyState&&400<=n.status&&599>=n.status?r.call(i,t,n):o.call(i,t,n)}catch(a){i.hasLoaded?window.console&&console.error(a):i.asyncComplete(t,a.message||"Exception")}},n.onerror=function(){try{return r.call(i,t,n)}catch(a){i.hasLoaded?window.console&&console.error(a):i.asyncComplete(t,a.message||"Exception")}},t.requestObject=n,t.requestUrl=e,n.send()},xhrLoadWithXDR:function(t,e,a,o,r){this._warnedAboutXDomainRequest||this.game.device.ie&&!(10<=this.game.device.ieVersion)||(this._warnedAboutXDomainRequest=!0,console.warn("Phaser.Loader - using XDomainRequest outside of IE 9"));var n=new window.XDomainRequest;n.open("GET",e,!0),n.responseType=a,n.timeout=3e3,r=r||this.fileError;var i=this;n.onerror=function(){try{return r.call(i,t,n)}catch(a){i.asyncComplete(t,a.message||"Exception")}},n.ontimeout=function(){try{return r.call(i,t,n)}catch(a){i.asyncComplete(t,a.message||"Exception")}},n.onprogress=function(){},n.onload=function(){try{return 4===n.readyState&&400<=n.status&&599>=n.status?r.call(i,t,n):o.call(i,t,n)}catch(a){i.asyncComplete(t,a.message||"Exception")}},t.requestObject=n,t.requestUrl=e,setTimeout(function(){n.send()},0)},getVideoURL:function(e){for(var t=0;t<e.length;t++){var a=e[t],o;if(!a.uri){if(0===a.indexOf("blob:")||0===a.indexOf("data:"))return a;0<=a.indexOf("?")&&(a=a.substr(0,a.indexOf("?")));var r=a.substr((s(0,a.lastIndexOf("."))||Infinity)+1);if(o=r.toLowerCase(),this.game.device.canPlayVideo(o))return e[t]}else if(o=a.type,a=a.uri,this.game.device.canPlayVideo(o))return a}return null},getAudioURL:function(e){if(this.game.sound.noAudio)return null;for(var t=0;t<e.length;t++){var a=e[t],o;if(!a.uri){if(0===a.indexOf("blob:")||0===a.indexOf("data:"))return a;0<=a.indexOf("?")&&(a=a.substr(0,a.indexOf("?")));var r=a.substr((s(0,a.lastIndexOf("."))||Infinity)+1);if(o=r.toLowerCase(),this.game.device.canPlayAudio(o))return e[t]}else if(o=a.type,a=a.uri,this.game.device.canPlayAudio(o))return a}return null},fileError:function(e,t,a){var o=e.requestUrl||this.transformUrl(e.url,e),r="error loading asset from URL "+o;!a&&t&&(a=t.status),a&&(r=r+" ("+a+")"),this.asyncComplete(e,r)},fileComplete:function(e,t){var a=!0;switch(e.type){case"packfile":var o=JSON.parse(t.responseText);e.data=o||{};break;case"texture":var r=/\.([^.]+)$/.exec(e.url.split("?",1)[0])[1].toLowerCase();null===e.data?this.cache.addCompressedTextureMetaData(e.key,e.url,r,t.response):this.cache.addCompressedTextureMetaData(e.key,e.url,r,e.data);break;case"image":this.cache.addImage(e.key,e.url,e.data);break;case"spritesheet":this.cache.addSpriteSheet(e.key,e.url,e.data,e.frameWidth,e.frameHeight,e.frameMax,e.margin,e.spacing,e.skipFrames);break;case"textureatlas":if(null==e.atlasURL)this.cache.addTextureAtlas(e.key,e.url,e.data,e.atlasData,e.format);else if(a=!1,e.format===T.Loader.TEXTURE_ATLAS_JSON_ARRAY||e.format===T.Loader.TEXTURE_ATLAS_JSON_HASH||e.format===T.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(e,this.transformUrl(e.atlasURL,e),"text",this.jsonLoadComplete);else if(e.format===T.Loader.TEXTURE_ATLAS_XML_STARLING)this.xhrLoad(e,this.transformUrl(e.atlasURL,e),"text",this.xmlLoadComplete);else throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+e.format);break;case"bitmapfont":e.atlasURL?(a=!1,this.xhrLoad(e,this.transformUrl(e.atlasURL,e),"text",function(e,t){var a;try{a=JSON.parse(t.responseText)}catch(t){}a?(e.atlasType="json",this.jsonLoadComplete(e,t)):(e.atlasType="xml",this.xmlLoadComplete(e,t))})):this.cache.addBitmapFont(e.key,e.url,e.data,e.atlasData,e.atlasType,e.xSpacing,e.ySpacing);break;case"video":if(e.asBlob)try{e.data=t.response}catch(t){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+e.key)}this.cache.addVideo(e.key,e.url,e.data,e.asBlob);break;case"audio":this.game.sound.usingWebAudio?(e.data=t.response,this.cache.addSound(e.key,e.url,e.data,!0,!1),e.autoDecode&&this.game.sound.decode(e.key)):this.cache.addSound(e.key,e.url,e.data,!1,!0);break;case"text":e.data=t.responseText,this.cache.addText(e.key,e.url,e.data);break;case"shader":e.data=t.responseText,this.cache.addShader(e.key,e.url,e.data);break;case"physics":var o=JSON.parse(t.responseText);this.cache.addPhysicsData(e.key,e.url,o,e.format);break;case"script":e.data=document.createElement("script"),e.data.language="javascript",e.data.type="text/javascript",e.data.defer=!1,e.data.text=t.responseText,document.head.appendChild(e.data),e.callback&&(e.data=e.callback.call(e.callbackContext,e.key,t.responseText));break;case"binary":e.data=e.callback?e.callback.call(e.callbackContext,e.key,t.response):t.response,this.cache.addBinary(e.key,e.data);}a&&this.asyncComplete(e)},jsonLoadComplete:function(e,t){var a=JSON.parse(t.responseText);"tilemap"===e.type?this.cache.addTilemap(e.key,e.url,a,e.format):"bitmapfont"===e.type?this.cache.addBitmapFont(e.key,e.url,e.data,a,e.atlasType,e.xSpacing,e.ySpacing):"json"===e.type?this.cache.addJSON(e.key,e.url,a):this.cache.addTextureAtlas(e.key,e.url,e.data,a,e.format),this.asyncComplete(e)},csvLoadComplete:function(e,t){var a=t.responseText;this.cache.addTilemap(e.key,e.url,a,e.format),this.asyncComplete(e)},xmlLoadComplete:function(e,t){var a=t.responseText,o=this.parseXml(a);if(!o){var r=t.responseType||t.contentType;return console.warn("Phaser.Loader - "+e.key+": invalid XML ("+r+")"),void this.asyncComplete(e,"invalid XML")}"bitmapfont"===e.type?this.cache.addBitmapFont(e.key,e.url,e.data,o,e.atlasType,e.xSpacing,e.ySpacing):"textureatlas"===e.type?this.cache.addTextureAtlas(e.key,e.url,e.data,o,e.format):"xml"===e.type&&this.cache.addXML(e.key,e.url,o),this.asyncComplete(e)},parseXml:function(e){var t;try{if(window.DOMParser){var a=new DOMParser;t=a.parseFromString(e,"text/xml")}else t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)}catch(a){t=null}return t&&t.documentElement&&!t.getElementsByTagName("parsererror").length?t:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=c(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=c(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(T.Loader.prototype,"progressFloat",{get:function(){var e=100*(this._loadedFileCount/this._totalFileCount);return T.Math.clamp(e||0,0,100)}}),Object.defineProperty(T.Loader.prototype,"progress",{get:function(){return n(this.progressFloat)}}),T.Loader.prototype.constructor=T.Loader,T.LoaderParser={bitmapFont:function(e,t,a,o,r,n){return this.xmlBitmapFont(e,t,a,o,r,n)},xmlBitmapFont:function(e,t,a,o,r,n){null==n&&(n=1);var s={},d=e.getElementsByTagName("info")[0],l=e.getElementsByTagName("common")[0];s.font=d.getAttribute("face"),s.size=parseInt(d.getAttribute("size"),10),s.lineHeight=parseInt(l.getAttribute("lineHeight"),10)+o,s.chars={};for(var p=e.getElementsByTagName("char"),c=r?r.x:0,u=r?r.y:0,h=0,i;h<p.length;h++)i=parseInt(p[h].getAttribute("id"),10),s.chars[i]={x:c+parseInt(p[h].getAttribute("x"),10),y:u+parseInt(p[h].getAttribute("y"),10),width:parseInt(p[h].getAttribute("width"),10),height:parseInt(p[h].getAttribute("height"),10),xOffset:parseInt(p[h].getAttribute("xoffset"),10)/n,yOffset:parseInt(p[h].getAttribute("yoffset"),10)/n,xAdvance:(parseInt(p[h].getAttribute("xadvance"),10)+a)/n,kerning:{}};var g=e.getElementsByTagName("kerning");for(h=0;h<g.length;h++){var m=parseInt(g[h].getAttribute("first"),10),y=parseInt(g[h].getAttribute("second"),10),f=parseInt(g[h].getAttribute("amount"),10)/n;s.chars[y].kerning[m]=f}return this.finalizeBitmapFont(t,s)},jsonBitmapFont:function(e,t,a,o,r,n){null==n&&(n=1);var i={font:e.font.info._face,size:parseInt(e.font.info._size,10),lineHeight:parseInt(e.font.common._lineHeight,10)+o,chars:{}},s=r?r.x:0,d=r?r.y:0;return e.font.chars.char.forEach(function(e){var t=parseInt(e._id,10);i.chars[t]={x:s+parseInt(e._x,10),y:d+parseInt(e._y,10),width:parseInt(e._width,10),height:parseInt(e._height,10),xOffset:parseInt(e._xoffset,10)/n,yOffset:parseInt(e._yoffset,10)/n,xAdvance:(parseInt(e._xadvance,10)+a)/n,kerning:{}}}),e.font.kernings&&e.font.kernings.kerning&&e.font.kernings.kerning.forEach(function(e){i.chars[e._second].kerning[e._first]=parseInt(e._amount,10)/n}),this.finalizeBitmapFont(t,i)},finalizeBitmapFont:function(e,t){return Object.keys(t.chars).forEach(function(a){var o=t.chars[a];o.texture=new PIXI.Texture(e,new T.Rectangle(o.x,o.y,o.width,o.height))}),t},pvr:function(e){var t=new Uint32Array(e.slice(0,52)),a=new Uint8Array(e),o=null,r=t[3]<<32|t[2],n=0,i;return 55727696===t[0]&&0<=[0,1,2,3,6,7,9,11].indexOf(r)&&(0<=r&&3>=r?i="PVRTC":7<=r&&11>=r?i="S3TC":6==r&&(i="ETC1"),n=0==r?35841:1==r?35843:2==r?35840:3==r?35842:6==r?36196:7==r?33777:9==r?33778:11==r?33779:-1,o={complete:!0,fileFormat:"PVR",compressionAlgorithm:i,flags:t[1],pixelFormat:r,colorSpace:t[4],channelType:t[5],height:t[6],width:t[7],depth:t[8],numberOfSurfaces:t[9],numberOfFaces:t[10],numberOfMipmaps:t[11],metaDataSize:t[12],textureData:a.subarray(52+t[12],a.byteLength),glExtensionFormat:n}),o},dds:function(e){var t=new Uint8Array(e),o=new Uint32Array(e),r=null;return 68===t[0]&&68===t[1]&&83===t[2]&&32===t[3]&&(r={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:o[1],flags:o[2],height:o[3],width:o[4],pitch:o[5],depth:o[6],mipmapCount:o[7],formatSize:o[19],formatFlag:o[19],formatFourCC:[a(t[84]),a(t[85]),a(t[86]),a(t[87])].join(""),formatBitCount:o[21],formatRBitMask:o[22],formatGBitMask:o[23],formatBBitMask:o[24],formatABitMask:o[25],caps1:o[26],caps2:o[27],caps3:o[28],caps4:o[29],reserved2:o[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:t.subarray(o[1]+4,t.byteLength)},"DX10"===r.formatFourCC&&(r.DXGIFormat=o[31],r.resourceDimension=o[32],r.miscFlag=o[33],r.arraySize=o[34],r.miscFlag=o[35])),r},ktx:function(e){var t=new Uint8Array(e),a=new Uint32Array(e),o=null,r=0|16+a[15]/4,n=a[r],i=a[7],s=0;return 171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11]&&0<=[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(i)&&(36196===i?s="ETC1":35840===i||35841===i||35842===i||35843===i?s="PVRTC":33776===i||33777===i||33778===i||33779===i?s="S3TC":void 0,o={complete:!0,fileFormat:"KTX",compressionAlgorithm:s,endianness:a[3],glType:a[4],glTypeSize:a[5],glFormat:a[6],glInternalFormat:a[7],glBaseInternalFormat:a[8],width:a[9],height:a[10],pixelDepth:a[11],numberOfArrayElements:a[12],numberOfFaces:a[13],numberOfMipmapLevels:a[14],bytesOfKeyValueData:a[15],keyAndValueByteSize:a[16],imageSize:n,textureData:t.subarray(4*(r+1),n+100)}),o},pkm:function(e){var t=new Uint8Array(e),a=null;return 80===t[0]&&75===t[1]&&77===t[2]&&32===t[3]&&(a={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(t[6]<<8|t[7]),width:65535&(t[8]<<8|t[9]),height:65535&(t[10]<<8|t[11]),originalWidth:65535&(t[12]<<8|t[13]),originalHeight:65535&(t[14]<<8|t[15]),textureData:t.subarray(16,t.length)}),a}},T.AudioSprite=function(e,t){for(var a in this.game=e,this.key=t,this.config=this.game.cache.getJSON(t+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={},this.config.spritemap){var o=this.config.spritemap[a],r=this.game.add.sound(this.key);r.addMarker(a,o.start,o.end-o.start,null,o.loop),this.sounds[a]=r}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},T.AudioSprite.prototype={play:function(e,t){return void 0===t&&(t=1),this.sounds[e].play(e,null,t)},stop:function(e){if(!e)for(var t in this.sounds)this.sounds[t].stop();else this.sounds[e].stop()},get:function(e){return this.sounds[e]}},T.AudioSprite.prototype.constructor=T.AudioSprite,T.Sound=function(e,t,a,o,r){void 0===a&&(a=1),void 0===o&&(o=!1),void 0===r&&(r=e.sound.connectToMaster),this.game=e,this.name=t,this.key=t,this.loop=o,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._globalVolume=1,this._markedToDelete=!1,this._removeFromSoundManager=!1,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,this.gainNode=void 0===this.context.createGain?this.context.createGainNode():this.context.createGain(),this.gainNode.gain.value=a*this.game.sound.volume,r&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(t)&&this.game.cache.isSoundReady(t)?(this._sound=this.game.cache.getSoundData(t),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new T.Signal,this.onPlay=new T.Signal,this.onPause=new T.Signal,this.onResume=new T.Signal,this.onLoop=new T.Signal,this.onStop=new T.Signal,this.onMute=new T.Signal,this.onMarkerComplete=new T.Signal,this.onFadeComplete=new T.Signal,this._volume=a,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},T.Sound.prototype={soundHasUnlocked:function(e){e===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(e,t,a,o,r){(void 0===a||null===a)&&(a=1),(void 0===o||null===o)&&(o=1),void 0===r&&(r=!1),this.markers[e]={name:e,start:t,stop:t+a,volume:o,duration:a,durationMS:1e3*a,loop:r}},removeMarker:function(e){delete this.markers[e]},onEndedHandler:function(){this._sound.onended=null,this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this._markedToDelete&&(this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))},update:function(){return this.game.cache.checkSoundKey(this.key)?void(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))):void this.destroy()},loopFull:function(e){return this.play(null,0,e,!0)},play:function(e,t,a,o,r){if((void 0===e||!1===e||null===e)&&(e=""),void 0===r&&(r=!0),this.isPlaying&&!this.allowMultiple&&!r&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||r)){if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(t){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);this.isPlaying=!1}if(""===e&&0<Object.keys(this.markers).length)return this;if(""===e)t=t||0,void 0===a&&(a=this._volume),void 0===o&&(o=this.loop),this.position=s(0,t),this.volume=a,this.loop=o,this.duration=0,this.durationMS=0,this._tempMarker=e,this._tempPosition=t,this._tempVolume=a,this._tempLoop=o;else if(this.markers[e])this.currentMarker=e,this.position=this.markers[e].start,this.volume=this.markers[e].volume,this.loop=this.markers[e].loop,this.duration=this.markers[e].duration,this.durationMS=this.markers[e].durationMS,"undefined"!=typeof a&&(this.volume=a),"undefined"!=typeof o&&(this.loop=o),this._tempMarker=e,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop;else return console.warn("Phaser.Sound.play: audio marker "+e+" doesn't exist"),this;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===e&&(this._sound.loop=!0),!this.loop&&""===e&&(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=l(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===e?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted||this.game.sound.mute?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0,this},restart:function(e,t,a,o){e=e||"",t=t||0,a=a||1,void 0===o&&(o=!1),this.play(e,t,a,o,!0)},pause:function(){this.isPlaying&&this._sound&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var e=s(0,this.position+this.pausedPosition/1e3);this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));var t=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,e,t):this.loop&&this.game.device.chrome?42===this.game.device.chromeVersion?this._sound.start(0):this._sound.start(0,e):this._sound.start(0,e,t)}else this._sound.currentTime=this._tempPause,this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound)if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(t){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);if(this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var e=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,e)}},fadeIn:function(e,t,a){void 0===t&&(t=!1),void 0===a&&(a=this.currentMarker),this.paused||(this.play(a,0,0,t),this.fadeTo(e,1))},fadeOut:function(e){this.fadeTo(e,0)},fadeTo:function(e,t){if(this.isPlaying&&!this.paused&&t!==this.volume)return void 0===e&&(e=1e3),void 0===t?void console.warn("Phaser.Sound.fadeTo: No Volume Specified."):void(this.fadeTween=this.game.add.tween(this).to({volume:t},e,T.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this))},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},updateGlobalVolume:function(e){this.usingAudioTag&&this._sound&&(this._globalVolume=e,this._sound.volume=this._globalVolume*this._volume)},destroy:function(e){void 0===e&&(e=!0),this._markedToDelete=!0,this._removeFromSoundManager=e,this.stop(),e?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())}},T.Sound.prototype.constructor=T.Sound,Object.defineProperty(T.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(T.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(T.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(e){e=e||!1,e===this._muted||(e?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(T.Sound.prototype,"volume",{get:function(){return this._volume},set:function(e){return this.usingAudioTag&&(e=this.game.math.clamp(e,0,1)),this._muted?void(this._muteVolume=e):void(this._tempVolume=e,this._volume=e,this.usingWebAudio?this.gainNode.gain.value=e:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*e))}}),T.SoundManager=function(e){this.game=e,this.onSoundDecode=new T.Signal,this.onVolumeChange=new T.Signal,this.onMute=new T.Signal,this.onUnMute=new T.Signal,this.context=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new T.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null},T.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&!1===this.game.device.webAudio&&(this.channels=1),window.PhaserGlobal){if(!0===window.PhaserGlobal.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===window.PhaserGlobal.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(window.PhaserGlobal&&window.PhaserGlobal.audioContext)this.context=window.PhaserGlobal.audioContext;else if(!!window.AudioContext)try{this.context=new window.AudioContext}catch(e){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}else if(!!window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(e){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,this.masterGain=void 0===this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination);!this.noAudio&&this.game.device.needsTouchUnlock()&&this.setTouchLock()},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(8<this.game.device.iOSVersion||55<=this.game.device.chromeVersion?this.game.input.addTouchLockCallback(this.unlock,this,!0):this.game.input.addTouchLockCallback(this.unlock,this),this.touchLocked=!0)},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.touchLocked=!1,this._unlockSource=null;else if(this.usingWebAudio){var e=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=e,this._unlockSource.connect(this.context.destination),void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),"suspended"===this._unlockSource.context.state&&this._unlockSource.context.resume()}return!0},stopAll:function(){if(!this.noAudio)for(var e=0;e<this._sounds.length;e++)this._sounds[e]&&this._sounds[e].stop()},pauseAll:function(){if(!this.noAudio)for(var e=0;e<this._sounds.length;e++)this._sounds[e]&&this._sounds[e].pause()},resumeAll:function(){if(!this.noAudio)for(var e=0;e<this._sounds.length;e++)this._sounds[e]&&this._sounds[e].resume()},decode:function(e,t){t=t||null;var a=this.game.cache.getSoundData(e);if(a&&!1===this.game.cache.isSoundDecoded(e)){this.game.cache.updateSound(e,"isDecoding",!0);var o=this;try{this.context.decodeAudioData(a,function(a){a&&(o.game.cache.decodedSound(e,a),o.onSoundDecode.dispatch(e,t))})}catch(t){}}},setDecodedCallback:function(e,t,a){"string"==typeof e&&(e=[e]),this._watchList.reset();for(var o=0;o<e.length;o++)e[o]instanceof T.Sound?this.game.cache.isSoundDecoded(e[o].key)||this._watchList.add(e[o].key):this.game.cache.isSoundDecoded(e[o])||this._watchList.add(e[o]);0===this._watchList.total?(this._watching=!1,t.call(a)):(this._watching=!0,this._watchCallback=t,this._watchContext=a)},update:function(){if(!this.noAudio){this.touchLocked&&null!==this._unlockSource&&(this._unlockSource.playbackState===this._unlockSource.PLAYING_STATE||this._unlockSource.playbackState===this._unlockSource.FINISHED_STATE)&&(this.touchLocked=!1,this._unlockSource=null);for(var e=0;e<this._sounds.length;e++)this._sounds[e].update();if(this._watching){for(var t=this._watchList.first;t;)this.game.cache.isSoundDecoded(t)&&this._watchList.remove(t),t=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(e,t,a,o){void 0===t&&(t=1),void 0===a&&(a=!1),void 0===o&&(o=this.connectToMaster);var r=new T.Sound(this.game,e,t,a,o);return this._sounds.push(r),r},addSprite:function(e){var t=new T.AudioSprite(this.game,e);return t},remove:function(e){for(var t=this._sounds.length;t--;)if(this._sounds[t]===e)return this._sounds[t].destroy(!1),this._sounds.splice(t,1),!0;return!1},removeByKey:function(e){for(var t=this._sounds.length,a=0;t--;)this._sounds[t].key===e&&(this._sounds[t].destroy(!1),this._sounds.splice(t,1),a++);return a},play:function(e,t,a){if(!this.noAudio){var o=this.add(e,t,a);return o.play(),o}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var e=0;e<this._sounds.length;e++)this._sounds[e].usingAudioTag&&(this._sounds[e].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1,this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var e=0;e<this._sounds.length;e++)this._sounds[e].usingAudioTag&&(this._sounds[e].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.stopAll();for(var e=0;e<this._sounds.length;e++)this._sounds[e]&&this._sounds[e].destroy();this._sounds=[],this.onSoundDecode.dispose(),this.context&&(window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close())}},T.SoundManager.prototype.constructor=T.SoundManager,Object.defineProperty(T.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(e){if(e=e||!1,e){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(T.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(e){if(0>e?e=0:1<e&&(e=1),this._volume!==e){if(this._volume=e,this.usingWebAudio)this.masterGain.gain.value=e;else for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&this._sounds[t].updateGlobalVolume(e);this.onVolumeChange.dispatch(e)}}}),T.ScaleManager=function(e,t,a){this.game=e,this.dom=T.DOM,this.grid=null,this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new T.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new T.Signal,this.enterIncorrectOrientation=new T.Signal,this.leaveIncorrectOrientation=new T.Signal,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new T.Signal,this.onFullScreenChange=new T.Signal,this.onFullScreenError=new T.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new T.Point(1,1),this.scaleFactorInversed=new T.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new T.Rectangle,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=T.ScaleManager.NO_SCALE,this._fullScreenScaleMode=T.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new T.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new T.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new T.Rectangle,this._userScaleFactor=new T.Point(1,1),this._userScaleTrim=new T.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new T.Rectangle,this._tempBounds=new T.Rectangle,this._lastReportedCanvasSize=new T.Rectangle,this._lastReportedGameSize=new T.Rectangle,this._booted=!1,e.config&&this.parseConfig(e.config),this.setupScale(t,a)},T.ScaleManager.EXACT_FIT=0,T.ScaleManager.NO_SCALE=1,T.ScaleManager.SHOW_ALL=2,T.ScaleManager.RESIZE=3,T.ScaleManager.USER_SCALE=4,T.ScaleManager.prototype={boot:function(){var e=this.compatibility;e.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?e.scrollTo=new T.Point(0,1):e.scrollTo=new T.Point(0,0)),this.game.device.desktop?(e.orientationFallback="screen",e.clickTrampoline="when-not-mouse"):(e.orientationFallback="",e.clickTrampoline="");var t=this;this._orientationChange=function(e){return t.orientationChange(e)},this._windowResize=function(e){return t.windowResize(e)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(e){return t.fullScreenChange(e)},this._fullScreenError=function(e){return t.fullScreenError(e)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),T.FlexGrid&&(this.grid=new T.FlexGrid(this,this.width,this.height)),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(e){void 0!==e.scaleMode&&(this._booted?this.scaleMode=e.scaleMode:this._pendingScaleMode=e.scaleMode),void 0!==e.fullScreenScaleMode&&(this.fullScreenScaleMode=e.fullScreenScaleMode),e.fullScreenTarget&&(this.fullScreenTarget=e.fullScreenTarget)},setupScale:function(e,t){var a=new T.Rectangle,o;""!==this.game.parent&&("string"==typeof this.game.parent?o=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(o=this.game.parent)),o?(this.parentNode=o,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds),a.width=this._parentBounds.width,a.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,a.width=this.dom.visualBounds.width,a.height=this.dom.visualBounds.height,this.offset.set(0,0));var r=0,n=0;"number"==typeof e?r=e:(this.parentScaleFactor.x=parseInt(e,10)/100,r=a.width*this.parentScaleFactor.x),"number"==typeof t?n=t:(this.parentScaleFactor.y=parseInt(t,10)/100,n=a.height*this.parentScaleFactor.y),r=c(r),n=c(n),this._gameSize.setTo(0,0,r,n),this.updateDimensions(r,n,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(e,t){this._gameSize.setTo(0,0,e,t),this.currentScaleMode!==T.ScaleManager.RESIZE&&this.updateDimensions(e,t,!0),this.queueUpdate(!0)},setUserScale:function(e,t,a,o,r,n){this._userScaleFactor.setTo(e,t),this._userScaleTrim.setTo(0|a,0|o),void 0===r&&(r=!0),void 0===n&&(n=!0),r&&this.queueUpdate(n)},setResizeCallback:function(e,t){this.onResize=e,this.onResizeContext=t},signalSizeChange:function(){if(!T.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!T.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var e=this.width,t=this.height;this._lastReportedCanvasSize.setTo(0,0,e,t),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.grid&&this.grid.onResize(e,t),this.onSizeChange.dispatch(this,e,t),this.currentScaleMode===T.ScaleManager.RESIZE&&(this.game.state.resize(e,t),this.game.load.resize(e,t))}},setMinMax:function(e,t,a,o){this.minWidth=e,this.minHeight=t,"undefined"!=typeof a&&(this.maxWidth=a),"undefined"!=typeof o&&(this.maxHeight=o)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var e=this._updateThrottle;this._updateThrottleReset=400<=e?0:100,this.dom.getOffset(this.game.canvas,this.offset);var t=this._parentBounds.width,a=this._parentBounds.height,o=this.getParentBounds(this._parentBounds),r=o.width!==t||o.height!==a,n=this.updateOrientationState();(r||n)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,o),this.updateLayout(),this.signalSizeChange());var i=2*this._updateThrottle;this._updateThrottle<e&&(i=p(e,this._updateThrottleReset)),this._updateThrottle=T.Math.clamp(i,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(e,t,a){this.width=e*this.parentScaleFactor.x,this.height=t*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),a&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(e,t){return void 0===t&&(t=!1),!0===e&&!0===t?void console.warn("Phaser.ScaleManager: forceLandscape and forcePortrait cannot both be true."):void(this.forceLandscape=e,this.forcePortrait=t,this.queueUpdate(!0))},classifyOrientation:function(e){return"portrait-primary"===e||"portrait-secondary"===e?"portrait":"landscape-primary"===e||"landscape-secondary"===e?"landscape":null},updateOrientationState:function(){var e=this.screenOrientation,t=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var a=e!==this.screenOrientation,o=t!==this.incorrectOrientation;return o&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(a||o)&&this.onOrientationChange.dispatch(this,e,t),a||o},orientationChange:function(e){this.event=e,this.queueUpdate(!0)},windowResize:function(e){this.event=e,this.queueUpdate(!0)},scrollTop:function(){var e=this.compatibility.scrollTo;e&&window.scrollTo(e.x,e.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var e=this.currentScaleMode;if(e===T.ScaleManager.RESIZE)return void this.reflowGame();if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():e===T.ScaleManager.EXACT_FIT?this.setExactFit():e===T.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():e===T.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):e===T.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(e===T.ScaleManager.SHOW_ALL||e===T.ScaleManager.USER_SCALE)){var t=this.getParentBounds(this._tempBounds);this.width=p(this.width,t.width),this.height=p(this.height,t.height)}this.width|=0,this.height|=0,this.reflowCanvas()},getParentBounds:function(e){var t=e||new T.Rectangle,a=this.boundingParent,o=this.dom.visualBounds,r=this.dom.layoutBounds;if(!a)t.setTo(0,0,o.width,o.height);else{var i=a.getBoundingClientRect(),s=a.offsetParent?a.offsetParent.getBoundingClientRect():a.getBoundingClientRect();t.setTo(i.left-s.left,i.top-s.top,i.width,i.height);var d=this.windowConstraints;if(d.right){var l="layout"===d.right?r:o;t.right=p(t.right,l.width)}if(d.bottom){var l="layout"===d.bottom?r:o;t.bottom=p(t.bottom,l.height)}}return t.setTo(n(t.x),n(t.y),n(t.width),n(t.height)),t},align:function(e,t){null!=e&&(this.pageAlignHorizontally=e),null!=t&&(this.pageAlignVertically=t)},alignCanvas:function(e,t){var a=this.getParentBounds(this._tempBounds),o=this.game.canvas,r=this.margin;if(e){r.left=r.right=0;var i=o.getBoundingClientRect();if(this.width<a.width&&!this.incorrectOrientation){var d=i.left-a.x,l=a.width/2-this.width/2;l=s(l,0);var p=l-d;r.left=n(p)}o.style.marginLeft=r.left+"px",0!==r.left&&(r.right=-(a.width-i.width-r.left),o.style.marginRight=r.right+"px")}if(t){r.top=r.bottom=0;var i=o.getBoundingClientRect();if(this.height<a.height&&!this.incorrectOrientation){var d=i.top-a.y,l=a.height/2-this.height/2;l=s(l,0);var p=l-d;r.top=n(p)}o.style.marginTop=r.top+"px",0!==r.top&&(r.bottom=-(a.height-i.height-r.top),o.style.marginBottom=r.bottom+"px")}r.x=r.left,r.y=r.top},reflowGame:function(){this.resetCanvas("","");var e=this.getParentBounds(this._tempBounds);this.updateDimensions(e.width,e.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=T.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=T.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height)),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()},resetCanvas:function(e,t){void 0===e&&(e=this.width+"px"),void 0===t&&(t=this.height+"px");var a=this.game.canvas;this.compatibility.noMargins||(a.style.marginLeft="",a.style.marginTop="",a.style.marginRight="",a.style.marginBottom=""),a.style.width=e,a.style.height=t},queueUpdate:function(e){e&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(e){e&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(e){var t=this.getParentBounds(this._tempBounds),a=t.width,o=t.height,r;r=e?s(o/this.game.height,a/this.game.width):p(o/this.game.height,a/this.game.width),this.width=n(this.game.width*r),this.height=n(this.game.height*r)},setExactFit:function(){var e=this.getParentBounds(this._tempBounds);this.width=e.width,this.height=e.height,this.isFullScreen||(this.maxWidth&&(this.width=p(this.width,this.maxWidth)),this.maxHeight&&(this.height=p(this.height,this.maxHeight)))},createFullScreenTarget:function(){var e=document.createElement("div");return e.style.margin="0",e.style.padding="0",e.style.background="#000",e},startFullScreen:function(e,t){if(this.isFullScreen)return!1;if(!this.compatibility.supportsFullScreen){var a=this;return void setTimeout(function(){a.fullScreenError()},10)}if("when-not-mouse"===this.compatibility.clickTrampoline){var o=this.game.input;if(o.activePointer&&o.activePointer!==o.mousePointer&&(t||!1!==t))return void o.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[e,!1])}void 0!==e&&this.game.renderType===T.CANVAS&&(this.game.stage.smoothed=e);var r=this.fullScreenTarget;r||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),r=this._createdFullScreenTarget);var n={targetElement:r};if(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,n),this._createdFullScreenTarget){var i=this.game.canvas,s=i.parentNode;s.insertBefore(r,i),r.appendChild(i)}return this.game.device.fullscreenKeyboard?r[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):r[this.game.device.requestFullscreen](),!0},stopFullScreen:function(){return this.isFullScreen&&this.compatibility.supportsFullScreen&&(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),!0)},cleanupCreatedTarget:function(){var e=this._createdFullScreenTarget;if(e&&e.parentNode){var t=e.parentNode;t.insertBefore(this.game.canvas,e),t.removeChild(e)}this._createdFullScreenTarget=null},prepScreenMode:function(e){var t=!!this._createdFullScreenTarget,a=this._createdFullScreenTarget||this.fullScreenTarget;e?(t||this.fullScreenScaleMode===T.ScaleManager.EXACT_FIT)&&a!==this.game.canvas&&(this._fullScreenRestore={targetWidth:a.style.width,targetHeight:a.style.height},a.style.width="100%",a.style.height="100%"):(this._fullScreenRestore&&(a.style.width=this._fullScreenRestore.targetWidth,a.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(e){this.event=e,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(e){this.event=e,this.cleanupCreatedTarget(),console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"),this.onFullScreenError.dispatch(this)},scaleSprite:function(e,t,a,o){if(void 0===t&&(t=this.width),void 0===a&&(a=this.height),void 0===o&&(o=!1),!e||!e.scale)return e;if(e.scale.x=1,e.scale.y=1,0>=e.width||0>=e.height||0>=t||0>=a)return e;var r=t,n=e.height*t/e.width,i=e.width*a/e.height,s=a,d=i>t;return d=d?o:!o,d?(e.width=c(r),e.height=c(n)):(e.width=c(i),e.height=c(s)),e},destroy:function(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},T.ScaleManager.prototype.constructor=T.ScaleManager,Object.defineProperty(T.ScaleManager.prototype,"boundingParent",{get:function(){if(this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget)return null;var e=this.game.canvas&&this.game.canvas.parentNode;return e||null}}),Object.defineProperty(T.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(e){return e!==this._scaleMode&&(!this.isFullScreen&&(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=e),this._scaleMode}}),Object.defineProperty(T.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(e){return e!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=e,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=e),this._fullScreenScaleMode}}),Object.defineProperty(T.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(T.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(e){e!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=e,this.queueUpdate(!0))}}),Object.defineProperty(T.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(e){e!==this._pageAlignVertically&&(this._pageAlignVertically=e,this.queueUpdate(!0))}}),Object.defineProperty(T.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(T.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(T.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(T.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(T.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),T.Utils.Debug=function(e){this.game=e,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px Courier",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},T.Utils.Debug.prototype={boot:function(){this.game.renderType===T.CANVAS?this.context=this.game.context:(this.bmd=new T.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=T.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new T.Line,this._rect=new T.Rectangle},resize:function(){this.bmd.resize(this.game.width,this.game.height),this.canvas.width=this.game.width,this.canvas.height=this.game.height},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(e,t,a,o){"number"!=typeof e&&(e=0),"number"!=typeof t&&(t=0),a=a||"rgb(255,255,255)",void 0===o&&(o=0),this.currentX=e,this.currentY=t,this.currentColor=a,this.columnWidth=o,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=a,this.context.fillStyle=a,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var e=this.currentX,t=0;t<arguments.length;t++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[t],e+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[t],e,this.currentY),e+=this.columnWidth;this.currentY+=this.lineHeight},soundInfo:function(e,t,a,o){this.start(t,a,o),this.line("Sound: "+e.key+" Locked: "+e.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(e.key)+" Pending Playback: "+e.pendingPlayback),this.line("Decoded: "+e.isDecoded+" Decoding: "+e.isDecoding),this.line("Total Duration: "+e.totalDuration+" Playing: "+e.isPlaying),this.line("Time: "+e.currentTime),this.line("Volume: "+e.volume+" Muted: "+e.mute),this.line("WebAudio: "+e.usingWebAudio+" Audio: "+e.usingAudioTag),""!==e.currentMarker&&(this.line("Marker: "+e.currentMarker+" Duration: "+e.duration+" (ms: "+e.durationMS+")"),this.line("Start: "+e.markers[e.currentMarker].start+" Stop: "+e.markers[e.currentMarker].stop),this.line("Position: "+e.position)),this.stop()},camera:function(e,t,a){var o=e.deadzone,r=e.target,n=e.view;o&&(this._rect.setTo(n.x+o.x,n.y+o.y,o.width,o.height),this.rectangle(this._rect,t,a)),r&&(this._line.setTo(n.centerX,n.centerY,r.x,r.y),this.geom(this._line,t,a),this.geom(r,t,!1,3))},cameraInfo:function(e,t,a,o){var r=e.bounds,n=e.deadzone,i=e.target,s=e.view;this.start(t,a,o),this.line("Camera ("+e.width+" x "+e.height+")"),this.line("x: "+e.x+" y: "+e.y),r&&this.line("Bounds x: "+r.x+" y: "+r.y+" w: "+r.width+" h: "+r.height),this.line("View x: "+s.x+" y: "+s.y+" w: "+s.width+" h: "+s.height),this.line("Deadzone: "+(n?"x: "+n.x+" y: "+n.y+" w: "+n.width+" h: "+n.height:n)),this.line("Total in view: "+e.totalInView),this.line("At limit: x: "+e.atLimit.x+" y: "+e.atLimit.y),this.line("Target: "+(i?i.name||i:i)),this.stop()},timer:function(e,t,a,o){this.start(t,a,o),this.line("Timer (running: "+e.running+" expired: "+e.expired+")"),this.line("Next Tick: "+e.next+" Duration: "+e.duration),this.line("Paused: "+e.paused+" Length: "+e.length),this.stop()},pointer:function(e,t,a,o,r){null!=e&&(void 0===t&&(t=!1),a=a||"rgba(0,255,0,0.5)",o=o||"rgba(255,0,0,0.5)",!0===t&&!0===e.isUp||(this.start(e.x,e.y-100,r),this.context.beginPath(),this.context.arc(e.x,e.y,e.circle.radius,0,2*d),this.context.fillStyle=e.active?a:o,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(e.positionDown.x,e.positionDown.y),this.context.lineTo(e.position.x,e.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath(),this.line("ID: "+e.id+" Active: "+e.active),this.line("World X: "+e.worldX+" World Y: "+e.worldY),this.line("Screen X: "+e.x+" Screen Y: "+e.y+" In: "+e.withinGame),this.line("Duration: "+e.duration+" ms"),this.line("is Down: "+e.isDown+" is Up: "+e.isUp),this.stop()))},spriteInputInfo:function(e,t,a,o){this.start(t,a,o),this.line("Sprite Input: ("+e.width+" x "+e.height+")"),this.line("x: "+e.input.pointerX().toFixed(1)+" y: "+e.input.pointerY().toFixed(1)),this.line("over: "+e.input.pointerOver()+" duration: "+e.input.overDuration().toFixed(0)),this.line("down: "+e.input.pointerDown()+" duration: "+e.input.downDuration().toFixed(0)),this.line("just over: "+e.input.justOver()+" just out: "+e.input.justOut()),this.stop()},key:function(e,t,a,o){this.start(t,a,o,150),this.line("Key:",e.keyCode,"isDown:",e.isDown),this.line("justDown:",e.justDown,"justUp:",e.justUp),this.line("Time Down:",e.timeDown.toFixed(0),"duration:",e.duration.toFixed(0)),this.stop()},inputInfo:function(e,t,a){this.start(e,t,a),this.line("Input"),this.line("X: "+this.game.input.x+" Y: "+this.game.input.y),this.line("World X: "+this.game.input.worldX+" World Y: "+this.game.input.worldY),this.line("Scale X: "+this.game.input.scale.x.toFixed(1)+" Scale Y: "+this.game.input.scale.x.toFixed(1)),this.line("Screen X: "+this.game.input.activePointer.screenX+" Screen Y: "+this.game.input.activePointer.screenY),this.stop()},spriteBounds:function(e,t,a){var o=e.getBounds();o.x+=this.game.camera.x,o.y+=this.game.camera.y,this.rectangle(o,t,a)},ropeSegments:function(e,t,a){var o=e.segments,r=this;o.forEach(function(e){r.rectangle(e,t,a)},this)},spriteInfo:function(e,t,a,o){this.start(t,a,o),this.line("Sprite:  ("+e.width+" x "+e.height+") anchor: "+e.anchor.x+" x "+e.anchor.y),this.line("x: "+e.x.toFixed(1)+" y: "+e.y.toFixed(1)),this.line("angle: "+e.angle.toFixed(1)+" rotation: "+e.rotation.toFixed(1)),this.line("visible: "+e.visible+" in camera: "+e.inCamera),this.line("bounds x: "+e._bounds.x.toFixed(1)+" y: "+e._bounds.y.toFixed(1)+" w: "+e._bounds.width.toFixed(1)+" h: "+e._bounds.height.toFixed(1)),this.stop()},spriteCoords:function(e,t,a,o){this.start(t,a,o,100),e.name&&this.line(e.name),this.line("x:",e.x.toFixed(2),"y:",e.y.toFixed(2)),this.line("pos x:",e.position.x.toFixed(2),"pos y:",e.position.y.toFixed(2)),this.line("world x:",e.world.x.toFixed(2),"world y:",e.world.y.toFixed(2)),this.stop()},lineInfo:function(e,t,a,o){this.start(t,a,o,80),this.line("start.x:",e.start.x.toFixed(2),"start.y:",e.start.y.toFixed(2)),this.line("end.x:",e.end.x.toFixed(2),"end.y:",e.end.y.toFixed(2)),this.line("length:",e.length.toFixed(2),"angle:",e.angle),this.stop()},pixel:function(e,t,a,o){o=o||2,this.start(),this.context.fillStyle=a,this.context.fillRect(e,t,o,o),this.stop()},geom:function(e,t,a,o){void 0===a&&(a=!0),void 0===o&&(o=0),t=t||"rgba(0,255,0,0.4)",this.start(),this.context.fillStyle=t,this.context.strokeStyle=t,this.context.lineWidth=this.lineWidth,e instanceof T.Rectangle||1===o?a?this.context.fillRect(e.x-this.game.camera.x,e.y-this.game.camera.y,e.width,e.height):this.context.strokeRect(e.x-this.game.camera.x,e.y-this.game.camera.y,e.width,e.height):e instanceof T.Circle||2===o?(this.context.beginPath(),this.context.arc(e.x-this.game.camera.x,e.y-this.game.camera.y,e.radius,0,2*d,!1),this.context.closePath(),a?this.context.fill():this.context.stroke()):e instanceof T.Point||3===o?this.context.fillRect(e.x-this.game.camera.x,e.y-this.game.camera.y,4,4):e instanceof T.Line||4===o?(this.context.beginPath(),this.context.moveTo(e.start.x+0.5-this.game.camera.x,e.start.y+0.5-this.game.camera.y),this.context.lineTo(e.end.x+0.5-this.game.camera.x,e.end.y+0.5-this.game.camera.y),this.context.closePath(),this.context.stroke()):(e instanceof T.Ellipse||5===o)&&(this.context.beginPath(),this.context.ellipse(e.x-this.game.camera.x,e.y-this.game.camera.y,e.width/2,e.height/2,0,2*d,!1),this.context.closePath(),a?this.context.fill():this.context.stroke()),this.stop()},rectangle:function(e,t,a){void 0===a&&(a=!0),t=t||"rgba(0, 255, 0, 0.4)",this.start(),a?(this.context.fillStyle=t,this.context.fillRect(e.x-this.game.camera.x,e.y-this.game.camera.y,e.width,e.height)):(this.context.lineWidth=this.lineWidth,this.context.strokeStyle=t,this.context.strokeRect(e.x-this.game.camera.x,e.y-this.game.camera.y,e.width,e.height)),this.stop()},text:function(e,t,a,o,r){o=o||"rgb(255,255,255)",r=r||"16px Courier",this.start(),this.context.font=r,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(e,t+1,a+1)),this.context.fillStyle=o,this.context.fillText(e,t,a),this.stop()},quadTree:function(e,t){t=t||"rgba(255,0,0,0.3)",this.start();var a=e.bounds;if(0===e.nodes.length){this.context.strokeStyle=t,this.context.strokeRect(a.x,a.y,a.width,a.height),this.text("size: "+e.objects.length,a.x+4,a.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(var o=0;o<e.objects.length;o++)this.context.strokeRect(e.objects[o].x,e.objects[o].y,e.objects[o].width,e.objects[o].height)}else for(var o=0;o<e.nodes.length;o++)this.quadTree(e.nodes[o]);this.stop()},body:function(e,t,a){e.body&&(this.start(),e.body.type===T.Physics.ARCADE?T.Physics.Arcade.Body.render(this.context,e.body,t,a,this.lineWidth):e.body.type===T.Physics.NINJA?T.Physics.Ninja.Body.render(this.context,e.body,t,a):e.body.type===T.Physics.BOX2D&&T.Physics.Box2D.renderBody(this.context,e.body,t),this.stop())},bodyInfo:function(e,t,a,o){e.body&&(this.start(t,a,o,210),e.body.type===T.Physics.ARCADE?T.Physics.Arcade.Body.renderBodyInfo(this,e.body):e.body.type===T.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,e.body),this.stop())},box2dWorld:function(){this.start(),this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0),this.game.physics.box2d.renderDebugDraw(this.context),this.stop()},box2dBody:function(e,t){this.start(),T.Physics.Box2D.renderBody(this.context,e,t),this.stop()},displayList:function(e){if(void 0===e&&(e=this.game.world),e.hasOwnProperty("renderOrderID")?console.log("["+e.renderOrderID+"]",e):console.log("[]",e),e.children&&0<e.children.length)for(var t=0;t<e.children.length;t++)this.game.debug.displayList(e.children[t])},renderer:function(e,t,a){var o=this.game.renderer,r=o.renderSession;if(this.start(e,t,a),this.line((o.gl?"WebGL":"Canvas")+" Renderer ("+o.width+" x "+o.height+")"),this.line("autoResize: "+o.autoResize),this.line("clearBeforeRender: "+o.clearBeforeRender),this.line("resolution: "+o.resolution),this.line("transparent: "+o.transparent),this.line("renderSession:"),o.gl){this.line("  currentBatchedTextures: ("+o.currentBatchedTextures.length+")");for(var n=0;n<o.currentBatchedTextures.length;n++)this.line("    "+o.currentBatchedTextures[n]);this.line("  drawCount: "+r.drawCount),this.line("  maxTextures: "+o.maxTextures),this.line("  maxTextureSize: "+o.maxTextureSize),this.line("  maxTextureAvailableSpace: "+r.maxTextureAvailableSpace),this.line("  roundPixels: "+r.roundPixels)}else this.line("  roundPixels: "+r.roundPixels),this.line("  scaleMode: "+(0===r.scaleMode?"LINEAR":1===r.scaleMode?"NEAREST":r.scaleMode));this.stop()},canvasPool:function(e,t,a,o){var r=T.CanvasPool;this.start(e,t,a,o||100),this.line("Canvas Pool"),this.line("Used:",r.getTotal()),this.line("Free:",r.getFree()),this.line("Total:",r.length),this.stop()},physicsGroup:function(e,t,a,o){e.forEach(this.body,this,o,t,a)},phaser:function(e,t,a){this.text("Phaser v"+T.VERSION+" "+(this.game.renderType===T.WEBGL?"WebGL":"Canvas")+" "+(this.game.device.webAudio?"WebAudio":"HTML Audio"),e,t,a,this.font)},destroy:function(){T.CanvasPool.remove(this)}},T.Utils.Debug.prototype.constructor=T.Utils.Debug,T.DOM={getOffset:function(e,t){t=t||new T.Point;var a=e.getBoundingClientRect(),o=T.DOM.scrollY,r=T.DOM.scrollX,n=document.documentElement.clientTop,i=document.documentElement.clientLeft;return t.x=a.left+r-i,t.y=a.top+o-n,t},getBounds:function(e,t){return void 0===t&&(t=0),e=e&&!e.nodeType?e[0]:e,e&&1===e.nodeType&&this.calibrate(e.getBoundingClientRect(),t)},calibrate:function(e,t){t=+t||0;var a={width:0,height:0,left:0,right:0,top:0,bottom:0};return a.width=(a.right=e.right+t)-(a.left=e.left-t),a.height=(a.bottom=e.bottom+t)-(a.top=e.top-t),a},getAspectRatio:function(e){e=null==e?this.visualBounds:1===e.nodeType?this.getBounds(e):e;var t=e.width,a=e.height;return"function"==typeof t&&(t=t.call(e)),"function"==typeof a&&(a=a.call(e)),t/a},inLayoutViewport:function(e,t){var a=this.getBounds(e,t);return!!a&&0<=a.bottom&&0<=a.right&&a.top<=this.layoutBounds.width&&a.left<=this.layoutBounds.height},getScreenOrientation:function(e){var t=window.screen,a=t.orientation||t.mozOrientation||t.msOrientation;if(a&&"string"==typeof a.type)return a.type;if("string"==typeof a)return a;var o="portrait-primary",r="landscape-primary";if("screen"===e)return t.height>t.width?o:r;if("viewport"===e)return this.visualBounds.height>this.visualBounds.width?o:r;if("window.orientation"===e&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?o:r;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return o;if(window.matchMedia("(orientation: landscape)").matches)return r}return this.visualBounds.height>this.visualBounds.width?o:r},visualBounds:new T.Rectangle,layoutBounds:new T.Rectangle,documentBounds:new T.Rectangle},T.Device.whenReady(function(e){var t=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},a=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};Object.defineProperty(T.DOM,"scrollX",{get:t}),Object.defineProperty(T.DOM,"scrollY",{get:a}),Object.defineProperty(T.DOM.visualBounds,"x",{get:t}),Object.defineProperty(T.DOM.visualBounds,"y",{get:a}),Object.defineProperty(T.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(T.DOM.layoutBounds,"y",{value:0});var o=e.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight;if(o){var r=function(){return s(window.innerWidth,document.documentElement.clientWidth)},n=function(){return s(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(T.DOM.visualBounds,"width",{get:r}),Object.defineProperty(T.DOM.visualBounds,"height",{get:n}),Object.defineProperty(T.DOM.layoutBounds,"width",{get:r}),Object.defineProperty(T.DOM.layoutBounds,"height",{get:n})}else Object.defineProperty(T.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(T.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(T.DOM.layoutBounds,"width",{get:function(){var e=document.documentElement.clientWidth,t=window.innerWidth;return e<t?t:e}}),Object.defineProperty(T.DOM.layoutBounds,"height",{get:function(){var e=document.documentElement.clientHeight,t=window.innerHeight;return e<t?t:e}});Object.defineProperty(T.DOM.documentBounds,"x",{value:0}),Object.defineProperty(T.DOM.documentBounds,"y",{value:0}),Object.defineProperty(T.DOM.documentBounds,"width",{get:function(){var e=document.documentElement;return s(e.clientWidth,e.offsetWidth,e.scrollWidth)}}),Object.defineProperty(T.DOM.documentBounds,"height",{get:function(){var e=document.documentElement;return s(e.clientHeight,e.offsetHeight,e.scrollHeight)}})},null,!0),T.ArraySet=function(e){this.position=0,this.list=e||[]},T.ArraySet.prototype={add:function(e){return this.exists(e)||this.list.push(e),e},getIndex:function(e){return this.list.indexOf(e)},getByKey:function(e,t){for(var a=this.list.length;a--;)if(this.list[a][e]===t)return this.list[a];return null},exists:function(e){return-1<this.list.indexOf(e)},reset:function(){this.list.length=0},remove:function(e){var t=this.list.indexOf(e);if(-1<t)return this.list.splice(t,1),e},setAll:function(e,t){for(var a=this.list.length;a--;)this.list[a]&&(this.list[a][e]=t)},callAll:function(e){for(var t=Array.prototype.slice.call(arguments,1),a=this.list.length;a--;)this.list[a]&&this.list[a][e]&&this.list[a][e].apply(this.list[a],t)},removeAll:function(e){void 0===e&&(e=!1);for(var t=this.list.length;t--;)if(this.list[t]){var a=this.remove(this.list[t]);e&&a.destroy()}this.position=0,this.list=[]}},Object.defineProperty(T.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(T.ArraySet.prototype,"first",{get:function(){return this.position=0,0<this.list.length?this.list[0]:null}}),Object.defineProperty(T.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),T.ArraySet.prototype.constructor=T.ArraySet,T.ArrayUtils={getRandomItem:function(e,t,a){if(null===e)return null;void 0===t&&(t=0),void 0===a&&(a=e.length);var o=t+c(Math.random()*a);return void 0===e[o]?null:e[o]},removeRandomItem:function(e,t,a){if(null==e)return null;void 0===t&&(t=0),void 0===a&&(a=e.length);var o=t+c(Math.random()*a);if(o<e.length){var r=e.splice(o,1);return void 0===r[0]?null:r[0]}return null},remove:function(e,t,a){var o=e.length;if(!(t>=o||0===a)){null==a&&(a=1);for(var r=o-a,n=t;n<r;++n)e[n]=e[n+a];e.length=r}},shuffle:function(e){for(var t=e.length-1;0<t;t--){var a=c(Math.random()*(t+1)),o=e[t];e[t]=e[a],e[a]=o}return e},transposeMatrix:function(e){for(var t=e.length,a=e[0].length,o=Array(a),r=0;r<a;r++){o[r]=Array(t);for(var n=t-1;-1<n;n--)o[r][n]=e[n][r]}return o},rotateMatrix:function(e,t){if("string"!=typeof t&&(t=(t%360+360)%360),90===t||-270===t||"rotateLeft"===t)e=T.ArrayUtils.transposeMatrix(e),e=e.reverse();else if(-90===t||270===t||"rotateRight"===t)e=e.reverse(),e=T.ArrayUtils.transposeMatrix(e);else if(180===f(t)||"rotate180"===t){for(var a=0;a<e.length;a++)e[a].reverse();e=e.reverse()}return e},findClosest:function(e,t){if(!t.length)return NaN;if(1===t.length||e<t[0])return t[0];for(var a=1;t[a]<e;)a++;var r=t[a-1],n=a<t.length?t[a]:o;return n-e<=e-r?n:r},rotateRight:function(e){var t=e.pop();return e.unshift(t),t},rotateLeft:function(e){var t=e.shift();return e.push(t),t},rotate:function(e){var t=e.shift();return e.push(t),t},numberArray:function(e,t){(void 0===t||null===t)&&(t=e,e=0);for(var a=[],o=e;o<=t;o++)a.push(o);return a},numberArrayStep:function(e,t,a){(void 0===e||null===e)&&(e=0),(void 0===t||null===t)&&(t=e,e=0),void 0===a&&(a=1);for(var o=[],r=s(T.Math.roundAwayFromZero((t-e)/(a||1)),0),n=0;n<r;n++)o.push(e),e+=a;return o}},T.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},T.LinkedList.prototype={add:function(e){return 0===this.total&&null===this.first&&null===this.last?(this.first=e,this.last=e,this.next=e,e.prev=this,this.total++,e):(this.last.next=e,e.prev=this.last,this.last=e,this.total++,e)},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(e){return 1===this.total?(this.reset(),void(e.next=e.prev=null)):void(e===this.first?this.first=this.first.next:e===this.last&&(this.last=this.last.prev),e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.next=e.prev=null,null===this.first&&(this.last=null),this.total--)},callAll:function(e){if(this.first&&this.last){var t=this.first;do t&&t[e]&&t[e].call(t),t=t.next;while(t!==this.last.next)}}},T.LinkedList.prototype.constructor=T.LinkedList,T.Create=function(e){this.game=e,this.bmd=null,this.canvas=null,this.ctx=null,this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},T.Create.PALETTE_ARNE=0,T.Create.PALETTE_JMP=1,T.Create.PALETTE_CGA=2,T.Create.PALETTE_C64=3,T.Create.PALETTE_JAPANESE_MACHINE=4,T.Create.prototype={texture:function(e,t,a,o,r,n,i,s){void 0===a&&(a=8),void 0===o&&(o=a),void 0===r&&(r=0),void 0===n&&(n=!0);var l=t[0].length*a,p=t.length*o;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(l,p),this.bmd.clear();for(var c=0,u;c<t.length;c++){u=t[c];for(var h=0,g;h<u.length;h++)g=u[h],"."!==g&&" "!==g&&(this.ctx.fillStyle=this.palettes[r][g],this.ctx.fillRect(h*a,c*o,a,o))}return n?this.bmd.generateTexture(e,i,s):this.copy()},grid:function(e,t,a,o,r,n,i,s,d){void 0===i&&(i=!0),null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(t,a),this.ctx.fillStyle=n;for(var l=0;l<a;l+=r)this.ctx.fillRect(0,l,t,1);for(var p=0;p<t;p+=o)this.ctx.fillRect(p,0,1,a);return i?this.bmd.generateTexture(e,s,d):this.copy()},copy:function(e,t,a,o,r,n,i){return null==e&&(e=this.game.make.bitmapData()),e.resize(this.bmd.width,this.bmd.height),e.draw(this.bmd,t,a,o,r,n,i)}},T.Create.prototype.constructor=T.Create,T.FlexGrid=function(e,t,a){this.game=e.game,this.manager=e,this.width=t,this.height=a,this.boundsCustom=new T.Rectangle(0,0,t,a),this.boundsFluid=new T.Rectangle(0,0,t,a),this.boundsFull=new T.Rectangle(0,0,t,a),this.boundsNone=new T.Rectangle(0,0,t,a),this.positionCustom=new T.Point(0,0),this.positionFluid=new T.Point(0,0),this.positionFull=new T.Point(0,0),this.positionNone=new T.Point(0,0),this.scaleCustom=new T.Point(1,1),this.scaleFluid=new T.Point(1,1),this.scaleFluidInversed=new T.Point(1,1),this.scaleFull=new T.Point(1,1),this.scaleNone=new T.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=t/a,this.ratioV=a/t,this.multiplier=0,this.layers=[]},T.FlexGrid.prototype={setSize:function(e,t){this.width=e,this.height=t,this.ratioH=e/t,this.ratioV=t/e,this.scaleNone=new T.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(e,t,a,o){void 0===o&&(o=!0),this.customWidth=e,this.customHeight=t,this.boundsCustom.width=e,this.boundsCustom.height=t;var r=new T.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return o&&this.game.world.add(r),this.layers.push(r),"undefined"!=typeof a&&null!==typeof a&&r.addMultiple(a),r},createFluidLayer:function(e,t){void 0===t&&(t=!0);var a=new T.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return t&&this.game.world.add(a),this.layers.push(a),"undefined"!=typeof e&&null!==typeof e&&a.addMultiple(e),a},createFullLayer:function(e){var t=new T.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(t),this.layers.push(t),"undefined"!=typeof e&&t.addMultiple(e),t},createFixedLayer:function(e){var t=new T.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(t),this.layers.push(t),"undefined"!=typeof e&&t.addMultiple(e),t},reset:function(){for(var e=this.layers.length;e--;)this.layers[e].persist||(this.layers[e].position=null,this.layers[e].scale=null,this.layers.slice(e,1))},onResize:function(e,t){this.ratioH=e/t,this.ratioV=t/e,this.refresh(e,t)},refresh:function(){this.multiplier=p(this.manager.height/this.height,this.manager.width/this.width),this.boundsFluid.width=n(this.width*this.multiplier),this.boundsFluid.height=n(this.height*this.multiplier),this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height),this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height),this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height),this.boundsFull.width=n(this.manager.width*this.scaleFluidInversed.x),this.boundsFull.height=n(this.manager.height*this.scaleFluidInversed.y),this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y),this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(e){this.manager.scaleSprite(e),e.x=this.manager.bounds.centerX,e.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16),this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},T.FlexGrid.prototype.constructor=T.FlexGrid,T.FlexLayer=function(e,t,a,o){T.Group.call(this,e.game,null,"__flexLayer"+e.game.rnd.uuid(),!1),this.manager=e.manager,this.grid=e,this.persist=!1,this.position=t,this.bounds=a,this.scale=o,this.topLeft=a.topLeft,this.topMiddle=new T.Point(a.halfWidth,0),this.topRight=a.topRight,this.bottomLeft=a.bottomLeft,this.bottomMiddle=new T.Point(a.halfWidth,a.bottom),this.bottomRight=a.bottomRight},T.FlexLayer.prototype=Object.create(T.Group.prototype),T.FlexLayer.prototype.constructor=T.FlexLayer,T.FlexLayer.prototype.resize=function(){},T.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16),this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1),this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},T.Color={packPixel:function(e,t,o,r){return T.Device.LITTLE_ENDIAN?(r<<24|o<<16|t<<8|e)>>>0:(e<<24|t<<16|o<<8|r)>>>0},unpackPixel:function(e,t,a,o){return(void 0===t||null===t)&&(t=T.Color.createColor()),(void 0===a||null===a)&&(a=!1),(void 0===o||null===o)&&(o=!1),T.Device.LITTLE_ENDIAN?(t.a=(4278190080&e)>>>24,t.b=(16711680&e)>>>16,t.g=(65280&e)>>>8,t.r=255&e):(t.r=(4278190080&e)>>>24,t.g=(16711680&e)>>>16,t.b=(65280&e)>>>8,t.a=255&e),t.color=e,t.rgba="rgba("+t.r+","+t.g+","+t.b+","+t.a/255+")",a&&T.Color.RGBtoHSL(t.r,t.g,t.b,t),o&&T.Color.RGBtoHSV(t.r,t.g,t.b,t),t},fromRGBA:function(e,t){return t||(t=T.Color.createColor()),t.r=(4278190080&e)>>>24,t.g=(16711680&e)>>>16,t.b=(65280&e)>>>8,t.a=255&e,t.rgba="rgba("+t.r+","+t.g+","+t.b+","+t.a+")",t},toRGBA:function(e,t,o,r){return e<<24|t<<16|o<<8|r},toABGR:function(e,t,o,r){return(r<<24|o<<16|t<<8|e)>>>0},hexToRGBArray:function(e){return[(255&e>>16)/255,(255&e>>8)/255,(255&e)/255]},RGBArrayToHex:function(e){return(255*e[0]<<16)+(255*e[1]<<8)+255*e[2]},RGBtoHSL:function(e,t,a,o){o||(o=T.Color.createColor(e,t,a,1)),e/=255,t/=255,a/=255;var r=p(e,t,a),n=s(e,t,a);if(o.h=0,o.s=0,o.l=(n+r)/2,n!==r){var i=n-r;o.s=0.5<o.l?i/(2-n-r):i/(n+r),n===e?o.h=(t-a)/i+(t<a?6:0):n===t?o.h=(a-e)/i+2:n===a&&(o.h=(e-t)/i+4),o.h/=6}return o},HSLtoRGB:function(e,t,a,o){if(o?(o.r=a,o.g=a,o.b=a):o=T.Color.createColor(a,a,a),0!==t){var r=0.5>a?a*(1+t):a+t-a*t,n=2*a-r;o.r=T.Color.hueToColor(n,r,e+1/3),o.g=T.Color.hueToColor(n,r,e),o.b=T.Color.hueToColor(n,r,e-1/3)}return o.r=c(0|255*o.r),o.g=c(0|255*o.g),o.b=c(0|255*o.b),T.Color.updateColor(o),o},RGBtoHSV:function(e,t,a,o){o||(o=T.Color.createColor(e,t,a,255)),e/=255,t/=255,a/=255;var r=p(e,t,a),n=s(e,t,a),i=n-r;return o.h=0,o.s=0===n?0:i/n,o.v=n,n!==r&&(n===e?o.h=(t-a)/i+(t<a?6:0):n===t?o.h=(a-e)/i+2:n===a&&(o.h=(e-t)/i+4),o.h/=6),o},HSVtoRGB:function(e,a,o,n){void 0===n&&(n=T.Color.createColor(0,0,0,1,e,a,0,o));var s=c(6*e),i=6*e-s,d=o*(1-a),l=o*(1-i*a),p=o*(1-(1-i)*a),t,r,u;switch(s%6){case 0:t=o,r=p,u=d;break;case 1:t=l,r=o,u=d;break;case 2:t=d,r=o,u=p;break;case 3:t=d,r=l,u=o;break;case 4:t=p,r=d,u=o;break;case 5:t=o,r=d,u=l;}return n.r=c(255*t),n.g=c(255*r),n.b=c(255*u),T.Color.updateColor(n),n},hueToColor:function(e,a,o){return 0>o&&(o+=1),1<o&&(o-=1),o<1/6?e+6*(a-e)*o:o<1/2?a:o<2/3?e+6*((a-e)*(2/3-o)):e},createColor:function(e,t,o,r,a,n,i,s){return T.Color.updateColor({r:e||0,g:t||0,b:o||0,a:r||1,h:a||0,s:n||0,l:i||0,v:s||0,color:0,color32:0,rgba:""})},updateColor:function(e){return e.rgba="rgba("+e.r.toFixed()+","+e.g.toFixed()+","+e.b.toFixed()+","+e.a.toString()+")",e.color=T.Color.getColor(e.r,e.g,e.b),e.color32=T.Color.getColor32(255*e.a,e.r,e.g,e.b),e},getColor32:function(e,t,a,o){return e<<24|t<<16|a<<8|o},getColor:function(e,t,a){return e<<16|t<<8|a},RGBtoString:function(e,t,o,r,a){return void 0===r&&(r=255),void 0===a&&(a="#"),"#"===a?"#"+(16777216+(e<<16)+(t<<8)+o).toString(16).slice(1):"0x"+T.Color.componentToHex(r)+T.Color.componentToHex(e)+T.Color.componentToHex(t)+T.Color.componentToHex(o)},hexToRGB:function(e){var t=T.Color.hexToColor(e);if(t)return T.Color.getColor32(t.a,t.r,t.g,t.b)},hexToColor:function(e,t){e=e.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,t,a,o){return t+t+a+a+o+o});var a=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(a){var o=parseInt(a[1],16),r=parseInt(a[2],16),n=parseInt(a[3],16);t?(t.r=o,t.g=r,t.b=n):t=T.Color.createColor(o,r,n)}return t},webToColor:function(e,t){t||(t=T.Color.createColor());var a=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(e);return a&&(t.r=parseInt(a[1],10),t.g=parseInt(a[2],10),t.b=parseInt(a[3],10),t.a=void 0===a[4]?1:parseFloat(a[4]),T.Color.updateColor(t)),t},valueToColor:function(e,t){if(t||(t=T.Color.createColor()),"string"==typeof e)return 0===e.indexOf("rgb")?T.Color.webToColor(e,t):(t.a=1,T.Color.hexToColor(e,t));if("number"==typeof e){var a=T.Color.getRGB(e);return t.r=a.r,t.g=a.g,t.b=a.b,t.a=a.a/255,t}return t},componentToHex:function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},HSVColorWheel:function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);for(var a=[],o=0;359>=o;o++)a.push(T.Color.HSVtoRGB(o/359,e,t));return a},HSLColorWheel:function(e,t){void 0===e&&(e=0.5),void 0===t&&(t=0.5);for(var a=[],o=0;359>=o;o++)a.push(T.Color.HSLtoRGB(o/359,e,t));return a},interpolateColor:function(e,t,a,o,n,i){void 0===n&&(n=255),void 0===i&&(i=0);var d=T.Color.getRGB(e),l=T.Color.getRGB(t);if(0===i)var p=(l.red-d.red)*o/a+d.red,r=(l.green-d.green)*o/a+d.green,c=(l.blue-d.blue)*o/a+d.blue;if(1===i){var u=T.Color.RGBtoHSV(d.r,d.g,d.b),g=T.Color.RGBtoHSV(l.r,l.g,l.b),m=g.h-u.h,y;if(u.h>g.h){var h=g.h;g.h=u.h,u.h=h,m=-m,o=a-o}0.5<m&&(++u.h,y=((g.h-u.h)*o/a+u.h)%1),0.5>=m&&(y=(g.h-u.h)*o/a+u.h);var f=(g.s-u.s)*o/a+u.s,s=(g.v-u.v)*o/a+u.v,x=T.Color.HSVtoRGB(y,f,s,x),p=x.r,r=x.g,c=x.b}return T.Color.getColor32(n,p,r,c)},interpolateColorWithRGB:function(e,t,a,o,r,n){var i=T.Color.getRGB(e),s=(t-i.red)*n/r+i.red,d=(a-i.green)*n/r+i.green,l=(o-i.blue)*n/r+i.blue;return T.Color.getColor(s,d,l)},interpolateRGB:function(e,t,a,o,r,n,i,s){return T.Color.getColor((o-e)*s/i+e,(r-t)*s/i+t,(n-a)*s/i+a)},linear:function(e,a,o){return this.interpolateColor(e,a,1,o)},linearInterpolation:function(e,a){var t=T.Math.linear(0,e.length-1,a),o=e[c(t)],r=e[l(t)];return this.linear(o,r,t%1)},getRandomColor:function(e,t,a){if(void 0===e&&(e=0),void 0===t&&(t=255),void 0===a&&(a=255),255<t||e>t)return T.Color.getColor(255,255,255);var o=e+n(Math.random()*(t-e)),r=e+n(Math.random()*(t-e)),i=e+n(Math.random()*(t-e));return T.Color.getColor32(a,o,r,i)},getRGB:function(e){return 16777215<e?{alpha:e>>>24,red:255&e>>16,green:255&e>>8,blue:255&e,a:e>>>24,r:255&e>>16,g:255&e>>8,b:255&e}:{alpha:255,red:255&e>>16,green:255&e>>8,blue:255&e,a:255,r:255&e>>16,g:255&e>>8,b:255&e}},getWebRGB:function(e){if("object"==typeof e)return"rgba("+e.r.toString()+","+e.g.toString()+","+e.b.toString()+","+(e.a/255).toString()+")";var t=T.Color.getRGB(e);return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")"},getAlpha:function(e){return e>>>24},getAlphaFloat:function(e){return(e>>>24)/255},getRed:function(e){return 255&e>>16},getGreen:function(e){return 255&e>>8},getBlue:function(e){return 255&e},blendNormal:function(e){return e},blendLighten:function(e,t){return t>e?t:e},blendDarken:function(e,t){return t>e?e:t},blendMultiply:function(e,t){return e*t/255},blendAverage:function(e,t){return(e+t)/2},blendAdd:function(e,t){return p(255,e+t)},blendSubtract:function(e,t){return s(0,e+t-255)},blendDifference:function(e,t){return f(e-t)},blendNegation:function(e,t){return 255-f(255-e-t)},blendScreen:function(e,t){return 255-((255-e)*(255-t)>>8)},blendExclusion:function(e,t){return e+t-2*e*t/255},blendOverlay:function(e,t){return 128>t?2*e*t/255:255-2*(255-e)*(255-t)/255},blendSoftLight:function(e,t){return 128>t?2*((e>>1)+64)*(t/255):255-2*(255-((e>>1)+64))*(255-t)/255},blendHardLight:function(e,t){return T.Color.blendOverlay(t,e)},blendColorDodge:function(e,t){return 255===t?t:p(255,(e<<8)/(255-t))},blendColorBurn:function(e,t){return 0===t?t:s(0,255-(255-e<<8)/t)},blendLinearDodge:function(e,t){return T.Color.blendAdd(e,t)},blendLinearBurn:function(e,t){return T.Color.blendSubtract(e,t)},blendLinearLight:function(e,t){return 128>t?T.Color.blendLinearBurn(e,2*t):T.Color.blendLinearDodge(e,2*(t-128))},blendVividLight:function(e,t){return 128>t?T.Color.blendColorBurn(e,2*t):T.Color.blendColorDodge(e,2*(t-128))},blendPinLight:function(e,t){return 128>t?T.Color.blendDarken(e,2*t):T.Color.blendLighten(e,2*(t-128))},blendHardMix:function(e,t){return 128>T.Color.blendVividLight(e,t)?0:255},blendReflect:function(e,t){return 255===t?t:p(255,e*e/(255-t))},blendGlow:function(e,t){return T.Color.blendReflect(t,e)},blendPhoenix:function(e,t){return p(e,t)-s(e,t)+255}},T.Physics=function(e,t){t=t||{},this.game=e,this.config=t,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},T.Physics.ARCADE=0,T.Physics.P2JS=1,T.Physics.NINJA=2,T.Physics.BOX2D=3,T.Physics.CHIPMUNK=4,T.Physics.MATTERJS=5,T.Physics.prototype={parseConfig:function(){(!this.config.hasOwnProperty("arcade")||!0===this.config.arcade)&&T.Physics.hasOwnProperty("Arcade")&&(this.arcade=new T.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&T.Physics.hasOwnProperty("Ninja")&&(this.ninja=new T.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&T.Physics.hasOwnProperty("P2")&&(this.p2=new T.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&T.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new T.Physics.BOX2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&T.Physics.hasOwnProperty("Matter")&&(this.matter=new T.Physics.Matter(this.game,this.config))},startSystem:function(e){e===T.Physics.ARCADE?this.arcade=new T.Physics.Arcade(this.game):e===T.Physics.P2JS?null===this.p2?this.p2=new T.Physics.P2(this.game,this.config):this.p2.reset():e===T.Physics.NINJA?this.ninja=new T.Physics.Ninja(this.game):e===T.Physics.BOX2D?null===this.box2d?this.box2d=new T.Physics.Box2D(this.game,this.config):this.box2d.reset():e===T.Physics.MATTERJS&&(null===this.matter?this.matter=new T.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(e,t,a){void 0===t&&(t=T.Physics.ARCADE),void 0===a&&(a=!1),t===T.Physics.ARCADE?this.arcade.enable(e):t===T.Physics.P2JS&&this.p2?this.p2.enable(e,a):t===T.Physics.NINJA&&this.ninja?this.ninja.enableAABB(e):t===T.Physics.BOX2D&&this.box2d?this.box2d.enable(e):t===T.Physics.MATTERJS&&this.matter?this.matter.enable(e):console.warn(e.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},T.Physics.prototype.constructor=T.Physics,T.Physics.Arcade=function(e){this.game=e,this.gravity=new T.Point,this.bounds=new T.Rectangle(0,0,e.world.width,e.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=T.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new T.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},T.Physics.Arcade.prototype.constructor=T.Physics.Arcade,T.Physics.Arcade.SORT_NONE=0,T.Physics.Arcade.LEFT_RIGHT=1,T.Physics.Arcade.RIGHT_LEFT=2,T.Physics.Arcade.TOP_BOTTOM=3,T.Physics.Arcade.BOTTOM_TOP=4,T.Physics.Arcade.prototype={setBounds:function(e,t,a,o){this.bounds.setTo(e,t,a,o)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(e,t){void 0===t&&(t=!0);var a=1;if(Array.isArray(e))for(a=e.length;a--;)e[a]instanceof T.Group?this.enable(e[a].children,t):(this.enableBody(e[a]),t&&e[a].hasOwnProperty("children")&&0<e[a].children.length&&this.enable(e[a],!0));else e instanceof T.Group?this.enable(e.children,t):(this.enableBody(e),t&&e.hasOwnProperty("children")&&0<e.children.length&&this.enable(e.children,!0))},enableBody:function(e){e.hasOwnProperty("body")&&null===e.body&&(e.body=new T.Physics.Arcade.Body(e),e.parent&&e.parent instanceof T.Group&&e.parent.addToHash(e))},updateMotion:function(e){if(e.allowRotation){var t=this.computeVelocity(0,e,e.angularVelocity,e.angularAcceleration,e.angularDrag,e.maxAngular)-e.angularVelocity;e.angularVelocity+=t,e.rotation+=e.angularVelocity*this.game.time.physicsElapsed}e.velocity.x=this.computeVelocity(1,e,e.velocity.x,e.acceleration.x,e.drag.x,e.maxVelocity.x),e.velocity.y=this.computeVelocity(2,e,e.velocity.y,e.acceleration.y,e.drag.y,e.maxVelocity.y)},computeVelocity:function(e,t,a,o,r,n){return void 0===n&&(n=1e4),1===e&&t.allowGravity?a+=(this.gravity.x+t.gravity.x)*this.game.time.physicsElapsed:2===e&&t.allowGravity&&(a+=(this.gravity.y+t.gravity.y)*this.game.time.physicsElapsed),o?a+=o*this.game.time.physicsElapsed:r&&t.allowDrag&&(r*=this.game.time.physicsElapsed,0<a-r?a-=r:0>a+r?a+=r:a=0),a>n?a=n:a<-n&&(a=-n),a},overlap:function(e,t,a,o,r){return a=a||null,o=o||null,r=r||a,this._total=0,this.collideObjects(e,t,a,o,r,!0),0<this._total},collide:function(e,t,a,o,r){return a=a||null,o=o||null,r=r||a,this._total=0,this.collideObjects(e,t,a,o,r,!1),0<this._total},sortLeftRight:function(e,t){return e.body&&t.body?e.body.x-t.body.x:0},sortRightLeft:function(e,t){return e.body&&t.body?t.body.x-e.body.x:0},sortTopBottom:function(e,t){return e.body&&t.body?e.body.y-t.body.y:0},sortBottomTop:function(e,t){return e.body&&t.body?t.body.y-e.body.y:0},sort:function(e,t){null===e.physicsSortDirection?void 0===t&&(t=this.sortDirection):t=e.physicsSortDirection,t===T.Physics.Arcade.LEFT_RIGHT?e.hash.sort(this.sortLeftRight):t===T.Physics.Arcade.RIGHT_LEFT?e.hash.sort(this.sortRightLeft):t===T.Physics.Arcade.TOP_BOTTOM?e.hash.sort(this.sortTopBottom):t===T.Physics.Arcade.BOTTOM_TOP&&e.hash.sort(this.sortBottomTop)},collideObjects:function(e,t,a,o,r,n){if(!Array.isArray(e)&&Array.isArray(t))for(var s=0;s<t.length;s++)t[s]&&this.collideHandler(e,t[s],a,o,r,n);else if(Array.isArray(e)&&!Array.isArray(t))for(var s=0;s<e.length;s++)e[s]&&this.collideHandler(e[s],t,a,o,r,n);else if(Array.isArray(e)&&Array.isArray(t)){for(var s=0;s<e.length;s++)if(e[s])for(var i=0;i<t.length;i++)t[i]&&this.collideHandler(e[s],t[i],a,o,r,n);}else this.collideHandler(e,t,a,o,r,n)},collideHandler:function(e,t,a,o,r,n){return void 0===t&&e.physicsType===T.GROUP?(this.sort(e),void this.collideGroupVsSelf(e,a,o,r,n)):void(!e||!t||!e.exists||!t.exists||(this.sortDirection!==T.Physics.Arcade.SORT_NONE&&(e.physicsType===T.GROUP&&this.sort(e),t.physicsType===T.GROUP&&this.sort(t)),e.physicsType===T.SPRITE?t.physicsType===T.SPRITE?this.collideSpriteVsSprite(e,t,a,o,r,n):t.physicsType===T.GROUP?this.collideSpriteVsGroup(e,t,a,o,r,n):t.physicsType===T.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(e,t,a,o,r,n):e.physicsType===T.GROUP?t.physicsType===T.SPRITE?this.collideSpriteVsGroup(t,e,a,o,r,n):t.physicsType===T.GROUP?this.collideGroupVsGroup(e,t,a,o,r,n):t.physicsType===T.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(e,t,a,o,r,n):e.physicsType===T.TILEMAPLAYER&&(t.physicsType===T.SPRITE?this.collideSpriteVsTilemapLayer(t,e,a,o,r,n):t.physicsType===T.GROUP&&this.collideGroupVsTilemapLayer(t,e,a,o,r,n))))},collideSpriteVsSprite:function(e,t,a,o,r,n){return e.body&&t.body&&(this.separate(e.body,t.body,o,r,n)&&(a&&a.call(r,e,t),this._total++),!0)},collideSpriteVsGroup:function(e,t,a,o,r,n){if(0!==t.length&&e.body)if(this.skipQuadTree||e.body.skipQuadTree){for(var s={},d=0,i;d<t.hash.length;d++)if(i=t.hash[d],i&&i.exists&&i.body){if(s=i.body.getBounds(s),this.sortDirection===T.Physics.Arcade.LEFT_RIGHT){if(e.body.right<s.x)break;else if(s.right<e.body.x)continue;}else if(this.sortDirection===T.Physics.Arcade.RIGHT_LEFT){if(e.body.x>s.right)break;else if(s.x>e.body.right)continue;}else if(this.sortDirection===T.Physics.Arcade.TOP_BOTTOM){if(e.body.bottom<s.y)break;else if(s.bottom<e.body.y)continue;}else if(this.sortDirection===T.Physics.Arcade.BOTTOM_TOP)if(e.body.y>s.bottom)break;else if(s.y>e.body.bottom)continue;this.collideSpriteVsSprite(e,i,a,o,r,n)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(t);for(var l=this.quadTree.retrieve(e),d=0;d<l.length;d++)this.separate(e.body,l[d],o,r,n)&&(a&&a.call(r,e,l[d].sprite),this._total++)}},collideGroupVsSelf:function(e,t,a,o,r){if(0!==e.length)for(var n=0;n<e.hash.length;n++){var i={},s=e.hash[n];if(s&&s.exists&&s.body){i=s.body.getBounds(i);for(var d=n+1;d<e.hash.length;d++){var l={},p=e.hash[d];if(p&&p.exists&&p.body){if(l=p.body.getBounds(l),this.sortDirection===T.Physics.Arcade.LEFT_RIGHT){if(i.right<l.x)break;else if(l.right<i.x)continue;}else if(this.sortDirection===T.Physics.Arcade.RIGHT_LEFT){if(i.x>l.right)continue;else if(l.x>i.right)break;}else if(this.sortDirection===T.Physics.Arcade.TOP_BOTTOM){if(i.bottom<l.y)continue;else if(l.bottom<i.y)break;}else if(this.sortDirection===T.Physics.Arcade.BOTTOM_TOP)if(i.y>l.bottom)continue;else if(l.y>s.body.bottom)break;this.collideSpriteVsSprite(s,p,t,a,o,r)}}}}},collideGroupVsGroup:function(e,t,a,o,r,n){if(0!==e.length&&0!==t.length)for(var s=0;s<e.children.length;s++)e.children[s].exists&&(e.children[s].physicsType===T.GROUP?this.collideGroupVsGroup(e.children[s],t,a,o,r,n):this.collideSpriteVsGroup(e.children[s],t,a,o,r,n))},separate:function(e,t,a,o,r){if(!e.enable||!t.enable||e.checkCollision.none||t.checkCollision.none||!this.intersects(e,t))return!1;if(a&&!1===a.call(o,e.sprite,t.sprite))return!1;if(e.isCircle&&t.isCircle)return this.separateCircle(e,t,r);if(e.isCircle!==t.isCircle){var n=e.isCircle?t:e,i=e.isCircle?e:t,s={x:n.x,y:n.y,right:n.right,bottom:n.bottom},d=i.center;if((d.y<s.y||d.y>s.bottom)&&(d.x<s.x||d.x>s.right))return this.separateCircle(e,t,r)}var l=!1,p=!1;this.forceX||f(this.gravity.y+e.gravity.y)<f(this.gravity.x+e.gravity.x)?(l=this.separateX(e,t,r),this.intersects(e,t)&&(p=this.separateY(e,t,r))):(p=this.separateY(e,t,r),this.intersects(e,t)&&(l=this.separateX(e,t,r)));var c=l||p;return c&&(r?(e.onOverlap&&e.onOverlap.dispatch(e.sprite,t.sprite),t.onOverlap&&t.onOverlap.dispatch(t.sprite,e.sprite)):(e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite),t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite))),c},intersects:function(e,t){return e!==t&&(e.isCircle?t.isCircle?T.Math.distance(e.center.x,e.center.y,t.center.x,t.center.y)<=e.halfWidth+t.halfWidth:this.circleBodyIntersects(e,t):t.isCircle?this.circleBodyIntersects(t,e):!(e.right<=t.position.x)&&!(e.bottom<=t.position.y)&&!(e.position.x>=t.right)&&!(e.position.y>=t.bottom))},circleBodyIntersects:function(e,t){var a=T.Math.clamp(e.center.x,t.left,t.right),o=T.Math.clamp(e.center.y,t.top,t.bottom),r=(e.center.x-a)*(e.center.x-a),n=(e.center.y-o)*(e.center.y-o);return r+n<=e.halfWidth*e.halfWidth},separateCircle:function(e,t,a){this.getOverlapX(e,t),this.getOverlapY(e,t);var o=t.center.x-e.center.x,n=t.center.y-e.center.y,i=r(n,o),s=0;if(e.isCircle!==t.isCircle){var l={x:t.isCircle?e.position.x:t.position.x,y:t.isCircle?e.position.y:t.position.y,right:t.isCircle?e.right:t.right,bottom:t.isCircle?e.bottom:t.bottom},p={x:e.isCircle?e.center.x:t.center.x,y:e.isCircle?e.center.y:t.center.y,radius:e.isCircle?e.halfWidth:t.halfWidth};p.y<l.y?p.x<l.x?s=T.Math.distance(p.x,p.y,l.x,l.y)-p.radius:p.x>l.right&&(s=T.Math.distance(p.x,p.y,l.right,l.y)-p.radius):p.y>l.bottom&&(p.x<l.x?s=T.Math.distance(p.x,p.y,l.x,l.bottom)-p.radius:p.x>l.right&&(s=T.Math.distance(p.x,p.y,l.right,l.bottom)-p.radius)),s*=-1}else s=e.halfWidth+t.halfWidth-T.Math.distance(e.center.x,e.center.y,t.center.x,t.center.y);if(a||0==s||e.immovable&&t.immovable||e.customSeparateX||t.customSeparateX)return 0!=s&&(e.onOverlap&&e.onOverlap.dispatch(e.sprite,t.sprite),t.onOverlap&&t.onOverlap.dispatch(t.sprite,e.sprite)),0!=s;var c={x:e.velocity.x*m(i)+e.velocity.y*h(i),y:e.velocity.x*h(i)-e.velocity.y*m(i)},u={x:t.velocity.x*m(i)+t.velocity.y*h(i),y:t.velocity.x*h(i)-t.velocity.y*m(i)},g=((e.mass-t.mass)*c.x+2*t.mass*u.x)/(e.mass+t.mass),y=(2*e.mass*c.x+(t.mass-e.mass)*u.x)/(e.mass+t.mass);return e.immovable||(e.velocity.x=(g*m(i)-c.y*h(i))*e.bounce.x,e.velocity.y=(c.y*m(i)+g*h(i))*e.bounce.y),t.immovable||(t.velocity.x=(y*m(i)-u.y*h(i))*t.bounce.x,t.velocity.y=(u.y*m(i)+y*h(i))*t.bounce.y),f(i)<d/2?0<e.velocity.x&&!e.immovable&&t.velocity.x>e.velocity.x?e.velocity.x*=-1:0>t.velocity.x&&!t.immovable&&e.velocity.x<t.velocity.x?t.velocity.x*=-1:0<e.velocity.y&&!e.immovable&&t.velocity.y>e.velocity.y?e.velocity.y*=-1:0>t.velocity.y&&!t.immovable&&e.velocity.y<t.velocity.y&&(t.velocity.y*=-1):f(i)>d/2&&(0>e.velocity.x&&!e.immovable&&t.velocity.x<e.velocity.x?e.velocity.x*=-1:0<t.velocity.x&&!t.immovable&&e.velocity.x>t.velocity.x?t.velocity.x*=-1:0>e.velocity.y&&!e.immovable&&t.velocity.y<e.velocity.y?e.velocity.y*=-1:0<t.velocity.y&&!t.immovable&&e.velocity.x>t.velocity.y&&(t.velocity.y*=-1)),e.immovable||(e.x+=e.velocity.x*this.game.time.physicsElapsed-s*m(i),e.y+=e.velocity.y*this.game.time.physicsElapsed-s*h(i)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed+s*m(i),t.y+=t.velocity.y*this.game.time.physicsElapsed+s*h(i)),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite),t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),!0},getOverlapX:function(e,t,a){var o=0,r=e.deltaAbsX()+t.deltaAbsX()+this.OVERLAP_BIAS;return 0===e.deltaX()&&0===t.deltaX()?(e.embedded=!0,t.embedded=!0):e.deltaX()>t.deltaX()?(o=e.right-t.x,o>r&&!a||!1===e.checkCollision.right||!1===t.checkCollision.left?o=0:(e.touching.none=!1,e.touching.right=!0,t.touching.none=!1,t.touching.left=!0)):e.deltaX()<t.deltaX()&&(o=e.x-t.width-t.x,-o>r&&!a||!1===e.checkCollision.left||!1===t.checkCollision.right?o=0:(e.touching.none=!1,e.touching.left=!0,t.touching.none=!1,t.touching.right=!0)),e.overlapX=o,t.overlapX=o,o},getOverlapY:function(e,t,a){var o=0,r=e.deltaAbsY()+t.deltaAbsY()+this.OVERLAP_BIAS;return 0===e.deltaY()&&0===t.deltaY()?(e.embedded=!0,t.embedded=!0):e.deltaY()>t.deltaY()?(o=e.bottom-t.y,o>r&&!a||!1===e.checkCollision.down||!1===t.checkCollision.up?o=0:(e.touching.none=!1,e.touching.down=!0,t.touching.none=!1,t.touching.up=!0)):e.deltaY()<t.deltaY()&&(o=e.y-t.bottom,-o>r&&!a||!1===e.checkCollision.up||!1===t.checkCollision.down?o=0:(e.touching.none=!1,e.touching.up=!0,t.touching.none=!1,t.touching.down=!0)),e.overlapY=o,t.overlapY=o,o},separateX:function(e,t,a){var o=this.getOverlapX(e,t,a);if(a||0===o||e.immovable&&t.immovable||e.customSeparateX||t.customSeparateX)return 0!=o||e.embedded&&t.embedded;var r=e.velocity.x,n=t.velocity.x;if(!e.immovable&&!t.immovable){o*=0.5,e.x-=o,t.x+=o;var i=_(n*n*t.mass/e.mass)*(0<n?1:-1),s=_(r*r*e.mass/t.mass)*(0<r?1:-1),d=0.5*(i+s);i-=d,s-=d,e.velocity.x=d+i*e.bounce.x,t.velocity.x=d+s*t.bounce.x}else e.immovable?(t.x+=o,t.velocity.x=r-n*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y)):(e.x-=o,e.velocity.x=n-r*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y));return!0},separateY:function(e,t,a){var o=this.getOverlapY(e,t,a);if(a||0===o||e.immovable&&t.immovable||e.customSeparateY||t.customSeparateY)return 0!=o||e.embedded&&t.embedded;var r=e.velocity.y,n=t.velocity.y;if(!e.immovable&&!t.immovable){o*=0.5,e.y-=o,t.y+=o;var i=_(n*n*t.mass/e.mass)*(0<n?1:-1),s=_(r*r*e.mass/t.mass)*(0<r?1:-1),d=0.5*(i+s);i-=d,s-=d,e.velocity.y=d+i*e.bounce.y,t.velocity.y=d+s*t.bounce.y}else e.immovable?(t.y+=o,t.velocity.y=r-n*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x)):(e.y-=o,e.velocity.y=n-r*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x));return!0},getObjectsUnderPointer:function(e,t,a,o){return 0!==t.length&&e.exists?this.getObjectsAtLocation(e.x,e.y,t,a,o,e):void 0},getObjectsAtLocation:function(e,t,a,o,r,n){this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(a);for(var s=new T.Rectangle(e,t,1,1),d=[],l=this.quadTree.retrieve(s),p=0;p<l.length;p++)l[p].hitTest(e,t)&&(o&&o.call(r,n,l[p].sprite),d.push(l[p].sprite));return d},moveToObject:function(e,t,a,o){void 0===a&&(a=60),void 0===o&&(o=0);var n=r(t.y-e.y,t.x-e.x);return 0<o&&(a=this.distanceBetween(e,t)/(o/1e3)),e.body.velocity.setToPolar(n,a),n},moveToPointer:function(e,t,a,o){void 0===t&&(t=60),a=a||this.game.input.activePointer,void 0===o&&(o=0);var r=this.angleToPointer(e,a);return 0<o&&(t=this.distanceToPointer(e,a)/(o/1e3)),e.body.velocity.setToPolar(r,t),r},moveToXY:function(e,t,a,o,n){void 0===o&&(o=60),void 0===n&&(n=0);var i=r(a-e.y,t-e.x);return 0<n&&(o=this.distanceToXY(e,t,a)/(n/1e3)),e.body.velocity.setToPolar(i,o),i},velocityFromAngle:function(e,t,a){return void 0===t&&(t=60),a=a||new T.Point,a.setToPolar(e,t,!0)},velocityFromRotation:function(e,t,a){return void 0===t&&(t=60),a=a||new T.Point,a.setToPolar(e,t)},accelerationFromRotation:function(e,t,a){return void 0===t&&(t=60),a=a||new T.Point,a.setToPolar(e,t)},accelerateToObject:function(e,t,a,o,r){void 0===a&&(a=60),void 0===o&&(o=1e3),void 0===r&&(r=1e3);var n=this.angleBetween(e,t);return e.body.acceleration.setToPolar(n,a),e.body.maxVelocity.setTo(o,r),n},accelerateToPointer:function(e,t,a,o,r){void 0===a&&(a=60),void 0===t&&(t=this.game.input.activePointer),void 0===o&&(o=1e3),void 0===r&&(r=1e3);var n=this.angleToPointer(e,t);return e.body.acceleration.setToPolar(n,a),e.body.maxVelocity.setTo(o,r),n},accelerateToXY:function(e,t,a,o,r,n){void 0===o&&(o=60),void 0===r&&(r=1e3),void 0===n&&(n=1e3);var i=this.angleToXY(e,t,a);return e.body.acceleration.setTo(i,o),e.body.maxVelocity.setTo(r,n),i},distanceBetween:function(e,t,a){void 0===a&&(a=!1);var o=a?e.world.x-t.world.x:e.x-t.x,r=a?e.world.y-t.world.y:e.y-t.y;return _(o*o+r*r)},distanceToXY:function(e,t,a,o){void 0===o&&(o=!1);var r=o?e.world.x-t:e.x-t,n=o?e.world.y-a:e.y-a;return _(r*r+n*n)},distanceToPointer:function(e,t,a){void 0===t&&(t=this.game.input.activePointer),void 0===a&&(a=!1);var o=a?e.world.x-t.worldX:e.x-t.worldX,r=a?e.world.y-t.worldY:e.y-t.worldY;return _(o*o+r*r)},closest:function(e,t,a){for(var o=Infinity,r=null,n=0,i=t.length;n<i;n++){var s=t[n],d=this.distanceBetween(e,s,a);d<o&&(r=s,o=d)}return r},farthest:function(e,t,a){for(var o=-1,r=null,n=0,i=t.length;n<i;n++){var s=t[n],d=this.distanceBetween(e,s,a);d>o&&(r=s,o=d)}return r},angleBetween:function(e,t,a){return void 0===a&&(a=!1),a?r(t.world.y-e.world.y,t.world.x-e.world.x):r(t.y-e.y,t.x-e.x)},angleBetweenCenters:function(e,t){var a=t.centerX-e.centerX,o=t.centerY-e.centerY;return r(o,a)},angleToXY:function(e,t,a,o){return void 0===o&&(o=!1),o?r(a-e.world.y,t-e.world.x):r(a-e.y,t-e.x)},angleToPointer:function(e,t,a){return void 0===t&&(t=this.game.input.activePointer),void 0===a&&(a=!1),a?r(t.worldY-e.world.y,t.worldX-e.world.x):r(t.worldY-e.y,t.worldX-e.x)},worldAngleToPointer:function(e,t){return this.angleToPointer(e,t,!0)}},T.Physics.Arcade.Body=function(e){this.sprite=e,this.game=e.game,this.type=T.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new T.Point,this.position=new T.Point(e.x,e.y),this.prev=new T.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=e.width,this.height=e.height,this.sourceWidth=e.width,this.sourceHeight=e.height,e.texture&&(this.sourceWidth=e.texture.frame.width,this.sourceHeight=e.texture.frame.height),this.halfWidth=f(e.width/2),this.halfHeight=f(e.height/2),this.center=new T.Point(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new T.Point,this.newVelocity=new T.Point,this.deltaMax=new T.Point,this.acceleration=new T.Point,this.allowDrag=!0,this.drag=new T.Point,this.allowGravity=!0,this.gravity=new T.Point,this.bounce=new T.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new T.Point(1e4,1e4),this.friction=new T.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=T.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.tilePadding=new T.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.moveTimer=0,this.moveDistance=0,this.moveDuration=0,this.moveTarget=null,this.moveEnd=null,this.onMoveComplete=new T.Signal,this.movementCallback=null,this.movementCallbackContext=null,this._reset=!0,this._sx=e.scale.x,this._sy=e.scale.y,this._dx=0,this._dy=0},T.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var e=this.sprite.getBounds();e.ceilAll(),(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._reset=!0)}else{var t=f(this.sprite.scale.x),a=f(this.sprite.scale.y);(t!==this._sx||a!==this._sy)&&(this.width=this.sourceWidth*t,this.height=this.sourceHeight*a,this._sx=t,this._sy=a,this._reset=!0)}this._reset&&(this.halfWidth=c(this.width/2),this.halfHeight=c(this.height/2),this.updateCenter())},updateCenter:function(){this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},preUpdate:function(){!this.enable||this.game.physics.arcade.isPaused||(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=0>this.sprite.scale.x?this.width:0,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=0>this.sprite.scale.y?this.height:0,this.updateCenter(),this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),(this.position.x!==this.prev.x||this.position.y!==this.prev.y)&&(this.angle=r(this.velocity.y,this.velocity.x)),this.speed=_(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},updateMovement:function(){var e=0,t=0!==this.overlapX||0!==this.overlapY;if(0<this.moveDuration?(this.moveTimer+=this.game.time.elapsedMS,e=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),e=this.moveTarget.length/this.moveDistance),this.movementCallback)var a=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,e);return t||1<=e||void 0!==a&&!0!==a?(this.stopMovement(1<=e||this.stopVelocityOnCollide&&t),!1):!0},stopMovement:function(e){this.isMoving&&(this.isMoving=!1,e&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,0>this.deltaX()?this.facing=T.LEFT:0<this.deltaX()&&(this.facing=T.RIGHT),0>this.deltaY()?this.facing=T.UP:0<this.deltaY()&&(this.facing=T.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(0>this._dx&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:0<this._dx&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(0>this._dy&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:0<this._dy&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var e=this.position,t=this.game.physics.arcade.bounds,a=this.game.physics.arcade.checkCollision,o=this.worldBounce?-this.worldBounce.x:-this.bounce.x,r=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return e.x<t.x&&a.left?(e.x=t.x,this.velocity.x*=o,this.blocked.left=!0,this.blocked.none=!1):this.right>t.right&&a.right&&(e.x=t.right-this.width,this.velocity.x*=o,this.blocked.right=!0,this.blocked.none=!1),e.y<t.y&&a.up?(e.y=t.y,this.velocity.y*=r,this.blocked.up=!0,this.blocked.none=!1):this.bottom>t.bottom&&a.down&&(e.y=t.bottom-this.height,this.velocity.y*=r,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(e,t,a){if(void 0===t&&(t=this.speed),0===t)return!1;var o;return void 0===a?(o=this.angle,a=this.game.math.radToDeg(o)):o=this.game.math.degToRad(a),this.moveTimer=0,this.moveDuration=e,0===a||180===a?this.velocity.set(m(o)*t,0):90===a||270===a?this.velocity.set(0,h(o)*t):this.velocity.setToPolar(o,t),this.isMoving=!0,!0},moveTo:function(e,t,a){var o=t/(e/1e3);if(0==o)return!1;var r;return void 0===a?(r=this.angle,a=this.game.math.radToDeg(r)):r=this.game.math.degToRad(a),t=f(t),this.moveDuration=0,this.moveDistance=t,null===this.moveTarget&&(this.moveTarget=new T.Line,this.moveEnd=new T.Point),this.moveTarget.fromAngle(this.x,this.y,r,t),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===a||180===a?this.velocity.set(m(r)*o,0):90===a||270===a?this.velocity.set(0,h(r)*o):this.velocity.setToPolar(r,o),this.isMoving=!0,!0},setSize:function(e,t,a,o){void 0===a&&(a=this.offset.x),void 0===o&&(o=this.offset.y),this.sourceWidth=e,this.sourceHeight=t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=c(this.width/2),this.halfHeight=c(this.height/2),this.offset.setTo(a,o),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(e,t,a){void 0===t&&(t=this.offset.x),void 0===a&&(a=this.offset.y),0<e?(this.isCircle=!0,this.radius=e,this.sourceWidth=2*e,this.sourceHeight=2*e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=c(this.width/2),this.halfHeight=c(this.height/2),this.offset.setTo(t,a),this.updateCenter()):this.isCircle=!1},reset:function(e,t){this.stop(),this.position.x=e-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=0>this.sprite.scale.x?this.width:0,this.position.y=t-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=0>this.sprite.scale.y?this.height:0,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this.updateBounds(),this.updateCenter()},stop:function(){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0},getBounds:function(e){return e.x=this.x,e.y=this.y,e.right=this.right,e.bottom=this.bottom,e},hitTest:function(e,t){return this.isCircle?T.Circle.contains(this,e,t):T.Rectangle.contains(this,e,t)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return 0<this.deltaX()?this.deltaX():-this.deltaX()},deltaAbsY:function(){return 0<this.deltaY()?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof T.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(T.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(T.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(T.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(T.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(T.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(e){this.position.x=e}}),Object.defineProperty(T.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(e){this.position.y=e}}),T.Physics.Arcade.Body.render=function(e,t,a,o,r){void 0===o&&(o=!0),a=a||"rgba(0,255,0,0.4)",e.fillStyle=a,e.strokeStyle=a,e.lineWidth=r||1,t.isCircle?(e.beginPath(),e.arc(t.center.x-t.game.camera.x,t.center.y-t.game.camera.y,t.halfWidth,0,2*d),o?e.fill():e.stroke()):o?e.fillRect(t.position.x-t.game.camera.x,t.position.y-t.game.camera.y,t.width,t.height):e.strokeRect(t.position.x-t.game.camera.x,t.position.y-t.game.camera.y,t.width,t.height)},T.Physics.Arcade.Body.renderBodyInfo=function(e,t){e.line("x: "+t.x.toFixed(2),"y: "+t.y.toFixed(2),"width: "+t.width,"height: "+t.height),e.line("velocity x: "+t.velocity.x.toFixed(2),"y: "+t.velocity.y.toFixed(2),"deltaX: "+t._dx.toFixed(2),"deltaY: "+t._dy.toFixed(2)),e.line("acceleration x: "+t.acceleration.x.toFixed(2),"y: "+t.acceleration.y.toFixed(2),"speed: "+t.speed.toFixed(2),"angle: "+t.angle.toFixed(2)),e.line("gravity x: "+t.gravity.x,"y: "+t.gravity.y,"bounce x: "+t.bounce.x.toFixed(2),"y: "+t.bounce.y.toFixed(2)),e.line("touching left: "+t.touching.left,"right: "+t.touching.right,"up: "+t.touching.up,"down: "+t.touching.down),e.line("blocked left: "+t.blocked.left,"right: "+t.blocked.right,"up: "+t.blocked.up,"down: "+t.blocked.down)},T.Physics.Arcade.Body.prototype.constructor=T.Physics.Arcade.Body,T.Physics.Arcade.TilemapCollision=function(){},T.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(e,t,a,o,r,n){if(e.body){var s=t.getTiles(e.body.position.x-e.body.tilePadding.x-t.getTileOffsetX(),e.body.position.y-e.body.tilePadding.y-t.getTileOffsetY(),e.body.width+e.body.tilePadding.x,e.body.height+e.body.tilePadding.y,!1,!1);if(0!==s.length)for(var d=0;d<s.length;d++)o?o.call(r,e,s[d])&&this.separateTile(d,e.body,s[d],t,n)&&(this._total++,a&&a.call(r,e,s[d])):this.separateTile(d,e.body,s[d],t,n)&&(this._total++,a&&a.call(r,e,s[d]))}},collideGroupVsTilemapLayer:function(e,t,a,o,r,n){if(0!==e.length)for(var s=0;s<e.children.length;s++)e.children[s].exists&&this.collideSpriteVsTilemapLayer(e.children[s],t,a,o,r,n)},separateTile:function(e,t,a,o,r){if(!t.enable)return!1;var n=o.getTileOffsetX(),i=o.getTileOffsetY();if(!a.intersects(t.position.x-n,t.position.y-i,t.right-n,t.bottom-i))return!1;if(r)return!0;if(a.collisionCallback&&!a.collisionCallback.call(a.collisionCallbackContext,t.sprite,a))return!1;if("undefined"!=typeof a.layer.callbacks&&a.layer.callbacks[a.index]&&!a.layer.callbacks[a.index].callback.call(a.layer.callbacks[a.index].callbackContext,t.sprite,a))return!1;if(!a.faceLeft&&!a.faceRight&&!a.faceTop&&!a.faceBottom)return!1;var s=0,d=0,l=0,c=1;if(t.deltaAbsX()>t.deltaAbsY()?l=-1:t.deltaAbsX()<t.deltaAbsY()&&(c=-1),0!==t.deltaX()&&0!==t.deltaY()&&(a.faceLeft||a.faceRight)&&(a.faceTop||a.faceBottom)&&(l=p(f(t.position.x-n-a.right),f(t.right-n-a.left)),c=p(f(t.position.y-i-a.bottom),f(t.bottom-i-a.top))),l<c){if((a.faceLeft||a.faceRight)&&(s=this.tileCheckX(t,a,o),0!==s&&!a.intersects(t.position.x-n,t.position.y-i,t.right-n,t.bottom-i)))return!0;(a.faceTop||a.faceBottom)&&(d=this.tileCheckY(t,a,o))}else{if((a.faceTop||a.faceBottom)&&(d=this.tileCheckY(t,a,o),0!==d&&!a.intersects(t.position.x-n,t.position.y-i,t.right-n,t.bottom-i)))return!0;(a.faceLeft||a.faceRight)&&(s=this.tileCheckX(t,a,o))}return 0!==s||0!==d},tileCheckX:function(e,t,a){var o=0,r=a.getTileOffsetX();return 0>e.deltaX()&&!e.blocked.left&&t.collideRight&&e.checkCollision.left?t.faceRight&&e.x-r<t.right&&(o=e.x-r-t.right,o<-this.TILE_BIAS&&(o=0)):0<e.deltaX()&&!e.blocked.right&&t.collideLeft&&e.checkCollision.right&&t.faceLeft&&e.right-r>t.left&&(o=e.right-r-t.left,o>this.TILE_BIAS&&(o=0)),0!=o&&(e.customSeparateX?e.overlapX=o:this.processTileSeparationX(e,o)),o},tileCheckY:function(e,t,a){var o=0,r=a.getTileOffsetY();return 0>e.deltaY()&&!e.blocked.up&&t.collideDown&&e.checkCollision.up?t.faceBottom&&e.y-r<t.bottom&&(o=e.y-r-t.bottom,o<-this.TILE_BIAS&&(o=0)):0<e.deltaY()&&!e.blocked.down&&t.collideUp&&e.checkCollision.down&&t.faceTop&&e.bottom-r>t.top&&(o=e.bottom-r-t.top,o>this.TILE_BIAS&&(o=0)),0!=o&&(e.customSeparateY?e.overlapY=o:this.processTileSeparationY(e,o)),o},processTileSeparationX:function(e,t){0>t?(e.blocked.left=!0,e.blocked.none=!1):0<t&&(e.blocked.right=!0,e.blocked.none=!1),e.position.x-=t,e.velocity.x=0===e.bounce.x?0:-e.velocity.x*e.bounce.x},processTileSeparationY:function(e,t){0>t?(e.blocked.up=!0,e.blocked.none=!1):0<t&&(e.blocked.down=!0,e.blocked.none=!1),e.position.y-=t,e.velocity.y=0===e.bounce.y?0:-e.velocity.y*e.bounce.y}},T.Utils.mixinPrototype(T.Physics.Arcade.prototype,T.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,T.Physics.P2=function(e,t){this.game=e,void 0===t?t={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(!t.hasOwnProperty("gravity")&&(t.gravity=[0,0]),!t.hasOwnProperty("broadphase")&&(t.broadphase=new p2.SAPBroadphase)),this.config=t,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new T.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new T.Signal,this.onBodyRemoved=new T.Signal,this.onSpringAdded=new T.Signal,this.onSpringRemoved=new T.Signal,this.onConstraintAdded=new T.Signal,this.onConstraintRemoved=new T.Signal,this.onContactMaterialAdded=new T.Signal,this.onContactMaterialRemoved=new T.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new T.Signal,this.onEndContact=new T.Signal,t.hasOwnProperty("mpx")&&t.hasOwnProperty("pxm")&&t.hasOwnProperty("mpxi")&&t.hasOwnProperty("pxmi")&&(this.mpx=t.mpx,this.mpxi=t.mpxi,this.pxm=t.pxm,this.pxmi=t.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new T.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new T.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new T.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},T.Physics.P2.prototype={removeBodyNextStep:function(e){this._toRemove.push(e)},preUpdate:function(){for(var e=this._toRemove.length;e--;)this.removeBody(this._toRemove[e]);this._toRemove.length=0},enable:function(e,t,a){void 0===t&&(t=!1),void 0===a&&(a=!0);var o=1;if(Array.isArray(e))for(o=e.length;o--;)e[o]instanceof T.Group?this.enable(e[o].children,t,a):(this.enableBody(e[o],t),a&&e[o].hasOwnProperty("children")&&0<e[o].children.length&&this.enable(e[o],t,!0));else e instanceof T.Group?this.enable(e.children,t,a):(this.enableBody(e,t),a&&e.hasOwnProperty("children")&&0<e.children.length&&this.enable(e.children,t,!0))},enableBody:function(e,t){e.hasOwnProperty("body")&&null===e.body&&(e.body=new T.Physics.P2.Body(this.game,e,e.x,e.y,1),e.body.debug=t,"undefined"!=typeof e.anchor&&e.anchor.set(0.5))},setImpactEvents:function(e){e?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(e,t){this.postBroadphaseCallback=e,this.callbackContext=t,null===e?this.world.off("postBroadphase",this.postBroadphaseHandler,this):this.world.on("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(e){if(this.postBroadphaseCallback&&0!==e.pairs.length)for(var t=e.pairs.length-2;0<=t;t-=2)e.pairs[t].parent&&e.pairs[t+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,e.pairs[t].parent,e.pairs[t+1].parent)&&e.pairs.splice(t,2)},impactHandler:function(e){if(e.bodyA.parent&&e.bodyB.parent){var t=e.bodyA.parent,a=e.bodyB.parent;t._bodyCallbacks[e.bodyB.id]&&t._bodyCallbacks[e.bodyB.id].call(t._bodyCallbackContext[e.bodyB.id],t,a,e.shapeA,e.shapeB),a._bodyCallbacks[e.bodyA.id]&&a._bodyCallbacks[e.bodyA.id].call(a._bodyCallbackContext[e.bodyA.id],a,t,e.shapeB,e.shapeA),t._groupCallbacks[e.shapeB.collisionGroup]&&t._groupCallbacks[e.shapeB.collisionGroup].call(t._groupCallbackContext[e.shapeB.collisionGroup],t,a,e.shapeA,e.shapeB),a._groupCallbacks[e.shapeA.collisionGroup]&&a._groupCallbacks[e.shapeA.collisionGroup].call(a._groupCallbackContext[e.shapeA.collisionGroup],a,t,e.shapeB,e.shapeA)}},beginContactHandler:function(e){e.bodyA&&e.bodyB&&(this.onBeginContact.dispatch(e.bodyA,e.bodyB,e.shapeA,e.shapeB,e.contactEquations),e.bodyA.parent&&e.bodyA.parent.onBeginContact.dispatch(e.bodyB.parent,e.bodyB,e.shapeA,e.shapeB,e.contactEquations),e.bodyB.parent&&e.bodyB.parent.onBeginContact.dispatch(e.bodyA.parent,e.bodyA,e.shapeB,e.shapeA,e.contactEquations))},endContactHandler:function(e){e.bodyA&&e.bodyB&&(this.onEndContact.dispatch(e.bodyA,e.bodyB,e.shapeA,e.shapeB),e.bodyA.parent&&e.bodyA.parent.onEndContact.dispatch(e.bodyB.parent,e.bodyB,e.shapeA,e.shapeB),e.bodyB.parent&&e.bodyB.parent.onEndContact.dispatch(e.bodyA.parent,e.bodyA,e.shapeB,e.shapeA))},setBoundsToWorld:function(e,t,a,o,r){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,e,t,a,o,r)},setWorldMaterial:function(e,t,a,o,r){void 0===t&&(t=!0),void 0===a&&(a=!0),void 0===o&&(o=!0),void 0===r&&(r=!0),t&&this.walls.left&&(this.walls.left.shapes[0].material=e),a&&this.walls.right&&(this.walls.right.shapes[0].material=e),o&&this.walls.top&&(this.walls.top.shapes[0].material=e),r&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=e)},updateBoundsCollisionGroup:function(e){void 0===e&&(e=!0);var t=e?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=t),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=t),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=t),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=t),this._boundsOwnGroup=e},setBounds:function(e,t,a,o,r,n,i,s,d){void 0===r&&(r=this._boundsLeft),void 0===n&&(n=this._boundsRight),void 0===i&&(i=this._boundsTop),void 0===s&&(s=this._boundsBottom),void 0===d&&(d=this._boundsOwnGroup),this.setupWall(r,"left",e,t,1.5707963267948966,d),this.setupWall(n,"right",e+a,t,-1.5707963267948966,d),this.setupWall(i,"top",e,t,-3.141592653589793,d),this.setupWall(s,"bottom",e,t+o,0,d),this._boundsLeft=r,this._boundsRight=n,this._boundsTop=i,this._boundsBottom=s,this._boundsOwnGroup=d},setupWall:function(e,t,a,o,r,n){e?(this.walls[t]?this.walls[t].position=[this.pxmi(a),this.pxmi(o)]:(this.walls[t]=new p2.Body({mass:0,position:[this.pxmi(a),this.pxmi(o)],angle:r}),this.walls[t].addShape(new p2.Plane),this.world.addBody(this.walls[t])),n&&(this.walls[t].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[t]&&(this.world.removeBody(this.walls[t]),this.walls[t]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new T.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new T.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new T.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var e=this.world.constraints,t=e.length-1;0<=t;t--)this.world.removeConstraint(e[t]);for(var a=this.world.bodies,t=a.length-1;0<=t;t--)this.world.removeBody(a[t]);for(var o=this.world.springs,t=o.length-1;0<=t;t--)this.world.removeSpring(o[t]);for(var r=this.world.contactMaterials,t=r.length-1;0<=t;t--)this.world.removeContactMaterial(r[t]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[],this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear(),this.game=null},addBody:function(e){return!e.data.world&&(this.world.addBody(e.data),this.onBodyAdded.dispatch(e),!0)},removeBody:function(e){return e.data.world===this.world&&(this.world.removeBody(e.data),this.onBodyRemoved.dispatch(e)),e},addSpring:function(e){return e instanceof T.Physics.P2.Spring||e instanceof T.Physics.P2.RotationalSpring?this.world.addSpring(e.data):this.world.addSpring(e),this.onSpringAdded.dispatch(e),e},removeSpring:function(e){return e instanceof T.Physics.P2.Spring||e instanceof T.Physics.P2.RotationalSpring?this.world.removeSpring(e.data):this.world.removeSpring(e),this.onSpringRemoved.dispatch(e),e},createDistanceConstraint:function(e,t,a,o,r,n){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addConstraint(new T.Physics.P2.DistanceConstraint(this,e,t,a,o,r,n)):void console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(e,t,a,o){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addConstraint(new T.Physics.P2.GearConstraint(this,e,t,a,o)):void console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(e,t,a,o,r,n){return e=this.getBody(e),a=this.getBody(a),e&&a?this.addConstraint(new T.Physics.P2.RevoluteConstraint(this,e,t,a,o,r,n)):void console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(e,t,a,o,r){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addConstraint(new T.Physics.P2.LockConstraint(this,e,t,a,o,r)):void console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(e,t,a,o,r,n,i){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addConstraint(new T.Physics.P2.PrismaticConstraint(this,e,t,a,o,r,n,i)):void console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(e){return this.world.addConstraint(e),this.onConstraintAdded.dispatch(e),e},removeConstraint:function(e){return this.world.removeConstraint(e),this.onConstraintRemoved.dispatch(e),e},addContactMaterial:function(e){return this.world.addContactMaterial(e),this.onContactMaterialAdded.dispatch(e),e},removeContactMaterial:function(e){return this.world.removeContactMaterial(e),this.onContactMaterialRemoved.dispatch(e),e},getContactMaterial:function(e,t){return this.world.getContactMaterial(e,t)},setMaterial:function(e,t){for(var a=t.length;a--;)t[a].setMaterial(e)},createMaterial:function(e,t){e=e||"";var a=new T.Physics.P2.Material(e);return this.materials.push(a),"undefined"!=typeof t&&t.setMaterial(a),a},createContactMaterial:function(e,t,a){void 0===e&&(e=this.createMaterial()),void 0===t&&(t=this.createMaterial());var o=new T.Physics.P2.ContactMaterial(e,t,a);return this.addContactMaterial(o)},getBodies:function(){for(var e=[],t=this.world.bodies.length;t--;)e.push(this.world.bodies[t].parent);return e},getBody:function(e){return e instanceof p2.Body?e:e instanceof T.Physics.P2.Body?e.data:e.body&&e.body.type===T.Physics.P2JS?e.body.data:null},getSprings:function(){for(var e=[],t=this.world.springs.length;t--;)e.push(this.world.springs[t].parent);return e},getConstraints:function(){for(var e=[],t=this.world.constraints.length;t--;)e.push(this.world.constraints[t]);return e},hitTest:function(e,t,a,o){void 0===t&&(t=this.world.bodies),void 0===a&&(a=5),void 0===o&&(o=!1);for(var r=[this.pxmi(e.x),this.pxmi(e.y)],n=[],s=t.length;s--;)t[s]instanceof T.Physics.P2.Body&&!(o&&t[s].data.type===p2.Body.STATIC)?n.push(t[s].data):t[s]instanceof p2.Body&&t[s].parent&&!(o&&t[s].type===p2.Body.STATIC)?n.push(t[s]):t[s]instanceof T.Sprite&&t[s].hasOwnProperty("body")&&!(o&&t[s].body.data.type===p2.Body.STATIC)&&n.push(t[s].body.data);return this.world.hitTest(r,n,a)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(e){var t=u(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask|=t),this.walls.right&&(this.walls.right.shapes[0].collisionMask|=t),this.walls.top&&(this.walls.top.shapes[0].collisionMask|=t),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask|=t),this._collisionGroupID++;var a=new T.Physics.P2.CollisionGroup(t);return this.collisionGroups.push(a),e&&this.setCollisionGroup(e,a),a},setCollisionGroup:function(e,t){if(e instanceof T.Group)for(var a=0;a<e.total;a++)e.children[a].body&&e.children[a].body.type===T.Physics.P2JS&&e.children[a].body.setCollisionGroup(t);else e.body.setCollisionGroup(t)},createSpring:function(e,t,a,o,r,n,i,s,d){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addSpring(new T.Physics.P2.Spring(this,e,t,a,o,r,n,i,s,d)):void console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(e,t,a,o,r){return e=this.getBody(e),t=this.getBody(t),e&&t?this.addSpring(new T.Physics.P2.RotationalSpring(this,e,t,a,o,r)):void console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(e,t,a,o,r,n){void 0===o&&(o=!1);var i=new T.Physics.P2.Body(this.game,null,e,t,a);if(n){var s=i.addPolygon(r,n);if(!s)return!1}return o&&this.world.addBody(i.data),i},createParticle:function(e,t,a,o,r,n){void 0===o&&(o=!1);var i=new T.Physics.P2.Body(this.game,null,e,t,a);if(n){var s=i.addPolygon(r,n);if(!s)return!1}return o&&this.world.addBody(i.data),i},convertCollisionObjects:function(e,t,a){void 0===a&&(a=!0);for(var o=[],r=0,n=e.collision[t].length;r<n;r++){var i=e.collision[t][r],s=i.polyline||i.polygon;if(s)var d=this.createBody(i.x,i.y,0,a,{},s);else if(i.rectangle){var d=this.createBody(i.x,i.y,0,a);d.addRectangle(i.width,i.height,i.width/2,i.height/2)}d&&o.push(d)}return o},clearTilemapLayerBodies:function(e,t){t=e.getLayer(t);for(var a=e.layers[t].bodies.length;a--;)e.layers[t].bodies[a].destroy();e.layers[t].bodies.length=0},convertTilemap:function(e,t,a,o){t=e.getLayer(t),void 0===a&&(a=!0),void 0===o&&(o=!0),this.clearTilemapLayerBodies(e,t);for(var r=0,n=0,i=0,s=0,d=e.layers[t].height;s<d;s++){r=0;for(var l=0,p=e.layers[t].width,c;l<p;l++)if(c=e.layers[t].data[s][l],c&&-1<c.index&&c.collides)if(o){var u=e.getTileRight(t,l,s);if(0==r&&(n=c.x*c.width,i=c.y*c.height,r=c.width),u&&u.collides)r+=c.width;else{var h=this.createBody(n,i,0,!1);h.addRectangle(r,c.height,r/2,c.height/2,0),a&&this.addBody(h),e.layers[t].bodies.push(h),r=0}}else{var h=this.createBody(c.x*c.width,c.y*c.height,0,!1);h.addRectangle(c.width,c.height,c.width/2,c.height/2,0),a&&this.addBody(h),e.layers[t].bodies.push(h)}}return e.layers[t].bodies},mpx:function(e){return e*=20},pxm:function(e){return 0.05*e},mpxi:function(e){return e*=-20},pxmi:function(e){return-0.05*e}},Object.defineProperty(T.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(e){this.world.defaultContactMaterial.friction=e}}),Object.defineProperty(T.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(e){this.world.defaultContactMaterial.restitution=e}}),Object.defineProperty(T.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(e){this.world.defaultContactMaterial=e}}),Object.defineProperty(T.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(e){this.world.applySpringForces=e}}),Object.defineProperty(T.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(e){this.world.applyDamping=e}}),Object.defineProperty(T.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(e){this.world.applyGravity=e}}),Object.defineProperty(T.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(e){this.world.solveConstraints=e}}),Object.defineProperty(T.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(T.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(e){this.world.emitImpactEvent=e}}),Object.defineProperty(T.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(e){this.world.sleepMode=e}}),Object.defineProperty(T.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),T.Physics.P2.FixtureList=function(e){Array.isArray(e)||(e=[e]),this.rawList=e,this.init(),this.parse(this.rawList)},T.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(e,t){this.getFixtures(t).forEach(function(t){t.collisionGroup=e})},setMask:function(e,t){this.getFixtures(t).forEach(function(t){t.collisionMask=e})},setSensor:function(e,t){this.getFixtures(t).forEach(function(t){t.sensor=e})},setMaterial:function(e,t){this.getFixtures(t).forEach(function(t){t.material=e})},getFixtures:function(e){var t=[];if(e){e instanceof Array||(e=[e]);var a=this;return e.forEach(function(e){a.namedFixtures[e]&&t.push(a.namedFixtures[e])}),this.flatten(t)}return this.allFixtures},getFixtureByKey:function(e){return this.namedFixtures[e]},getGroup:function(e){return this.groupedFixtures[e]},parse:function(){var e,t,a,o;for(e in a=this.rawList,o=[],a)t=a[e],isNaN(e-0)?this.namedFixtures[e]=this.flatten(t):(this.groupedFixtures[e]=this.groupedFixtures[e]||[],this.groupedFixtures[e]=this.groupedFixtures[e].concat(t)),o.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(e){var t,a;return t=[],a=arguments.callee,e.forEach(function(e){return Array.prototype.push.apply(t,Array.isArray(e)?a(e):[e])}),t}},T.Physics.P2.PointProxy=function(e,t){this.world=e,this.destination=t},T.Physics.P2.PointProxy.prototype.constructor=T.Physics.P2.PointProxy,Object.defineProperty(T.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(e){this.destination[0]=this.world.pxm(e)}}),Object.defineProperty(T.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(e){this.destination[1]=this.world.pxm(e)}}),Object.defineProperty(T.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(e){this.destination[0]=e}}),Object.defineProperty(T.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(e){this.destination[1]=e}}),T.Physics.P2.InversePointProxy=function(e,t){this.world=e,this.destination=t},T.Physics.P2.InversePointProxy.prototype.constructor=T.Physics.P2.InversePointProxy,Object.defineProperty(T.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(e){this.destination[0]=this.world.pxmi(e)}}),Object.defineProperty(T.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(e){this.destination[1]=this.world.pxmi(e)}}),Object.defineProperty(T.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(e){this.destination[0]=-e}}),Object.defineProperty(T.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(e){this.destination[1]=-e}}),T.Physics.P2.Body=function(e,t,a,o,r){t=t||null,a=a||0,o=o||0,void 0===r&&(r=1),this.game=e,this.world=e.physics.p2,this.sprite=t,this.type=T.Physics.P2JS,this.offset=new T.Point,this.data=new p2.Body({position:[this.world.pxmi(a),this.world.pxmi(o)],mass:r}),this.data.parent=this,this.velocity=new T.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new T.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new T.Point,this.onBeginContact=new T.Signal,this.onEndContact=new T.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,t&&(this.setRectangleFromSprite(t),t.exists&&this.game.physics.p2.addBody(this))},T.Physics.P2.Body.prototype={createBodyCallback:function(e,t,a){var o=-1;e.id?o=e.id:e.body&&(o=e.body.id),-1<o&&(null===t?(delete this._bodyCallbacks[o],delete this._bodyCallbackContext[o]):(this._bodyCallbacks[o]=t,this._bodyCallbackContext[o]=a))},createGroupCallback:function(e,t,a){null===t?(delete this._groupCallbacks[e.mask],delete this._groupCallbackContext[e.mask]):(this._groupCallbacks[e.mask]=t,this._groupCallbackContext[e.mask]=a)},getCollisionMask:function(){var e=0;this._collideWorldBounds&&(e=this.game.physics.p2.boundsCollisionGroup.mask);for(var t=0;t<this.collidesWith.length;t++)e|=this.collidesWith[t].mask;return e},updateCollisionMask:function(e){var t=this.getCollisionMask();if(void 0===e)for(var a=this.data.shapes.length-1;0<=a;a--)this.data.shapes[a].collisionMask=t;else e.collisionMask=t},setCollisionGroup:function(e,t){var a=this.getCollisionMask();if(void 0===t)for(var o=this.data.shapes.length-1;0<=o;o--)this.data.shapes[o].collisionGroup=e.mask,this.data.shapes[o].collisionMask=a;else t.collisionGroup=e.mask,t.collisionMask=a},clearCollision:function(e,t,a){if(void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===a)for(var o=this.data.shapes.length-1;0<=o;o--)e&&(this.data.shapes[o].collisionGroup=null),t&&(this.data.shapes[o].collisionMask=null);else e&&(a.collisionGroup=null),t&&(a.collisionMask=null);e&&(this.collidesWith.length=0)},removeCollisionGroup:function(e,t,a){void 0===t&&(t=!0);var o;if(Array.isArray(e))for(var r=0;r<e.length;r++)o=this.collidesWith.indexOf(e[r]),-1<o&&(this.collidesWith.splice(o,1),t&&(delete this._groupCallbacks[e.mask],delete this._groupCallbackContext[e.mask]));else o=this.collidesWith.indexOf(e),-1<o&&(this.collidesWith.splice(o,1),t&&(delete this._groupCallbacks[e.mask],delete this._groupCallbackContext[e.mask]));var n=this.getCollisionMask();if(void 0===a)for(var r=this.data.shapes.length-1;0<=r;r--)this.data.shapes[r].collisionMask=n;else a.collisionMask=n},collides:function(e,t,a,o){if(Array.isArray(e))for(var r=0;r<e.length;r++)-1===this.collidesWith.indexOf(e[r])&&(this.collidesWith.push(e[r]),t&&this.createGroupCallback(e[r],t,a));else-1===this.collidesWith.indexOf(e)&&(this.collidesWith.push(e),t&&this.createGroupCallback(e,t,a));var n=this.getCollisionMask();if(void 0===o)for(var r=this.data.shapes.length-1;0<=r;r--)this.data.shapes[r].collisionMask=n;else o.collisionMask=n},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(e,t){return this.data.getVelocityAtPoint(e,t)},applyDamping:function(e){this.data.applyDamping(e)},applyImpulse:function(e,t,a){this.data.applyImpulse(e,[this.world.pxmi(t),this.world.pxmi(a)])},applyImpulseLocal:function(e,t,a){this.data.applyImpulseLocal(e,[this.world.pxmi(t),this.world.pxmi(a)])},applyForce:function(e,t,a){this.data.applyForce(e,[this.world.pxmi(t),this.world.pxmi(a)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(e,t){return this.data.toLocalFrame(e,t)},toWorldFrame:function(e,t){return this.data.toWorldFrame(e,t)},rotateLeft:function(e){this.data.angularVelocity=this.world.pxm(-e)},rotateRight:function(e){this.data.angularVelocity=this.world.pxm(e)},moveForward:function(e){var t=this.world.pxmi(-e),a=this.data.angle+d/2;this.data.velocity[0]=t*m(a),this.data.velocity[1]=t*h(a)},moveBackward:function(e){var t=this.world.pxmi(-e),a=this.data.angle+d/2;this.data.velocity[0]=-(t*m(a)),this.data.velocity[1]=-(t*h(a))},thrust:function(e){var t=this.world.pxmi(-e),a=this.data.angle+d/2;this.data.force[0]+=t*m(a),this.data.force[1]+=t*h(a)},thrustLeft:function(e){var t=this.world.pxmi(-e),a=this.data.angle;this.data.force[0]+=t*m(a),this.data.force[1]+=t*h(a)},thrustRight:function(e){var t=this.world.pxmi(-e),a=this.data.angle;this.data.force[0]-=t*m(a),this.data.force[1]-=t*h(a)},reverse:function(e){var t=this.world.pxmi(-e),a=this.data.angle+d/2;this.data.force[0]-=t*m(a),this.data.force[1]-=t*h(a)},moveLeft:function(e){this.data.velocity[0]=this.world.pxmi(-e)},moveRight:function(e){this.data.velocity[0]=this.world.pxmi(e)},moveUp:function(e){this.data.velocity[1]=this.world.pxmi(-e)},moveDown:function(e){this.data.velocity[1]=this.world.pxmi(e)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x,this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y,this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(e,t,a,o){void 0===a&&(a=!1),void 0===o&&(o=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),a&&this.setZeroDamping(),o&&(this.mass=1),this.x=e,this.y=t},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var e=0;e<this.game.physics.p2._toRemove.length;e++)this.game.physics.p2._toRemove[e]===this&&this.game.physics.p2._toRemove.splice(e,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld(),this.clearShapes(),this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this.debugBody&&this.debugBody.destroy(!0,!0),this.debugBody=null,this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var e=this.data.shapes.length;e--;)this.data.removeShape(this.data.shapes[e]);this.shapeChanged()},addShape:function(e,t,a,o){return void 0===t&&(t=0),void 0===a&&(a=0),void 0===o&&(o=0),this.data.addShape(e,[this.world.pxmi(t),this.world.pxmi(a)],o),this.shapeChanged(),e},addCircle:function(e,t,a,o){var r=new p2.Circle({radius:this.world.pxm(e)});return this.addShape(r,t,a,o)},addRectangle:function(e,t,a,o,r){var n=new p2.Box({width:this.world.pxm(e),height:this.world.pxm(t)});return this.addShape(n,a,o,r)},addPlane:function(e,t,a){var o=new p2.Plane;return this.addShape(o,e,t,a)},addParticle:function(e,t,a){var o=new p2.Particle;return this.addShape(o,e,t,a)},addLine:function(e,t,a,o){var r=new p2.Line({length:this.world.pxm(e)});return this.addShape(r,t,a,o)},addCapsule:function(e,t,a,o,r){var n=new p2.Capsule({length:this.world.pxm(e),radius:this.world.pxm(t)});return this.addShape(n,a,o,r)},addPolygon:function(e,t){e=e||{},Array.isArray(t)||(t=Array.prototype.slice.call(arguments,1));var a=[];if(1===t.length&&Array.isArray(t[0]))a=t[0].slice(0);else if(Array.isArray(t[0]))a=t.slice();else if("number"==typeof t[0])for(var o=0,r=t.length;o<r;o+=2)a.push([t[o],t[o+1]]);var n=a.length-1;a[n][0]===a[0][0]&&a[n][1]===a[0][1]&&a.pop();for(var i=0;i<a.length;i++)a[i][0]=this.world.pxmi(a[i][0]),a[i][1]=this.world.pxmi(a[i][1]);var s=this.data.fromPolygon(a,e);return this.shapeChanged(),s},removeShape:function(e){var t=this.data.removeShape(e);return this.shapeChanged(),t},setCircle:function(e,t,a,o){return this.clearShapes(),this.addCircle(e,t,a,o)},setRectangle:function(e,t,a,o,r){return void 0===e&&(e=16),void 0===t&&(t=16),this.clearShapes(),this.addRectangle(e,t,a,o,r)},setRectangleFromSprite:function(e){return void 0===e&&(e=this.sprite),this.clearShapes(),this.addRectangle(e.width,e.height,0,0,e.rotation)},setMaterial:function(e,t){if(void 0===t)for(var a=this.data.shapes.length-1;0<=a;a--)this.data.shapes[a].material=e;else t.material=e},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(e,t){for(var a=this.game.cache.getPhysicsData(e,t),o=[],r=0;r<a.length;r++){var n=a[r],i=this.addFixture(n);o[n.filter.group]=o[n.filter.group]||[],o[n.filter.group]=o[n.filter.group].concat(i),n.fixtureKey&&(o[n.fixtureKey]=i)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),o},addFixture:function(e){var t=[];if(e.circle){var a=new p2.Circle({radius:this.world.pxm(e.circle.radius)});a.collisionGroup=e.filter.categoryBits,a.collisionMask=e.filter.maskBits,a.sensor=e.isSensor;var o=p2.vec2.create();o[0]=this.world.pxmi(e.circle.position[0]-this.sprite.width/2),o[1]=this.world.pxmi(e.circle.position[1]-this.sprite.height/2),this.data.addShape(a,o),t.push(a)}else for(var r=e.polygons,n=p2.vec2.create(),d=0;d<r.length;d++){for(var i=r[d],l=[],p=0;p<i.length;p+=2)l.push([this.world.pxmi(i[p]),this.world.pxmi(i[p+1])]);for(var a=new p2.Convex({vertices:l}),s=0,c;s!==a.vertices.length;s++)c=a.vertices[s],p2.vec2.sub(c,c,a.centerOfMass);p2.vec2.scale(n,a.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),a.updateTriangles(),a.updateCenterOfMass(),a.updateBoundingRadius(),a.collisionGroup=e.filter.categoryBits,a.collisionMask=e.filter.maskBits,a.sensor=e.isSensor,this.data.addShape(a,n),t.push(a)}return t},loadPolygon:function(e,t,a){if(null===e)var o=t;else var o=this.game.cache.getPhysicsData(e,t);"number"!=typeof a&&(a=1);for(var r=p2.vec2.create(),n=0,i;n<o.length;n++){i=[];for(var d=0;d<o[n].shape.length;d+=2)i.push([this.world.pxmi(o[n].shape[d]*a),this.world.pxmi(o[n].shape[d+1]*a)]);for(var s=new p2.Convex({vertices:i}),l=0,p;l!==s.vertices.length;l++)p=s.vertices[l],p2.vec2.sub(p,p,s.centerOfMass);p2.vec2.scale(r,s.centerOfMass,1),r[0]-=this.world.pxmi(this.sprite.width/2),r[1]-=this.world.pxmi(this.sprite.height/2),s.updateTriangles(),s.updateCenterOfMass(),s.updateBoundingRadius(),this.data.addShape(s,r)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},T.Physics.P2.Body.prototype.constructor=T.Physics.P2.Body,T.Physics.P2.Body.DYNAMIC=1,T.Physics.P2.Body.STATIC=2,T.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(T.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===T.Physics.P2.Body.STATIC},set:function(e){e&&this.data.type!==T.Physics.P2.Body.STATIC?(this.data.type=T.Physics.P2.Body.STATIC,this.mass=0):!e&&this.data.type===T.Physics.P2.Body.STATIC&&(this.data.type=T.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===T.Physics.P2.Body.DYNAMIC},set:function(e){e&&this.data.type!==T.Physics.P2.Body.DYNAMIC?(this.data.type=T.Physics.P2.Body.DYNAMIC,this.mass=1):!e&&this.data.type===T.Physics.P2.Body.DYNAMIC&&(this.data.type=T.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===T.Physics.P2.Body.KINEMATIC},set:function(e){e&&this.data.type!==T.Physics.P2.Body.KINEMATIC?(this.data.type=T.Physics.P2.Body.KINEMATIC,this.mass=4):!e&&this.data.type===T.Physics.P2.Body.KINEMATIC&&(this.data.type=T.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(e){e!==this.data.allowSleep&&(this.data.allowSleep=e)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"angle",{get:function(){return T.Math.wrapAngle(T.Math.radToDeg(this.data.angle))},set:function(e){this.data.angle=T.Math.degToRad(T.Math.wrapAngle(e))}}),Object.defineProperty(T.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(e){this.data.angularDamping=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(e){this.data.angularForce=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(e){this.data.angularVelocity=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(e){this.data.damping=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(e){e!==this.data.fixedRotation&&(this.data.fixedRotation=e)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(e){this.data.inertia=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(e){e!==this.data.mass&&(this.data.mass=e,this.data.updateMassProperties())}}),Object.defineProperty(T.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(e){e!==this.data.type&&(this.data.type=e)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(e){this.data.angle=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(e){this.data.sleepSpeedLimit=e}}),Object.defineProperty(T.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(e){this.data.position[0]=this.world.pxmi(e)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(e){this.data.position[1]=this.world.pxmi(e)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(T.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(e){e&&!this.debugBody?this.debugBody=new T.Physics.P2.BodyDebug(this.game,this.data):!e&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(T.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(e){e&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!e&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),T.Physics.P2.BodyDebug=function(e,t,a){T.Group.call(this,e);var o={pixelsPerLengthUnit:e.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:0.5};this.settings=T.Utils.extend(o,a),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=t,this.canvas=new T.Graphics(e),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},T.Physics.P2.BodyDebug.prototype=Object.create(T.Group.prototype),T.Physics.P2.BodyDebug.prototype.constructor=T.Physics.P2.BodyDebug,T.Utils.extend(T.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu,this.position.y=this.body.position[1]*this.ppu,this.rotation=this.body.angle},draw:function(){var e,t,a,o,r,n,i,s,d,p,c,u,h,g,m;if(s=this.body,p=this.canvas,p.clear(),a=parseInt(this.randomPastelHex(),16),n=16711680,i=this.lineWidth,s instanceof p2.Body&&s.shapes.length){var y=s.shapes.length;for(o=0;o!==y;){if(t=s.shapes[o],d=t.position||0,e=t.angle||0,t instanceof p2.Circle)this.drawCircle(p,d[0]*this.ppu,d[1]*this.ppu,e,t.radius*this.ppu,a,i);else if(t instanceof p2.Capsule)this.drawCapsule(p,d[0]*this.ppu,d[1]*this.ppu,e,t.length*this.ppu,t.radius*this.ppu,n,a,i);else if(t instanceof p2.Plane)this.drawPlane(p,d[0]*this.ppu,-d[1]*this.ppu,a,n,5*i,10*i,10*i,100*this.ppu,e);else if(t instanceof p2.Line)this.drawLine(p,t.length*this.ppu,n,i);else if(t instanceof p2.Box)this.drawRectangle(p,d[0]*this.ppu,d[1]*this.ppu,e,t.width*this.ppu,t.height*this.ppu,n,a,i);else if(t instanceof p2.Convex){for(u=[],h=p2.vec2.create(),(r=g=0,m=t.vertices.length);0<=m?g<m:g>m;r=0<=m?++g:--g)c=t.vertices[r],p2.vec2.rotate(h,c,e),u.push([(h[0]+d[0])*this.ppu,-(h[1]+d[1])*this.ppu]);this.drawConvex(p,u,t.triangles,n,a,i,this.settings.debugPolygons,[d[0]*this.ppu,-d[1]*this.ppu])}o++}}},drawRectangle:function(e,t,a,o,r,n,i,s,d){void 0===d&&(d=1),void 0===i&&(i=0),e.lineStyle(d,i,1),e.beginFill(s),e.drawRect(t-r/2,a-n/2,r,n)},drawCircle:function(e,t,a,o,r,n,i){void 0===i&&(i=1),void 0===n&&(n=16777215),e.lineStyle(i,0,1),e.beginFill(n,1),e.drawCircle(t,a,2*-r),e.endFill(),e.moveTo(t,a),e.lineTo(t+r*m(-o),a+r*h(-o))},drawLine:function(e,t,a,o){void 0===o&&(o=1),void 0===a&&(a=0),e.lineStyle(5*o,a,1),e.moveTo(-t/2,0),e.lineTo(t/2,0)},drawConvex:function(e,t,a,o,r,n,s,d){var l,p,i,c,u,h,g,m,f,x,b;if(void 0===n&&(n=1),void 0===o&&(o=0),!s){for(e.lineStyle(n,o,1),e.beginFill(r),p=0;p!==t.length;)i=t[p],h=i[0],f=i[1],0===p?e.moveTo(h,-f):e.lineTo(h,-f),p++;if(e.endFill(),2<t.length)return e.moveTo(t[t.length-1][0],-t[t.length-1][1]),e.lineTo(t[0][0],-t[0][1])}else{for(l=[16711680,65280,255],p=0;p!==t.length+1;)c=t[p%t.length],u=t[(p+1)%t.length],g=c[0],x=c[1],m=u[0],b=u[1],e.lineStyle(n,l[p%l.length],1),e.moveTo(g,-x),e.lineTo(m,-b),e.drawCircle(g,-x,2*n),p++;return e.lineStyle(n,0,1),e.drawCircle(d[0],d[1],2*n)}},drawPath:function(e,t,a,o,r){var n,s,i,d,l,p,c,u,h,g,m,f,x;for(void 0===r&&(r=1),void 0===a&&(a=0),e.lineStyle(r,a,1),"number"==typeof o&&e.beginFill(o),i=null,d=null,s=0;s<t.length;)m=t[s],f=m[0],x=m[1],(f!==i||x!==d)&&(0===s?e.moveTo(f,x):(l=i,p=d,c=f,u=x,h=t[(s+1)%t.length][0],g=t[(s+1)%t.length][1],n=(c-l)*(g-p)-(h-l)*(u-p),0!==n&&e.lineTo(f,x)),i=f,d=x),s++;"number"==typeof o&&e.endFill(),2<t.length&&"number"==typeof o&&(e.moveTo(t[t.length-1][0],t[t.length-1][1]),e.lineTo(t[0][0],t[0][1]))},drawPlane:function(e,t,a,o,r,n,i,s,d,l){var p,c,u;void 0===n&&(n=1),void 0===o&&(o=16777215),e.lineStyle(n,r,11),e.beginFill(o),p=d,e.moveTo(t,-a),c=t+m(l)*this.game.width,u=a+h(l)*this.game.height,e.lineTo(c,-u),e.moveTo(t,-a),c=t+m(l)*-this.game.width,u=a+h(l)*-this.game.height,e.lineTo(c,-u)},drawCapsule:function(e,t,a,o,r,n,i,d,l){void 0===l&&(l=1),void 0===i&&(i=0),e.lineStyle(l,i,1);var p=m(o),c=h(o);e.beginFill(d,1),e.drawCircle(-r/2*p+t,-r/2*c+a,2*-n),e.drawCircle(r/2*p+t,r/2*c+a,2*-n),e.endFill(),e.lineStyle(l,i,0),e.beginFill(d,1),e.moveTo(-r/2*p+n*c+t,-r/2*c+n*p+a),e.lineTo(r/2*p+n*c+t,r/2*c+n*p+a),e.lineTo(r/2*p-n*c+t,r/2*c-n*p+a),e.lineTo(-r/2*p-n*c+t,-r/2*c-n*p+a),e.endFill(),e.lineStyle(l,i,1),e.moveTo(-r/2*p+n*c+t,-r/2*c+n*p+a),e.lineTo(r/2*p+n*c+t,r/2*c+n*p+a),e.moveTo(-r/2*p-n*c+t,-r/2*c-n*p+a),e.lineTo(r/2*p-n*c+t,r/2*c-n*p+a)},randomPastelHex:function(){var e,t,a,o;return a=[255,255,255],o=c(256*Math.random()),t=c(256*Math.random()),e=c(256*Math.random()),o=c((o+3*a[0])/4),t=c((t+3*a[1])/4),e=c((e+3*a[2])/4),this.rgbToHex(o,t,e)},rgbToHex:function(e,t,a){return this.componentToHex(e)+this.componentToHex(t)+this.componentToHex(a)},componentToHex:function(e){var t;return t=e.toString(16),2===t.length?t:t+"0"}}),T.Physics.P2.Spring=function(e,t,a,o,r,n,i,s,d,l){this.game=e.game,this.world=e,void 0===o&&(o=1),void 0===r&&(r=100),void 0===n&&(n=1),o=e.pxm(o);var p={restLength:o,stiffness:r,damping:n};"undefined"!=typeof i&&null!==i&&(p.worldAnchorA=[e.pxm(i[0]),e.pxm(i[1])]),"undefined"!=typeof s&&null!==s&&(p.worldAnchorB=[e.pxm(s[0]),e.pxm(s[1])]),"undefined"!=typeof d&&null!==d&&(p.localAnchorA=[e.pxm(d[0]),e.pxm(d[1])]),"undefined"!=typeof l&&null!==l&&(p.localAnchorB=[e.pxm(l[0]),e.pxm(l[1])]),this.data=new p2.LinearSpring(t,a,p),this.data.parent=this},T.Physics.P2.Spring.prototype.constructor=T.Physics.P2.Spring,T.Physics.P2.RotationalSpring=function(e,t,a,o,r,n){this.game=e.game,this.world=e,void 0===o&&(o=null),void 0===r&&(r=100),void 0===n&&(n=1),o&&(o=e.pxm(o));var i={restAngle:o,stiffness:r,damping:n};this.data=new p2.RotationalSpring(t,a,i),this.data.parent=this},T.Physics.P2.Spring.prototype.constructor=T.Physics.P2.Spring,T.Physics.P2.Material=function(e){this.name=e,p2.Material.call(this)},T.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),T.Physics.P2.Material.prototype.constructor=T.Physics.P2.Material,T.Physics.P2.ContactMaterial=function(e,t,a){p2.ContactMaterial.call(this,e,t,a)},T.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),T.Physics.P2.ContactMaterial.prototype.constructor=T.Physics.P2.ContactMaterial,T.Physics.P2.CollisionGroup=function(e){this.mask=e},T.Physics.P2.DistanceConstraint=function(e,t,a,o,r,n,i){void 0===o&&(o=100),void 0===r&&(r=[0,0]),void 0===n&&(n=[0,0]),void 0===i&&(i=g),this.game=e.game,this.world=e,o=e.pxm(o),r=[e.pxmi(r[0]),e.pxmi(r[1])],n=[e.pxmi(n[0]),e.pxmi(n[1])];var s={distance:o,localAnchorA:r,localAnchorB:n,maxForce:i};p2.DistanceConstraint.call(this,t,a,s)},T.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),T.Physics.P2.DistanceConstraint.prototype.constructor=T.Physics.P2.DistanceConstraint,T.Physics.P2.GearConstraint=function(e,t,a,o,r){void 0===o&&(o=0),void 0===r&&(r=1),this.game=e.game,this.world=e;var n={angle:o,ratio:r};p2.GearConstraint.call(this,t,a,n)},T.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),T.Physics.P2.GearConstraint.prototype.constructor=T.Physics.P2.GearConstraint,T.Physics.P2.LockConstraint=function(e,t,a,o,r,n){void 0===o&&(o=[0,0]),void 0===r&&(r=0),void 0===n&&(n=g),this.game=e.game,this.world=e,o=[e.pxm(o[0]),e.pxm(o[1])];var i={localOffsetB:o,localAngleB:r,maxForce:n};p2.LockConstraint.call(this,t,a,i)},T.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),T.Physics.P2.LockConstraint.prototype.constructor=T.Physics.P2.LockConstraint,T.Physics.P2.PrismaticConstraint=function(e,t,a,o,r,n,i,s){void 0===o&&(o=!0),void 0===r&&(r=[0,0]),void 0===n&&(n=[0,0]),void 0===i&&(i=[0,0]),void 0===s&&(s=g),this.game=e.game,this.world=e,r=[e.pxmi(r[0]),e.pxmi(r[1])],n=[e.pxmi(n[0]),e.pxmi(n[1])];var d={localAnchorA:r,localAnchorB:n,localAxisA:i,maxForce:s,disableRotationalLock:!o};p2.PrismaticConstraint.call(this,t,a,d)},T.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),T.Physics.P2.PrismaticConstraint.prototype.constructor=T.Physics.P2.PrismaticConstraint,T.Physics.P2.RevoluteConstraint=function(e,t,a,o,r,n,i){void 0===n&&(n=g),void 0===i&&(i=null),this.game=e.game,this.world=e,a=[e.pxmi(a[0]),e.pxmi(a[1])],r=[e.pxmi(r[0]),e.pxmi(r[1])],i&&(i=[e.pxmi(i[0]),e.pxmi(i[1])]);var s={worldPivot:i,localPivotA:a,localPivotB:r,maxForce:n};p2.RevoluteConstraint.call(this,t,o,s)},T.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),T.Physics.P2.RevoluteConstraint.prototype.constructor=T.Physics.P2.RevoluteConstraint,T.ImageCollection=function(e,t,a,o,r,n,i){(void 0===a||0>=a)&&(a=32),(void 0===o||0>=o)&&(o=32),void 0===r&&(r=0),void 0===n&&(n=0),this.name=e,this.firstgid=0|t,this.imageWidth=0|a,this.imageHeight=0|o,this.imageMargin=0|r,this.imageSpacing=0|n,this.properties=i||{},this.images=[],this.total=0},T.ImageCollection.prototype={containsImageIndex:function(e){return e>=this.firstgid&&e<this.firstgid+this.total},addImage:function(e,t){this.images.push({gid:e,image:t}),this.total++}},T.ImageCollection.prototype.constructor=T.ImageCollection,T.Tile=function(e,t,a,o,r,n){this.layer=e,this.index=t,this.x=a,this.y=o,this.rotation=0,this.flipped=!1,this.worldX=a*r,this.worldY=o*n,this.width=r,this.height=n,this.centerX=f(r/2),this.centerY=f(n/2),this.alpha=1,this.properties={},this.scanned=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.collisionCallback=null,this.collisionCallbackContext=this},T.Tile.prototype={containsPoint:function(e,t){return!(e<this.worldX||t<this.worldY||e>this.right||t>this.bottom)},intersects:function(e,t,a,o){return!(a<=this.worldX)&&!(o<=this.worldY)&&!(e>=this.worldX+this.width)&&!(t>=this.worldY+this.height)},setCollisionCallback:function(e,t){this.collisionCallback=e,this.collisionCallbackContext=t},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(e,t,a,o){this.collideLeft=e,this.collideRight=t,this.collideUp=a,this.collideDown=o,this.faceLeft=e,this.faceRight=t,this.faceTop=a,this.faceBottom=o},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(e,t){return e&&t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!t&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(e){this.index=e.index,this.alpha=e.alpha,this.properties=e.properties,this.collideUp=e.collideUp,this.collideDown=e.collideDown,this.collideLeft=e.collideLeft,this.collideRight=e.collideRight,this.collisionCallback=e.collisionCallback,this.collisionCallbackContext=e.collisionCallbackContext}},T.Tile.prototype.constructor=T.Tile,Object.defineProperty(T.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(T.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(T.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(T.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(T.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(T.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),T.Tilemap=function(e,t,a,o,r,n){this.game=e,this.key=t;var i=T.TilemapParser.parse(this.game,t,a,o,r,n);null===i||(this.width=i.width,this.height=i.height,this.tileWidth=i.tileWidth,this.tileHeight=i.tileHeight,this.orientation=i.orientation,this.format=i.format,this.version=i.version,this.properties=i.properties,this.widthInPixels=i.widthInPixels,this.heightInPixels=i.heightInPixels,this.layers=i.layers,this.tilesets=i.tilesets,this.imagecollections=i.imagecollections,this.tiles=i.tiles,this.objects=i.objects,this.collideIndexes=[],this.collision=i.collision,this.images=i.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},T.Tilemap.CSV=0,T.Tilemap.TILED_JSON=1,T.Tilemap.NORTH=0,T.Tilemap.EAST=1,T.Tilemap.SOUTH=2,T.Tilemap.WEST=3,T.Tilemap.prototype={create:function(e,t,a,o,r,n){return void 0===n&&(n=this.game.world),this.width=t,this.height=a,this.setTileSize(o,r),this.layers.length=0,this.createBlankLayer(e,t,a,o,r,n)},setTileSize:function(e,t){this.tileWidth=e,this.tileHeight=t,this.widthInPixels=this.width*e,this.heightInPixels=this.height*t},addTilesetImage:function(e,a,o,r,n,s,d){if(void 0===e)return null;void 0===o&&(o=this.tileWidth),void 0===r&&(r=this.tileHeight),void 0===n&&(n=0),void 0===s&&(s=0),void 0===d&&(d=0),0===o&&(o=32),0===r&&(r=32);var l=null;if((void 0===a||null===a)&&(a=e),a instanceof T.BitmapData)l=a.canvas;else{if(!this.game.cache.checkImageKey(a))return console.warn("Phaser.Tilemap.addTilesetImage: Invalid image key given: \""+a+"\""),null;l=this.game.cache.getImage(a)}var p=this.getTilesetIndex(e);if(null===p&&this.format===T.Tilemap.TILED_JSON)return console.warn("Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: \""+e+"\""),null;if(this.tilesets[p])return this.tilesets[p].setImage(l),this.tilesets[p];var c=new T.Tileset(e,d,o,r,n,s,{});c.setImage(l),this.tilesets.push(c);for(var u=this.tilesets.length-1,i=n,h=n,g=0,m=0,y=0,f=d;f<d+c.total&&(this.tiles[f]=[i,h,u],i+=o+s,g++,g!==c.total)&&(m++,!(m===c.columns&&(i=n,h+=r+s,m=0,y++,y===c.rows)));f++);return c},createFromObjects:function(e,t,a,o,r,n,s,d,l){if(void 0===r&&(r=!0),void 0===n&&(n=!1),void 0===s&&(s=this.game.world),void 0===d&&(d=T.Sprite),void 0===l&&(l=!0),!this.objects[e])return void console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: "+e);for(var p=0;p<this.objects[e].length;p++){var i=!1,c=this.objects[e][p];if(void 0!==c.gid&&"number"==typeof t&&c.gid===t?i=!0:void 0!==c.id&&"number"==typeof t&&c.id===t?i=!0:void 0!==c.name&&"string"==typeof t&&c.name===t&&(i=!0),i){var u=new d(this.game,parseFloat(c.x,10),parseFloat(c.y,10),a,o);for(var h in u.name=c.name,u.autoCull=n,u.exists=r,u.visible=c.visible,c.width&&(u.width=c.width),c.height&&(u.height=c.height),c.rotation&&(u.angle=c.rotation),l&&(u.y-=u.height),s.add(u),c.properties)s.set(u,h,c.properties[h],!1,!1,0,!0)}}},createFromTiles:function(e,t,a,o,r,n){"number"==typeof e&&(e=[e]),void 0===t||null===t?t=[]:"number"==typeof t&&(t=[t]),o=this.getLayer(o),void 0===r&&(r=this.game.world),void 0===n&&(n={}),void 0===n.customClass&&(n.customClass=T.Sprite),void 0===n.adjustY&&(n.adjustY=!0);var s=this.layers[o].width,d=this.layers[o].height;if(this.copy(0,0,s,d,o),2>this._results.length)return 0;for(var l=0,p=1,i=this._results.length,c;p<i;p++)if(-1!==e.indexOf(this._results[p].index)){for(var u in c=new n.customClass(this.game,this._results[p].worldX,this._results[p].worldY,a),n)c[u]=n[u];r.add(c),l++}if(1===t.length)for(p=0;p<e.length;p++)this.replace(e[p],t[0],0,0,s,d,o);else if(1<t.length)for(p=0;p<e.length;p++)this.replace(e[p],t[p],0,0,s,d,o);return l},createLayer:function(e,t,a,o){void 0===t&&(t=this.game.width),void 0===a&&(a=this.game.height),void 0===o&&(o=this.game.world);var r=e;if("string"==typeof e&&(r=this.getLayerIndex(e)),null===r||r>this.layers.length)return void console.warn("Tilemap.createLayer: Invalid layer ID given: \""+e+"\"");void 0===t||0>=t?t=p(this.game.width,this.layers[r].widthInPixels):t>this.game.width&&(t=this.game.width),void 0===a||0>=a?a=p(this.game.height,this.layers[r].heightInPixels):a>this.game.height&&(a=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[r].name),console.log("Size:",t,"x",a),console.log("Tileset:",this.tilesets[0].name,"index:",r));var n=o.add(new T.TilemapLayer(this.game,this,r,t,a));return this.enableDebug&&console.groupEnd(),n},createBlankLayer:function(e,t,a,o,r,n){if(void 0===n&&(n=this.game.world),null!==this.getLayerIndex(e))return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+e);for(var i={name:e,x:0,y:0,width:t,height:a,widthInPixels:t*o,heightInPixels:a*r,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},s=[],d=0,l;d<a;d++){l=[];for(var p=0;p<t;p++)l.push(new T.Tile(i,-1,p,d,o,r));s.push(l)}i.data=s,this.layers.push(i),this.currentLayer=this.layers.length-1;var c=i.widthInPixels,u=i.heightInPixels;c>this.game.width&&(c=this.game.width),u>this.game.height&&(u=this.game.height);var s=new T.TilemapLayer(this.game,this,this.layers.length-1,c,u);return s.name=e,n.add(s)},getIndex:function(e,t){for(var a=0;a<e.length;a++)if(e[a].name===t)return a;return null},getLayerIndex:function(e){return this.getIndex(this.layers,e)},getTilesetIndex:function(e){return this.getIndex(this.tilesets,e)},getImageIndex:function(e){return this.getIndex(this.images,e)},setTileIndexCallback:function(e,t,a,o){if(o=this.getLayer(o),"number"==typeof e)null===t?delete this.layers[o].callbacks[e]:this.layers[o].callbacks[e]={callback:t,callbackContext:a};else for(var r=0,n=e.length;r<n;r++)null===t?delete this.layers[o].callbacks[e[r]]:this.layers[o].callbacks[e[r]]={callback:t,callbackContext:a}},setTileLocationCallback:function(e,t,a,o,r,n,s){if(s=this.getLayer(s),this.copy(e,t,a,o,s),!(2>this._results.length))for(var d=1;d<this._results.length;d++)this._results[d].setCollisionCallback(r,n)},setCollision:function(e,t,a,o){if(void 0===t&&(t=!0),void 0===o&&(o=!0),a=this.getLayer(a),"number"==typeof e)return this.setCollisionByIndex(e,t,a,!0);if(Array.isArray(e)){for(var r=0;r<e.length;r++)this.setCollisionByIndex(e[r],t,a,!1);o&&this.calculateFaces(a)}},setCollisionBetween:function(e,t,a,o,r){if(void 0===a&&(a=!0),void 0===r&&(r=!0),o=this.getLayer(o),!(e>t)){for(var n=e;n<=t;n++)this.setCollisionByIndex(n,a,o,!1);r&&this.calculateFaces(o)}},setCollisionByExclusion:function(e,t,a,o){void 0===t&&(t=!0),void 0===o&&(o=!0),a=this.getLayer(a);for(var r=0,n=this.tiles.length;r<n;r++)-1===e.indexOf(r)&&this.setCollisionByIndex(r,t,a,!1);o&&this.calculateFaces(a)},setCollisionByIndex:function(e,t,a,o){if(void 0===t&&(t=!0),void 0===a&&(a=this.currentLayer),void 0===o&&(o=!0),t)this.collideIndexes.push(e);else{var r=this.collideIndexes.indexOf(e);-1<r&&this.collideIndexes.splice(r,1)}for(var n=0;n<this.layers[a].height;n++)for(var i=0,s;i<this.layers[a].width;i++)s=this.layers[a].data[n][i],s&&s.index===e&&(t?s.setCollision(!0,!0,!0,!0):s.resetCollision(),s.faceTop=t,s.faceBottom=t,s.faceLeft=t,s.faceRight=t);return o&&this.calculateFaces(a),a},getLayer:function(e){return void 0===e?e=this.currentLayer:"string"==typeof e?e=this.getLayerIndex(e):e instanceof T.TilemapLayer&&(e=e.index),e},setPreventRecalculate:function(e){if(!0===e&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===e&&!0===this.preventingRecalculate){for(var t in this.preventingRecalculate=!1,this.needToRecalculate)this.calculateFaces(t);this.needToRecalculate=!1}},calculateFaces:function(e){if(this.preventingRecalculate)return void(this.needToRecalculate[e]=!0);for(var t=null,a=null,o=null,r=null,n=0,i=this.layers[e].height;n<i;n++)for(var s=0,d=this.layers[e].width,l;s<d;s++)l=this.layers[e].data[n][s],l&&(t=this.getTileAbove(e,s,n),a=this.getTileBelow(e,s,n),o=this.getTileLeft(e,s,n),r=this.getTileRight(e,s,n),l.collides&&(l.faceTop=!0,l.faceBottom=!0,l.faceLeft=!0,l.faceRight=!0),t&&t.collides&&(l.faceTop=!1),a&&a.collides&&(l.faceBottom=!1),o&&o.collides&&(l.faceLeft=!1),r&&r.collides&&(l.faceRight=!1))},getTileAbove:function(e,t,a){return 0<a?this.layers[e].data[a-1][t]:null},getTileBelow:function(e,t,a){return a<this.layers[e].height-1?this.layers[e].data[a+1][t]:null},getTileLeft:function(e,t,a){return 0<t?this.layers[e].data[a][t-1]:null},getTileRight:function(e,t,a){return t<this.layers[e].width-1?this.layers[e].data[a][t+1]:null},setLayer:function(e){e=this.getLayer(e),this.layers[e]&&(this.currentLayer=e)},hasTile:function(e,t,a){return a=this.getLayer(a),void 0===this.layers[a].data[t]||void 0===this.layers[a].data[t][e]?!1:-1<this.layers[a].data[t][e].index},removeTile:function(e,t,a){if(a=this.getLayer(a),0<=e&&e<this.layers[a].width&&0<=t&&t<this.layers[a].height&&this.hasTile(e,t,a)){var o=this.layers[a].data[t][e];return this.layers[a].data[t][e]=new T.Tile(this.layers[a],-1,e,t,this.tileWidth,this.tileHeight),this.layers[a].dirty=!0,this.calculateFaces(a),o}},removeTileWorldXY:function(e,t,a,o,r){return r=this.getLayer(r),e=this.game.math.snapToFloor(e,a)/a,t=this.game.math.snapToFloor(t,o)/o,this.removeTile(e,t,r)},putTile:function(e,t,a,o){if(null===e)return this.removeTile(t,a,o);if(o=this.getLayer(o),0<=t&&t<this.layers[o].width&&0<=a&&a<this.layers[o].height){var r;return e instanceof T.Tile?(r=e.index,this.hasTile(t,a,o)?this.layers[o].data[a][t].copy(e):this.layers[o].data[a][t]=new T.Tile(o,r,t,a,e.width,e.height)):(r=e,this.hasTile(t,a,o)?this.layers[o].data[a][t].index=r:this.layers[o].data[a][t]=new T.Tile(this.layers[o],r,t,a,this.tileWidth,this.tileHeight)),-1<this.collideIndexes.indexOf(r)?this.layers[o].data[a][t].setCollision(!0,!0,!0,!0):this.layers[o].data[a][t].resetCollision(),this.layers[o].dirty=!0,this.calculateFaces(o),this.layers[o].data[a][t]}return null},putTileWorldXY:function(e,t,a,o,r,n){return n=this.getLayer(n),t=this.game.math.snapToFloor(t,o)/o,a=this.game.math.snapToFloor(a,r)/r,this.putTile(e,t,a,n)},searchTileIndex:function(e,t,a,o){void 0===t&&(t=0),void 0===a&&(a=!1),o=this.getLayer(o);var r=0;if(a){for(var n=this.layers[o].height-1;0<=n;n--)for(var i=this.layers[o].width-1;0<=i;i--)if(this.layers[o].data[n][i].index===e){if(r===t)return this.layers[o].data[n][i];r++}}else for(var n=0;n<this.layers[o].height;n++)for(var i=0;i<this.layers[o].width;i++)if(this.layers[o].data[n][i].index===e){if(r===t)return this.layers[o].data[n][i];r++}return null},getTile:function(e,t,a,o){return void 0===o&&(o=!1),a=this.getLayer(a),0<=e&&e<this.layers[a].width&&0<=t&&t<this.layers[a].height?-1===this.layers[a].data[t][e].index?o?this.layers[a].data[t][e]:null:this.layers[a].data[t][e]:null},getTileWorldXY:function(e,t,a,o,r,n){return void 0===a&&(a=this.tileWidth),void 0===o&&(o=this.tileHeight),r=this.getLayer(r),e=this.game.math.snapToFloor(e,a)/a,t=this.game.math.snapToFloor(t,o)/o,this.getTile(e,t,r,n)},copy:function(e,t,a,o,r){if(r=this.getLayer(r),!this.layers[r])return void(this._results.length=0);void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=this.layers[r].width),void 0===o&&(o=this.layers[r].height),0>e&&(e=0),0>t&&(t=0),a>this.layers[r].width&&(a=this.layers[r].width),o>this.layers[r].height&&(o=this.layers[r].height),this._results.length=0,this._results.push({x:e,y:t,width:a,height:o,layer:r});for(var n=t;n<t+o;n++)for(var i=e;i<e+a;i++)this._results.push(this.layers[r].data[n][i]);return this._results},paste:function(e,t,a,o){if(void 0===e&&(e=0),void 0===t&&(t=0),o=this.getLayer(o),a&&!(2>a.length)){for(var r=e-a[1].x,n=t-a[1].y,s=1;s<a.length;s++)this.layers[o].data[n+a[s].y][r+a[s].x].copy(a[s]);this.layers[o].dirty=!0,this.calculateFaces(o)}},swap:function(e,t,a,o,r,n,i){i=this.getLayer(i),this.copy(a,o,r,n,i),2>this._results.length||(this._tempA=e,this._tempB=t,this._results.forEach(this.swapHandler,this),this.paste(a,o,this._results,i))},swapHandler:function(e){e.index===this._tempA?e.index=this._tempB:e.index===this._tempB&&(e.index=this._tempA)},forEach:function(e,t,a,o,r,n,i){i=this.getLayer(i),this.copy(a,o,r,n,i),2>this._results.length||(this._results.forEach(e,t),this.paste(a,o,this._results,i))},replace:function(e,t,a,o,r,n,s){if(s=this.getLayer(s),this.copy(a,o,r,n,s),!(2>this._results.length)){for(var d=1;d<this._results.length;d++)this._results[d].index===e&&(this._results[d].index=t);this.paste(a,o,this._results,s)}},random:function(e,a,o,r,n){if(n=this.getLayer(n),this.copy(e,a,o,r,n),!(2>this._results.length)){for(var s=[],d=1;d<this._results.length;d++)if(this._results[d].index){var t=this._results[d].index;-1===s.indexOf(t)&&s.push(t)}for(var l=1;l<this._results.length;l++)this._results[l].index=this.game.rnd.pick(s);this.paste(e,a,this._results,n)}},shuffle:function(e,a,o,r,n){if(n=this.getLayer(n),this.copy(e,a,o,r,n),!(2>this._results.length)){for(var s=[],d=1;d<this._results.length;d++)this._results[d].index&&s.push(this._results[d].index);T.ArrayUtils.shuffle(s);for(var t=1;t<this._results.length;t++)this._results[t].index=s[t-1];this.paste(e,a,this._results,n)}},fill:function(e,t,a,o,r,n){if(n=this.getLayer(n),this.copy(t,a,o,r,n),!(2>this._results.length)){for(var s=1;s<this._results.length;s++)this._results[s].index=e;this.paste(t,a,this._results,n)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var e="",t=[""],a=0;a<this.layers[this.currentLayer].height;a++){for(var o=0;o<this.layers[this.currentLayer].width;o++)e+="%c  ",1<this.layers[this.currentLayer].data[a][o]?this.debugMap[this.layers[this.currentLayer].data[a][o]]?t.push("background: "+this.debugMap[this.layers[this.currentLayer].data[a][o]]):t.push("background: #ffffff"):t.push("background: rgb(0, 0, 0)");e+="\n"}t[0]=e,console.log.apply(console,t)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},T.Tilemap.prototype.constructor=T.Tilemap,Object.defineProperty(T.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(e){e!==this.currentLayer&&this.setLayer(e)}}),T.TilemapLayer=function(e,t,a,o,r){o|=0,r|=0,T.Sprite.call(this,e,0,0),this.map=t,this.index=a,this.layer=t.layers[a],this.canvas=T.CanvasPool.create(this,o,r),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution))),this.type=T.TILEMAPLAYER,this.physicsType=T.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!0,overdrawRatio:0.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:0.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:t.tileWidth,tileHeight:t.tileHeight,cw:t.tileWidth,ch:t.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this.tileOffset=new T.Point(this.layer.offsetX||0,this.layer.offsetY||0),this._results=[],e.device.canvasBitBltShift||(this.renderSettings.copyCanvas=T.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},T.TilemapLayer.prototype=Object.create(T.Sprite.prototype),T.TilemapLayer.prototype.constructor=T.TilemapLayer,T.TilemapLayer.prototype.preUpdateCore=T.Component.Core.preUpdate,T.TilemapLayer.sharedCopyCanvas=null,T.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=T.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},T.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},T.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y},T.TilemapLayer.prototype._renderCanvas=function(e){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderCanvas.call(this,e)},T.TilemapLayer.prototype._renderWebGL=function(e){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderWebGL.call(this,e)},T.TilemapLayer.prototype.destroy=function(){T.CanvasPool.remove(this),T.Component.Destroy.prototype.destroy.call(this)},T.TilemapLayer.prototype.resize=function(e,t){this.canvas.width=e,this.canvas.height=t,this.texture.frame.resize(e,t),this.texture.width=e,this.texture.height=t,this.texture.crop.width=e,this.texture.crop.height=t,this.texture.baseTexture.width=e,this.texture.baseTexture.height=t,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},T.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},T.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},T.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},T.TilemapLayer.prototype._fixX=function(e){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?e:0===this.scrollFactorX&&0!==this.position.x?e-this.position.x:this._scrollX+(e-this._scrollX/this.scrollFactorX)},T.TilemapLayer.prototype._unfixX=function(e){return 1===this.scrollFactorX?e:this._scrollX/this.scrollFactorX+(e-this._scrollX)},T.TilemapLayer.prototype._fixY=function(e){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?e:0===this.scrollFactorY&&0!==this.position.y?e-this.position.y:this._scrollY+(e-this._scrollY/this.scrollFactorY)},T.TilemapLayer.prototype._unfixY=function(e){return 1===this.scrollFactorY?e:this._scrollY/this.scrollFactorY+(e-this._scrollY)},T.TilemapLayer.prototype.getTileX=function(e){return c(this._fixX(e)/this._mc.tileWidth)},T.TilemapLayer.prototype.getTileY=function(e){return c(this._fixY(e)/this._mc.tileHeight)},T.TilemapLayer.prototype.getTileXY=function(e,t,a){return a.x=this.getTileX(e),a.y=this.getTileY(t),a},T.TilemapLayer.prototype.getRayCastTiles=function(e,a,o,r){a||(a=this.rayStepRate),void 0===o&&(o=!1),void 0===r&&(r=!1);var n=this.getTiles(e.x,e.y,e.width,e.height,o,r);if(0===n.length)return[];for(var s=e.coordinatesOnLine(a),d=[],l=0;l<n.length;l++)for(var i=0;i<s.length;i++){var t=n[l],p=s[i];if(t.containsPoint(p[0],p[1])){d.push(t);break}}return d},T.TilemapLayer.prototype.getTiles=function(e,t,a,o,r,n){void 0===r&&(r=!1),void 0===n&&(n=!1);var i=!(r||n);e=this._fixX(e),t=this._fixY(t);for(var s=c(e/(this._mc.cw*this.scale.x)),d=c(t/(this._mc.ch*this.scale.y)),p=l((e+a)/(this._mc.cw*this.scale.x))-s,u=l((t+o)/(this._mc.ch*this.scale.y))-d;this._results.length;)this._results.pop();for(var h=d;h<d+u;h++)for(var g=s,m;g<s+p;g++)m=this.layer.data[h],m&&m[g]&&(i||m[g].isInteresting(r,n))&&this._results.push(m[g]);return this._results.slice()},T.TilemapLayer.prototype.resolveTileset=function(e){var t=this._mc.tilesets;if(2e3>e)for(;t.length<e;)t.push(void 0);var a=this.map.tiles[e]&&this.map.tiles[e][2];if(null!==a){var o=this.map.tilesets[a];if(o&&o.containsTileIndex(e))return t[e]=o}return t[e]=null},T.TilemapLayer.prototype.resetTilesetCache=function(){for(var e=this._mc.tilesets;e.length;)e.pop()},T.TilemapLayer.prototype.setScale=function(e,t){e=e||1,t=t||e;for(var a=0,o;a<this.layer.data.length;a++){o=this.layer.data[a];for(var r=0,n;r<o.length;r++)n=o[r],n.width=this.map.tileWidth*e,n.height=this.map.tileHeight*t,n.worldX=n.x*n.width,n.worldY=n.y*n.height}this.scale.setTo(e,t)},T.TilemapLayer.prototype.shiftCanvas=function(e,t,a){var o=e.canvas,r=o.width-f(t),n=o.height-f(a),i=0,s=0,d=t,l=a;0>t&&(i=-t,d=0),0>a&&(s=-a,l=0);var p=this.renderSettings.copyCanvas;if(p){(p.width<r||p.height<n)&&(p.width=r,p.height=n);var c=p.getContext("2d");c.clearRect(0,0,r,n),c.drawImage(o,i,s,r,n,0,0,r,n),e.clearRect(d,l,r,n),e.drawImage(p,0,0,r,n,d,l,r,n)}else e.save(),e.globalCompositeOperation="copy",e.drawImage(o,i,s,r,n,d,l,r,n),e.restore()},T.TilemapLayer.prototype.renderRegion=function(e,t,a,o,r,n){var i=this.context,d=this.layer.width,l=this.layer.height,c=this._mc.tileWidth,u=this._mc.tileHeight,h=this._mc.tilesets,g=NaN;this._wrap||(a<=r&&(a=s(0,a),r=p(d-1,r)),o<=n&&(o=s(0,o),n=p(l-1,n)));var m=a*c-e,f=o*u-t,b=(a+1048576*d)%d,_=(o+1048576*l)%l,v,T,C,x,y,P;for(x=_,P=n-o,T=f;0<=P;x++,P--,T+=u){x>=l&&(x-=l);var S=this.layer.data[x];for(C=b,y=r-a,v=m;0<=y;C++,y--,v+=c){C>=d&&(C-=d);var w=S[C];if(w&&!(0>w.index)){var A=w.index,E=h[A];void 0===E&&(E=this.resolveTileset(A)),w.alpha===g||this.debug||(i.globalAlpha=w.alpha,g=w.alpha),E?w.rotation||w.flipped?(i.save(),i.translate(v+w.centerX,T+w.centerY),i.rotate(w.rotation),w.flipped&&i.scale(-1,1),E.draw(i,-w.centerX,-w.centerY,A),i.restore()):E.draw(i,v,T,A):this.debugSettings.missingImageFill&&(i.fillStyle=this.debugSettings.missingImageFill,i.fillRect(v,T,c,u)),w.debug&&this.debugSettings.debuggedTileOverfill&&(i.fillStyle=this.debugSettings.debuggedTileOverfill,i.fillRect(v,T,c,u))}}}},T.TilemapLayer.prototype.renderDeltaScroll=function(e,t){var a=this._mc.scrollX,o=this._mc.scrollY,r=this.canvas.width,n=this.canvas.height,i=this._mc.tileWidth,s=this._mc.tileHeight,d=0,l=-i,p=0,u=-s;if(0>e?(d=r+e,l=r-1):0<e&&(l=e),0>t?(p=n+t,u=n-1):0<t&&(u=t),this.shiftCanvas(this.context,e,t),d=c((d+a)/i),l=c((l+a)/i),p=c((p+o)/s),u=c((u+o)/s),d<=l){this.context.clearRect(d*i-a,0,(l-d+1)*i,n);var h=c((0+o)/s),g=c((n-1+o)/s);this.renderRegion(a,o,d,h,l,g)}if(p<=u){this.context.clearRect(0,p*s-o,r,(u-p+1)*s);var m=c((0+a)/i),y=c((r-1+a)/i);this.renderRegion(a,o,m,p,y,u)}},T.TilemapLayer.prototype.renderFull=function(){var e=this._mc.scrollX,t=this._mc.scrollY,a=this.canvas.width,o=this.canvas.height,r=this._mc.tileWidth,n=this._mc.tileHeight,i=c(e/r),s=c((a-1+e)/r),d=c(t/n),l=c((o-1+t)/n);this.context.clearRect(0,0,a,o),this.renderRegion(e,t,i,d,s,l)},T.TilemapLayer.prototype.render=function(){var e=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,e=!0);var t=this.canvas.width,a=this.canvas.height,o=0|this._scrollX,r=0|this._scrollY,n=this._mc,i=n.scrollX-o,s=n.scrollY-r;if(e||0!=i||0!=s||n.renderWidth!==t||n.renderHeight!==a)return this.context.save(),n.scrollX=o,n.scrollY=r,(n.renderWidth!==t||n.renderHeight!==a)&&(n.renderWidth=t,n.renderHeight=a),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(e=!0)),!e&&this.renderSettings.enableScrollDelta&&f(i)+f(s)<p(t,a)?this.renderDeltaScroll(i,s):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},T.TilemapLayer.prototype.renderDebug=function(){var e=this._mc.scrollX,t=this._mc.scrollY,a=this.context,o=this.canvas.width,r=this.canvas.height,n=this.layer.width,i=this.layer.height,s=this._mc.tileWidth,d=this._mc.tileHeight,l=c(e/s),p=c((o-1+e)/s),u=c(t/d),h=c((r-1+t)/d),g,m,f,x,y,b;for(a.strokeStyle=this.debugSettings.facingEdgeStroke,x=(u+1048576*i)%i,b=h-u,m=u*d-t;0<=b;x++,b--,m+=d){x>=i&&(x-=i);var _=this.layer.data[x];for(f=(l+1048576*n)%n,y=p-l,g=l*s-e;0<=y;f++,y--,g+=s){f>=n&&(f-=n);var v=_[f];v&&!(0>v.index)&&v.collides&&(this.debugSettings.collidingTileOverfill&&(a.fillStyle=this.debugSettings.collidingTileOverfill,a.fillRect(g,m,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(a.beginPath(),v.faceTop&&(a.moveTo(g,m),a.lineTo(g+this._mc.cw,m)),v.faceBottom&&(a.moveTo(g,m+this._mc.ch),a.lineTo(g+this._mc.cw,m+this._mc.ch)),v.faceLeft&&(a.moveTo(g,m),a.lineTo(g,m+this._mc.ch)),v.faceRight&&(a.moveTo(g+this._mc.cw,m),a.lineTo(g+this._mc.cw,m+this._mc.ch)),a.closePath(),a.stroke()))}}},Object.defineProperty(T.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(e){this._wrap=e,this.dirty=!0}}),Object.defineProperty(T.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(e){this._scrollX=e}}),Object.defineProperty(T.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(e){this._scrollY=e}}),Object.defineProperty(T.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(e){this._mc.cw=0|e,this.dirty=!0}}),Object.defineProperty(T.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(e){this._mc.ch=0|e,this.dirty=!0}}),T.TilemapParser={INSERT_NULL:!1,parse:function(e,t,a,o,r,n){if(void 0===a&&(a=32),void 0===o&&(o=32),void 0===r&&(r=10),void 0===n&&(n=10),void 0===t)return this.getEmptyData();if(null===t)return this.getEmptyData(a,o,r,n);var i=e.cache.getTilemapData(t);if(i){if(i.format===T.Tilemap.CSV)return this.parseCSV(t,i.data,a,o);if(!i.format||i.format===T.Tilemap.TILED_JSON)return this.parseTiledJSON(i.data)}else console.warn("Phaser.TilemapParser.parse - No map data found for key "+t)},parseCSV:function(e,t,a,o){var r=this.getEmptyData();t=t.trim();for(var n=[],i=t.split("\n"),s=i.length,d=0,l=0;l<i.length;l++){n[l]=[];for(var p=i[l].split(","),c=0;c<p.length;c++)n[l][c]=new T.Tile(r.layers[0],parseInt(p[c],10),c,l,a,o);0==d&&(d=p.length)}return r.format=T.Tilemap.CSV,r.name=e,r.width=d,r.height=s,r.tileWidth=a,r.tileHeight=o,r.widthInPixels=d*a,r.heightInPixels=s*o,r.layers[0].width=d,r.layers[0].height=s,r.layers[0].widthInPixels=r.widthInPixels,r.layers[0].heightInPixels=r.heightInPixels,r.layers[0].data=n,r},getEmptyData:function(e,t,a,o){return{width:void 0!==a&&null!==a?a:0,height:void 0!==o&&null!==o?o:0,tileWidth:void 0!==e&&null!==e?e:0,tileHeight:void 0!==t&&null!==t?t:0,orientation:"orthogonal",version:"1",properties:{},widthInPixels:0,heightInPixels:0,layers:[{name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]}],images:[],objects:{},collision:{},tilesets:[],tiles:[]}},parseObjectGroup:function(e,t,a,o,r){function n(e,t){var a={};for(var o in t){var r=t[o];"undefined"!=typeof e[r]&&(a[r]=e[r])}return a}var o=o||e.name,r=r||{x:0,y:0};o||console.warn("No name found for objectGroup",e),(void 0===r.x||void 0===r.y)&&console.warn("Malformed xy properties in relativePosition",r),t[o]=t[o]||[],a[o]=a[o]||[];for(var i=0,s=e.objects.length;i<s;i++)if(e.objects[i].gid){var d={gid:e.objects[i].gid,name:e.objects[i].name,type:e.objects[i].hasOwnProperty("type")?e.objects[i].type:"",x:e.objects[i].x+r.x,y:e.objects[i].y+r.y,width:e.objects[i].width,height:e.objects[i].height,visible:e.objects[i].visible,properties:e.objects[i].properties};e.objects[i].rotation&&(d.rotation=e.objects[i].rotation),t[o].push(d)}else if(e.objects[i].polyline){var d={name:e.objects[i].name,type:e.objects[i].type,x:e.objects[i].x+r.x,y:e.objects[i].y+r.y,width:e.objects[i].width,height:e.objects[i].height,visible:e.objects[i].visible,properties:e.objects[i].properties};e.objects[i].rotation&&(d.rotation=e.objects[i].rotation),d.polyline=[];for(var l=0;l<e.objects[i].polyline.length;l++)d.polyline.push([e.objects[i].polyline[l].x,e.objects[i].polyline[l].y]);a[o].push(d),t[o].push(d)}else if(e.objects[i].polygon){var d=n(e.objects[i],["name","type","x","y","visible","rotation","properties"]);d.x+=r.x,d.y+=r.y,d.polygon=[];for(var l=0;l<e.objects[i].polygon.length;l++)d.polygon.push([e.objects[i].polygon[l].x,e.objects[i].polygon[l].y]);a[o].push(d),t[o].push(d)}else if(e.objects[i].ellipse){var d=n(e.objects[i],["name","type","ellipse","x","y","width","height","visible","rotation","properties"]);d.x+=r.x,d.y+=r.y,a[o].push(d),t[o].push(d)}else{var d=n(e.objects[i],["name","type","x","y","width","height","visible","rotation","properties"]);d.x+=r.x,d.y+=r.y,d.rectangle=!0,a[o].push(d),t[o].push(d)}return{objectsCollection:t,collisionCollection:a}},parseTiledJSON:function(e){if("orthogonal"!==e.orientation)return console.warn("TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser"),null;for(var a={width:e.width,height:e.height,tileWidth:e.tilewidth,tileHeight:e.tileheight,orientation:e.orientation,format:T.Tilemap.TILED_JSON,version:e.version,properties:e.properties,widthInPixels:e.width*e.tilewidth,heightInPixels:e.height*e.tileheight},o=[],r=0;r<e.layers.length;r++)if("tilelayer"===e.layers[r].type){var n=e.layers[r];if(!n.compression&&n.encoding&&"base64"===n.encoding){for(var i=window.atob(n.data),s=i.length,l=Array(s),p=0;p<s;p+=4)l[p/4]=(i.charCodeAt(p)|i.charCodeAt(p+1)<<8|i.charCodeAt(p+2)<<16|i.charCodeAt(p+3)<<24)>>>0;n.data=l,delete n.encoding}else if(n.compression){console.warn("TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer '"+n.name+"'");continue}var c={name:n.name,x:n.x,y:n.y,width:n.width,height:n.height,widthInPixels:n.width*e.tilewidth,heightInPixels:n.height*e.tileheight,alpha:n.opacity,offsetX:n.offsetx,offsetY:n.offsety,visible:n.visible,properties:{},indexes:[],callbacks:[],bodies:[]};n.properties&&(c.properties=n.properties);for(var u=0,h=[],g=[],m=0,s=n.data.length,t,f,x,b;m<s;m++){if(t=0,f=!1,b=n.data[m],x=0,(536870912<b&&(2147483648<b&&(b-=2147483648,x+=4),1073741824<b&&(b-=1073741824,x+=2),536870912<b&&(b-=536870912,x+=1),5===x?t=d/2:6===x?t=d:3===x?t=3*d/2:4===x?(t=0,f=!0):7===x?(t=d/2,f=!0):2===x?(t=d,f=!0):1===x?(t=3*d/2,f=!0):void 0),0<b)){var _=new T.Tile(c,b,u,g.length,e.tilewidth,e.tileheight);_.rotation=t,_.flipped=f,0!==x&&(_.flippedVal=x),h.push(_)}else T.TilemapParser.INSERT_NULL?h.push(null):h.push(new T.Tile(c,-1,u,g.length,e.tilewidth,e.tileheight));u++,u===n.width&&(g.push(h),u=0,h=[])}c.data=g,o.push(c)}a.layers=o;for(var v=[],r=0;r<e.layers.length;r++)if("imagelayer"===e.layers[r].type){var C=e.layers[r],P={name:C.name,image:C.image,x:C.x,y:C.y,alpha:C.opacity,visible:C.visible,properties:{}};C.properties&&(P.properties=C.properties),v.push(P)}a.images=v;for(var S=[],w={},A=[],E=null,r=0,R;r<e.tilesets.length;r++){if(R=e.tilesets[r],R.source)console.warn("Phaser.TilemapParser - Phaser can't load external tilesets (%s). Use the Embed Tileset button and then export the map again.",R.source);else if(R.image){var L=new T.Tileset(R.name,R.firstgid,R.tilewidth,R.tileheight,R.margin,R.spacing,R.properties);R.tileproperties&&(L.tileProperties=R.tileproperties),L.updateTileData(R.imagewidth,R.imageheight),S.push(L)}else if(R.tiles){var B=new T.ImageCollection(R.name,R.firstgid,R.tilewidth,R.tileheight,R.margin,R.spacing,R.properties);for(var F in R.tiles){var P=R.tiles[F].image,b=R.firstgid+parseInt(F,10);B.addImage(b,P)}A.push(B)}else throw new Error("Tileset "+R.name+" has no `image` or `tiles` property.");for(var F in R.tiles){var D=R.tiles[F].objectgroup;D&&(w[parseInt(F)+R.firstgid]=D)}E&&(E.lastgid=R.firstgid-1),E=R}if(0===S.length&&0===A.length)throw new Error("This tilemap has no tilesets.");a.tilesets=S,a.imagecollections=A;for(var M={},O={},r=0;r<e.layers.length;r++)if("objectgroup"===e.layers[r].type){var D=e.layers[r];this.parseObjectGroup(D,M,O)}a.objects=M,a.collision=O,a.tiles=[];for(var r=0;r<a.tilesets.length;r++)for(var R=a.tilesets[r],u=R.tileMargin,I=R.tileMargin,y=0,U=0,G=0,m=R.firstgid;m<R.firstgid+R.total&&(a.tiles[m]=[u,I,r],u+=R.tileWidth+R.tileSpacing,y++,y!==R.total)&&(U++,!(U===R.columns&&(u=R.tileMargin,I+=R.tileHeight+R.tileSpacing,U=0,G++,G===R.rows)));m++);for(var r=0,c,_,N,R;r<a.layers.length;r++){c=a.layers[r],O[c.name]=[],R=null;for(var p=0;p<c.data.length;p++){h=c.data[p];for(var W=0;W<h.length;W++)if(_=h[W],!(null===_||0>_.index)){N=a.tiles[_.index][2],R=a.tilesets[N],R.tileProperties&&R.tileProperties[_.index-R.firstgid]&&(_.properties=T.Utils.mixin(R.tileProperties[_.index-R.firstgid],_.properties));var D=w[_.index];D&&this.parseObjectGroup(D,a.objects,a.collision,_.layer.name,{x:_.worldX+D.x,y:_.worldY+D.y})}}}return a}},T.Tileset=function(e,t,a,o,r,n,i){(void 0===a||0>=a)&&(a=32),(void 0===o||0>=o)&&(o=32),void 0===r&&(r=0),void 0===n&&(n=0),this.name=e,this.firstgid=0|t,this.tileWidth=0|a,this.tileHeight=0|o,this.tileMargin=0|r,this.tileSpacing=0|n,this.properties=i||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},T.Tileset.prototype={draw:function(e,t,a,o){var r=o-this.firstgid<<1;0<=r&&r+1<this.drawCoords.length&&e.drawImage(this.image,this.drawCoords[r],this.drawCoords[r+1],this.tileWidth,this.tileHeight,t,a,this.tileWidth,this.tileHeight)},containsTileIndex:function(e){return e>=this.firstgid&&e<this.firstgid+this.total},setImage:function(e){this.image=e,this.updateTileData(e.width,e.height)},setSpacing:function(e,t){this.tileMargin=0|e,this.tileSpacing=0|t,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(e,t){var a=(t-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),o=(e-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);(0!=a%1||0!=o%1)&&console.warn("Phaser.Tileset - "+this.name+" image tile area is not an even multiple of tile size"),a=c(a),o=c(o),(this.rows&&this.rows!==a||this.columns&&this.columns!==o)&&console.warn("Phaser.Tileset - actual and expected number of tile rows and columns differ"),this.rows=a,this.columns=o,this.total=a*o,this.drawCoords.length=0;for(var r=this.tileMargin,n=this.tileMargin,i=0;i<this.rows;i++){for(var s=0;s<this.columns;s++)this.drawCoords.push(r),this.drawCoords.push(n),r+=this.tileWidth+this.tileSpacing;r=this.tileMargin,n+=this.tileHeight+this.tileSpacing}}},T.Tileset.prototype.constructor=T.Tileset,T.Particle=function(e,t,a,o,r){T.Sprite.call(this,e,t,a,o,r),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},T.Particle.prototype=Object.create(T.Sprite.prototype),T.Particle.prototype.constructor=T.Particle,T.Particle.prototype.update=function(){this.autoScale&&(this._s--,this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1),this.autoAlpha&&(this._a--,this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},T.Particle.prototype.onEmit=function(){},T.Particle.prototype.setAlphaData=function(e){this.alphaData=e,this._a=e.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},T.Particle.prototype.setScaleData=function(e){this.scaleData=e,this._s=e.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},T.Particle.prototype.reset=function(e,t,a){return T.Component.Reset.prototype.reset.call(this,e,t,a),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},T.Particles=function(e){this.game=e,this.emitters={},this.ID=0},T.Particles.prototype={add:function(e){return this.emitters[e.id]=e,e},remove:function(e){delete this.emitters[e.id]},update:function(){for(var e in this.emitters)this.emitters[e].exists&&this.emitters[e].update()}},T.Particles.prototype.constructor=T.Particles,T.Particles.Arcade={},T.Particles.Arcade.Emitter=function(e,t,a,o){this.maxParticles=o||50,T.Group.call(this,e),this._id=this.game.particles.ID++,this.name="emitter"+this.id,this.type=T.EMITTER,this.physicsType=T.GROUP,this.area=new T.Rectangle(t,a,1,1),this.minAngle=null,this.maxAngle=null,this.minSpeed=0,this.maxSpeed=100,this.minParticleSpeed=new T.Point(-100,-100),this.maxParticleSpeed=new T.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.scaleData=null,this.minRotation=-360,this.maxRotation=360,this.minParticleAlpha=1,this.maxParticleAlpha=1,this.alphaData=null,this.particleClass=T.Particle,this.particleDrag=new T.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new T.Point,this.on=!1,this.particleAnchor=new T.Point(0.5,0.5),this.blendMode=T.blendModes.NORMAL,this.emitX=t,this.emitY=a,this.autoScale=!1,this.autoAlpha=!1,this.particleBringToTop=!1,this.particleSendToBack=!1,this.counts={emitted:0,failed:0,totalEmitted:0,totalFailed:0},this._gravity=new T.Point(0,100),this._minParticleScale=new T.Point(1,1),this._maxParticleScale=new T.Point(1,1),this._total=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},T.Particles.Arcade.Emitter.prototype=Object.create(T.Group.prototype),T.Particles.Arcade.Emitter.prototype.constructor=T.Particles.Arcade.Emitter,T.Particles.Arcade.Emitter.prototype.update=function(){if(this.counts.emitted=0,this.counts.failed=0,this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0===this._flowTotal)this.emitParticle()&&(this._counter++,0<this._total&&this._counter>=this._total&&(this.on=!1));else if(0<this._flowQuantity){for(var e=0;e<this._flowQuantity;e++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));for(var e=this.children.length;e--;)this.children[e].exists&&this.children[e].update()},T.Particles.Arcade.Emitter.prototype.makeParticles=function(e,t,a,o,r,n){void 0===t&&(t=0),void 0===a&&(a=this.maxParticles),void 0===o&&(o=!1),void 0===r&&(r=!1),void 0===n&&(n=null);var s=0,i=e,d=t,l;for(this._frames=t,a>this.maxParticles&&(this.maxParticles=a);s<a;)Array.isArray(e)&&(i=this.game.rnd.pick(e)),Array.isArray(t)&&(d=this.game.rnd.pick(t)),l=new this.particleClass(this.game,0,0,i,d,n),this.game.physics.arcade.enable(l,!1),l.body.checkCollision.none=!o,l.body.collideWorldBounds=r,l.body.skipQuadTree=!0,l.exists=!1,l.visible=!1,l.anchor.copyFrom(this.particleAnchor),this.add(l),s++;return this},T.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},T.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},T.Particles.Arcade.Emitter.prototype.explode=function(e,t){return void 0===t&&(t=this.maxParticles),this._flowTotal=0,this.start(!0,e,0,t,!1),this},T.Particles.Arcade.Emitter.prototype.flow=function(e,t,a,o,r){return(void 0===t||null===t)&&(t=250),(void 0===a||0===a)&&(a=1),void 0===o&&(o=-1),void 0===r&&(r=!0),a>this.maxParticles&&(a=this.maxParticles),this._counter=0,this._flowQuantity=a,this._flowTotal=o,r?(this.start(!0,e,t,a),this._counter+=a,this.on=!0,this._timer=this.game.time.time+t*this.game.time.slowMotion):this.start(!1,e,t,a),this},T.Particles.Arcade.Emitter.prototype.start=function(e,t,a,o,r){if(void 0===e&&(e=!0),void 0===t&&(t=0),(void 0===a||null===a)&&(a=250),void 0===o&&(o=0),void 0===r&&(r=!1),o>this.maxParticles&&(o=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=t,this.frequency=a,e||r)for(var n=0;n<o;n++)this.emitParticle();else this.on=!0,this._total=o,this._counter=0,this._timer=this.game.time.time+a*this.game.time.slowMotion;return this},T.Particles.Arcade.Emitter.prototype.emitParticle=function(e,t,a,o){void 0===e&&(e=null),void 0===t&&(t=null);var r=this.getNextParticle();if(null===r)return this.counts.failed++,this.counts.totalFailed++,!1;this.counts.emitted++,this.counts.totalEmitted++;var n=this.game.rnd;void 0!==a&&void 0!==o?r.loadTexture(a,o):void 0!==a&&(r.loadTexture(a),r.frame=Array.isArray(this._frames)?n.pick(this._frames):this._frames);var i=this.emitX,s=this.emitY;return null===e?1<this.width&&(i=n.between(this.left,this.right)):i=e,null===t?1<this.height&&(s=n.between(this.top,this.bottom)):s=t,this.resetParticle(r,i,s),!0},T.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var e=this.length,t;e--;)if(t=this.next(),!t.exists)return t;return null},T.Particles.Arcade.Emitter.prototype.resetParticle=function(e,t,a){var o=this.game.rnd;e.reset(t,a),e.angle=0,e.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(e):this.particleSendToBack&&this.sendToBack(e),this.autoScale?e.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?e.scale.set(o.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?e.scale.set(o.realInRange(this._minParticleScale.x,this._maxParticleScale.x),o.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):e.scale.set(this._minParticleScale.x,this._minParticleScale.y),this.autoAlpha?e.setAlphaData(this.alphaData):e.alpha=o.realInRange(this.minParticleAlpha,this.maxParticleAlpha),e.blendMode=this.blendMode;var r=e.body;r.updateBounds(),r.bounce.copyFrom(this.bounce),r.drag.copyFrom(this.particleDrag),null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:o.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:o.between(this.minSpeed,this.maxSpeed),r.velocity):(r.velocity.x=o.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),r.velocity.y=o.between(this.minParticleSpeed.y,this.maxParticleSpeed.y)),r.angularVelocity=o.between(this.minRotation,this.maxRotation),r.gravity.copyFrom(this.gravity),r.angularDrag=this.angularDrag,e.onEmit()},T.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),T.Group.prototype.destroy.call(this,!0,!1)},T.Particles.Arcade.Emitter.prototype.setSize=function(e,t){return this.area.width=e,this.area.height=t,this},T.Particles.Arcade.Emitter.prototype.setXSpeed=function(e,t){return e=e||0,t=t||0,this.minParticleSpeed.x=e,this.maxParticleSpeed.x=t,this},T.Particles.Arcade.Emitter.prototype.setYSpeed=function(e,t){return e=e||0,t=t||0,this.minParticleSpeed.y=e,this.maxParticleSpeed.y=t,this},T.Particles.Arcade.Emitter.prototype.setRotation=function(e,t){return e=e||0,t=t||0,this.minRotation=e,this.maxRotation=t,this},T.Particles.Arcade.Emitter.prototype.setAlpha=function(e,t,a,o,r){if(void 0===e&&(e=1),void 0===t&&(t=1),void 0===a&&(a=0),void 0===o&&(o=T.Easing.Linear.None),void 0===r&&(r=!1),this.minParticleAlpha=e,this.maxParticleAlpha=t,this.autoAlpha=!1,0<a&&e!==t){var n={v:e},i=this.game.make.tween(n).to({v:t},a,o);i.yoyo(r),this.alphaData=i.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},T.Particles.Arcade.Emitter.prototype.setScale=function(e,t,a,o,r,n,i){if(void 0===e&&(e=1),void 0===t&&(t=1),void 0===a&&(a=1),void 0===o&&(o=1),void 0===r&&(r=0),void 0===n&&(n=T.Easing.Linear.None),void 0===i&&(i=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(e,a),this._maxParticleScale.set(t,o),this.autoScale=!1,0<r&&(e!==t||a!==o)){var s={x:e,y:a},d=this.game.make.tween(s).to({x:t,y:o},r,n);d.yoyo(i),this.scaleData=d.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},T.Particles.Arcade.Emitter.prototype.setAngle=function(e,t,a,o){return this.minAngle=e,this.maxAngle=t,null!=a&&(this.minSpeed=a),null!=o&&(this.maxSpeed=o),this},T.Particles.Arcade.Emitter.prototype.at=function(e){return e.center?(this.emitX=e.center.x,this.emitY=e.center.y):(this.emitX=e.world.x+e.anchor.x*e.width,this.emitY=e.world.y+e.anchor.y*e.height),this},Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(e){"number"==typeof e?this._gravity.y=e:this._gravity=e}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(e){this.area.width=e}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(e){this.area.height=e}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(e){this.emitX=e}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(e){this.emitY=e}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"left",{get:function(){return c(this.x-this.area.width/2)}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"right",{get:function(){return c(this.x+this.area.width/2)}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"top",{get:function(){return c(this.y-this.area.height/2)}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return c(this.y+this.area.height/2)}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?Infinity:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(T.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),T.Weapon=function(e,t){T.Plugin.call(this,e,t),this.bullets=null,this.autoExpandBulletsGroup=!1,this.autofire=!1,this.shots=0,this.fireLimit=0,this.fireRate=100,this.fireRateVariance=0,this.fireFrom=new T.Rectangle(0,0,1,1),this.fireAngle=T.ANGLE_UP,this.bulletInheritSpriteSpeed=!1,this.bulletAnimation="",this.bulletFrameRandom=!1,this.bulletFrameCycle=!1,this.bulletWorldWrap=!1,this.bulletWorldWrapPadding=0,this.bulletAngleOffset=0,this.bulletAngleVariance=0,this.bulletSpeed=200,this.bulletSpeedVariance=0,this.bulletLifespan=0,this.bulletKillDistance=0,this.bulletGravity=new T.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=T.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=T.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new T.Rectangle,this.bulletBounds=e.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new T.Signal,this.onKill=new T.Signal,this.onFireLimit=new T.Signal,this.trackedSprite=null,this.trackedPointer=null,this.multiFire=!1,this._hasFired=!1,this.trackRotation=!1,this.trackOffset=new T.Point,this._nextFire=0,this._tempNextFire=0,this._rotatedPoint=new T.Point},T.Weapon.prototype=Object.create(T.Plugin.prototype),T.Weapon.prototype.constructor=T.Weapon,T.Weapon.KILL_NEVER=0,T.Weapon.KILL_LIFESPAN=1,T.Weapon.KILL_DISTANCE=2,T.Weapon.KILL_WEAPON_BOUNDS=3,T.Weapon.KILL_CAMERA_BOUNDS=4,T.Weapon.KILL_WORLD_BOUNDS=5,T.Weapon.KILL_STATIC_BOUNDS=6,T.Weapon.prototype.createBullets=function(e,t,a,o){return void 0===e&&(e=1),void 0===o&&(o=this.game.world),this.bullets||(this.bullets=this.game.add.physicsGroup(T.Physics.ARCADE,o),this.bullets.classType=this._bulletClass),0!==e&&(-1===e&&(this.autoExpandBulletsGroup=!0,e=1),this.bullets.createMultiple(e,t,a),this.bullets.setAll("data.bulletManager",this),this.bulletKey=t,this.bulletFrame=a),this},T.Weapon.prototype.forEach=function(e,t){return this.bullets.forEachExists(e,t,arguments),this},T.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},T.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},T.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},T.Weapon.prototype.resetShots=function(e){return this.shots=0,void 0!==e&&(this.fireLimit=e),this},T.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},T.Weapon.prototype.update=function(){this._bulletKillType===T.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY)),this.autofire&&this.fire()},T.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},T.Weapon.prototype.trackSprite=function(e,t,a,o){return void 0===t&&(t=0),void 0===a&&(a=0),void 0===o&&(o=!1),this.trackedPointer=null,this.trackedSprite=e,this.trackRotation=o,this.trackOffset.set(t,a),this},T.Weapon.prototype.trackPointer=function(e,t,a){return void 0===e&&(e=this.game.input.activePointer),void 0===t&&(t=0),void 0===a&&(a=0),this.trackedPointer=e,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(t,a),this},T.Weapon.prototype.fireMany=function(e,t){this.multiFire=!0;var a=[],o=this;return t||this.trackedSprite||this.trackedPointer?e.forEach(function(e){a.push(o.fire(t,null,null,e.x,e.y))}):e.forEach(function(e){a.push(o.fire(e))}),a},T.Weapon.prototype.fireOffset=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.fire(null,null,null,e,t)},T.Weapon.prototype.fire=function(e,t,a,o,n){if(void 0===t&&(t=null),void 0===a&&(a=null),this.game.time.now<this._nextFire||0<this.fireLimit&&this.shots===this.fireLimit)return null;var i=this.bulletSpeed;0!==this.bulletSpeedVariance&&(i+=T.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance)),e?1<this.fireFrom.width?this.fireFrom.centerOn(e.x,e.y):(this.fireFrom.x=e.x,this.fireFrom.y=e.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.worldRotation),1<this.fireFrom.width?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):1<this.fireFrom.width?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(i+=this.trackedSprite.body.speed)):this.trackedPointer&&(1<this.fireFrom.width?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y)),void 0!==o&&(this.fireFrom.x+=o),void 0!==n&&(this.fireFrom.y+=n);var s=1<this.fireFrom.width?this.fireFrom.randomX:this.fireFrom.x,d=1<this.fireFrom.height?this.fireFrom.randomY:this.fireFrom.y,l=this.trackRotation?this.trackedSprite.angle:this.fireAngle;null!==t&&null!==a&&(l=this.game.math.radToDeg(r(a-d,t-s))),0!==this.bulletAngleVariance&&(l+=T.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var p=0,u=0;0===l||180===l?p=m(this.game.math.degToRad(l))*i:90===l||270===l?u=h(this.game.math.degToRad(l))*i:(p=m(this.game.math.degToRad(l))*i,u=h(this.game.math.degToRad(l))*i);var g=null;if(this.autoExpandBulletsGroup?(g=this.bullets.getFirstExists(!1,!0,s,d,this.bulletKey,this.bulletFrame),g.data.bulletManager=this):g=this.bullets.getFirstExists(!1),g){if(g.reset(s,d),g.data.fromX=s,g.data.fromY=d,g.data.killType=this.bulletKillType,g.data.killDistance=this.bulletKillDistance,g.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===T.Weapon.KILL_LIFESPAN&&(g.lifespan=this.bulletLifespan),g.angle=l+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===g.animations.getAnimation(this.bulletAnimation)){var y=this.anims[this.bulletAnimation];g.animations.add(y.name,y.frames,y.frameRate,y.loop,y.useNumericIndex)}g.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(g.frame=this.bulletFrames[this.bulletFrameIndex],this.bulletFrameIndex++,this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(g.frame=this.bulletFrames[c(Math.random()*this.bulletFrames.length)]);g.data.bodyDirty&&(this._data.customBody&&g.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),g.body.collideWorldBounds=this.bulletCollideWorldBounds,g.data.bodyDirty=!1),g.body.velocity.set(p,u),g.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var f=0;if(0!==this.bulletSpeedVariance){var x=this.fireRate;x+=T.Math.between(-this.fireRateVariance,this.fireRateVariance),0>x&&(x=0),f=this.game.time.now+x}else f=this.game.time.now+this.fireRate;this.multiFire?!this._hasFired&&(this._hasFired=!0,this._tempNextFire=f,this.shots++):(this._nextFire=f,this.shots++),this.onFire.dispatch(g,this,i),0<this.fireLimit&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return g},T.Weapon.prototype.fireAtPointer=function(e){return void 0===e&&(e=this.game.input.activePointer),this.fire(null,e.worldX,e.worldY)},T.Weapon.prototype.fireAtSprite=function(e){return this.fire(null,e.world.x,e.world.y)},T.Weapon.prototype.fireAtXY=function(e,t){return this.fire(null,e,t)},T.Weapon.prototype.setBulletBodyOffset=function(e,t,a,o){return void 0===a&&(a=0),void 0===o&&(o=0),this._data.customBody=!0,this._data.width=e,this._data.height=t,this._data.offsetX=a,this._data.offsetY=o,this.bullets.callAll("body.setSize","body",e,t,a,o),this.bullets.setAll("data.bodyDirty",!1),this},T.Weapon.prototype.setBulletFrames=function(e,t,a,o){return void 0===a&&(a=!0),void 0===o&&(o=!1),this.bulletFrames=T.ArrayUtils.numberArray(e,t),this.bulletFrameIndex=0,this.bulletFrameCycle=a,this.bulletFrameRandom=o,this},T.Weapon.prototype.addBulletAnimation=function(e,t,a,o,r){return this.anims[e]={name:e,frames:t,frameRate:a,loop:o,useNumericIndex:r},this.bullets.callAll("animations.add","animations",e,t,a,o,r),this.bulletAnimation=e,this},T.Weapon.prototype.debug=function(e,t,a){void 0===e&&(e=16),void 0===t&&(t=32),void 0===a&&(a=!1),this.game.debug.text("Weapon Plugin",e,t),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,e,t+24),a&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(T.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(e){this._bulletClass=e,this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(T.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(e){e===T.Weapon.KILL_STATIC_BOUNDS||e===T.Weapon.KILL_WEAPON_BOUNDS?this.bulletBounds=this.bounds:e===T.Weapon.KILL_CAMERA_BOUNDS?this.bulletBounds=this.game.camera.view:e===T.Weapon.KILL_WORLD_BOUNDS?this.bulletBounds=this.game.world.bounds:void 0,this._bulletKillType=e}}),Object.defineProperty(T.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(e){this._bulletCollideWorldBounds=e,this.bullets.setAll("body.collideWorldBounds",e),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(T.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(e){this.fireFrom.x=e}}),Object.defineProperty(T.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(e){this.fireFrom.y=e}}),T.Bullet=function(e,t,a,o,r){T.Sprite.call(this,e,t,a,o,r),this.anchor.set(0.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},T.Bullet.prototype=Object.create(T.Sprite.prototype),T.Bullet.prototype.constructor=T.Bullet,T.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},T.Bullet.prototype.update=function(){this.exists&&(this.data.killType>T.Weapon.KILL_LIFESPAN&&(this.data.killType===T.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():!this.data.bulletManager.bulletBounds.intersects(this)&&this.kill()),this.data.rotateToVelocity&&(this.rotation=r(this.body.velocity.y,this.body.velocity.x)),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},T.Video=function(e,t,a){if(void 0===t&&(t=null),void 0===a&&(a=null),this.game=e,this.key=t,this.width=0,this.height=0,this.type=T.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new T.Signal,this.onChangeSource=new T.Signal,this.onComplete=new T.Signal,this.onAccess=new T.Signal,this.onError=new T.Signal,this.onTimeout=new T.Signal,this.timeout=15000,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,t&&this.game.cache.checkVideoKey(t)){var o=this.game.cache.getVideo(t);o.isBlob?this.createVideoFromBlob(o.data):this.video=o.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else a&&this.createVideoFromURL(a,!1);this.video&&!a?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(T.Cache.DEFAULT.baseTexture.source,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new T.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==t&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,T.BitmapData&&(this.snapshot=new T.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():o&&(o.locked=!1)},T.Video.prototype={connectToMediaStream:function(e,t){return e&&t&&(this.video=e,this.videoStream=t,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(e,t,a){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===a&&(a=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),null!==t&&(this.video.width=t),null!==a&&(this.video.height=a),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:e,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(e){this.getUserMediaError(e)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(e){clearTimeout(this._timeOutID),this.onError.dispatch(this,e)},getUserMediaSuccess:function(e){clearTimeout(this._timeOutID),this.videoStream=e,void 0===this.video.mozSrcObject?this.video.src=window.URL&&window.URL.createObjectURL(e)||e:this.video.mozSrcObject=e;var t=this;this.video.onloadeddata=function(){function e(){if(!(0<a))console.warn("Unable to connect to video stream. Webcam error?");else if(0<t.video.videoWidth){var o=t.video.videoWidth,r=t.video.videoHeight;isNaN(t.video.videoHeight)&&(r=o/(4/3)),t.video.play(),t.isStreaming=!0,t.baseTexture.source=t.video,t.updateTexture(null,o,r),t.onAccess.dispatch(t)}else window.setTimeout(e,500);a--}var a=10;e()}},createVideoFromBlob:function(e){var t=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.addEventListener("loadeddata",function(e){t.updateTexture(e)},!0),this.video.src=window.URL.createObjectURL(e),this.video.canplay=!0,this},createVideoFromURL:function(e,t){return void 0===t&&(t=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,t&&this.video.setAttribute("autoplay","autoplay"),this.video.src=e,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=e,this},updateTexture:function(e,t,a){var o=!1;(void 0===t||null===t)&&(t=this.video.videoWidth,o=!0),(void 0===a||null===a)&&(a=this.video.videoHeight),this.width=t,this.height=a,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(t,a),this.texture.frame.resize(t,a),this.texture.width=t,this.texture.height=a,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(t,a),o&&null!==this.key&&(this.onChangeSource.dispatch(this,t,a),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(e,t){return this._pendingChangeSource?this:(void 0===e&&(e=!1),void 0===t&&(t=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=e?"loop":"",this.video.playbackRate=t,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4===this.video.readyState?(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0)):(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval))),this.video.play(),this.onPlay.dispatch(this,e,t)),this)},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(e){e.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)e[t].loadTexture&&e[t].loadTexture(this);else e.loadTexture(this);return this},addToWorld:function(e,t,a,o,r,n){r=r||1,n=n||1;var i=this.game.add.image(e,t,this);return i.anchor.set(a,o),i.scale.set(r,n),i},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){!this._muted||this._codeMuted||(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,!this.video.ended&&this.video.play())},changeSource:function(e,t){return void 0===t&&(t=!0),this.texture.valid=!1,this.video.pause(),this._pendingChangeSource=!0,this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=e,this.video.load(),this._autoplay=t,t||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?(this._pendingChangeSource=!1,this.updateTexture()):(this.retry--,0<this.retry?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming))},setTouchLock:function(){this.game.input.addTouchLockCallback(this.unlock,this),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate),this.key){var e=this.game.cache.getVideo(this.key);e&&!e.isBlob&&(e.locked=!1)}return!0},grab:function(e,t,a){return(void 0===e&&(e=!1),void 0===t&&(t=1),void 0===a&&(a=null),null===this.snapshot)?void console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable"):(e&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,t,a),this.snapshot)},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.touch.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(T.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(e){this.video.currentTime=e}}),Object.defineProperty(T.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(T.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(T.Video.prototype,"mute",{get:function(){return this._muted},set:function(e){if(e=e||null,e){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(T.Video.prototype,"paused",{get:function(){return this._paused},set:function(e){if(e=e||null,!this.touchLocked)if(e){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(T.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(e){0>e?e=0:1<e&&(e=1),this.video&&(this.video.volume=e)}}),Object.defineProperty(T.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(e){this.video&&(this.video.playbackRate=e)}}),Object.defineProperty(T.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(e){e&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(T.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),T.Video.prototype.constructor=T.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=T.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=T.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture())),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new T.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return T.Device.canUseMultiply},"undefined"==typeof exports?"undefined"!=typeof define&&define.amd?define("Phaser",function(){return y.Phaser=T}()):y.Phaser=T:("undefined"!=typeof module&&module.exports&&(exports=module.exports=T),exports.Phaser=T),T}.call(this);