!function(a){if("object"==typeofexports)module.exports=a();else{varb;"undefined"!=typeofwindow?b=window:"undefined"!=typeofglobal?b=global:"undefined"!=typeofself&&(b=self),b.p2=a()}}(function(){returnfunctiona(b,c,d){functione(g,h){if(!c[g]){if(!b[g]){vari="function"==typeofrequire&&require;if(!h&&i)returni(g,!0);if(f)returnf(g,!0);thrownewError("Cannot find module '"+g+"'")}varj=c[g]={exports:{}};b[g][0].call(j.exports,function(a){varc=b[g][1][a];returne(c?c:a)},j,j.exports,a,b,c,d)}returnc[g].exports}for(varf="function"==typeofrequire&&require,g=0;g<d.length;g++)e(d[g]);returne}({1:[function(a,b){functionc(){}vard=a("./Scalar");b.exports=c,c.lineInt=function(a,b,c){c=c||0;vare,f,g,h,i,j,k,l=[0,0];returne=a[1][1]-a[0][1],f=a[0][0]-a[1][0],g=e*a[0][0]+f*a[0][1],h=b[1][1]-b[0][1],i=b[0][0]-b[1][0],j=h*b[0][0]+i*b[0][1],k=e*i-h*f,d.eq(k,0,c)||(l[0]=(i*g-f*j)/k,l[1]=(e*j-h*g)/k),l},c.segmentsIntersect=function(a,b,c,d){vare=b[0]-a[0],f=b[1]-a[1],g=d[0]-c[0],h=d[1]-c[1];if(g*f-h*e==0)return!1;vari=(e*(c[1]-a[1])+f*(a[0]-c[0]))/(g*f-h*e),j=(g*(a[1]-c[1])+h*(c[0]-a[0]))/(h*e-g*f);returni>=0&&1>=i&&j>=0&&1>=j}},{"./Scalar":4}],2:[function(a,b){functionc(){}b.exports=c,c.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},c.left=function(a,b,d){returnc.area(a,b,d)>0},c.leftOn=function(a,b,d){returnc.area(a,b,d)>=0},c.right=function(a,b,d){returnc.area(a,b,d)<0},c.rightOn=function(a,b,d){returnc.area(a,b,d)<=0};vard=[],e=[];c.collinear=function(a,b,f,g){if(g){varh=d,i=e;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=f[0]-b[0],i[1]=f[1]-b[1];varj=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.acos(j/(k*l));returng>m}return0==c.area(a,b,f)},c.sqdist=function(a,b){varc=b[0]-a[0],d=b[1]-a[1];returnc*c+d*d}},{}],3:[function(a,b){functionc(){this.vertices=[]}functiond(a,b,c,d,e){e=e||0;varf=b[1]-a[1],h=a[0]-b[0],i=f*a[0]+h*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*h;returng.eq(m,0,e)?[0,0]:[(k*i-h*l)/m,(f*l-j*i)/m]}vare=a("./Line"),f=a("./Point"),g=a("./Scalar");b.exports=c,c.prototype.at=function(a){varb=this.vertices,c=b.length;returnb[0>a?a%c+c:a%c]},c.prototype.first=function(){returnthis.vertices[0]},c.prototype.last=function(){returnthis.vertices[this.vertices.length-1]},c.prototype.clear=function(){this.vertices.length=0},c.prototype.append=function(a,b,c){if("undefined"==typeofb)thrownewError("From is not given!");if("undefined"==typeofc)thrownewError("To is not given!");if(b>c-1)thrownewError("lol1");if(c>a.vertices.length)thrownewError("lol2");if(0>b)thrownewError("lol3");for(vard=b;c>d;d++)this.vertices.push(a.vertices[d])},c.prototype.makeCCW=function(){for(vara=0,b=this.vertices,c=1;c<this.vertices.length;++c)(b[c][1]<b[a][1]||b[c][1]==b[a][1]&&b[c][0]>b[a][0])&&(a=c);f.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},c.prototype.reverse=function(){for(vara=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},c.prototype.isReflex=function(a){returnf.right(this.at(a-1),this.at(a),this.at(a+1))};varh=[],i=[];c.prototype.canSee=function(a,b){varc,d,g=h,j=i;if(f.leftOn(this.at(a+1),this.at(a),this.at(b))&&f.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=f.sqdist(this.at(a),this.at(b));for(vark=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&f.leftOn(this.at(a),this.at(b),this.at(k+1))&&f.rightOn(this.at(a),this.at(b),this.at(k))&&(g[0]=this.at(a),g[1]=this.at(b),j[0]=this.at(k),j[1]=this.at(k+1),c=e.lineInt(g,j),f.sqdist(this.at(a),c)<d))return!1;return!0},c.prototype.copy=function(a,b,d){vare=d||newc;if(e.clear(),b>a)for(varf=a;b>=f;f++)e.vertices.push(this.vertices[f]);else{for(varf=0;b>=f;f++)e.vertices.push(this.vertices[f]);for(varf=a;f<this.vertices.length;f++)e.vertices.push(this.vertices[f])}returne},c.prototype.getCutEdges=function(){for(vara=[],b=[],d=[],e=newc,f=Number.MAX_VALUE,g=0;g<this.vertices.length;++g)if(this.isReflex(g))for(varh=0;h<this.vertices.length;++h)if(this.canSee(g,h)){b=this.co
}vard=a("../math/vec2"),e=a("poly-decomp"),f=a("../shapes/Convex"),g=a("../collision/RaycastResult"),h=a("../collision/Ray"),i=a("../collision/AABB"),j=a("../events/EventEmitter");b.exports=c,c.prototype=newj,c.prototype.constructor=c,c._idCounter=0,c.prototype.updateSolveMassProperties=function(){this.sleepState===c.SLEEPING||this.type===c.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},c.prototype.setDensity=function(a){varb=this.getArea();this.mass=b*a,this.updateMassProperties()},c.prototype.getArea=function(){for(vara=0,b=0;b<this.shapes.length;b++)a+=this.shapes[b].area;returna},c.prototype.getAABB=function(){returnthis.aabbNeedsUpdate&&this.updateAABB(),this.aabb};vark=newi,l=d.create();c.prototype.updateAABB=function(){for(vara=this.shapes,b=a.length,c=l,e=this.angle,f=0;f!==b;f++){varg=a[f],h=g.angle+e;d.rotate(c,g.position,e),d.add(c,c,this.position),g.computeAABB(k,c,h),0===f?this.aabb.copy(k):this.aabb.extend(k)}this.aabbNeedsUpdate=!1},c.prototype.updateBoundingRadius=function(){for(vara=this.shapes,b=a.length,c=0,e=0;e!==b;e++){varf=a[e],g=d.length(f.position),h=f.boundingRadius;g+h>c&&(c=g+h)}this.boundingRadius=c},c.prototype.addShape=function(a,b,c){if(a.body)thrownewError("A shape can only be added to one body.");a.body=this,b?d.copy(a.position,b):d.set(a.position,0,0),a.angle=c||0,this.shapes.push(a),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},c.prototype.removeShape=function(a){varb=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.aabbNeedsUpdate=!0,a.body=null,!0):!1},c.prototype.updateMassProperties=function(){if(this.type===c.STATIC||this.type===c.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{vara=this.shapes,b=a.length,e=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(varg=0;b>g;g++){varh=a[g],i=d.squaredLength(h.position),j=h.computeMomentOfInertia(e);f+=j+e*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass,d.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};d.create();c.prototype.applyForce=function(a,b){if(d.add(this.force,this.force,a),b){varc=d.crossLength(b,a);this.angularForce+=c}};varm=d.create(),n=d.create(),o=d.create();c.prototype.applyForceLocal=function(a,b){b=b||o;varc=m,d=n;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyForce(c,d)};varp=d.create();c.prototype.applyImpulse=function(a,b){if(this.type===c.DYNAMIC){vare=p;if(d.scale(e,a,this.invMass),d.multiply(e,this.massMultiplier,e),d.add(this.velocity,e,this.velocity),b){varf=d.crossLength(b,a);f*=this.invInertia,this.angularVelocity+=f}}};varq=d.create(),r=d.create(),s=d.create();c.prototype.applyImpulseLocal=function(a,b){b=b||s;varc=q,d=r;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyImpulse(c,d)},c.prototype.toLocalFrame=function(a,b){d.toLocalFrame(a,b,this.position,this.angle)},c.prototype.toWorldFrame=function(a,b){d.toGlobalFrame(a,b,this.position,this.angle)},c.prototype.vectorToLocalFrame=function(a,b){d.vectorToLocalFrame(a,b,this.angle)},c.prototype.vectorToWorldFrame=function(a,b){d.vectorToGlobalFrame(a,b,this.angle)},c.prototype.fromPolygon=function(a,b){b=b||{};for(varc=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);varg=newe.Polygon;if(g.vertices=a,g.makeCCW(),"number"==typeofb.removeCollinearPoints&&g.removeCollinearPoints(b.removeCollinearPoints),"undefined"==typeofb.skipSimpleCheck&&!g.isSimple())return!1;this.concavePath=g.vertices.slice(0);for(varc=0;c<this.concavePath.length;c++){varh=[0,0];d.copy(h,this.concavePath[c]),this.concavePath[c]=h}vari;i=b.optimalDecomp?g.decomp():g.quickDecomp();for(varj=d.create(),c=0;c!==i.length;c++){for(vark=newf({vertices:i[c].vertices}),l=0;l!==k.vertices.length;l++){varh=k.vertices[l];d.sub(h,h,k.centerOfMass)}d.scale(j,k.centerOfMass,1),k.updateTriangles(),k.updateCenterOfMass(),k.updateBoundingRadius(),this.addShape(k,
for(vart=this.invCs,u=this.Bs,q=this.lambda,r=0;r!==k.length;r++){varv=k[r];(v.timeStep!==a||v.needsUpdate)&&(v.timeStep=a,v.update()),u[r]=v.computeB(v.a,v.b,a),t[r]=v.computeInvC(v.epsilon)}varv,w,r,x;if(0!==l){for(r=0;r!==o;r++){vars=n[r];s.resetConstraintVelocity()}if(j){for(f=0;f!==j;f++){for(w=0,x=0;x!==l;x++){v=k[x];vary=c.iterateEquation(x,v,v.epsilon,u,t,q,p,a,f);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(c.updateMultipliers(k,q,1/a),x=0;x!==l;x++){varz=k[x];if(zinstanceofh){for(varA=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(f=0;f!==i;f++){for(w=0,x=0;x!==l;x++){v=k[x];vary=c.iterateEquation(x,v,v.epsilon,u,t,q,p,a,f);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();c.updateMultipliers(k,q,1/a)}},c.updateMultipliers=function(a,b,c){for(vard=a.length;d--;)a[d].multiplier=b[d]*c},c.iterateEquation=function(a,b,c,d,e,f,g,h){vari=d[a],j=e[a],k=f[a],l=b.computeGWlambda(),m=b.maxForce,n=b.minForce;g&&(i=0);varo=j*(i-l-c*k),p=k+o;returnn*h>p?o=n*h-k:p>m*h&&(o=m*h-k),f[a]+=o,b.addToWlambda(o),o}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(a,b){functionc(a,b){a=a||{},d.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}vard=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=c,c.prototype=newd,c.prototype.constructor=c,c.prototype.solve=function(){thrownewError("Solver.solve should be implemented by subclasses!")};vare={bodies:[]};c.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),e.bodies.length=0,b.getBodies(e.bodies),e.bodies.length&&this.solve(a,e))},c.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},c.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},c.prototype.addEquations=function(a){for(varb=0,c=a.length;b!==c;b++){vard=a[b];d.enabled&&this.equations.push(d)}},c.prototype.removeEquation=function(a){varb=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},c.prototype.removeAllEquations=function(){this.equations.length=0},c.GS=1,c.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(a,b){functionc(){e.apply(this,arguments)}vard=a("../equations/ContactEquation"),e=a("./Pool");b.exports=c,c.prototype=newe,c.prototype.constructor=c,c.prototype.create=function(){returnnewd},c.prototype.destroy=function(a){returna.bodyA=a.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(a,b){functionc(){e.apply(this,arguments)}vard=a("../equations/FrictionEquation"),e=a("./Pool");b.exports=c,c.prototype=newe,c.prototype.constructor=c,c.prototype.create=function(){returnnewd},c.prototype.destroy=function(a){returna.bodyA=a.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(a,b){functionc(){e.apply(this,arguments)}vard=a("../world/IslandNode"),e=a("./Pool");b.exports=c,c.prototype=newe,c.prototype.constructor=c,c.prototype.create=function(){returnnewd},c.prototype.destroy=function(a){returna.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(a,b){functionc(){e.apply(this,arguments)}vard=a("../world/Island"),e=a("./Pool");b.exports=c,c.prototype=newe,c.prototype.constructor=c,c.prototype.create=function(){returnnewd},c.prototype.destroy=function(a){returna.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(a,b){functionc(){this.overlappingShapesLastState=newd,this.overlappingShapesCurrentState=newd,this.recordPool=newe({size:16}),this.tmpDict=newd,this.tmpArray1=[]}{vard=a("./TupleDictionary"),e=(a("./OverlapKeeperRecord"),a("./OverlapKeeperRecordPool"));a("./Utils")}b.exports=c,c.prototype.tick=function(){for(vara=this.overlappingShapesLastState,b=this.overlappingShapesCurrentState,c=a.keys.length;c--;){{vard=a.keys[c],e=a.getByKey(
if(-1!==b)returnthis.removeChildAt(b)},b.DisplayObjectContainer.prototype.removeChildAt=function(a){varb=this.getChildAt(a);returnthis.stage&&b.removeStageReference(),b.parent=void0,this.children.splice(a,1),b},b.DisplayObjectContainer.prototype.removeChildren=function(a,b){varc=a||0,d="number"==typeofb?b:this.children.length,e=d-c;if(e>0&&d>=e){for(varf=this.children.splice(c,e),g=0;g<f.length;g++){varh=f[g];this.stage&&h.removeStageReference(),h.parent=void0}returnf}if(0===e&&0===this.children.length)return[];thrownewError("removeChildren: Range Error, numeric values are outside the acceptable range")},b.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(vara=0;a<this.children.length;a++)this.children[a].updateTransform()},b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=b.DisplayObjectContainer.prototype.updateTransform,b.DisplayObjectContainer.prototype.getBounds=function(){if(0===this.children.length)returnb.EmptyRectangle;for(vara,c,d,e=1/0,f=1/0,g=-1/0,h=-1/0,i=!1,j=0,k=this.children.length;k>j;j++){varl=this.children[j];l.visible&&(i=!0,a=this.children[j].getBounds(),e=e<a.x?e:a.x,f=f<a.y?f:a.y,c=a.width+a.x,d=a.height+a.y,g=g>c?g:c,h=h>d?h:d)}if(!i)returnb.EmptyRectangle;varm=this._bounds;returnm.x=e,m.y=f,m.width=g-e,m.height=h-f,m},b.DisplayObjectContainer.prototype.getLocalBounds=function(){vara=this.worldTransform;this.worldTransform=b.identityMatrix;for(varc=0,d=this.children.length;d>c;c++)this.children[c].updateTransform();vare=this.getBounds();returnthis.worldTransform=a,e},b.DisplayObjectContainer.prototype.setStageReference=function(a){this.stage=a;for(varb=0;b<this.children.length;b++)this.children[b].setStageReference(a)},b.DisplayObjectContainer.prototype.removeStageReference=function(){for(vara=0;a<this.children.length;a++)this.children[a].removeStageReference();this.stage=null},b.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)returnvoidthis._renderCachedSprite(a);varb;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}elsefor(b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a)}},b.DisplayObjectContainer.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)returnvoidthis._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(varb=0;b<this.children.length;b++)this.children[b]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Sprite=function(a){b.DisplayObjectContainer.call(this),this.anchor=newb.Point,this.texture=a||b.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=b.blendModes.NORMAL,this.shader=null,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},b.Sprite.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Sprite.prototype.constructor=b.Sprite,Object.defineProperty(b.Sprite.prototype,"width",{get:function(){returnthis.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(b.Sprite.prototype,"height",{get:function(){returnthis.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),b.Sprite.prototype.setTexture=function(a){this.texture=a,this.texture.valid=!0},b.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)},b.Sprite.prototype.getBounds=function(a){varb=this.texture.frame.wid
},b.WebGLRenderer.prototype.constructor=b.WebGLRenderer,b.WebGLRenderer.prototype.initContext=function(){vara=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=a,!a)thrownewError("This browser does not support webGL. Try using the canvas renderer");this.glContextId=a.id=b.WebGLRenderer.glContextId++,b.glContexts[this.glContextId]=a,b.instances[this.glContextId]=this,a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),this.shaderManager.setContext(a),this.spriteBatch.setContext(a),this.maskManager.setContext(a),this.filterManager.setContext(a),this.blendModeManager.setContext(a),this.stencilManager.setContext(a),this.renderSession.gl=this.gl,this.resize(this.width,this.height)},b.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a),a.updateTransform();varb=this.gl;b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.clearBeforeRender&&(this.transparent?b.clearColor(0,0,0,0):b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],1),b.clear(b.COLOR_BUFFER_BIT)),this.renderDisplayObject(a,this.projection)}},b.WebGLRenderer.prototype.renderDisplayObject=function(a,c,d,e){this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=d?-1:1,this.renderSession.projection=c,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,d),a._renderWebGL(this.renderSession,e),this.spriteBatch.end()},b.WebGLRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*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},b.WebGLRenderer.prototype.updateTexture=function(a){if(a.hasLoaded){varc=this.gl;returna._glTextures[c.id]||(a._glTextures[c.id]=c.createTexture()),c.bindTexture(c.TEXTURE_2D,a._glTextures[c.id]),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultipliedAlpha),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a.source),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a.mipmap&&b.isPowerOfTwo(a.width,a.height)?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR_MIPMAP_LINEAR:c.NEAREST_MIPMAP_NEAREST),c.generateMipmap(c.TEXTURE_2D)):c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a._powerOf2?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.REPEAT),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.REPEAT)):(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE)),a._dirty[c.id]=!1,a._glTextures[c.id]}},b.WebGLRenderer.prototype.destroy=function(){b.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,b.instances[this.glContextId]=null,b.WebGLRenderer.glContextId--},b.WebGLRenderer.prototype.mapBlendModes=function(){vara=this.gl;b.blendModesWebGL||(b.blendModesWebGL=[],b.blendModesWebGL[b.blendModes.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],b.blendModesWebGL[b.blendModes.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SCREEN]=[a.SRC_ALPHA,a.ONE],b.blendModesWebGL[b.blendModes.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.LIGH
vare;returnbinstanceofc.State?e=b:"object"==typeofb?(e=b,e.game=this.game):"function"==typeofb&&(e=newb(this.game)),this.states[a]=e,d&&(this.game.isBooted?this.start(a):this._pendingState=a),e},remove:function(a){this.current===a&&(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),deletethis.states[a]},start:function(a,b,c){void0===b&&(b=!0),void0===c&&(c=!1),this.checkState(a)&&(this._pendingState=a,this._clearWorld=b,this._clearCache=c,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(a,b){void0===a&&(a=!0),void0===b&&(b=!1),this._pendingState=this.current,this._clearWorld=a,this._clearCache=b,arguments.length>2&&(this._args=Array.prototype.splice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){vara=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,a),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===!0&&this.game.cache.destroy()))},checkState:function(a){if(this.states[a]){varb=!1;return(this.states[a].preload||this.states[a].create||this.states[a].update||this.states[a].render)&&(b=!0),b===!1?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render"),!1):!0}returnconsole.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].make=this.game.make,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].scale=this.game.scale,this.states[a].state=this,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].rnd=this.game.rnd,this.states[a].physics=this.game.physics,this.states[a].key=a},unlink:function(a){this.states[a]&&(this.states[a].game=null,this.states[a].add=null,this.states[a].make=null,this.states[a].camera=null,this.states[a].cache=null,this.states[a].input=null,this.states[a].load=null,this.states[a].math=null,this.states[a].sound=null,this.states[a].scale=null,this.states[a].state=null,this.states[a].stage=null,this.states[a].time=null,this.states[a].tweens=null,this.states[a].world=null,this.states[a].particles=null,this.states[a].rnd=null,this.states[a].physics=null)},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,t
this.renderRegion(c,d,i,m,j,n)}if(l>=k){this.context.clearRect(0,k*h-d,e,(l-k+1)*h);varo=Math.floor((0+c)/g),p=Math.floor((e-1+c)/g);this.renderRegion(c,d,o,k,p,l)}},c.TilemapLayer.prototype.renderFull=function(){vara=this._mc.scrollX,b=this._mc.scrollY,c=this.canvas.width,d=this.canvas.height,e=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(a/e),h=Math.floor((c-1+a)/e),i=Math.floor(b/f),j=Math.floor((d-1+b)/f);this.context.clearRect(0,0,c,d),this.renderRegion(a,b,g,i,h,j)},c.TilemapLayer.prototype.render=function(){vara=!1;if(this.visible){this.context.save(),(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,a=!0);varb=this.canvas.width,c=this.canvas.height,d=0|this._scrollX,e=0|this._scrollY,f=this._mc,g=f.scrollX-d,h=f.scrollY-e;if(a||0!==g||0!==h||f.renderWidth!==b||f.renderHeight!==c)returnf.scrollX=d,f.scrollY=e,(f.renderWidth!==b||f.renderHeight!==c)&&(f.renderWidth=b,f.renderHeight=c),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(a=!0)),!a&&this.renderSettings.enableScrollDelta&&Math.abs(g)+Math.abs(h)<Math.min(b,c)?this.renderDeltaScroll(g,h):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},c.TilemapLayer.prototype.renderDebug=function(){vara,b,c,d,e,f,g=this._mc.scrollX,h=this._mc.scrollY,i=this.context,j=this.canvas.width,k=this.canvas.height,l=this.layer.width,m=this.layer.height,n=this._mc.tileWidth,o=this._mc.tileHeight,p=Math.floor(g/n),q=Math.floor((j-1+g)/n),r=Math.floor(h/o),s=Math.floor((k-1+h)/o),t=p*n-g,u=r*o-h,v=(p+(1<<20)*l)%l,w=(r+(1<<20)*m)%m;for(i.strokeStyle=this.debugSettings.facingEdgeStroke,d=w,f=s-r,b=u;f>=0;d++,f--,b+=o){d>=m&&(d-=m);varx=this.layer.data[d];for(c=v,e=q-p,a=t;e>=0;c++,e--,a+=n){c>=l&&(c-=l);vary=x[c];!y||y.index<0||!y.collides||(this.debugSettings.collidingTileOverfill&&(i.fillStyle=this.debugSettings.collidingTileOverfill,i.fillRect(a,b,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(i.beginPath(),y.faceTop&&(i.moveTo(a,b),i.lineTo(a+this._mc.cw,b)),y.faceBottom&&(i.moveTo(a,b+this._mc.ch),i.lineTo(a+this._mc.cw,b+this._mc.ch)),y.faceLeft&&(i.moveTo(a,b),i.lineTo(a,b+this._mc.ch)),y.faceRight&&(i.moveTo(a+this._mc.cw,b),i.lineTo(a+this._mc.cw,b+this._mc.ch)),i.stroke()))}}},Object.defineProperty(c.TilemapLayer.prototype,"wrap",{get:function(){returnthis._wrap},set:function(a){this._wrap=a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollX",{get:function(){returnthis._scrollX},set:function(a){this._scrollX=a}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollY",{get:function(){returnthis._scrollY},set:function(a){this._scrollY=a}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionWidth",{get:function(){returnthis._mc.cw},set:function(a){this._mc.cw=0|a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionHeight",{get:function(){returnthis._mc.ch},set:function(a){this._mc.ch=0|a,this.dirty=!0}}),c.TilemapParser={parse:function(a,b,d,e,f,g){if(void0===d&&(d=32),void0===e&&(e=32),void0===f&&(f=10),void0===g&&(g=10),void0===b)returnthis.getEmptyData();if(null===b)returnthis.getEmptyData(d,e,f,g);varh=a.cache.getTilemapData(b);if(h){if(h.format===c.Tilemap.CSV)returnthis.parseCSV(b,h.data,d,e);if(!h.format||h.format===c.Tilemap.TILED_JSON)returnthis.parseTiledJSON(h.data)}elseconsole.warn("Phaser.TilemapParser.parse - No map data found for key "+b)},parseCSV:function(a,b,d,e){varf=this.getEmptyData();b=b.trim();for(varg=[],h=b.split("\n"),i=h.length,j=0,k=0;k<h.length;k++){g[k]=[];for(varl=h[k].split(","),m=0;m<l.length;m++)g[k][m]=newc.Tile(f.layers[0],parseInt(l[m],10),m,k,d,e);0===j&&(j=l.length)}returnf.format=c.Tilemap.CSV,f.name=a,f.width=j,f.height=i,f.tileWidth=d,f.tileHeight=e,f.widthInPixels=j*d,f.heightInPixels=i*e,f.layers[0].width=j,f.layers[0].height=i,f.layers[0].widthInPixels=f.widthInPixels,f.layers[0].heightInPixels=f.heightInPixels,f.layers[0].data=g,f},getEmptyData:function(a,b,c,d){vare