0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-30 10:20:52 -05:00
liabru-matter-js/demo/js/matter-demo.6283b1.min.js
2023-02-16 14:19:15 +00:00

6 lines
No EOL
149 KiB
JavaScript

/*!
* matter-demo bundle 0.19.0 by @liabru
* http://brm.io/matter-js/
* License MIT
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MatterDemo",[],t):"object"==typeof exports?exports.MatterDemo=t():e.MatterDemo=t()}(this,(function(){return(this.webpackJsonpMatterDemo=this.webpackJsonpMatterDemo||[]).push([[0],{"+QOk":function(e,t,n){var r=r||{};r.timescale=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.Composite,a=Matter.Composites,s=Matter.Common,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=n.create();n.run(f,u),i.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var v=1,g=s.now();o.on(u,"afterUpdate",(function(e){var t=(e.delta||1e3/60)/1e3;u.timing.timeScale+=12*(v-u.timing.timeScale)*t,s.now()-g>=2e3&&(v=v<1?1:0,function(e,t){for(var n=1e3/60/t,o=i.allBodies(e.world),a=0;a<o.length;a++){var c=o[a];if(!c.isStatic&&c.position.y>=500){var l=.05*c.mass*n;r.applyForce(c,c.position,{x:(l+s.random()*l)*s.choose([1,-1]),y:-l+s.random()*-l})}}}(u,e.delta),g=s.now())}));var y={frictionAir:0,friction:1e-4,restitution:.8};i.add(p,a.stack(20,100,15,3,20,40,(function(e,t){return d.circle(e,t,s.random(10,20),y)}))),i.add(p,a.stack(50,50,8,3,0,0,(function(e,t){switch(Math.round(s.random(0,1))){case 0:return s.random()<.8?d.rectangle(e,t,s.random(20,50),s.random(20,50),y):d.rectangle(e,t,s.random(80,120),s.random(20,30),y);case 1:return d.polygon(e,t,Math.round(s.random(4,8)),s.random(20,50),y)}})));var x=l.create(m.canvas),h=c.create(u,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(p,h),m.mouse=x,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.timescale.title="Time Scaling",r.timescale.for=">=0.14.2",e.exports=r.timescale},"+jwT":function(e,t,n){var r=r||{};r.constraints=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=(Matter.Composites,Matter.Common,Matter.Constraint),o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=s.polygon(150,200,5,30),m=r.create({pointA:{x:150,y:100},bodyB:p,pointB:{x:-10,y:-10}});a.add(l,[p,m]);p=s.polygon(280,100,3,30),m=r.create({pointA:{x:280,y:120},bodyB:p,pointB:{x:-10,y:-7},stiffness:.001});a.add(l,[p,m]);p=s.polygon(400,100,4,30),m=r.create({pointA:{x:400,y:120},bodyB:p,pointB:{x:-10,y:-10},stiffness:.001,damping:.05});a.add(l,[p,m]);p=s.rectangle(600,200,200,20);var f=s.circle(550,150,20);m=r.create({pointA:{x:600,y:200},bodyB:p,length:0});a.add(l,[p,f,m]);p=s.rectangle(500,400,100,20,{collisionFilter:{group:-1}}),f=s.circle(600,400,20,{collisionFilter:{group:-1}}),m=r.create({bodyA:p,bodyB:f});a.add(l,[p,f,m]);var v=s.polygon(100,400,6,20),g=s.polygon(200,400,1,50);m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-10}});a.add(l,[v,g,m]);v=s.polygon(300,400,4,20),g=s.polygon(400,400,3,30),m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-7},stiffness:.001});a.add(l,[v,g,m]);v=s.polygon(500,400,6,30),g=s.polygon(600,400,7,60),m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-10},stiffness:.001,damping:.1});a.add(l,[v,g,m]),a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var y=i.create(d.canvas),x=o.create(c,{mouse:y,constraint:{angularStiffness:0,render:{visible:!1}}});return a.add(l,x),d.mouse=y,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.constraints.title="Constraints",r.constraints.for=">=0.14.2",e.exports=r.constraints},"/iAh":function(e,t,n){var r=r||{};r.svg=function(){var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Vertices,l=Matter.Svg,d=Matter.Bodies;o.setDecomp(n("Dded"));var u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600}});t.run(m);var f=r.create();if(r.run(f,u),"undefined"!=typeof fetch){var v=function(e,t){return Array.prototype.slice.call(e.querySelectorAll(t))},g=function(e){return fetch(e).then((function(e){return e.text()})).then((function(e){return(new window.DOMParser).parseFromString(e,"image/svg+xml")}))};["./svg/iconmonstr-check-mark-8-icon.svg","./svg/iconmonstr-paperclip-2-icon.svg","./svg/iconmonstr-puzzle-icon.svg","./svg/iconmonstr-user-icon.svg"].forEach((function(e,t){g(e).then((function(e){var n=o.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),r=v(e,"path").map((function(e){return c.scale(l.pathToVertices(e,30),.4,.4)}));s.add(p,d.fromVertices(100+150*t,200+50*t,r,{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0))}))})),g("./svg/svg.svg").then((function(e){var t=o.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),n=v(e,"path").map((function(e){return l.pathToVertices(e,30)}));s.add(p,d.fromVertices(400,80,n,{render:{fillStyle:t,strokeStyle:t,lineWidth:1}},!0))}))}else o.warn("Fetch is not available. Could not load SVG.");s.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var y=a.create(m.canvas),x=i.create(u,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(p,x),m.mouse=y,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.svg.title="Concave SVG Paths",r.svg.for=">0.16.1",e.exports=r.svg},"02te":function(e,t,n){var r=r||{};r.ballPool=function(){try{"undefined"!=typeof MatterWrap?Matter.use("matter-wrap"):Matter.use(n("OPlj"))}catch(e){}var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=r.create();r.run(m,d),o.add(u,[l.rectangle(400,600,1200,50.5,{isStatic:!0,render:{fillStyle:"#060a19"}})]);var f=i.stack(100,0,10,8,10,10,(function(e,t){return l.circle(e,t,a.random(15,30),{restitution:.6,friction:.1})}));o.add(u,[f,l.polygon(200,460,3,60),l.polygon(400,460,5,60),l.rectangle(600,460,80,80)]);var v=c.create(p.canvas),g=s.create(d,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});o.add(u,g),p.mouse=v,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}});for(var y=o.allBodies(u),x=0;x<y.length;x+=1)y[x].plugin.wrap={min:{x:p.bounds.min.x-100,y:p.bounds.min.y},max:{x:p.bounds.max.x+100,y:p.bounds.max.y}};return{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.ballPool.title="Ball Pool",r.ballPool.for=">=0.14.2",e.exports=r.ballPool},"0Aok":function(e,t,n){var r={};e.exports=r;n("Tgw/");var o=n("571F");r.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||o.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,i,a,s,c,l,d,u,p,m,f,v=[],g=0,y=0,x=0;t=t||15;var h=function(e,t,n){var r=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&r?(m=p.x,f=p.y):(m=0,f=0);var o={x:m+e,y:f+t};!r&&p||(p=o),v.push(o),y=m+e,x=f+t}},b=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":y=e.x,x=e.y;break;case"H":y=e.x;break;case"V":x=e.y}h(y,x,e.pathSegType)}};for(r._svgPathToAbsolute(e),a=e.getTotalLength(),l=[],n=0;n<e.pathSegList.numberOfItems;n+=1)l.push(e.pathSegList.getItem(n));for(d=l.concat();g<a;){if((c=l[e.getPathSegAtLength(g)])!=u){for(;d.length&&d[0]!=c;)b(d.shift());u=c}switch(c.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":s=e.getPointAtLength(g),h(s.x,s.y,0)}g+=t}for(n=0,i=d.length;n<i;++n)b(d[n]);return v},r._svgPathToAbsolute=function(e){for(var t,n,r,o,i,a,s=e.pathSegList,c=0,l=0,d=s.numberOfItems,u=0;u<d;++u){var p=s.getItem(u),m=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(m))"x"in p&&(c=p.x),"y"in p&&(l=p.y);else switch("x1"in p&&(r=c+p.x1),"x2"in p&&(i=c+p.x2),"y1"in p&&(o=l+p.y1),"y2"in p&&(a=l+p.y2),"x"in p&&(c+=p.x),"y"in p&&(l+=p.y),m){case"m":s.replaceItem(e.createSVGPathSegMovetoAbs(c,l),u);break;case"l":s.replaceItem(e.createSVGPathSegLinetoAbs(c,l),u);break;case"h":s.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(c),u);break;case"v":s.replaceItem(e.createSVGPathSegLinetoVerticalAbs(l),u);break;case"c":s.replaceItem(e.createSVGPathSegCurvetoCubicAbs(c,l,r,o,i,a),u);break;case"s":s.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(c,l,i,a),u);break;case"q":s.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(c,l,r,o),u);break;case"t":s.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(c,l),u);break;case"a":s.replaceItem(e.createSVGPathSegArcAbs(c,l,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":c=t,l=n}"M"!=m&&"m"!=m||(t=c,n=l)}}},"0kzT":function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("571F");r.create=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r],i={x:o.x,y:o.y,index:r,body:t,isInternal:!1};n.push(i)}return n},r.fromPath=function(e,t){var n=[];return e.replace(/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi,(function(e,t,r){n.push({x:parseFloat(t),y:parseFloat(r)})})),r.create(n,t)},r.centre=function(e){for(var t,n,i,a=r.area(e,!0),s={x:0,y:0},c=0;c<e.length;c++)i=(c+1)%e.length,t=o.cross(e[c],e[i]),n=o.mult(o.add(e[c],e[i]),t),s=o.add(s,n);return o.div(s,6*a)},r.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return o.div(t,e.length)},r.area=function(e,t){for(var n=0,r=e.length-1,o=0;o<e.length;o++)n+=(e[r].x-e[o].x)*(e[r].y+e[o].y),r=o;return t?n/2:Math.abs(n)/2},r.inertia=function(e,t){for(var n,r,i=0,a=0,s=e,c=0;c<s.length;c++)r=(c+1)%s.length,i+=(n=Math.abs(o.cross(s[r],s[c])))*(o.dot(s[r],s[r])+o.dot(s[r],s[c])+o.dot(s[c],s[c])),a+=n;return t/6*(i/a)},r.translate=function(e,t,n){n=void 0!==n?n:1;var r,o=e.length,i=t.x*n,a=t.y*n;for(r=0;r<o;r++)e[r].x+=i,e[r].y+=a;return e},r.rotate=function(e,t,n){if(0!==t){var r,o,i,a,s=Math.cos(t),c=Math.sin(t),l=n.x,d=n.y,u=e.length;for(a=0;a<u;a++)o=(r=e[a]).x-l,i=r.y-d,r.x=l+(o*s-i*c),r.y=d+(o*c+i*s);return e}},r.contains=function(e,t){for(var n,r=t.x,o=t.y,i=e.length,a=e[i-1],s=0;s<i;s++){if(n=e[s],(r-a.x)*(n.y-a.y)+(o-a.y)*(a.x-n.x)>0)return!1;a=n}return!0},r.scale=function(e,t,n,i){if(1===t&&1===n)return e;var a,s;i=i||r.centre(e);for(var c=0;c<e.length;c++)a=e[c],s=o.sub(a,i),e[c].x=i.x+s.x*t,e[c].y=i.y+s.y*n;return e},r.chamfer=function(e,t,n,r,a){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,r=r||2,a=a||14;for(var s=[],c=0;c<e.length;c++){var l=e[c-1>=0?c-1:e.length-1],d=e[c],u=e[(c+1)%e.length],p=t[c<t.length?c:t.length-1];if(0!==p){var m=o.normalise({x:d.y-l.y,y:l.x-d.x}),f=o.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),g=o.mult(i.clone(m),p),y=o.normalise(o.mult(o.add(m,f),.5)),x=o.sub(d,o.mult(y,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),(h=i.clamp(h,r,a))%2==1&&(h+=1);for(var b=Math.acos(o.dot(m,f))/h,M=0;M<h;M++)s.push(o.add(o.rotate(g,b*M),x))}else s.push(d)}return s},r.clockwiseSort=function(e){var t=r.mean(e);return e.sort((function(e,n){return o.angle(t,e)-o.angle(t,n)})),e},r.isConvex=function(e){var t,n,r,o,i=0,a=e.length;if(a<3)return null;for(t=0;t<a;t++)if(r=(t+2)%a,o=(e[n=(t+1)%a].x-e[t].x)*(e[r].y-e[n].y),(o-=(e[n].y-e[t].y)*(e[r].x-e[n].x))<0?i|=1:o>0&&(i|=2),3===i)return!1;return 0!==i||null},r.hull=function(e){var t,n,r=[],i=[];for((e=e.slice(0)).sort((function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y})),n=0;n<e.length;n+=1){for(t=e[n];i.length>=2&&o.cross3(i[i.length-2],i[i.length-1],t)<=0;)i.pop();i.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];r.length>=2&&o.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}return r.pop(),i.pop(),r.concat(i)}},"0mtl":function(e,t,n){var r=r||{};r.catapult=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Constraint,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=Matter.Body,d=Matter.Vector,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(m);var f=n.create();n.run(f,u);var v=l.nextGroup(!0),g=r.stack(250,255,1,6,0,0,(function(e,t){return c.rectangle(e,t,30,30)})),y=c.rectangle(400,520,320,20,{collisionFilter:{group:v}});s.add(p,[g,y,c.rectangle(400,600,800,50.5,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(250,555,20,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(400,535,20,80,{isStatic:!0,collisionFilter:{group:v},render:{fillStyle:"#060a19"}}),c.circle(560,100,50,{density:.005}),o.create({bodyA:y,pointB:d.clone(y.position),stiffness:1,length:0})]);var x=a.create(m.canvas),h=i.create(u,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(p,h),m.mouse=x,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.catapult.title="Catapult",r.catapult.for=">=0.14.2",e.exports=r.catapult},"136C":function(e,t,n){var r=r||{};r.slingshot=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Events,i=Matter.Constraint,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Body,l=Matter.Composite,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=n.create();n.run(f,u);var v=d.rectangle(395,600,815,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),g={density:.004},y=d.polygon(170,450,8,20,g),x=i.create({pointA:{x:170,y:450},bodyB:y,length:.01,damping:.01,stiffness:.05}),h=r.pyramid(500,300,9,10,0,0,(function(e,t){return d.rectangle(e,t,25,40)})),b=d.rectangle(610,250,200,20,{isStatic:!0,render:{fillStyle:"#060a19"}}),M=r.pyramid(550,0,5,10,0,0,(function(e,t){return d.rectangle(e,t,25,40)}));l.add(u.world,[v,h,b,M,y,x]),o.on(u,"afterUpdate",(function(){-1===w.mouse.button&&(y.position.x>190||y.position.y<430)&&(c.getSpeed(y)>45&&c.setSpeed(y,45),y=d.polygon(170,450,7,20,g),l.add(u.world,y),x.bodyB=y)}));var S=s.create(m.canvas),w=a.create(u,{mouse:S,constraint:{stiffness:.2,render:{visible:!1}}});return l.add(p,w),m.mouse=S,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.slingshot.title="Slingshot",r.slingshot.for=">=0.14.2",e.exports=r.slingshot},"2Og8":function(e,t,n){var r={};e.exports=r;var o=n("571F");r._registry={},r.register=function(e){if(r.isPlugin(e)||o.warn("Plugin.register:",r.toString(e),"does not implement all required fields."),e.name in r._registry){var t=r._registry[e.name],n=r.versionParse(e.version).number,i=r.versionParse(t.version).number;n>i?(o.warn("Plugin.register:",r.toString(t),"was upgraded to",r.toString(e)),r._registry[e.name]=e):n<i?o.warn("Plugin.register:",r.toString(t),"can not be downgraded to",r.toString(e)):e!==t&&o.warn("Plugin.register:",r.toString(e),"is already registered to different plugin object")}else r._registry[e.name]=e;return e},r.resolve=function(e){return r._registry[r.dependencyParse(e).name]},r.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},r.isPlugin=function(e){return e&&e.name&&e.version&&e.install},r.isUsed=function(e,t){return e.used.indexOf(t)>-1},r.isFor=function(e,t){var n=e.for&&r.dependencyParse(e.for);return!e.for||t.name===n.name&&r.versionSatisfies(t.version,n.range)},r.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0!==e.uses.length){for(var n=r.dependencies(e),i=o.topologicalSort(n),a=[],s=0;s<i.length;s+=1)if(i[s]!==e.name){var c=r.resolve(i[s]);c?r.isUsed(e,c.name)||(r.isFor(c,e)||(o.warn("Plugin.use:",r.toString(c),"is for",c.for,"but installed on",r.toString(e)+"."),c._warned=!0),c.install?c.install(e):(o.warn("Plugin.use:",r.toString(c),"does not specify an install function."),c._warned=!0),c._warned?(a.push("🔶 "+r.toString(c)),delete c._warned):a.push("✅ "+r.toString(c)),e.used.push(c.name)):a.push("❌ "+i[s])}a.length>0&&o.info(a.join(" "))}else o.warn("Plugin.use:",r.toString(e),"does not specify any dependencies to install.")},r.dependencies=function(e,t){var n=r.dependencyParse(e),i=n.name;if(!(i in(t=t||{}))){e=r.resolve(e)||e,t[i]=o.map(e.uses||[],(function(t){r.isPlugin(t)&&r.register(t);var i=r.dependencyParse(t),a=r.resolve(t);return a&&!r.versionSatisfies(a.version,i.range)?(o.warn("Plugin.dependencies:",r.toString(a),"does not satisfy",r.toString(i),"used by",r.toString(n)+"."),a._warned=!0,e._warned=!0):a||(o.warn("Plugin.dependencies:",r.toString(t),"used by",r.toString(n),"could not be resolved."),e._warned=!0),i.name}));for(var a=0;a<t[i].length;a+=1)r.dependencies(t[i][a],t);return t}},r.dependencyParse=function(e){return o.isString(e)?(/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(e)||o.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}):{name:e.name,range:e.range||e.version}},r.versionParse=function(e){var t=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;t.test(e)||o.warn("Plugin.versionParse:",e,"is not a valid version or range.");var n=t.exec(e),r=Number(n[4]),i=Number(n[5]),a=Number(n[6]);return{isRange:Boolean(n[1]||n[2]),version:n[3],range:e,operator:n[1]||n[2]||"",major:r,minor:i,patch:a,parts:[r,i,a],prerelease:n[7],number:1e8*r+1e4*i+a}},r.versionSatisfies=function(e,t){t=t||"*";var n=r.versionParse(t),o=r.versionParse(e);if(n.isRange){if("*"===n.operator||"*"===e)return!0;if(">"===n.operator)return o.number>n.number;if(">="===n.operator)return o.number>=n.number;if("~"===n.operator)return o.major===n.major&&o.minor===n.minor&&o.patch>=n.patch;if("^"===n.operator)return n.major>0?o.major===n.major&&o.number>=n.number:n.minor>0?o.minor===n.minor&&o.patch>=n.patch:o.patch===n.patch}return e===t||"*"===e}},"2oV2":function(e,t,n){var r=r||{};r.raycasting=function(){var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.Query,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.Events,u=Matter.Vertices,p=Matter.Bodies,m=e.create(),f=m.world,v=t.create({element:document.body,engine:m,options:{width:800,height:600,showAngleIndicator:!0}});t.run(v);var g=r.create();r.run(g,m);var y=i.stack(20,20,12,4,0,0,(function(e,t){switch(Math.round(a.random(0,1))){case 0:return a.random()<.8?p.rectangle(e,t,a.random(20,50),a.random(20,50)):p.rectangle(e,t,a.random(80,120),a.random(20,30));case 1:var n=Math.round(a.random(1,8));return n=3===n?4:n,p.polygon(e,t,n,a.random(20,50))}}));a.setDecomp(n("Dded"));var x=u.fromPath("50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38"),h=p.fromVertices(200,200,x);o.add(f,[y,h,p.rectangle(400,0,800,50,{isStatic:!0}),p.rectangle(400,600,800,50,{isStatic:!0}),p.rectangle(800,300,50,600,{isStatic:!0}),p.rectangle(0,300,50,600,{isStatic:!0})]);var b=[],M={x:400,y:100};d.on(m,"afterUpdate",(function(){var e=w.mouse,t=o.allBodies(m.world),n=e.position||{x:100,y:600};b=s.ray(t,M,n)})),d.on(v,"afterRender",(function(){var e=w.mouse,n=v.context,r=e.position||{x:100,y:600};t.startViewTransform(v),n.beginPath(),n.moveTo(M.x,M.y),n.lineTo(r.x,r.y),b.length>0?n.strokeStyle="#fff":n.strokeStyle="#555",n.lineWidth=.5,n.stroke();for(var o=0;o<b.length;o++){var i=b[o];n.rect(i.bodyA.position.x-4.5,i.bodyA.position.y-4.5,8,8)}n.fillStyle="rgba(255,165,0,0.7)",n.fill(),t.endViewTransform(v)}));var S=l.create(v.canvas),w=c.create(m,{mouse:S,constraint:{stiffness:.2,render:{visible:!1}}});return o.add(f,w),v.mouse=S,t.lookAt(v,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:m,runner:g,render:v,canvas:v.canvas,stop:function(){Matter.Render.stop(v),Matter.Runner.stop(g)}}},r.raycasting.title="Raycasting",r.raycasting.for=">0.16.1",e.exports=r.raycasting},"3Slt":function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("571F"),a=n("Tgw/");r._restingThresh=2,r._restingThreshTangent=Math.sqrt(6),r._positionDampen=.9,r._positionWarming=.8,r._frictionNormalMultiplier=5,r._frictionMaxStatic=Number.MAX_VALUE,r.preSolvePosition=function(e){var t,n,r,o=e.length;for(t=0;t<o;t++)(n=e[t]).isActive&&(r=n.activeContacts.length,n.collision.parentA.totalContacts+=r,n.collision.parentB.totalContacts+=r)},r.solvePosition=function(e,t,n){var o,a,s,c,l,d,u,p,m=r._positionDampen*(n||1),f=i.clamp(t/i._baseDelta,0,1),v=e.length;for(o=0;o<v;o++)(a=e[o]).isActive&&!a.isSensor&&(c=(s=a.collision).parentA,l=s.parentB,d=s.normal,a.separation=d.x*(l.positionImpulse.x+s.penetration.x-c.positionImpulse.x)+d.y*(l.positionImpulse.y+s.penetration.y-c.positionImpulse.y));for(o=0;o<v;o++)(a=e[o]).isActive&&!a.isSensor&&(c=(s=a.collision).parentA,l=s.parentB,d=s.normal,p=a.separation-a.slop*f,(c.isStatic||l.isStatic)&&(p*=2),c.isStatic||c.isSleeping||(u=m/c.totalContacts,c.positionImpulse.x+=d.x*p*u,c.positionImpulse.y+=d.y*p*u),l.isStatic||l.isSleeping||(u=m/l.totalContacts,l.positionImpulse.x-=d.x*p*u,l.positionImpulse.y-=d.y*p*u))},r.postSolvePosition=function(e){for(var t=r._positionWarming,n=e.length,i=o.translate,s=a.update,c=0;c<n;c++){var l=e[c],d=l.positionImpulse,u=d.x,p=d.y,m=l.velocity;if(l.totalContacts=0,0!==u||0!==p){for(var f=0;f<l.parts.length;f++){var v=l.parts[f];i(v.vertices,d),s(v.bounds,v.vertices,m),v.position.x+=u,v.position.y+=p}l.positionPrev.x+=u,l.positionPrev.y+=p,u*m.x+p*m.y<0?(d.x=0,d.y=0):(d.x*=t,d.y*=t)}}},r.preSolveVelocity=function(e){var t,n,r=e.length;for(t=0;t<r;t++){var o=e[t];if(o.isActive&&!o.isSensor){var i=o.activeContacts,a=i.length,s=o.collision,c=s.parentA,l=s.parentB,d=s.normal,u=s.tangent;for(n=0;n<a;n++){var p=i[n],m=p.vertex,f=p.normalImpulse,v=p.tangentImpulse;if(0!==f||0!==v){var g=d.x*f+u.x*v,y=d.y*f+u.y*v;c.isStatic||c.isSleeping||(c.positionPrev.x+=g*c.inverseMass,c.positionPrev.y+=y*c.inverseMass,c.anglePrev+=c.inverseInertia*((m.x-c.position.x)*y-(m.y-c.position.y)*g)),l.isStatic||l.isSleeping||(l.positionPrev.x-=g*l.inverseMass,l.positionPrev.y-=y*l.inverseMass,l.anglePrev-=l.inverseInertia*((m.x-l.position.x)*y-(m.y-l.position.y)*g))}}}}},r.solveVelocity=function(e,t){var n,o,a,s,c=t/i._baseDelta,l=c*c*c,d=-r._restingThresh*c,u=r._restingThreshTangent,p=r._frictionNormalMultiplier*c,m=r._frictionMaxStatic,f=e.length;for(a=0;a<f;a++){var v=e[a];if(v.isActive&&!v.isSensor){var g=v.collision,y=g.parentA,x=g.parentB,h=y.velocity,b=x.velocity,M=g.normal.x,S=g.normal.y,w=g.tangent.x,C=g.tangent.y,A=v.activeContacts,B=A.length,k=1/B,R=y.inverseMass+x.inverseMass,P=v.friction*v.frictionStatic*p;for(h.x=y.position.x-y.positionPrev.x,h.y=y.position.y-y.positionPrev.y,b.x=x.position.x-x.positionPrev.x,b.y=x.position.y-x.positionPrev.y,y.angularVelocity=y.angle-y.anglePrev,x.angularVelocity=x.angle-x.anglePrev,s=0;s<B;s++){var I=A[s],_=I.vertex,E=_.x-y.position.x,T=_.y-y.position.y,F=_.x-x.position.x,V=_.y-x.position.y,D=h.x-T*y.angularVelocity,L=h.y+E*y.angularVelocity,O=D-(b.x-V*x.angularVelocity),W=L-(b.y+F*x.angularVelocity),j=M*O+S*W,q=w*O+C*W,H=v.separation+j,U=Math.min(H,1),G=(U=H<0?0:U)*P;q<-G||q>G?(o=q>0?q:-q,(n=v.friction*(q>0?1:-1)*l)<-o?n=-o:n>o&&(n=o)):(n=q,o=m);var N=E*S-T*M,z=F*S-V*M,Z=k/(R+y.inverseInertia*N*N+x.inverseInertia*z*z),Q=(1+v.restitution)*j*Z;if(n*=Z,j<d)I.normalImpulse=0;else{var X=I.normalImpulse;I.normalImpulse+=Q,I.normalImpulse>0&&(I.normalImpulse=0),Q=I.normalImpulse-X}if(q<-u||q>u)I.tangentImpulse=0;else{var Y=I.tangentImpulse;I.tangentImpulse+=n,I.tangentImpulse<-o&&(I.tangentImpulse=-o),I.tangentImpulse>o&&(I.tangentImpulse=o),n=I.tangentImpulse-Y}var J=M*Q+w*n,K=S*Q+C*n;y.isStatic||y.isSleeping||(y.positionPrev.x+=J*y.inverseMass,y.positionPrev.y+=K*y.inverseMass,y.anglePrev+=(E*K-T*J)*y.inverseInertia),x.isStatic||x.isSleeping||(x.positionPrev.x-=J*x.inverseMass,x.positionPrev.y-=K*x.inverseMass,x.anglePrev-=(F*K-V*J)*x.inverseInertia)}}}}},"4XQC":function(e,t,n){var r=r||{};r.staticFriction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.Events,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showVelocity:!0}});t.run(p);var m=n.create();n.run(m,d);var f=l.rectangle(400,500,200,60,{isStatic:!0,chamfer:10,render:{fillStyle:"#060a19"}}),v=o.stack(350,170,1,6,0,0,(function(e,t){return l.rectangle(e,t,100,50,{slop:.5,friction:1,frictionStatic:1/0})}));c.add(u,[f,v,l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]),i.on(d,"beforeUpdate",(function(){if(!(d.timing.timestamp<1500)){var e=400+100*Math.sin(.001*(d.timing.timestamp-1500));"0.18.0"===Matter.version&&r.setVelocity(f,{x:e-f.position.x,y:0}),r.setPosition(f,{x:e,y:f.position.y},!0)}}));var g=s.create(p.canvas),y=a.create(d,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,y),p.mouse=g,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.staticFriction.title="Static Friction",r.staticFriction.for=">=0.14.2",e.exports=r.staticFriction},"4d8i":function(e,t,n){var r={};e.exports=r;var o=n("yTB+"),i=n("nIFq"),a=n("571F");!function(){var e,t,n;("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),e)||(e=function(e){n=setTimeout((function(){e(a.now())}),1e3/60)},t=function(){clearTimeout(n)});r.create=function(e){var t=a.extend({fps:60,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,frameRequestId:null,isFixed:!1,enabled:!0},e);return t.delta=t.delta||1e3/t.fps,t.deltaMin=t.deltaMin||1e3/t.fps,t.deltaMax=t.deltaMax||1e3/(.5*t.fps),t.fps=1e3/t.delta,t},r.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=r.create()),function o(i){t.frameRequestId=e(o),i&&t.enabled&&r.tick(t,n,i)}(),t},r.tick=function(e,t,n){var r,a=t.timing;e.isFixed?r=e.delta:(r=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(r),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),r=(r=(r=Math.min.apply(null,e.deltaHistory))<e.deltaMin?e.deltaMin:r)>e.deltaMax?e.deltaMax:r,e.delta=r);var s={timestamp:a.timestamp};o.trigger(e,"beforeTick",s),e.frameCounter+=1,n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),o.trigger(e,"tick",s),o.trigger(e,"beforeUpdate",s),i.update(t,r),o.trigger(e,"afterUpdate",s),o.trigger(e,"afterTick",s)},r.stop=function(e){t(e.frameRequestId)},r.start=function(e,t){r.run(e,t)}}()},"52dP":function(e,t,n){var r=r||{};r.terrain=function(){var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Query,d=Matter.Svg,u=Matter.Bodies;i.setDecomp(n("Dded"));var p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600}});t.run(f);var v,g=r.create();if(r.run(g,p),"undefined"!=typeof fetch){(v="./svg/terrain.svg",fetch(v).then((function(e){return e.text()})).then((function(e){return(new window.DOMParser).parseFromString(e,"image/svg+xml")}))).then((function(e){var t=function(e,t){return Array.prototype.slice.call(e.querySelectorAll(t))}(e,"path").map((function(e){return d.pathToVertices(e,30)})),n=u.fromVertices(400,350,t,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#060a19",lineWidth:1}},!0);c.add(m,n);var r={frictionAir:0,friction:1e-4,restitution:.6};c.add(m,o.stack(80,100,20,20,10,10,(function(e,t){if(0===l.point([n],{x:e,y:t}).length)return u.polygon(e,t,5,12,r)})))}))}else i.warn("Fetch is not available. Could not load SVG.");var y=s.create(f.canvas),x=a.create(p,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(m,x),f.mouse=y,t.lookAt(f,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:p,runner:g,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(g)}}},r.terrain.title="Terrain",r.terrain.for=">0.16.1",e.exports=r.terrain},"571F":function(e,t){var n={};e.exports=n,function(){n._baseDelta=1e3/60,n._nextId=0,n._seed=0,n._nowStartTime=+new Date,n._warnedOnce={},n._decomp=null,n.extend=function(e,t){var r,o;"boolean"==typeof t?(r=2,o=t):(r=1,o=!0);for(var i=r;i<arguments.length;i++){var a=arguments[i];if(a)for(var s in a)o&&a[s]&&a[s].constructor===Object?e[s]&&e[s].constructor!==Object?e[s]=a[s]:(e[s]=e[s]||{},n.extend(e[s],o,a[s])):e[s]=a[s]}return e},n.clone=function(e,t){return n.extend({},t,e)},n.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},n.values=function(e){var t=[];if(Object.keys){for(var n=Object.keys(e),r=0;r<n.length;r++)t.push(e[n[r]]);return t}for(var o in e)t.push(e[o]);return t},n.get=function(e,t,n,r){t=t.split(".").slice(n,r);for(var o=0;o<t.length;o+=1)e=e[t[o]];return e},n.set=function(e,t,r,o,i){var a=t.split(".").slice(o,i);return n.get(e,t,0,-1)[a[a.length-1]]=r,r},n.shuffle=function(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(n.random()*(t+1)),o=e[t];e[t]=e[r],e[r]=o}return e},n.choose=function(e){return e[Math.floor(n.random()*e.length)]},n.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},n.isString=function(e){return"[object String]"===toString.call(e)},n.clamp=function(e,t,n){return e<t?t:e>n?n:e},n.sign=function(e){return e<0?-1:1},n.now=function(){if("undefined"!=typeof window&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-n._nowStartTime},n.random=function(t,n){return n=void 0!==n?n:1,(t=void 0!==t?t:0)+e()*(n-t)};var e=function(){return n._seed=(9301*n._seed+49297)%233280,n._seed/233280};n.colorToNumber=function(e){return 3==(e=e.replace("#","")).length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},n.logLevel=1,n.log=function(){console&&n.logLevel>0&&n.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.info=function(){console&&n.logLevel>0&&n.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.warn=function(){console&&n.logLevel>0&&n.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.warnOnce=function(){var e=Array.prototype.slice.call(arguments).join(" ");n._warnedOnce[e]||(n.warn(e),n._warnedOnce[e]=!0)},n.deprecated=function(e,t,r){e[t]=n.chain((function(){n.warnOnce("🔅 deprecated 🔅",r)}),e[t])},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},n.map=function(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n},n.topologicalSort=function(e){var t=[],r=[],o=[];for(var i in e)r[i]||o[i]||n._topologicalSort(i,r,o,e,t);return t},n._topologicalSort=function(e,t,r,o,i){var a=o[e]||[];r[e]=!0;for(var s=0;s<a.length;s+=1){var c=a[s];r[c]||(t[c]||n._topologicalSort(c,t,r,o,i))}r[e]=!1,t[e]=!0,i.push(e)},n.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var r=function(){for(var t,n=new Array(arguments.length),r=0,o=arguments.length;r<o;r++)n[r]=arguments[r];for(r=0;r<e.length;r+=1){var i=e[r].apply(t,n);void 0!==i&&(t=i)}return t};return r._chained=e,r},n.chainPathBefore=function(e,t,r){return n.set(e,t,n.chain(r,n.get(e,t)))},n.chainPathAfter=function(e,t,r){return n.set(e,t,n.chain(n.get(e,t),r))},n.setDecomp=function(e){n._decomp=e},n.getDecomp=function(){var e=n._decomp;try{e||"undefined"==typeof window||(e=window.decomp),e||"undefined"==typeof global||(e=global.decomp)}catch(t){e=null}return e}}()},"5ocS":function(e,t,n){var r=r||{};r.pyramid=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.pyramid(100,260,15,10,0,0,(function(e,t){return s.rectangle(e,t,40,40)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),s.rectangle(400,605,800,50,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.pyramid.title="Pyramid",r.pyramid.for=">=0.14.2",e.exports=r.pyramid},"6IAi":function(e,t,n){var r=r||{};r.airFriction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.Composite,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(200,100,60,60,{frictionAir:.001}),a.rectangle(400,100,60,60,{frictionAir:.05}),a.rectangle(600,100,60,60,{frictionAir:.1}),a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.airFriction.title="Air Friction",r.airFriction.for=">=0.14.2",e.exports=r.airFriction},"71Xj":function(e,t,n){var r=n("akk5");e.exports={demo:function(e,t){var n=r.Demo.create({toolbar:{title:"matter-js"+(t?" ・ dev":""),url:"https://github.com/liabru/matter-js",reset:!0,source:!0,inspector:!0,tools:!0,fullscreen:!0,exampleSelect:!0},tools:{inspector:!0,gui:!0},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!0,startExample:"mixed",examples:e});if(window.MatterDemoInstance=n,document.body.appendChild(n.dom.root),document.title="Matter.js Demo"+(t?" ・ Dev":""),t){var o=n.dom.buttonSource,i=o.cloneNode(!0);i.textContent="⎄",i.title="Compare",i.href="?compare",i.target="",i.className="matter-btn matter-btn-compare",i.addEventListener("click",(function(e){window.location="?compare#"+n.example.id,e.preventDefault()})),o.parentNode.insertBefore(i,o.nextSibling),Matter.before("Render.create",(function(e){e.options.showDebug=!0}))}r.Demo.start(n)}}},"74MQ":function(e,t,n){var r=r||{};r.doublePendulum=function(){var e=Matter.Engine,t=Matter.Events,n=Matter.Render,r=Matter.Runner,o=Matter.Body,i=Matter.Composite,a=Matter.Composites,s=Matter.Constraint,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.Bodies,u=Matter.Vector,p=e.create(),m=p.world,f=n.create({element:document.body,engine:p,options:{width:800,height:600,wireframes:!1}});n.run(f);var v=r.create();r.run(v,p);var g=o.nextGroup(!0),y=a.stack(350,160,2,1,-20,0,(function(e,t){return d.rectangle(e,t,200,25,{collisionFilter:{group:g},frictionAir:0,chamfer:5,render:{fillStyle:"transparent",lineWidth:1}})}));p.gravity.scale=.002,a.chain(y,.45,0,-.45,0,{stiffness:.9,length:0,angularStiffness:.7,render:{strokeStyle:"#4a485b"}}),i.add(y,s.create({bodyB:y.bodies[0],pointB:{x:-84,y:0},pointA:{x:y.bodies[0].position.x-84,y:y.bodies[0].position.y},stiffness:.9,length:0,render:{strokeStyle:"#4a485b"}}));var x=y.bodies[1];o.rotate(x,.3*-Math.PI,{x:x.position.x-100,y:x.position.y}),i.add(m,y);var h=[];t.on(f,"afterRender",(function(){h.unshift({position:u.clone(x.position),speed:x.speed}),n.startViewTransform(f),f.context.globalAlpha=.7;for(var e=0;e<h.length;e+=1){var t=h[e].position,r=h[e].speed,o=250+Math.round(170*(1-Math.min(1,r/10)));f.context.fillStyle="hsl("+o+", 100%, 55%)",f.context.fillRect(t.x,t.y,2,2)}f.context.globalAlpha=1,n.endViewTransform(f),h.length>2e3&&h.pop()}));var b=l.create(f.canvas),M=c.create(p,{mouse:b,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(m,M),f.mouse=b,n.lookAt(f,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.doublePendulum.title="Double Pendulum",r.doublePendulum.for=">0.16.1",e.exports=r.doublePendulum},"7MJU":function(e,t,n){var r=r||{};r.gravity=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showVelocity:!0,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50.5,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]),l.gravity.y=-1;var m=r.stack(50,120,11,5,0,0,(function(e,t){switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(20,50),o.random(20,50)):c.rectangle(e,t,o.random(80,120),o.random(20,30));case 1:return c.polygon(e,t,Math.round(o.random(1,8)),o.random(20,50))}}));s.add(d,m);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.gravity.title="Reverse Gravity",r.gravity.for=">0.16.1",e.exports=r.gravity},"9K63":function(e,t){var n={};e.exports=n,n.create=function(e){return{vertex:e,normalImpulse:0,tangentImpulse:0}}},"9Nbg":function(e,t,n){var r={};e.exports=r;var o=n("wAS/"),i=n("ga9t"),a=n("571F"),s=n("IbIC"),c=n("oT59"),l=a.deprecated;r.stack=function(e,t,n,r,i,a,c){for(var l,d=o.create({label:"Stack"}),u=e,p=t,m=0,f=0;f<r;f++){for(var v=0,g=0;g<n;g++){var y=c(u,p,g,f,l,m);if(y){var x=y.bounds.max.y-y.bounds.min.y,h=y.bounds.max.x-y.bounds.min.x;x>v&&(v=x),s.translate(y,{x:.5*h,y:.5*x}),u=y.bounds.max.x+i,o.addBody(d,y),l=y,m+=1}else u+=i}p+=v+a,u=e}return d},r.chain=function(e,t,n,r,s,c){for(var l=e.bodies,d=1;d<l.length;d++){var u=l[d-1],p=l[d],m=u.bounds.max.y-u.bounds.min.y,f=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,g={bodyA:u,pointA:{x:f*t,y:m*n},bodyB:p,pointB:{x:(p.bounds.max.x-p.bounds.min.x)*r,y:v*s}},y=a.extend(g,c);o.addConstraint(e,i.create(y))}return e.label+=" Chain",e},r.mesh=function(e,t,n,r,s){var c,l,d,u,p,m=e.bodies;for(c=0;c<n;c++){for(l=1;l<t;l++)d=m[l-1+c*t],u=m[l+c*t],o.addConstraint(e,i.create(a.extend({bodyA:d,bodyB:u},s)));if(c>0)for(l=0;l<t;l++)d=m[l+(c-1)*t],u=m[l+c*t],o.addConstraint(e,i.create(a.extend({bodyA:d,bodyB:u},s))),r&&l>0&&(p=m[l-1+(c-1)*t],o.addConstraint(e,i.create(a.extend({bodyA:p,bodyB:u},s)))),r&&l<t-1&&(p=m[l+1+(c-1)*t],o.addConstraint(e,i.create(a.extend({bodyA:p,bodyB:u},s))))}return e.label+=" Mesh",e},r.pyramid=function(e,t,n,o,i,a,c){return r.stack(e,t,n,o,i,a,(function(t,r,a,l,d,u){var p=Math.min(o,Math.ceil(n/2)),m=d?d.bounds.max.x-d.bounds.min.x:0;if(!(l>p||a<(l=p-l)||a>n-1-l))return 1===u&&s.translate(d,{x:(a+(n%2==1?1:-1))*m,y:0}),c(e+(d?a*m:0)+a*i,r,a,l,d,u)}))},r.newtonsCradle=function(e,t,n,r,a){for(var s=o.create({label:"Newtons Cradle"}),l=0;l<n;l++){var d=c.circle(e+l*(1.9*r),t+a,r,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=i.create({pointA:{x:e+l*(1.9*r),y:t},bodyB:d});o.addBody(s,d),o.addConstraint(s,u)}return s},l(r,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),r.car=function(e,t,n,r,a){var l=s.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=o.create({label:"Car"}),m=c.rectangle(e,t,n,r,{collisionFilter:{group:l},chamfer:{radius:.5*r},density:2e-4}),f=c.circle(e+d,t+0,a,{collisionFilter:{group:l},friction:.8}),v=c.circle(e+u,t+0,a,{collisionFilter:{group:l},friction:.8}),g=i.create({bodyB:m,pointB:{x:d,y:0},bodyA:f,stiffness:1,length:0}),y=i.create({bodyB:m,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return o.addBody(p,m),o.addBody(p,f),o.addBody(p,v),o.addConstraint(p,g),o.addConstraint(p,y),p},l(r,"car","Composites.car ➤ moved to car example"),r.softBody=function(e,t,n,o,i,s,l,d,u,p){u=a.extend({inertia:1/0},u),p=a.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var m=r.stack(e,t,n,o,i,s,(function(e,t){return c.circle(e,t,d,u)}));return r.mesh(m,n,o,l,p),m.label="Soft Body",m},l(r,"softBody","Composites.softBody ➤ moved to softBody and cloth examples")},C3Ti:function(e,t,n){var r=r||{};r.avalanche=function(){try{"undefined"!=typeof MatterWrap?Matter.use("matter-wrap"):Matter.use(n("OPlj"))}catch(e){}var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=r.create();r.run(m,d);var f=i.stack(20,20,20,5,0,0,(function(e,t){return l.circle(e,t,a.random(10,20),{friction:1e-5,restitution:.5,density:.001})}));o.add(u,f),o.add(u,[l.rectangle(200,150,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),l.rectangle(500,350,700,20,{isStatic:!0,angle:.06*-Math.PI,render:{fillStyle:"#060a19"}}),l.rectangle(340,580,700,20,{isStatic:!0,angle:.04*Math.PI,render:{fillStyle:"#060a19"}})]);var v=c.create(p.canvas),g=s.create(d,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});o.add(u,g),p.mouse=v,t.lookAt(p,o.allBodies(u));for(var y=0;y<f.bodies.length;y+=1)f.bodies[y].plugin.wrap={min:{x:p.bounds.min.x,y:p.bounds.min.y},max:{x:p.bounds.max.x,y:p.bounds.max.y}};return{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.avalanche.title="Avalanche",r.avalanche.for=">=0.14.2",e.exports=r.avalanche},"C6Q+":function(e,t,n){var r=r||{};r.events=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.Composite,a=Matter.Composites,s=Matter.Common,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,wireframes:!1}});t.run(m);var f=n.create();n.run(f,u),o.on(p,"afterAdd",(function(e){}));var v=s.now();o.on(u,"beforeUpdate",(function(e){var t=e.source;s.now()-v>=5e3&&(x(t),v=s.now())})),o.on(u,"collisionStart",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#333",r.bodyB.render.fillStyle="#333"}})),o.on(u,"collisionActive",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#333",r.bodyB.render.fillStyle="#333"}})),o.on(u,"collisionEnd",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#222",r.bodyB.render.fillStyle="#222"}}));var g={fillStyle:"#222"};i.add(p,[d.rectangle(400,0,800,50,{isStatic:!0,render:g}),d.rectangle(400,600,800,50,{isStatic:!0,render:g}),d.rectangle(800,300,50,600,{isStatic:!0,render:g}),d.rectangle(0,300,50,600,{isStatic:!0,render:g})]);var y=a.stack(70,100,9,4,50,50,(function(e,t){return d.circle(e,t,15,{restitution:1,render:g})}));i.add(p,y);var x=function(e){for(var t=1e3/60/e.timing.lastDelta,n=i.allBodies(e.world),o=0;o<n.length;o++){var a=n[o];if(!a.isStatic&&a.position.y>=500){var c=.03*a.mass*t;r.applyForce(a,a.position,{x:(c+s.random()*c)*s.choose([1,-1]),y:-c+s.random()*-c})}}},h=l.create(m.canvas),b=c.create(u,{mouse:h,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(p,b),m.mouse=h,o.on(b,"mousedown",(function(e){var t=e.mouse.position;console.log("mousedown at "+t.x+" "+t.y),x(u)})),o.on(b,"mouseup",(function(e){var t=e.mouse.position;console.log("mouseup at "+t.x+" "+t.y)})),o.on(b,"startdrag",(function(e){console.log("startdrag",e)})),o.on(b,"enddrag",(function(e){console.log("enddrag",e)})),t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.events.title="Events",r.events.for=">=0.14.2",e.exports=r.events},Czbd:function(e,t,n){var r=r||{};r.softBody=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,o=(Matter.Composites,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!1}});t.run(d);var u=n.create();n.run(u,c);var p={friction:.05,frictionStatic:.1,render:{visible:!0}};a.add(l,[r.softBody.softBody(250,100,5,5,0,0,!0,18,p),r.softBody.softBody(400,300,8,3,0,0,!0,15,p),r.softBody.softBody(250,400,4,4,0,0,!0,15,p),s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.9,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.softBody.title="Soft Body",r.softBody.for=">=0.14.2",r.softBody.softBody=function(e,t,n,r,o,i,a,s,c,l){var d=Matter.Common,u=Matter.Composites,p=Matter.Bodies;c=d.extend({inertia:1/0},c),l=d.extend({stiffness:.2,render:{type:"line",anchors:!1}},l);var m=u.stack(e,t,n,r,o,i,(function(e,t){return p.circle(e,t,s,c)}));return u.mesh(m,n,r,a,l),m.label="Soft Body",m},e.exports=r.softBody},DeYi:function(e,t,n){var r=r||{};r.friction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.Composite,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]),i.add(c,[a.rectangle(300,180,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,70,40,40,{friction:.001})]),i.add(c,[a.rectangle(300,350,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,250,40,40,{friction:5e-4})]),i.add(c,[a.rectangle(300,520,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,430,40,40,{friction:0})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.friction.title="Friction",r.friction.for=">=0.14.2",e.exports=r.friction},DqtB:function(e,t,n){var r={};e.exports=r;var o=n("Z/YF"),i=n("571F").deprecated;r.collides=function(e,t){return o.collides(e,t)},i(r,"collides","SAT.collides ➤ replaced by Collision.collides")},EUdY:function(e,t,n){var r=r||{};r.stress=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showStats:!0,showPerformance:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(90,50,18,15,0,0,(function(e,t){return s.rectangle(e,t,35,35)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stress.title="Stress",r.stress.for=">=0.14.2",e.exports=r.stress},H5X8:function(e,t,n){var r=r||{};r.stress3=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create({positionIterations:10,velocityIterations:10}),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showStats:!0,showPerformance:!0}});t.run(u);var p=n.create({isFixed:!0});n.run(p,l);var m=.3,f=r.stack(40,40,38,18,0,0,(function(e,t){var n=Math.round(o.random(1,8));switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50)*m,o.random(25,50)*m):c.rectangle(e,t,o.random(80,120)*m,o.random(25,30)*m);case 1:return c.polygon(e,t,n,o.random(25,50)*m)}}));s.add(d,f),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var v=a.create(u.canvas),g=i.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.stress3.title="Stress 3",r.stress3.for=">=0.14.2",e.exports=r.stress3},I5nt:function(e,t,n){var r={};e.exports=r;var o=n("571F");r.create=function(e){var t={};return e||o.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=parseInt(t.element.getAttribute("data-pixel-ratio"),10)||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},r.setElement(t,t.element),t},r.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},r.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},r.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},r.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},r._getRelativeMousePosition=function(e,t,n){var r,o,i=t.getBoundingClientRect(),a=document.documentElement||document.body.parentNode||document.body,s=void 0!==window.pageXOffset?window.pageXOffset:a.scrollLeft,c=void 0!==window.pageYOffset?window.pageYOffset:a.scrollTop,l=e.changedTouches;return l?(r=l[0].pageX-i.left-s,o=l[0].pageY-i.top-c):(r=e.pageX-i.left-s,o=e.pageY-i.top-c),{x:r/(t.clientWidth/(t.width||t.clientWidth)*n),y:o/(t.clientHeight/(t.height||t.clientHeight)*n)}}},IOLg:function(e,t,n){var r=r||{};r.concave=function(){var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Vertices,d=Matter.Bodies;i.setDecomp(n("Dded"));var u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600}});t.run(m);var f=r.create();r.run(f,u),c.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var v=l.fromPath("40 0 40 20 100 20 100 80 40 80 40 100 0 50"),g=l.fromPath("100 0 75 50 100 100 25 100 0 50 25 0"),y=l.fromPath("50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38"),x=l.fromPath("35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7"),h=o.stack(50,50,6,4,10,10,(function(e,t){var n=i.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]);return d.fromVertices(e,t,i.choose([v,g,y,x]),{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0)}));c.add(p,h);var b=s.create(m.canvas),M=a.create(u,{mouse:b,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(p,M),m.mouse=b,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.concave.title="Concave",r.concave.for=">0.16.1",e.exports=r.concave},IbIC:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm"),a=n("yw0d"),s=n("571F"),c=n("Tgw/"),l=n("JKEF");!function(){r._timeCorrection=!0,r._inertiaScale=4,r._nextCollidingGroupId=1,r._nextNonCollidingGroupId=-1,r._nextCategory=1,r._baseDelta=1e3/60,r.create=function(t){var n={id:s.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:o.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,isSensor:!1,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,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:1e3/60,_original:null},r=s.extend(n,t);return e(r,t),r},r.nextGroup=function(e){return e?r._nextNonCollidingGroupId--:r._nextCollidingGroupId++},r.nextCategory=function(){return r._nextCategory=r._nextCategory<<1,r._nextCategory};var e=function(e,t){t=t||{},r.set(e,{bounds:e.bounds||c.create(e.vertices),positionPrev:e.positionPrev||i.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),o.rotate(e.vertices,e.angle,e.position),l.rotate(e.axes,e.angle),c.update(e.bounds,e.vertices,e.velocity),r.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#14151f":s.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),a=e.isStatic?"#555":"#ccc",d=e.isStatic&&null===e.render.fillStyle?1:0;e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||a,e.render.lineWidth=e.render.lineWidth||d,e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};r.set=function(e,t,n){var o;for(o in"string"==typeof t&&(o=t,(t={})[o]=n),t)if(Object.prototype.hasOwnProperty.call(t,o))switch(n=t[o],o){case"isStatic":r.setStatic(e,n);break;case"isSleeping":a.set(e,n);break;case"mass":r.setMass(e,n);break;case"density":r.setDensity(e,n);break;case"inertia":r.setInertia(e,n);break;case"vertices":r.setVertices(e,n);break;case"position":r.setPosition(e,n);break;case"angle":r.setAngle(e,n);break;case"velocity":r.setVelocity(e,n);break;case"angularVelocity":r.setAngularVelocity(e,n);break;case"speed":r.setSpeed(e,n);break;case"angularSpeed":r.setAngularSpeed(e,n);break;case"parts":r.setParts(e,n);break;case"centre":r.setCentre(e,n);break;default:e[o]=n}},r.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var r=e.parts[n];r.isStatic=t,t?(r._original={restitution:r.restitution,friction:r.friction,mass:r.mass,inertia:r.inertia,density:r.density,inverseMass:r.inverseMass,inverseInertia:r.inverseInertia},r.restitution=0,r.friction=1,r.mass=r.inertia=r.density=1/0,r.inverseMass=r.inverseInertia=0,r.positionPrev.x=r.position.x,r.positionPrev.y=r.position.y,r.anglePrev=r.angle,r.angularVelocity=0,r.speed=0,r.angularSpeed=0,r.motion=0):r._original&&(r.restitution=r._original.restitution,r.friction=r._original.friction,r.mass=r._original.mass,r.inertia=r._original.inertia,r.density=r._original.density,r.inverseMass=r._original.inverseMass,r.inverseInertia=r._original.inverseInertia,r._original=null)}},r.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},r.setDensity=function(e,t){r.setMass(e,t*e.area),e.density=t},r.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},r.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=o.create(t,e),e.axes=l.fromVertices(e.vertices),e.area=o.area(e.vertices),r.setMass(e,e.density*e.area);var n=o.centre(e.vertices);o.translate(e.vertices,n,-1),r.setInertia(e,r._inertiaScale*o.inertia(e.vertices,e.mass)),o.translate(e.vertices,e.position),c.update(e.bounds,e.vertices,e.velocity)},r.setParts=function(e,t,n){var i;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,i=0;i<t.length;i++){var a=t[i];a!==e&&(a.parent=e,e.parts.push(a))}if(1!==e.parts.length){if(n=void 0===n||n){var s=[];for(i=0;i<t.length;i++)s=s.concat(t[i].vertices);o.clockwiseSort(s);var c=o.hull(s),l=o.centre(c);r.setVertices(e,c),o.translate(e.vertices,l)}var d=r._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,r.setMass(e,d.mass),r.setInertia(e,d.inertia),r.setPosition(e,d.centre)}},r.setCentre=function(e,t,n){n?(e.positionPrev.x+=t.x,e.positionPrev.y+=t.y,e.position.x+=t.x,e.position.y+=t.y):(e.positionPrev.x=t.x-(e.position.x-e.positionPrev.x),e.positionPrev.y=t.y-(e.position.y-e.positionPrev.y),e.position.x=t.x,e.position.y=t.y)},r.setPosition=function(e,t,n){var r=i.sub(t,e.position);n?(e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.velocity.x=r.x,e.velocity.y=r.y,e.speed=i.magnitude(r)):(e.positionPrev.x+=r.x,e.positionPrev.y+=r.y);for(var a=0;a<e.parts.length;a++){var s=e.parts[a];s.position.x+=r.x,s.position.y+=r.y,o.translate(s.vertices,r),c.update(s.bounds,s.vertices,e.velocity)}},r.setAngle=function(e,t,n){var r=t-e.angle;n?(e.anglePrev=e.angle,e.angularVelocity=r,e.angularSpeed=Math.abs(r)):e.anglePrev+=r;for(var a=0;a<e.parts.length;a++){var s=e.parts[a];s.angle+=r,o.rotate(s.vertices,r,e.position),l.rotate(s.axes,r),c.update(s.bounds,s.vertices,e.velocity),a>0&&i.rotateAbout(s.position,r,e.position,s.position)}},r.setVelocity=function(e,t){var n=e.deltaTime/r._baseDelta;e.positionPrev.x=e.position.x-t.x*n,e.positionPrev.y=e.position.y-t.y*n,e.velocity.x=(e.position.x-e.positionPrev.x)/n,e.velocity.y=(e.position.y-e.positionPrev.y)/n,e.speed=i.magnitude(e.velocity)},r.getVelocity=function(e){var t=r._baseDelta/e.deltaTime;return{x:(e.position.x-e.positionPrev.x)*t,y:(e.position.y-e.positionPrev.y)*t}},r.getSpeed=function(e){return i.magnitude(r.getVelocity(e))},r.setSpeed=function(e,t){r.setVelocity(e,i.mult(i.normalise(r.getVelocity(e)),t))},r.setAngularVelocity=function(e,t){var n=e.deltaTime/r._baseDelta;e.anglePrev=e.angle-t*n,e.angularVelocity=(e.angle-e.anglePrev)/n,e.angularSpeed=Math.abs(e.angularVelocity)},r.getAngularVelocity=function(e){return(e.angle-e.anglePrev)*r._baseDelta/e.deltaTime},r.getAngularSpeed=function(e){return Math.abs(r.getAngularVelocity(e))},r.setAngularSpeed=function(e,t){r.setAngularVelocity(e,s.sign(r.getAngularVelocity(e))*t)},r.translate=function(e,t,n){r.setPosition(e,i.add(e.position,t),n)},r.rotate=function(e,t,n,o){if(n){var i=Math.cos(t),a=Math.sin(t),s=e.position.x-n.x,c=e.position.y-n.y;r.setPosition(e,{x:n.x+(s*i-c*a),y:n.y+(s*a+c*i)},o),r.setAngle(e,e.angle+t,o)}else r.setAngle(e,e.angle+t,o)},r.scale=function(e,t,n,i){var a=0,s=0;i=i||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];o.scale(u.vertices,t,n,i),u.axes=l.fromVertices(u.vertices),u.area=o.area(u.vertices),r.setMass(u,e.density*u.area),o.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),r.setInertia(u,r._inertiaScale*o.inertia(u.vertices,u.mass)),o.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(a+=u.area,s+=u.inertia),u.position.x=i.x+(u.position.x-i.x)*t,u.position.y=i.y+(u.position.y-i.y)*n,c.update(u.bounds,u.vertices,e.velocity)}e.parts.length>1&&(e.area=a,e.isStatic||(r.setMass(e,e.density*a),r.setInertia(e,s))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},r.update=function(e,t){var n=(t=(void 0!==t?t:1e3/60)*e.timeScale)*t,a=r._timeCorrection?t/(e.deltaTime||t):1,d=1-e.frictionAir*(t/s._baseDelta),u=(e.position.x-e.positionPrev.x)*a,p=(e.position.y-e.positionPrev.y)*a;e.velocity.x=u*d+e.force.x/e.mass*n,e.velocity.y=p*d+e.force.y/e.mass*n,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.deltaTime=t,e.angularVelocity=(e.angle-e.anglePrev)*d*a+e.torque/e.inertia*n,e.anglePrev=e.angle,e.angle+=e.angularVelocity;for(var m=0;m<e.parts.length;m++){var f=e.parts[m];o.translate(f.vertices,e.velocity),m>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(o.rotate(f.vertices,e.angularVelocity,e.position),l.rotate(f.axes,e.angularVelocity),m>0&&i.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),c.update(f.bounds,f.vertices,e.velocity)}},r.updateVelocities=function(e){var t=r._baseDelta/e.deltaTime,n=e.velocity;n.x=(e.position.x-e.positionPrev.x)*t,n.y=(e.position.y-e.positionPrev.y)*t,e.speed=Math.sqrt(n.x*n.x+n.y*n.y),e.angularVelocity=(e.angle-e.anglePrev)*t,e.angularSpeed=Math.abs(e.angularVelocity)},r.applyForce=function(e,t,n){var r=t.x-e.position.x,o=t.y-e.position.y;e.force.x+=n.x,e.force.y+=n.y,e.torque+=r*n.y-o*n.x},r._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var r=e.parts[n],o=r.mass!==1/0?r.mass:1;t.mass+=o,t.area+=r.area,t.inertia+=r.inertia,t.centre=i.add(t.centre,i.mult(r.position,o))}return t.centre=i.div(t.centre,t.mass),t}}()},Inl5:function(e,t,n){var r={};e.exports=r;var o=n("wAS/");n("571F");r.create=o.create,r.add=o.add,r.remove=o.remove,r.clear=o.clear,r.addComposite=o.addComposite,r.addBody=o.addBody,r.addConstraint=o.addConstraint},JBRW:function(e,t,n){e.exports={airFriction:n("6IAi"),avalanche:n("C3Ti"),ballPool:n("02te"),bridge:n("wycb"),car:n("Me0I"),catapult:n("0mtl"),chains:n("ZUN1"),circleStack:n("zc7U"),cloth:n("siNf"),collisionFiltering:n("Zo9v"),compositeManipulation:n("a3OZ"),compound:n("djnZ"),compoundStack:n("JbtQ"),concave:n("IOLg"),constraints:n("+jwT"),doublePendulum:n("74MQ"),events:n("C6Q+"),friction:n("DeYi"),gravity:n("7MJU"),gyro:n("k7Ch"),manipulation:n("VZUp"),mixed:n("ibhy"),newtonsCradle:n("xoNv"),ragdoll:n("c7us"),pyramid:n("5ocS"),raycasting:n("2oV2"),restitution:n("ZRMD"),rounded:n("elWf"),remove:n("Vyp4"),sensors:n("yWqE"),sleeping:n("LHSH"),slingshot:n("136C"),softBody:n("Czbd"),sprites:n("tlRp"),stack:n("ZpbE"),staticFriction:n("4XQC"),stats:n("vSND"),stress:n("EUdY"),stress2:n("Qnbh"),stress3:n("H5X8"),svg:n("/iAh"),terrain:n("52dP"),timescale:n("+QOk"),views:n("MhOg"),wreckingBall:n("LS1c")}},JKEF:function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("571F");r.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){var r=(n+1)%e.length,a=o.normalise({x:e[r].y-e[n].y,y:e[n].x-e[r].x}),s=0===a.y?1/0:a.x/a.y;t[s=s.toFixed(3).toString()]=a}return i.values(t)},r.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),r=Math.sin(t),o=0;o<e.length;o++){var i,a=e[o];i=a.x*n-a.y*r,a.y=a.x*r+a.y*n,a.x=i}}},JbtQ:function(e,t,n){var r=r||{};r.compoundStack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=o.stack(100,283,12,6,0,0,(function(e,t){var n=c.rectangle(e,t,50,10),o=c.rectangle(e,t,10,50,{render:n.render});return r.create({parts:[n,o]})}));s.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0}),c.rectangle(400,609,800,50,{isStatic:!0})]);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.compoundStack.title="Compound Stack",r.compoundStack.for=">=0.14.2",e.exports=r.compoundStack},LHSH:function(e,t,n){var r=r||{};r.sleeping=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=(Matter.Events,Matter.MouseConstraint),a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create({enableSleeping:!0}),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var m=r.stack(50,50,12,3,0,0,(function(e,t){switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(20,50),o.random(20,50)):c.rectangle(e,t,o.random(80,120),o.random(20,30));case 1:return c.polygon(e,t,Math.round(o.random(1,8)),o.random(20,50))}}));s.add(d,m);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.sleeping.title="Sleeping",r.sleeping.for=">=0.14.2",e.exports=r.sleeping},LS1c:function(e,t,n){var r=r||{};r.wreckingBall=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Constraint,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(400,175,5,10,0,0,(function(e,t){return c.rectangle(e,t,40,40)}));a.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var f=c.circle(100,400,50,{density:.04,frictionAir:.005});a.add(d,f),a.add(d,s.create({pointA:{x:300,y:100},bodyB:f}));var v=i.create(u.canvas),g=o.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.wreckingBall.title="Wrecking Ball",r.wreckingBall.for=">=0.14.2",e.exports=r.wreckingBall},Me0I:function(e,t,n){var r=r||{};r.car=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,o=(Matter.Composites,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0}});t.run(d);var u=n.create();n.run(u,c),a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var p=.9;a.add(l,r.car.car(150,100,150*p,30*p,30*p)),p=.8,a.add(l,r.car.car(350,300,150*p,30*p,30*p)),a.add(l,[s.rectangle(200,150,400,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),s.rectangle(500,350,650,20,{isStatic:!0,angle:.06*-Math.PI,render:{fillStyle:"#060a19"}}),s.rectangle(300,560,600,20,{isStatic:!0,angle:.04*Math.PI,render:{fillStyle:"#060a19"}})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.car.title="Car",r.car.for=">=0.14.2",r.car.car=function(e,t,n,r,o){var i=Matter.Body,a=Matter.Bodies,s=Matter.Composite,c=Matter.Constraint,l=i.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=s.create({label:"Car"}),m=a.rectangle(e,t,n,r,{collisionFilter:{group:l},chamfer:{radius:.5*r},density:2e-4}),f=a.circle(e+d,t+0,o,{collisionFilter:{group:l},friction:.8}),v=a.circle(e+u,t+0,o,{collisionFilter:{group:l},friction:.8}),g=c.create({bodyB:m,pointB:{x:d,y:0},bodyA:f,stiffness:1,length:0}),y=c.create({bodyB:m,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return s.addBody(p,m),s.addBody(p,f),s.addBody(p,v),s.addConstraint(p,g),s.addConstraint(p,y),p},e.exports=r.car},MhOg:function(e,t,n){var r=r||{};r.views=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Vector,d=Matter.Bounds,u=Matter.Bodies,p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600,hasBounds:!0,showAngleIndicator:!0}});t.run(f);var v=n.create();n.run(v,p);var g=s.create(f.canvas),y=a.create(p,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});c.add(m,y),f.mouse=g;var x=o.stack(20,20,10,4,0,0,(function(e,t){switch(Math.round(i.random(0,1))){case 0:return i.random()<.8?u.rectangle(e,t,i.random(20,50),i.random(20,50)):u.rectangle(e,t,i.random(80,120),i.random(20,30));case 1:var n=Math.round(i.random(1,8));return n=3===n?4:n,u.polygon(e,t,n,i.random(20,50))}}));c.add(m,[x,u.rectangle(400,0,800,50,{isStatic:!0}),u.rectangle(400,600,800,50,{isStatic:!0}),u.rectangle(800,300,50,600,{isStatic:!0}),u.rectangle(0,300,50,600,{isStatic:!0})]);var h={x:.5*f.options.width,y:.5*f.options.height},b={x:-300,y:-300},M={x:1100,y:900},S=1,w={x:1,y:1};return r.on(f,"beforeRender",(function(){p.world;var e,t=y.mouse,n=-.1*t.wheelDelta;0!==n&&(n<0&&w.x>=.6||n>0&&w.x<=1.4)&&(S+=n),Math.abs(w.x-S)>.01&&(n=.2*(S-w.x),w.x+=n,w.y+=n,f.bounds.max.x=f.bounds.min.x+f.options.width*w.x,f.bounds.max.y=f.bounds.min.y+f.options.height*w.y,e={x:f.options.width*n*-.5,y:f.options.height*n*-.5},d.translate(f.bounds,e),s.setScale(t,w),s.setOffset(t,f.bounds.min));var r=l.sub(t.absolute,h),o=l.magnitude(r);if(o>50){var i=l.normalise(r),a=Math.min(10,2e-4*Math.pow(o-50,2));e=l.mult(i,a),f.bounds.min.x+e.x<b.x&&(e.x=b.x-f.bounds.min.x),f.bounds.max.x+e.x>M.x&&(e.x=M.x-f.bounds.max.x),f.bounds.min.y+e.y<b.y&&(e.y=b.y-f.bounds.min.y),f.bounds.max.y+e.y>M.y&&(e.y=M.y-f.bounds.max.y),d.translate(f.bounds,e),s.setOffset(t,f.bounds.min)}})),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.views.title="Views",r.views.for=">=0.14.2",e.exports=r.views},NDQ1:function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("Z/YF"),a=n("Tgw/"),s=n("oT59"),c=n("0kzT");r.collides=function(e,t){for(var n=[],r=t.length,o=e.bounds,s=i.collides,c=a.overlaps,l=0;l<r;l++){var d=t[l],u=d.parts.length,p=1===u?0:1;if(c(d.bounds,o))for(var m=p;m<u;m++){var f=d.parts[m];if(c(f.bounds,o)){var v=s(f,e);if(v){n.push(v);break}}}}return n},r.ray=function(e,t,n,i){i=i||1e-100;for(var a=o.angle(t,n),c=o.magnitude(o.sub(t,n)),l=.5*(n.x+t.x),d=.5*(n.y+t.y),u=s.rectangle(l,d,c,i,{angle:a}),p=r.collides(u,e),m=0;m<p.length;m+=1){var f=p[m];f.body=f.bodyB=f.bodyA}return p},r.region=function(e,t,n){for(var r=[],o=0;o<e.length;o++){var i=e[o],s=a.overlaps(i.bounds,t);(s&&!n||!s&&n)&&r.push(i)}return r},r.point=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r];if(a.contains(o.bounds,t))for(var i=1===o.parts.length?0:1;i<o.parts.length;i++){var s=o.parts[i];if(a.contains(s.bounds,t)&&c.contains(s.vertices,t)){n.push(o);break}}}return n}},Qnbh:function(e,t,n){var r=r||{};r.stress2=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showStats:!0,showPerformance:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(100,125,25,18,0,0,(function(e,t){return s.rectangle(e,t,25,25)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stress2.title="Stress 2",r.stress2.for=">=0.14.2",e.exports=r.stress2},Sq1W:function(e,t,n){var r={};e.exports=r;var o=n("t8gT"),i=n("571F"),a=i.deprecated;r.create=function(e){return i.extend({buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48},e)},r.update=function(e,t,n,o){var i,a,s,c,l,d=n.world,u=e.buckets,p=!1;for(i=0;i<t.length;i++){var m=t[i];if((!m.isSleeping||o)&&(!d.bounds||!(m.bounds.max.x<d.bounds.min.x||m.bounds.min.x>d.bounds.max.x||m.bounds.max.y<d.bounds.min.y||m.bounds.min.y>d.bounds.max.y))){var f=r._getRegion(e,m);if(!m.region||f.id!==m.region.id||o){m.region&&!o||(m.region=f);var v=r._regionUnion(f,m.region);for(a=v.startCol;a<=v.endCol;a++)for(s=v.startRow;s<=v.endRow;s++){c=u[l=r._getBucketId(a,s)];var g=a>=f.startCol&&a<=f.endCol&&s>=f.startRow&&s<=f.endRow,y=a>=m.region.startCol&&a<=m.region.endCol&&s>=m.region.startRow&&s<=m.region.endRow;!g&&y&&y&&c&&r._bucketRemoveBody(e,c,m),(m.region===f||g&&!y||o)&&(c||(c=r._createBucket(u,l)),r._bucketAddBody(e,c,m))}m.region=f,p=!0}}}p&&(e.pairsList=r._createActivePairsList(e))},a(r,"update","Grid.update ➤ replaced by Matter.Detector"),r.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},a(r,"clear","Grid.clear ➤ replaced by Matter.Detector"),r._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),o=Math.max(e.endCol,t.endCol),i=Math.min(e.startRow,t.startRow),a=Math.max(e.endRow,t.endRow);return r._createRegion(n,o,i,a)},r._getRegion=function(e,t){var n=t.bounds,o=Math.floor(n.min.x/e.bucketWidth),i=Math.floor(n.max.x/e.bucketWidth),a=Math.floor(n.min.y/e.bucketHeight),s=Math.floor(n.max.y/e.bucketHeight);return r._createRegion(o,i,a,s)},r._createRegion=function(e,t,n,r){return{id:e+","+t+","+n+","+r,startCol:e,endCol:t,startRow:n,endRow:r}},r._getBucketId=function(e,t){return"C"+e+"R"+t},r._createBucket=function(e,t){return e[t]=[]},r._bucketAddBody=function(e,t,n){var r,i=e.pairs,a=o.id,s=t.length;for(r=0;r<s;r++){var c=t[r];if(!(n.id===c.id||n.isStatic&&c.isStatic)){var l=a(n,c),d=i[l];d?d[2]+=1:i[l]=[n,c,1]}}t.push(n)},r._bucketRemoveBody=function(e,t,n){var r,a=e.pairs,s=o.id;t.splice(i.indexOf(t,n),1);var c=t.length;for(r=0;r<c;r++){var l=a[s(n,t[r])];l&&(l[2]-=1)}},r._createActivePairsList=function(e){var t,n,r=e.pairs,o=i.keys(r),a=o.length,s=[];for(n=0;n<a;n++)(t=r[o[n]])[2]>0?s.push(t):delete r[o[n]];return s}},"Tgw/":function(e,t){var n={};e.exports=n,n.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&n.update(t,e),t},n.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var r=0;r<t.length;r++){var o=t[r];o.x>e.max.x&&(e.max.x=o.x),o.x<e.min.x&&(e.min.x=o.x),o.y>e.max.y&&(e.max.y=o.y),o.y<e.min.y&&(e.min.y=o.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},n.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},n.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},n.translate=function(e,t){e.min.x+=t.x,e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},n.shift=function(e,t){var n=e.max.x-e.min.x,r=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+r}},VZUp:function(e,t,n){var r=r||{};r.manipulation=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAxes:!0,showCollisions:!0,showConvexHulls:!0}});t.run(u);var p=n.create();n.run(p,l);var m=c.rectangle(100,300,50,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),f=c.rectangle(200,200,50,50),v=c.rectangle(300,200,50,50),g=c.rectangle(400,200,50,50),y=c.rectangle(550,200,50,50),x=c.rectangle(700,200,50,50),h=c.circle(400,100,25,{render:{fillStyle:"#060a19"}}),b=c.rectangle(600,200,96,40,{render:{fillStyle:"#060a19"}}),M=c.rectangle(660,200,40,152,{render:{fillStyle:"#060a19"}}),S=r.create({parts:[b,M],isStatic:!0});r.setPosition(S,{x:600,y:300}),s.add(d,[m,f,v,g,y,x,h,S]),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var w=0,C=.6;o.on(l,"beforeUpdate",(function(e){var t=(e.delta||1e3/60)/1e3;C>0&&(r.scale(x,1+C*t,1+C*t),y.vertices[0].x-=.2*t,y.vertices[0].y-=.2*t,y.vertices[1].x+=.2*t,y.vertices[1].y-=.2*t,r.setVertices(y,y.vertices));var n=300+100*Math.sin(.002*l.timing.timestamp);"0.18.0"===Matter.version&&(r.setVelocity(m,{x:0,y:n-m.position.y}),r.setVelocity(S,{x:0,y:n-S.position.y}),r.setAngularVelocity(S,1*Math.PI*t)),r.setPosition(m,{x:100,y:n},!0),r.setPosition(S,{x:600,y:n},!0),r.rotate(S,1*Math.PI*t,null,!0),l.timing.timestamp>=800&&r.setStatic(h,!0),l.timing.timestamp-w>=1500&&(r.setVelocity(f,{x:0,y:-10}),r.setAngle(v,.26*-Math.PI),r.setAngularVelocity(g,.2),C=0,w=l.timing.timestamp)}));var A=a.create(u.canvas),B=i.create(l,{mouse:A,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,B),u.mouse=A,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.manipulation.title="Manipulation",r.manipulation.for=">=0.14.2",e.exports=r.manipulation},Vyp4:function(e,t,n){var r=r||{};r.remove=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=Matter.Events,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=n.create();n.run(m,d);var f=null,v=0,g=function(){return r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch(n>2&&o.random()>.7&&(r={radius:10}),Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50),o.random(25,50),{chamfer:r}):c.rectangle(e,t,o.random(80,120),o.random(25,30),{chamfer:r});case 1:return c.polygon(e,t,n,o.random(25,50),{chamfer:r})}}))};l.on(d,"afterUpdate",(function(e){f&&e.timestamp-v<800||(v=e.timestamp,f&&s.remove(u,f),f=g(),s.add(u,f))})),s.add(u,g()),s.add(u,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var y=a.create(p.canvas),x=i.create(d,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(u,x),p.mouse=y,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.remove.title="Composite Remove",r.remove.for=">=0.14.2",e.exports=r.remove},"Z/YF":function(e,t,n){var r={};e.exports=r;var o,i,a,s=n("0kzT"),c=n("t8gT");o=[],i={overlap:0,axis:null},a={overlap:0,axis:null},r.create=function(e,t){return{pair:null,collided:!1,bodyA:e,bodyB:t,parentA:e.parent,parentB:t.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},r.collides=function(e,t,n){if(r._overlapAxes(i,e.vertices,t.vertices,e.axes),i.overlap<=0)return null;if(r._overlapAxes(a,t.vertices,e.vertices,t.axes),a.overlap<=0)return null;var o,l,d=n&&n.table[c.id(e,t)];d?o=d.collision:((o=r.create(e,t)).collided=!0,o.bodyA=e.id<t.id?e:t,o.bodyB=e.id<t.id?t:e,o.parentA=o.bodyA.parent,o.parentB=o.bodyB.parent),e=o.bodyA,t=o.bodyB,l=i.overlap<a.overlap?i:a;var u=o.normal,p=o.supports,m=l.axis,f=m.x,v=m.y;f*(t.position.x-e.position.x)+v*(t.position.y-e.position.y)<0?(u.x=f,u.y=v):(u.x=-f,u.y=-v),o.tangent.x=-u.y,o.tangent.y=u.x,o.depth=l.overlap,o.penetration.x=u.x*o.depth,o.penetration.y=u.y*o.depth;var g=r._findSupports(e,t,u,1),y=0;if(s.contains(e.vertices,g[0])&&(p[y++]=g[0]),s.contains(e.vertices,g[1])&&(p[y++]=g[1]),y<2){var x=r._findSupports(t,e,u,-1);s.contains(t.vertices,x[0])&&(p[y++]=x[0]),y<2&&s.contains(t.vertices,x[1])&&(p[y++]=x[1])}return 0===y&&(p[y++]=g[0]),p.length=y,o},r._overlapAxes=function(e,t,n,r){var o,i,a,s,c,l,d=t.length,u=n.length,p=t[0].x,m=t[0].y,f=n[0].x,v=n[0].y,g=r.length,y=Number.MAX_VALUE,x=0;for(c=0;c<g;c++){var h=r[c],b=h.x,M=h.y,S=p*b+m*M,w=f*b+v*M,C=S,A=w;for(l=1;l<d;l+=1)(s=t[l].x*b+t[l].y*M)>C?C=s:s<S&&(S=s);for(l=1;l<u;l+=1)(s=n[l].x*b+n[l].y*M)>A?A=s:s<w&&(w=s);if((o=(i=C-w)<(a=A-S)?i:a)<y&&(y=o,x=c,o<=0))break}e.axis=r[x],e.overlap=y},r._projectToAxis=function(e,t,n){for(var r=t[0].x*n.x+t[0].y*n.y,o=r,i=1;i<t.length;i+=1){var a=t[i].x*n.x+t[i].y*n.y;a>o?o=a:a<r&&(r=a)}e.min=r,e.max=o},r._findSupports=function(e,t,n,r){var i,a,s,c,l,d=t.vertices,u=d.length,p=e.position.x,m=e.position.y,f=n.x*r,v=n.y*r,g=Number.MAX_VALUE;for(l=0;l<u;l+=1)(c=f*(p-(a=d[l]).x)+v*(m-a.y))<g&&(g=c,i=a);return g=f*(p-(s=d[(u+i.index-1)%u]).x)+v*(m-s.y),f*(p-(a=d[(i.index+1)%u]).x)+v*(m-a.y)<g?(o[0]=i,o[1]=a,o):(o[0]=i,o[1]=s,o)}},ZRMD:function(e,t,n){var r=r||{};r.restitution=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.Composite,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s);var u=.9;i.add(c,[a.rectangle(100,150,50,50,{restitution:u}),a.rectangle(220,150,50,50,{restitution:u,angle:.15*-Math.PI}),a.rectangle(340,150,50,50,{restitution:u,angle:.25*-Math.PI}),a.circle(460,150,25,{restitution:u}),a.rectangle(700,150,180,20,{restitution:u,angle:.5*-Math.PI}),a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]);var p=o.create(l.canvas),m=r.create(s,{mouse:p,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,m),l.mouse=p,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.restitution.title="Restitution",r.restitution.for=">=0.14.2",e.exports=r.restitution},ZUN1:function(e,t,n){var r=r||{};r.chains=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composite,i=Matter.Composites,a=Matter.Constraint,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(p);var m=n.create();n.run(m,d);var f=r.nextGroup(!0),v=i.stack(100,50,8,1,10,10,(function(e,t){return l.rectangle(e,t,50,20,{collisionFilter:{group:f}})}));i.chain(v,.5,0,-.5,0,{stiffness:.8,length:2,render:{type:"line"}}),o.add(v,a.create({bodyB:v.bodies[0],pointB:{x:-25,y:0},pointA:{x:v.bodies[0].position.x,y:v.bodies[0].position.y},stiffness:.5})),f=r.nextGroup(!0);var g=i.stack(350,50,10,1,10,10,(function(e,t){return l.circle(e,t,20,{collisionFilter:{group:f}})}));i.chain(g,.5,0,-.5,0,{stiffness:.8,length:2,render:{type:"line"}}),o.add(g,a.create({bodyB:g.bodies[0],pointB:{x:-20,y:0},pointA:{x:g.bodies[0].position.x,y:g.bodies[0].position.y},stiffness:.5})),f=r.nextGroup(!0);var y=i.stack(600,50,13,1,10,10,(function(e,t){return l.rectangle(e-20,t,50,20,{collisionFilter:{group:f},chamfer:5})}));i.chain(y,.3,0,-.3,0,{stiffness:1,length:0}),o.add(y,a.create({bodyB:y.bodies[0],pointB:{x:-20,y:0},pointA:{x:y.bodies[0].position.x,y:y.bodies[0].position.y},stiffness:.5})),o.add(u,[v,g,y,l.rectangle(400,600,1200,50.5,{isStatic:!0})]);var x=c.create(p.canvas),h=s.create(d,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return o.add(u,h),p.mouse=x,t.lookAt(p,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.chains.title="Chains",r.chains.for=">=0.14.2",e.exports=r.chains},Zo9v:function(e,t,n){var r=r||{};r.collisionFiltering=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composite,o=Matter.Composites,i=(Matter.Common,Matter.MouseConstraint),a=Matter.Mouse,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,wireframes:!1}});t.run(d);var u=n.create();n.run(u,c);var p="#f55a3c",m="#063e7b",f="#f5d259";r.add(l,s.rectangle(400,600,900,50,{isStatic:!0,render:{fillStyle:"transparent",lineWidth:1}})),r.add(l,o.stack(275,100,5,9,10,10,(function(e,t,n,r){var o=2,i=p;return r>5?(o=8,i=m):r>2&&(o=4,i=f),s.circle(e,t,20,{collisionFilter:{category:o},render:{strokeStyle:i,fillStyle:"transparent",lineWidth:1}})}))),r.add(l,s.circle(310,40,30,{collisionFilter:{mask:5},render:{fillStyle:f}})),r.add(l,s.circle(400,40,30,{collisionFilter:{mask:3},render:{fillStyle:p}})),r.add(l,s.circle(480,40,30,{collisionFilter:{mask:9},render:{fillStyle:m}}));var v=a.create(d.canvas),g=i.create(c,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return r.add(l,g),d.mouse=v,g.collisionFilter.mask=13,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.collisionFiltering.title="Collision Filtering",r.collisionFiltering.for=">=0.14.2",e.exports=r.collisionFiltering},ZpbE:function(e,t,n){var r=r||{};r.stack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(200,380.75,10,5,0,0,(function(e,t){return s.rectangle(e,t,40,40)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),s.rectangle(400,606,800,50.5,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stack.title="Stack",r.stack.for=">=0.14.2",e.exports=r.stack},"a+ms":function(e,t,n){var r=n("akk5"),o=n("lniP"),i=n("lniP");e.exports={compare:function(e,t){var n=r.Demo.create({toolbar:{title:"matter-js ・ "+(t?"dev":"")+" ・ comparing to "+i.version,url:"https://github.com/liabru/matter-js",reset:!0,source:!0,inspector:!1,tools:!1,fullscreen:!0,exampleSelect:!0},tools:{inspector:!1,gui:!1},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!0,startExample:!1,examples:e}),a=r.Demo.create({toolbar:{title:"matter-js-compare-build",reset:!1,source:!1,inspector:!1,tools:!1,fullscreen:!1,exampleSelect:!1},tools:{inspector:!1,gui:!1},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!1,startExample:!1,examples:e.map((function(e){return Matter.Common.extend({},e)}))});i.Runner.run=function(){},i.Render.run=function(){},o.Runner._tick=o.Runner.tick,o.Render._world=o.Render.world,i.Mouse._setElement=i.Mouse.setElement,r.Demo._setExample=r.Demo.setExample,r.Demo.setExample=function(e,t){i.Common._nextId=i.Common._seed=0,o.Common._nextId=o.Common._seed=0,i.Plugin._registry=o.Plugin._registry,i.use.apply(null,o.used),window.Matter=o,r.Demo._setExample(n,n.examples.find((function(e){return e.name===t.name})));var s=parseFloat(window.location.search.split("=")[1]),c=0;o.Runner.tick=function(e,t,n){if(-1!==c){if(c>=s)return console.info("Demo.Compare: ran "+c+" ticks, timestamp is now "+t.timing.timestamp.toFixed(2)),void(c=-1);c+=1;var r=a.example.instance;return e.isFixed=r.runner.isFixed=!0,e.delta=r.runner.delta=1e3/60,window.Matter=i,i.Runner.tick(r.runner,r.engine,n),window.Matter=o,o.Runner._tick(e,t,n)}},o.Render.world=function(e){return window.Matter=i,i.Render.world(a.example.instance.render),window.Matter=o,o.Render._world(e)},i.Mouse.setElement=function(e){return i.Mouse._setElement(e,n.example.instance.render.canvas)},window.Matter=i,r.Demo._setExample(a,a.examples.find((function(e){return e.name===t.name}))),window.Matter=o},r.Demo._reset=r.Demo.reset,r.Demo.reset=function(e){i.Common._nextId=i.Common._seed=0,o.Common._nextId=o.Common._seed=0,window.Matter=i,r.Demo._reset(a),window.Matter=o,r.Demo._reset(n)},document.body.appendChild(n.dom.root),document.body.appendChild(a.dom.root),r.Demo.start(n),document.title="Matter.js Compare"+(t?" ・ Dev":""),console.info("Demo.Compare: matter-js@"+o.version+" with matter-js@"+i.version)}}},a3OZ:function(e,t,n){var r=r||{};r.compositeManipulation=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.Composite,i=Matter.Composites,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l),o.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.stack(200,200,4,4,0,0,(function(e,t){return c.rectangle(e,t,40,40)}));o.add(d,m),l.gravity.y=0,r.on(l,"afterUpdate",(function(e){var t=l.timing.timestamp,n=(e.delta||1e3/60)/1e3;o.translate(m,{x:10*Math.sin(.001*t)*n,y:0}),o.rotate(m,.75*Math.sin(.001*t)*n,{x:300,y:300});var r=1+.75*Math.sin(.001*t)*n;o.scale(m,r,r,{x:300,y:300})}));var f=s.create(u.canvas),v=a.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return o.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.compositeManipulation.title="Composite Manipulation",r.compositeManipulation.for=">0.16.1",e.exports=r.compositeManipulation},c7us:function(e,t,n){var r=r||{};r.ragdoll=function(){var e=Matter.Engine,t=Matter.Events,n=Matter.Render,o=Matter.Runner,i=Matter.Body,a=Matter.Common,s=Matter.Composite,c=Matter.Composites,l=Matter.MouseConstraint,d=Matter.Mouse,u=Matter.Bodies,p=e.create(),m=p.world,f=n.create({element:document.body,engine:p,options:{width:800,height:600,showAngleIndicator:!0}});n.run(f);var v=o.create();o.run(v,p);for(var g=(f.bounds.max.y-f.bounds.min.y)/50,y=c.stack(0,0,g+2,1,0,0,(function(e,t,n){return u.rectangle(e-50,t+50*n,100,1e3,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#ffffff",lineWidth:1}})})),x=c.stack(300,0,15,3,10,10,(function(e,t,n){var r=Math.round(a.random(1,8)),o={render:{fillStyle:a.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"])}};switch(Math.round(a.random(0,1))){case 0:return a.random()<.8?u.rectangle(e,t,a.random(25,50),a.random(25,50),o):u.rectangle(e,t,a.random(80,120),a.random(25,30),o);case 1:return u.polygon(e,t,r,a.random(25,50),o)}})),h=s.create(),b=0;b<1;b+=1){var M=r.ragdoll.ragdoll(200,-1e3*b,1.3);s.add(h,M)}s.add(m,[y,x,h]);var S=1,w=a.now();t.on(p,"afterUpdate",(function(e){var t=(e.delta||1e3/60)/1e3;-1===C.button?p.timing.timeScale+=3*(S-p.timing.timeScale)*t:p.timing.timeScale=1,a.now()-w>=2e3&&(S=S<1?1:.05,w=a.now());for(var n=0;n<y.bodies.length;n+=1){var r=y.bodies[n];i.translate(r,{x:-30*t,y:-30*t}),r.position.x<-50&&(i.setPosition(r,{x:50*(y.bodies.length-1),y:25+f.bounds.max.y+.5*(r.bounds.max.y-r.bounds.min.y)}),i.setVelocity(r,{x:0,y:0}))}for(n=0;n<h.composites.length;n+=1){var o=h.composites[n];(c=s.bounds(o)).min.y>f.bounds.max.y+100&&s.translate(o,{x:.9*-c.min.x,y:-f.bounds.max.y-400})}for(n=0;n<x.bodies.length;n+=1){var c;(c=(r=x.bodies[n]).bounds).min.y>f.bounds.max.y+100&&i.translate(r,{x:-c.min.x,y:-f.bounds.max.y-300})}}));var C=d.create(f.canvas),A=l.create(p,{mouse:C,constraint:{stiffness:.6,length:0,angularStiffness:0,render:{visible:!1}}});return s.add(m,A),f.mouse=C,n.lookAt(f,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.ragdoll.ragdoll=function(e,t,n,r){n=void 0===n?1:n;var o=Matter.Body,i=Matter.Bodies,a=Matter.Constraint,s=Matter.Composite,c=Matter.Common,l=c.extend({label:"head",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:[15*n,15*n,15*n,15*n]},render:{fillStyle:"#FFBC42"}},r),d=c.extend({label:"chest",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:[20*n,20*n,26*n,26*n]},render:{fillStyle:"#E0A423"}},r),u=c.extend({label:"left-arm",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),p=c.extend({},u,{render:{fillStyle:"#E59B12"}}),m=c.extend({label:"right-arm",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),f=c.extend({},m,{render:{fillStyle:"#E59B12"}}),v=c.extend({label:"left-leg",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),g=c.extend({},v,{render:{fillStyle:"#E59B12"}}),y=c.extend({label:"right-leg",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),x=c.extend({},y,{render:{fillStyle:"#E59B12"}}),h=i.rectangle(e,t-60*n,34*n,40*n,l),b=i.rectangle(e,t,55*n,80*n,d),M=i.rectangle(e+39*n,t-15*n,20*n,40*n,m),S=i.rectangle(e+39*n,t+25*n,20*n,60*n,f),w=i.rectangle(e-39*n,t-15*n,20*n,40*n,u),C=i.rectangle(e-39*n,t+25*n,20*n,60*n,p),A=i.rectangle(e-20*n,t+57*n,20*n,40*n,v),B=i.rectangle(e-20*n,t+97*n,20*n,60*n,g),k=i.rectangle(e+20*n,t+57*n,20*n,40*n,y),R=i.rectangle(e+20*n,t+97*n,20*n,60*n,x),P=a.create({bodyA:b,pointA:{x:24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:M,stiffness:.6,render:{visible:!1}}),I=a.create({bodyA:b,pointA:{x:-24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:w,stiffness:.6,render:{visible:!1}}),_=a.create({bodyA:b,pointA:{x:-10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:A,stiffness:.6,render:{visible:!1}}),E=a.create({bodyA:b,pointA:{x:10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:k,stiffness:.6,render:{visible:!1}}),T=a.create({bodyA:M,bodyB:S,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),F=a.create({bodyA:w,bodyB:C,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),V=a.create({bodyA:A,bodyB:B,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),D=a.create({bodyA:k,bodyB:R,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),L=a.create({bodyA:h,pointA:{x:0,y:25*n},pointB:{x:0,y:-35*n},bodyB:b,stiffness:.6,render:{visible:!1}}),O=a.create({bodyA:B,bodyB:R,stiffness:.01,render:{visible:!1}});return s.create({bodies:[b,h,C,w,S,M,B,R,A,k],constraints:[F,T,I,P,L,V,D,_,E,O]})},r.ragdoll.title="Ragdoll",r.ragdoll.for=">=0.14.2",e.exports=r.ragdoll},djnZ:function(e,t,n){var r=r||{};r.compound=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Constraint,i=Matter.Composite,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAxes:!0,showConvexHulls:!0}});t.run(u);var p=n.create();n.run(p,l);var m=200,f=200,v=200,g=c.rectangle(f,v,m,m/5),y=c.rectangle(f,v,m/5,m,{render:g.render}),x=r.create({parts:[g,y]});m=150,f=400,v=300;var h=c.circle(f,v,30),b=c.circle(f+m,v,30),M=c.circle(f+m,v+m,30),S=c.circle(f,v+m,30),w=r.create({parts:[h,b,M,S]}),C=o.create({pointA:{x:400,y:100},bodyB:w,pointB:{x:0,y:0}});i.add(d,[x,w,C,c.rectangle(400,600,800,50.5,{isStatic:!0})]);var A=s.create(u.canvas),B=a.create(l,{mouse:A,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(d,B),u.mouse=A,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.compound.title="Compound Bodies",r.compound.for=">=0.14.2",e.exports=r.compound},elWf:function(e,t,n){var r=r||{};r.rounded=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.Composite,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showAxes:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]),i.add(c,[a.rectangle(200,200,100,100,{chamfer:{radius:20}}),a.rectangle(300,200,100,100,{chamfer:{radius:[90,0,0,0]}}),a.rectangle(400,200,200,200,{chamfer:{radius:[150,20,40,20]}}),a.rectangle(200,200,200,200,{chamfer:{radius:[150,20,150,20]}}),a.rectangle(300,200,200,50,{chamfer:{radius:[25,25,0,0]}}),a.polygon(200,100,8,80,{chamfer:{radius:30}}),a.polygon(300,100,5,80,{chamfer:{radius:[10,40,20,40,10]}}),a.polygon(400,200,3,50,{chamfer:{radius:[20,0,20]}})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.rounded.title="Rounded Corners (Chamfering)",r.rounded.for=">=0.14.2",e.exports=r.rounded},ga9t:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm"),a=n("yw0d"),s=n("Tgw/"),c=n("JKEF"),l=n("571F");r._warming=.4,r._torqueDampen=1,r._minLength=1e-6,r.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?i.add(t.bodyA.position,t.pointA):t.pointA,r=t.bodyB?i.add(t.bodyB.position,t.pointB):t.pointB,o=i.magnitude(i.sub(n,r));t.length=void 0!==t.length?t.length:o,t.id=t.id||l.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var a={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(a.type="pin",a.anchors=!1):t.stiffness<.9&&(a.type="spring"),t.render=l.extend(a,t.render),t},r.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],r=n.constraintImpulse;n.isStatic||0===r.x&&0===r.y&&0===r.angle||(n.position.x+=r.x,n.position.y+=r.y,n.angle+=r.angle)}},r.solveAll=function(e,t){for(var n=l.clamp(t/l._baseDelta,0,1),o=0;o<e.length;o+=1){var i=e[o],a=!i.bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic;(a||s)&&r.solve(e[o],n)}for(o=0;o<e.length;o+=1)a=!(i=e[o]).bodyA||i.bodyA&&i.bodyA.isStatic,s=!i.bodyB||i.bodyB&&i.bodyB.isStatic,a||s||r.solve(e[o],n)},r.solve=function(e,t){var n=e.bodyA,o=e.bodyB,a=e.pointA,s=e.pointB;if(n||o){n&&!n.isStatic&&(i.rotate(a,n.angle-e.angleA,a),e.angleA=n.angle),o&&!o.isStatic&&(i.rotate(s,o.angle-e.angleB,s),e.angleB=o.angle);var c=a,l=s;if(n&&(c=i.add(n.position,a)),o&&(l=i.add(o.position,s)),c&&l){var d=i.sub(c,l),u=i.magnitude(d);u<r._minLength&&(u=r._minLength);var p,m,f,v,g,y=(u-e.length)/u,x=e.stiffness>=1||0===e.length?e.stiffness*t:e.stiffness*t*t,h=e.damping*t,b=i.mult(d,y*x),M=(n?n.inverseMass:0)+(o?o.inverseMass:0),S=M+((n?n.inverseInertia:0)+(o?o.inverseInertia:0));if(h>0){var w=i.create();f=i.div(d,u),g=i.sub(o&&i.sub(o.position,o.positionPrev)||w,n&&i.sub(n.position,n.positionPrev)||w),v=i.dot(f,g)}n&&!n.isStatic&&(m=n.inverseMass/M,n.constraintImpulse.x-=b.x*m,n.constraintImpulse.y-=b.y*m,n.position.x-=b.x*m,n.position.y-=b.y*m,h>0&&(n.positionPrev.x-=h*f.x*v*m,n.positionPrev.y-=h*f.y*v*m),p=i.cross(a,b)/S*r._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),o&&!o.isStatic&&(m=o.inverseMass/M,o.constraintImpulse.x+=b.x*m,o.constraintImpulse.y+=b.y*m,o.position.x+=b.x*m,o.position.y+=b.y*m,h>0&&(o.positionPrev.x+=h*f.x*v*m,o.positionPrev.y+=h*f.y*v*m),p=i.cross(s,b)/S*r._torqueDampen*o.inverseInertia*(1-e.angularStiffness),o.constraintImpulse.angle+=p,o.angle+=p)}}},r.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],l=n.constraintImpulse;if(!(n.isStatic||0===l.x&&0===l.y&&0===l.angle)){a.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];o.translate(u.vertices,l),d>0&&(u.position.x+=l.x,u.position.y+=l.y),0!==l.angle&&(o.rotate(u.vertices,l.angle,n.position),c.rotate(u.axes,l.angle),d>0&&i.rotateAbout(u.position,l.angle,n.position,u.position)),s.update(u.bounds,u.vertices,n.velocity)}l.angle*=r._warming,l.x*=r._warming,l.y*=r._warming}}},r.pointAWorld=function(e){return{x:(e.bodyA?e.bodyA.position.x:0)+(e.pointA?e.pointA.x:0),y:(e.bodyA?e.bodyA.position.y:0)+(e.pointA?e.pointA.y:0)}},r.pointBWorld=function(e){return{x:(e.bodyB?e.bodyB.position.x:0)+(e.pointB?e.pointB.x:0),y:(e.bodyB?e.bodyB.position.y:0)+(e.pointB?e.pointB.y:0)}}},ibhy:function(e,t,n){var r=r||{};r.mixed=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch(n>2&&o.random()>.7&&(r={radius:10}),Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50),o.random(25,50),{chamfer:r}):c.rectangle(e,t,o.random(80,120),o.random(25,30),{chamfer:r});case 1:return c.polygon(e,t,n,o.random(25,50),{chamfer:r})}}));s.add(d,m),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.mixed.title="Mixed Shapes",r.mixed.for=">=0.14.2",e.exports=r.mixed},"ix+/":function(e,t,n){var r={};e.exports=r;var o=n("571F"),i=n("Z/YF");r.create=function(e){return o.extend({bodies:[],pairs:null},e)},r.setBodies=function(e,t){e.bodies=t.slice(0)},r.clear=function(e){e.bodies=[]},r.collisions=function(e){var t,n,o=[],a=e.pairs,s=e.bodies,c=s.length,l=r.canCollide,d=i.collides;for(s.sort(r._compareBoundsX),t=0;t<c;t++){var u=s[t],p=u.bounds,m=u.bounds.max.x,f=u.bounds.max.y,v=u.bounds.min.y,g=u.isStatic||u.isSleeping,y=u.parts.length,x=1===y;for(n=t+1;n<c;n++){var h=s[n];if((k=h.bounds).min.x>m)break;if(!(f<k.min.y||v>k.max.y)&&(!g||!h.isStatic&&!h.isSleeping)&&l(u.collisionFilter,h.collisionFilter)){var b=h.parts.length;if(x&&1===b)(A=d(u,h,a))&&o.push(A);else for(var M=b>1?1:0,S=y>1?1:0;S<y;S++)for(var w=u.parts[S],C=(p=w.bounds,M);C<b;C++){var A,B=h.parts[C],k=B.bounds;p.min.x>k.max.x||p.max.x<k.min.x||p.max.y<k.min.y||p.min.y>k.max.y||(A=d(w,B,a))&&o.push(A)}}}}return o},r.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)},r._compareBoundsX=function(e,t){return e.bounds.min.x-t.bounds.min.x}},k7Ch:function(e,t,n){var r=r||{};r.gyro=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch(n>2&&o.random()>.7&&(r={radius:10}),Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50),o.random(25,50),{chamfer:r}):c.rectangle(e,t,o.random(80,120),o.random(25,30),{chamfer:r});case 1:return c.polygon(e,t,n,o.random(25,50),{chamfer:r})}}));if(s.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]),"undefined"!=typeof window){var f=function(e){var t=void 0!==window.orientation?window.orientation:0,n=l.gravity;0===t?(n.x=o.clamp(e.gamma,-90,90)/90,n.y=o.clamp(e.beta,-90,90)/90):180===t?(n.x=o.clamp(e.gamma,-90,90)/90,n.y=o.clamp(-e.beta,-90,90)/90):90===t?(n.x=o.clamp(e.beta,-90,90)/90,n.y=o.clamp(-e.gamma,-90,90)/90):-90===t&&(n.x=o.clamp(-e.beta,-90,90)/90,n.y=o.clamp(e.gamma,-90,90)/90)};window.addEventListener("deviceorientation",f)}var v=a.create(u.canvas),g=i.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p),"undefined"!=typeof window&&window.removeEventListener("deviceorientation",f)}}},r.gyro.title="Gyroscope",r.gyro.for=">=0.14.2",e.exports=r.gyro},lWug:function(e,t,n){var r={};e.exports=r;var o=n("IbIC"),i=n("571F"),a=n("wAS/"),s=n("Tgw/"),c=n("yTB+"),l=n("m6Dm"),d=n("I5nt");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout((function(){e(i.now())}),1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),r._goodFps=30,r._goodDelta=1e3/60,r.create=function(e){var t={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},n=i.extend(t,e);return n.canvas&&(n.canvas.width=n.options.width||n.canvas.width,n.canvas.height=n.options.height||n.canvas.height),n.mouse=e.mouse,n.engine=e.engine,n.canvas=n.canvas||p(n.options.width,n.options.height),n.context=n.canvas.getContext("2d"),n.textures={},n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.canvas.width,y:n.canvas.height}},n.controller=r,n.options.showBroadphase=!1,1!==n.options.pixelRatio&&r.setPixelRatio(n,n.options.pixelRatio),i.isElement(n.element)&&n.element.appendChild(n.canvas),n},r.run=function(t){!function o(i){t.frameRequestId=e(o),n(t,i),r.world(t,i),(t.options.showStats||t.options.showDebug)&&r.stats(t,t.context,i),(t.options.showPerformance||t.options.showDebug)&&r.performance(t,t.context,i)}()},r.stop=function(e){t(e.frameRequestId)},r.setPixelRatio=function(e,t){var n=e.options,r=e.canvas;"auto"===t&&(t=m(r)),n.pixelRatio=t,r.setAttribute("data-pixel-ratio",t),r.width=n.width*t,r.height=n.height*t,r.style.width=n.width+"px",r.style.height=n.height+"px"},r.lookAt=function(e,t,n,r){r=void 0===r||r,t=i.isArray(t)?t:[t],n=n||{x:0,y:0};for(var o={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},a=0;a<t.length;a+=1){var s=t[a],c=s.bounds?s.bounds.min:s.min||s.position||s,l=s.bounds?s.bounds.max:s.max||s.position||s;c&&l&&(c.x<o.min.x&&(o.min.x=c.x),l.x>o.max.x&&(o.max.x=l.x),c.y<o.min.y&&(o.min.y=c.y),l.y>o.max.y&&(o.max.y=l.y))}var u=o.max.x-o.min.x+2*n.x,p=o.max.y-o.min.y+2*n.y,m=e.canvas.height,f=e.canvas.width/m,v=u/p,g=1,y=1;v>f?y=v/f:g=f/v,e.options.hasBounds=!0,e.bounds.min.x=o.min.x,e.bounds.max.x=o.min.x+u*g,e.bounds.min.y=o.min.y,e.bounds.max.y=o.min.y+p*y,r&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*y*.5,e.bounds.max.y+=.5*p-p*y*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))},r.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,r=t/e.options.width,o=n/e.options.height;e.context.setTransform(e.options.pixelRatio/r,0,0,e.options.pixelRatio/o,0,0),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},r.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},r.world=function(e,t){var n,o=i.now(),u=e.engine,p=u.world,m=e.canvas,f=e.context,g=e.options,y=e.timing,x=a.allBodies(p),h=a.allConstraints(p),b=g.wireframes?g.wireframeBackground:g.background,M=[],S=[],w={timestamp:u.timing.timestamp};if(c.trigger(e,"beforeRender",w),e.currentBackground!==b&&v(e,b),f.globalCompositeOperation="source-in",f.fillStyle="transparent",f.fillRect(0,0,m.width,m.height),f.globalCompositeOperation="source-over",g.hasBounds){for(n=0;n<x.length;n++){var C=x[n];s.overlaps(C.bounds,e.bounds)&&M.push(C)}for(n=0;n<h.length;n++){var A=h[n],B=A.bodyA,k=A.bodyB,R=A.pointA,P=A.pointB;B&&(R=l.add(B.position,A.pointA)),k&&(P=l.add(k.position,A.pointB)),R&&P&&((s.contains(e.bounds,R)||s.contains(e.bounds,P))&&S.push(A))}r.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.options.width,y:(e.bounds.max.y-e.bounds.min.y)/e.options.height}),d.setOffset(e.mouse,e.bounds.min))}else S=h,M=x,1!==e.options.pixelRatio&&e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0);!g.wireframes||u.enableSleeping&&g.showSleeping?r.bodies(e,M,f):(g.showConvexHulls&&r.bodyConvexHulls(e,M,f),r.bodyWireframes(e,M,f)),g.showBounds&&r.bodyBounds(e,M,f),(g.showAxes||g.showAngleIndicator)&&r.bodyAxes(e,M,f),g.showPositions&&r.bodyPositions(e,M,f),g.showVelocity&&r.bodyVelocity(e,M,f),g.showIds&&r.bodyIds(e,M,f),g.showSeparations&&r.separations(e,u.pairs.list,f),g.showCollisions&&r.collisions(e,u.pairs.list,f),g.showVertexNumbers&&r.vertexNumbers(e,M,f),g.showMousePosition&&r.mousePosition(e,e.mouse,f),r.constraints(S,f),g.hasBounds&&r.endViewTransform(e),c.trigger(e,"afterRender",w),y.lastElapsed=i.now()-o},r.stats=function(e,t,n){for(var r=e.engine,o=r.world,i=a.allBodies(o),s=0,c=0,l=0;l<i.length;l+=1)s+=i[l].parts.length;var d={Part:s,Body:i.length,Cons:a.allConstraints(o).length,Comp:a.allComposites(o).length,Pair:r.pairs.list.length};for(var u in t.fillStyle="#0e0f19",t.fillRect(c,0,302.5,44),t.font="12px Arial",t.textBaseline="top",t.textAlign="right",d){var p=d[u];t.fillStyle="#aaa",t.fillText(u,c+55,8),t.fillStyle="#eee",t.fillText(p,c+55,26),c+=55}},r.performance=function(e,t){var n=e.engine,o=e.timing,i=o.deltaHistory,a=o.elapsedHistory,s=o.timestampElapsedHistory,c=o.engineDeltaHistory,l=o.engineElapsedHistory,d=n.timing.lastDelta,p=u(i),m=u(a),f=u(c),v=u(l),g=u(s)/p||0,y=1e3/p||0,x=60;t.fillStyle="#0e0f19",t.fillRect(0,50,370,34),r.status(t,10,69,x,4,i.length,Math.round(y)+" fps",y/r._goodFps,(function(e){return i[e]/p-1})),r.status(t,82,69,x,4,c.length,d.toFixed(2)+" dt",r._goodDelta/d,(function(e){return c[e]/f-1})),r.status(t,154,69,x,4,l.length,v.toFixed(2)+" ut",1-v/r._goodFps,(function(e){return l[e]/v-1})),r.status(t,226,69,x,4,a.length,m.toFixed(2)+" rt",1-m/r._goodFps,(function(e){return a[e]/m-1})),r.status(t,298,69,x,4,s.length,g.toFixed(2)+" x",g*g*g,(function(e){return(s[e]/i[e]/g||0)-1}))},r.status=function(e,t,n,r,o,a,s,c,l){e.strokeStyle="#888",e.fillStyle="#444",e.lineWidth=1,e.fillRect(t,n+7,r,1),e.beginPath(),e.moveTo(t,n+7-o*i.clamp(.4*l(0),-2,2));for(var d=0;d<r;d+=1)e.lineTo(t+d,n+7-(d<a?o*i.clamp(.4*l(d),-2,2):0));e.stroke(),e.fillStyle="hsl("+i.clamp(25+95*c,0,120)+",100%,60%)",e.fillRect(t,n-7,4,4),e.font="12px Arial",e.textBaseline="middle",e.textAlign="right",e.fillStyle="#eee",e.fillText(s,t+r,n-5)},r.constraints=function(e,t){for(var n=t,r=0;r<e.length;r++){var o=e[r];if(o.render.visible&&o.pointA&&o.pointB){var a,s,c=o.bodyA,d=o.bodyB;if(a=c?l.add(c.position,o.pointA):o.pointA,"pin"===o.render.type)n.beginPath(),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath();else{if(s=d?l.add(d.position,o.pointB):o.pointB,n.beginPath(),n.moveTo(a.x,a.y),"spring"===o.render.type)for(var u,p=l.sub(s,a),m=l.perp(l.normalise(p)),f=Math.ceil(i.clamp(o.length/5,12,20)),v=1;v<f;v+=1)u=v%2==0?1:-1,n.lineTo(a.x+p.x*(v/f)+m.x*u*4,a.y+p.y*(v/f)+m.y*u*4);n.lineTo(s.x,s.y)}o.render.lineWidth&&(n.lineWidth=o.render.lineWidth,n.strokeStyle=o.render.strokeStyle,n.stroke()),o.render.anchors&&(n.fillStyle=o.render.strokeStyle,n.beginPath(),n.arc(a.x,a.y,3,0,2*Math.PI),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},r.bodies=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options),l=c.showInternalEdges||!c.wireframes;for(i=0;i<t.length;i++)if((r=t[i]).render.visible)for(a=r.parts.length>1?1:0;a<r.parts.length;a++)if((o=r.parts[a]).render.visible){if(c.showSleeping&&r.isSleeping?s.globalAlpha=.5*o.render.opacity:1!==o.render.opacity&&(s.globalAlpha=o.render.opacity),o.render.sprite&&o.render.sprite.texture&&!c.wireframes){var d=o.render.sprite,u=f(e,d.texture);s.translate(o.position.x,o.position.y),s.rotate(o.angle),s.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),s.rotate(-o.angle),s.translate(-o.position.x,-o.position.y)}else{if(o.circleRadius)s.beginPath(),s.arc(o.position.x,o.position.y,o.circleRadius,0,2*Math.PI);else{s.beginPath(),s.moveTo(o.vertices[0].x,o.vertices[0].y);for(var p=1;p<o.vertices.length;p++)!o.vertices[p-1].isInternal||l?s.lineTo(o.vertices[p].x,o.vertices[p].y):s.moveTo(o.vertices[p].x,o.vertices[p].y),o.vertices[p].isInternal&&!l&&s.moveTo(o.vertices[(p+1)%o.vertices.length].x,o.vertices[(p+1)%o.vertices.length].y);s.lineTo(o.vertices[0].x,o.vertices[0].y),s.closePath()}c.wireframes?(s.lineWidth=1,s.strokeStyle="#bbb",s.stroke()):(s.fillStyle=o.render.fillStyle,o.render.lineWidth&&(s.lineWidth=o.render.lineWidth,s.strokeStyle=o.render.strokeStyle,s.stroke()),s.fill())}s.globalAlpha=1}},r.bodyWireframes=function(e,t,n){var r,o,i,a,s,c=n,l=e.options.showInternalEdges;for(c.beginPath(),i=0;i<t.length;i++)if((r=t[i]).render.visible)for(s=r.parts.length>1?1:0;s<r.parts.length;s++){for(o=r.parts[s],c.moveTo(o.vertices[0].x,o.vertices[0].y),a=1;a<o.vertices.length;a++)!o.vertices[a-1].isInternal||l?c.lineTo(o.vertices[a].x,o.vertices[a].y):c.moveTo(o.vertices[a].x,o.vertices[a].y),o.vertices[a].isInternal&&!l&&c.moveTo(o.vertices[(a+1)%o.vertices.length].x,o.vertices[(a+1)%o.vertices.length].y);c.lineTo(o.vertices[0].x,o.vertices[0].y)}c.lineWidth=1,c.strokeStyle="#bbb",c.stroke()},r.bodyConvexHulls=function(e,t,n){var r,o,i,a=n;for(a.beginPath(),o=0;o<t.length;o++)if((r=t[o]).render.visible&&1!==r.parts.length){for(a.moveTo(r.vertices[0].x,r.vertices[0].y),i=1;i<r.vertices.length;i++)a.lineTo(r.vertices[i].x,r.vertices[i].y);a.lineTo(r.vertices[0].x,r.vertices[0].y)}a.lineWidth=1,a.strokeStyle="rgba(255,255,255,0.2)",a.stroke()},r.vertexNumbers=function(e,t,n){var r,o,i,a=n;for(r=0;r<t.length;r++){var s=t[r].parts;for(i=s.length>1?1:0;i<s.length;i++){var c=s[i];for(o=0;o<c.vertices.length;o++)a.fillStyle="rgba(255,255,255,0.2)",a.fillText(r+"_"+o,c.position.x+.8*(c.vertices[o].x-c.position.x),c.position.y+.8*(c.vertices[o].y-c.position.y))}}},r.mousePosition=function(e,t,n){var r=n;r.fillStyle="rgba(255,255,255,0.8)",r.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},r.bodyBounds=function(e,t,n){var r=n,o=(e.engine,e.options);r.beginPath();for(var i=0;i<t.length;i++){if(t[i].render.visible)for(var a=t[i].parts,s=a.length>1?1:0;s<a.length;s++){var c=a[s];r.rect(c.bounds.min.x,c.bounds.min.y,c.bounds.max.x-c.bounds.min.x,c.bounds.max.y-c.bounds.min.y)}}o.wireframes?r.strokeStyle="rgba(255,255,255,0.08)":r.strokeStyle="rgba(0,0,0,0.1)",r.lineWidth=1,r.stroke()},r.bodyAxes=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options);for(s.beginPath(),o=0;o<t.length;o++){var l=t[o],d=l.parts;if(l.render.visible)if(c.showAxes)for(i=d.length>1?1:0;i<d.length;i++)for(r=d[i],a=0;a<r.axes.length;a++){var u=r.axes[a];s.moveTo(r.position.x,r.position.y),s.lineTo(r.position.x+20*u.x,r.position.y+20*u.y)}else for(i=d.length>1?1:0;i<d.length;i++)for(r=d[i],a=0;a<r.axes.length;a++)s.moveTo(r.position.x,r.position.y),s.lineTo((r.vertices[0].x+r.vertices[r.vertices.length-1].x)/2,(r.vertices[0].y+r.vertices[r.vertices.length-1].y)/2)}c.wireframes?(s.strokeStyle="indianred",s.lineWidth=1):(s.strokeStyle="rgba(255, 255, 255, 0.4)",s.globalCompositeOperation="overlay",s.lineWidth=2),s.stroke(),s.globalCompositeOperation="source-over"},r.bodyPositions=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options);for(s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).render.visible)for(a=0;a<r.parts.length;a++)o=r.parts[a],s.arc(o.position.x,o.position.y,3,0,2*Math.PI,!1),s.closePath();for(c.wireframes?s.fillStyle="indianred":s.fillStyle="rgba(0,0,0,0.5)",s.fill(),s.beginPath(),i=0;i<t.length;i++)(r=t[i]).render.visible&&(s.arc(r.positionPrev.x,r.positionPrev.y,2,0,2*Math.PI,!1),s.closePath());s.fillStyle="rgba(255,165,0,0.8)",s.fill()},r.bodyVelocity=function(e,t,n){var r=n;r.beginPath();for(var i=0;i<t.length;i++){var a=t[i];if(a.render.visible){var s=o.getVelocity(a);r.moveTo(a.position.x,a.position.y),r.lineTo(a.position.x+s.x,a.position.y+s.y)}}r.lineWidth=3,r.strokeStyle="cornflowerblue",r.stroke()},r.bodyIds=function(e,t,n){var r,o,i=n;for(r=0;r<t.length;r++)if(t[r].render.visible){var a=t[r].parts;for(o=a.length>1?1:0;o<a.length;o++){var s=a[o];i.font="12px Arial",i.fillStyle="rgba(255,255,255,0.5)",i.fillText(s.id,s.position.x+10,s.position.y-10)}}},r.collisions=function(e,t,n){var r,o,i,a,s=n,c=e.options;for(s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).isActive)for(o=r.collision,a=0;a<r.activeContacts.length;a++){var l=r.activeContacts[a].vertex;s.rect(l.x-1.5,l.y-1.5,3.5,3.5)}for(c.wireframes?s.fillStyle="rgba(255,255,255,0.7)":s.fillStyle="orange",s.fill(),s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).isActive&&(o=r.collision,r.activeContacts.length>0)){var d=r.activeContacts[0].vertex.x,u=r.activeContacts[0].vertex.y;2===r.activeContacts.length&&(d=(r.activeContacts[0].vertex.x+r.activeContacts[1].vertex.x)/2,u=(r.activeContacts[0].vertex.y+r.activeContacts[1].vertex.y)/2),o.bodyB===o.supports[0].body||!0===o.bodyA.isStatic?s.moveTo(d-8*o.normal.x,u-8*o.normal.y):s.moveTo(d+8*o.normal.x,u+8*o.normal.y),s.lineTo(d,u)}c.wireframes?s.strokeStyle="rgba(255,165,0,0.7)":s.strokeStyle="orange",s.lineWidth=1,s.stroke()},r.separations=function(e,t,n){var r,o,i,a,s,c=n,l=e.options;for(c.beginPath(),s=0;s<t.length;s++)if((r=t[s]).isActive){i=(o=r.collision).bodyA;var d=1;(a=o.bodyB).isStatic||i.isStatic||(d=.5),a.isStatic&&(d=0),c.moveTo(a.position.x,a.position.y),c.lineTo(a.position.x-o.penetration.x*d,a.position.y-o.penetration.y*d),d=1,a.isStatic||i.isStatic||(d=.5),i.isStatic&&(d=0),c.moveTo(i.position.x,i.position.y),c.lineTo(i.position.x+o.penetration.x*d,i.position.y+o.penetration.y*d)}l.wireframes?c.strokeStyle="rgba(255,165,0,0.5)":c.strokeStyle="orange",c.stroke()},r.inspector=function(e,t){e.engine;var n,r=e.selected,o=e.render,i=o.options;if(i.hasBounds){var a=o.bounds.max.x-o.bounds.min.x,s=o.bounds.max.y-o.bounds.min.y,c=a/o.options.width,l=s/o.options.height;t.scale(1/c,1/l),t.translate(-o.bounds.min.x,-o.bounds.min.y)}for(var d=0;d<r.length;d++){var u=r[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),i.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=e.engine,o=e.timing,i=o.historySize,a=n.timing.timestamp;o.delta=t-o.lastTime||r._goodDelta,o.lastTime=t,o.timestampElapsed=a-o.lastTimestamp||0,o.lastTimestamp=a,o.deltaHistory.unshift(o.delta),o.deltaHistory.length=Math.min(o.deltaHistory.length,i),o.engineDeltaHistory.unshift(n.timing.lastDelta),o.engineDeltaHistory.length=Math.min(o.engineDeltaHistory.length,i),o.timestampElapsedHistory.unshift(o.timestampElapsed),o.timestampElapsedHistory.length=Math.min(o.timestampElapsedHistory.length,i),o.engineElapsedHistory.unshift(n.timing.lastElapsed),o.engineElapsedHistory.length=Math.min(o.engineElapsedHistory.length,i),o.elapsedHistory.unshift(o.lastElapsed),o.elapsedHistory.length=Math.min(o.elapsedHistory.length,i)},u=function(e){for(var t=0,n=0;n<e.length;n+=1)t+=e[n];return t/e.length||0},p=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},m=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},f=function(e,t){var n=e.textures[t];return n||((n=e.textures[t]=new Image).src=t,n)},v=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},lniP:function(e,t,n){var r=e.exports=n("pm/U");r.Axes=n("JKEF"),r.Bodies=n("oT59"),r.Body=n("IbIC"),r.Bounds=n("Tgw/"),r.Collision=n("Z/YF"),r.Common=n("571F"),r.Composite=n("wAS/"),r.Composites=n("9Nbg"),r.Constraint=n("ga9t"),r.Contact=n("9K63"),r.Detector=n("ix+/"),r.Engine=n("nIFq"),r.Events=n("yTB+"),r.Grid=n("Sq1W"),r.Mouse=n("I5nt"),r.MouseConstraint=n("q4y7"),r.Pair=n("t8gT"),r.Pairs=n("ttsO"),r.Plugin=n("2Og8"),r.Query=n("NDQ1"),r.Render=n("lWug"),r.Resolver=n("3Slt"),r.Runner=n("4d8i"),r.SAT=n("DqtB"),r.Sleeping=n("yw0d"),r.Svg=n("0Aok"),r.Vector=n("m6Dm"),r.Vertices=n("0kzT"),r.World=n("Inl5"),r.Engine.run=r.Runner.run,r.Common.deprecated(r.Engine,"run","Engine.run ➤ use Matter.Runner.run(engine) instead")},m6Dm:function(e,t){var n={};e.exports=n,n.create=function(e,t){return{x:e||0,y:t||0}},n.clone=function(e){return{x:e.x,y:e.y}},n.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},n.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},n.rotate=function(e,t,n){var r=Math.cos(t),o=Math.sin(t);n||(n={});var i=e.x*r-e.y*o;return n.y=e.x*o+e.y*r,n.x=i,n},n.rotateAbout=function(e,t,n,r){var o=Math.cos(t),i=Math.sin(t);r||(r={});var a=n.x+((e.x-n.x)*o-(e.y-n.y)*i);return r.y=n.y+((e.x-n.x)*i+(e.y-n.y)*o),r.x=a,r},n.normalise=function(e){var t=n.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},n.dot=function(e,t){return e.x*t.x+e.y*t.y},n.cross=function(e,t){return e.x*t.y-e.y*t.x},n.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},n.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},n.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},n.mult=function(e,t){return{x:e.x*t,y:e.y*t}},n.div=function(e,t){return{x:e.x/t,y:e.y/t}},n.perp=function(e,t){return{x:(t=!0===t?-1:1)*-e.y,y:t*e.x}},n.neg=function(e){return{x:-e.x,y:-e.y}},n.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},n._temp=[n.create(),n.create(),n.create(),n.create(),n.create(),n.create()]},nIFq:function(e,t,n){var r={};e.exports=r;var o=n("yw0d"),i=n("3Slt"),a=n("ix+/"),s=n("ttsO"),c=n("yTB+"),l=n("wAS/"),d=n("ga9t"),u=n("571F"),p=n("IbIC");r.create=function(e){e=e||{};var t=u.extend({positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0}},e);return t.world=e.world||l.create({label:"World"}),t.pairs=e.pairs||s.create(),t.detector=e.detector||a.create(),t.grid={buckets:[]},t.world.gravity=t.gravity,t.broadphase=t.grid,t.metrics={},t},r.update=function(e,t){var n,p=u.now(),m=e.world,f=e.detector,v=e.pairs,g=e.timing,y=g.timestamp;t=void 0!==t?t:u._baseDelta,t*=g.timeScale,g.timestamp+=t,g.lastDelta=t;var x={timestamp:g.timestamp,delta:t};c.trigger(e,"beforeUpdate",x);var h=l.allBodies(m),b=l.allConstraints(m);for(m.isModified&&(a.setBodies(f,h),l.setModified(m,!1,!1,!0)),e.enableSleeping&&o.update(h,t),r._bodiesApplyGravity(h,e.gravity),t>0&&r._bodiesUpdate(h,t),d.preSolveAll(h),n=0;n<e.constraintIterations;n++)d.solveAll(b,t);d.postSolveAll(h),f.pairs=e.pairs;var M=a.collisions(f);s.update(v,M,y),e.enableSleeping&&o.afterCollisions(v.list),v.collisionStart.length>0&&c.trigger(e,"collisionStart",{pairs:v.collisionStart});var S=u.clamp(20/e.positionIterations,0,1);for(i.preSolvePosition(v.list),n=0;n<e.positionIterations;n++)i.solvePosition(v.list,t,S);for(i.postSolvePosition(h),d.preSolveAll(h),n=0;n<e.constraintIterations;n++)d.solveAll(b,t);for(d.postSolveAll(h),i.preSolveVelocity(v.list),n=0;n<e.velocityIterations;n++)i.solveVelocity(v.list,t);return r._bodiesUpdateVelocities(h),v.collisionActive.length>0&&c.trigger(e,"collisionActive",{pairs:v.collisionActive}),v.collisionEnd.length>0&&c.trigger(e,"collisionEnd",{pairs:v.collisionEnd}),r._bodiesClearForces(h),c.trigger(e,"afterUpdate",x),e.timing.lastElapsed=u.now()-p,e},r.merge=function(e,t){if(u.extend(e,t),t.world){e.world=t.world,r.clear(e);for(var n=l.allBodies(e.world),i=0;i<n.length;i++){var a=n[i];o.set(a,!1),a.id=u.nextId()}}},r.clear=function(e){s.clear(e.pairs),a.clear(e.detector)},r._bodiesClearForces=function(e){for(var t=e.length,n=0;n<t;n++){var r=e[n];r.force.x=0,r.force.y=0,r.torque=0}},r._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001,r=e.length;if((0!==t.x||0!==t.y)&&0!==n)for(var o=0;o<r;o++){var i=e[o];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*n,i.force.x+=i.mass*t.x*n)}},r._bodiesUpdate=function(e,t){for(var n=e.length,r=0;r<n;r++){var o=e[r];o.isStatic||o.isSleeping||p.update(o,t)}},r._bodiesUpdateVelocities=function(e){for(var t=e.length,n=0;n<t;n++)p.updateVelocities(e[n])}},oT59:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("571F"),a=n("IbIC"),s=n("Tgw/"),c=n("m6Dm");r.rectangle=function(e,t,n,r,s){s=s||{};var c={label:"Rectangle Body",position:{x:e,y:t},vertices:o.fromPath("L 0 0 L "+n+" 0 L "+n+" "+r+" L 0 "+r)};if(s.chamfer){var l=s.chamfer;c.vertices=o.chamfer(c.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete s.chamfer}return a.create(i.extend({},c,s))},r.trapezoid=function(e,t,n,r,s,c){c=c||{};var l,d=n*(s*=.5),u=d+(1-2*s)*n,p=u+d;l=s<.5?"L 0 0 L "+d+" "+-r+" L "+u+" "+-r+" L "+p+" 0":"L 0 0 L "+u+" "+-r+" L "+p+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:o.fromPath(l)};if(c.chamfer){var f=c.chamfer;m.vertices=o.chamfer(m.vertices,f.radius,f.quality,f.qualityMin,f.qualityMax),delete c.chamfer}return a.create(i.extend({},m,c))},r.circle=function(e,t,n,o,a){o=o||{};var s={label:"Circle Body",circleRadius:n};a=a||25;var c=Math.ceil(Math.max(10,Math.min(a,n)));return c%2==1&&(c+=1),r.polygon(e,t,c,n,i.extend({},s,o))},r.polygon=function(e,t,n,s,c){if(c=c||{},n<3)return r.circle(e,t,s,c);for(var l=2*Math.PI/n,d="",u=.5*l,p=0;p<n;p+=1){var m=u+p*l,f=Math.cos(m)*s,v=Math.sin(m)*s;d+="L "+f.toFixed(3)+" "+v.toFixed(3)+" "}var g={label:"Polygon Body",position:{x:e,y:t},vertices:o.fromPath(d)};if(c.chamfer){var y=c.chamfer;g.vertices=o.chamfer(g.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete c.chamfer}return a.create(i.extend({},g,c))},r.fromVertices=function(e,t,n,r,l,d,u,p){var m,f,v,g,y,x,h,b,M,S,w=i.getDecomp();for(m=Boolean(w&&w.quickDecomp),r=r||{},v=[],l=void 0!==l&&l,d=void 0!==d?d:.01,u=void 0!==u?u:10,p=void 0!==p?p:.01,i.isArray(n[0])||(n=[n]),M=0;M<n.length;M+=1)if(y=n[M],!(g=o.isConvex(y))&&!m&&i.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),g||!m)y=g?o.clockwiseSort(y):o.hull(y),v.push({position:{x:e,y:t},vertices:y});else{var C=y.map((function(e){return[e.x,e.y]}));w.makeCCW(C),!1!==d&&w.removeCollinearPoints(C,d),!1!==p&&w.removeDuplicatePoints&&w.removeDuplicatePoints(C,p);var A=w.quickDecomp(C);for(x=0;x<A.length;x++){var B=A[x].map((function(e){return{x:e[0],y:e[1]}}));u>0&&o.area(B)<u||v.push({position:o.centre(B),vertices:B})}}for(x=0;x<v.length;x++)v[x]=a.create(i.extend(v[x],r));if(l)for(x=0;x<v.length;x++){var k=v[x];for(h=x+1;h<v.length;h++){var R=v[h];if(s.overlaps(k.bounds,R.bounds)){var P=k.vertices,I=R.vertices;for(b=0;b<k.vertices.length;b++)for(S=0;S<R.vertices.length;S++){var _=c.magnitudeSquared(c.sub(P[(b+1)%P.length],I[S])),E=c.magnitudeSquared(c.sub(P[b],I[(S+1)%I.length]));_<5&&E<5&&(P[b].isInternal=!0,I[S].isInternal=!0)}}}}return v.length>1?(f=a.create(i.extend({parts:v.slice(0)},r)),a.setPosition(f,{x:e,y:t}),f):v[0]}},"pm/U":function(e,t,n){var r={};e.exports=r;var o=n("2Og8"),i=n("571F");r.name="matter-js",r.version="*",r.uses=[],r.used=[],r.use=function(){o.use(r,Array.prototype.slice.call(arguments))},r.before=function(e,t){return e=e.replace(/^Matter./,""),i.chainPathBefore(r,e,t)},r.after=function(e,t){return e=e.replace(/^Matter./,""),i.chainPathAfter(r,e,t)}},q4y7:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("yw0d"),a=n("I5nt"),s=n("yTB+"),c=n("ix+/"),l=n("ga9t"),d=n("wAS/"),u=n("571F"),p=n("Tgw/");r.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=a.create(e.render.canvas):t&&t.element?n=a.create(t.element):(n=a.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var o={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:l.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),collisionFilter:{category:1,mask:4294967295,group:0}},i=u.extend(o,t);return s.on(e,"beforeUpdate",(function(){var t=d.allBodies(e.world);r.update(i,t),r._triggerEvents(i)})),i},r.update=function(e,t){var n=e.mouse,r=e.constraint,a=e.body;if(0===n.button){if(r.bodyB)i.set(r.bodyB,!1),r.pointA=n.position;else for(var l=0;l<t.length;l++)if(a=t[l],p.contains(a.bounds,n.position)&&c.canCollide(a.collisionFilter,e.collisionFilter))for(var d=a.parts.length>1?1:0;d<a.parts.length;d++){var u=a.parts[d];if(o.contains(u.vertices,n.position)){r.pointA=n.position,r.bodyB=e.body=a,r.pointB={x:n.position.x-a.position.x,y:n.position.y-a.position.y},r.angleB=a.angle,i.set(a,!1),s.trigger(e,"startdrag",{mouse:n,body:a});break}}}else r.bodyB=e.body=null,r.pointB=null,a&&s.trigger(e,"enddrag",{mouse:n,body:a})},r._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents;n.mousemove&&s.trigger(e,"mousemove",{mouse:t}),n.mousedown&&s.trigger(e,"mousedown",{mouse:t}),n.mouseup&&s.trigger(e,"mouseup",{mouse:t}),a.clearSourceEvents(t)}},siNf:function(e,t,n){var r=r||{};r.cloth=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,o=(Matter.Body,Matter.Composites,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600}});t.run(d);var u=n.create();n.run(u,c);for(var p=r.cloth.cloth(200,200,20,12,5,5,!1,8),m=0;m<20;m++)p.bodies[m].isStatic=!0;a.add(l,[p,s.circle(300,500,80,{isStatic:!0,render:{fillStyle:"#060a19"}}),s.rectangle(500,480,80,80,{isStatic:!0,render:{fillStyle:"#060a19"}}),s.rectangle(400,609,800,50,{isStatic:!0})]);var f=i.create(d.canvas),v=o.create(c,{mouse:f,constraint:{stiffness:.98,render:{visible:!1}}});return a.add(l,v),d.mouse=f,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.cloth.title="Cloth",r.cloth.for=">=0.14.2",r.cloth.cloth=function(e,t,n,r,o,i,a,s,c,l){var d=Matter.Body,u=Matter.Bodies,p=Matter.Common,m=Matter.Composites,f=d.nextGroup(!0);c=p.extend({inertia:1/0,friction:1e-5,collisionFilter:{group:f},render:{visible:!1}},c),l=p.extend({stiffness:.06,render:{type:"line",anchors:!1}},l);var v=m.stack(e,t,n,r,o,i,(function(e,t){return u.circle(e,t,s,c)}));return m.mesh(v,n,r,a,l),v.label="Cloth Body",v},e.exports=r.cloth},t8gT:function(e,t,n){var r={};e.exports=r;var o=n("9K63");r.create=function(e,t){var n=e.bodyA,o=e.bodyB,i={id:r.id(n,o),bodyA:n,bodyB:o,collision:e,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:n.isSensor||o.isSensor,timeCreated:t,timeUpdated:t,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return r.update(i,e,t),i},r.update=function(e,t,n){var r=e.contacts,i=t.supports,a=e.activeContacts,s=t.parentA,c=t.parentB,l=s.vertices.length;e.isActive=!0,e.timeUpdated=n,e.collision=t,e.separation=t.depth,e.inverseMass=s.inverseMass+c.inverseMass,e.friction=s.friction<c.friction?s.friction:c.friction,e.frictionStatic=s.frictionStatic>c.frictionStatic?s.frictionStatic:c.frictionStatic,e.restitution=s.restitution>c.restitution?s.restitution:c.restitution,e.slop=s.slop>c.slop?s.slop:c.slop,t.pair=e,a.length=0;for(var d=0;d<i.length;d++){var u=i[d],p=u.body===s?u.index:l+u.index,m=r[p];m?a.push(m):a.push(r[p]=o.create(u))}},r.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},r.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}},tlRp:function(e,t,n){var r=r||{};r.sprites=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!1,wireframes:!1}});t.run(u);var p=n.create();n.run(p,l);var m={isStatic:!0};d.bodies=[],s.add(d,[c.rectangle(400,-10,820.5,50.5,m),c.rectangle(400,610,820.5,50.5,m),c.rectangle(810,300,50.5,620.5,m),c.rectangle(-10,300,50.5,620.5,m)]);var f=r.stack(20,20,10,4,0,0,(function(e,t){return o.random()>.35?c.rectangle(e,t,64,64,{render:{strokeStyle:"#ffffff",sprite:{texture:"./img/box.png"}}}):c.circle(e,t,46,{density:5e-4,frictionAir:.06,restitution:.3,friction:.01,render:{sprite:{texture:"./img/ball.png"}}})}));s.add(d,f);var v=a.create(u.canvas),g=i.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.sprites.title="Sprites",r.sprites.for=">=0.14.2",e.exports=r.sprites},ttsO:function(e,t,n){var r={};e.exports=r;var o=n("t8gT"),i=n("571F");r.create=function(e){return i.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},r.update=function(e,t,n){var r,i,a,s,c=e.list,l=c.length,d=e.table,u=t.length,p=e.collisionStart,m=e.collisionEnd,f=e.collisionActive;for(p.length=0,m.length=0,f.length=0,s=0;s<l;s++)c[s].confirmedActive=!1;for(s=0;s<u;s++)(a=(r=t[s]).pair)?(a.isActive?f.push(a):p.push(a),o.update(a,r,n),a.confirmedActive=!0):(d[(a=o.create(r,n)).id]=a,p.push(a),c.push(a));var v=[];for(l=c.length,s=0;s<l;s++)(a=c[s]).confirmedActive||(o.setActive(a,!1,n),m.push(a),a.collision.bodyA.isSleeping||a.collision.bodyB.isSleeping||v.push(s));for(s=0;s<v.length;s++)a=c[i=v[s]-s],c.splice(i,1),delete d[a.id]},r.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}},uZME:function(e,t,n){var r=n("lniP"),o=n("JBRW"),i=n("a+ms").compare,a=n("71Xj").demo;window.pathseg=n("v5Dj"),window.MatterTools=n("akk5"),window.Matter=r;var s=r.Common.keys(o).map((function(e){return{id:e,sourceLink:"https://github.com/liabru/matter-js/blob/master/examples/"+e+".js",name:o[e].title,init:o[e]}}));window.location.search.indexOf("compare")>=0?i(s,false):a(s,false)},vSND:function(e,t,n){var r=r||{};r.stats=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Common,o=Matter.Composites,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showStats:!0,showPerformance:!0}});t.run(u);var p=n.create();n.run(p,l);var m=o.stack(70,30,13,9,5,5,(function(e,t){return c.circle(e,t,10+20*r.random())}));s.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.stats.title="Stats & Performance",r.stats.for=">=0.16.1",e.exports=r.stats},"wAS/":function(e,t,n){var r={};e.exports=r;var o=n("yTB+"),i=n("571F"),a=n("Tgw/"),s=n("IbIC");r.create=function(e){return i.extend({id:i.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},e)},r.setModified=function(e,t,n,o){if(e.isModified=t,t&&e.cache&&(e.cache.allBodies=null,e.cache.allConstraints=null,e.cache.allComposites=null),n&&e.parent&&r.setModified(e.parent,t,n,o),o)for(var i=0;i<e.composites.length;i++){var a=e.composites[i];r.setModified(a,t,n,o)}},r.add=function(e,t){var n=[].concat(t);o.trigger(e,"beforeAdd",{object:t});for(var a=0;a<n.length;a++){var s=n[a];switch(s.type){case"body":if(s.parent!==s){i.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}r.addBody(e,s);break;case"constraint":r.addConstraint(e,s);break;case"composite":r.addComposite(e,s);break;case"mouseConstraint":r.addConstraint(e,s.constraint)}}return o.trigger(e,"afterAdd",{object:t}),e},r.remove=function(e,t,n){var i=[].concat(t);o.trigger(e,"beforeRemove",{object:t});for(var a=0;a<i.length;a++){var s=i[a];switch(s.type){case"body":r.removeBody(e,s,n);break;case"constraint":r.removeConstraint(e,s,n);break;case"composite":r.removeComposite(e,s,n);break;case"mouseConstraint":r.removeConstraint(e,s.constraint)}}return o.trigger(e,"afterRemove",{object:t}),e},r.addComposite=function(e,t){return e.composites.push(t),t.parent=e,r.setModified(e,!0,!0,!1),e},r.removeComposite=function(e,t,n){var o=i.indexOf(e.composites,t);if(-1!==o&&r.removeCompositeAt(e,o),n)for(var a=0;a<e.composites.length;a++)r.removeComposite(e.composites[a],t,!0);return e},r.removeCompositeAt=function(e,t){return e.composites.splice(t,1),r.setModified(e,!0,!0,!1),e},r.addBody=function(e,t){return e.bodies.push(t),r.setModified(e,!0,!0,!1),e},r.removeBody=function(e,t,n){var o=i.indexOf(e.bodies,t);if(-1!==o&&r.removeBodyAt(e,o),n)for(var a=0;a<e.composites.length;a++)r.removeBody(e.composites[a],t,!0);return e},r.removeBodyAt=function(e,t){return e.bodies.splice(t,1),r.setModified(e,!0,!0,!1),e},r.addConstraint=function(e,t){return e.constraints.push(t),r.setModified(e,!0,!0,!1),e},r.removeConstraint=function(e,t,n){var o=i.indexOf(e.constraints,t);if(-1!==o&&r.removeConstraintAt(e,o),n)for(var a=0;a<e.composites.length;a++)r.removeConstraint(e.composites[a],t,!0);return e},r.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),r.setModified(e,!0,!0,!1),e},r.clear=function(e,t,n){if(n)for(var o=0;o<e.composites.length;o++)r.clear(e.composites[o],t,!0);return t?e.bodies=e.bodies.filter((function(e){return e.isStatic})):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,r.setModified(e,!0,!0,!1),e},r.allBodies=function(e){if(e.cache&&e.cache.allBodies)return e.cache.allBodies;for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(r.allBodies(e.composites[n]));return e.cache&&(e.cache.allBodies=t),t},r.allConstraints=function(e){if(e.cache&&e.cache.allConstraints)return e.cache.allConstraints;for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(r.allConstraints(e.composites[n]));return e.cache&&(e.cache.allConstraints=t),t},r.allComposites=function(e){if(e.cache&&e.cache.allComposites)return e.cache.allComposites;for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(r.allComposites(e.composites[n]));return e.cache&&(e.cache.allComposites=t),t},r.get=function(e,t,n){var o,i;switch(n){case"body":o=r.allBodies(e);break;case"constraint":o=r.allConstraints(e);break;case"composite":o=r.allComposites(e).concat(e)}return o?0===(i=o.filter((function(e){return e.id.toString()===t.toString()}))).length?null:i[0]:null},r.move=function(e,t,n){return r.remove(e,t),r.add(n,t),e},r.rebase=function(e){for(var t=r.allBodies(e).concat(r.allConstraints(e)).concat(r.allComposites(e)),n=0;n<t.length;n++)t[n].id=i.nextId();return e},r.translate=function(e,t,n){for(var o=n?r.allBodies(e):e.bodies,i=0;i<o.length;i++)s.translate(o[i],t);return e},r.rotate=function(e,t,n,o){for(var i=Math.cos(t),a=Math.sin(t),c=o?r.allBodies(e):e.bodies,l=0;l<c.length;l++){var d=c[l],u=d.position.x-n.x,p=d.position.y-n.y;s.setPosition(d,{x:n.x+(u*i-p*a),y:n.y+(u*a+p*i)}),s.rotate(d,t)}return e},r.scale=function(e,t,n,o,i){for(var a=i?r.allBodies(e):e.bodies,c=0;c<a.length;c++){var l=a[c],d=l.position.x-o.x,u=l.position.y-o.y;s.setPosition(l,{x:o.x+d*t,y:o.y+u*n}),s.scale(l,t,n)}return e},r.bounds=function(e){for(var t=r.allBodies(e),n=[],o=0;o<t.length;o+=1){var i=t[o];n.push(i.bounds.min,i.bounds.max)}return a.create(n)}},wycb:function(e,t,n){var r=r||{};r.bridge=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.Common,a=Matter.Constraint,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.Composite,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=n.create();n.run(f,u);var v=r.nextGroup(!0),g=o.stack(160,290,15,1,0,0,(function(e,t){return d.rectangle(e-20,t,53,20,{collisionFilter:{group:v},chamfer:5,density:.005,frictionAir:.05,render:{fillStyle:"#060a19"}})}));o.chain(g,.3,0,-.3,0,{stiffness:.99,length:1e-4,render:{visible:!1}});var y=o.stack(250,50,6,3,0,0,(function(e,t){return d.rectangle(e,t,50,50,i.random(20,40))}));l.add(p,[g,y,d.rectangle(30,490,220,380,{isStatic:!0,chamfer:{radius:20}}),d.rectangle(770,490,220,380,{isStatic:!0,chamfer:{radius:20}}),a.create({pointA:{x:140,y:300},bodyB:g.bodies[0],pointB:{x:-25,y:0},length:2,stiffness:.9}),a.create({pointA:{x:660,y:300},bodyB:g.bodies[g.bodies.length-1],pointB:{x:25,y:0},length:2,stiffness:.9})]);var x=c.create(m.canvas),h=s.create(u,{mouse:x,constraint:{stiffness:.1,render:{visible:!1}}});return l.add(p,h),m.mouse=x,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.bridge.title="Bridge",r.bridge.for=">=0.14.2",e.exports=r.bridge},xoNv:function(e,t,n){var r=r||{};r.newtonsCradle=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,o=Matter.Body,i=(Matter.Composites,Matter.MouseConstraint),a=Matter.Mouse,s=Matter.Composite,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showVelocity:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.newtonsCradle.newtonsCradle(280,100,5,30,200);s.add(l,p),o.translate(p.bodies[0],{x:-180,y:-100}),p=r.newtonsCradle.newtonsCradle(280,380,7,20,140),s.add(l,p),o.translate(p.bodies[0],{x:-140,y:-100});var m=a.create(d.canvas),f=i.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:50},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.newtonsCradle.title="Newton's Cradle",r.newtonsCradle.for=">=0.14.2",r.newtonsCradle.newtonsCradle=function(e,t,n,r,o){for(var i=Matter.Composite,a=Matter.Constraint,s=Matter.Bodies,c=i.create({label:"Newtons Cradle"}),l=0;l<n;l++){var d=s.circle(e+l*(1.9*r),t+o,r,{inertia:1/0,restitution:1,friction:0,frictionAir:0,slop:.02*r}),u=a.create({pointA:{x:e+l*(1.9*r),y:t},bodyB:d});i.addBody(c,d),i.addConstraint(c,u)}return c},e.exports=r.newtonsCradle},"yTB+":function(e,t,n){var r={};e.exports=r;var o=n("571F");r.on=function(e,t,n){for(var r,o=t.split(" "),i=0;i<o.length;i++)r=o[i],e.events=e.events||{},e.events[r]=e.events[r]||[],e.events[r].push(n);return n},r.off=function(e,t,n){if(t){"function"==typeof t&&(n=t,t=o.keys(e.events).join(" "));for(var r=t.split(" "),i=0;i<r.length;i++){var a=e.events[r[i]],s=[];if(n&&a)for(var c=0;c<a.length;c++)a[c]!==n&&s.push(a[c]);e.events[r[i]]=s}}else e.events={}},r.trigger=function(e,t,n){var r,i,a,s,c=e.events;if(c&&o.keys(c).length>0){n||(n={}),r=t.split(" ");for(var l=0;l<r.length;l++)if(a=c[i=r[l]]){(s=o.clone(n,!1)).name=i,s.source=e;for(var d=0;d<a.length;d++)a[d].apply(e,[s])}}}},yWqE:function(e,t,n){var r=r||{};r.sensors=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,wireframes:!1}});t.run(d);var u=n.create();n.run(u,c);var p="#f55a3c",m="#f5d259",f=s.rectangle(400,300,500,50,{isSensor:!0,isStatic:!0,render:{strokeStyle:p,fillStyle:"transparent",lineWidth:1}});a.add(l,[f,s.rectangle(400,600,800,50,{isStatic:!0,render:{fillStyle:"#060a19",lineWidth:0}})]),a.add(l,s.circle(400,40,30,{render:{strokeStyle:m,fillStyle:"transparent",lineWidth:1}})),r.on(c,"collisionStart",(function(e){for(var t=e.pairs,n=0,r=t.length;n!=r;++n){var o=t[n];o.bodyA===f?o.bodyB.render.strokeStyle=p:o.bodyB===f&&(o.bodyA.render.strokeStyle=p)}})),r.on(c,"collisionEnd",(function(e){for(var t=e.pairs,n=0,r=t.length;n!=r;++n){var o=t[n];o.bodyA===f?o.bodyB.render.strokeStyle=m:o.bodyB===f&&(o.bodyA.render.strokeStyle=m)}}));var v=i.create(d.canvas),g=o.create(c,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,g),d.mouse=v,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.sensors.title="Sensors",r.sensors.for=">=0.14.2",e.exports=r.sensors},yw0d:function(e,t,n){var r={};e.exports=r;var o=n("IbIC"),i=n("yTB+"),a=n("571F");r._motionWakeThreshold=.18,r._motionSleepThreshold=.08,r._minBias=.9,r.update=function(e,t){for(var n=t/a._baseDelta,i=r._motionSleepThreshold,s=0;s<e.length;s++){var c=e[s],l=o.getSpeed(c),d=o.getAngularSpeed(c),u=l*l+d*d;if(0===c.force.x&&0===c.force.y){var p=Math.min(c.motion,u),m=Math.max(c.motion,u);c.motion=r._minBias*p+(1-r._minBias)*m,c.sleepThreshold>0&&c.motion<i?(c.sleepCounter+=1,c.sleepCounter>=c.sleepThreshold/n&&r.set(c,!0)):c.sleepCounter>0&&(c.sleepCounter-=1)}else r.set(c,!1)}},r.afterCollisions=function(e){for(var t=r._motionSleepThreshold,n=0;n<e.length;n++){var o=e[n];if(o.isActive){var i=o.collision,a=i.bodyA.parent,s=i.bodyB.parent;if(!(a.isSleeping&&s.isSleeping||a.isStatic||s.isStatic)&&(a.isSleeping||s.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:s,l=c===a?s:a;!c.isStatic&&l.motion>t&&r.set(c,!1)}}}},r.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&i.trigger(e,"sleepEnd"))}},zc7U:function(e,t,n){var r=r||{};r.circleStack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(100,179,10,10,20,0,(function(e,t){return s.circle(e,t,20)}));a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),p]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.circleStack.title="Circle Stack",r.circleStack.for=">=0.14.2",e.exports=r.circleStack}},[["uZME",1,2,3,4,5]]])}));