!function(){vara={},b={};!function(){b._inertiaScale=4;vara=1,c=-1;b.create=function(a){varb={id:o.nextId(),type:"body",label:"Body",angle:0,vertices:A.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,sprite:{xScale:1,yScale:1},lineWidth:1.5}},c=o.extend(b,a);returnd(c,a),c},b.nextGroup=function(b){returnb?c--:a++};vard=function(a,c){a.bounds=a.bounds||y.create(a.vertices),a.positionPrev=a.positionPrev||z.clone(a.position),a.anglePrev=a.anglePrev||a.angle,b.setVertices(a,a.vertices),b.setStatic(a,a.isStatic),u.set(a,a.isSleeping),A.rotate(a.vertices,a.angle,a.position),x.rotate(a.axes,a.angle),y.update(a.bounds,a.vertices,a.velocity),a.axes=c.axes||a.axes,a.area=c.area||a.area,b.setMass(a,c.mass||a.mass),b.setInertia(a,c.inertia||a.inertia);vard=a.isStatic?"#eeeeee":o.choose(["#556270","#4ECDC4","#C7F464","#FF6B6B","#C44D58"]),e=o.shadeColor(d,-20);a.render.fillStyle=a.render.fillStyle||d,a.render.strokeStyle=a.render.strokeStyle||e};b.setStatic=function(a,b){a.isStatic=b,b&&(a.restitution=0,a.friction=1,a.mass=a.inertia=a.density=1/0,a.inverseMass=a.inverseInertia=0,a.positionPrev.x=a.position.x,a.positionPrev.y=a.position.y,a.anglePrev=a.angle,a.angularVelocity=0,a.speed=0,a.angularSpeed=0,a.motion=0)},b.setMass=function(a,b){a.mass=b,a.inverseMass=1/a.mass,a.density=a.mass/a.area},b.setDensity=function(a,c){b.setMass(a,c*a.area),a.density=c},b.setInertia=function(a,b){a.inertia=b,a.inverseInertia=1/a.inertia},b.setVertices=function(a,c){a.vertices=c[0].body===a?c:A.create(c,a),a.axes=x.fromVertices(a.vertices),a.area=A.area(a.vertices),b.setMass(a,a.density*a.area);vard=A.centre(a.vertices);A.translate(a.vertices,d,-1),b.setInertia(a,b._inertiaScale*A.inertia(a.vertices,a.mass)),A.translate(a.vertices,a.position),y.update(a.bounds,a.vertices,a.velocity)},b.setPosition=function(a,b){varc=z.sub(b,a.position);a.position.x=b.x,a.position.y=b.y,a.positionPrev.x+=c.x,a.positionPrev.y+=c.y,A.translate(a.vertices,c),y.update(a.bounds,a.vertices,a.velocity)},b.setAngle=function(a,b){varc=b-a.angle;a.angle=b,a.anglePrev+=c,A.rotate(a.vertices,c,a.position),x.rotate(a.axes,c),y.update(a.bounds,a.vertices,a.velocity)},b.setVelocity=function(a,b){a.positionPrev.x=a.position.x-b.x,a.positionPrev.y=a.position.y-b.y,a.velocity.x=b.x,a.velocity.y=b.y,a.speed=z.magnitude(a.velocity)},b.setAngularVelocity=function(a,b){a.anglePrev=a.angle-b,a.angularVelocity=b,a.angularSpeed=Math.abs(a.angularVelocity)},b.translate=function(a,c){b.setPosition(a,z.add(a.position,c))},b.rotate=function(a,c){b.setAngle(a,a.angle+c)},b.scale=function(a,c,d,e){A.scale(a.vertices,c,d,e),a.axes=x.fromVertices(a.vertices),a.area=A.area(a.vertices),b.setMass(a,a.density*a.area),A.translate(a.vertices,{x:-a.position.x,y:-a.position.y}),b.setInertia(a,A.inertia(a.vertices,a.mass)),A.translate(a.vertices,{x:a.position.x,y:a.position.y}),y.update(a.bounds,a.vertices,a.velocity)},b.resetForcesAll=function(a){for(varb=0;b<a.length;b++){varc=a[b];c.force.x=0,c.force.y=0,c.torque=0}},b.applyGravityAll=function(a,b){for(varc=0;c<a.length;c++){vard=a[c];d.isStatic||d.isSleeping||(d.force.y+=d.mass*b.y*.001,d.force.x+=d.mass*b.x*.001)}},b.updateAll=function(a,c,d,e,f){for(varg=0;g<a.length;g++){varh=a[g];h.isStatic||h.isSleeping||h.bounds.max.x<f.min.x||h.bounds.min.x>f.max.x||h.bounds.max.y<f.min.y||h.bounds.min.y>f.max.y||b.update(h,c,d,e)}},b.update=function(a,b,c,d){vare=Math.pow(b*c*a.timeScale,2),f=1-a.frictionAir*c*a.timeScale,g=a.position.x-a.positionPrev.x,h=a.position.y-a.positionPrev.y;a.velocity.x=g*f*d+a.force.x/a.mass*e,a.velocity.y=h*f*d+a.force.y/a.mass*e,a.positionPrev.x=a.position.x,a.positionPrev.y=a.position.y,a.position.x+=a.velocity.x,a.position.y+=a.velocity.y,a.angularVelocity=(a.