!function(a){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=a();elseif("function"==typeofdefine&&define.amd)define([],a);else{varb;b="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,b.Matter=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);varj=newError("Cannot find module '"+g+"'");throwj.code="MODULE_NOT_FOUND",j}vark=c[g]={exports:{}};b[g][0].call(k.exports,function(a){varc=b[g][1][a];returne(c?c:a)},k,k.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){varc={};b.exports=c;vard=a("../geometry/Vertices"),e=a("../geometry/Vector"),f=a("../core/Sleeping"),g=(a("../render/Render"),a("../core/Common")),h=a("../geometry/Bounds"),i=a("../geometry/Axes");!function(){c._inertiaScale=4;vara=1,b=-1,j=1;c.create=function(a){varb={id:g.nextId(),type:"body",label:"Body",parts:[],angle:0,vertices:d.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},totalContacts: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,frictionStatic:.5,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=g.extend(b,a);returnk(c,a),c},c.nextGroup=function(c){returnc?b--:a++},c.nextCategory=function(){returnj<<=1};vark=function(a,b){c.set(a,{bounds:a.bounds||h.create(a.vertices),positionPrev:a.positionPrev||e.clone(a.position),anglePrev:a.anglePrev||a.angle,vertices:a.vertices,parts:a.parts||[a],isStatic:a.isStatic,isSleeping:a.isSleeping,parent:a.parent||a}),d.rotate(a.vertices,a.angle,a.position),i.rotate(a.axes,a.angle),h.update(a.bounds,a.vertices,a.velocity),c.set(a,{axes:b.axes||a.axes,area:b.area||a.area,mass:b.mass||a.mass,inertia:b.inertia||a.inertia});varf=a.isStatic?"#eeeeee":g.choose(["#556270","#4ECDC4","#C7F464","#FF6B6B","#C44D58"]),j=g.shadeColor(f,-20);a.render.fillStyle=a.render.fillStyle||f,a.render.strokeStyle=a.render.strokeStyle||j};c.set=function(a,b,d){vare;"string"==typeofb&&(e=b,b={},b[e]=d);for(einb)if(d=b[e],b.hasOwnProperty(e))switch(e){case"isStatic":c.setStatic(a,d);break;case"isSleeping":f.set(a,d);break;case"mass":c.setMass(a,d);break;case"density":c.setDensity(a,d);break;case"inertia":c.setInertia(a,d);break;case"vertices":c.setVertices(a,d);break;case"position":c.setPosition(a,d);break;case"angle":c.setAngle(a,d);break;case"velocity":c.setVelocity(a,d);break;case"angularVelocity":c.setAngularVelocity(a,d);break;case"parts":c.setParts(a,d);break;default:a[e]=d}},c.setStatic=function(a,b){for(varc=0;c<a.parts.length;c++){vard=a.parts[c];d.isStatic=b,b&&(d.restitution=0,d.friction=1,d.mass=d.inertia=d.density=1/0,d.inverseMass=d.inverseInertia=0,d.positionPrev.x=d.position.x,d.positionPrev.y=d.position.y,d.anglePrev=d.angle,d.angularVelocity=0,d.speed=0,d.angularSpeed=0,d.motion=0)}},c.setMass=function(a,b){a.mass=b,a.inverseMass=1/a.mass,a.density=a.mass/a.area},c.setDensity=function(a,b){c.setMass(a,b*a.area),a.density=b},c.setInertia=function(a,b){a.inertia=b,a.inverseInertia=1/a.inertia},c.setVertices=function(a,b){a.vertices=b[0].body===a?b:d.create(b,a),a.axes=i.fromVertices(a.vertices),a.area=d.area(a.vertices),c.setMass(a,a.density*a.area);vare=d.centre(a.vertices);d.translate(a.vertices,e,-1),c.setInertia(a,c._inertiaScale*d.inertia(a.vertices,a.mass)),d.translate(a.vertices,a.position),h.update(a.bounds,a.vertices,a.velocity)},c.setParts=function(a,b,e){varf;for(b=b.slice(0),a.parts.length=0,a.parts.push(a),a.parent=a,f=0;f<b.length;f++){varg=b[f];g!==a&&(g.parent=a,a.parts.push(g))}if(1!==a.parts.length){if(e="undefined"!=typeofe?e:!0){varh=[];for(f=0;f<b.length;f++)h=h.concat(b[f].vertices);d.clockwiseSort(h);vari=