function goToHome(){isEmbed||window.self!==window.top?window.open("http://www.onlinedominogames.com","_blank"):window.location="/"}function initsocial(){var n=document.getElementById("socialframe");if(n)n:n.innerHTML='<div><table align="center"><tr><!--<td><button class="socialbtn btn-google" onclick="javascript:socialShare(\'google\'); return false;">Google+<\/button><\/td>--><td><button class="socialbtn btn-facebook" onclick="javascript:socialShare(\'facebook\'); return false;">Share<\/button><\/td><td><button class="socialbtn btn-tweet" onclick="javascript:socialShare(\'twitter\'); return false;">Tweet<\/button><\/td><\/tr><\/table><\/div>'}function socialShare(n){var i="http://www.onlinedominogames.com",t;switch(n){case"facebook":t="https://www.facebook.com/sharer/sharer.php?u="+i;break;case"google":t="https://plus.google.com/share?url="+i;break;case"twitter":t="https://twitter.com/intent/tweet?text=Play Online Domino Games&url="+i}var r=window.innerWidth/2,u=window.innerHeight/2,f=window.innerWidth/2-r/2+window.screenX,e=window.innerHeight/2-u/2+window.screenY,o="scrollbars=no, width="+r+", height="+u+", top="+e+", left="+f,s=window.open(t,"",o);window.focus&&s.focus()}function LocalStorageManager(){this.gameConfigKey="onlinedominogames-gameConfig";this.gameDataKey="onlinedominogames-gameData";this.gamesKey="onlinedominogames-games";this.gameStatsKey="onlinedominogames-gameStats";var n=this.localStorageSupported();this.storage=n?window.localStorage:window.fakeStorage}function returnBestScore(n){return n&&typeof n!="undefined"&&n!==0?n:"-"}function returnBestTime(n){return n&&typeof n!="undefined"&&n!==0?new Date(n*1e3).toISOString().substr(11,8):"-"}function LocalSessionManager(){var n=this.localSessionSupported();this.storage=n?window.sessionStorage:window.cookieStorage}function Node(n){this.data=n;this.parent=null;this.children=[]}function Queue(){this._oldestIndex=1;this._newestIndex=1;this._storage={}}function Tree(n){var t=new Node(n);this._root=t}function findIndex(n,t){for(var r,i=0;i<n.length;i++)n[i].data===t&&(r=i);return r}function SLNode(n){this.data=n;this.next=null}function SinglyLinkedList(){this.head=null;this.tail=null;this.numberOfValues=0}function Player(n,t){this[_0x58ea[4]]=n;this[_0x58ea[5]]=t}function Domino(n,t,i,r){this[_0x58ea[4]]=n+_0x58ea[6]+t;this[_0x58ea[7]]=n;this[_0x58ea[8]]=t;this[_0x58ea[9]]=i;this[_0x58ea[10]]=0;this[_0x58ea[11]]=0;this[_0x58ea[12]]=null;this[_0x58ea[13]]=r;this[_0x58ea[14]]=!1;this[_0x58ea[15]]=!1}function Deck(n,t,i,r,u,f){this[_0x58ea[24]]=[];this[_0x58ea[25]]=t;this[_0x58ea[14]]=!0;this[_0x58ea[26]]=0;this[_0x58ea[27]]=0;this[_0x58ea[28]]=0;this[_0x58ea[29]]=r;this[_0x58ea[30]]=u;this[_0x58ea[31]]=n?n:0;this[_0x58ea[32]]=!1;this[_0x58ea[10]]=0;this[_0x58ea[33]]=1;f&&(this[_0x58ea[34]]=f);this[_0x58ea[34]]&&this[_0x58ea[34]][_0x58ea[35]]&&(this[_0x58ea[35]]={x:this[_0x58ea[34]][_0x58ea[35]][_0x58ea[36]],y:this[_0x58ea[34]][_0x58ea[35]][_0x58ea[37]]});this[_0x58ea[31]]>0&&this[_0x58ea[38]](i)}function shuffle(n){for(var t=0,i=0,r=null,t=n[_0x58ea[43]]-1;t>0;t-=1)i=Math[_0x58ea[60]](Math[_0x58ea[59]]()*(t+1)),r=n[t],n[t]=n[i],n[i]=r}function LocalScaleManager(){}function LocalAudioManager(n){this[_0x58ea[25]]=n;this[_0x58ea[76]]={}}function GameManager(n){this[_0x58ea[25]]=n;this[_0x58ea[87]]={};this[_0x58ea[88]]=[]}function eliminateDuplicates(n){for(var u=n[_0x58ea[43]],r=[],i={},t=0;t<u;t++)i[n[t]]=n[t];for(t in i)r[_0x58ea[40]](i[t]);return r}function pluckInfoInArray(n,t){return n[_0x58ea[272]](function(n){for(var r={},i=0;i<t[_0x58ea[43]];i++)r[t[i]]=n[t[i]];return r})}function pluckInfoInObject(n,t){for(var r={},i=0;i<t[_0x58ea[43]];i++)r[t[i]]=n[t[i]];return r}function pluckInfoInObjArray(n,t,i){return n[_0x58ea[272]](function(n){for(var u={},r=0;r<t[_0x58ea[43]];r++)u[t[r]]=n[t[r]],typeof u[t[r]]===_0x58ea[273]&&(u[t[r]]=pluckInfoInObject(u[t[r]],i));return u})}function getQueryVariable(n){for(var u=window[_0x58ea[276]][_0x58ea[275]][_0x58ea[274]](1),r=u[_0x58ea[278]](_0x58ea[277]),i,t=0;t<r[_0x58ea[43]];t++)if(i=r[t][_0x58ea[278]](_0x58ea[279]),decodeURIComponent(i[0])==n)return decodeURIComponent(i[1])}function isPrime(n){if(n>1){for(i=2;i<=n-1;i++)if(n%i==0)return!1;return!0}return!1}function splice1(n,t){var i=n[_0x58ea[43]];if(i){while(t<i)n[t++]=n[t];--n[_0x58ea[43]]}}function log(n){window[_0x58ea[280]]&&log[_0x58ea[14]]&&console[_0x58ea[281]](n)}function initGameState(){mygame&&mygame[_0x5f5d[13]][_0x5f5d[12]](dominoGameState)}function initHelpModal(){var t=document[_0x5f5d[183]](_0x5f5d[182]),n;t&&(n=document[_0x5f5d[184]](_0x5f5d[96])[0],n&&(n[_0x5f5d[185]]=function(){t[_0x5f5d[187]][_0x5f5d[186]]=_0x5f5d[188]}))}function showHelp(){var n=document[_0x5f5d[183]](_0x5f5d[189]);n&&(n[_0x5f5d[187]][_0x5f5d[190]]=_0x5f5d[98]);initsocial()}function getGameConfig(n){for(var i,t=0,r=dominoGames[_0x5f5d[119]];t<r;t++)if(i=dominoGames[t],i[_0x5f5d[191]]===n)return i}function getGameName(n){for(var i,t=0,r=dominoGames[_0x5f5d[119]];t<r;t++)if(i=dominoGames[t],i[_0x5f5d[191]]===n)return i[_0x5f5d[155]];return _0x5f5d[66]}function launchHelpModal(){var n=document[_0x5f5d[183]](_0x5f5d[182]);n[_0x5f5d[187]][_0x5f5d[186]]=_0x5f5d[192]}var cookieConsent,_0x58ea,scaleManager,globalParams,SelectMode,SelectOpponents,SelectOptions;!function(n){if("object"==typeof exports)module.exports=n();else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self);t.p2=n()}}(function(){return function n(t,i,r){function u(f,o){var h,s;if(!i[f]){if(!t[f]){if(h="function"==typeof require&&require,!o&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'");}s=i[f]={exports:{}};t[f][0].call(s.exports,function(n){var i=t[f][1][n];return u(i||n)},s,s.exports,n,t,i,r)}return i[f].exports}for(var e="function"==typeof require&&require,f=0;f<r.length;f++)u(r[f]);return u}({1:[function(n,t){function i(){}var r=n("./Scalar");t.exports=i;i.lineInt=function(n,t,i){i=i||0;var u,f,h,e,o,c,s,l=[0,0];return u=n[1][1]-n[0][1],f=n[0][0]-n[1][0],h=u*n[0][0]+f*n[0][1],e=t[1][1]-t[0][1],o=t[0][0]-t[1][0],c=e*t[0][0]+o*t[0][1],s=u*o-e*f,r.eq(s,0,i)||(l[0]=(o*h-f*c)/s,l[1]=(u*c-e*h)/s),l};i.segmentsIntersect=function(n,t,i,r){var u=t[0]-n[0],f=t[1]-n[1],e=r[0]-i[0],o=r[1]-i[1],s,h;return e*f-o*u==0?!1:(s=(u*(i[1]-n[1])+f*(n[0]-i[0]))/(e*f-o*u),h=(e*(n[1]-i[1])+o*(i[0]-n[0]))/(o*u-e*f),s>=0&&s<=1&&h>=0&&h<=1)}},{"./Scalar":4}],2:[function(n,t){function i(){}t.exports=i;i.area=function(n,t,i){return(t[0]-n[0])*(i[1]-n[1])-(i[0]-n[0])*(t[1]-n[1])};i.left=function(n,t,r){return i.area(n,t,r)>0};i.leftOn=function(n,t,r){return i.area(n,t,r)>=0};i.right=function(n,t,r){return i.area(n,t,r)<0};i.rightOn=function(n,t,r){return i.area(n,t,r)<=0};var r=[],u=[];i.collinear=function(n,t,f,e){var o,s;if(e){o=r;s=u;o[0]=t[0]-n[0];o[1]=t[1]-n[1];s[0]=f[0]-t[0];s[1]=f[1]-t[1];var h=o[0]*s[0]+o[1]*s[1],c=Math.sqrt(o[0]*o[0]+o[1]*o[1]),l=Math.sqrt(s[0]*s[0]+s[1]*s[1]);return Math.acos(h/(c*l))<e}return 0==i.area(n,t,f)};i.sqdist=function(n,t){var i=t[0]-n[0],r=t[1]-n[1];return i*i+r*r}},{}],3:[function(n,t){function i(){this.vertices=[]}function f(n,t,i,r,u){u=u||0;var f=t[1]-n[1],e=n[0]-t[0],l=f*n[0]+e*n[1],o=r[1]-i[1],h=i[0]-r[0],a=o*i[0]+h*i[1],c=f*h-o*e;return s.eq(c,0,u)?[0,0]:[(h*l-e*a)/c,(f*a-o*l)/c]}var u=n("./Line"),r=n("./Point"),s=n("./Scalar"),e,o;t.exports=i;i.prototype.at=function(n){var i=this.vertices,t=i.length;return i[n<0?n%t+t:n%t]};i.prototype.first=function(){return this.vertices[0]};i.prototype.last=function(){return this.vertices[this.vertices.length-1]};i.prototype.clear=function(){this.vertices.length=0};i.prototype.append=function(n,t,i){if(void 0===t)throw new Error("From is not given!");if(void 0===i)throw new Error("To is not given!");if(i-1<t)throw new Error("lol1");if(i>n.vertices.length)throw new Error("lol2");if(t<0)throw new Error("lol3");for(var r=t;r<i;r++)this.vertices.push(n.vertices[r])};i.prototype.makeCCW=function(){for(var n=0,t=this.vertices,i=1;i<this.vertices.length;++i)(t[i][1]<t[n][1]||t[i][1]==t[n][1]&&t[i][0]>t[n][0])&&(n=i);r.left(this.at(n-1),this.at(n),this.at(n+1))||this.reverse()};i.prototype.reverse=function(){for(var n=[],t=0,i=this.vertices.length;t!==i;t++)n.push(this.vertices.pop());this.vertices=n};i.prototype.isReflex=function(n){return r.right(this.at(n-1),this.at(n),this.at(n+1))};e=[];o=[];i.prototype.canSee=function(n,t){var h,c,f=e,s=o,i;if(r.leftOn(this.at(n+1),this.at(n),this.at(t))&&r.rightOn(this.at(n-1),this.at(n),this.at(t)))return!1;for(c=r.sqdist(this.at(n),this.at(t)),i=0;i!==this.vertices.length;++i)if((i+1)%this.vertices.length!==n&&i!==n&&r.leftOn(this.at(n),this.at(t),this.at(i+1))&&r.rightOn(this.at(n),this.at(t),this.at(i))&&(f[0]=this.at(n),f[1]=this.at(t),s[0]=this.at(i),s[1]=this.at(i+1),h=u.lineInt(f,s),r.sqdist(this.at(n),h)<c))return!1;return!0};i.prototype.copy=function(n,t,r){var f=r||new i,u;if(f.clear(),n<t)for(u=n;u<=t;u++)f.vertices.push(this.vertices[u]);else{for(u=0;u<=t;u++)f.vertices.push(this.vertices[u]);for(u=n;u<this.vertices.length;u++)f.vertices.push(this.vertices[u])}return f};i.prototype.getCutEdges=function(){for(var t,u,f=[],r=[],e=[],o=new i,s=Number.MAX_VALUE,n=0;n<this.vertices.length;++n)if(this.isReflex(n))for(t=0;t<this.vertices.length;++t)if(this.canSee(n,t)){for(r=this.copy(n,t,o).getCutEdges(),e=this.copy(t,n,o).getCutEdges(),u=0;u<e.length;u++)r.push(e[u]);r.length<s&&(f=r,s=r.length,f.push([this.at(n),this.at(t)]))}return f};i.prototype.decomp=function(){var n=this.getCutEdges();return n.length>0?this.slice(n):[this]};i.prototype.slice=function(n){var r,i,u,t,f;if(0==n.length)return[this];if(n instanceof Array&&n.length&&n[0]instanceof Array&&2==n[0].length&&n[0][0]instanceof Array){for(r=[this],i=0;i<n.length;i++)for(u=n[i],t=0;t<r.length;t++)if(f=r[t].slice(u),f){r.splice(t,1);r.push(f[0],f[1]);break}return r}var u=n,i=this.vertices.indexOf(u[0]),t=this.vertices.indexOf(u[1]);return-1!=i&&-1!=t&&[this.copy(i,t),this.copy(t,i)]};i.prototype.isSimple=function(){for(var i,n=this.vertices,t=0;t<n.length-1;t++)for(i=0;i<t-1;i++)if(u.segmentsIntersect(n[t],n[t+1],n[i],n[i+1]))return!1;for(t=1;t<n.length-2;t++)if(u.segmentsIntersect(n[0],n[n.length-1],n[t],n[t+1]))return!1;return!0};i.prototype.quickDecomp=function(n,t,u,e,o,s){var c,l;o=o||100;s=s||0;e=e||25;n=void 0!==n?n:[];t=t||[];u=u||[];var d=[0,0],g=[0,0],a=[0,0],nt=0,tt=0,k=0,it=0,p=0,w=0,b=0,v=new i,y=new i,h=this,rt=this.vertices;if(rt.length<3)return n;if(++s>o)return console.warn("quickDecomp: max level ("+o+") reached."),n;for(c=0;c<this.vertices.length;++c)if(h.isReflex(c)){for(t.push(h.vertices[c]),nt=tt=Number.MAX_VALUE,l=0;l<this.vertices.length;++l)r.left(h.at(c-1),h.at(c),h.at(l))&&r.rightOn(h.at(c-1),h.at(c),h.at(l-1))&&(a=f(h.at(c-1),h.at(c),h.at(l),h.at(l-1)),r.right(h.at(c+1),h.at(c),a)&&(k=r.sqdist(h.vertices[c],a))<tt&&(tt=k,g=a,w=l)),r.left(h.at(c+1),h.at(c),h.at(l+1))&&r.rightOn(h.at(c+1),h.at(c),h.at(l))&&(a=f(h.at(c+1),h.at(c),h.at(l),h.at(l+1)),r.left(h.at(c-1),h.at(c),a)&&(k=r.sqdist(h.vertices[c],a))<nt&&(nt=k,d=a,p=l));if(w==(p+1)%this.vertices.length)a[0]=(g[0]+d[0])/2,a[1]=(g[1]+d[1])/2,u.push(a),c<p?(v.append(h,c,p+1),v.vertices.push(a),y.vertices.push(a),0!=w&&y.append(h,w,h.vertices.length),y.append(h,0,c+1)):(0!=c&&v.append(h,c,h.vertices.length),v.append(h,0,p+1),v.vertices.push(a),y.vertices.push(a),y.append(h,w,c+1));else{if(w>p&&(p+=this.vertices.length),it=Number.MAX_VALUE,p<w)return n;for(l=w;l<=p;++l)r.leftOn(h.at(c-1),h.at(c),h.at(l))&&r.rightOn(h.at(c+1),h.at(c),h.at(l))&&(k=r.sqdist(h.at(c),h.at(l)))<it&&(it=k,b=l%this.vertices.length);c<b?(v.append(h,c,b+1),0!=b&&y.append(h,b,rt.length),y.append(h,0,c+1)):(0!=c&&v.append(h,c,rt.length),v.append(h,0,b+1),y.append(h,b,c+1))}return v.vertices.length<y.vertices.length?(v.quickDecomp(n,t,u,e,o,s),y.quickDecomp(n,t,u,e,o,s)):(y.quickDecomp(n,t,u,e,o,s),v.quickDecomp(n,t,u,e,o,s)),n}return n.push(this),n};i.prototype.removeCollinearPoints=function(n){for(var i=0,t=this.vertices.length-1;this.vertices.length>3&&t>=0;--t)r.collinear(this.at(t-1),this.at(t),this.at(t+1),n)&&(this.vertices.splice(t%this.vertices.length,1),t--,i++);return i}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(n,t){function i(){}t.exports=i;i.eq=function(n,t,i){return i=i||0,Math.abs(n-t)<i}},{}],5:[function(n,t){t.exports={Polygon:n("./Polygon"),Point:n("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(n,t){t.exports={name:"p2",version:"0.7.1",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.1"}}},{}],7:[function(n,t){function r(n){this.lowerBound=i.create();n&&n.lowerBound&&i.copy(this.lowerBound,n.lowerBound);this.upperBound=i.create();n&&n.upperBound&&i.copy(this.upperBound,n.upperBound)}var i=n("../math/vec2"),u;n("../utils/Utils");t.exports=r;u=i.create();r.prototype.setFromPoints=function(n,t,r,f){var s=this.lowerBound,h=this.upperBound,o,l,a,e;"number"!=typeof r&&(r=0);0!==r?i.rotate(s,n[0],r):i.copy(s,n[0]);i.copy(h,s);for(var v=Math.cos(r),y=Math.sin(r),c=1;c<n.length;c++)for(o=n[c],0!==r&&(l=o[0],a=o[1],u[0]=v*l-y*a,u[1]=y*l+v*a,o=u),e=0;e<2;e++)o[e]>h[e]&&(h[e]=o[e]),o[e]<s[e]&&(s[e]=o[e]);t&&(i.add(this.lowerBound,this.lowerBound,t),i.add(this.upperBound,this.upperBound,t));f&&(this.lowerBound[0]-=f,this.lowerBound[1]-=f,this.upperBound[0]+=f,this.upperBound[1]+=f)};r.prototype.copy=function(n){i.copy(this.lowerBound,n.lowerBound);i.copy(this.upperBound,n.upperBound)};r.prototype.extend=function(n){for(var i,r,t=2;t--;)i=n.lowerBound[t],this.lowerBound[t]>i&&(this.lowerBound[t]=i),r=n.upperBound[t],this.upperBound[t]<r&&(this.upperBound[t]=r)};r.prototype.overlaps=function(n){var r=this.lowerBound,t=this.upperBound,u=n.lowerBound,i=n.upperBound;return(u[0]<=t[0]&&t[0]<=i[0]||r[0]<=i[0]&&i[0]<=t[0])&&(u[1]<=t[1]&&t[1]<=i[1]||r[1]<=i[1]&&i[1]<=t[1])};r.prototype.containsPoint=function(n){var t=this.lowerBound,i=this.upperBound;return t[0]<=n[0]&&n[0]<=i[0]&&t[1]<=n[1]&&n[1]<=i[1]};r.prototype.overlapsRay=function(n){var t=1/n.direction[0],i=1/n.direction[1],r=(this.lowerBound[0]-n.from[0])*t,u=(this.upperBound[0]-n.from[0])*t,f=(this.lowerBound[1]-n.from[1])*i,e=(this.upperBound[1]-n.from[1])*i,o=Math.max(Math.max(Math.min(r,u),Math.min(f,e))),s=Math.min(Math.min(Math.max(r,u),Math.max(f,e)));return s<0?-1:o>s?-1:o}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(n,t){function i(n){this.type=n;this.result=[];this.world=null;this.boundingVolumeType=i.AABB}var u=n("../math/vec2"),r=n("../objects/Body"),f;t.exports=i;i.AABB=1;i.BOUNDING_CIRCLE=2;i.prototype.setWorld=function(n){this.world=n};i.prototype.getCollisionPairs=function(){};f=u.create();i.boundingRadiusCheck=function(n,t){u.sub(f,n.position,t.position);var r=u.squaredLength(f),i=n.boundingRadius+t.boundingRadius;return r<=i*i};i.aabbCheck=function(n,t){return n.getAABB().overlaps(t.getAABB())};i.prototype.boundingVolumeCheck=function(n,t){var r;switch(this.boundingVolumeType){case i.BOUNDING_CIRCLE:r=i.boundingRadiusCheck(n,t);break;case i.AABB:r=i.aabbCheck(n,t);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType);}return r};i.canCollide=function(n,t){var u=r.KINEMATIC,i=r.STATIC;return(n.type!==i||t.type!==i)&&!(n.type===u&&t.type===i||n.type===i&&t.type===u)&&(n.type!==u||t.type!==u)&&(n.sleepState!==r.SLEEPING||t.sleepState!==r.SLEEPING)&&!(n.sleepState===r.SLEEPING&&t.type===i||t.sleepState===r.SLEEPING&&n.type===i)};i.NAIVE=1;i.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(n,t){function i(){r.call(this,r.NAIVE)}n("../shapes/Circle");n("../shapes/Plane");n("../shapes/Shape");n("../shapes/Particle");var r=n("../collision/Broadphase");n("../math/vec2");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.getCollisionPairs=function(n){var e=n.bodies,o=this.result,t,s,i,u,f;for(o.length=0,t=0,s=e.length;t!==s;t++)for(i=e[t],u=0;u<t;u++)f=e[u],r.canCollide(i,f)&&this.boundingVolumeCheck(i,f)&&o.push(i,f);return o};i.prototype.aabbQuery=function(n,t,i){var f,u,r;for(i=i||[],f=n.bodies,u=0;u<f.length;u++)r=f[u],r.aabbNeedsUpdate&&r.updateAABB(),r.aabb.overlaps(t)&&i.push(r);return i}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(n,t){function u(){this.contactEquations=[];this.frictionEquations=[];this.enableFriction=!0;this.enabledEquations=!0;this.slipForce=10;this.frictionCoefficient=.3;this.surfaceVelocity=0;this.contactEquationPool=new ht({size:32});this.frictionEquationPool=new ct({size:64});this.restitution=0;this.stiffness=v.DEFAULT_STIFFNESS;this.relaxation=v.DEFAULT_RELAXATION;this.frictionStiffness=v.DEFAULT_STIFFNESS;this.frictionRelaxation=v.DEFAULT_RELAXATION;this.enableFrictionReduction=!0;this.collidingBodiesLastStep=new lt;this.contactSkinSize=.01}function b(n,t){i.set(n.vertices[0],.5*-t.length,-t.radius);i.set(n.vertices[1],.5*t.length,-t.radius);i.set(n.vertices[2],.5*t.length,t.radius);i.set(n.vertices[3],.5*-t.length,t.radius)}function it(n,t,u,f){for(var w,b,a,s=ri,h=ui,v=fi,y=ei,p=n,o=t.vertices,c=null,l=0;l!==o.length+1;l++){if(w=o[l%o.length],b=o[(l+1)%o.length],i.rotate(s,w,f),i.rotate(h,b,f),e(s,s,u),e(h,h,u),r(v,s,p),r(y,h,p),a=i.crossLength(v,y),null===c&&(c=a),a*c<=0)return!1;c=a}return!0}var i=n("../math/vec2"),r=i.sub,e=i.add,o=i.dot,ht=(n("../utils/Utils"),n("../utils/ContactEquationPool")),ct=n("../utils/FrictionEquationPool"),lt=n("../utils/TupleDictionary"),v=n("../equations/Equation"),at=(n("../equations/ContactEquation"),n("../equations/FrictionEquation"),n("../shapes/Circle")),vt=n("../shapes/Convex"),f=n("../shapes/Shape"),y=(n("../objects/Body"),n("../shapes/Box")),et,ot,st;t.exports=u;var p=i.fromValues(0,1),s=i.fromValues(0,0),h=i.fromValues(0,0),c=i.fromValues(0,0),l=i.fromValues(0,0),a=i.fromValues(0,0),k=i.fromValues(0,0),w=i.fromValues(0,0),d=i.fromValues(0,0),g=i.fromValues(0,0),nt=i.fromValues(0,0),rt=i.fromValues(0,0),yt=i.fromValues(0,0),tt=i.fromValues(0,0),ut=i.fromValues(0,0),pt=i.fromValues(0,0),wt=i.fromValues(0,0),bt=i.fromValues(0,0),kt=i.fromValues(0,0),ft=[],dt=i.create(),gt=i.create();u.prototype.bodiesOverlap=function(n,t){for(var i,u,s,r,e=dt,o=gt,f=0,h=n.shapes.length;f!==h;f++)for(i=n.shapes[f],n.toWorldFrame(e,i.position),u=0,s=t.shapes.length;u!==s;u++)if(r=t.shapes[u],t.toWorldFrame(o,r.position),this[i.type|r.type](n,i,e,i.angle+n.angle,t,r,o,r.angle+t.angle,!0))return!0;return!1};u.prototype.collidedLastStep=function(n,t){var i=0|n.id,r=0|t.id;return!!this.collidingBodiesLastStep.get(i,r)};u.prototype.reset=function(){var t,i;for(this.collidingBodiesLastStep.reset(),t=this.contactEquations,i=t.length;i--;){var r=t[i],e=r.bodyA.id,o=r.bodyB.id;this.collidingBodiesLastStep.set(e,o,!0)}for(var u=this.contactEquations,f=this.frictionEquations,n=0;n<u.length;n++)this.contactEquationPool.release(u[n]);for(n=0;n<f.length;n++)this.frictionEquationPool.release(f[n]);this.contactEquations.length=this.frictionEquations.length=0};u.prototype.createContactEquation=function(n,t,i,r){var u=this.contactEquationPool.get();return u.bodyA=n,u.bodyB=t,u.shapeA=i,u.shapeB=r,u.restitution=this.restitution,u.firstImpact=!this.collidedLastStep(n,t),u.stiffness=this.stiffness,u.relaxation=this.relaxation,u.needsUpdate=!0,u.enabled=this.enabledEquations,u.offset=this.contactSkinSize,u};u.prototype.createFrictionEquation=function(n,t,i,r){var u=this.frictionEquationPool.get();return u.bodyA=n,u.bodyB=t,u.shapeA=i,u.shapeB=r,u.setSlipForce(this.slipForce),u.frictionCoefficient=this.frictionCoefficient,u.relativeVelocity=this.surfaceVelocity,u.enabled=this.enabledEquations,u.needsUpdate=!0,u.stiffness=this.frictionStiffness,u.relaxation=this.frictionRelaxation,u.contactEquations.length=0,u};u.prototype.createFrictionFromContact=function(n){var t=this.createFrictionEquation(n.bodyA,n.bodyB,n.shapeA,n.shapeB);return i.copy(t.contactPointA,n.contactPointA),i.copy(t.contactPointB,n.contactPointB),i.rotate90cw(t.t,n.normalA),t.contactEquations.push(n),t};u.prototype.createFrictionFromAverage=function(n){var r=this.contactEquations[this.contactEquations.length-1],t=this.createFrictionEquation(r.bodyA,r.bodyB,r.shapeA,r.shapeB),e=r.bodyA,u,f;for(r.bodyB,i.set(t.contactPointA,0,0),i.set(t.contactPointB,0,0),i.set(t.t,0,0),u=0;u!==n;u++)(r=this.contactEquations[this.contactEquations.length-1-u]).bodyA===e?(i.add(t.t,t.t,r.normalA),i.add(t.contactPointA,t.contactPointA,r.contactPointA),i.add(t.contactPointB,t.contactPointB,r.contactPointB)):(i.sub(t.t,t.t,r.normalA),i.add(t.contactPointA,t.contactPointA,r.contactPointB),i.add(t.contactPointB,t.contactPointB,r.contactPointA)),t.contactEquations.push(r);return f=1/n,i.scale(t.contactPointA,t.contactPointA,f),i.scale(t.contactPointB,t.contactPointB,f),i.normalize(t.t,t.t),i.rotate90cw(t.t,t.t),t};u.prototype[f.LINE|f.CONVEX]=u.prototype.convexLine=function(n,t,i,r,u,f,e,o,s){return!s&&0};u.prototype[f.LINE|f.BOX]=u.prototype.lineBox=function(n,t,i,r,u,f,e,o,s){return!s&&0};et=new y({width:1,height:1});ot=i.create();u.prototype[f.CAPSULE|f.CONVEX]=u.prototype[f.CAPSULE|f.BOX]=u.prototype.convexCapsule=function(n,t,r,u,f,e,o,s,h){var c=ot,l,a,v;return(i.set(c,e.length/2,0),i.rotate(c,c,s),i.add(c,c,o),l=this.circleConvex(f,e,c,s,n,t,r,u,h,e.radius),i.set(c,-e.length/2,0),i.rotate(c,c,s),i.add(c,c,o),a=this.circleConvex(f,e,c,s,n,t,r,u,h,e.radius),h&&(l||a))?!0:(v=et,b(v,e),this.convexConvex(n,t,r,u,f,v,o,s,h)+l+a)};u.prototype[f.CAPSULE|f.LINE]=u.prototype.lineCapsule=function(n,t,i,r,u,f,e,o,s){return!s&&0};var ni=i.create(),ti=i.create(),ii=new y({width:1,height:1});u.prototype[f.CAPSULE|f.CAPSULE]=u.prototype.capsuleCapsule=function(n,t,r,u,f,e,o,s,h){for(var p,k,y,d,v,g,c=ni,l=ti,a=0,w=0;w<2;w++)for(i.set(c,(0===w?-1:1)*t.length/2,0),i.rotate(c,c,u),i.add(c,c,r),p=0;p<2;p++){if(i.set(l,(0===p?-1:1)*e.length/2,0),i.rotate(l,l,s),i.add(l,l,o),this.enableFrictionReduction&&(v=this.enableFriction,this.enableFriction=!1),k=this.circleCircle(n,t,c,u,f,e,l,s,h,t.radius,e.radius),this.enableFrictionReduction&&(this.enableFriction=v),h&&k)return!0;a+=k}return(this.enableFrictionReduction&&(v=this.enableFriction,this.enableFriction=!1),y=ii,b(y,t),d=this.convexCapsule(n,y,r,u,f,e,o,s,h),this.enableFrictionReduction&&(this.enableFriction=v),h&&d)?!0:((a+=d,this.enableFrictionReduction)&&(v=this.enableFriction,this.enableFriction=!1),b(y,e),g=this.convexCapsule(f,y,o,s,n,t,r,u,h),this.enableFrictionReduction&&(this.enableFriction=v),!(!h||!g)||(a+=g,this.enableFrictionReduction&&a&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(a)),a))};u.prototype[f.LINE|f.LINE]=u.prototype.lineLine=function(n,t,i,r,u,f,e,o,s){return!s&&0};u.prototype[f.PLANE|f.LINE]=u.prototype.planeLine=function(n,t,u,f,v,y,b,nt,tt){var rt=s,ut=h,et=c,ot=l,pt=a,wt=k,st=w,ht=d,bt=g,ct=ft,lt=0,at,vt,yt,it;for(i.set(rt,-y.length/2,0),i.set(ut,y.length/2,0),i.rotate(et,rt,nt),i.rotate(ot,ut,nt),e(et,et,b),e(ot,ot,b),i.copy(rt,et),i.copy(ut,ot),r(pt,ut,rt),i.normalize(wt,pt),i.rotate90cw(bt,wt),i.rotate(ht,p,f),ct[0]=rt,ct[1]=ut,at=0;at<ct.length;at++)if(vt=ct[at],r(st,vt,u),yt=o(st,ht),yt<0){if(tt)return!0;it=this.createContactEquation(n,v,t,y);lt++;i.copy(it.normalA,ht);i.normalize(it.normalA,it.normalA);i.scale(st,ht,yt);r(it.contactPointA,vt,st);r(it.contactPointA,it.contactPointA,n.position);r(it.contactPointB,vt,b);e(it.contactPointB,it.contactPointB,b);r(it.contactPointB,it.contactPointB,v.position);this.contactEquations.push(it);this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(it))}return!tt&&(this.enableFrictionReduction||lt&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(lt)),lt)};u.prototype[f.PARTICLE|f.CAPSULE]=u.prototype.particleCapsule=function(n,t,i,r,u,f,e,o,s){return this.circleLine(n,t,i,r,u,f,e,o,s,f.radius,0)};u.prototype[f.CIRCLE|f.LINE]=u.prototype.circleLine=function(n,t,u,f,v,y,p,b,it,et,ot){var et=et||0,ot=void 0!==ot?ot:t.radius,ni=s,ct=h,at=c,si=l,vt=a,ui=k,pt=w,ht=d,lt=g,bt=nt,kt=rt,wt=yt,fi=tt,ei=ut,dt=ft,ti,ii,gt,ri,st;if(i.set(ht,-y.length/2,0),i.set(lt,y.length/2,0),i.rotate(bt,ht,b),i.rotate(kt,lt,b),e(bt,bt,p),e(kt,kt,p),i.copy(ht,bt),i.copy(lt,kt),r(ui,lt,ht),i.normalize(pt,ui),i.rotate90cw(vt,pt),r(wt,u,ht),ti=o(wt,vt),r(si,ht,p),r(fi,u,p),ii=ot+et,Math.abs(ti)<ii){i.scale(ni,vt,ti);r(at,u,ni);i.scale(ct,vt,o(vt,fi));i.normalize(ct,ct);i.scale(ct,ct,et);e(at,at,ct);var oi=o(pt,at),hi=o(pt,ht),ci=o(pt,lt);if(oi>hi&&oi<ci)return it?!0:(st=this.createContactEquation(n,v,t,y),i.scale(st.normalA,ni,-1),i.normalize(st.normalA,st.normalA),i.scale(st.contactPointA,st.normalA,ot),e(st.contactPointA,st.contactPointA,u),r(st.contactPointA,st.contactPointA,n.position),r(st.contactPointB,at,p),e(st.contactPointB,st.contactPointB,p),r(st.contactPointB,st.contactPointB,v.position),this.contactEquations.push(st),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(st)),1)}for(dt[0]=ht,dt[1]=lt,gt=0;gt<dt.length;gt++)if(ri=dt[gt],r(wt,ri,u),i.squaredLength(wt)<Math.pow(ii,2))return it?!0:(st=this.createContactEquation(n,v,t,y),i.copy(st.normalA,wt),i.normalize(st.normalA,st.normalA),i.scale(st.contactPointA,st.normalA,ot),e(st.contactPointA,st.contactPointA,u),r(st.contactPointA,st.contactPointA,n.position),r(st.contactPointB,ri,p),i.scale(ei,st.normalA,-et),e(st.contactPointB,st.contactPointB,ei),e(st.contactPointB,st.contactPointB,p),r(st.contactPointB,st.contactPointB,v.position),this.contactEquations.push(st),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(st)),1);return 0};u.prototype[f.CIRCLE|f.CAPSULE]=u.prototype.circleCapsule=function(n,t,i,r,u,f,e,o,s){return this.circleLine(n,t,i,r,u,f,e,o,s,f.radius)};u.prototype[f.CIRCLE|f.CONVEX]=u.prototype[f.CIRCLE|f.BOX]=u.prototype.circleConvex=function(n,t,u,f,o,v,y,p,w,b){for(var ni,ti,lt,ii,k,b="number"==typeof b?b:t.radius,et=s,st=h,vt=c,yt=l,ht=a,at=nt,ot=rt,ct=tt,g=ut,bt=pt,kt=wt,dt=!1,gt=Number.MAX_VALUE,ft=v.vertices,d=0;d!==ft.length+1;d++)ni=ft[d%ft.length],ti=ft[(d+1)%ft.length],(i.rotate(et,ni,p),i.rotate(st,ti,p),e(et,et,y),e(st,st,y),r(vt,st,et),i.normalize(yt,vt),i.rotate90cw(ht,yt),i.scale(g,ht,-t.radius),e(g,g,u),it(g,v,y,p))&&(i.sub(bt,et,g),lt=Math.abs(i.dot(bt,ht)),lt<gt&&(i.copy(kt,g),gt=lt,i.scale(ct,ht,lt),i.add(ct,ct,g),dt=!0));if(dt)return w?!0:(k=this.createContactEquation(n,o,t,v),i.sub(k.normalA,kt,u),i.normalize(k.normalA,k.normalA),i.scale(k.contactPointA,k.normalA,b),e(k.contactPointA,k.contactPointA,u),r(k.contactPointA,k.contactPointA,n.position),r(k.contactPointB,ct,y),e(k.contactPointB,k.contactPointB,y),r(k.contactPointB,k.contactPointB,o.position),this.contactEquations.push(k),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(k)),1);if(b>0)for(d=0;d<ft.length;d++)if(ii=ft[d],i.rotate(ot,ii,p),e(ot,ot,y),r(at,ot,u),i.squaredLength(at)<Math.pow(b,2))return w?!0:(k=this.createContactEquation(n,o,t,v),i.copy(k.normalA,at),i.normalize(k.normalA,k.normalA),i.scale(k.contactPointA,k.normalA,b),e(k.contactPointA,k.contactPointA,u),r(k.contactPointA,k.contactPointA,n.position),r(k.contactPointB,ot,y),e(k.contactPointB,k.contactPointB,y),r(k.contactPointB,k.contactPointB,o.position),this.contactEquations.push(k),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(k)),1);return 0};var ri=i.create(),ui=i.create(),fi=i.create(),ei=i.create();u.prototype[f.PARTICLE|f.CONVEX]=u.prototype[f.PARTICLE|f.BOX]=u.prototype.particleConvex=function(n,t,u,f,v,y,p,b,d){var rt=s,ot=h,ct=c,lt=l,ut=a,ni=k,ti=w,at=nt,st=tt,vt=bt,yt=kt,pt=Number.MAX_VALUE,wt=!1,ft=y.vertices,et,dt,gt,ht,g;if(!it(u,y,p,b))return 0;if(d)return!0;for(et=0;et!==ft.length+1;et++)dt=ft[et%ft.length],gt=ft[(et+1)%ft.length],i.rotate(rt,dt,b),i.rotate(ot,gt,b),e(rt,rt,p),e(ot,ot,p),r(ct,ot,rt),i.normalize(lt,ct),i.rotate90cw(ut,lt),r(at,u,rt),o(at,ut),r(ni,rt,p),r(ti,u,p),i.sub(vt,rt,u),ht=Math.abs(i.dot(vt,ut)),ht<pt&&(pt=ht,i.scale(st,ut,ht),i.add(st,st,u),i.copy(yt,ut),wt=!0);return wt?(g=this.createContactEquation(n,v,t,y),i.scale(g.normalA,yt,-1),i.normalize(g.normalA,g.normalA),i.set(g.contactPointA,0,0),e(g.contactPointA,g.contactPointA,u),r(g.contactPointA,g.contactPointA,n.position),r(g.contactPointB,st,p),e(g.contactPointB,g.contactPointB,p),r(g.contactPointB,g.contactPointB,v.position),this.contactEquations.push(g),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g)),1):0};u.prototype[f.CIRCLE]=u.prototype.circleCircle=function(n,t,u,f,o,h,c,l,a,v,y){var w=s,v=v||t.radius,y=y||h.radius,b,p;return(r(w,u,c),b=v+y,i.squaredLength(w)>Math.pow(b,2))?0:a?!0:(p=this.createContactEquation(n,o,t,h),r(p.normalA,c,u),i.normalize(p.normalA,p.normalA),i.scale(p.contactPointA,p.normalA,v),i.scale(p.contactPointB,p.normalA,-y),e(p.contactPointA,p.contactPointA,u),r(p.contactPointA,p.contactPointA,n.position),e(p.contactPointB,p.contactPointB,c),r(p.contactPointB,p.contactPointB,o.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1)};u.prototype[f.PLANE|f.CONVEX]=u.prototype[f.PLANE|f.BOX]=u.prototype.planeConvex=function(n,t,u,f,l,a,v,y,w){var k=s,tt=h,d=c,g=0,nt,it,b,rt;for(i.rotate(tt,p,f),nt=0;nt!==a.vertices.length;nt++)if(it=a.vertices[nt],i.rotate(k,it,y),e(k,k,v),r(d,k,u),o(d,tt)<=0){if(w)return!0;g++;b=this.createContactEquation(n,l,t,a);r(d,k,u);i.copy(b.normalA,tt);rt=o(d,b.normalA);i.scale(d,b.normalA,rt);r(b.contactPointB,k,l.position);r(b.contactPointA,k,d);r(b.contactPointA,b.contactPointA,n.position);this.contactEquations.push(b);this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(b))}return this.enableFrictionReduction&&this.enableFriction&&g&&this.frictionEquations.push(this.createFrictionFromAverage(g)),g};u.prototype[f.PARTICLE|f.PLANE]=u.prototype.particlePlane=function(n,t,u,f,e,c,l,a,v){var w=s,b=h,k,y;return(a=a||0,r(w,u,l),i.rotate(b,p,a),k=o(w,b),k>0)?0:v?!0:(y=this.createContactEquation(e,n,c,t),i.copy(y.normalA,b),i.scale(w,y.normalA,k),r(y.contactPointA,u,w),r(y.contactPointA,y.contactPointA,e.position),r(y.contactPointB,u,n.position),this.contactEquations.push(y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(y)),1)};u.prototype[f.CIRCLE|f.PARTICLE]=u.prototype.circleParticle=function(n,t,u,f,o,h,c,l,a){var y=s,v;return(r(y,c,u),i.squaredLength(y)>Math.pow(t.radius,2))?0:a?!0:(v=this.createContactEquation(n,o,t,h),i.copy(v.normalA,y),i.normalize(v.normalA,v.normalA),i.scale(v.contactPointA,v.normalA,t.radius),e(v.contactPointA,v.contactPointA,u),r(v.contactPointA,v.contactPointA,n.position),r(v.contactPointB,c,o.position),this.contactEquations.push(v),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v)),1)};var oi=new at({radius:1}),si=i.create(),hi=i.create();i.create();u.prototype[f.PLANE|f.CAPSULE]=u.prototype.planeCapsule=function(n,t,r,u,f,o,s,h,c){var l=si,a=hi,y=oi,b,p,w,v;return(i.set(l,-o.length/2,0),i.rotate(l,l,h),e(l,l,s),i.set(a,o.length/2,0),i.rotate(a,a,h),e(a,a,s),y.radius=o.radius,this.enableFrictionReduction&&(b=this.enableFriction,this.enableFriction=!1),p=this.circlePlane(f,y,l,0,n,t,r,u,c),w=this.circlePlane(f,y,a,0,n,t,r,u,c),this.enableFrictionReduction&&(this.enableFriction=b),c)?p||w:(v=p+w,this.enableFrictionReduction&&v&&this.frictionEquations.push(this.createFrictionFromAverage(v)),v)};u.prototype[f.CIRCLE|f.PLANE]=u.prototype.circlePlane=function(n,t,u,f,l,a,v,y,w){var tt=n,it=t,rt=u,ut=l,ft=v,k=y,nt,b;k=k||0;var d=s,g=h,et=c;return(r(d,rt,ft),i.rotate(g,p,k),nt=o(g,d),nt>it.radius)?0:w?!0:(b=this.createContactEquation(ut,tt,a,t),i.copy(b.normalA,g),i.scale(b.contactPointB,b.normalA,-it.radius),e(b.contactPointB,b.contactPointB,rt),r(b.contactPointB,b.contactPointB,tt.position),i.scale(et,b.normalA,nt),r(b.contactPointA,d,et),e(b.contactPointA,b.contactPointA,ft),r(b.contactPointA,b.contactPointA,ut.position),this.contactEquations.push(b),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(b)),1)};u.prototype[f.CONVEX]=u.prototype[f.CONVEX|f.BOX]=u.prototype[f.BOX]=u.prototype.convexConvex=function(n,t,f,v,y,p,b,k,nt,tt){var lt=s,ht=h,ut=c,et=l,dt=a,ci=w,at=d,gt=g,ni=0,tt="number"==typeof tt?tt:0,ei,oi,ti,ft,fi,li,hi,ct,it,wt,bt,kt;if(!u.findSeparatingAxis(t,f,v,p,b,k,lt)||(r(at,b,f),o(lt,at)>0&&i.scale(lt,lt,-1),ei=u.getClosestEdge(t,v,lt,!0),oi=u.getClosestEdge(p,k,lt),-1===ei||-1===oi))return 0;for(ti=0;ti<2;ti++){var ot=ei,ii=oi,rt=t,vt=p,st=f,pt=b,yt=v,si=k,ri=n,ui=y;for(0===ti&&(ft=ot,ot=ii,ii=ft,ft=rt,rt=vt,vt=ft,ft=st,st=pt,pt=ft,ft=yt,yt=si,si=ft,ft=ri,ri=ui,ui=ft),fi=ii;fi<ii+2;fi++){for(li=vt.vertices[(fi+vt.vertices.length)%vt.vertices.length],i.rotate(ht,li,si),e(ht,ht,pt),hi=0,ct=ot-1;ct<ot+2;ct++)wt=rt.vertices[(ct+rt.vertices.length)%rt.vertices.length],bt=rt.vertices[(ct+1+rt.vertices.length)%rt.vertices.length],i.rotate(ut,wt,yt),i.rotate(et,bt,yt),e(ut,ut,st),e(et,et,st),r(dt,et,ut),i.rotate90cw(gt,dt),i.normalize(gt,gt),r(at,ht,ut),kt=o(gt,at),(ct===ot&&kt<=tt||ct!==ot&&kt<=0)&&hi++;if(hi>=3){if(nt)return!0;it=this.createContactEquation(ri,ui,rt,vt);ni++;wt=rt.vertices[ot%rt.vertices.length];bt=rt.vertices[(ot+1)%rt.vertices.length];i.rotate(ut,wt,yt);i.rotate(et,bt,yt);e(ut,ut,st);e(et,et,st);r(dt,et,ut);i.rotate90cw(it.normalA,dt);i.normalize(it.normalA,it.normalA);r(at,ht,ut);kt=o(it.normalA,at);i.scale(ci,it.normalA,kt);r(it.contactPointA,ht,st);r(it.contactPointA,it.contactPointA,ci);e(it.contactPointA,it.contactPointA,st);r(it.contactPointA,it.contactPointA,ri.position);r(it.contactPointB,ht,pt);e(it.contactPointB,it.contactPointB,pt);r(it.contactPointB,it.contactPointB,ui.position);this.contactEquations.push(it);this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(it))}}}return this.enableFrictionReduction&&this.enableFriction&&ni&&this.frictionEquations.push(this.createFrictionFromAverage(ni)),ni};st=i.fromValues(0,0);u.projectConvexOntoAxis=function(n,t,r,u,f){var a,h,e=null,s=null,v=st,c,y,l;for(i.rotate(v,u,-r),c=0;c<n.vertices.length;c++)a=n.vertices[c],h=o(a,v),(null===e||h>e)&&(e=h),(null===s||h<s)&&(s=h);s>e&&(y=s,s=e,e=y);l=o(t,u);i.set(f,s+l,e+l)};var ci=i.fromValues(0,0),li=i.fromValues(0,0),ai=i.fromValues(0,0),vi=i.fromValues(0,0),yi=i.fromValues(0,0),pi=i.fromValues(0,0);u.findSeparatingAxis=function(n,t,f,e,o,s,h){var nt=null,tt=!1,it=!1,rt=ci,ut=li,ft=ai,c=vi,p=yi,w=pi,b,a,v,l,k,d,g;if(n instanceof y&&e instanceof y)for(b=0;2!==b;b++)for(a=n,v=f,1===b&&(a=e,v=s),l=0;2!==l;l++)0===l?i.set(c,0,1):1===l&&i.set(c,1,0),0!==v&&i.rotate(c,c,v),u.projectConvexOntoAxis(n,t,f,c,p),u.projectConvexOntoAxis(e,o,s,c,w),k=p,d=w,p[0]>w[0]&&(d=p,k=w,!0),tt=(g=d[0]-k[1])<=0,(null===nt||g>nt)&&(i.copy(h,c),nt=g,it=tt);else for(b=0;2!==b;b++)for(a=n,v=f,1===b&&(a=e,v=s),l=0;l!==a.vertices.length;l++)i.rotate(ut,a.vertices[l],v),i.rotate(ft,a.vertices[(l+1)%a.vertices.length],v),r(rt,ft,ut),i.rotate90cw(c,rt),i.normalize(c,c),u.projectConvexOntoAxis(n,t,f,c,p),u.projectConvexOntoAxis(e,o,s,c,w),k=p,d=w,p[0]>w[0]&&(d=p,k=w,!0),g=d[0]-k[1],tt=g<=0,(null===nt||g>nt)&&(i.copy(h,c),nt=g,it=tt);return it};var wi=i.fromValues(0,0),bi=i.fromValues(0,0),ki=i.fromValues(0,0);u.getClosestEdge=function(n,t,u,f){var s=wi,v=bi,h=ki,a;i.rotate(s,u,-t);f&&i.scale(s,s,-1);for(var l=-1,c=n.vertices.length,y=-1,e=0;e!==c;e++)r(v,n.vertices[(e+1)%c],n.vertices[e%c]),i.rotate90cw(h,v),i.normalize(h,h),a=o(h,s),(-1===l||a>y)&&(l=e%c,y=a);return l};var di=i.create(),gi=i.create(),nr=i.create(),tr=i.create(),ir=i.create(),rr=i.create(),ur=i.create();u.prototype[f.CIRCLE|f.HEIGHTFIELD]=u.prototype.circleHeightfield=function(n,t,u,f,o,s,h,c,l,a){var p=s.heights,a=a||t.radius,tt=s.elementWidth,k=gi,d=di,et=ir,ot=ur,b=rr,w=nr,it=tr,g=Math.floor((u[0]-a-h[0])/tt),nt=Math.ceil((u[0]+a-h[0])/tt),rt,y,ft,v;g<0&&(g=0);nt>=p.length&&(nt=p.length-1);for(var ut=p[g],st=p[nt],y=g;y<nt;y++)p[y]<st&&(st=p[y]),p[y]>ut&&(ut=p[y]);if(u[1]-a>ut)return!l&&0;for(rt=!1,y=g;y<nt;y++)if(i.set(w,y*tt,p[y]),i.set(it,(y+1)*tt,p[y+1]),i.add(w,w,h),i.add(it,it,h),i.sub(b,it,w),i.rotate(b,b,Math.PI/2),i.normalize(b,b),i.scale(d,b,-a),i.add(d,d,u),i.sub(k,d,w),ft=i.dot(k,b),d[0]>=w[0]&&d[0]<it[0]&&ft<=0){if(l)return!0;rt=!0;i.scale(k,b,-ft);i.add(et,d,k);i.copy(ot,b);v=this.createContactEquation(o,n,s,t);i.copy(v.normalA,ot);i.scale(v.contactPointB,v.normalA,-a);e(v.contactPointB,v.contactPointB,u);r(v.contactPointB,v.contactPointB,n.position);i.copy(v.contactPointA,et);i.sub(v.contactPointA,v.contactPointA,o.position);this.contactEquations.push(v);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v))}if(rt=!1,a>0)for(y=g;y<=nt;y++)if(i.set(w,y*tt,p[y]),i.add(w,w,h),i.sub(k,u,w),i.squaredLength(k)<Math.pow(a,2)){if(l)return!0;rt=!0;v=this.createContactEquation(o,n,s,t);i.copy(v.normalA,k);i.normalize(v.normalA,v.normalA);i.scale(v.contactPointB,v.normalA,-a);e(v.contactPointB,v.contactPointB,u);r(v.contactPointB,v.contactPointB,n.position);r(v.contactPointA,w,h);e(v.contactPointA,v.contactPointA,h);r(v.contactPointA,v.contactPointA,o.position);this.contactEquations.push(v);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v))}return rt?1:0};var fr=i.create(),er=i.create(),or=i.create(),sr=new vt({vertices:[i.create(),i.create(),i.create(),i.create()]});u.prototype[f.BOX|f.HEIGHTFIELD]=u.prototype[f.CONVEX|f.HEIGHTFIELD]=u.prototype.convexHeightfield=function(n,t,r,u,f,e,o,s,h){var l=e.heights,b=e.elementWidth,v=fr,y=er,k=or,a=sr,p=Math.floor((n.aabb.lowerBound[0]-o[0])/b),w=Math.ceil((n.aabb.upperBound[0]-o[0])/b),g,c;p<0&&(p=0);w>=l.length&&(w=l.length-1);for(var d=l[p],nt=l[w],c=p;c<w;c++)l[c]<nt&&(nt=l[c]),l[c]>d&&(d=l[c]);if(n.aabb.lowerBound[1]>d)return!h&&0;for(g=0,c=p;c<w;c++)i.set(v,c*b,l[c]),i.set(y,(c+1)*b,l[c+1]),i.add(v,v,o),i.add(y,y,o),i.set(k,.5*(y[0]+v[0]),.5*(y[1]+v[1]-100)),i.sub(a.vertices[0],y,k),i.sub(a.vertices[1],v,k),i.copy(a.vertices[2],a.vertices[1]),i.copy(a.vertices[3],a.vertices[0]),a.vertices[2][1]-=100,a.vertices[3][1]-=100,g+=this.convexConvex(n,t,r,u,f,a,k,0,h);return g}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(n,t){function r(n){n=n||{};this.from=n.from?i.fromValues(n.from[0],n.from[1]):i.create();this.to=n.to?i.fromValues(n.to[0],n.to[1]):i.create();this.checkCollisionResponse=void 0===n.checkCollisionResponse||n.checkCollisionResponse;this.skipBackfaces=!!n.skipBackfaces;this.collisionMask=void 0!==n.collisionMask?n.collisionMask:-1;this.collisionGroup=void 0!==n.collisionGroup?n.collisionGroup:-1;this.mode=void 0!==n.mode?n.mode:r.ANY;this.callback=n.callback||function(){};this.direction=i.create();this.length=1;this.update()}function o(n,t,r){i.sub(f,r,n);var e=i.dot(f,t);return i.scale(u,t,e),i.add(u,u,n),i.squaredDistance(r,u)}var i,e,f,u;t.exports=r;i=n("../math/vec2");n("../collision/RaycastResult");n("../shapes/Shape");n("../collision/AABB");r.prototype.constructor=r;r.CLOSEST=1;r.ANY=2;r.ALL=4;r.prototype.update=function(){var n=this.direction;i.sub(n,this.to,this.from);this.length=i.length(n);i.normalize(n,n)};r.prototype.intersectBodies=function(n,t){for(var r,u,i=0,f=t.length;!n.shouldStop(this)&&i<f;i++)r=t[i],u=r.getAABB(),(u.overlapsRay(this)>=0||u.containsPoint(this.from))&&this.intersectBody(n,r)};e=i.create();r.prototype.intersectBody=function(n,t){var o=this.checkCollisionResponse,r,s;if(!o||t.collisionResponse)for(var u=e,f=0,h=t.shapes.length;f<h;f++)if(r=t.shapes[f],(!o||r.collisionResponse)&&0!=(this.collisionGroup&r.collisionMask)&&0!=(r.collisionGroup&this.collisionMask)&&(i.rotate(u,r.position,t.angle),i.add(u,u,t.position),s=r.angle+t.angle,this.intersectShape(n,r,s,u,t),n.shouldStop(this)))break};r.prototype.intersectShape=function(n,t,i,r,u){o(this.from,this.direction,r)>t.boundingRadius*t.boundingRadius||(this._currentBody=u,this._currentShape=t,t.raycast(n,this,r,i),this._currentBody=this._currentShape=null)};r.prototype.getAABB=function(n){var t=this.to,r=this.from;i.set(n.lowerBound,Math.min(t[0],r[0]),Math.min(t[1],r[1]));i.set(n.upperBound,Math.max(t[0],r[0]),Math.max(t[1],r[1]))};i.create();r.prototype.reportIntersection=function(n,t,u,f){this.from;this.to;var e=this._currentShape,o=this._currentBody;if(!(this.skipBackfaces&&i.dot(u,this.direction)>0))switch(this.mode){case r.ALL:n.set(u,e,o,t,f);this.callback(n);break;case r.CLOSEST:(t<n.fraction||!n.hasHit())&&n.set(u,e,o,t,f);break;case r.ANY:n.set(u,e,o,t,f)}};f=i.create();u=i.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(n,t){function i(){this.normal=r.create();this.shape=null;this.body=null;this.faceIndex=-1;this.fraction=-1;this.isStopped=!1}var r=n("../math/vec2"),u=n("../collision/Ray");t.exports=i;i.prototype.reset=function(){r.set(this.normal,0,0);this.shape=null;this.body=null;this.faceIndex=-1;this.fraction=-1;this.isStopped=!1};i.prototype.getHitDistance=function(n){return r.distance(n.from,n.to)*this.fraction};i.prototype.hasHit=function(){return-1!==this.fraction};i.prototype.getHitPoint=function(n,t){r.lerp(n,t.from,t.to,this.fraction)};i.prototype.stop=function(){this.isStopped=!0};i.prototype.shouldStop=function(n){return this.isStopped||-1!==this.fraction&&n.mode===u.ANY};i.prototype.set=function(n,t,i,u,f){r.copy(this.normal,n);this.shape=t;this.body=i;this.fraction=u;this.faceIndex=f}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(n,t){function i(){r.call(this,r.SAP);this.axisList=[];this.axisIndex=0;var n=this;this._addBodyHandler=function(t){n.axisList.push(t.body)};this._removeBodyHandler=function(t){var i=n.axisList.indexOf(t.body);-1!==i&&n.axisList.splice(i,1)}}var u=n("../utils/Utils"),r=n("../collision/Broadphase");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.setWorld=function(n){this.axisList.length=0;u.appendArray(this.axisList,n.bodies);n.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler);n.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler);this.world=n};i.sortAxisList=function(n,t){var r,f,u,i;for(t|=0,r=1,f=n.length;r<f;r++){for(u=n[r],i=r-1;i>=0&&!(n[i].aabb.lowerBound[t]<=u.aabb.lowerBound[t]);i--)n[i+1]=n[i];n[i+1]=u}return n};i.prototype.sortList=function(){var n=this.axisList,t=this.axisIndex;i.sortAxisList(n,t)};i.prototype.getCollisionPairs=function(){var n=this.axisList,e=this.result,c=this.axisIndex,o,s,t,h,i,f,u;for(e.length=0,o=n.length;o--;)s=n[o],s.aabbNeedsUpdate&&s.updateAABB();for(this.sortList(),t=0,h=0|n.length;t!==h;t++)for(i=n[t],f=t+1;f<h;f++){if(u=n[f],!(u.aabb.lowerBound[c]<=i.aabb.upperBound[c]))break;r.canCollide(i,u)&&this.boundingVolumeCheck(i,u)&&e.push(i,u)}return e};i.prototype.aabbQuery=function(n,t,i){var e,r,o,f,u;for(i=i||[],this.sortList(),e=this.axisIndex,r="x",1===e&&(r="y"),2===e&&(r="z"),o=this.axisList,f=(t.lowerBound[r],t.upperBound[r],0);f<o.length;f++)u=o[f],u.aabbNeedsUpdate&&u.updateAABB(),u.aabb.overlaps(t)&&i.push(u);return i}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(n,t){function i(n,t,i,u){this.type=i;u=r.defaults(u,{collideConnected:!0,wakeUpBodies:!0});this.equations=[];this.bodyA=n;this.bodyB=t;this.collideConnected=u.collideConnected;u.wakeUpBodies&&(n&&n.wakeUp(),t&&t.wakeUp())}t.exports=i;var r=n("../utils/Utils");i.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!");};i.DISTANCE=1;i.GEAR=2;i.LOCK=3;i.PRISMATIC=4;i.REVOLUTE=5;i.prototype.setStiffness=function(n){for(var r,i=this.equations,t=0;t!==i.length;t++)r=i[t],r.stiffness=n,r.needsUpdate=!0};i.prototype.setRelaxation=function(n){for(var r,i=this.equations,t=0;t!==i.length;t++)r=i[t],r.relaxation=n,r.needsUpdate=!0}},{"../utils/Utils":57}],15:[function(n,t){function u(n,t,r){var o,c,e,l;if(r=h.defaults(r,{localAnchorA:[0,0],localAnchorB:[0,0]}),f.call(this,n,t,f.DISTANCE,r),this.localAnchorA=i.fromValues(r.localAnchorA[0],r.localAnchorA[1]),this.localAnchorB=i.fromValues(r.localAnchorB[0],r.localAnchorB[1]),o=this.localAnchorA,c=this.localAnchorB,this.distance=0,"number"==typeof r.distance)this.distance=r.distance;else{var a=i.create(),v=i.create(),u=i.create();i.rotate(a,o,n.angle);i.rotate(v,c,t.angle);i.add(u,t.position,v);i.sub(u,u,a);i.sub(u,u,n.position);this.distance=i.length(u)}e=void 0===r.maxForce?Number.MAX_VALUE:r.maxForce;l=new s(n,t,-e,e);this.equations=[l];this.maxForce=e;var u=i.create(),y=i.create(),p=i.create(),w=this;l.computeGq=function(){var n=this.bodyA,t=this.bodyB,r=n.position,f=t.position;return i.rotate(y,o,n.angle),i.rotate(p,c,t.angle),i.add(u,f,p),i.sub(u,u,y),i.sub(u,u,r),i.length(u)-w.distance};this.setMaxForce(e);this.upperLimitEnabled=!1;this.upperLimit=1;this.lowerLimitEnabled=!1;this.lowerLimit=0;this.position=0}var f=n("./Constraint"),s=n("../equations/Equation"),i=n("../math/vec2"),h=n("../utils/Utils");t.exports=u;(u.prototype=new f).constructor=u;var r=i.create(),e=i.create(),o=i.create();u.prototype.update=function(){var l=this.equations[0],f=this.bodyA,s=this.bodyB,a=(this.distance,f.position),v=s.position,n=this.equations[0],t=l.G,u,h,c;i.rotate(e,this.localAnchorA,f.angle);i.rotate(o,this.localAnchorB,s.angle);i.add(r,v,o);i.sub(r,r,e);i.sub(r,r,a);this.position=i.length(r);u=!1;(this.upperLimitEnabled&&this.position>this.upperLimit&&(n.maxForce=0,n.minForce=-this.maxForce,this.distance=this.upperLimit,u=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(n.maxForce=this.maxForce,n.minForce=0,this.distance=this.lowerLimit,u=!0),(this.lowerLimitEnabled||this.upperLimitEnabled)&&!u)?n.enabled=!1:(n.enabled=!0,i.normalize(r,r),h=i.crossLength(e,r),c=i.crossLength(o,r),t[0]=-r[0],t[1]=-r[1],t[2]=-h,t[3]=r[0],t[4]=r[1],t[5]=c)};u.prototype.setMaxForce=function(n){var t=this.equations[0];t.minForce=-n;t.maxForce=n};u.prototype.getMaxForce=function(){return this.equations[0].maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(n,t){function i(n,t,i){i=i||{};r.call(this,n,t,r.GEAR,i);this.ratio=void 0!==i.ratio?i.ratio:1;this.angle=void 0!==i.angle?i.angle:t.angle-this.ratio*n.angle;i.angle=this.angle;i.ratio=this.ratio;this.equations=[new u(n,t,i)];void 0!==i.maxTorque&&this.setMaxTorque(i.maxTorque)}var r=n("./Constraint"),u=(n("../equations/Equation"),n("../equations/AngleLockEquation"));n("../math/vec2");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.update=function(){var n=this.equations[0];n.ratio!==this.ratio&&n.setRatio(this.ratio);n.angle=this.angle};i.prototype.setMaxTorque=function(n){this.equations[0].setMaxTorque(n)};i.prototype.getMaxTorque=function(){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(n,t){function u(n,t,r){var s,h;r=r||{};e.call(this,n,t,e.LOCK,r);var f=void 0===r.maxForce?Number.MAX_VALUE:r.maxForce,a=(r.localAngleB,new o(n,t,-f,f)),v=new o(n,t,-f,f),y=new o(n,t,-f,f),c=i.create(),u=i.create(),l=this;a.computeGq=function(){return i.rotate(c,l.localOffsetB,n.angle),i.sub(u,t.position,n.position),i.sub(u,u,c),u[0]};v.computeGq=function(){return i.rotate(c,l.localOffsetB,n.angle),i.sub(u,t.position,n.position),i.sub(u,u,c),u[1]};s=i.create();h=i.create();y.computeGq=function(){return i.rotate(s,l.localOffsetB,t.angle-l.localAngleB),i.scale(s,s,-1),i.sub(u,n.position,t.position),i.add(u,u,s),i.rotate(h,s,-Math.PI/2),i.normalize(h,h),i.dot(u,h)};this.localOffsetB=i.create();r.localOffsetB?i.copy(this.localOffsetB,r.localOffsetB):(i.sub(this.localOffsetB,t.position,n.position),i.rotate(this.localOffsetB,this.localOffsetB,-n.angle));this.localAngleB=0;this.localAngleB="number"==typeof r.localAngleB?r.localAngleB:t.angle-n.angle;this.equations.push(a,v,y);this.setMaxForce(f)}var e=n("./Constraint"),i=n("../math/vec2"),o=n("../equations/Equation");t.exports=u;(u.prototype=new e).constructor=u;u.prototype.setMaxForce=function(n){for(var i=this.equations,t=0;t<this.equations.length;t++)i[t].maxForce=n,i[t].minForce=-n};u.prototype.getMaxForce=function(){return this.equations[0].maxForce};var s=i.create(),f=i.create(),r=i.create(),h=i.fromValues(1,0),c=i.fromValues(0,1);u.prototype.update=function(){var t=this.equations[0],u=this.equations[1],n=this.equations[2],e=this.bodyA,o=this.bodyB;i.rotate(s,this.localOffsetB,e.angle);i.rotate(f,this.localOffsetB,o.angle-this.localAngleB);i.scale(f,f,-1);i.rotate(r,f,Math.PI/2);i.normalize(r,r);t.G[0]=-1;t.G[1]=0;t.G[2]=-i.crossLength(s,h);t.G[3]=1;u.G[0]=0;u.G[1]=-1;u.G[2]=-i.crossLength(s,c);u.G[4]=1;n.G[0]=-r[0];n.G[1]=-r[1];n.G[3]=r[0];n.G[4]=r[1];n.G[5]=i.crossLength(f,r)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(n,t){function u(n,t,r){var k,d,o;r=r||{};s.call(this,n,t,s.PRISMATIC,r);var h=i.fromValues(0,0),c=i.fromValues(1,0),y=i.fromValues(0,0);r.localAnchorA&&i.copy(h,r.localAnchorA);r.localAxisA&&i.copy(c,r.localAxisA);r.localAnchorB&&i.copy(y,r.localAnchorB);this.localAnchorA=h;this.localAnchorB=y;this.localAxisA=c;var e=this.maxForce=void 0!==r.maxForce?r.maxForce:Number.MAX_VALUE,p=new a(n,t,-e,e),w=new i.create,b=new i.create,f=new i.create,u=new i.create;(p.computeGq=function(){return i.dot(f,u)},p.updateJacobian=function(){var r=this.G,e=n.position,o=t.position;i.rotate(w,h,n.angle);i.rotate(b,y,t.angle);i.add(f,o,b);i.sub(f,f,e);i.sub(f,f,w);i.rotate(u,c,n.angle+Math.PI/2);r[0]=-u[0];r[1]=-u[1];r[2]=-i.crossLength(w,u)+i.crossLength(u,f);r[3]=u[0];r[4]=u[1];r[5]=i.crossLength(b,u)},this.equations.push(p),r.disableRotationalLock)||(k=new v(n,t,-e,e),this.equations.push(k));this.position=0;this.velocity=0;this.lowerLimitEnabled=void 0!==r.lowerLimit;this.upperLimitEnabled=void 0!==r.upperLimit;this.lowerLimit=void 0!==r.lowerLimit?r.lowerLimit:0;this.upperLimit=void 0!==r.upperLimit?r.upperLimit:1;this.upperLimitEquation=new l(n,t);this.lowerLimitEquation=new l(n,t);this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0;this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=e;this.motorEquation=new a(n,t);this.motorEnabled=!1;this.motorSpeed=0;d=this;o=this.motorEquation;o.computeGW;o.computeGq=function(){return 0};o.computeGW=function(){var i=this.G,n=this.bodyA,t=this.bodyB,r=n.velocity,u=t.velocity,f=n.angularVelocity,e=t.angularVelocity;return this.gmult(i,r,f,u,e)+d.motorSpeed}}var s=n("./Constraint"),l=n("../equations/ContactEquation"),a=n("../equations/Equation"),i=n("../math/vec2"),v=n("../equations/RotationalLockEquation");t.exports=u;(u.prototype=new s).constructor=u;var r=i.create(),f=i.create(),e=i.create(),h=i.create(),c=i.create(),o=i.create();u.prototype.update=function(){var n=this.equations,b=n[0],p=this.upperLimit,w=this.lowerLimit,t=this.upperLimitEquation,u=this.lowerLimitEquation,l=this.bodyA,v=this.bodyB,k=this.localAxisA,d=this.localAnchorA,g=this.localAnchorB,y,s,a;b.updateJacobian();i.rotate(r,k,l.angle);i.rotate(h,d,l.angle);i.add(f,h,l.position);i.rotate(c,g,v.angle);i.add(e,c,v.position);y=this.position=i.dot(e,r)-i.dot(f,r);this.motorEnabled&&(s=this.motorEquation.G,s[0]=r[0],s[1]=r[1],s[2]=i.crossLength(r,c),s[3]=-r[0],s[4]=-r[1],s[5]=-i.crossLength(r,h));(this.upperLimitEnabled&&y>p?(i.scale(t.normalA,r,-1),i.sub(t.contactPointA,f,l.position),i.sub(t.contactPointB,e,v.position),i.scale(o,r,p),i.add(t.contactPointA,t.contactPointA,o),-1===n.indexOf(t)&&n.push(t)):-1!==(a=n.indexOf(t))&&n.splice(a,1),this.lowerLimitEnabled&&y<w)?(i.scale(u.normalA,r,1),i.sub(u.contactPointA,f,l.position),i.sub(u.contactPointB,e,v.position),i.scale(o,r,w),i.sub(u.contactPointB,u.contactPointB,o),-1===n.indexOf(u)&&n.push(u)):(a=n.indexOf(u),-1!==a&&n.splice(a,1))};u.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)};u.prototype.disableMotor=function(){if(this.motorEnabled){var n=this.equations.indexOf(this.motorEquation);this.equations.splice(n,1);this.motorEnabled=!1}};u.prototype.setLimits=function(n,t){"number"==typeof n?(this.lowerLimit=n,this.lowerLimitEnabled=!0):(this.lowerLimit=n,this.lowerLimitEnabled=!1);"number"==typeof t?(this.upperLimit=t,this.upperLimitEnabled=!0):(this.upperLimit=t,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(n,t){function u(n,t,u){var v;u=u||{};o.call(this,n,t,o.REVOLUTE,u);v=this.maxForce=void 0!==u.maxForce?u.maxForce:Number.MAX_VALUE;this.pivotA=i.create();this.pivotB=i.create();u.worldPivot?(i.sub(this.pivotA,u.worldPivot,n.position),i.sub(this.pivotB,u.worldPivot,t.position),i.rotate(this.pivotA,this.pivotA,-n.angle),i.rotate(this.pivotB,this.pivotB,-t.angle)):(i.copy(this.pivotA,u.localPivotA),i.copy(this.pivotB,u.localPivotB));var b=this.equations=[new c(n,t,-v,v),new c(n,t,-v,v)],p=b[0],w=b[1],y=this;p.computeGq=function(){return i.rotate(f,y.pivotA,n.angle),i.rotate(e,y.pivotB,t.angle),i.add(r,t.position,e),i.sub(r,r,n.position),i.sub(r,r,f),i.dot(r,s)};w.computeGq=function(){return i.rotate(f,y.pivotA,n.angle),i.rotate(e,y.pivotB,t.angle),i.add(r,t.position,e),i.sub(r,r,n.position),i.sub(r,r,f),i.dot(r,h)};w.minForce=p.minForce=-v;w.maxForce=p.maxForce=v;this.motorEquation=new a(n,t);this.motorEnabled=!1;this.angle=0;this.lowerLimitEnabled=!1;this.upperLimitEnabled=!1;this.lowerLimit=0;this.upperLimit=0;this.upperLimitEquation=new l(n,t);this.lowerLimitEquation=new l(n,t);this.upperLimitEquation.minForce=0;this.lowerLimitEquation.maxForce=0}var o=n("./Constraint"),c=n("../equations/Equation"),a=n("../equations/RotationalVelocityEquation"),l=n("../equations/RotationalLockEquation"),i=n("../math/vec2");t.exports=u;var f=i.create(),e=i.create(),s=i.fromValues(1,0),h=i.fromValues(0,1),r=i.create();(u.prototype=new o).constructor=u;u.prototype.setLimits=function(n,t){"number"==typeof n?(this.lowerLimit=n,this.lowerLimitEnabled=!0):(this.lowerLimit=n,this.lowerLimitEnabled=!1);"number"==typeof t?(this.upperLimit=t,this.upperLimitEnabled=!0):(this.upperLimit=t,this.upperLimitEnabled=!1)};u.prototype.update=function(){var l=this.bodyA,a=this.bodyB,w=this.pivotA,b=this.pivotB,n=this.equations,t=(n[0],n[1],n[0]),r=n[1],v=this.upperLimit,y=this.lowerLimit,o=this.upperLimitEquation,c=this.lowerLimitEquation,p=this.angle=a.angle-l.angle,u;(this.upperLimitEnabled&&p>v?(o.angle=v,-1===n.indexOf(o)&&n.push(o)):-1!==(u=n.indexOf(o))&&n.splice(u,1),this.lowerLimitEnabled&&p<y)?(c.angle=y,-1===n.indexOf(c)&&n.push(c)):(u=n.indexOf(c),-1!==u&&n.splice(u,1));i.rotate(f,w,l.angle);i.rotate(e,b,a.angle);t.G[0]=-1;t.G[1]=0;t.G[2]=-i.crossLength(f,s);t.G[3]=1;t.G[4]=0;t.G[5]=i.crossLength(e,s);r.G[0]=0;r.G[1]=-1;r.G[2]=-i.crossLength(f,h);r.G[3]=0;r.G[4]=1;r.G[5]=i.crossLength(e,h)};u.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)};u.prototype.disableMotor=function(){if(this.motorEnabled){var n=this.equations.indexOf(this.motorEquation);this.equations.splice(n,1);this.motorEnabled=!1}};u.prototype.setMotorSpeed=function(n){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations[t].relativeVelocity=n}};u.prototype.getMotorSpeed=function(){return!!this.motorEnabled&&this.motorEquation.relativeVelocity}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(n,t){function i(n,t,i){i=i||{};r.call(this,n,t,-Number.MAX_VALUE,Number.MAX_VALUE);this.angle=i.angle||0;this.ratio="number"==typeof i.ratio?i.ratio:1;this.setRatio(this.ratio)}var r=n("./Equation");n("../math/vec2");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle};i.prototype.setRatio=function(n){var t=this.G;t[2]=n;t[5]=-1;this.ratio=n};i.prototype.setMaxTorque=function(n){this.maxForce=n;this.minForce=-n}},{"../math/vec2":30,"./Equation":22}],21:[function(n,t){function r(n,t){u.call(this,n,t,0,Number.MAX_VALUE);this.contactPointA=i.create();this.penetrationVec=i.create();this.contactPointB=i.create();this.normalA=i.create();this.restitution=0;this.firstImpact=!1;this.shapeA=null;this.shapeB=null}var u=n("./Equation"),i=n("../math/vec2");t.exports=r;(r.prototype=new u).constructor=r;r.prototype.computeB=function(n,t,r){var l=this.bodyA,a=this.bodyB,h=this.contactPointA,c=this.contactPointB,v=l.position,y=a.position,f=this.penetrationVec,u=this.normalA,e=this.G,p=i.crossLength(h,u),w=i.crossLength(c,u),o,s;return e[0]=-u[0],e[1]=-u[1],e[2]=-p,e[3]=u[0],e[4]=u[1],e[5]=w,i.add(f,y,c),i.sub(f,f,v),i.sub(f,f,h),this.firstImpact&&0!==this.restitution?(s=0,o=1/t*(1+this.restitution)*this.computeGW()):(s=i.dot(u,f)+this.offset,o=this.computeGW()),-s*n-o*t-r*this.computeGiMf()};var f=i.create(),e=i.create(),o=i.create();r.prototype.getVelocityAlongNormal=function(){return this.bodyA.getVelocityAtPoint(f,this.contactPointA),this.bodyB.getVelocityAtPoint(e,this.contactPointB),i.subtract(o,f,e),i.dot(this.normalA,o)}},{"../math/vec2":30,"./Equation":22}],22:[function(n,t){function r(n,t,i,u){this.minForce=void 0===i?-Number.MAX_VALUE:i;this.maxForce=void 0===u?Number.MAX_VALUE:u;this.bodyA=n;this.bodyB=t;this.stiffness=r.DEFAULT_STIFFNESS;this.relaxation=r.DEFAULT_RELAXATION;this.G=new e.ARRAY_TYPE(6);for(var f=0;f<6;f++)this.G[f]=0;this.offset=0;this.a=0;this.b=0;this.epsilon=0;this.timeStep=1/60;this.needsUpdate=!0;this.multiplier=0;this.relativeVelocity=0;this.enabled=!0}var i,e,o,s,u,f;t.exports=r;i=n("../math/vec2");e=n("../utils/Utils");n("../objects/Body");r.prototype.constructor=r;r.DEFAULT_STIFFNESS=1e6;r.DEFAULT_RELAXATION=4;r.prototype.update=function(){var i=this.stiffness,n=this.relaxation,t=this.timeStep;this.a=4/(t*(1+4*n));this.b=4*n/(1+4*n);this.epsilon=4/(t*t*i*(1+4*n));this.needsUpdate=!1};r.prototype.gmult=function(n,t,i,r,u){return n[0]*t[0]+n[1]*t[1]+n[2]*i+n[3]*r[0]+n[4]*r[1]+n[5]*u};r.prototype.computeB=function(n,t,i){var r=this.computeGW();return-this.computeGq()*n-r*t-this.computeGiMf()*i};o=i.create();s=i.create();r.prototype.computeGq=function(){var i=this.G,n=this.bodyA,t=this.bodyB,r=(n.position,t.position,n.angle),u=t.angle;return this.gmult(i,o,r,s,u)+this.offset};r.prototype.computeGW=function(){var i=this.G,n=this.bodyA,t=this.bodyB,r=n.velocity,u=t.velocity,f=n.angularVelocity,e=t.angularVelocity;return this.gmult(i,r,f,u,e)+this.relativeVelocity};r.prototype.computeGWlambda=function(){var i=this.G,n=this.bodyA,t=this.bodyB,r=n.vlambda,u=t.vlambda,f=n.wlambda,e=t.wlambda;return this.gmult(i,r,f,u,e)};u=i.create();f=i.create();r.prototype.computeGiMf=function(){var n=this.bodyA,t=this.bodyB,r=n.force,e=n.angularForce,o=t.force,s=t.angularForce,h=n.invMassSolve,c=t.invMassSolve,l=n.invInertiaSolve,a=t.invInertiaSolve,v=this.G;return i.scale(u,r,h),i.multiply(u,n.massMultiplier,u),i.scale(f,o,c),i.multiply(f,t.massMultiplier,f),this.gmult(v,u,e*l,f,s*a)};r.prototype.computeGiMGt=function(){var t=this.bodyA,i=this.bodyB,r=t.invMassSolve,u=i.invMassSolve,f=t.invInertiaSolve,e=i.invInertiaSolve,n=this.G;return n[0]*n[0]*r*t.massMultiplier[0]+n[1]*n[1]*r*t.massMultiplier[1]+n[2]*n[2]*f+n[3]*n[3]*u*i.massMultiplier[0]+n[4]*n[4]*u*i.massMultiplier[1]+n[5]*n[5]*e};var h=i.create(),c=i.create(),l=i.create();i.create();i.create();i.create();r.prototype.addToWlambda=function(n){var r=this.bodyA,u=this.bodyB,t=h,e=c,o=l,s=r.invMassSolve,a=u.invMassSolve,v=r.invInertiaSolve,y=u.invInertiaSolve,f=this.G;e[0]=f[0];e[1]=f[1];o[0]=f[3];o[1]=f[4];i.scale(t,e,s*n);i.multiply(t,t,r.massMultiplier);i.add(r.vlambda,r.vlambda,t);r.wlambda+=v*f[2]*n;i.scale(t,o,a*n);i.multiply(t,t,u.massMultiplier);i.add(u.vlambda,u.vlambda,t);u.wlambda+=y*f[5]*n};r.prototype.computeInvC=function(n){return 1/(this.computeGiMGt()+n)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(n,t){function i(n,t,i){u.call(this,n,t,-i,i);this.contactPointA=r.create();this.contactPointB=r.create();this.t=r.create();this.contactEquations=[];this.shapeA=null;this.shapeB=null;this.frictionCoefficient=.3}var r=n("../math/vec2"),u=n("./Equation");n("../utils/Utils");t.exports=i;(i.prototype=new u).constructor=i;i.prototype.setSlipForce=function(n){this.maxForce=n;this.minForce=-n};i.prototype.getSlipForce=function(){return this.maxForce};i.prototype.computeB=function(n,t,i){this.bodyA;this.bodyB;var e=this.contactPointA,o=this.contactPointB,u=this.t,f=this.G;return f[0]=-u[0],f[1]=-u[1],f[2]=-r.crossLength(e,u),f[3]=u[0],f[4]=u[1],f[5]=r.crossLength(o,u),-this.computeGW()*t-i*this.computeGiMf()}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(n,t){function r(n,t,i){i=i||{};u.call(this,n,t,-Number.MAX_VALUE,Number.MAX_VALUE);this.angle=i.angle||0;var r=this.G;r[2]=1;r[5]=-1}var u=n("./Equation"),i=n("../math/vec2");t.exports=r;(r.prototype=new u).constructor=r;var f=i.create(),e=i.create(),o=i.fromValues(1,0),s=i.fromValues(0,1);r.prototype.computeGq=function(){return i.rotate(f,o,this.bodyA.angle+this.angle),i.rotate(e,s,this.bodyB.angle),i.dot(f,e)}},{"../math/vec2":30,"./Equation":22}],25:[function(n,t){function i(n,t){r.call(this,n,t,-Number.MAX_VALUE,Number.MAX_VALUE);this.relativeVelocity=1;this.ratio=1}var r=n("./Equation");n("../math/vec2");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.computeB=function(n,t,i){var r=this.G,u;return r[2]=-1,r[5]=this.ratio,u=this.computeGiMf(),-this.computeGW()*t-i*u}},{"../math/vec2":30,"./Equation":22}],26:[function(n,t){var i=function(){};t.exports=i;i.prototype={constructor:i,on:function(n,t,i){t.context=i||this;void 0===this._listeners&&(this._listeners={});var r=this._listeners;return void 0===r[n]&&(r[n]=[]),-1===r[n].indexOf(t)&&r[n].push(t),this},has:function(n,t){if(void 0===this._listeners)return!1;var i=this._listeners;if(t){if(void 0!==i[n]&&-1!==i[n].indexOf(t))return!0}else if(void 0!==i[n])return!0;return!1},off:function(n,t){if(void 0===this._listeners)return this;var i=this._listeners,r=i[n].indexOf(t);return-1!==r&&i[n].splice(r,1),this},emit:function(n){var t,i,u,r;if(void 0===this._listeners)return this;if(t=this._listeners[n.type],void 0!==t)for(n.target=this,i=0,u=t.length;i<u;i++)r=t[i],r.call(r.context,n);return this}}},{}],27:[function(n,t){function r(n,t,f){if(f=f||{},!(n instanceof u&&t instanceof u))throw new Error("First two arguments must be Material instances.");this.id=r.idCounter++;this.materialA=n;this.materialB=t;this.friction=void 0!==f.friction?Number(f.friction):.3;this.restitution=void 0!==f.restitution?Number(f.restitution):0;this.stiffness=void 0!==f.stiffness?Number(f.stiffness):i.DEFAULT_STIFFNESS;this.relaxation=void 0!==f.relaxation?Number(f.relaxation):i.DEFAULT_RELAXATION;this.frictionStiffness=void 0!==f.frictionStiffness?Number(f.frictionStiffness):i.DEFAULT_STIFFNESS;this.frictionRelaxation=void 0!==f.frictionRelaxation?Number(f.frictionRelaxation):i.DEFAULT_RELAXATION;this.surfaceVelocity=void 0!==f.surfaceVelocity?Number(f.surfaceVelocity):0;this.contactSkinSize=.005}var u=n("./Material"),i=n("../equations/Equation");t.exports=r;r.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(n,t){function i(n){this.id=n||i.idCounter++}t.exports=i;i.idCounter=0},{}],29:[function(n,t){var i={};i.GetArea=function(n){if(n.length<6)return 0;for(var i=n.length-2,r=0,t=0;t<i;t+=2)r+=(n[t+2]-n[t])*(n[t+1]+n[t+3]);return.5*-(r+=(n[0]-n[i])*(n[i+1]+n[1]))};i.Triangulate=function(n){var c=n.length>>1,t,u,h,f;if(c<3)return[];for(var l=[],r=[],t=0;t<c;t++)r.push(t);for(t=0,u=c;u>3;){var e=r[(t+0)%u],o=r[(t+1)%u],s=r[(t+2)%u],v=n[2*e],y=n[2*e+1],p=n[2*o],w=n[2*o+1],b=n[2*s],k=n[2*s+1],a=!1;if(i._convex(v,y,p,w,b,k))for(a=!0,h=0;h<u;h++)if(f=r[h],f!=e&&f!=o&&f!=s&&i._PointInTriangle(n[2*f],n[2*f+1],v,y,p,w,b,k)){a=!1;break}if(a)l.push(e,o,s),r.splice((t+1)%u,1),u--,t=0;else if(t++>3*u)break}return l.push(r[0],r[1],r[2]),l};i._PointInTriangle=function(n,t,i,r,u,f,e,o){var s=e-i,h=o-r,c=u-i,l=f-r,v=n-i,y=t-r,p=s*s+h*h,a=s*c+h*l,w=s*v+h*y,b=c*c+l*l,k=c*v+l*y,d=1/(p*b-a*a),g=(b*w-a*k)*d,nt=(p*k-a*w)*d;return g>=0&&nt>=0&&g+nt<1};i._convex=function(n,t,i,r,u,f){return(t-r)*(u-i)+(i-n)*(f-r)>=0};t.exports=i},{}],30:[function(n,t){var i=t.exports={},r=n("../utils/Utils");i.crossLength=function(n,t){return n[0]*t[1]-n[1]*t[0]};i.crossVZ=function(n,t,r){return i.rotate(n,t,-Math.PI/2),i.scale(n,n,r),n};i.crossZV=function(n,t,r){return i.rotate(n,r,Math.PI/2),i.scale(n,n,t),n};i.rotate=function(n,t,i){if(0!==i){var r=Math.cos(i),u=Math.sin(i),f=t[0],e=t[1];n[0]=r*f-u*e;n[1]=u*f+r*e}else n[0]=t[0],n[1]=t[1]};i.rotate90cw=function(n,t){var i=t[0],r=t[1];n[0]=r;n[1]=-i};i.toLocalFrame=function(n,t,r,u){i.copy(n,t);i.sub(n,n,r);i.rotate(n,n,-u)};i.toGlobalFrame=function(n,t,r,u){i.copy(n,t);i.rotate(n,n,u);i.add(n,n,r)};i.vectorToLocalFrame=function(n,t,r){i.rotate(n,t,-r)};i.vectorToGlobalFrame=function(n,t,r){i.rotate(n,t,r)};i.centroid=function(n,t,r,u){return i.add(n,t,r),i.add(n,n,u),i.scale(n,n,1/3),n};i.create=function(){var n=new r.ARRAY_TYPE(2);return n[0]=0,n[1]=0,n};i.clone=function(n){var t=new r.ARRAY_TYPE(2);return t[0]=n[0],t[1]=n[1],t};i.fromValues=function(n,t){var i=new r.ARRAY_TYPE(2);return i[0]=n,i[1]=t,i};i.copy=function(n,t){return n[0]=t[0],n[1]=t[1],n};i.set=function(n,t,i){return n[0]=t,n[1]=i,n};i.add=function(n,t,i){return n[0]=t[0]+i[0],n[1]=t[1]+i[1],n};i.subtract=function(n,t,i){return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n};i.sub=i.subtract;i.multiply=function(n,t,i){return n[0]=t[0]*i[0],n[1]=t[1]*i[1],n};i.mul=i.multiply;i.divide=function(n,t,i){return n[0]=t[0]/i[0],n[1]=t[1]/i[1],n};i.div=i.divide;i.scale=function(n,t,i){return n[0]=t[0]*i,n[1]=t[1]*i,n};i.distance=function(n,t){var i=t[0]-n[0],r=t[1]-n[1];return Math.sqrt(i*i+r*r)};i.dist=i.distance;i.squaredDistance=function(n,t){var i=t[0]-n[0],r=t[1]-n[1];return i*i+r*r};i.sqrDist=i.squaredDistance;i.length=function(n){var t=n[0],i=n[1];return Math.sqrt(t*t+i*i)};i.len=i.length;i.squaredLength=function(n){var t=n[0],i=n[1];return t*t+i*i};i.sqrLen=i.squaredLength;i.negate=function(n,t){return n[0]=-t[0],n[1]=-t[1],n};i.normalize=function(n,t){var r=t[0],u=t[1],i=r*r+u*u;return i>0&&(i=1/Math.sqrt(i),n[0]=t[0]*i,n[1]=t[1]*i),n};i.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]};i.str=function(n){return"vec2("+n[0]+", "+n[1]+")"};i.lerp=function(n,t,i,r){var u=t[0],f=t[1];return n[0]=u+r*(i[0]-u),n[1]=f+r*(i[1]-f),n};i.reflect=function(n,t,i){var r=t[0]*i[0]+t[1]*i[1];n[0]=t[0]-2*i[0]*r;n[1]=t[1]-2*i[1]*r};i.getLineSegmentsIntersection=function(n,t,r,u,f){var e=i.getLineSegmentsIntersectionFraction(t,r,u,f);return!(e<0)&&(n[0]=t[0]+e*(r[0]-t[0]),n[1]=t[1]+e*(r[1]-t[1]),!0)};i.getLineSegmentsIntersectionFraction=function(n,t,i,r){var f,u,e=t[0]-n[0],o=t[1]-n[1],s=r[0]-i[0],h=r[1]-i[1];return f=(-o*(n[0]-i[0])+e*(n[1]-i[1]))/(-s*o+e*h),u=(s*(n[1]-i[1])-h*(n[0]-i[0]))/(-s*o+e*h),f>=0&&f<=1&&u>=0&&u<=1?u:-1}},{"../utils/Utils":57}],31:[function(n,t){function r(n){n=n||{};v.call(this);this.id=n.id||++r._idCounter;this.world=null;this.shapes=[];this.mass=n.mass||0;this.invMass=0;this.inertia=0;this.invInertia=0;this.invMassSolve=0;this.invInertiaSolve=0;this.fixedRotation=!!n.fixedRotation;this.fixedX=!!n.fixedX;this.fixedY=!!n.fixedY;this.massMultiplier=i.create();this.position=i.fromValues(0,0);n.position&&i.copy(this.position,n.position);this.interpolatedPosition=i.fromValues(0,0);this.interpolatedAngle=0;this.previousPosition=i.fromValues(0,0);this.previousAngle=0;this.velocity=i.fromValues(0,0);n.velocity&&i.copy(this.velocity,n.velocity);this.vlambda=i.fromValues(0,0);this.wlambda=0;this.angle=n.angle||0;this.angularVelocity=n.angularVelocity||0;this.force=i.create();n.force&&i.copy(this.force,n.force);this.angularForce=n.angularForce||0;this.damping="number"==typeof n.damping?n.damping:.1;this.angularDamping="number"==typeof n.angularDamping?n.angularDamping:.1;this.type=r.STATIC;this.type=void 0!==n.type?n.type:n.mass?r.DYNAMIC:r.STATIC;this.boundingRadius=0;this.aabb=new a;this.aabbNeedsUpdate=!0;this.allowSleep=void 0===n.allowSleep||n.allowSleep;this.wantsToSleep=!1;this.sleepState=r.AWAKE;this.sleepSpeedLimit=void 0!==n.sleepSpeedLimit?n.sleepSpeedLimit:.2;this.sleepTimeLimit=void 0!==n.sleepTimeLimit?n.sleepTimeLimit:1;this.gravityScale=void 0!==n.gravityScale?n.gravityScale:1;this.collisionResponse=void 0===n.collisionResponse||n.collisionResponse;this.idleTime=0;this.timeLastSleepy=0;this.ccdSpeedThreshold=void 0!==n.ccdSpeedThreshold?n.ccdSpeedThreshold:-1;this.ccdIterations=void 0!==n.ccdIterations?n.ccdIterations:10;this.concavePath=null;this._wakeUpAfterNarrowphase=!1;this.updateMassProperties()}var i=n("../math/vec2"),b=n("poly-decomp"),k=n("../shapes/Convex"),d=n("../collision/RaycastResult"),l=n("../collision/Ray"),a=n("../collision/AABB"),v=n("../events/EventEmitter"),h,y,p,s,u;t.exports=r;r.prototype=new v;r.prototype.constructor=r;r._idCounter=0;r.prototype.updateSolveMassProperties=function(){this.sleepState===r.SLEEPING||this.type===r.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)};r.prototype.setDensity=function(n){var t=this.getArea();this.mass=t*n;this.updateMassProperties()};r.prototype.getArea=function(){for(var t=0,n=0;n<this.shapes.length;n++)t+=this.shapes[n].area;return t};r.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};h=new a;y=i.create();r.prototype.updateAABB=function(){for(var r,e,u=this.shapes,o=u.length,n=y,f=this.angle,t=0;t!==o;t++)r=u[t],e=r.angle+f,i.rotate(n,r.position,f),i.add(n,n,this.position),r.computeAABB(h,n,e),0===t?this.aabb.copy(h):this.aabb.extend(h);this.aabbNeedsUpdate=!1};r.prototype.updateBoundingRadius=function(){for(var r=this.shapes,o=r.length,n=0,t=0;t!==o;t++){var u=r[t],f=i.length(u.position),e=u.boundingRadius;f+e>n&&(n=f+e)}this.boundingRadius=n};r.prototype.addShape=function(n,t,r){if(n.body)throw new Error("A shape can only be added to one body.");n.body=this;t?i.copy(n.position,t):i.set(n.position,0,0);n.angle=r||0;this.shapes.push(n);this.updateMassProperties();this.updateBoundingRadius();this.aabbNeedsUpdate=!0};r.prototype.removeShape=function(n){var t=this.shapes.indexOf(n);return-1!==t&&(this.shapes.splice(t,1),this.aabbNeedsUpdate=!0,n.body=null,!0)};r.prototype.updateMassProperties=function(){var t,u,s;if(this.type===r.STATIC||this.type===r.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var f=this.shapes,e=f.length,o=this.mass/e,n=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(t=0;t<e;t++)u=f[t],s=i.squaredLength(u.position),n+=u.computeMomentOfInertia(o)+o*s;this.inertia=n;this.invInertia=n>0?1/n:0}this.invMass=1/this.mass;i.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};i.create();r.prototype.applyForce=function(n,t){if(i.add(this.force,this.force,n),t){var r=i.crossLength(t,n);this.angularForce+=r}};var g=i.create(),nt=i.create(),tt=i.create();r.prototype.applyForceLocal=function(n,t){t=t||tt;var i=g,r=nt;this.vectorToWorldFrame(i,n);this.vectorToWorldFrame(r,t);this.applyForce(i,r)};p=i.create();r.prototype.applyImpulse=function(n,t){var u,f;this.type===r.DYNAMIC&&(u=p,(i.scale(u,n,this.invMass),i.multiply(u,this.massMultiplier,u),i.add(this.velocity,u,this.velocity),t)&&(f=i.crossLength(t,n),f*=this.invInertia,this.angularVelocity+=f))};var it=i.create(),rt=i.create(),ut=i.create();r.prototype.applyImpulseLocal=function(n,t){t=t||ut;var i=it,r=rt;this.vectorToWorldFrame(i,n);this.vectorToWorldFrame(r,t);this.applyImpulse(i,r)};r.prototype.toLocalFrame=function(n,t){i.toLocalFrame(n,t,this.position,this.angle)};r.prototype.toWorldFrame=function(n,t){i.toGlobalFrame(n,t,this.position,this.angle)};r.prototype.vectorToLocalFrame=function(n,t){i.vectorToLocalFrame(n,t,this.angle)};r.prototype.vectorToWorldFrame=function(n,t){i.vectorToGlobalFrame(n,t,this.angle)};r.prototype.fromPolygon=function(n,t){var f,s,h,r,u,o,e;for(t=t||{},r=this.shapes.length;r>=0;--r)this.removeShape(this.shapes[r]);if(f=new b.Polygon,f.vertices=n,f.makeCCW(),"number"==typeof t.removeCollinearPoints&&f.removeCollinearPoints(t.removeCollinearPoints),void 0===t.skipSimpleCheck&&!f.isSimple())return!1;for(this.concavePath=f.vertices.slice(0),r=0;r<this.concavePath.length;r++)e=[0,0],i.copy(e,this.concavePath[r]),this.concavePath[r]=e;for(s=t.optimalDecomp?f.decomp():f.quickDecomp(),h=i.create(),r=0;r!==s.length;r++){for(u=new k({vertices:s[r].vertices}),o=0;o!==u.vertices.length;o++)e=u.vertices[o],i.sub(e,e,u.centerOfMass);i.scale(h,u.centerOfMass,1);u.updateTriangles();u.updateCenterOfMass();u.updateBoundingRadius();this.addShape(u,h)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0,!0};i.fromValues(0,0);var ft=i.fromValues(0,0),et=i.fromValues(0,0),ot=i.fromValues(0,0);r.prototype.adjustCenterOfMass=function(){var f=ft,r=et,u=ot,e=0,t,n;for(i.set(r,0,0),n=0;n!==this.shapes.length;n++)t=this.shapes[n],i.scale(f,t.position,t.area),i.add(r,r,f),e+=t.area;for(i.scale(u,r,1/e),n=0;n!==this.shapes.length;n++)t=this.shapes[n],i.sub(t.position,t.position,u);for(i.add(this.position,this.position,u),n=0;this.concavePath&&n<this.concavePath.length;n++)i.sub(this.concavePath[n],this.concavePath[n],u);this.updateMassProperties();this.updateBoundingRadius()};r.prototype.setZeroForce=function(){i.set(this.force,0,0);this.angularForce=0};r.prototype.resetConstraintVelocity=function(){var n=this,t=n.vlambda;i.set(t,0,0);n.wlambda=0};r.prototype.addConstraintVelocity=function(){var n=this,t=n.velocity;i.add(t,t,n.vlambda);n.angularVelocity+=n.wlambda};r.prototype.applyDamping=function(n){if(this.type===r.DYNAMIC){var t=this.velocity;i.scale(t,t,Math.pow(1-this.damping,n));this.angularVelocity*=Math.pow(1-this.angularDamping,n)}};r.prototype.wakeUp=function(){var n=this.sleepState;this.sleepState=r.AWAKE;this.idleTime=0;n!==r.AWAKE&&this.emit(r.wakeUpEvent)};r.prototype.sleep=function(){this.sleepState=r.SLEEPING;this.angularVelocity=0;this.angularForce=0;i.set(this.velocity,0,0);i.set(this.force,0,0);this.emit(r.sleepEvent)};r.prototype.sleepTick=function(n,t,u){this.allowSleep&&this.type!==r.SLEEPING&&(this.wantsToSleep=!1,this.sleepState,i.squaredLength(this.velocity)+Math.pow(this.angularVelocity,2)>=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=r.AWAKE):(this.idleTime+=u,this.sleepState=r.SLEEPY),this.idleTime>this.sleepTimeLimit&&(t?this.wantsToSleep=!0:this.sleep()))};r.prototype.overlaps=function(n){return this.world.overlapKeeper.bodiesAreOverlapping(this,n)};s=i.create();u=i.create();r.prototype.integrate=function(n){var f=this.invMass,e=this.force,r=this.position,t=this.velocity;i.copy(this.previousPosition,this.position);this.previousAngle=this.angle;this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*n);i.scale(s,e,n*f);i.multiply(s,this.massMultiplier,s);i.add(t,s,t);this.integrateToTimeOfImpact(n)||(i.scale(u,t,n),i.add(r,r,u),this.fixedRotation||(this.angle+=this.angularVelocity*n));this.aabbNeedsUpdate=!0};var w=new d,e=new l({mode:l.ALL}),st=i.create(),f=i.create(),o=i.create(),c=i.create();r.prototype.integrateToTimeOfImpact=function(n){var h;if(this.ccdSpeedThreshold<0||i.squaredLength(this.velocity)<Math.pow(this.ccdSpeedThreshold,2))return!1;i.normalize(st,this.velocity);i.scale(f,this.velocity,n);i.add(f,f,this.position);i.sub(o,f,this.position);var r,v=this.angularVelocity*n,b=i.length(o),t=1,y=this;if(w.reset(),e.callback=function(n){n.body!==y&&(r=n.body,n.getHitPoint(f,e),i.sub(o,f,y.position),t=i.length(o)/b,n.stop())},i.copy(e.from,this.position),i.copy(e.to,f),e.update(),this.world.raycast(w,e),!r)return!1;h=this.angle;i.copy(c,this.position);for(var p=0,l=0,s=0,a=t;a>=l&&p<this.ccdIterations;)p++,s=(a-l)/2,i.scale(u,o,t),i.add(this.position,c,u),this.angle=h+v*t,this.updateAABB(),this.aabb.overlaps(r.aabb)&&this.world.narrowphase.bodiesOverlap(this,r)?l=s:a=s;return t=s,i.copy(this.position,c),this.angle=h,i.scale(u,o,t),i.add(this.position,this.position,u),this.fixedRotation||(this.angle+=v*t),!0};r.prototype.getVelocityAtPoint=function(n,t){return i.crossVZ(n,t,this.angularVelocity),i.subtract(n,this.velocity,n),n};r.sleepyEvent={type:"sleepy"};r.sleepEvent={type:"sleep"};r.wakeUpEvent={type:"wakeup"};r.DYNAMIC=1;r.STATIC=2;r.KINEMATIC=4;r.AWAKE=0;r.SLEEPY=1;r.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(n,t){function r(n,t,r){var f,e,o;r=r||{};u.call(this,n,t,r);this.localAnchorA=i.fromValues(0,0);this.localAnchorB=i.fromValues(0,0);r.localAnchorA&&i.copy(this.localAnchorA,r.localAnchorA);r.localAnchorB&&i.copy(this.localAnchorB,r.localAnchorB);r.worldAnchorA&&this.setWorldAnchorA(r.worldAnchorA);r.worldAnchorB&&this.setWorldAnchorB(r.worldAnchorB);f=i.create();e=i.create();this.getWorldAnchorA(f);this.getWorldAnchorB(e);o=i.distance(f,e);this.restLength="number"==typeof r.restLength?r.restLength:o}var i=n("../math/vec2"),u=n("./Spring");n("../utils/Utils");t.exports=r;(r.prototype=new u).constructor=r;r.prototype.setWorldAnchorA=function(n){this.bodyA.toLocalFrame(this.localAnchorA,n)};r.prototype.setWorldAnchorB=function(n){this.bodyB.toLocalFrame(this.localAnchorB,n)};r.prototype.getWorldAnchorA=function(n){this.bodyA.toWorldFrame(n,this.localAnchorA)};r.prototype.getWorldAnchorB=function(n){this.bodyB.toWorldFrame(n,this.localAnchorB)};var f=i.create(),e=i.create(),o=i.create(),s=i.create(),h=i.create(),c=i.create(),l=i.create(),a=i.create(),v=i.create();r.prototype.applyForce=function(){var rt=this.stiffness,ut=this.damping,ft=this.restLength,n=this.bodyA,t=this.bodyB,p=f,w=e,r=o,u=s,y=v,b=h,k=c,d=l,g=a,nt,tt,it;this.getWorldAnchorA(b);this.getWorldAnchorB(k);i.sub(d,b,n.position);i.sub(g,k,t.position);i.sub(p,k,b);nt=i.len(p);i.normalize(w,p);i.sub(r,t.velocity,n.velocity);i.crossZV(y,t.angularVelocity,g);i.add(r,r,y);i.crossZV(y,n.angularVelocity,d);i.sub(r,r,y);i.scale(u,w,-rt*(nt-ft)-ut*i.dot(r,w));i.sub(n.force,n.force,u);i.add(t.force,t.force,u);tt=i.crossLength(d,u);it=i.crossLength(g,u);n.angularForce-=tt;t.angularForce+=it}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(n,t){function i(n,t,i){i=i||{};r.call(this,n,t,i);this.restAngle="number"==typeof i.restAngle?i.restAngle:t.angle-n.angle}n("../math/vec2");var r=n("./Spring");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.applyForce=function(){var r=this.stiffness,u=this.damping,f=this.restAngle,n=this.bodyA,t=this.bodyB,i=-r*(t.angle-n.angle-f)-u*(t.angularVelocity-n.angularVelocity)*0;n.angularForce-=i;t.angularForce+=i}},{"../math/vec2":30,"./Spring":34}],34:[function(n,t){function i(n,t,i){i=r.defaults(i,{stiffness:100,damping:1});this.stiffness=i.stiffness;this.damping=i.damping;this.bodyA=n;this.bodyB=t}n("../math/vec2");var r=n("../utils/Utils");t.exports=i;i.prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(n,t){function r(n,t){t=t||{};this.chassisBody=n;this.wheels=[];this.groundBody=new c({mass:0});this.world=null;var i=this;this.preStepCallback=function(){i.update()}}function u(n,t){t=t||{};this.vehicle=n;this.forwardEquation=new h(n.chassisBody,n.groundBody);this.sideEquation=new h(n.chassisBody,n.groundBody);this.steerValue=0;this.engineForce=0;this.setSideFriction(void 0!==t.sideFriction?t.sideFriction:5);this.localForwardVector=i.fromValues(0,1);t.localForwardVector&&i.copy(this.localForwardVector,t.localForwardVector);this.localPosition=i.fromValues(0,0);t.localPosition&&i.copy(this.localPosition,t.localPosition);s.apply(this,n.chassisBody,n.groundBody);this.equations.push(this.forwardEquation,this.sideEquation);this.setBrakeForce(0)}var i=n("../math/vec2"),s=(n("../utils/Utils"),n("../constraints/Constraint")),h=n("../equations/FrictionEquation"),c=n("../objects/Body"),o,e,f;t.exports=r;r.prototype.addToWorld=function(n){var t,i;for(this.world=n,n.addBody(this.groundBody),n.on("preStep",this.preStepCallback),t=0;t<this.wheels.length;t++)i=this.wheels[t],n.addConstraint(i)};r.prototype.removeFromWorld=function(){var t=this.world,n,i;for(t.removeBody(this.groundBody),t.off("preStep",this.preStepCallback),n=0;n<this.wheels.length;n++)i=this.wheels[n],t.removeConstraint(i);this.world=null};r.prototype.addWheel=function(n){var t=new u(this,n);return this.wheels.push(t),t};r.prototype.update=function(){for(var n=0;n<this.wheels.length;n++)this.wheels[n].update()};(u.prototype=new s).setBrakeForce=function(n){this.forwardEquation.setSlipForce(n)};u.prototype.setSideFriction=function(n){this.sideEquation.setSlipForce(n)};o=i.create();e=i.create();u.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(e,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(o,e),i.dot(o,e)};f=i.create();u.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector);i.rotate(this.sideEquation.t,this.localForwardVector,Math.PI/2);this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t);i.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue);i.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue);this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition);i.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB);this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition);i.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA);i.normalize(f,this.forwardEquation.t);i.scale(f,f,this.engineForce);this.vehicle.chassisBody.applyForce(f,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(n,t){var i=t.exports={AABB:n("./collision/AABB"),AngleLockEquation:n("./equations/AngleLockEquation"),Body:n("./objects/Body"),Broadphase:n("./collision/Broadphase"),Capsule:n("./shapes/Capsule"),Circle:n("./shapes/Circle"),Constraint:n("./constraints/Constraint"),ContactEquation:n("./equations/ContactEquation"),ContactEquationPool:n("./utils/ContactEquationPool"),ContactMaterial:n("./material/ContactMaterial"),Convex:n("./shapes/Convex"),DistanceConstraint:n("./constraints/DistanceConstraint"),Equation:n("./equations/Equation"),EventEmitter:n("./events/EventEmitter"),FrictionEquation:n("./equations/FrictionEquation"),FrictionEquationPool:n("./utils/FrictionEquationPool"),GearConstraint:n("./constraints/GearConstraint"),GSSolver:n("./solver/GSSolver"),Heightfield:n("./shapes/Heightfield"),Line:n("./shapes/Line"),LockConstraint:n("./constraints/LockConstraint"),Material:n("./material/Material"),Narrowphase:n("./collision/Narrowphase"),NaiveBroadphase:n("./collision/NaiveBroadphase"),Particle:n("./shapes/Particle"),Plane:n("./shapes/Plane"),Pool:n("./utils/Pool"),RevoluteConstraint:n("./constraints/RevoluteConstraint"),PrismaticConstraint:n("./constraints/PrismaticConstraint"),Ray:n("./collision/Ray"),RaycastResult:n("./collision/RaycastResult"),Box:n("./shapes/Box"),RotationalVelocityEquation:n("./equations/RotationalVelocityEquation"),SAPBroadphase:n("./collision/SAPBroadphase"),Shape:n("./shapes/Shape"),Solver:n("./solver/Solver"),Spring:n("./objects/Spring"),TopDownVehicle:n("./objects/TopDownVehicle"),LinearSpring:n("./objects/LinearSpring"),RotationalSpring:n("./objects/RotationalSpring"),Utils:n("./utils/Utils"),World:n("./world/World"),vec2:n("./math/vec2"),version:n("../package.json").version};Object.defineProperty(i,"Rectangle",{get:function(){return console.warn("The Rectangle class has been renamed to Box."),this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(n,t){function r(n){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(n={width:arguments[0],height:arguments[1]},console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })"));n=n||{};var t=this.width=n.width||1,r=this.height=n.height||1,e=[i.fromValues(-t/2,-r/2),i.fromValues(t/2,-r/2),i.fromValues(t/2,r/2),i.fromValues(-t/2,r/2)],o=[i.fromValues(1,0),i.fromValues(0,1)];n.vertices=e;n.axes=o;n.type=f.BOX;u.call(this,n)}var i=n("../math/vec2"),f=n("./Shape"),u=n("./Convex");t.exports=r;(r.prototype=new u).constructor=r;r.prototype.computeMomentOfInertia=function(n){var t=this.width,i=this.height;return n*(i*i+t*t)/12};r.prototype.updateBoundingRadius=function(){var n=this.width,t=this.height;this.boundingRadius=Math.sqrt(n*n+t*t)/2};i.create();i.create();i.create();i.create();r.prototype.computeAABB=function(n,t,i){n.setFromPoints(this.vertices,t,i,0)};r.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(n,t){function u(n){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(n={length:arguments[0],radius:arguments[1]},console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })"));n=n||{};this.length=n.length||1;this.radius=n.radius||1;n.type=f.CAPSULE;f.call(this,n)}var f=n("./Shape"),i=n("../math/vec2"),r;t.exports=u;(u.prototype=new f).constructor=u;u.prototype.computeMomentOfInertia=function(n){var t=this.radius,i=this.length+t,r=2*t;return n*(r*r+i*i)/12};u.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2};u.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};r=i.create();u.prototype.computeAABB=function(n,t,u){var f=this.radius;i.set(r,this.length/2,0);0!==u&&i.rotate(r,r,u);i.set(n.upperBound,Math.max(r[0]+f,-r[0]+f),Math.max(r[1]+f,-r[1]+f));i.set(n.lowerBound,Math.min(r[0]-f,-r[0]-f),Math.min(r[1]-f,-r[1]-f));i.add(n.lowerBound,n.lowerBound,t);i.add(n.upperBound,n.upperBound,t)};var e=i.create(),o=i.create(),s=i.create(),h=i.create(),c=i.fromValues(0,1);u.prototype.raycast=function(n,t,r,u){for(var tt,d,a=t.from,p=t.to,v=(t.direction,e),f=o,l=s,b=h,k=this.length/2,y=0;y<2;y++)if(tt=this.radius*(2*y-1),i.set(l,-k,tt),i.set(b,k,tt),i.toGlobalFrame(l,l,r,u),i.toGlobalFrame(b,b,r,u),(w=i.getLineSegmentsIntersectionFraction(a,p,l,b))>=0&&(i.rotate(f,c,u),i.scale(f,f,2*y-1),t.reportIntersection(n,w,f,-1),n.shouldStop(t)))return;for(d=Math.pow(this.radius,2)+Math.pow(k,2),y=0;y<2;y++){i.set(l,k*(2*y-1),0);i.toGlobalFrame(l,l,r,u);var rt=Math.pow(p[0]-a[0],2)+Math.pow(p[1]-a[1],2),it=2*((p[0]-a[0])*(a[0]-l[0])+(p[1]-a[1])*(a[1]-l[1])),et=Math.pow(a[0]-l[0],2)+Math.pow(a[1]-l[1],2)-Math.pow(this.radius,2),w=Math.pow(it,2)-4*rt*et;if(!(w<0))if(0===w){if(i.lerp(v,a,p,w),i.squaredDistance(v,r)>d&&(i.sub(f,v,l),i.normalize(f,f),t.reportIntersection(n,w,f,-1),n.shouldStop(t)))return}else{var ut=Math.sqrt(w),ft=1/(2*rt),g=(-it-ut)*ft,nt=(-it+ut)*ft;if(g>=0&&g<=1&&(i.lerp(v,a,p,g),i.squaredDistance(v,r)>d&&(i.sub(f,v,l),i.normalize(f,f),t.reportIntersection(n,g,f,-1),n.shouldStop(t))))return;if(nt>=0&&nt<=1&&(i.lerp(v,a,p,nt),i.squaredDistance(v,r)>d&&(i.sub(f,v,l),i.normalize(f,f),t.reportIntersection(n,nt,f,-1),n.shouldStop(t))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(n,t){function r(n){"number"==typeof arguments[0]&&(n={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })"));n=n||{};this.radius=n.radius||1;n.type=u.CIRCLE;u.call(this,n)}var u=n("./Shape"),i=n("../math/vec2"),f,e;t.exports=r;(r.prototype=new u).constructor=r;r.prototype.computeMomentOfInertia=function(n){var t=this.radius;return n*t*t/2};r.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius};r.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius};r.prototype.computeAABB=function(n,t){var r=this.radius;i.set(n.upperBound,r,r);i.set(n.lowerBound,-r,-r);t&&(i.add(n.lowerBound,n.lowerBound,t),i.add(n.upperBound,n.upperBound,t))};f=i.create();e=i.create();r.prototype.raycast=function(n,t,r){var o=t.from,s=t.to,b=this.radius,y=Math.pow(s[0]-o[0],2)+Math.pow(s[1]-o[1],2),v=2*((s[0]-o[0])*(o[0]-r[0])+(s[1]-o[1])*(o[1]-r[1])),k=Math.pow(o[0]-r[0],2)+Math.pow(o[1]-r[1],2)-Math.pow(b,2),c=Math.pow(v,2)-4*y*k,h=f,u=e;if(!(c<0))if(0===c)i.lerp(h,o,s,c),i.sub(u,h,r),i.normalize(u,u),t.reportIntersection(n,c,u,-1);else{var p=Math.sqrt(c),w=1/(2*y),l=(-v-p)*w,a=(-v+p)*w;if(l>=0&&l<=1&&(i.lerp(h,o,s,l),i.sub(u,h,r),i.normalize(u,u),t.reportIntersection(n,l,u,-1),n.shouldStop(t)))return;a>=0&&a<=1&&(i.lerp(h,o,s,a),i.sub(u,h,r),i.normalize(u,u),t.reportIntersection(n,a,u,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(n,t){function r(n){var f,t,e,o;for(Array.isArray(arguments[0])&&(n={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),n=n||{},this.vertices=[],f=void 0!==n.vertices?n.vertices:[],t=0;t<f.length;t++)e=i.create(),i.copy(e,f[t]),this.vertices.push(e);if(this.axes=[],n.axes)for(t=0;t<n.axes.length;t++)o=i.create(),i.copy(o,n.axes[t]),this.axes.push(o);else for(t=0;t<this.vertices.length;t++){var s=this.vertices[t],h=this.vertices[(t+1)%this.vertices.length],r=i.create();i.sub(r,h,s);i.rotate90cw(r,r);i.normalize(r,r);this.axes.push(r)}if(this.centerOfMass=i.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,n.type=u.CONVEX,u.call(this,n),this.updateBoundingRadius(),this.updateArea(),this.area<0)throw new Error("Convex vertices must be given in conter-clockwise winding.");}var u=n("./Shape"),i=n("../math/vec2"),o=n("../math/polyk"),f,e;n("poly-decomp");t.exports=r;(r.prototype=new u).constructor=r;f=i.create();e=i.create();r.prototype.projectOntoLocalAxis=function(n,t){for(var h,s,e,r=null,u=null,n=f,o=0;o<this.vertices.length;o++)s=this.vertices[o],e=i.dot(s,n),(null===r||e>r)&&(r=e),(null===u||e<u)&&(u=e);u>r&&(h=u,u=r,r=h);i.set(t,u,r)};r.prototype.projectOntoWorldAxis=function(n,t,r,u){var f=e,o;this.projectOntoLocalAxis(n,u);0!==r?i.rotate(f,n,r):f=n;o=i.dot(t,f);i.set(u,u[0]+o,u[1]+o)};r.prototype.updateTriangles=function(){var i,r,t,n;for(this.triangles.length=0,i=[],n=0;n<this.vertices.length;n++)r=this.vertices[n],i.push(r[0],r[1]);for(t=o.Triangulate(i),n=0;n<t.length;n+=3){var u=t[n],f=t[n+1],e=t[n+2];this.triangles.push([u,f,e])}};var s=i.create(),h=i.create(),c=i.create(),l=i.create(),a=i.create();i.create();i.create();i.create();i.create();r.prototype.updateCenterOfMass=function(){var w=this.triangles,u=this.vertices,n=this.centerOfMass,b=s,f=c,e=l,o=a,k=h,v,t,p;for(i.set(n,0,0),v=0,t=0;t!==w.length;t++){var y=w[t],f=u[y[0]],e=u[y[1]],o=u[y[2]];i.centroid(b,f,e,o);p=r.triangleArea(f,e,o);v+=p;i.scale(k,b,p);i.add(n,n,k)}i.scale(n,n,1/v)};r.prototype.computeMomentOfInertia=function(n){for(var f=0,e=0,o=this.vertices.length,s=o-1,t=0;t<o;s=t,t++){var r=this.vertices[s],u=this.vertices[t],h=Math.abs(i.crossLength(r,u));f+=h*(i.dot(u,u)+i.dot(u,r)+i.dot(r,r));e+=h}return n/6*(f/e)};r.prototype.updateBoundingRadius=function(){for(var r,u=this.vertices,n=0,t=0;t!==u.length;t++)r=i.squaredLength(u[t]),r>n&&(n=r);this.boundingRadius=Math.sqrt(n)};r.triangleArea=function(n,t,i){return.5*((t[0]-n[0])*(i[1]-n[1])-(i[0]-n[0])*(t[1]-n[1]))};r.prototype.updateArea=function(){this.updateTriangles();this.area=0;for(var u=this.triangles,n=this.vertices,t=0;t!==u.length;t++){var i=u[t],f=n[i[0]],e=n[i[1]],o=n[i[2]],s=r.triangleArea(f,e,o);this.area+=s}};r.prototype.computeAABB=function(n,t,i){n.setFromPoints(this.vertices,t,i,0)};var v=i.create(),y=i.create(),p=i.create();r.prototype.raycast=function(n,t,r,u){var h=v,c=y,f=p,o=this.vertices,s,e;for(i.toLocalFrame(h,t.from,r,u),i.toLocalFrame(c,t.to,r,u),s=o.length,e=0;e<s&&!n.shouldStop(t);e++){var l=o[e],a=o[(e+1)%s],w=i.getLineSegmentsIntersectionFraction(h,c,l,a);w>=0&&(i.sub(f,a,l),i.rotate(f,f,-Math.PI/2+u),i.normalize(f,f),t.reportIntersection(n,w,f,e))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(n,t){function r(n){if(Array.isArray(arguments[0])){if(n={heights:arguments[0]},"object"==typeof arguments[1])for(var t in arguments[1])n[t]=arguments[1][t];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}n=n||{};this.heights=n.heights?n.heights.slice(0):[];this.maxValue=n.maxValue||null;this.minValue=n.minValue||null;this.elementWidth=n.elementWidth||.1;void 0!==n.maxValue&&void 0!==n.minValue||this.updateMaxMinValues();n.type=f.HEIGHTFIELD;f.call(this,n)}var f=n("./Shape"),i=n("../math/vec2"),u;n("../utils/Utils");t.exports=r;(r.prototype=new f).constructor=r;r.prototype.updateMaxMinValues=function(){for(var n,t=this.heights,i=t[0],r=t[0],u=0;u!==t.length;u++)n=t[u],n>i&&(i=n),n<r&&(r=n);this.maxValue=i;this.minValue=r};r.prototype.computeMomentOfInertia=function(){return Number.MAX_VALUE};r.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE};r.prototype.updateArea=function(){for(var t=this.heights,i=0,n=0;n<t.length-1;n++)i+=(t[n]+t[n+1])/2*this.elementWidth;this.area=i};u=[i.create(),i.create(),i.create(),i.create()];r.prototype.computeAABB=function(n,t,r){i.set(u[0],0,this.maxValue);i.set(u[1],this.elementWidth*this.heights.length,this.maxValue);i.set(u[2],this.elementWidth*this.heights.length,this.minValue);i.set(u[3],0,this.minValue);n.setFromPoints(u,t,r)};r.prototype.getLineSegment=function(n,t,r){var u=this.heights,f=this.elementWidth;i.set(n,r*f,u[r]);i.set(t,(r+1)*f,u[r+1])};r.prototype.getSegmentIndex=function(n){return Math.floor(n[0]/this.elementWidth)};r.prototype.getClampedSegmentIndex=function(n){var t=this.getSegmentIndex(n);return Math.min(this.heights.length,Math.max(t,0))};i.create();var e=i.create(),o=i.create(),s=i.create(),h=i.create(),c=i.create();i.fromValues(0,1);r.prototype.raycast=function(n,t,r,u){var g=t.from,nt=t.to,f=(t.direction,e),y=o,p=s,w=h,b=c,l,a,d,v,k;for(i.toLocalFrame(w,g,r,u),i.toLocalFrame(b,nt,r,u),l=this.getClampedSegmentIndex(w),a=this.getClampedSegmentIndex(b),l>a&&(d=l,l=a,a=d),v=0;v<this.heights.length-1;v++)if(this.getLineSegment(y,p,v),k=i.getLineSegmentsIntersectionFraction(w,b,y,p),k>=0&&(i.sub(f,p,y),i.rotate(f,f,u+Math.PI/2),i.normalize(f,f),t.reportIntersection(n,k,f,-1),n.shouldStop(t)))return}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(n,t){function r(n){"number"==typeof arguments[0]&&(n={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })"));n=n||{};this.length=n.length||1;n.type=f.LINE;f.call(this,n)}var f=n("./Shape"),i=n("../math/vec2"),u;t.exports=r;(r.prototype=new f).constructor=r;r.prototype.computeMomentOfInertia=function(n){return n*Math.pow(this.length,2)/12};r.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};u=[i.create(),i.create()];r.prototype.computeAABB=function(n,t,r){var f=this.length/2;i.set(u[0],-f,0);i.set(u[1],f,0);n.setFromPoints(u,t,r,0)};i.create();var e=i.create(),o=i.create(),s=i.create(),h=i.fromValues(0,1);r.prototype.raycast=function(n,t,r,u){var y=t.from,p=t.to,f=o,c=s,v=this.length/2,l,a;i.set(f,-v,0);i.set(c,v,0);i.toGlobalFrame(f,f,r,u);i.toGlobalFrame(c,c,r,u);l=i.getLineSegmentsIntersectionFraction(f,c,y,p);l>=0&&(a=e,i.rotate(a,h,u),t.reportIntersection(n,l,a,-1))}},{"../math/vec2":30,"./Shape":45}],43:[function(n,t){function i(n){(n=n||{}).type=r.PARTICLE;r.call(this,n)}var r=n("./Shape"),u=n("../math/vec2");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.computeMomentOfInertia=function(){return 0};i.prototype.updateBoundingRadius=function(){this.boundingRadius=0};i.prototype.computeAABB=function(n,t){u.copy(n.lowerBound,t);u.copy(n.upperBound,t)}},{"../math/vec2":30,"./Shape":45}],44:[function(n,t){function r(n){(n=n||{}).type=u.PLANE;u.call(this,n)}var u=n("./Shape"),i=n("../math/vec2");n("../utils/Utils");t.exports=r;(r.prototype=new u).constructor=r;r.prototype.computeMomentOfInertia=function(){return 0};r.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE};r.prototype.computeAABB=function(n,t,r){var u=r%(2*Math.PI),o=i.set,f=n.lowerBound,e=n.upperBound;o(f,-1e7,-1e7);o(e,1e7,1e7);0===u?e[1]=0:u===Math.PI/2?f[0]=0:u===Math.PI?f[1]=0:u===3*Math.PI/2&&(e[0]=0)};r.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var f=i.create(),e=(i.create(),i.create(),i.create()),o=i.create();r.prototype.raycast=function(n,t,r,u){var l=t.from,a=t.to,w=t.direction,v=f,s=e,h=o,c,y,p;i.set(s,0,1);i.rotate(s,s,u);i.sub(h,l,r);c=i.dot(h,s);(i.sub(h,a,r),c*i.dot(h,s)>0||i.squaredDistance(l,a)<c*c)||(y=i.dot(s,w),i.sub(v,l,r),p=-i.dot(s,v)/y/t.length,t.reportIntersection(n,p,s,-1))}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(n,t){function i(n){n=n||{};this.body=null;this.position=r.fromValues(0,0);n.position&&r.copy(this.position,n.position);this.angle=n.angle||0;this.type=n.type||0;this.id=i.idCounter++;this.boundingRadius=0;this.collisionGroup=void 0!==n.collisionGroup?n.collisionGroup:1;this.collisionResponse=void 0===n.collisionResponse||n.collisionResponse;this.collisionMask=void 0!==n.collisionMask?n.collisionMask:1;this.material=n.material||null;this.area=0;this.sensor=void 0!==n.sensor&&n.sensor;this.type&&this.updateBoundingRadius();this.updateArea()}t.exports=i;var r=n("../math/vec2");i.idCounter=0;i.CIRCLE=1;i.PARTICLE=2;i.PLANE=4;i.CONVEX=8;i.LINE=16;i.BOX=32;i.CAPSULE=64;i.HEIGHTFIELD=128;i.prototype.computeMomentOfInertia=function(){};i.prototype.updateBoundingRadius=function(){};i.prototype.updateArea=function(){};i.prototype.computeAABB=function(){};i.prototype.raycast=function(){}},{"../math/vec2":30}],46:[function(n,t){function i(n){u.call(this,n,u.GS);n=n||{};this.iterations=n.iterations||10;this.tolerance=n.tolerance||1e-7;this.arrayStep=30;this.lambda=new r.ARRAY_TYPE(this.arrayStep);this.Bs=new r.ARRAY_TYPE(this.arrayStep);this.invCs=new r.ARRAY_TYPE(this.arrayStep);this.useZeroRHS=!1;this.frictionIterations=void 0!==n.frictionIterations?0:n.frictionIterations;this.usedIterations=0}function e(n){for(var t=n.length;t--;)n[t]=0}var f=n("../math/vec2"),u=n("./Solver"),r=n("../utils/Utils"),o=n("../equations/FrictionEquation");t.exports=i;(i.prototype=new u).constructor=i;i.prototype.solve=function(n,t){var s,y,h,it,p,w,b,k;this.sortEquations();var l=0,et=this.iterations,rt=this.frictionIterations,a=this.equations,c=a.length,ut=Math.pow(this.tolerance*c,2),d=t.bodies,g=t.bodies.length,ft=(f.add,f.set,this.useZeroRHS),v=this.lambda;if(this.usedIterations=0,c)for(u=0;u!==g;u++)(it=d[u]).updateSolveMassProperties();v.length<c&&(v=this.lambda=new r.ARRAY_TYPE(c+this.arrayStep),this.Bs=new r.ARRAY_TYPE(c+this.arrayStep),this.invCs=new r.ARRAY_TYPE(c+this.arrayStep));e(v);for(var nt=this.invCs,tt=this.Bs,v=this.lambda,u=0;u!==a.length;u++)((s=a[u]).timeStep!==n||s.needsUpdate)&&(s.timeStep=n,s.update()),tt[u]=s.computeB(s.a,s.b,n),nt[u]=s.computeInvC(s.epsilon);if(0!==c){for(u=0;u!==g;u++)it=d[u],it.resetConstraintVelocity();if(rt){for(l=0;l!==rt;l++){for(y=0,h=0;h!==c;h++)s=a[h],k=i.iterateEquation(h,s,s.epsilon,tt,nt,v,ft,n,l),y+=Math.abs(k);if(this.usedIterations++,y*y<=ut)break}for(i.updateMultipliers(a,v,1/n),h=0;h!==c;h++)if(p=a[h],p instanceof o){for(w=0,b=0;b!==p.contactEquations.length;b++)w+=p.contactEquations[b].multiplier;w*=p.frictionCoefficient/p.contactEquations.length;p.maxForce=w;p.minForce=-w}}for(l=0;l!==et;l++){for(y=0,h=0;h!==c;h++)s=a[h],k=i.iterateEquation(h,s,s.epsilon,tt,nt,v,ft,n,l),y+=Math.abs(k);if(this.usedIterations++,y*y<=ut)break}for(u=0;u!==g;u++)d[u].addConstraintVelocity();i.updateMultipliers(a,v,1/n)}};i.updateMultipliers=function(n,t,i){for(var r=n.length;r--;)n[r].multiplier=t[r]*i};i.iterateEquation=function(n,t,i,r,u,f,e,o){var l=r[n],y=u[n],h=f[n],p=t.computeGWlambda(),a=t.maxForce,v=t.minForce,s,c;return e&&(l=0),s=y*(l-p-i*h),c=h+s,c<v*o?s=v*o-h:c>a*o&&(s=a*o-h),f[n]+=s,t.addToWlambda(s),s}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(n,t){function i(n,t){n=n||{};u.call(this);this.type=t;this.equations=[];this.equationSortFunction=n.equationSortFunction||!1}var u,r;n("../utils/Utils");u=n("../events/EventEmitter");t.exports=i;(i.prototype=new u).constructor=i;i.prototype.solve=function(){throw new Error("Solver.solve should be implemented by subclasses!");};r={bodies:[]};i.prototype.solveIsland=function(n,t){this.removeAllEquations();t.equations.length&&(this.addEquations(t.equations),r.bodies.length=0,t.getBodies(r.bodies),r.bodies.length&&this.solve(n,r))};i.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)};i.prototype.addEquation=function(n){n.enabled&&this.equations.push(n)};i.prototype.addEquations=function(n){for(var i,t=0,r=n.length;t!==r;t++)i=n[t],i.enabled&&this.equations.push(i)};i.prototype.removeEquation=function(n){var t=this.equations.indexOf(n);-1!==t&&this.equations.splice(t,1)};i.prototype.removeAllEquations=function(){this.equations.length=0};i.GS=1;i.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(n,t){function i(){r.apply(this,arguments)}var u=n("../equations/ContactEquation"),r=n("./Pool");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.create=function(){return new u};i.prototype.destroy=function(n){return n.bodyA=n.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(n,t){function i(){r.apply(this,arguments)}var u=n("../equations/FrictionEquation"),r=n("./Pool");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.create=function(){return new u};i.prototype.destroy=function(n){return n.bodyA=n.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(n,t){function i(){r.apply(this,arguments)}var u=n("../world/IslandNode"),r=n("./Pool");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.create=function(){return new u};i.prototype.destroy=function(n){return n.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(n,t){function i(){r.apply(this,arguments)}var u=n("../world/Island"),r=n("./Pool");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.create=function(){return new u};i.prototype.destroy=function(n){return n.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(n,t){function i(){this.overlappingShapesLastState=new r;this.overlappingShapesCurrentState=new r;this.recordPool=new u({size:16});this.tmpDict=new r;this.tmpArray1=[]}var r=n("./TupleDictionary"),u=(n("./OverlapKeeperRecord"),n("./OverlapKeeperRecordPool"));n("./Utils");t.exports=i;i.prototype.tick=function(){for(var i,r,n=this.overlappingShapesLastState,t=this.overlappingShapesCurrentState,u=n.keys.length;u--;)i=n.keys[u],r=n.getByKey(i),t.getByKey(i),r&&this.recordPool.release(r);n.reset();n.copy(t);t.reset()};i.prototype.setOverlapping=function(n,t,i,r){var u,f;this.overlappingShapesLastState;u=this.overlappingShapesCurrentState;u.get(t.id,r.id)||(f=this.recordPool.get(),f.set(n,t,i,r),u.set(t.id,r.id,f))};i.prototype.getNewOverlaps=function(n){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,n)};i.prototype.getEndOverlaps=function(n){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,n)};i.prototype.bodiesAreOverlapping=function(n,t){for(var f,i,r=this.overlappingShapesCurrentState,u=r.keys.length;u--;)if(f=r.keys[u],i=r.data[f],i.bodyA===n&&i.bodyB===t||i.bodyA===t&&i.bodyB===n)return!0;return!1};i.prototype.getDiff=function(n,t,i){var o=n,u=t,f,r,e;for((i=i||[]).length=0,f=u.keys.length;f--;){if(r=u.keys[f],e=u.data[r],!e)throw new Error("Key "+r+" had no data!");o.data[r]||i.push(e)}return i};i.prototype.isNewOverlap=function(n,t){var i=0|n.id,r=0|t.id,u=this.overlappingShapesLastState,f=this.overlappingShapesCurrentState;return!u.get(i,r)&&!!f.get(i,r)};i.prototype.getNewBodyOverlaps=function(n){this.tmpArray1.length=0;var t=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(t,n)};i.prototype.getEndBodyOverlaps=function(n){this.tmpArray1.length=0;var t=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(t,n)};i.prototype.getBodyDiff=function(n,t){var r,u,i;for(t=t||[],r=this.tmpDict,u=n.length;u--;)i=n[u],r.set(0|i.bodyA.id,0|i.bodyB.id,i);for(u=r.keys.length;u--;)(i=r.getByKey(r.keys[u]))&&t.push(i.bodyA,i.bodyB);return r.reset(),t}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(n,t){function i(n,t,i,r){this.shapeA=t;this.shapeB=r;this.bodyA=n;this.bodyB=i}t.exports=i;i.prototype.set=function(n,t,r,u){i.call(this,n,t,r,u)}},{}],54:[function(n,t){function i(){r.apply(this,arguments)}var u=n("./OverlapKeeperRecord"),r=n("./Pool");t.exports=i;(i.prototype=new r).constructor=i;i.prototype.create=function(){return new u};i.prototype.destroy=function(n){return n.bodyA=n.bodyB=n.shapeA=n.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(n,t){function i(n){n=n||{};this.objects=[];void 0!==n.size&&this.resize(n.size)}t.exports=i;i.prototype.resize=function(n){for(var t=this.objects;t.length>n;)t.pop();for(;t.length<n;)t.push(this.create());return this};i.prototype.get=function(){var n=this.objects;return n.length?n.pop():this.create()};i.prototype.release=function(n){return this.destroy(n),this.objects.push(n),this}},{}],56:[function(n,t){function i(){this.data={};this.keys=[]}var r=n("./Utils");t.exports=i;i.prototype.getKey=function(n,t){return n|=0,t|=0,(0|n)==(0|t)?-1:0|((0|n)>(0|t)?n<<16|65535&t:t<<16|65535&n)};i.prototype.getByKey=function(n){return n|=0,this.data[n]};i.prototype.get=function(n,t){return this.data[this.getKey(n,t)]};i.prototype.set=function(n,t,i){if(!i)throw new Error("No data!");var r=this.getKey(n,t);return this.data[r]||this.keys.push(r),this.data[r]=i,r};i.prototype.reset=function(){for(var i=this.data,n=this.keys,t=n.length;t--;)delete i[n[t]];n.length=0};i.prototype.copy=function(n){var t,i;for(this.reset(),r.appendArray(this.keys,n.keys),t=n.keys.length;t--;)i=n.keys[t],this.data[i]=n.data[i]}},{"./Utils":57}],57:[function(n,t){function i(){}t.exports=i;i.appendArray=function(n,t){if(t.length<15e4)n.push.apply(n,t);else for(var i=0,r=t.length;i!==r;++i)n.push(t[i])};i.splice=function(n,t,i){i=i||1;for(var r=t,u=n.length-i;r<u;r++)n[r]=n[r+i];n.length=u};i.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array;i.extend=function(n,t){for(var i in t)n[i]=t[i]};i.defaults=function(n,t){n=n||{};for(var i in t)i in n||(n[i]=t[i]);return n}},{}],58:[function(n,t){function r(){this.equations=[];this.bodies=[]}var u=n("../objects/Body"),i;t.exports=r;r.prototype.reset=function(){this.equations.length=this.bodies.length=0};i=[];r.prototype.getBodies=function(n){var u=n||[],f=this.equations,r,t;for(i.length=0,r=0;r!==f.length;r++)t=f[r],-1===i.indexOf(t.bodyA.id)&&(u.push(t.bodyA),i.push(t.bodyA.id)),-1===i.indexOf(t.bodyB.id)&&(u.push(t.bodyB),i.push(t.bodyB.id));return u};r.prototype.wantsToSleep=function(){for(var t,n=0;n<this.bodies.length;n++)if(t=this.bodies[n],t.type===u.DYNAMIC&&!t.wantsToSleep)return!1;return!0};r.prototype.sleep=function(){for(var n=0;n<this.bodies.length;n++)this.bodies[n].sleep();return!0}},{"../objects/Body":31}],59:[function(n,t){function i(){this.nodePool=new u({size:16});this.islandPool=new f({size:8});this.equations=[];this.islands=[];this.nodes=[];this.queue=[]}n("../math/vec2");n("./Island");n("./IslandNode");var u=n("./../utils/IslandNodePool"),f=n("./../utils/IslandPool"),r=n("../objects/Body");t.exports=i;i.getUnvisitedNode=function(n){for(var i,u=n.length,t=0;t!==u;t++)if(i=n[t],!i.visited&&i.body.type===r.DYNAMIC)return i;return!1};i.prototype.visit=function(n,t,i){var f,r,u;for(t.push(n.body),f=n.equations.length,r=0;r!==f;r++)u=n.equations[r],-1===i.indexOf(u)&&i.push(u)};i.prototype.bfs=function(n,t,u){var f=this.queue,e,o;for(f.length=0,f.push(n),n.visited=!0,this.visit(n,t,u);f.length;)for(o=f.pop();e=i.getUnvisitedNode(o.neighbors);)e.visited=!0,this.visit(e,t,u),e.body.type===r.DYNAMIC&&f.push(e)};i.prototype.split=function(n){for(var h,e,u,t,v,s,f=n.bodies,r=this.nodes,a=this.equations;r.length;)this.nodePool.release(r.pop());for(t=0;t!==f.length;t++)h=this.nodePool.get(),h.body=f[t],r.push(h);for(e=0;e!==a.length;e++){var o=a[e],t=f.indexOf(o.bodyA),y=f.indexOf(o.bodyB),c=r[t],l=r[y];c.neighbors.push(l);l.neighbors.push(c);c.equations.push(o);l.equations.push(o)}for(u=this.islands,t=0;t<u.length;t++)this.islandPool.release(u[t]);for(u.length=0;v=i.getUnvisitedNode(r);)s=this.islandPool.get(),this.bfs(v,s.bodies,s.equations),u.push(s);return u}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(n,t){function i(n){this.body=n;this.neighbors=[];this.equations=[];this.visited=!1}t.exports=i;i.prototype.reset=function(){this.equations.length=0;this.neighbors.length=0;this.visited=!1;this.body=null}},{}],61:[function(n,t){function r(n){a.apply(this);n=n||{};this.springs=[];this.bodies=[];this.disabledBodyCollisionPairs=[];this.solver=n.solver||new p;this.narrowphase=new rt(this);this.islandManager=new ft;this.gravity=i.fromValues(0,-9.78);n.gravity&&i.copy(this.gravity,n.gravity);this.frictionGravity=i.length(this.gravity)||10;this.useWorldGravityAsFrictionGravity=!0;this.useFrictionGravityOnZeroGravity=!0;this.broadphase=n.broadphase||new it;this.broadphase.setWorld(this);this.constraints=[];this.defaultMaterial=new g;this.defaultContactMaterial=new nt(this.defaultMaterial,this.defaultMaterial);this.lastTimeStep=1/60;this.applySpringForces=!0;this.applyDamping=!0;this.applyGravity=!0;this.solveConstraints=!0;this.contactMaterials=[];this.time=0;this.accumulator=0;this.stepping=!1;this.bodiesToBeRemoved=[];this.islandSplit=void 0===n.islandSplit||!!n.islandSplit;this.emitImpactEvent=!0;this._constraintIdCounter=0;this._bodyIdCounter=0;this.postStepEvent={type:"postStep"};this.addBodyEvent={type:"addBody",body:null};this.removeBodyEvent={type:"removeBody",body:null};this.addSpringEvent={type:"addSpring",spring:null};this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null};this.postBroadphaseEvent={type:"postBroadphase",pairs:null};this.sleepMode=r.NO_SLEEPING;this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]};this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null};this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null};this.overlappingShapesLastState={keys:[]};this.overlappingShapesCurrentState={keys:[]};this.overlapKeeper=new ut}var p=n("../solver/GSSolver"),i=(n("../solver/Solver"),n("../collision/Ray"),n("../math/vec2")),w=n("../shapes/Circle"),b=n("../shapes/Convex"),k=(n("../shapes/Line"),n("../shapes/Plane")),d=n("../shapes/Capsule"),l=n("../shapes/Particle"),a=n("../events/EventEmitter"),u=n("../objects/Body"),g=(n("../shapes/Shape"),n("../objects/LinearSpring"),n("../material/Material")),nt=n("../material/ContactMaterial"),tt=(n("../constraints/DistanceConstraint"),n("../constraints/Constraint"),n("../constraints/LockConstraint"),n("../constraints/RevoluteConstraint"),n("../constraints/PrismaticConstraint"),n("../constraints/GearConstraint"),n("../../package.json"),n("../collision/Broadphase"),n("../collision/AABB")),it=n("../collision/SAPBroadphase"),rt=n("../collision/Narrowphase"),f=n("../utils/Utils"),ut=n("../utils/OverlapKeeper"),ft=n("./IslandManager"),s,v,y,c,h;n("../objects/RotationalSpring");t.exports=r;r.prototype=new Object(a.prototype);r.prototype.constructor=r;r.NO_SLEEPING=1;r.BODY_SLEEPING=2;r.ISLAND_SLEEPING=4;r.prototype.addConstraint=function(n){this.constraints.push(n)};r.prototype.addContactMaterial=function(n){this.contactMaterials.push(n)};r.prototype.removeContactMaterial=function(n){var t=this.contactMaterials.indexOf(n);-1!==t&&f.splice(this.contactMaterials,t,1)};r.prototype.getContactMaterial=function(n,t){for(var i,u=this.contactMaterials,r=0,f=u.length;r!==f;r++)if(i=u[r],i.materialA.id===n.id&&i.materialB.id===t.id||i.materialA.id===t.id&&i.materialB.id===n.id)return i;return!1};r.prototype.removeConstraint=function(n){var t=this.constraints.indexOf(n);-1!==t&&f.splice(this.constraints,t,1)};i.create();i.create();i.create();i.create();i.create();i.create();var et=i.create(),e=i.fromValues(0,0),o=i.fromValues(0,0);i.fromValues(0,0);i.fromValues(0,0);r.prototype.step=function(n,t,r){var e,o,f,u;if(r=r||10,0===(t=t||0))this.internalStep(n),this.time+=n;else{for(this.accumulator+=t,e=0;this.accumulator>=n&&e<r;)this.internalStep(n),this.time+=n,this.accumulator-=n,e++;for(o=this.accumulator%n/n,f=0;f!==this.bodies.length;f++)u=this.bodies[f],i.lerp(u.interpolatedPosition,u.previousPosition,u.position,o),u.interpolatedAngle=u.previousAngle+o*(u.angle-u.previousAngle)}};s=[];r.prototype.internalStep=function(n){var ct,lt,c,g,o,bt,pt,nt,y,ft,tt,p,ot,w,b,st,ht,t;this.stepping=!0;var dt=this.springs.length,gt=this.springs,l=this.bodies,ni=this.gravity,k=this.solver,a=this.bodies.length,ti=this.broadphase,h=this.narrowphase,d=this.constraints,wt=et,ii=(i.scale,i.add),v=(i.rotate,this.islandManager);if((this.overlapKeeper.tick(),this.lastTimeStep=n,this.useWorldGravityAsFrictionGravity)&&(ct=i.length(this.gravity),0===ct&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=ct)),this.applyGravity)for(t=0;t!==a;t++)lt=(c=l[t]).force,c.type===u.DYNAMIC&&c.sleepState!==u.SLEEPING&&(i.scale(wt,ni,c.mass*c.gravityScale),ii(lt,lt,wt));if(this.applySpringForces)for(t=0;t!==dt;t++)gt[t].applyForce();if(this.applyDamping)for(t=0;t!==a;t++)c=l[t],c.type===u.DYNAMIC&&c.applyDamping(n);for(var e=ti.getCollisionPairs(this),it=this.disabledBodyCollisionPairs,t=it.length-2;t>=0;t-=2)for(o=e.length-2;o>=0;o-=2)(it[t]===e[o]&&it[t+1]===e[o+1]||it[t+1]===e[o]&&it[t]===e[o+1])&&e.splice(o,2);for(p=d.length,t=0;t!==p;t++)if(g=d[t],!g.collideConnected)for(o=e.length-2;o>=0;o-=2)(g.bodyA===e[o]&&g.bodyB===e[o+1]||g.bodyB===e[o]&&g.bodyA===e[o+1])&&e.splice(o,2);for(this.postBroadphaseEvent.pairs=e,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,h.reset(this),t=0,bt=e.length;t!==bt;t+=2)for(var at=e[t],vt=e[t+1],yt=0,ri=at.shapes.length;yt!==ri;yt++)for(var rt=at.shapes[yt],ui=rt.position,fi=rt.angle,y=0,ei=vt.shapes.length;y!==ei;y++){var ut=vt.shapes[y],oi=ut.position,si=ut.angle,kt=this.defaultContactMaterial;rt.material&&ut.material&&(pt=this.getContactMaterial(rt.material,ut.material),pt&&(kt=pt));this.runNarrowphase(h,at,rt,ui,fi,vt,ut,oi,si,kt,this.frictionGravity)}for(t=0;t!==a;t++)(ot=l[t])._wakeUpAfterNarrowphase&&(ot.wakeUp(),ot._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){for(this.overlapKeeper.getEndOverlaps(s),nt=this.endContactEvent,y=s.length;y--;)ft=s[y],nt.shapeA=ft.shapeA,nt.shapeB=ft.shapeB,nt.bodyA=ft.bodyA,nt.bodyB=ft.bodyB,this.emit(nt);s.length=0}for(tt=this.preSolveEvent,tt.contactEquations=h.contactEquations,tt.frictionEquations=h.frictionEquations,this.emit(tt),tt.contactEquations=tt.frictionEquations=null,p=d.length,t=0;t!==p;t++)d[t].update();if(h.contactEquations.length||h.frictionEquations.length||p)if(this.islandSplit){for(v.equations.length=0,f.appendArray(v.equations,h.contactEquations),f.appendArray(v.equations,h.frictionEquations),t=0;t!==p;t++)f.appendArray(v.equations,d[t].equations);for(v.split(this),t=0;t!==v.islands.length;t++)(st=v.islands[t]).equations.length&&k.solveIsland(n,st)}else{for(k.addEquations(h.contactEquations),k.addEquations(h.frictionEquations),t=0;t!==p;t++)k.addEquations(d[t].equations);this.solveConstraints&&k.solve(n,this);k.removeAllEquations()}for(t=0;t!==a;t++)ot=l[t],ot.integrate(n);for(t=0;t!==a;t++)l[t].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(w=this.impactEvent,t=0;t!==h.contactEquations.length;t++)b=h.contactEquations[t],b.firstImpact&&(w.bodyA=b.bodyA,w.bodyB=b.bodyB,w.shapeA=b.shapeA,w.shapeB=b.shapeB,w.contactEquation=b,this.emit(w));if(this.sleepMode===r.BODY_SLEEPING)for(t=0;t!==a;t++)l[t].sleepTick(this.time,!1,n);else if(this.sleepMode===r.ISLAND_SLEEPING&&this.islandSplit){for(t=0;t!==a;t++)l[t].sleepTick(this.time,!0,n);for(t=0;t<this.islandManager.islands.length;t++)st=this.islandManager.islands[t],st.wantsToSleep()&&st.sleep()}for(this.stepping=!1,ht=this.bodiesToBeRemoved,t=0;t!==ht.length;t++)this.removeBody(ht[t]);ht.length=0;this.emit(this.postStepEvent)};r.prototype.runNarrowphase=function(n,t,r,f,s,h,c,l,a,v,y){var g,nt,rt,k,b,tt,ut,d,p,w,it;if(0!=(r.collisionGroup&c.collisionMask)&&0!=(c.collisionGroup&r.collisionMask)&&(i.rotate(e,f,t.angle),i.rotate(o,l,h.angle),i.add(e,e,t.position),i.add(o,o,h.position),g=s+t.angle,nt=a+h.angle,n.enableFriction=v.friction>0,n.frictionCoefficient=v.friction,rt=t.type===u.STATIC||t.type===u.KINEMATIC?h.mass:h.type===u.STATIC||h.type===u.KINEMATIC?t.mass:t.mass*h.mass/(t.mass+h.mass),n.slipForce=v.friction*y*rt,n.restitution=v.restitution,n.surfaceVelocity=v.surfaceVelocity,n.frictionStiffness=v.frictionStiffness,n.frictionRelaxation=v.frictionRelaxation,n.stiffness=v.stiffness,n.relaxation=v.relaxation,n.contactSkinSize=v.contactSkinSize,n.enabledEquations=t.collisionResponse&&h.collisionResponse&&r.collisionResponse&&c.collisionResponse,k=n[r.type|c.type],b=0,k&&(tt=r.sensor||c.sensor,ut=n.frictionEquations.length,b=r.type<c.type?k.call(n,t,r,e,g,h,c,o,nt,tt):k.call(n,h,c,o,nt,t,r,e,g,tt),d=n.frictionEquations.length-ut,b))){if(t.allowSleep&&t.type===u.DYNAMIC&&t.sleepState===u.SLEEPING&&h.sleepState===u.AWAKE&&h.type!==u.STATIC&&i.squaredLength(h.velocity)+Math.pow(h.angularVelocity,2)>=2*Math.pow(h.sleepSpeedLimit,2)&&(t._wakeUpAfterNarrowphase=!0),h.allowSleep&&h.type===u.DYNAMIC&&h.sleepState===u.SLEEPING&&t.sleepState===u.AWAKE&&t.type!==u.STATIC&&i.squaredLength(t.velocity)+Math.pow(t.angularVelocity,2)>=2*Math.pow(t.sleepSpeedLimit,2)&&(h._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(t,r,h,c),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(r,c)){if(p=this.beginContactEvent,p.shapeA=r,p.shapeB=c,p.bodyA=t,p.bodyB=h,p.contactEquations.length=0,"number"==typeof b)for(w=n.contactEquations.length-b;w<n.contactEquations.length;w++)p.contactEquations.push(n.contactEquations[w]);this.emit(p)}if("number"==typeof b&&d>1)for(w=n.frictionEquations.length-d;w<n.frictionEquations.length;w++)it=n.frictionEquations[w],it.setSlipForce(it.getSlipForce()/d)}};r.prototype.addSpring=function(n){this.springs.push(n);var t=this.addSpringEvent;t.spring=n;this.emit(t);t.spring=null};r.prototype.removeSpring=function(n){var t=this.springs.indexOf(n);-1!==t&&f.splice(this.springs,t,1)};r.prototype.addBody=function(n){if(-1===this.bodies.indexOf(n)){this.bodies.push(n);n.world=this;var t=this.addBodyEvent;t.body=n;this.emit(t);t.body=null}};r.prototype.removeBody=function(n){if(this.stepping)this.bodiesToBeRemoved.push(n);else{n.world=null;var t=this.bodies.indexOf(n);-1!==t&&(f.splice(this.bodies,t,1),this.removeBodyEvent.body=n,n.resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}};r.prototype.getBodyById=function(n){for(var r,i=this.bodies,t=0;t<i.length;t++)if(r=i[t],r.id===n)return r;return!1};r.prototype.disableBodyCollision=function(n,t){this.disabledBodyCollisionPairs.push(n,t)};r.prototype.enableBodyCollision=function(n,t){for(var r=this.disabledBodyCollisionPairs,i=0;i<r.length;i+=2)if(r[i]===n&&r[i+1]===t||r[i+1]===n&&r[i]===t)return void r.splice(i,2)};r.prototype.clear=function(){var t,i,u,f,n;for(this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations(),t=this.constraints,n=t.length-1;n>=0;n--)this.removeConstraint(t[n]);for(i=this.bodies,n=i.length-1;n>=0;n--)this.removeBody(i[n]);for(u=this.springs,n=u.length-1;n>=0;n--)this.removeSpring(u[n]);for(f=this.contactMaterials,n=f.length-1;n>=0;n--)this.removeContactMaterial(f[n]);r.apply(this)};v=i.create();y=(i.fromValues(0,0),i.fromValues(0,0));r.prototype.hitTest=function(n,t,r){var f,c;r=r||0;var s=new u({position:n}),h=new l,a=n,o=v,it=y;s.addShape(h);for(var p=this.narrowphase,tt=[],g=0,rt=t.length;g!==rt;g++)for(var e=t[g],nt=0,ut=e.shapes.length;nt!==ut;nt++)f=e.shapes[nt],i.rotate(o,f.position,e.angle),i.add(o,o,e.position),c=f.angle+e.angle,(f instanceof w&&p.circleParticle(e,f,o,c,s,h,a,0,!0)||f instanceof b&&p.particleConvex(s,h,a,0,e,f,o,c,!0)||f instanceof k&&p.particlePlane(s,h,a,0,e,f,o,c,!0)||f instanceof d&&p.particleCapsule(s,h,a,0,e,f,o,c,!0)||f instanceof l&&i.squaredLength(i.sub(it,o,n))<r*r)&&tt.push(e);return tt};r.prototype.setGlobalStiffness=function(n){for(var i,r,f,e,u=this.constraints,t=0;t!==u.length;t++)for(i=u[t],r=0;r!==i.equations.length;r++)f=i.equations[r],f.stiffness=n,f.needsUpdate=!0;for(e=this.contactMaterials,t=0;t!==e.length;t++)(i=e[t]).stiffness=i.frictionStiffness=n;(i=this.defaultContactMaterial).stiffness=i.frictionStiffness=n};r.prototype.setGlobalRelaxation=function(n){for(var i,r,u,t=0;t!==this.constraints.length;t++)for(i=this.constraints[t],r=0;r!==i.equations.length;r++)u=i.equations[r],u.relaxation=n,u.needsUpdate=!0;for(t=0;t!==this.contactMaterials.length;t++)(i=this.contactMaterials[t]).relaxation=i.frictionRelaxation=n;(i=this.defaultContactMaterial).relaxation=i.frictionRelaxation=n};c=new tt;h=[];r.prototype.raycast=function(n,t){return t.getAABB(c),this.broadphase.aabbQuery(this,c,h),t.intersectBodies(n,h),h.length=0,n.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){function r(t,i,r,u){var f=t.createTexture();return t.bindTexture(t.TEXTURE_2D,f),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,u===n.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,u===n.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i,r,0,t.RGBA,t.UNSIGNED_BYTE,null),f}function u(n,t,u,f,e){var o=n.createFramebuffer(),h=n.createRenderbuffer(),s=null,c=0;return n.activeTexture(n.TEXTURE0+e),n.bindFramebuffer(n.FRAMEBUFFER,o),n.bindRenderbuffer(n.RENDERBUFFER,h),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,this.renderBuffer),s=r(n,t,u,f),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,s,0),(c=n.checkFramebufferStatus(n.FRAMEBUFFER))!==n.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",i[c]),o.width=t,o.height=u,o.targetTexture=s,o.renderBuffer=h,o}var t=this,n=n||{},i;return n.DisplayObject=function(){this.position=new n.Point(0,0);this.scale=new n.Point(1,1);this.pivot=new n.Point(0,0);this.rotation=0;this.alpha=1;this.visible=!0;this.hitArea=null;this.renderable=!1;this.parent=null;this.worldAlpha=1;this.worldTransform=new Phaser.Matrix;this.worldPosition=new n.Point(0,0);this.worldScale=new n.Point(1,1);this.worldRotation=0;this.filterArea=null;this._sr=0;this._cr=1;this._bounds=new n.Rectangle(0,0,0,0);this._currentBounds=null;this._mask=null;this._cacheAsBitmap=!1;this._cacheIsDirty=!1},n.DisplayObject.prototype={constructor:n.DisplayObject,destroy:function(){if(this.children){for(var n=this.children.length;n--;)this.children[n].destroy();this.children=[]}this.hitArea=null;this.parent=null;this.worldTransform=null;this.filterArea=null;this.renderable=!1;this._bounds=null;this._currentBounds=null;this._mask=null;this._destroyCachedSprite()},updateTransform:function(n){var h,r,e,f,u,o,s,t,i,a,c,l;return!n&&!this.parent&&!this.game?this:(h=this.parent,n?h=n:this.parent||(h=this.game.world),t=h.worldTransform,i=this.worldTransform,this.rotation%Phaser.Math.PI2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),r=this._cr*this.scale.x,e=this._sr*this.scale.x,f=-this._sr*this.scale.y,u=this._cr*this.scale.y,o=this.position.x,s=this.position.y,(this.pivot.x||this.pivot.y)&&(o-=this.pivot.x*r+this.pivot.y*f,s-=this.pivot.x*e+this.pivot.y*u),i.a=r*t.a+e*t.c,i.b=r*t.b+e*t.d,i.c=f*t.a+u*t.c,i.d=f*t.b+u*t.d,i.tx=o*t.a+s*t.c+t.tx,i.ty=o*t.b+s*t.d+t.ty):(r=this.scale.x,e=0,f=0,u=this.scale.y,o=this.position.x-this.pivot.x*r,s=this.position.y-this.pivot.y*u,i.a=r*t.a,i.b=r*t.b,i.c=u*t.c,i.d=u*t.d,i.tx=o*t.a+s*t.c+t.tx,i.ty=o*t.b+s*t.d+t.ty),r=i.a,e=i.b,f=i.c,a=r*(u=i.d)-e*f,r||e?(c=Math.sqrt(r*r+e*e),this.worldRotation=e>0?Math.acos(r/c):-Math.acos(r/c),this.worldScale.x=c,this.worldScale.y=a/c):f||u?(l=Math.sqrt(f*f+u*u),this.worldRotation=Phaser.Math.HALF_PI-(u>0?Math.acos(-f/l):-Math.acos(f/l)),this.worldScale.x=a/l,this.worldScale.y=l):(this.worldScale.x=0,this.worldScale.y=0),this.worldAlpha=this.alpha*h.worldAlpha,this.worldPosition.x=i.tx,this.worldPosition.y=i.ty,this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,i,t),this)},preUpdate:function(){},generateTexture:function(t,i,r){var u=this.getLocalBounds(),f=new Phaser.RenderTexture(this.game,0|u.width,0|u.height,r,i,t);return n.DisplayObject._tempMatrix.tx=-u.x,n.DisplayObject._tempMatrix.ty=-u.y,f.render(this,n.DisplayObject._tempMatrix),f},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(n){return this.updateTransform(),this.worldTransform.apply(n)},toLocal:function(n,t){return t&&(n=t.toGlobal(n)),this.updateTransform(),this.worldTransform.applyInverse(n)},_renderCachedSprite:function(t){this._cachedSprite.worldAlpha=this.worldAlpha;t.gl?n.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):n.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},_generateCachedSprite:function(){var t,i,u,r;this._cacheAsBitmap=!1;t=this.getLocalBounds();(t.width=Math.max(1,Math.ceil(t.width)),t.height=Math.max(1,Math.ceil(t.height)),this.updateTransform(),this._cachedSprite)?this._cachedSprite.texture.resize(t.width,t.height):(i=0,this.texture&&this.texture.baseTexture&&n._enableMultiTextureToggle&&(i=this.texture.baseTexture.textureIndex),u=new Phaser.RenderTexture(this.game,t.width,t.height,void 0,void 0,void 0,void 0,i),this._cachedSprite=new n.Sprite(u),this._cachedSprite.worldTransform=this.worldTransform);r=this._filters;this._filters=null;this._cachedSprite.filters=r;n.DisplayObject._tempMatrix.tx=-t.x;n.DisplayObject._tempMatrix.ty=-t.y;this._cachedSprite.texture.render(this,n.DisplayObject._tempMatrix,!0);this._cachedSprite.anchor.x=-t.x/t.width;this._cachedSprite.anchor.y=-t.y/t.height;this._filters=r;this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},n.DisplayObject.prototype.displayObjectUpdateTransform=n.DisplayObject.prototype.updateTransform,Object.defineProperties(n.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(n){this.position.x=n}},y:{get:function(){return this.position.y},set:function(n){this.position.y=n}},worldVisible:{get:function(){if(this.visible){var n=this.parent;if(!n)return this.visible;do{if(!n.visible)return!1;n=n.parent}while(n);return!0}return!1}},mask:{get:function(){return this._mask},set:function(n){this._mask&&(this._mask.isMask=!1);this._mask=n;n&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(t){var u,i,f,r;if(Array.isArray(t)){for(u=[],i=0;i<t.length;i++)for(f=t[i].passes,r=0;r<f.length;r++)u.push(f[r]);this._filterBlock={target:this,filterPasses:u}}this._filters=t;this.blendMode&&this.blendMode===n.blendModes.MULTIPLY&&(this.blendMode=n.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(n){this._cacheAsBitmap!==n&&(n?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=n)}}}),n.DisplayObjectContainer=function(){n.DisplayObject.call(this);this.children=[];this.ignoreChildInput=!1},n.DisplayObjectContainer.prototype=Object.create(n.DisplayObject.prototype),n.DisplayObjectContainer.prototype.constructor=n.DisplayObjectContainer,n.DisplayObjectContainer.prototype.addChild=function(n){return this.addChildAt(n,this.children.length)},n.DisplayObjectContainer.prototype.addChildAt=function(n,t){if(t>=0&&t<=this.children.length)return n.parent&&n.parent.removeChild(n),n.parent=this,this.children.splice(t,0,n),n;throw new Error(n+"addChildAt: The index "+t+" supplied is out of bounds "+this.children.length);},n.DisplayObjectContainer.prototype.swapChildren=function(n,t){if(n!==t){var i=this.getChildIndex(n),r=this.getChildIndex(t);if(i<0||r<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=t;this.children[r]=n}},n.DisplayObjectContainer.prototype.getChildIndex=function(n){var t=this.children.indexOf(n);if(-1===t)throw new Error("The supplied DisplayObject must be a child of the caller");return t},n.DisplayObjectContainer.prototype.setChildIndex=function(n,t){if(t<0||t>=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(n);this.children.splice(i,1);this.children.splice(t,0,n)},n.DisplayObjectContainer.prototype.getChildAt=function(n){if(n<0||n>=this.children.length)throw new Error("getChildAt: Supplied index "+n+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[n]},n.DisplayObjectContainer.prototype.removeChild=function(n){var t=this.children.indexOf(n);if(-1!==t)return this.removeChildAt(t)},n.DisplayObjectContainer.prototype.removeChildAt=function(n){var t=this.getChildAt(n);return t&&(t.parent=void 0,this.children.splice(n,1)),t},n.DisplayObjectContainer.prototype.bringChildToTop=function(n){if(n.parent===this)return this.setChildIndex(n,this.children.length-1)},n.DisplayObjectContainer.prototype.sendChildToBack=function(n){if(n.parent===this)return this.setChildIndex(n,0)},n.DisplayObjectContainer.prototype.removeChildren=function(n,t){var i,r,u;if(void 0===n&&(n=0),void 0===t&&(t=this.children.length),i=t-n,i>0&&i<=t){for(r=this.children.splice(n,i),u=0;u<r.length;u++)r[u].parent=void 0;return r}if(0===i&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range");},n.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var n=0;n<this.children.length;n++)this.children[n].updateTransform()},n.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=n.DisplayObjectContainer.prototype.updateTransform,n.DisplayObjectContainer.prototype.getBounds=function(t){var ft=t&&t instanceof n.DisplayObject,ht=!0,r,ct,i,st;if(ft?ht=t instanceof n.DisplayObjectContainer&&t.contains(this):t=this,ft)for(ct=t.worldTransform,t.worldTransform=Phaser.identityMatrix,r=0;r<t.children.length;r++)t.children[r].updateTransform();var s,et,ot,f=1/0,u=1/0,e=-1/0,o=-1/0,lt=!1;for(r=0;r<this.children.length;r++)this.children[r].visible&&(lt=!0,f=f<(s=this.children[r].getBounds()).x?f:s.x,u=u<s.y?u:s.y,et=s.width+s.x,ot=s.height+s.y,e=e>et?e:et,o=o>ot?o:ot);if(i=this._bounds,!lt){var c=(i=new n.Rectangle).x,l=i.width+i.x,a=i.y,v=i.height+i.y,h=this.worldTransform,y=h.a,p=h.b,w=h.c,b=h.d,k=h.tx,d=h.ty,at=y*l+w*v+k,vt=b*v+p*l+d,g=y*c+w*v+k,nt=b*v+p*c+d,tt=y*c+w*a+k,it=b*a+p*c+d,rt=y*l+w*a+k,ut=b*a+p*l+d;e=at;o=vt;u=vt;f=rt<(f=tt<(f=g<(f=at)?g:f)?tt:f)?rt:f;u=ut<(u=it<(u=nt<u?nt:u)?it:u)?ut:u;e=rt>(e=tt>(e=g>e?g:e)?tt:e)?rt:e;o=ut>(o=it>(o=nt>o?nt:o)?it:o)?ut:o}if(i.x=f,i.y=u,i.width=e-f,i.height=o-u,ft)for(t.worldTransform=ct,r=0;r<t.children.length;r++)t.children[r].updateTransform();return ht||(st=t.getBounds(),i.x-=st.x,i.y-=st.y),i},n.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},n.DisplayObjectContainer.prototype.contains=function(n){return!!n&&(n===this||this.contains(n.parent))},n.DisplayObjectContainer.prototype._renderWebGL=function(n){if(this.visible&&!(this.alpha<=0))if(this._cacheAsBitmap)this._renderCachedSprite(n);else{var t;if(this._mask||this._filters){for(this._filters&&(n.spriteBatch.flush(),n.filterManager.pushFilter(this._filterBlock)),this._mask&&(n.spriteBatch.stop(),n.maskManager.pushMask(this.mask,n),n.spriteBatch.start()),t=0;t<this.children.length;t++)this.children[t]._renderWebGL(n);n.spriteBatch.stop();this._mask&&n.maskManager.popMask(this._mask,n);this._filters&&n.filterManager.popFilter();n.spriteBatch.start()}else for(t=0;t<this.children.length;t++)this.children[t]._renderWebGL(n)}},n.DisplayObjectContainer.prototype._renderCanvas=function(n){if(!1!==this.visible&&0!==this.alpha)if(this._cacheAsBitmap)this._renderCachedSprite(n);else{this._mask&&n.maskManager.pushMask(this._mask,n);for(var t=0;t<this.children.length;t++)this.children[t]._renderCanvas(n);this._mask&&n.maskManager.popMask(n)}},Object.defineProperty(n.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(n){var t=this.getLocalBounds().width;this.scale.x=0!==t?n/t:1;this._width=n}}),Object.defineProperty(n.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(n){var t=this.getLocalBounds().height;this.scale.y=0!==t?n/t:1;this._height=n}}),n.Sprite=function(t){n.DisplayObjectContainer.call(this);this.anchor=new n.Point(n.Sprite.defaultAnchor.x,n.Sprite.defaultAnchor.y);this.texture=t||n.Texture.emptyTexture;this._width=0;this._height=0;this.tint=16777215;this.cachedTint=-1;this.tintedTexture=null;this.blendMode=n.blendModes.NORMAL;this.shader=null;this.exists=!0;this.texture.baseTexture.hasLoaded&&this.onTextureUpdate();this.renderable=!0},n.Sprite.defaultAnchor={x:0,y:0},n.Sprite.prototype=Object.create(n.DisplayObjectContainer.prototype),n.Sprite.prototype.constructor=n.Sprite,Object.defineProperty(n.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(n){this.scale.x=n/this.texture.frame.width;this._width=n}}),Object.defineProperty(n.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(n){this.scale.y=n/this.texture.frame.height;this._height=n}}),n.Sprite.prototype.setTexture=function(n,t){t&&this.texture.baseTexture.destroy();this.texture.baseTexture.skipRender=!1;this.texture=n;this.texture.valid=!0;this.cachedTint=-1},n.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width);this._height&&(this.scale.y=this._height/this.texture.frame.height)},n.Sprite.prototype.getBounds=function(n){var ft=this.texture.frame.width,et=this.texture.frame.height,o=ft*(1-this.anchor.x),s=ft*-this.anchor.x,h=et*(1-this.anchor.y),c=et*-this.anchor.y,a=n||this.worldTransform,f=a.a,p=a.b,w=a.c,e=a.d,v=a.tx,y=a.ty,r=-1/0,u=-1/0,t=1/0,i=1/0,b,l;if(0===p&&0===w)f<0&&(f*=-1,b=o,o=-s,s=-b),e<0&&(e*=-1,b=h,h=-c,c=-b),t=f*s+v,r=f*o+v,i=e*c+y,u=e*h+y;else{var k=f*s+w*c+v,d=e*c+p*s+y,g=f*o+w*c+v,nt=e*c+p*o+y,tt=f*o+w*h+v,it=e*h+p*o+y,rt=f*s+w*h+v,ut=e*h+p*s+y;t=rt<(t=tt<(t=g<(t=k<t?k:t)?g:t)?tt:t)?rt:t;i=ut<(i=it<(i=nt<(i=d<i?d:i)?nt:i)?it:i)?ut:i;r=rt>(r=tt>(r=g>(r=k>r?k:r)?g:r)?tt:r)?rt:r;u=ut>(u=it>(u=nt>(u=d>u?d:u)?nt:u)?it:u)?ut:u}return l=this._bounds,l.x=t,l.width=r-t,l.y=i,l.height=u-i,this._currentBounds=l,l},n.Sprite.prototype.getLocalBounds=function(){var i=this.worldTransform,n,t;for(this.worldTransform=Phaser.identityMatrix,n=0;n<this.children.length;n++)this.children[n].updateTransform();for(t=this.getBounds(),this.worldTransform=i,n=0;n<this.children.length;n++)this.children[n].updateTransform();return t},n.Sprite.prototype._renderWebGL=function(n,t){var u,r,i;if(this.visible&&!(this.alpha<=0)&&this.renderable)if(u=this.worldTransform,t&&(u=t),this._mask||this._filters){for(r=n.spriteBatch,this._filters&&(r.flush(),n.filterManager.pushFilter(this._filterBlock)),this._mask&&(r.stop(),n.maskManager.pushMask(this.mask,n),r.start()),r.render(this),i=0;i<this.children.length;i++)this.children[i]._renderWebGL(n);r.stop();this._mask&&n.maskManager.popMask(this._mask,n);this._filters&&n.filterManager.popFilter();r.start()}else for(n.spriteBatch.render(this),i=0;i<this.children.length;i++)this.children[i]._renderWebGL(n,u)},n.Sprite.prototype._renderCanvas=function(t,i){var r,o,w,b,e;if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<1||this.texture.crop.height<1))if(r=this.worldTransform,i&&(r=i),this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=n.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t),this.texture.valid){o=this.texture.baseTexture.resolution/t.resolution;t.context.globalAlpha=this.worldAlpha;t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===n.scaleModes.LINEAR);var s=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,h=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,c=r.tx*t.resolution+t.shakeX,l=r.ty*t.resolution+t.shakeY,f=this.texture.crop.width,u=this.texture.crop.height;if(this.texture.rotated){var a=r.a,v=r.b,y=r.c,p=r.d,k=f;c=r.c*u+c;l=r.d*u+l;r.a=6123233995736766e-32*a-y;r.b=6123233995736766e-32*v-p;r.c=a+6123233995736766e-32*y;r.d=v+6123233995736766e-32*p;f=u;u=k}if(t.roundPixels?(t.context.setTransform(r.a,r.b,r.c,r.d,0|c,0|l),s|=0,h|=0):t.context.setTransform(r.a,r.b,r.c,r.d,c,l),s/=o,h/=o,f|=0,u|=0,f&&u){for(16777215!==this.tint?((this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=n.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),t.context.drawImage(this.tintedTexture,0,0,f,u,s,h,f/o,u/o)):(w=this.texture.crop.x,b=this.texture.crop.y,t.context.drawImage(this.texture.baseTexture.source,w,b,f,u,s,h,f/o,u/o)),e=0;e<this.children.length;e++)this.children[e]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}else{for(e=0;e<this.children.length;e++)this.children[e]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},n.initDefaultShaders=function(){},n.CompileVertexShader=function(t,i){return n._CompileShader(t,i,t.VERTEX_SHADER)},n.CompileFragmentShader=function(t,i){return n._CompileShader(t,i,t.FRAGMENT_SHADER)},n._CompileShader=function(n,t,i){var u=t,r;return Array.isArray(t)&&(u=t.join("\n")),r=n.createShader(i),n.shaderSource(r,u),n.compileShader(r),n.getShaderParameter(r,n.COMPILE_STATUS)?r:(window.console.log(n.getShaderInfoLog(r)),null)},n.compileProgram=function(t,i,r){var f=n.CompileFragmentShader(t,r),e=n.CompileVertexShader(t,i),u=t.createProgram();return t.attachShader(u,e),t.attachShader(u,f),t.linkProgram(u),t.getProgramParameter(u,t.LINK_STATUS)||(window.console.log(t.getProgramInfoLog(u)),window.console.log("Could not initialise shaders")),u},n.PixiShader=function(n){this._UID=Phaser._UID++;this.gl=n;this.program=null;this.fragmentSrc=null;this.textureCount=0;this.firstRun=!0;this.dirty=!0;this.attributes=[];this.init()},n.PixiShader.prototype.constructor=n.PixiShader,n.PixiShader.prototype.initMultitexShader=function(){var t=this.gl,f,r,i,e,o,u,s;for(this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),f="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",r=1;r<this.MAX_TEXTURES;++r)f+="\tif (vTextureIndex == "+r+".0) {gl_FragColor = texture2D(uSamplerArray["+r+"], vTextureCoord) * vColor;return;}\n";for(this.fragmentSrc=["// PixiShader Fragment Shader.","precision lowp float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",f,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"],i=n.compileProgram(t,this.vertexSrc||n.PixiShader.defaultVertexSrc,this.fragmentSrc),t.useProgram(i),this.uSamplerArray=t.getUniformLocation(i,"uSamplerArray[0]"),this.projectionVector=t.getUniformLocation(i,"projectionVector"),this.offsetVector=t.getUniformLocation(i,"offsetVector"),this.dimensions=t.getUniformLocation(i,"dimensions"),this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(i,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(i,"aColor"),this.aTextureIndex=t.getAttribLocation(i,"aTextureIndex"),e=[],o=t.createTexture(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null),u=0;u<this.MAX_TEXTURES;++u)t.activeTexture(t.TEXTURE0+u),t.bindTexture(t.TEXTURE_2D,o),e.push(u);t.activeTexture(t.TEXTURE0);t.uniform1iv(this.uSamplerArray,e);-1===this.colorAttribute&&(this.colorAttribute=2);this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(s in this.uniforms)this.uniforms[s].uniformLocation=t.getUniformLocation(i,s);this.initUniforms();this.program=i},n.PixiShader.prototype.initDefaultShader=function(){var t,i,r;null===this.fragmentSrc&&(this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"]);t=this.gl;i=n.compileProgram(t,this.vertexSrc||n.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(i);this.uSampler=t.getUniformLocation(i,"uSampler");this.projectionVector=t.getUniformLocation(i,"projectionVector");this.offsetVector=t.getUniformLocation(i,"offsetVector");this.dimensions=t.getUniformLocation(i,"dimensions");this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition");this.aTextureCoord=t.getAttribLocation(i,"aTextureCoord");this.colorAttribute=t.getAttribLocation(i,"aColor");this.aTextureIndex=t.getAttribLocation(i,"aTextureIndex");-1===this.colorAttribute&&(this.colorAttribute=2);this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(r in this.uniforms)this.uniforms[r].uniformLocation=t.getUniformLocation(i,r);this.initUniforms();this.program=i},n.PixiShader.prototype.init=function(t){n._enableMultiTextureToggle&&!t?this.initMultitexShader():this.initDefaultShader()},n.PixiShader.prototype.initUniforms=function(){var t,i,r,n;this.textureCount=1;i=this.gl;for(r in this.uniforms)n=(t=this.uniforms[r]).type,"sampler2D"===n?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===n||"mat3"===n||"mat4"===n?(t.glMatrix=!0,t.glValueLength=1,"mat2"===n?t.glFunc=i.uniformMatrix2fv:"mat3"===n?t.glFunc=i.uniformMatrix3fv:"mat4"===n&&(t.glFunc=i.uniformMatrix4fv)):(t.glFunc=i["uniform"+n],t.glValueLength="2f"===n||"2i"===n?2:"3f"===n||"3i"===n?3:"4f"===n||"4i"===n?4:1)},n.PixiShader.prototype.initSampler2D=function(n){var t;if(n.value&&n.value.baseTexture&&n.value.baseTexture.hasLoaded){if(t=this.gl,t.activeTexture(t.TEXTURE0+this.textureCount),t.bindTexture(t.TEXTURE_2D,n.value.baseTexture._glTextures[t.id]),n.textureData){var i=n.textureData,e=i.magFilter?i.magFilter:t.LINEAR,o=i.minFilter?i.minFilter:t.LINEAR,u=i.wrapS?i.wrapS:t.CLAMP_TO_EDGE,f=i.wrapT?i.wrapT:t.CLAMP_TO_EDGE,r=i.luminance?t.LUMINANCE:t.RGBA;if(i.repeat&&(u=t.REPEAT,f=t.REPEAT),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var s=i.width?i.width:512,h=i.height?i.height:2,c=i.border?i.border:0;t.texImage2D(t.TEXTURE_2D,0,r,s,h,c,r,t.UNSIGNED_BYTE,null)}else t.texImage2D(t.TEXTURE_2D,0,r,t.RGBA,t.UNSIGNED_BYTE,n.value.baseTexture.source);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,o);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,u);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,f)}t.uniform1i(n.uniformLocation,this.textureCount);n._init=!0;this.textureCount++}},n.PixiShader.prototype.syncUniforms=function(){var t,i,r;this.textureCount=1;i=this.gl;for(r in this.uniforms)1===(t=this.uniforms[r]).glValueLength?!0===t.glMatrix?t.glFunc.call(i,t.uniformLocation,t.transpose,t.value):t.glFunc.call(i,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(i,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(i,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(i,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(i.activeTexture(i["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[i.id]?n.instances[i.id].updateTexture(t.value.baseTexture):i.bindTexture(i.TEXTURE_2D,t.value.baseTexture._glTextures[i.id]),i.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},n.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.uniforms=null;this.gl=null;this.attributes=null},n.PixiShader.defaultVertexSrc=["// PixiShader Vertex Shader","// With multi-texture rendering","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   if (aTextureIndex > 0.0) gl_Position = vec4(0.0);","   gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vColor = vec4(aColor.rgb * aColor.a, aColor.a);","   vTextureIndex = aTextureIndex;","}"],n.PixiFastShader=function(t){var t,r,i;if(this._UID=Phaser._UID++,this.gl=t,this.program=null,n._enableMultiTextureToggle){for(t=this.gl,this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),r="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)r+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",r,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   vec2 v;","   vec2 sv = aVertexPosition * aScale;","   v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);","   v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);","   v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;","   gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vTextureIndex = aTextureIndex;","   vColor = aColor;","}"];this.textureCount=0;this.init()},n.PixiFastShader.prototype.constructor=n.PixiFastShader,n.PixiFastShader.prototype.init=function(){var t=this.gl,i=n.compileProgram(t,this.vertexSrc,this.fragmentSrc),u,f,r;if(t.useProgram(i),this.uSampler=n._enableMultiTextureToggle?t.getUniformLocation(i,"uSamplerArray[0]"):t.getUniformLocation(i,"uSampler"),n._enableMultiTextureToggle){for(u=[],f=t.createTexture(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,f),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null),r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,f),u.push(r);t.activeTexture(t.TEXTURE0);t.uniform1iv(this.uSampler,u)}this.projectionVector=t.getUniformLocation(i,"projectionVector");this.offsetVector=t.getUniformLocation(i,"offsetVector");this.dimensions=t.getUniformLocation(i,"dimensions");this.uMatrix=t.getUniformLocation(i,"uMatrix");this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition");this.aPositionCoord=t.getAttribLocation(i,"aPositionCoord");this.aScale=t.getAttribLocation(i,"aScale");this.aRotation=t.getAttribLocation(i,"aRotation");this.aTextureCoord=t.getAttribLocation(i,"aTextureCoord");this.colorAttribute=t.getAttribLocation(i,"aColor");this.aTextureIndex=t.getAttribLocation(i,"aTextureIndex");-1===this.colorAttribute&&(this.colorAttribute=2);this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];this.program=i},n.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.uniforms=null;this.gl=null;this.attributes=null},n.StripShader=function(t){var t,r,i;if(this._UID=Phaser._UID++,this.gl=t,this.program=null,n._enableMultiTextureToggle){for(t=this.gl,this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),r="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord);return;}\n",i=1;i<this.MAX_TEXTURES;++i)r+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) ;return;}\n";this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","bool isnan( float val ) {  return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",r,"   if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}","   if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vTextureIndex;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vTextureIndex = aTextureIndex;","}"];this.init()},n.StripShader.prototype.constructor=n.StripShader,n.StripShader.prototype.init=function(){var t=this.gl,i=n.compileProgram(t,this.vertexSrc,this.fragmentSrc),u,f,r;if(t.useProgram(i),this.uSampler=n._enableMultiTextureToggle?t.getUniformLocation(i,"uSamplerArray[0]"):t.getUniformLocation(i,"uSampler"),n._enableMultiTextureToggle){for(u=[],f=t.createTexture(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,f),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null),r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,f),u.push(r);t.activeTexture(t.TEXTURE0);t.uniform1iv(this.uSampler,u)}this.projectionVector=t.getUniformLocation(i,"projectionVector");this.offsetVector=t.getUniformLocation(i,"offsetVector");this.colorAttribute=t.getAttribLocation(i,"aColor");this.aTextureIndex=t.getAttribLocation(i,"aTextureIndex");this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition");this.aTextureCoord=t.getAttribLocation(i,"aTextureCoord");this.attributes=[this.aVertexPosition,this.aTextureCoord,this.aTextureIndex];this.translationMatrix=t.getUniformLocation(i,"translationMatrix");this.alpha=t.getUniformLocation(i,"alpha");this.program=i},n.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.uniforms=null;this.gl=null;this.attribute=null},n.PrimitiveShader=function(n){this._UID=Phaser._UID++;this.gl=n;this.program=null;this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"];this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);","   vColor = aColor * vec4(tint * alpha, alpha);","}"];this.init()},n.PrimitiveShader.prototype.constructor=n.PrimitiveShader,n.PrimitiveShader.prototype.init=function(){var t=this.gl,i=n.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(i);this.projectionVector=t.getUniformLocation(i,"projectionVector");this.offsetVector=t.getUniformLocation(i,"offsetVector");this.tintColor=t.getUniformLocation(i,"tint");this.flipY=t.getUniformLocation(i,"flipY");this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition");this.colorAttribute=t.getAttribLocation(i,"aColor");this.attributes=[this.aVertexPosition,this.colorAttribute];this.translationMatrix=t.getUniformLocation(i,"translationMatrix");this.alpha=t.getUniformLocation(i,"alpha");this.program=i},n.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.uniforms=null;this.gl=null;this.attributes=null},n.ComplexPrimitiveShader=function(n){this._UID=Phaser._UID++;this.gl=n;this.program=null;this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"];this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);","   vColor = vec4(color * alpha * tint, alpha);","}"];this.init()},n.ComplexPrimitiveShader.prototype.constructor=n.ComplexPrimitiveShader,n.ComplexPrimitiveShader.prototype.init=function(){var t=this.gl,i=n.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(i);this.projectionVector=t.getUniformLocation(i,"projectionVector");this.offsetVector=t.getUniformLocation(i,"offsetVector");this.tintColor=t.getUniformLocation(i,"tint");this.color=t.getUniformLocation(i,"color");this.flipY=t.getUniformLocation(i,"flipY");this.aVertexPosition=t.getAttribLocation(i,"aVertexPosition");this.attributes=[this.aVertexPosition,this.colorAttribute];this.translationMatrix=t.getUniformLocation(i,"translationMatrix");this.alpha=t.getUniformLocation(i,"alpha");this.program=i},n.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.uniforms=null;this.gl=null;this.attribute=null},n.glContexts=[],n.instances=[],n._enableMultiTextureToggle=!1,n.WebGLRenderer=function(t,i){this.game=t;n.defaultRenderer||(n.defaultRenderer=this);this.extensions={};this.type=Phaser.WEBGL;this.resolution=t.resolution;this.transparent=t.transparent;this.autoResize=!1;this.preserveDrawingBuffer=t.preserveDrawingBuffer;this.clearBeforeRender=t.clearBeforeRender;this.width=t.width;this.height=t.height;this.view=t.canvas;this._contextOptions={alpha:this.transparent,antialias:t.antialias,failIfMajorPerformanceCaveat:i.failIfMajorPerformanceCaveat,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer};this.projection=new n.Point;this.offset=new n.Point;this.shaderManager=new n.WebGLShaderManager;this.spriteBatch=new n.WebGLSpriteBatch(t);this.maskManager=new n.WebGLMaskManager;this.filterManager=new n.WebGLFilterManager;this.stencilManager=new n.WebGLStencilManager;this.blendModeManager=new n.WebGLBlendModeManager;this.renderSession={};this.currentBatchedTextures=[];this.renderSession.game=this.game;this.renderSession.gl=this.gl;this.renderSession.drawCount=0;this.renderSession.shaderManager=this.shaderManager;this.renderSession.maskManager=this.maskManager;this.renderSession.filterManager=this.filterManager;this.renderSession.blendModeManager=this.blendModeManager;this.renderSession.spriteBatch=this.spriteBatch;this.renderSession.stencilManager=this.stencilManager;this.renderSession.renderer=this;this.renderSession.resolution=this.resolution;this.renderSession.roundPixels=i.roundPixels||!1;this.renderSession.maxTextureAvailableSpace=null;this.initContext();this.mapBlendModes()},n.WebGLRenderer.prototype.constructor=n.WebGLRenderer,n.WebGLRenderer.prototype.initContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.maxTextureSize=this.gl.getParameter(t.MAX_TEXTURE_SIZE);this.glContextId=t.id=n.WebGLRenderer.glContextId++;n.glContexts[this.glContextId]=t;n.instances[this.glContextId]=this;t.disable(t.DEPTH_TEST);t.disable(t.CULL_FACE);t.enable(t.BLEND);this.shaderManager.setContext(t);this.spriteBatch.setContext(t);this.maskManager.setContext(t);this.filterManager.setContext(t);this.blendModeManager.setContext(t);this.stencilManager.setContext(t);this.renderSession.gl=this.gl;this.resize(this.width,this.height);this.extensions.compression={};var i=t.getExtension("WEBGL_compressed_texture_etc1")||t.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),u=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");i&&(this.extensions.compression.ETC1=i);r&&(this.extensions.compression.PVRTC=r);u&&(this.extensions.compression.S3TC=u)},n.WebGLRenderer.prototype.setTexturePriority=function(t){var o,r,u;if(n._enableMultiTextureToggle){for(var h=function(n){return--n,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,++n},f=this.gl,c=f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),l=f.getParameter(f.MAX_TEXTURE_SIZE),e=this.game.cache._cache.image,i=null,s=0;s<this.currentBatchedTextures.length;s++)(i=this.currentBatchedTextures[s])in e?e[i].base.textureIndex=0:console.warn('setTexturePriority: There is no image "%s" in the image cache.',i);for(o=l-h(Math.max(this.width,this.height)),this.currentBatchedTextures.length=0,r=0;r<t.length;++r)(i=t[r])in e?(u=e[i].base,(o-=h(Math.max(u.width,u.height)))<=0?(u.textureIndex=0,console.warn('setTexturePriority: Image "%s" was given textureIndex=0 because there is no available texture space (%s).',i,o)):u.textureIndex=1+r%(c-1),this.currentBatchedTextures.push(i)):console.warn('setTexturePriority: There is no image "%s" in the image cache.',i);return this.renderSession.maxTextureAvailableSpace=o,this.currentBatchedTextures}console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.")},n.WebGLRenderer.prototype.render=function(n){if(!this.contextLost){var t=this.gl;t.viewport(0,0,this.width,this.height);t.bindFramebuffer(t.FRAMEBUFFER,null);this.game.clearBeforeRender&&(t.clearColor(n._bgColor.r,n._bgColor.g,n._bgColor.b,n._bgColor.a),t.clear(t.COLOR_BUFFER_BIT));this.offset.x=this.game.camera._shake.x;this.offset.y=this.game.camera._shake.y;this.renderDisplayObject(n,this.projection)}},n.WebGLRenderer.prototype.renderDisplayObject=function(t,i,r,u){this.renderSession.blendModeManager.setBlendMode(n.blendModes.NORMAL);this.renderSession.drawCount=0;this.renderSession.flipY=r?-1:1;this.renderSession.projection=i;this.renderSession.offset=this.offset;this.spriteBatch.begin(this.renderSession);this.filterManager.begin(this.renderSession,r);t._renderWebGL(this.renderSession,u);this.spriteBatch.end()},n.WebGLRenderer.prototype.resize=function(n,t){this.width=n*this.resolution;this.height=t*this.resolution;this.view.width=this.width;this.view.height=this.height;this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px");this.gl.viewport(0,0,this.width,this.height);this.projection.x=this.width/2/this.resolution;this.projection.y=-this.height/2/this.resolution},n.WebGLRenderer.prototype.updateCompressedTexture=function(t){if(!t.hasLoaded)return!1;var i=this.gl,r=t.source;return t._glTextures[i.id]||(t._glTextures[i.id]=i.createTexture()),i.activeTexture(i.TEXTURE0+t.textureIndex),i.bindTexture(i.TEXTURE_2D,t._glTextures[i.id]),i.compressedTexImage2D(i.TEXTURE_2D,0,r.glExtensionFormat,r.width,r.height,0,r.textureData),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR:i.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST),i.generateMipmap(i.TEXTURE_2D)):i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR:i.NEAREST),t._powerOf2?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.REPEAT)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)),t._dirty[i.id]=!1,!0},n.WebGLRenderer.prototype.updateTexture=function(t){if(!t.hasLoaded||!t.source)return!1;if(t.source.compressionAlgorithm)return this.updateCompressedTexture(t);var i=this.gl;return t._glTextures[i.id]||(t._glTextures[i.id]=i.createTexture()),i.activeTexture(i.TEXTURE0+t.textureIndex),i.bindTexture(i.TEXTURE_2D,t._glTextures[i.id]),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t.source),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR:i.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST),i.generateMipmap(i.TEXTURE_2D)):i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t.scaleMode===n.scaleModes.LINEAR?i.LINEAR:i.NEAREST),t._powerOf2?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.REPEAT)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)),t._dirty[i.id]=!1,!0},n.WebGLRenderer.prototype.destroy=function(){n.glContexts[this.glContextId]=null;this.projection=null;this.offset=null;this.shaderManager.destroy();this.spriteBatch.destroy();this.maskManager.destroy();this.filterManager.destroy();this.shaderManager=null;this.spriteBatch=null;this.maskManager=null;this.filterManager=null;this.gl=null;this.renderSession=null;Phaser.CanvasPool.remove(this);n.instances[this.glContextId]=null;n.WebGLRenderer.glContextId--},n.WebGLRenderer.prototype.mapBlendModes=function(){var t=this.gl,i,r;n.blendModesWebGL||(i=[],r=n.blendModes,i[r.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],i[r.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],i[r.SCREEN]=[t.SRC_ALPHA,t.ONE],i[r.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],i[r.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],n.blendModesWebGL=i)},n.WebGLRenderer.prototype.getMaxTextureUnit=function(){var n=this.gl;return n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS)},n.enableMultiTexture=function(){n._enableMultiTextureToggle=!0},n.WebGLRenderer.glContextId=0,n.WebGLRenderer.textureArray=[],n.WebGLBlendModeManager=function(){this.currentBlendMode=99999},n.WebGLBlendModeManager.prototype.constructor=n.WebGLBlendModeManager,n.WebGLBlendModeManager.prototype.setContext=function(n){this.gl=n},n.WebGLBlendModeManager.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var i=n.blendModesWebGL[this.currentBlendMode];return i&&this.gl.blendFunc(i[0],i[1]),!0},n.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},n.WebGLMaskManager=function(){},n.WebGLMaskManager.prototype.constructor=n.WebGLMaskManager,n.WebGLMaskManager.prototype.setContext=function(n){this.gl=n},n.WebGLMaskManager.prototype.pushMask=function(t,i){var r=i.gl;t.dirty&&n.WebGLGraphics.updateGraphics(t,r);void 0!==t._webGL[r.id]&&void 0!==t._webGL[r.id].data&&0!==t._webGL[r.id].data.length&&i.stencilManager.pushStencil(t,t._webGL[r.id].data[0],i)},n.WebGLMaskManager.prototype.popMask=function(n,t){var i=this.gl;void 0!==n._webGL[i.id]&&void 0!==n._webGL[i.id].data&&0!==n._webGL[i.id].data.length&&t.stencilManager.popStencil(n,n._webGL[i.id].data[0],t)},n.WebGLMaskManager.prototype.destroy=function(){this.gl=null},n.WebGLStencilManager=function(){this.stencilStack=[];this.reverse=!0;this.count=0},n.WebGLStencilManager.prototype.setContext=function(n){this.gl=n},n.WebGLStencilManager.prototype.pushStencil=function(n,t,i){var r=this.gl,u;this.bindGraphics(n,t,i);0===this.stencilStack.length&&(r.enable(r.STENCIL_TEST),r.clear(r.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0);this.stencilStack.push(t);u=this.count;r.colorMask(!1,!1,!1,!1);r.stencilFunc(r.ALWAYS,0,255);r.stencilOp(r.KEEP,r.KEEP,r.INVERT);1===t.mode?(r.drawElements(r.TRIANGLE_FAN,t.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?(r.stencilFunc(r.EQUAL,255-u,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,u,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(t.indices.length-4)),this.reverse?r.stencilFunc(r.EQUAL,255-(u+1),255):r.stencilFunc(r.EQUAL,u+1,255),this.reverse=!this.reverse):(this.reverse?(r.stencilFunc(r.EQUAL,u,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,255-u,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_STRIP,t.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,u+1,255):r.stencilFunc(r.EQUAL,255-(u+1),255));r.colorMask(!0,!0,!0,!0);r.stencilOp(r.KEEP,r.KEEP,r.KEEP);this.count++},n.WebGLStencilManager.prototype.bindGraphics=function(n,t,i){this._currentGraphics=n;var u,r=this.gl,f=i.projection,e=i.offset;1===t.mode?(u=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(u),r.uniform1f(u.flipY,i.flipY),r.uniformMatrix3fv(u.translationMatrix,!1,n.worldTransform.toArray(!0)),r.uniform2f(u.projectionVector,f.x,-f.y),r.uniform2f(u.offsetVector,-e.x,-e.y),r.uniform3fv(u.tintColor,Phaser.Color.hexToRGBArray(n.tint)),r.uniform3fv(u.color,t.color),r.uniform1f(u.alpha,n.worldAlpha*t.alpha),r.bindBuffer(r.ARRAY_BUFFER,t.buffer),r.vertexAttribPointer(u.aVertexPosition,2,r.FLOAT,!1,8,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.indexBuffer)):(u=i.shaderManager.primitiveShader,i.shaderManager.setShader(u),r.uniformMatrix3fv(u.translationMatrix,!1,n.worldTransform.toArray(!0)),r.uniform1f(u.flipY,i.flipY),r.uniform2f(u.projectionVector,f.x,-f.y),r.uniform2f(u.offsetVector,-e.x,-e.y),r.uniform3fv(u.tintColor,Phaser.Color.hexToRGBArray(n.tint)),r.uniform1f(u.alpha,n.worldAlpha),r.bindBuffer(r.ARRAY_BUFFER,t.buffer),r.vertexAttribPointer(u.aVertexPosition,2,r.FLOAT,!1,24,0),r.vertexAttribPointer(u.colorAttribute,4,r.FLOAT,!1,24,8),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.indexBuffer))},n.WebGLStencilManager.prototype.popStencil=function(n,t,i){var r=this.gl,u;(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)?r.disable(r.STENCIL_TEST):(u=this.count,this.bindGraphics(n,t,i),r.colorMask(!1,!1,!1,!1),1===t.mode?(this.reverse=!this.reverse,this.reverse?(r.stencilFunc(r.EQUAL,255-(u+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,u+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(t.indices.length-4)),r.stencilFunc(r.ALWAYS,0,255),r.stencilOp(r.KEEP,r.KEEP,r.INVERT),r.drawElements(r.TRIANGLE_FAN,t.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,u,255):r.stencilFunc(r.EQUAL,255-u,255)):(this.reverse?(r.stencilFunc(r.EQUAL,u+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,255-(u+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_STRIP,t.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,u,255):r.stencilFunc(r.EQUAL,255-u,255)),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP))},n.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null;this.gl=null},n.WebGLShaderManager=function(){this.maxAttibs=10;this.attribState=[];this.tempAttribState=[];for(var n=0;n<this.maxAttibs;n++)this.attribState[n]=!1;this.stack=[]},n.WebGLShaderManager.prototype.constructor=n.WebGLShaderManager,n.WebGLShaderManager.prototype.setContext=function(t){this.gl=t;this.primitiveShader=new n.PrimitiveShader(t);this.complexPrimitiveShader=new n.ComplexPrimitiveShader(t);this.defaultShader=new n.PixiShader(t);this.fastShader=new n.PixiFastShader(t);this.stripShader=new n.StripShader(t);this.creatureShader=n.CreatureShader?new n.CreatureShader(t):null;this.setShader(this.defaultShader)},n.WebGLShaderManager.prototype.setAttribs=function(n){for(var r,i,t=0;t<this.tempAttribState.length;t++)this.tempAttribState[t]=!1;for(t=0;t<n.length;t++)r=n[t],this.tempAttribState[r]=!0;for(i=this.gl,t=0;t<this.attribState.length;t++)this.attribState[t]!==this.tempAttribState[t]&&(this.attribState[t]=this.tempAttribState[t],this.tempAttribState[t]?i.enableVertexAttribArray(t):i.disableVertexAttribArray(t))},n.WebGLShaderManager.prototype.setShader=function(n){return this._currentId!==n._UID&&(this._currentId=n._UID,this.currentShader=n,this.gl.useProgram(n.program),this.setAttribs(n.attributes),!0)},n.WebGLShaderManager.prototype.destroy=function(){this.attribState=null;this.tempAttribState=null;this.primitiveShader.destroy();this.complexPrimitiveShader.destroy();this.defaultShader.destroy();this.fastShader.destroy();this.stripShader.destroy();this.creatureShader&&this.creatureShader.destroy();this.gl=null},n.WebGLSpriteBatch=function(n){var u,r,t,i;for(this.game=n,this.vertSize=5,this.size=2e3,this.vertexSize=24,u=this.vertexSize*this.size*4,r=6*this.size,this.vertices=new ArrayBuffer(u),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(r),this.lastIndexCount=0,t=0,i=0;t<r;t+=6,i+=4)this.indices[t+0]=i+0,this.indices[t+1]=i+1,this.indices[t+2]=i+2,this.indices[t+3]=i+0,this.indices[t+4]=i+2,this.indices[t+5]=i+3;this.drawing=!1;this.currentBatchSize=0;this.currentBaseTexture=null;this.dirty=!0;this.textures=[];this.blendModes=[];this.shaders=[];this.sprites=[];this.defaultShader=null},n.WebGLSpriteBatch.prototype.setContext=function(t){var u,i,r;if(this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.gl=t,n._enableMultiTextureToggle){for(u="\tif (vTextureIndex == 0.0) {gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)u+="\tif (vTextureIndex == "+i+".0) {gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","void main(void) {",u,"\tgl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;","}"])}else this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]);this.vertexBuffer=t.createBuffer();this.indexBuffer=t.createBuffer();t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW);t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer);t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW);this.currentBlendMode=99999;r=new n.PixiShader(t);r.fragmentSrc=this.defaultShader.fragmentSrc;r.uniforms={};r.init();this.defaultShader.shaders[t.id]=r},n.WebGLSpriteBatch.prototype.begin=function(n){this.renderSession=n;this.shader=this.renderSession.shaderManager.defaultShader;this.start()},n.WebGLSpriteBatch.prototype.end=function(){this.flush()},n.WebGLSpriteBatch.prototype.render=function(n,t){var f=n.texture,e=n.worldTransform,u,o,s,h,c,nt,tt,g;if(t&&(e=t),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=f.baseTexture),u=f._uvs,u){nt=n.anchor.x;tt=n.anchor.y;f.trim?(g=f.trim,o=(s=g.x-nt*g.width)+f.crop.width,h=(c=g.y-tt*g.height)+f.crop.height):(o=f.frame.width*(1-nt),s=f.frame.width*-nt,h=f.frame.height*(1-tt),c=f.frame.height*-tt);var i=this.currentBatchSize*this.vertexSize,it=f.baseTexture.resolution,b=f.baseTexture.textureIndex,v=e.a/it,y=e.b/it,p=e.c/it,w=e.d/it,l=e.tx,a=e.ty,ut=f.crop.height;if(f.rotated){var ft=e.a,et=e.b,ot=e.c,st=e.d,ht=s,ct=o;l=e.c*ut+l;a=e.d*ut+a;v=6123233995736766e-32*ft-ot;y=6123233995736766e-32*et-st;p=ft+6123233995736766e-32*ot;w=et+6123233995736766e-32*st;f._updateUvsInverted();o=h;s=c;h=ct;c=ht}var k=this.colors,r=this.positions,rt=n.tint,d=(rt>>16)+(65280&rt)+((255&rt)<<16)+(255*n.worldAlpha<<24);this.renderSession.roundPixels?(r[i++]=v*s+p*c+l|0,r[i++]=w*c+y*s+a|0,r[i++]=u.x0,r[i++]=u.y0,k[i++]=d,r[i++]=b,r[i++]=v*o+p*c+l|0,r[i++]=w*c+y*o+a|0,r[i++]=u.x1,r[i++]=u.y1,k[i++]=d,r[i++]=b,r[i++]=v*o+p*h+l|0,r[i++]=w*h+y*o+a|0,r[i++]=u.x2,r[i++]=u.y2,k[i++]=d,r[i++]=b,r[i++]=v*s+p*h+l|0,r[i++]=w*h+y*s+a|0,r[i++]=u.x3,r[i++]=u.y3,k[i++]=d,r[i++]=b):(r[i++]=v*s+p*c+l,r[i++]=w*c+y*s+a,r[i++]=u.x0,r[i++]=u.y0,k[i++]=d,r[i++]=b,r[i++]=v*o+p*c+l,r[i++]=w*c+y*o+a,r[i++]=u.x1,r[i++]=u.y1,k[i++]=d,r[i++]=b,r[i++]=v*o+p*h+l,r[i++]=w*h+y*o+a,r[i++]=u.x2,r[i++]=u.y2,k[i++]=d,r[i++]=b,r[i++]=v*s+p*h+l,r[i++]=w*h+y*s+a,r[i++]=u.x3,r[i++]=u.y3,k[i++]=d,r[i++]=b);this.sprites[this.currentBatchSize++]=n}},n.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,o=t.texture.baseTexture.textureIndex;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture);t._uvs||(t._uvs=new n.TextureUvs);var u=t._uvs,it=e.baseTexture.width,rt=e.baseTexture.height;t.tilePosition.x%=it*t.tileScaleOffset.x;t.tilePosition.y%=rt*t.tileScaleOffset.y;var s=t.tilePosition.x/(it*t.tileScaleOffset.x),h=t.tilePosition.y/(rt*t.tileScaleOffset.y),ft=t.width/it/(t.tileScale.x*t.tileScaleOffset.x),et=t.height/rt/(t.tileScale.y*t.tileScaleOffset.y);u.x0=0-s;u.y0=0-h;u.x1=1*ft-s;u.y1=0-h;u.x2=1*ft-s;u.y2=1*et-h;u.x3=0-s;u.y3=1*et-h;var ut=t.tint,c=(ut>>16)+(65280&ut)+((255&ut)<<16)+(255*t.worldAlpha<<24),r=this.positions,l=this.colors,ot=t.width,st=t.height,ht=t.anchor.x,ct=t.anchor.y,a=ot*(1-ht),v=ot*-ht,y=st*(1-ct),p=st*-ct,i=this.currentBatchSize*this.vertexSize,w=e.baseTexture.resolution,f=t.worldTransform,b=f.a/w,k=f.b/w,d=f.c/w,g=f.d/w,nt=f.tx,tt=f.ty;r[i++]=b*v+d*p+nt;r[i++]=g*p+k*v+tt;r[i++]=u.x0;r[i++]=u.y0;l[i++]=c;r[i++]=o;r[i++]=b*a+d*p+nt;r[i++]=g*p+k*a+tt;r[i++]=u.x1;r[i++]=u.y1;l[i++]=c;r[i++]=o;r[i++]=b*a+d*y+nt;r[i++]=g*y+k*a+tt;r[i++]=u.x2;r[i++]=u.y2;l[i++]=c;r[i++]=o;r[i++]=b*v+d*y+nt;r[i++]=g*y+k*v+tt;r[i++]=u.x3;r[i++]=u.y3;l[i++]=c;r[i++]=o;this.sprites[this.currentBatchSize++]=t},n.WebGLSpriteBatch.prototype.flush=function(){var i,t,u,b,c,p,w;if(0!==this.currentBatchSize){t=this.gl;this.dirty&&(this.dirty=!1,i=this.defaultShader.shaders[t.id],t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),u=this.vertexSize,t.vertexAttribPointer(i.aVertexPosition,2,t.FLOAT,!1,u,0),t.vertexAttribPointer(i.aTextureCoord,2,t.FLOAT,!1,u,8),t.vertexAttribPointer(i.colorAttribute,4,t.UNSIGNED_BYTE,!0,u,16),t.vertexAttribPointer(i.aTextureIndex,1,t.FLOAT,!1,u,20));this.currentBatchSize>.5*this.size?t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices):(t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),b=this.positions.subarray(0,this.currentBatchSize*this.vertexSize),t.bufferSubData(t.ARRAY_BUFFER,0,b));for(var e,k,d,r,o=0,l=0,s=null,a=this.renderSession.blendModeManager.currentBlendMode,f=null,v=!1,y=!1,h=0,g=this.currentBatchSize;h<g;h++)e=(r=this.sprites[h]).tilingTexture?r.tilingTexture.baseTexture:r.texture.baseTexture,v=a!==(k=r.blendMode),y=f!==(d=r.shader||this.defaultShader),c=e.skipRender,(c&&r.children.length>0&&(c=!1),(s!==e&&!c||v||y)&&(this.renderBatch(s,o,l),l=h,o=0,s=e,v&&(a=k,this.renderSession.blendModeManager.setBlendMode(a)),y))&&((i=(f=d).shaders[t.id])||((i=new n.PixiShader(t)).fragmentSrc=f.fragmentSrc,i.uniforms=f.uniforms,i.init(),f.shaders[t.id]=i),this.renderSession.shaderManager.setShader(i),i.dirty&&i.syncUniforms(),p=this.renderSession.projection,t.uniform2f(i.projectionVector,p.x,p.y),w=this.renderSession.offset,t.uniform2f(i.offsetVector,w.x,w.y)),o++;this.renderBatch(s,o,l);this.currentBatchSize=0}},n.WebGLSpriteBatch.prototype.renderBatch=function(n,t,i){if(0!==t){var r=this.gl;if(n._dirty[r.id]){if(!this.renderSession.renderer.updateTexture(n))return}else r.bindTexture(r.TEXTURE_2D,n._glTextures[r.id]);r.drawElements(r.TRIANGLES,6*t,r.UNSIGNED_SHORT,12*i);this.renderSession.drawCount++}},n.WebGLSpriteBatch.prototype.stop=function(){this.flush();this.dirty=!0},n.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},n.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null;this.indices=null;this.gl.deleteBuffer(this.vertexBuffer);this.gl.deleteBuffer(this.indexBuffer);this.currentBaseTexture=null;this.gl=null},n.WebGLFastSpriteBatch=function(n){var u,r,t,i;for(this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize,u=4*this.size*this.vertSize,r=6*this.maxSize,this.vertices=new Float32Array(u),this.indices=new Uint16Array(r),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0,t=0,i=0;t<r;t+=6,i+=4)this.indices[t+0]=i+0,this.indices[t+1]=i+1,this.indices[t+2]=i+2,this.indices[t+3]=i+0,this.indices[t+4]=i+2,this.indices[t+5]=i+3;this.drawing=!1;this.currentBatchSize=0;this.currentBaseTexture=null;this.currentBlendMode=0;this.renderSession=null;this.shader=null;this.matrix=null;this.setContext(n)},n.WebGLFastSpriteBatch.prototype.constructor=n.WebGLFastSpriteBatch,n.WebGLFastSpriteBatch.prototype.setContext=function(n){this.gl=n;this.vertexBuffer=n.createBuffer();this.indexBuffer=n.createBuffer();n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,this.indices,n.STATIC_DRAW);n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,this.vertices,n.DYNAMIC_DRAW)},n.WebGLFastSpriteBatch.prototype.begin=function(n,t){this.renderSession=t;this.shader=this.renderSession.shaderManager.fastShader;this.matrix=n.worldTransform.toArray(!0);this.start()},n.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},n.WebGLFastSpriteBatch.prototype.render=function(t){var f=t.children,r=f[0],e,i,u,o;if(r.texture._uvs){for(this.currentBaseTexture=r.texture.baseTexture,r.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(r.blendMode)),e=this.currentBaseTexture.textureIndex,i=this.gl,i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,this.currentBaseTexture._glTextures[i.id]),n.WebGLRenderer.textureArray[e]=this.currentBaseTexture,u=0,o=f.length;u<o;u++)this.renderSprite(f[u]);this.flush()}},n.WebGLFastSpriteBatch.prototype.renderSprite=function(t){var s=t.texture.baseTexture,e=this.gl,f=t.texture.baseTexture.textureIndex,u,v,y,h,c,l,a,i,r,o;(n.WebGLRenderer.textureArray[f]==s||!s._glTextures[e.id]||t.texture.baseTexture.skipRender||(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,s._glTextures[e.id]),n.WebGLRenderer.textureArray[f]=s,t.texture._uvs))&&t.visible&&(r=this.vertices,(u=t.texture._uvs,v=t.texture.frame.width,y=t.texture.frame.height,t.texture.trim)?(o=t.texture.trim,h=(c=o.x-t.anchor.x*o.width)+t.texture.crop.width,l=(a=o.y-t.anchor.y*o.height)+t.texture.crop.height):(h=v*(1-t.anchor.x),c=v*-t.anchor.x,l=y*(1-t.anchor.y),a=y*-t.anchor.y),i=4*this.currentBatchSize*this.vertSize,r[i++]=c,r[i++]=a,r[i++]=t.position.x,r[i++]=t.position.y,r[i++]=t.scale.x,r[i++]=t.scale.y,r[i++]=t.rotation,r[i++]=u.x0,r[i++]=u.y1,r[i++]=t.alpha,r[i++]=f,r[i++]=h,r[i++]=a,r[i++]=t.position.x,r[i++]=t.position.y,r[i++]=t.scale.x,r[i++]=t.scale.y,r[i++]=t.rotation,r[i++]=u.x1,r[i++]=u.y1,r[i++]=t.alpha,r[i++]=f,r[i++]=h,r[i++]=l,r[i++]=t.position.x,r[i++]=t.position.y,r[i++]=t.scale.x,r[i++]=t.scale.y,r[i++]=t.rotation,r[i++]=u.x2,r[i++]=u.y2,r[i++]=t.alpha,r[i++]=f,r[i++]=c,r[i++]=l,r[i++]=t.position.x,r[i++]=t.position.y,r[i++]=t.scale.x,r[i++]=t.scale.y,r[i++]=t.rotation,r[i++]=u.x3,r[i++]=u.y3,r[i++]=t.alpha,r[i++]=f,++this.currentBatchSize>=this.size&&this.flush())},n.WebGLFastSpriteBatch.prototype.flush=function(){var n,t;0!==this.currentBatchSize&&(n=this.gl,this.currentBaseTexture._glTextures[n.id]?(this.currentBatchSize>.5*this.size?n.bufferSubData(n.ARRAY_BUFFER,0,this.vertices):(t=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize),n.bufferSubData(n.ARRAY_BUFFER,0,t)),n.drawElements(n.TRIANGLES,6*this.currentBatchSize,n.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++):this.renderSession.renderer.updateTexture(this.currentBaseTexture,n))},n.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},n.WebGLFastSpriteBatch.prototype.start=function(){var n=this.gl,i,t;n.activeTexture(n.TEXTURE0);n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);i=this.renderSession.projection;n.uniform2f(this.shader.projectionVector,i.x,i.y);n.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);t=4*this.vertSize;n.vertexAttribPointer(this.shader.aVertexPosition,2,n.FLOAT,!1,t,0);n.vertexAttribPointer(this.shader.aPositionCoord,2,n.FLOAT,!1,t,8);n.vertexAttribPointer(this.shader.aScale,2,n.FLOAT,!1,t,16);n.vertexAttribPointer(this.shader.aRotation,1,n.FLOAT,!1,t,24);n.vertexAttribPointer(this.shader.aTextureCoord,2,n.FLOAT,!1,t,28);n.vertexAttribPointer(this.shader.colorAttribute,1,n.FLOAT,!1,t,36);n.vertexAttribPointer(this.shader.aTextureIndex,1,n.FLOAT,!1,t,40)},n.WebGLFilterManager=function(){this.filterStack=[];this.offsetX=0;this.offsetY=0},n.WebGLFilterManager.prototype.constructor=n.WebGLFilterManager,n.WebGLFilterManager.prototype.setContext=function(n){this.gl=n;this.texturePool=[];this.initShaderBuffers()},n.WebGLFilterManager.prototype.begin=function(n,t){this.renderSession=n;this.defaultShader=n.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x;this.height=2*-i.y;this.buffer=t},n.WebGLFilterManager.prototype.pushFilter=function(t){var r=this.gl,e=this.renderSession.projection,o=this.renderSession.offset,s,u,i,f;t._filterArea=t.target.filterArea||t.target.getBounds();t._previous_stencil_mgr=this.renderSession.stencilManager;this.renderSession.stencilManager=new n.WebGLStencilManager;this.renderSession.stencilManager.setContext(r);r.disable(r.STENCIL_TEST);this.filterStack.push(t);s=t.filterPasses[0];this.offsetX+=t._filterArea.x;this.offsetY+=t._filterArea.y;u=this.texturePool.pop();u?u.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):u=new n.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution);r.bindTexture(r.TEXTURE_2D,u.texture);i=t._filterArea;f=s.padding;i.x-=f;i.y-=f;i.width+=2*f;i.height+=2*f;i.x<0&&(i.x=0);i.width>this.width&&(i.width=this.width);i.y<0&&(i.y=0);i.height>this.height&&(i.height=this.height);r.bindFramebuffer(r.FRAMEBUFFER,u.frameBuffer);r.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution);e.x=i.width/2;e.y=-i.height/2;o.x=-i.x;o.y=-i.y;r.colorMask(!0,!0,!0,!0);r.clearColor(0,0,0,0);r.clear(r.COLOR_BUFFER_BIT);t._glFilterTexture=u},n.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,r=this.filterStack.pop(),i=r._filterArea,s=r._glFilterTexture,p=this.renderSession.projection,w=this.renderSession.offset,f,u,h,b,k,d,y,e,o;if(r.filterPasses.length>1){for(t.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray),f=s,u=this.texturePool.pop(),u||(u=new n.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),u.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,u.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND),h=0;h<r.filterPasses.length-1;h++)b=r.filterPasses[h],t.bindFramebuffer(t.FRAMEBUFFER,u.frameBuffer),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,f.texture),this.applyFilterPass(b,i,i.width,i.height),k=f,f=u,u=k;t.enable(t.BLEND);s=f;this.texturePool.push(u)}d=r.filterPasses[r.filterPasses.length-1];this.offsetX-=i.x;this.offsetY-=i.y;var c=this.width,l=this.height,a=0,v=0,g=this.buffer;0===this.filterStack.length?t.colorMask(!0,!0,!0,!0):(y=this.filterStack[this.filterStack.length-1],c=(i=y._filterArea).width,l=i.height,a=i.x,v=i.y,g=y._glFilterTexture.frameBuffer);p.x=c/2;p.y=-l/2;w.x=a;w.y=v;e=(i=r._filterArea).x-a;o=i.y-v;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer);this.vertexArray[0]=e;this.vertexArray[1]=o+i.height;this.vertexArray[2]=e+i.width;this.vertexArray[3]=o+i.height;this.vertexArray[4]=e;this.vertexArray[5]=o;this.vertexArray[6]=e+i.width;this.vertexArray[7]=o;t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray);t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer);this.uvArray[2]=i.width/this.width;this.uvArray[5]=i.height/this.height;this.uvArray[6]=i.width/this.width;this.uvArray[7]=i.height/this.height;t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);t.viewport(0,0,c*this.renderSession.resolution,l*this.renderSession.resolution);t.bindFramebuffer(t.FRAMEBUFFER,g);t.activeTexture(t.TEXTURE0);t.bindTexture(t.TEXTURE_2D,s.texture);this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy();this.renderSession.stencilManager=r._previous_stencil_mgr;r._previous_stencil_mgr=null;this.renderSession.stencilManager.count>0?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST);this.applyFilterPass(d,i,c,l);this.texturePool.push(s);r._glFilterTexture=null},n.WebGLFilterManager.prototype.applyFilterPass=function(t,i,r,u){var f=this.gl,e=t.shaders[f.id];e||((e=new n.PixiShader(f)).fragmentSrc=t.fragmentSrc,e.uniforms=t.uniforms,e.init(!0),t.shaders[f.id]=e);this.renderSession.shaderManager.setShader(e);f.uniform2f(e.projectionVector,r/2,-u/2);f.uniform2f(e.offsetVector,0,0);t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]);e.syncUniforms();f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer);f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,this.uvBuffer);f.vertexAttribPointer(e.aTextureCoord,2,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,this.colorBuffer);f.vertexAttribPointer(e.colorAttribute,2,f.FLOAT,!1,0,0);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this.indexBuffer);f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0);this.renderSession.drawCount++},n.WebGLFilterManager.prototype.initShaderBuffers=function(){var n=this.gl;this.vertexBuffer=n.createBuffer();this.uvBuffer=n.createBuffer();this.colorBuffer=n.createBuffer();this.indexBuffer=n.createBuffer();this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]);n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,this.vertexArray,n.STATIC_DRAW);this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]);n.bindBuffer(n.ARRAY_BUFFER,this.uvBuffer);n.bufferData(n.ARRAY_BUFFER,this.uvArray,n.STATIC_DRAW);this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]);n.bindBuffer(n.ARRAY_BUFFER,this.colorBuffer);n.bufferData(n.ARRAY_BUFFER,this.colorArray,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),n.STATIC_DRAW)},n.WebGLFilterManager.prototype.destroy=function(){var n=this.gl,t;for(this.filterStack=null,this.offsetX=0,this.offsetY=0,t=0;t<this.texturePool.length;t++)this.texturePool[t].destroy();this.texturePool=null;n.deleteBuffer(this.vertexBuffer);n.deleteBuffer(this.uvBuffer);n.deleteBuffer(this.colorBuffer);n.deleteBuffer(this.indexBuffer)},i={36054:"Incomplete attachment",36055:"Missing attachment",36057:"Incomplete dimensions",36061:"Framebuffer unsupported"},n.FilterTexture=function(t,i,r,f,e){e="number"==typeof e?e:0;this.gl=t;this.frameBuffer=u(t,i,r,f||n.scaleModes.DEFAULT,e);this.texture=this.frameBuffer.targetTexture;this.width=i;this.height=r;this.renderBuffer=this.frameBuffer.renderBuffer},n.FilterTexture.prototype.constructor=n.FilterTexture,n.FilterTexture.prototype.clear=function(){var n=this.gl;n.clearColor(0,0,0,0);n.clear(n.COLOR_BUFFER_BIT)},n.FilterTexture.prototype.resize=function(n,t){if(this.width!==n||this.height!==t){this.width=n;this.height=t;var i=this.gl;i.bindTexture(i.TEXTURE_2D,this.texture);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,t,0,i.RGBA,i.UNSIGNED_BYTE,null);i.bindRenderbuffer(i.RENDERBUFFER,this.renderBuffer);i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,n,t)}},n.FilterTexture.prototype.destroy=function(){var n=this.gl;n.deleteFramebuffer(this.frameBuffer);n.deleteTexture(this.texture);this.frameBuffer=null;this.texture=null},n.CanvasBuffer=function(n,t){this.width=n;this.height=t;this.canvas=Phaser.CanvasPool.create(this,this.width,this.height);this.context=this.canvas.getContext("2d");this.canvas.width=n;this.canvas.height=t},n.CanvasBuffer.prototype.constructor=n.CanvasBuffer,n.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0);this.context.clearRect(0,0,this.width,this.height)},n.CanvasBuffer.prototype.resize=function(n,t){this.width=this.canvas.width=n;this.height=this.canvas.height=t},n.CanvasBuffer.prototype.destroy=function(){Phaser.CanvasPool.remove(this)},n.CanvasMaskManager=function(){},n.CanvasMaskManager.prototype.constructor=n.CanvasMaskManager,n.CanvasMaskManager.prototype.pushMask=function(t,i){var f=i.context;f.save();var e=t.alpha,r=t.worldTransform,u=i.resolution;f.setTransform(r.a*u,r.b*u,r.c*u,r.d*u,r.tx*u,r.ty*u);n.CanvasGraphics.renderGraphicsMask(t,f);f.clip();t.worldAlpha=e},n.CanvasMaskManager.prototype.popMask=function(n){n.context.restore()},n.CanvasTinter=function(){},n.CanvasTinter.getTintedTexture=function(t,i){var r=t.tintedTexture||Phaser.CanvasPool.create(this);return n.CanvasTinter.tintMethod(t.texture,i,r),r},n.CanvasTinter.tintWithMultiply=function(n,t,i){var f=i.getContext("2d"),e=n.crop,u=e.width,r=e.height;n.rotated&&(u=r,r=e.width);i.width===u&&i.height===r||(i.width=u,i.height=r);f.clearRect(0,0,u,r);f.fillStyle="#"+("00000"+(0|t).toString(16)).substr(-6);f.fillRect(0,0,u,r);f.globalCompositeOperation="multiply";f.drawImage(n.baseTexture.source,e.x,e.y,u,r,0,0,u,r);f.globalCompositeOperation="destination-atop";f.drawImage(n.baseTexture.source,e.x,e.y,u,r,0,0,u,r)},n.CanvasTinter.tintWithPerPixel=function(t,i,r){var h=r.getContext("2d"),s=t.crop,o=s.width,e=s.height,c;t.rotated&&(o=e,e=s.width);r.width===o&&r.height===e||(r.width=o,r.height=e);h.globalCompositeOperation="copy";h.drawImage(t.baseTexture.source,s.x,s.y,o,e,0,0,o,e);for(var l=Phaser.Color.hexToRGBArray(i),v=l[0],y=l[1],p=l[2],a=h.getImageData(0,0,o,e),f=a.data,u=0;u<f.length;u+=4)(f[u+0]*=v,f[u+1]*=y,f[u+2]*=p,n.CanvasTinter.canHandleAlpha)||(c=f[u+3],f[u+0]/=255/c,f[u+1]/=255/c,f[u+2]/=255/c);h.putImageData(a,0,0)},n.CanvasRenderer=function(t,i){if(this.game=t,n.defaultRenderer||(n.defaultRenderer=this),this.type=Phaser.CANVAS,this.resolution=t.resolution,this.clearBeforeRender=t.clearBeforeRender,this.transparent=t.transparent,this.autoResize=!1,this.width=t.width*this.resolution,this.height=t.height*this.resolution,this.view=t.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),!this.context)throw new Error("Failed to create a Canvas 2d context.");this.refresh=!0;this.count=0;this.maskManager=new n.CanvasMaskManager;this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:i.roundPixels||!1};this.mapBlendModes();this.resize(this.width,this.height)},n.CanvasRenderer.prototype.constructor=n.CanvasRenderer,n.CanvasRenderer.prototype.render=function(n){this.context.setTransform(1,0,0,1,0,0);this.context.globalAlpha=1;this.renderSession.currentBlendMode=0;this.renderSession.shakeX=this.game.camera._shake.x;this.renderSession.shakeY=this.game.camera._shake.y;this.context.globalCompositeOperation="source-over";navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear());this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):n._bgColor&&(this.context.fillStyle=n._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height)));this.renderDisplayObject(n)},n.CanvasRenderer.prototype.setTexturePriority=function(){},n.CanvasRenderer.prototype.destroy=function(n){void 0===n&&(n=!0);n&&this.view.parent&&this.view.parent.removeChild(this.view);this.view=null;this.context=null;this.maskManager=null;this.renderSession=null},n.CanvasRenderer.prototype.resize=function(t,i){this.width=t*this.resolution;this.height=i*this.resolution;this.view.width=this.width;this.view.height=this.height;this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px");this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===n.scaleModes.LINEAR)},n.CanvasRenderer.prototype.renderDisplayObject=function(n,t,i){this.renderSession.context=t||this.context;this.renderSession.resolution=this.resolution;n._renderCanvas(this.renderSession,i)},n.CanvasRenderer.prototype.mapBlendModes=function(){if(!n.blendModesCanvas){var t=[],i=n.blendModes,r=this.game.device.canUseMultiply;t[i.NORMAL]="source-over";t[i.ADD]="lighter";t[i.MULTIPLY]=r?"multiply":"source-over";t[i.SCREEN]=r?"screen":"source-over";t[i.OVERLAY]=r?"overlay":"source-over";t[i.DARKEN]=r?"darken":"source-over";t[i.LIGHTEN]=r?"lighten":"source-over";t[i.COLOR_DODGE]=r?"color-dodge":"source-over";t[i.COLOR_BURN]=r?"color-burn":"source-over";t[i.HARD_LIGHT]=r?"hard-light":"source-over";t[i.SOFT_LIGHT]=r?"soft-light":"source-over";t[i.DIFFERENCE]=r?"difference":"source-over";t[i.EXCLUSION]=r?"exclusion":"source-over";t[i.HUE]=r?"hue":"source-over";t[i.SATURATION]=r?"saturation":"source-over";t[i.COLOR]=r?"color":"source-over";t[i.LUMINOSITY]=r?"luminosity":"source-over";n.blendModesCanvas=t}},n.BaseTexture=function(t,i,r){this.resolution=r||1;this.width=100;this.height=100;this.scaleMode=i||n.scaleModes.DEFAULT;this.hasLoaded=!1;this.source=t;this.premultipliedAlpha=!0;this._glTextures=[];this.mipmap=!1;this.textureIndex=0;this._dirty=[!0,!0,!0,!0];t&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},n.BaseTexture.prototype.constructor=n.BaseTexture,n.BaseTexture.prototype.forceLoaded=function(n,t){this.hasLoaded=!0;this.width=n;this.height=t;this.dirty()},n.BaseTexture.prototype.destroy=function(){this.source&&Phaser.CanvasPool.removeByCanvas(this.source);this.source=null;this.unloadFromGPU()},n.BaseTexture.prototype.dirty=function(){for(var n=0;n<this._glTextures.length;n++)this._dirty[n]=!0},n.BaseTexture.prototype.unloadFromGPU=function(){var t,i,r;for(this.dirty(),t=this._glTextures.length-1;t>=0;t--)i=this._glTextures[t],r=n.glContexts[t],r&&i&&r.deleteTexture(i);this._glTextures.length=0;this.dirty()},n.BaseTexture.fromCanvas=function(t,i,r){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),r=r||1,new n.BaseTexture(t,i,r)},n.TextureSilentFail=!1,n.Texture=function(t,i,r,u){this.noFrame=!1;i||(this.noFrame=!0,i=new n.Rectangle(0,0,1,1));t instanceof n.Texture&&(t=t.baseTexture);this.baseTexture=t;this.frame=i;this.trim=u;this.valid=!1;this.isTiling=!1;this.requiresUpdate=!1;this.requiresReTint=!1;this._uvs=null;this.width=0;this.height=0;this.crop=r||new n.Rectangle(0,0,1,1);this.rotated=!1;t.hasLoaded&&(this.noFrame&&(i=new n.Rectangle(0,0,t.width,t.height)),this.setFrame(i))},n.Texture.prototype.constructor=n.Texture,n.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;this.noFrame&&(this.frame=new n.Rectangle(0,0,t.width,t.height));this.setFrame(this.frame)},n.Texture.prototype.destroy=function(n){n&&this.baseTexture.destroy();this.valid=!1},n.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,!this.trim&&(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height)){if(!n.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}else this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},n.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new n.TextureUvs);var t=this.crop,i=this.baseTexture.width,r=this.baseTexture.height;this._uvs.x0=t.x/i;this._uvs.y0=t.y/r;this._uvs.x1=(t.x+t.width)/i;this._uvs.y1=t.y/r;this._uvs.x2=(t.x+t.width)/i;this._uvs.y2=(t.y+t.height)/r;this._uvs.x3=t.x/i;this._uvs.y3=(t.y+t.height)/r},n.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new n.TextureUvs);var t=this.crop,i=this.baseTexture.width,r=this.baseTexture.height;this._uvs.x0=t.x/i;this._uvs.y0=t.y/r;this._uvs.x1=(t.x+t.height)/i;this._uvs.y1=t.y/r;this._uvs.x2=(t.x+t.height)/i;this._uvs.y2=(t.y+t.width)/r;this._uvs.x3=t.x/i;this._uvs.y3=(t.y+t.width)/r},n.Texture.fromCanvas=function(t,i){var r=n.BaseTexture.fromCanvas(t,i);return new n.Texture(r)},n.TextureUvs=function(){this.x0=0;this.y0=0;this.x1=0;this.y1=0;this.x2=0;this.y2=0;this.x3=0;this.y3=0},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports.PIXI=n):"undefined"!=typeof define&&define.amd?define("PIXI",t.PIXI=n):t.PIXI=n,n}.call(this),function(){var u=this,n=n||{VERSION:"2.13.3",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0},t,r,i;("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Function.prototype.bind||(Function.prototype.bind=function(){var n=Array.prototype.slice;return function(t){function i(){var f=u.concat(n.call(arguments));r.apply(this instanceof i?this:t,f)}var r=this,u=n.call(arguments,1);if("function"!=typeof r)throw new TypeError;return i.prototype=function n(t){if(t&&(n.prototype=t),!(this instanceof n))return new n}(r.prototype),i}}()),Array.isArray||(Array.isArray=function(n){return"[object Array]"===Object.prototype.toString.call(n)}),Array.prototype.forEach||(Array.prototype.forEach=function(n){"use strict";var i,r,u,t;if(void 0===this||null===this)throw new TypeError;if(i=Object(this),r=i.length>>>0,"function"!=typeof n)throw new TypeError;for(u=arguments.length>=2?arguments[1]:void 0,t=0;t<r;t++)t in i&&n.call(u,i[t],t,i)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array)&&(t=function(n){window[n]=function(n){if("number"==typeof n)for(Array.call(this,n),this.length=n,t=0;t<this.length;t++)this[t]=0;else{Array.call(this,n.length);this.length=n.length;for(var t=0;t<this.length;t++)this[t]=n[t]}};window[n].prototype=[];window[n].constructor=window[n]},t("Float32Array"),t("Uint32Array"),t("Uint16Array"),t("Int16Array"),t("ArrayBuffer"));window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){});Object.assign||(Object.assign=function(n){"use strict";var t,i;if(null==n)throw new TypeError("Cannot convert undefined or null to object");for(var u=Object(n),f=Object.prototype.hasOwnProperty,r=1;r<arguments.length;r++)if(t=arguments[r],null!=t)for(i in t)f.call(t,i)&&(u[i]=t[i]);return u});n.Utils={defaults:function(n,t){for(var i,u=Object.keys(t),r=0,f=u.length;r<f;r++)i=u[r],void 0===n[i]&&(n[i]=t[i]);return n},reverseString:function(n){return n.split("").reverse().join("")},getProperty:function(n,t){var i=t.split(".");switch(i.length){case 1:return n[t];case 2:return n[i[0]][i[1]];case 3:return n[i[0]][i[1]][i[2]];case 4:return n[i[0]][i[1]][i[2]][i[3]];default:return this._getProperty(n,t)}},setProperties:function(n,t){for(var i in t)this.setProperty(n,i,t[i]);return n},setProperty:function(n,t,i){var r=t.split(".");switch(r.length){case 1:n[t]=i;break;case 2:n[r[0]][r[1]]=i;break;case 3:n[r[0]][r[1]][r[2]]=i;break;case 4:n[r[0]][r[1]][r[2]][r[3]]=i;break;default:this._setProperty(n,t,i)}},_getProperty:function(n,t){for(var f,u=t.split("."),e=u.length,r=0,i=n;r<e;){if(f=u[r],null==i)return;i=i[f];r++}return i},_setProperty:function(n,t,i){var r=t.split("."),e=r.length,o=0,u=n,f=r[0];if(1===e)n[t]=i;else{for(;o<e-1;)u=u[f],f=r[++o];u[f]=i}return n},chanceRoll:function(n){return void 0===n&&(n=50),n>0&&100*Math.random()<=n},randomChoice:function(n,t){return Math.random()<.5?n:t},parseDimension:function(n,t){var r=0,i=0;return"string"==typeof n?"%"===n.substr(-1)?(r=parseInt(n,10)/100,i=0===t?window.innerWidth*r:window.innerHeight*r):i=parseInt(n,10):i=n,i},pad:function(n,t,i,r){var t,i,r,u,f,e;if(void 0===t&&(t=0),void 0===i&&(i=" "),void 0===r&&(r=3),u=0,t+1>=(n=n.toString()).length)switch(r){case 1:n=new Array(t+1-n.length).join(i)+n;break;case 3:f=Math.ceil((u=t-n.length)/2);e=u-f;n=new Array(e+1).join(i)+n+new Array(f+1).join(i);break;default:n+=new Array(t+1-n.length).join(i)}return n},isPlainObject:function(n){if("object"!=typeof n||n.nodeType||n===n.window)return!1;try{if(n.constructor&&!{}.hasOwnProperty.call(n.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}return!0},extend:function(){var e,f,i,r,o,s,t=arguments[0]||{},u=1,c=arguments.length,h=!1;for("boolean"==typeof t&&(h=t,t=arguments[1]||{},u=2),c===u&&(t=this,--u);u<c;u++)if(null!=(e=arguments[u]))for(f in e)i=t[f],t!==(r=e[f])&&(h&&r&&(n.Utils.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,s=i&&Array.isArray(i)?i:[]):s=i&&n.Utils.isPlainObject(i)?i:{},t[f]=n.Utils.extend(h,s,r)):void 0!==r&&(t[f]=r));return t},mixinPrototype:function(n,t,i){var e,f,u,r;for(void 0===i&&(i=!1),e=Object.keys(t),f=0;f<e.length;f++)u=e[f],r=t[u],!i&&u in n||(!r||"function"!=typeof r.get&&"function"!=typeof r.set?n[u]=r:"function"==typeof r.clone?n[u]=r.clone():Object.defineProperty(n,u,r))},mixin:function(t,i){var r,u,f;if(!t||"object"!=typeof t)return i;for(r in t)u=t[r],u.childNodes||u.cloneNode||(f=typeof t[r],i[r]=t[r]&&"object"===f?typeof i[r]===f?n.Utils.mixin(t[r],i[r]):n.Utils.mixin(t[r],new u.constructor):t[r]);return i}};n.Circle=function(t,i,r){t=t||0;i=i||0;r=r||0;this.x=t;this.y=i;this._diameter=r;this._radius=0;r>0&&(this._radius=.5*r);this.type=n.CIRCLE};n.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new n.Point);var r=2*Math.PI*Math.random(),i=Math.random()+Math.random(),u=i>1?2-i:i,f=u*Math.cos(r),e=u*Math.sin(r);return t.x=this.x+f*this.radius,t.y=this.y+e*this.radius,t},getBounds:function(){return new n.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(n,t,i){return this.x=n,this.y=t,this._diameter=i,this._radius=.5*i,this},copyFrom:function(n){return this.setTo(n.x,n.y,n.diameter)},copyTo:function(n){return n.x=this.x,n.y=this.y,n.diameter=this._diameter,n},distance:function(t,i){var r=n.Math.distance(this.x,this.y,t.x,t.y);return i?Math.round(r):r},clone:function(t){return void 0===t||null===t?t=new n.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,i){return n.Circle.contains(this,t,i)},circumferencePoint:function(t,i,r){return n.Circle.circumferencePoint(this,t,i,r)},sample:function(t,i,r,u,f){t||(t=60);null==i&&(i=0);null==r&&(r=n.Math.PI2);f||(f=[]);for(var e=0;e<t;)this.circumferencePoint(n.Math.linear(i,r,e/t),u,f[e]||(f[e]=new n.Point)),e+=1;return f},offset:function(n,t){return this.x+=n,this.y+=t,this},offsetPoint:function(n){return this.offset(n.x,n.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}};n.Circle.prototype.constructor=n.Circle;Object.defineProperty(n.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(n){n>0&&(this._diameter=n,this._radius=.5*n)}});Object.defineProperty(n.Circle.prototype,"radius",{get:function(){return this._radius},set:function(n){n>0&&(this._radius=n,this._diameter=2*n)}});Object.defineProperty(n.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(n){n>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-n}});Object.defineProperty(n.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(n){n<this.x?(this._radius=0,this._diameter=0):this.radius=n-this.x}});Object.defineProperty(n.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(n){n>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-n}});Object.defineProperty(n.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(n){n<this.y?(this._radius=0,this._diameter=0):this.radius=n-this.y}});Object.defineProperty(n.Circle.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0}});Object.defineProperty(n.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(n){!0===n&&this.setTo(0,0,0)}});n.Circle.contains=function(n,t,i){return n.radius>0&&t>=n.left&&t<=n.right&&i>=n.top&&i<=n.bottom&&(n.x-t)*(n.x-t)+(n.y-i)*(n.y-i)<=n.radius*n.radius};n.Circle.equals=function(n,t){return n.x===t.x&&n.y===t.y&&n.diameter===t.diameter};n.Circle.intersects=function(t,i){return n.Math.distance(t.x,t.y,i.x,i.y)<=t.radius+i.radius};n.Circle.circumferencePoint=function(t,i,r,u){return void 0===r&&(r=!1),void 0===u&&(u=new n.Point),!0===r&&(i=n.Math.degToRad(i)),u.x=t.x+t.radius*Math.cos(i),u.y=t.y+t.radius*Math.sin(i),u};n.Circle.intersectsRectangle=function(n,t){var r=Math.abs(n.x-t.x-t.halfWidth),i,u,f;return r>t.halfWidth+n.radius?!1:(i=Math.abs(n.y-t.y-t.halfHeight),i>t.halfHeight+n.radius)?!1:r<=t.halfWidth||i<=t.halfHeight?!0:(u=r-t.halfWidth,f=i-t.halfHeight,u*u+f*f<=n.radius*n.radius)};n.Circle.intersectsLine=function(t,i,r){var a=t.x,o=t.y,u=(i.end.y-i.start.y)/(i.end.x-i.start.x),h=i.end.y-u*i.end.x,f=t.radius,e=t.radius,s=h+u*a,v=(a*e*e-u*f*f*(h-o)+f*e*Math.sqrt(f*f*u*u+e*e-s*s-o*o+2*s*o))/(f*f*u*u+e*e),y=(a*e*e-u*f*f*(h-o)-f*e*Math.sqrt(f*f*u*u+e*e-s*s-o*o+2*s*o))/(f*f*u*u+e*e),b=u*v+h,k=u*y+h,c=new n.Point(v,b),l=new n.Point(y,k),p=i.pointOnSegment(c.x,c.y,.01),w=i.pointOnSegment(l.x,l.y,.01);return p&&w?!r||[c,l]:p?!r||[c]:w?!r||[l]:!!r&&[]};PIXI.Circle=n.Circle;n.Ellipse=function(t,i,r,u){t=t||0;i=i||0;r=r||0;u=u||0;this.x=t;this.y=i;this.width=r;this.height=u;this.type=n.ELLIPSE};n.Ellipse.prototype={setTo:function(n,t,i,r){return this.x=n,this.y=t,this.width=i,this.height=r,this},getBounds:function(){return new n.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(n){return this.setTo(n.x,n.y,n.width,n.height)},copyTo:function(n){return n.x=this.x,n.y=this.y,n.width=this.width,n.height=this.height,n},clone:function(t){return void 0===t||null===t?t=new n.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,i){return n.Ellipse.contains(this,t,i)},random:function(t){void 0===t&&(t=new n.Point);var i=Math.random()*Math.PI*2,r=Math.sqrt(Math.random());return t.x=this.centerX+.5*r*Math.cos(i)*this.width,t.y=this.centerY+.5*r*Math.sin(i)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}};n.Ellipse.prototype.constructor=n.Ellipse;Object.defineProperty(n.Ellipse.prototype,"left",{get:function(){return this.x},set:function(n){this.x=n}});Object.defineProperty(n.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(n){this.width=n<this.x?0:n-this.x}});Object.defineProperty(n.Ellipse.prototype,"top",{get:function(){return this.y},set:function(n){this.y=n}});Object.defineProperty(n.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(n){this.height=n<this.y?0:n-this.y}});Object.defineProperty(n.Ellipse.prototype,"centerX",{get:function(){return this.x+.5*this.width}});Object.defineProperty(n.Ellipse.prototype,"centerY",{get:function(){return this.y+.5*this.height}});Object.defineProperty(n.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(n){!0===n&&this.setTo(0,0,0,0)}});n.Ellipse.contains=function(n,t,i){if(n.width<=0||n.height<=0)return!1;var r=(t-n.x)/n.width-.5,u=(i-n.y)/n.height-.5;return r*=r,u*=u,r+u<.25};n.Ellipse.intersectsLine=function(t,i,r){var a=t.x,o=t.y,u=(i.end.y-i.start.y)/(i.end.x-i.start.x),h=i.end.y-u*i.end.x,f=t.width/2,e=t.height/2,s=h+u*a,v=(a*e*e-u*f*f*(h-o)+f*e*Math.sqrt(f*f*u*u+e*e-s*s-o*o+2*s*o))/(f*f*u*u+e*e),y=(a*e*e-u*f*f*(h-o)-f*e*Math.sqrt(f*f*u*u+e*e-s*s-o*o+2*s*o))/(f*f*u*u+e*e),b=u*v+h,k=u*y+h,c=new n.Point(v,b),l=new n.Point(y,k),p=i.pointOnSegment(c.x,c.y,.01),w=i.pointOnSegment(l.x,l.y,.01);return p&&w?!r||[c,l]:p?!r||[c]:w?!r||[l]:!!r&&[]};PIXI.Ellipse=n.Ellipse;n.Line=function(t,i,r,u){t=t||0;i=i||0;r=r||0;u=u||0;this.start=new n.Point(t,i);this.end=new n.Point(r,u);this.type=n.LINE};n.Line.prototype={setTo:function(n,t,i,r){return this.start.setTo(n,t),this.end.setTo(i,r),this},fromPoints:function(n,t){return this.setTo(n.x,n.y,t.x,t.y),this},fromSprite:function(n,t,i){return void 0===i&&(i=!1),i?this.setTo(n.centerX,n.centerY,t.centerX,t.centerY):this.fromPoints(n,t)},fromAngle:function(n,t,i,r){return this.start.setTo(n,t),this.end.setTo(n+Math.cos(i)*r,t+Math.sin(i)*r),this},rotate:function(n,t){var i=(this.start.x+this.end.x)/2,r=(this.start.y+this.end.y)/2;return this.start.rotate(i,r,n,t),this.end.rotate(i,r,n,t),this},rotateAround:function(n,t,i,r){return this.start.rotate(n,t,i,r),this.end.rotate(n,t,i,r),this},intersects:function(t,i,r){return n.Line.intersectsPoints(this.start,this.end,t.start,t.end,i,r)},reflect:function(t){return n.Line.reflect(this,t)},midPoint:function(t){return void 0===t&&(t=new n.Point),t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t},centerOn:function(n,t){var i=n-(this.start.x+this.end.x)/2,r=t-(this.start.y+this.end.y)/2;this.start.add(i,r);this.end.add(i,r)},pointOnLine:function(t,i,r){return n.Math.fuzzyEqual((t-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(i-this.start.y),r||0)},pointOnSegment:function(n,t,i){var r=Math.min(this.start.x,this.end.x),u=Math.max(this.start.x,this.end.x),f=Math.min(this.start.y,this.end.y),e=Math.max(this.start.y,this.end.y);return this.pointOnLine(n,t,i)&&n>=r&&n<=u&&t>=f&&t<=e},random:function(t){void 0===t&&(t=new n.Point);var i=Math.random();return t.x=this.start.x+i*(this.end.x-this.start.x),t.y=this.start.y+i*(this.end.y-this.start.y),t},coordinatesOnLine:function(n,t){var h,c;void 0===n&&(n=1);void 0===t&&(t=[]);var i=Math.round(this.start.x),r=Math.round(this.start.y),u=Math.round(this.end.x),f=Math.round(this.end.y),e=Math.abs(u-i),o=Math.abs(f-r),l=i<u?1:-1,a=r<f?1:-1,s=e-o;for(t.push([i,r]),h=1;i!==u||r!==f;)c=s<<1,c>-o&&(s-=o,i+=l),c<e&&(s+=e,r+=a),h%n==0&&t.push([i,r]),h++;return t},clone:function(t){return void 0===t||null===t?t=new n.Line(this.start.x,this.start.y,this.end.x,this.end.y):t.setTo(this.start.x,this.start.y,this.end.x,this.end.y),t}};Object.defineProperty(n.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}});Object.defineProperty(n.Line.prototype,"angle",{get:function(){return n.Point.angle(this.end,this.start)}});Object.defineProperty(n.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}});Object.defineProperty(n.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}});Object.defineProperty(n.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}});Object.defineProperty(n.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}});Object.defineProperty(n.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}});Object.defineProperty(n.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}});Object.defineProperty(n.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}});Object.defineProperty(n.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}});Object.defineProperty(n.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}});Object.defineProperty(n.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}});Object.defineProperty(n.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}});Object.defineProperty(n.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}});Object.defineProperty(n.Line.prototype,"normalAngle",{get:function(){return n.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}});n.Line.intersectsPoints=function(t,i,r,u,f,e){void 0===f&&(f=!0);void 0===e&&(e=new n.Point);var s=i.y-t.y,h=u.y-r.y,c=t.x-i.x,l=r.x-u.x,a=i.x*t.y-t.x*i.y,v=u.x*r.y-r.x*u.y,o=s*l-h*c;if(0===o)return null;if(e.x=(c*v-l*a)/o,e.y=(h*a-s*v)/o,f){var y=(u.y-r.y)*(i.x-t.x)-(u.x-r.x)*(i.y-t.y),p=((u.x-r.x)*(t.y-r.y)-(u.y-r.y)*(t.x-r.x))/y,w=((i.x-t.x)*(t.y-r.y)-(i.y-t.y)*(t.x-r.x))/y;return p>=0&&p<=1&&w>=0&&w<=1?e:null}return e};n.Line.intersects=function(t,i,r,u){return n.Line.intersectsPoints(t.start,t.end,i.start,i.end,r,u)};n.Line.intersectsRectangle=function(n,t){if(0===n.length||t.empty)return!1;var i=n.start.x,r=n.start.y,u=n.end.x,f=n.end.y,o=t.x,s=t.y,h=t.right,c=t.bottom,e=0;if(i>=o&&i<=h&&r>=s&&r<=c||u>=o&&u<=h&&f>=s&&f<=c)return!0;if(i<o&&u>=o){if((e=r+(f-r)*(o-i)/(u-i))>s&&e<=c)return!0}else if(i>h&&u<=h&&(e=r+(f-r)*(h-i)/(u-i))>=s&&e<=c)return!0;if(r<s&&f>=s){if((e=i+(u-i)*(s-r)/(f-r))>=o&&e<=h)return!0}else if(r>c&&f<=c&&(e=i+(u-i)*(c-r)/(f-r))>=o&&e<=h)return!0;return!1};n.Line.intersectionWithRectangle=function(t,i,r){var u=n.Line.intersectionWithRectangle,y,a,c;r||(r=new n.Point);u.edges||(u.edges=[new n.Line,new n.Line,new n.Line,new n.Line]);u.edgeIntersection||(u.edgeIntersection=new n.Point);var f=u.edges,l=u.edgeIntersection.set(0),e=i.x,o=i.y,s=i.right,h=i.bottom,v=1/0;for(f[0].setTo(e,o,s,o),f[1].setTo(e,h,s,h),f[2].setTo(e,o,e,h),f[3].setTo(s,o,s,h),a=0;y=f[a];a++)t.intersects(y,!0,l)&&(c=t.start.distance(l),c<v&&(v=c,r.copyFrom(l)));return null!=c?r:null};n.Line.reflect=function(n,t){return 2*t.normalAngle-3.1415926535897931-n.angle};n.Matrix=function(t,i,r,u,f,e){void 0!==t&&null!==t||(t=1);void 0!==i&&null!==i||(i=0);void 0!==r&&null!==r||(r=0);void 0!==u&&null!==u||(u=1);void 0!==f&&null!==f||(f=0);void 0!==e&&null!==e||(e=0);this.a=t;this.b=i;this.c=r;this.d=u;this.tx=f;this.ty=e;this.type=n.MATRIX};n.Matrix.prototype={fromArray:function(n){return this.setTo(n[0],n[1],n[3],n[4],n[2],n[5])},setTo:function(n,t,i,r,u,f){return this.a=n,this.b=t,this.c=i,this.d=r,this.tx=u,this.ty=f,this},clone:function(t){return void 0===t||null===t?t=new n.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty),t},copyTo:function(n){return n.copyFrom(this),n},copyFrom:function(n){return this.a=n.a,this.b=n.b,this.c=n.c,this.d=n.d,this.tx=n.tx,this.ty=n.ty,this},toArray:function(n,t){return void 0===t&&(t=new Float32Array(9)),n?(t[0]=this.a,t[1]=this.b,t[2]=0,t[3]=this.c,t[4]=this.d,t[5]=0,t[6]=this.tx,t[7]=this.ty,t[8]=1):(t[0]=this.a,t[1]=this.c,t[2]=this.tx,t[3]=this.b,t[4]=this.d,t[5]=this.ty,t[6]=0,t[7]=0,t[8]=1),t},apply:function(t,i){return void 0===i&&(i=new n.Point),i.x=this.a*t.x+this.c*t.y+this.tx,i.y=this.b*t.x+this.d*t.y+this.ty,i},applyInverse:function(t,i){void 0===i&&(i=new n.Point);var r=1/(this.a*this.d+this.c*-this.b),u=t.x,f=t.y;return i.x=this.d*r*u+-this.c*r*f+(this.ty*this.c-this.tx*this.d)*r,i.y=this.a*r*f+-this.b*r*u+(-this.ty*this.a+this.tx*this.b)*r,i},translate:function(n,t){return this.tx+=n,this.ty+=t,this},scale:function(n,t){return this.a*=n,this.d*=t,this.c*=n,this.b*=t,this.tx*=n,this.ty*=t,this},rotate:function(n){var t=Math.cos(n),i=Math.sin(n),r=this.a,u=this.c,f=this.tx;return this.a=r*t-this.b*i,this.b=r*i+this.b*t,this.c=u*t-this.d*i,this.d=u*i+this.d*t,this.tx=f*t-this.ty*i,this.ty=f*i+this.ty*t,this},append:function(n){var t=this.a,i=this.b,r=this.c,u=this.d;return this.a=n.a*t+n.b*r,this.b=n.a*i+n.b*u,this.c=n.c*t+n.d*r,this.d=n.c*i+n.d*u,this.tx=n.tx*t+n.ty*r+this.tx,this.ty=n.tx*i+n.ty*u+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}};n.identityMatrix=new n.Matrix;n.Point=function(t,i){t=t||0;i=i||0;this.x=t;this.y=i;this.type=n.POINT};n.Point.prototype={copyFrom:function(n){return this.setTo(n.x,n.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,i){return n.Point.set(this,t,i)},set:function(t,i){return n.Point.set(this,t,i)},setToPolar:function(t,i,r){return null==i&&(i=1),r&&(t=n.Math.degToRad(t)),this.setTo(Math.cos(t)*i,Math.sin(t)*i)},add:function(n,t){return this.x+=n,this.y+=t,this},subtract:function(n,t){return this.x-=n,this.y-=t,this},multiply:function(n,t){return this.x*=n,this.y*=t,this},divide:function(n,t){return this.x/=n,this.y/=t,this},clampX:function(t,i){return this.x=n.Math.clamp(this.x,t,i),this},clampY:function(t,i){return this.y=n.Math.clamp(this.y,t,i),this},clamp:function(t,i){return this.x=n.Math.clamp(this.x,t,i),this.y=n.Math.clamp(this.y,t,i),this},clip:function(n){var t=n.left,i=n.top,r=n.right,u=n.bottom;return this.x<t?this.x=t:this.x>r&&(this.x=r),this.y<i?this.y=i:this.y>u&&(this.y=u),this},clone:function(t){return void 0===t||null===t?t=new n.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(n){return n.x=this.x,n.y=this.y,n},distance:function(t,i){return n.Point.distance(this,t,i)},equals:function(n){return n.x===this.x&&n.y===this.y},equalsXY:function(n,t){return this.x===n&&this.y===t},fuzzyEquals:function(t,i){return n.Point.fuzzyEquals(this,t,i)},fuzzyEqualsXY:function(t,i,r){return n.Point.fuzzyEqualsXY(this,t,i,r)},angle:function(n,t){return this.angleXY(n.x,n.y,t)},angleXY:function(t,i,r){var u=Math.atan2(i-this.y,t-this.x);return r?n.Math.radToDeg(u):u},atan:function(t){var i=Math.atan2(this.y,this.x);return t?n.Math.radToDeg(i):i},rotate:function(t,i,r,u,f){return n.Point.rotate(this,t,i,r,u,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(n){return this.normalize().multiply(n,n)},normalize:function(){if(!this.isZero()){var n=this.getMagnitude();this.x/=n;this.y/=n}return this},limit:function(n){return this.getMagnitudeSq()>n*n&&this.setMagnitude(n),this},expand:function(n){return this.getMagnitudeSq()<n*n&&this.setMagnitude(n),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(n){return this.x*n.x+this.y*n.y},cross:function(n){return this.x*n.y-this.y*n.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},round:function(){return this.setTo(Math.round(this.x),Math.round(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};n.Point.prototype.constructor=n.Point;n.Point.add=function(t,i,r){return void 0===r&&(r=new n.Point),r.x=t.x+i.x,r.y=t.y+i.y,r};n.Point.subtract=function(t,i,r){return void 0===r&&(r=new n.Point),r.x=t.x-i.x,r.y=t.y-i.y,r};n.Point.multiply=function(t,i,r){return void 0===r&&(r=new n.Point),r.x=t.x*i.x,r.y=t.y*i.y,r};n.Point.divide=function(t,i,r){return void 0===r&&(r=new n.Point),r.x=t.x/i.x,r.y=t.y/i.y,r};n.Point.equals=function(n,t){return n.x===t.x&&n.y===t.y};n.Point.equalsXY=function(n,t,i){return n.x===t&&n.y===i};n.Point.fuzzyEquals=function(t,i,r){return n.Math.fuzzyEqual(t.x,i.x,r)&&n.Math.fuzzyEqual(t.y,i.y,r)};n.Point.fuzzyEqualsXY=function(t,i,r,u){return n.Math.fuzzyEqual(t.x,i,u)&&n.Math.fuzzyEqual(t.y,r,u)};n.Point.angle=function(n,t){return Math.atan2(n.y-t.y,n.x-t.x)};n.Point.negative=function(t,i){return void 0===i&&(i=new n.Point),i.setTo(-t.x,-t.y)};n.Point.multiplyAdd=function(t,i,r,u){return void 0===u&&(u=new n.Point),u.setTo(t.x+i.x*r,t.y+i.y*r)};n.Point.interpolate=function(t,i,r,u){return void 0===u&&(u=new n.Point),u.setTo(t.x+(i.x-t.x)*r,t.y+(i.y-t.y)*r)};n.Point.perp=function(t,i){return void 0===i&&(i=new n.Point),i.setTo(-t.y,t.x)};n.Point.rperp=function(t,i){return void 0===i&&(i=new n.Point),i.setTo(t.y,-t.x)};n.Point.distance=function(t,i,r){var u=n.Math.distance(t.x,t.y,i.x,i.y);return r?Math.round(u):u};n.Point.project=function(t,i,r){void 0===r&&(r=new n.Point);var u=t.dot(i)/i.getMagnitudeSq();return 0!==u&&r.setTo(u*i.x,u*i.y),r};n.Point.projectUnit=function(t,i,r){void 0===r&&(r=new n.Point);var u=t.dot(i);return 0!==u&&r.setTo(u*i.x,u*i.y),r};n.Point.normalRightHand=function(t,i){return void 0===i&&(i=new n.Point),i.setTo(-1*t.y,t.x)};n.Point.normalize=function(t,i){void 0===i&&(i=new n.Point);var r=t.getMagnitude();return 0!==r&&i.setTo(t.x/r,t.y/r),i};n.Point.rotate=function(t,i,r,u,f,e){var o;if(f&&(u=n.Math.degToRad(u)),void 0===e){t.subtract(i,r);var s=Math.sin(u),h=Math.cos(u),c=h*t.x-s*t.y,l=s*t.x+h*t.y;t.x=c+i;t.y=l+r}else o=u+Math.atan2(t.y-r,t.x-i),t.x=i+e*Math.cos(o),t.y=r+e*Math.sin(o);return t};n.Point.centroid=function(t,i){var r,u;if(void 0===i&&(i=new n.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");if(r=t.length,r<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===r)return i.copyFrom(t[0]),i;for(u=0;u<r;u++)n.Point.add(i,t[u],i);return i.divide(r,r),i};n.Point.parse=function(t,i,r){i=i||"x";r=r||"y";var u=new n.Point;return t[i]&&(u.x=parseFloat(t[i])),t[r]&&(u.y=parseFloat(t[r])),u};n.Point.trunc=function(t){return t.x=n.Math.trunc(t.x),t.y=n.Math.trunc(t.y),t};n.Point.isPoint=function(n){return null!=n&&"number"==typeof n.x&&"number"==typeof n.y};n.Point.set=function(n,t,i){return n.x=t||0,n.y=i||(0!==i?n.x:0),n};n.Point.sortClockwise=function(n,t){t||(t=this.centroid(n));var i=t.x,r=t.y;return n.sort(function(n,t){if(n.x-i>=0&&t.x-i<0)return-1;if(n.x-i<0&&t.x-i>=0)return 1;if(n.x-i==0&&t.x-i==0)return n.y-r>=0||t.y-r>=0?n.y>t.y?1:-1:t.y>n.y?1:-1;var u=(n.x-i)*-(t.y-r)-(t.x-i)*-(n.y-r);return u<0?-1:u>0?1:(n.x-i)*(n.x-i)+(n.y-r)*(n.y-r)>(t.x-i)*(t.x-i)+(t.y-r)*(t.y-r)?-1:1})};PIXI.Point=n.Point;n.Polygon=function(){this.area=0;this._points=[];arguments.length>0&&this.setTo.apply(this,arguments);this.closed=!0;this.flattened=!1;this.type=n.POLYGON};n.Polygon.prototype={toNumberArray:function(n){void 0===n&&(n=[]);for(var t=0;t<this._points.length;t++)"number"==typeof this._points[t]?(n.push(this._points[t]),n.push(this._points[t+1]),t++):(n.push(this._points[t].x),n.push(this._points[t].y));return n},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(t){var i=this._points.slice();return void 0===t||null===t?t=new n.Polygon(i):t.setTo(i),t},contains:function(n,t){var e=!1,i,r;if(this.flattened)for(i=-2,r=this._points.length-2;(i+=2)<this._points.length;r=i){var o=this._points[i],u=this._points[i+1],s=this._points[r],f=this._points[r+1];(u<=t&&t<f||f<=t&&t<u)&&n<(s-o)*(t-u)/(f-u)+o&&(e=!e)}else for(i=-1,r=this._points.length-1;++i<this._points.length;r=i){var o=this._points[i].x,u=this._points[i].y,s=this._points[r].x,f=this._points[r].y;(u<=t&&t<f||f<=t&&t<u)&&n<(s-o)*(t-u)/(f-u)+o&&(e=!e)}return e},setTo:function(n){var i;if(this.area=0,this._points=[],arguments.length>0){Array.isArray(n)||(n=Array.prototype.slice.call(arguments));for(var r=Number.MAX_VALUE,t=0,u=n.length;t<u;t++)"number"==typeof n[t]?(i=new PIXI.Point(n[t],n[t+1]),t++):i=Array.isArray(n[t])?new PIXI.Point(n[t][0],n[t][1]):new PIXI.Point(n[t].x,n[t].y),this._points.push(i),i.y<r&&(r=i.y);this.calculateArea(r)}return this},calculateArea:function(n){for(var i,r,u,f,t=0,e=this._points.length;t<e;t++)i=this._points[t],r=t===e-1?this._points[0]:this._points[t+1],u=(i.y-n+(r.y-n))/2,f=i.x-r.x,this.area+=u*f;return this.area}};n.Polygon.prototype.constructor=n.Polygon;Object.defineProperty(n.Polygon.prototype,"points",{get:function(){return this._points}});PIXI.Polygon=n.Polygon;n.Rectangle=function(t,i,r,u){t=t||0;i=i||0;r=r||0;u=u||0;this.x=t;this.y=i;this.width=r;this.height=u;this.type=n.RECTANGLE};n.Rectangle.prototype={offset:function(n,t){return this.x+=n,this.y+=t,this},offsetPoint:function(n){return this.offset(n.x,n.y)},setTo:function(n,t,i,r){return this.x=n,this.y=t,this.width=i,this.height=r,this},scale:function(n,t){return void 0===t&&(t=n),this.width*=n,this.height*=t,this},centerOn:function(n,t){return this.centerX=n,this.centerY=t,this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.width=Math.floor(this.width);this.height=Math.floor(this.height)},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.width=Math.ceil(this.width);this.height=Math.ceil(this.height)},copyFrom:function(n){return this.setTo(n.x,n.y,n.width,n.height)},copyFromBounds:function(n){return this.setTo(n.left,n.top,n.width,n.height)},copyTo:function(n){return n.x=this.x,n.y=this.y,n.width=this.width,n.height=this.height,n},inflate:function(t,i){return n.Rectangle.inflate(this,t,i)},size:function(t){return n.Rectangle.size(this,t)},resize:function(n,t){return this.width=n,this.height=t,this},clone:function(t){return n.Rectangle.clone(this,t)},contains:function(t,i){return n.Rectangle.contains(this,t,i)},containsRect:function(t){return n.Rectangle.containsRect(t,this)},equals:function(t){return n.Rectangle.equals(this,t)},intersection:function(t,i){return n.Rectangle.intersection(this,t,i)},intersects:function(t){return n.Rectangle.intersects(this,t)},intersectsRaw:function(t,i,r,u,f){return n.Rectangle.intersectsRaw(this,t,i,r,u,f)},union:function(t,i){return n.Rectangle.union(this,t,i)},random:function(t){return void 0===t&&(t=new n.Point),t.x=this.randomX,t.y=this.randomY,t},getPoint:function(t,i){switch(void 0===i&&(i=new n.Point),t){default:case n.TOP_LEFT:return i.set(this.x,this.y);case n.TOP_CENTER:return i.set(this.centerX,this.y);case n.TOP_RIGHT:return i.set(this.right,this.y);case n.LEFT_CENTER:return i.set(this.x,this.centerY);case n.CENTER:return i.set(this.centerX,this.centerY);case n.RIGHT_CENTER:return i.set(this.right,this.centerY);case n.BOTTOM_LEFT:return i.set(this.x,this.bottom);case n.BOTTOM_CENTER:return i.set(this.centerX,this.bottom);case n.BOTTOM_RIGHT:return i.set(this.right,this.bottom)}},sides:function(t,i,r,u){arguments.length||(t=new n.Line,i=new n.Line,r=new n.Line,u=new n.Line);var f=this.x,e=this.y,o=this.right,s=this.bottom;return t.setTo(f,e,o,e),i.setTo(o,e,o,s),r.setTo(f,s,o,s),u.setTo(f,e,f,s),arguments.length?null:[t,i,r,u]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(n.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}});Object.defineProperty(n.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}});Object.defineProperty(n.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(n){this.height=n<=this.y?0:n-this.y}});Object.defineProperty(n.Rectangle.prototype,"bottomLeft",{get:function(){return new n.Point(this.x,this.bottom)},set:function(n){this.x=n.x;this.bottom=n.y}});Object.defineProperty(n.Rectangle.prototype,"bottomRight",{get:function(){return new n.Point(this.right,this.bottom)},set:function(n){this.right=n.x;this.bottom=n.y}});Object.defineProperty(n.Rectangle.prototype,"left",{get:function(){return this.x},set:function(n){this.width=n>=this.right?0:this.right-n;this.x=n}});Object.defineProperty(n.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(n){this.width=n<=this.x?0:n-this.x}});Object.defineProperty(n.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(n.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}});Object.defineProperty(n.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(n){this.x=n-this.halfWidth}});Object.defineProperty(n.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(n){this.y=n-this.halfHeight}});Object.defineProperty(n.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}});Object.defineProperty(n.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}});Object.defineProperty(n.Rectangle.prototype,"top",{get:function(){return this.y},set:function(n){n>=this.bottom?(this.height=0,this.y=n):this.height=this.bottom-n}});Object.defineProperty(n.Rectangle.prototype,"topLeft",{get:function(){return new n.Point(this.x,this.y)},set:function(n){this.x=n.x;this.y=n.y}});Object.defineProperty(n.Rectangle.prototype,"topRight",{get:function(){return new n.Point(this.x+this.width,this.y)},set:function(n){this.right=n.x;this.y=n.y}});Object.defineProperty(n.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(n){!0===n&&this.setTo(0,0,0,0)}});n.Rectangle.prototype.constructor=n.Rectangle;n.Rectangle.inflate=function(n,t,i){return n.x-=t,n.width+=2*t,n.y-=i,n.height+=2*i,n};n.Rectangle.inflatePoint=function(t,i){return n.Rectangle.inflate(t,i.x,i.y)};n.Rectangle.size=function(t,i){return void 0===i||null===i?i=new n.Point(t.width,t.height):i.setTo(t.width,t.height),i};n.Rectangle.clone=function(t,i){return void 0===i||null===i?i=new n.Rectangle(t.x,t.y,t.width,t.height):i.setTo(t.x,t.y,t.width,t.height),i};n.Rectangle.createFromBounds=function(t,i){return void 0!==i&&null!==i||(i=new n.Rectangle(t.x,t.y,t.width,t.height)),i.copyFromBounds(t)};n.Rectangle.contains=function(n,t,i){return!(n.width<=0||n.height<=0)&&t>=n.x&&t<n.right&&i>=n.y&&i<n.bottom};n.Rectangle.containsRaw=function(n,t,i,r,u,f){return u>=n&&u<n+i&&f>=t&&f<t+r};n.Rectangle.containsPoint=function(t,i){return n.Rectangle.contains(t,i.x,i.y)};n.Rectangle.containsRect=function(n,t){return!(n.volume>t.volume)&&n.x>=t.x&&n.y>=t.y&&n.right<t.right&&n.bottom<t.bottom};n.Rectangle.equals=function(n,t){return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height};n.Rectangle.sameDimensions=function(n,t){return n.width===t.width&&n.height===t.height};n.Rectangle.intersection=function(t,i,r){return void 0===r&&(r=new n.Rectangle),n.Rectangle.intersects(t,i)&&(r.x=Math.max(t.x,i.x),r.y=Math.max(t.y,i.y),r.width=Math.min(t.right,i.right)-r.x,r.height=Math.min(t.bottom,i.bottom)-r.y),r};n.Rectangle.intersects=function(n,t){return!(n.width<=0||n.height<=0||t.width<=0||t.height<=0)&&!(n.right<t.x||n.bottom<t.y||n.x>t.right||n.y>t.bottom)};n.Rectangle.intersectsRaw=function(n,t,i,r,u,f){return void 0===f&&(f=0),!(t>n.right+f||i<n.left-f||r>n.bottom+f||u<n.top-f)};n.Rectangle.union=function(t,i,r){return void 0===r&&(r=new n.Rectangle),r.setTo(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.max(t.right,i.right)-Math.min(t.left,i.left),Math.max(t.bottom,i.bottom)-Math.min(t.top,i.top))};n.Rectangle.aabb=function(t,i){void 0===i&&(i=new n.Rectangle);var f=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;return t.forEach(function(n){n.x>f&&(f=n.x);n.x<r&&(r=n.x);n.y>e&&(e=n.y);n.y<u&&(u=n.y)}),i.setTo(r,u,f-r,e-u),i};PIXI.Rectangle=n.Rectangle;n.EmptyRectangle=new n.Rectangle(0,0,0,0);n.RoundedRectangle=function(t,i,r,u,f){void 0===t&&(t=0);void 0===i&&(i=0);void 0===r&&(r=0);void 0===u&&(u=0);void 0===f&&(f=20);this.x=t;this.y=i;this.width=r;this.height=u;this.radius=f||20;this.type=n.ROUNDEDRECTANGLE};n.RoundedRectangle.prototype={clone:function(){return new n.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(n,t){var i,r;return this.width<=0||this.height<=0?!1:(i=this.x,n>=i&&n<=i+this.width&&(r=this.y,t>=r&&t<=r+this.height))?!0:!1}};n.RoundedRectangle.prototype.constructor=n.RoundedRectangle;PIXI.RoundedRectangle=n.RoundedRectangle;n.Camera=function(t,i,r,u,f,e){this.game=t;this.world=t.world;this.id=0;this.view=new n.Rectangle(r,u,f,e);this.bounds=new n.Rectangle(r,u,f,e);this.deadzone=null;this.visible=!0;this.roundPx=!0;this.atLimit={x:!1,y:!1};this.target=null;this.displayObject=null;this.scale=null;this.totalInView=0;this.lerp=new n.Point(1,1);this.onShakeComplete=new n.Signal;this.onFlashComplete=new n.Signal;this.onFadeComplete=new n.Signal;this.fx=null;this._targetPosition=new n.Point;this._edge=0;this._position=new n.Point;this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0};this._fxDuration=0;this._fxType=0;this._fixedView=new n.Rectangle};n.Camera.FOLLOW_LOCKON=0;n.Camera.FOLLOW_PLATFORMER=1;n.Camera.FOLLOW_TOPDOWN=2;n.Camera.FOLLOW_TOPDOWN_TIGHT=3;n.Camera.SHAKE_BOTH=4;n.Camera.SHAKE_HORIZONTAL=5;n.Camera.SHAKE_VERTICAL=6;n.Camera.ENABLE_FX=!0;n.Camera.prototype={boot:function(){this.displayObject=this.game.world;this.scale=this.game.world.scale;this.game.camera=this;n.Graphics&&n.Camera.ENABLE_FX&&(this.fx=new n.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,i,r,u){var f,o,e;void 0===i&&(i=n.Camera.FOLLOW_LOCKON);void 0===r&&(r=1);void 0===u&&(u=1);this.target=t;this.lerp.set(r,u);switch(i){case n.Camera.FOLLOW_PLATFORMER:o=this.width/8;e=this.height/3;this.deadzone=new n.Rectangle((this.width-o)/2,(this.height-e)/2-.25*e,o,e);break;case n.Camera.FOLLOW_TOPDOWN:f=Math.max(this.width,this.height)/4;this.deadzone=new n.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case n.Camera.FOLLOW_TOPDOWN_TIGHT:f=Math.max(this.width,this.height)/8;this.deadzone=new n.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case n.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(n){this.setPosition(Math.round(n.x-this.view.halfWidth),Math.round(n.y-this.view.halfHeight))},focusOnXY:function(n,t){this.setPosition(Math.round(n-this.view.halfWidth),Math.round(t-this.view.halfHeight))},shake:function(t,i,r,u,f){return void 0===t&&(t=.05),void 0===i&&(i=500),void 0===r&&(r=!0),void 0===u&&(u=n.Camera.SHAKE_BOTH),void 0===f&&(f=!0),!(!r&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=i,this._shake.shakeBounds=f,this._shake.x=0,this._shake.y=0,this._shake.horizontal=u===n.Camera.SHAKE_BOTH||u===n.Camera.SHAKE_HORIZONTAL,this._shake.vertical=u===n.Camera.SHAKE_BOTH||u===n.Camera.SHAKE_VERTICAL,!0)},flash:function(n,t,i,r){return void 0===n&&(n=16777215),void 0===t&&(t=500),void 0===i&&(i=!1),void 0===r&&(r=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(n,r),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=t,this._fxType=0,!0)},fade:function(n,t,i,r){return void 0===n&&(n=0),void 0===t&&(t=500),void 0===i&&(i=!1),void 0===r&&(r=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(n,r),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=t,this._fxType=1,!0)},update:function(){this._fxDuration>0&&this.updateFX();this._shake.duration>0&&this.updateShake();this.bounds&&this.checkBounds();this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y));this.displayObject.position.x=-this.view.x;this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha>=1&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS;this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x;this._targetPosition.y=this.view.y+this.target.worldPosition.y;this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y));this.bounds&&this.checkBounds();this.roundPx&&this.view.floor();this.displayObject.position.x=-this.view.x;this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1;this.atLimit.y=!1;var n=this.view.x+this._shake.x,t=this.view.right+this._shake.x,i=this.view.y+this._shake.y,r=this.view.bottom+this._shake.y;n<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):t>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0));i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):r>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(n,t){this.view.x=n;this.view.y=t;this.bounds&&this.checkBounds()},setSize:function(n,t){this.view.width=n;this.view.height=t},reset:function(){this.target=null;this.view.x=0;this.view.y=0;this._shake.duration=0;this._shake.x=0;this._shake.y=0;this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0);this._fxDuration=0}};n.Camera.prototype.constructor=n.Camera;Object.defineProperty(n.Camera.prototype,"x",{get:function(){return this.view.x},set:function(n){this.view.x=n;this.bounds&&this.checkBounds()}});Object.defineProperty(n.Camera.prototype,"y",{get:function(){return this.view.y},set:function(n){this.view.y=n;this.bounds&&this.checkBounds()}});Object.defineProperty(n.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(n){void 0!==n.x&&(this.view.x=n.x);void 0!==n.y&&(this.view.y=n.y);this.bounds&&this.checkBounds()}});Object.defineProperty(n.Camera.prototype,"width",{get:function(){return this.view.width},set:function(n){this.view.width=n}});Object.defineProperty(n.Camera.prototype,"height",{get:function(){return this.view.height},set:function(n){this.view.height=n}});Object.defineProperty(n.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(n){this._shake.intensity=n}});Object.defineProperty(n.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}});Object.defineProperty(n.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}});Object.defineProperty(n.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}});n.State=function(){this.game=null;this.key="";this.add=null;this.make=null;this.camera=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.sound=null;this.scale=null;this.stage=null;this.state=null;this.time=null;this.tweens=null;this.world=null;this.particles=null;this.physics=null;this.rnd=null};n.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}};n.State.prototype.constructor=n.State;n.StateManager=function(t,i){this.game=t;this.states={};this._pendingState=null;void 0!==i&&null!==i&&(this._pendingState=i);this._clearWorld=!1;this._clearCache=!1;this._created=!1;this._args=[];this.current="";this.onStateChange=new n.Signal;this.onInitCallback=null;this.onPreloadCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onResizeCallback=null;this.onPreRenderCallback=null;this.onLoadUpdateCallback=null;this.onLoadRenderCallback=null;this.onPausedCallback=null;this.onResumedCallback=null;this.onPauseUpdateCallback=null;this.onShutDownCallback=null};n.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this);this.game.onResume.add(this.resume,this);null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,i,r){void 0===r&&(r=!1);var u;return i instanceof n.State?u=i:"object"==typeof i?(u=i).game=this.game:"function"==typeof i&&(u=new i(this.game)),this.states[t]=u,r&&(this.game.isBooted?this.start(t):this._pendingState=t),u},remove:function(n){this.current===n&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null);delete this.states[n]},start:function(n,t,i){void 0===t&&(t=!0);void 0===i&&(i=!1);this.checkState(n)&&(this._pendingState=n,this._clearWorld=t,this._clearCache=i,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(n,t){void 0===n&&(n=!0);void 0===t&&(t=!1);this._pendingState=this.current;this._clearWorld=n;this._clearCache=t;arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var n=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,n),this.current!==this._pendingState)return;this._pendingState=null;this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(n){var t=this.states[n];return t?!!(t.preload||t.create||t.update||t.render)||(console.warn("Invalid Phaser State object given. Must contain at least one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+n),!1)},link:function(n){var t=this.states[n];t.game=this.game;t.add=this.game.add;t.make=this.game.make;t.camera=this.game.camera;t.cache=this.game.cache;t.input=this.game.input;t.load=this.game.load;t.math=this.game.math;t.sound=this.game.sound;t.scale=this.game.scale;t.state=this;t.stage=this.game.stage;t.time=this.game.time;t.tweens=this.game.tweens;t.world=this.game.world;t.particles=this.game.particles;t.rnd=this.game.rnd;t.physics=this.game.physics;t.key=n},unlink:function(n){var t=this.states[n];t&&(t.game=null,t.add=null,t.make=null,t.camera=null,t.cache=null,t.input=null,t.load=null,t.math=null,t.sound=null,t.scale=null,t.state=null,t.stage=null,t.time=null,t.tweens=null,t.world=null,t.particles=null,t.rnd=null,t.physics=null)},setCurrentState:function(n){var t=this.states[n];this.callbackContext=t;this.link(n);this.onInitCallback=t.init||this.dummy;this.onPreloadCallback=t.preload||null;this.onLoadRenderCallback=t.loadRender||null;this.onLoadUpdateCallback=t.loadUpdate||null;this.onCreateCallback=t.create||null;this.onUpdateCallback=t.update||null;this.onPostUpdateCallback=t.postUpdate||null;this.onPreRenderCallback=t.preRender||null;this.onRenderCallback=t.render||null;this.onResizeCallback=t.resize||null;this.onPausedCallback=t.paused||null;this.onResumedCallback=t.resumed||null;this.onPauseUpdateCallback=t.pauseUpdate||null;this.onShutDownCallback=t.shutdown||this.dummy;""!==this.current&&this.game.physics.reset();this.current=n;this._created=!1;this.onInitCallback.apply(this.callbackContext,this._args);n===this._pendingState&&(this._args=[]);this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},loadUpdate:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},postUpdate:function(){this._created&&this.onPostUpdateCallback&&this.onPostUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(n){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,n)},resize:function(n,t){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,n,t)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===n.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0;this._clearCache=!0;this.clearCurrentState();this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onPostUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onResumedCallback=null;this.onPauseUpdateCallback=null;this.game=null;this.states={};this._pendingState=null;this.current=""}};n.StateManager.prototype.constructor=n.StateManager;Object.defineProperty(n.StateManager.prototype,"created",{get:function(){return this._created}});n.Signal=function(){};n.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(n,t){if("function"!=typeof n)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",t));},_registerListener:function(t,i,r,u,f){var e,o=this._indexOfListener(t,r);if(-1!==o){if((e=this._bindings[o]).isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.");}else e=new n.SignalBinding(this,t,i,r,u,f),this._addBinding(e);return this.memorize&&this._prevParams&&e.execute(this._prevParams),e},_addBinding:function(n){this._bindings||(this._bindings=[]);var t=this._bindings.length;do t--;while(this._bindings[t]&&n._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,n)},_indexOfListener:function(n,t){if(!this._bindings)return-1;void 0===t&&(t=null);for(var r,i=this._bindings.length;i--;)if((r=this._bindings[i])._listener===n&&r.context===t)return i;return-1},has:function(n,t){return-1!==this._indexOfListener(n,t)},add:function(n,t,i){var u,r;if(this.validateListener(n,"add"),u=[],arguments.length>3)for(r=3;r<arguments.length;r++)u.push(arguments[r]);return this._registerListener(n,!1,t,i,u)},addOnce:function(n,t,i){var u,r;if(this.validateListener(n,"addOnce"),u=[],arguments.length>3)for(r=3;r<arguments.length;r++)u.push(arguments[r]);return this._registerListener(n,!0,t,i,u)},remove:function(n,t){this.validateListener(n,"remove");var i=this._indexOfListener(n,t);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),n},removeAll:function(n){if(void 0===n&&(n=null),this._bindings){for(var t=this._bindings.length;t--;)n?this._bindings[t].context===n&&(this._bindings[t]._destroy(),this._bindings.splice(t,1)):this._bindings[t]._destroy();n||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){var t,n,i;if(this.active&&(this._bindings||this.memorize)&&(t=Array.prototype.slice.call(arguments),this.memorize&&(this._prevParams=t),n=this._bindings?this._bindings.length:0,n)){i=this._bindings.slice();this._shouldPropagate=!0;do n--;while(i[n]&&this._shouldPropagate&&!1!==i[n].execute(t))}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll();this._bindings=null;this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Object.defineProperty(n.Signal.prototype,"boundDispatch",{get:function(){var n=this;return this._boundDispatch||(this._boundDispatch=function(){return n.dispatch.apply(n,arguments)})}});n.Signal.prototype.constructor=n.Signal;n.SignalBinding=function(n,t,i,r,u,f){this._listener=t;i&&(this._isOnce=!0);null!=r&&(this.context=r);this._signal=n;u&&(this._priority=u);f&&f.length&&(this._args=f)};n.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(n){var i,t;return this.active&&this._listener&&(t=this.params?this.params.concat(n):n,this._args&&(t=t.concat(this._args)),i=this._listener.apply(this.context,t),this.callCount++,this._isOnce&&this.detach()),i},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};n.SignalBinding.prototype.constructor=n.SignalBinding;n.Filter=function(t,i,r){var u,f;if(this.game=t,this.type=n.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new n.Point,u=new Date,this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[u.getFullYear(),u.getMonth(),u.getDate(),3600*u.getHours()+60*u.getMinutes()+u.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},i)for(f in i)this.uniforms[f]=i[f];"string"==typeof r&&(r=r.split("\n"));this.fragmentSrc=r||[]};n.Filter.prototype={init:function(){},setResolution:function(n,t){this.uniforms.resolution.value.x=n;this.uniforms.resolution.value.y=t},update:function(n){if(n){var t=n.x/this.game.width,i=1-n.y/this.game.height;t===this.prevPoint.x&&i===this.prevPoint.y||(this.uniforms.mouse.value.x=t.toFixed(2),this.uniforms.mouse.value.y=i.toFixed(2),this.prevPoint.set(t,i))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(t,i,r,u,f,e){void 0===f&&(f=0);void 0===e&&(e=0);void 0!==r&&null!==r?this.width=r:r=this.width;void 0!==u&&null!==u?this.height=u:u=this.height;var o=this.game.add.image(t,i,n.Cache.DEFAULT);return o.width=r,o.height=u,o.anchor.set(f,e),o.filters=[this],o},syncUniforms:function(){for(var n=0;n<this.shaders.length;n++)this.shaders[n].dirty=!0},destroy:function(){this.passes.length=0;this.shaders.length=0;this.fragmentSrc.length=0;this.game=null;this.uniforms=null;this.prevPoint=null}};n.Filter.prototype.constructor=n.Filter;Object.defineProperty(n.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(n){this.uniforms.resolution.value.x=n}});Object.defineProperty(n.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(n){this.uniforms.resolution.value.y=n}});n.Plugin=function(n,t){void 0===t&&(t=null);this.game=n;this.parent=t;this.active=!1;this.visible=!1;this.hasPreUpdate=!1;this.hasUpdate=!1;this.hasPostUpdate=!1;this.hasRender=!1;this.hasPostRender=!1};n.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=!1;this.visible=!1}};n.Plugin.prototype.constructor=n.Plugin;n.PluginManager=function(n){this.game=n;this.plugins=[];this._len=0;this._i=0};n.PluginManager.prototype={add:function(n){var i=Array.prototype.slice.call(arguments,1),t=!1;return"function"==typeof n?n=new n(this.game,this):(n.game=this.game,n.parent=this),"function"==typeof n.preUpdate&&(n.hasPreUpdate=!0,t=!0),"function"==typeof n.update&&(n.hasUpdate=!0,t=!0),"function"==typeof n.postUpdate&&(n.hasPostUpdate=!0,t=!0),"function"==typeof n.render&&(n.hasRender=!0,t=!0),"function"==typeof n.postRender&&(n.hasPostRender=!0,t=!0),t?((n.hasPreUpdate||n.hasUpdate||n.hasPostUpdate)&&(n.active=!0),(n.hasRender||n.hasPostRender)&&(n.visible=!0),this._len=this.plugins.push(n),"function"==typeof n.init&&n.init.apply(n,i),n):null},remove:function(n,t){for(void 0===t&&(t=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===n)return t&&n.destroy(),this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0;this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll();this.game=null}};n.PluginManager.prototype.constructor=n.PluginManager;n.Stage=function(t){this.game=t;PIXI.DisplayObjectContainer.call(this);this.name="_stage_root";this.disableVisibilityChange=!1;this.exists=!0;this.worldTransform=new n.Matrix;this.stage=this;this.currentRenderOrderID=0;this._hiddenVar="hidden";this._onChange=null;this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"};this.game.transparent||(this._bgColor.a=1);t.config&&this.parseConfig(t.config)};n.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);n.Stage.prototype.constructor=n.Stage;n.Stage.prototype.parseConfig=function(n){n.disableVisibilityChange&&(this.disableVisibilityChange=n.disableVisibilityChange);n.backgroundColor&&this.setBackgroundColor(n.backgroundColor)};n.Stage.prototype.boot=function(){n.DOM.getOffset(this.game.canvas,this.offset);n.Canvas.setUserSelect(this.game.canvas,"none");n.Canvas.setTouchAction(this.game.canvas,"none");this.checkVisibility()};n.Stage.prototype.preUpdate=function(){var n,t;for(this.currentRenderOrderID=0,n=0;n<this.children.length;)t=this.children[n],t.preUpdate(),this===t.parent&&n++};n.Stage.prototype.update=function(){for(var n=this.children.length;n--;)this.children[n].update()};n.Stage.prototype.postUpdate=function(){this.game.camera.update();this.game.camera.target&&(this.game.camera.target.postUpdate(),this.updateTransform(),this.game.camera.updateTarget());for(var n=0;n<this.children.length;n++)this.children[n].postUpdate();this.updateTransform()};n.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var n=0;n<this.children.length;n++)this.children[n].updateTransform()};n.Stage.prototype.checkVisibility=function(){this._hiddenVar=void 0!==document.hidden?"visibilitychange":void 0!==document.webkitHidden?"webkitvisibilitychange":void 0!==document.mozHidden?"mozvisibilitychange":void 0!==document.msHidden?"msvisibilitychange":null;var n=this;this._onChange=function(t){return n.visibilityChange(t)};this._onChangePause=function(){return n._onChange({type:"pause"})};this._onChangeResume=function(){return n._onChange({type:"resume"})};this._onClick=function(t){void 0===document.hasFocus||document.hasFocus()||n.visibilityChange(t)};this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1);window.onblur=this._onChange;window.onfocus=this._onChange;window.onpagehide=this._onChange;window.onpageshow=this._onChange;window.addEventListener("click",this._onClick);this.game.device.cocoonJSApp&&CocoonJS.App&&(CocoonJS.App.onSuspended&&CocoonJS.App.onSuspended.addEventListener(this._onChangePause),CocoonJS.App.onActivated&&CocoonJS.App.onActivated.addEventListener(this._onChangeResume),CocoonJS.App.on&&(CocoonJS.App.on("activated",this._onChangeResume),CocoonJS.App.on("suspended",this._onChangePause)))};n.Stage.prototype.visibilityChange=function(n){switch(n.type){case"blur":case"pagehide":return void this.game.focusLoss(n);case"click":case"focus":case"pageshow":return void this.game.focusGain(n)}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===n.type?this.game.gamePaused(n):this.game.gameResumed(n))};n.Stage.prototype.setBackgroundColor=function(t){this.game.transparent||(n.Color.valueToColor(t,this._bgColor),n.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)};n.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1);window.onpagehide=null;window.onpageshow=null;window.onblur=null;window.onfocus=null;window.removeEventListener("click",this._onClick)};n.Stage.prototype.add=function(n,t,i){return n.parent===this?n:(n.body&&n.parent&&n.parent.hash&&n.parent.removeFromHash(n),void 0===i?this.addChild(n):this.addChildAt(n,i),n)};Object.defineProperty(n.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(n){this.setBackgroundColor(n)}});Object.defineProperty(n.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(n){PIXI.scaleModes.DEFAULT=n?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}});n.Group=function(t,i,r,u,f,e){void 0===u&&(u=!1);void 0===f&&(f=!1);void 0===e&&(e=n.Physics.ARCADE);this.game=t;void 0===i&&(i=t.world);this.name=r||"group";this.z=0;PIXI.DisplayObjectContainer.call(this);u?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):i&&(i.addChild(this),this.z=i.children.length);this.type=n.GROUP;this.physicsType=n.GROUP;this.alive=!0;this.exists=!0;this.ignoreDestroy=!1;this.pendingDestroy=!1;this.classType=n.Sprite;this.cursor=null;this.inputEnableChildren=!1;this.updateOnlyExistingChildren=!1;this.onChildInputDown=new n.Signal;this.onChildInputUp=new n.Signal;this.onChildInputOver=new n.Signal;this.onChildInputOut=new n.Signal;this.enableBody=f;this.enableBodyDebug=!1;this.physicsBodyType=e;this.physicsSortDirection=null;this.onDestroy=new n.Signal;this.cursorIndex=0;this.fixedToCamera=!1;this.cameraOffset=new n.Point;this.hash=[];this._sortProperty="z"};n.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);n.Group.prototype.constructor=n.Group;n.Group.RETURN_NONE=0;n.Group.RETURN_TOTAL=1;n.Group.RETURN_CHILD=2;n.Group.RETURN_ALL=3;n.Group.SORT_ASCENDING=-1;n.Group.SORT_DESCENDING=1;n.Group.prototype.add=function(n,t,i){return void 0===t&&(t=!1),n.parent===this?n:(n.body&&n.parent&&n.parent.hash&&n.parent.removeFromHash(n),void 0===i?(n.z=this.children.length,this.addChild(n)):(this.addChildAt(n,i),this.updateZ()),this.enableBody&&n.hasOwnProperty("body")&&null===n.body?this.game.physics.enable(n,this.physicsBodyType):n.body&&this.addToHash(n),!this.inputEnableChildren||n.input&&!n.inputEnabled||(n.inputEnabled=!0),!t&&n.events&&n.events.onAddedToGroup$dispatch(n,this),null===this.cursor&&(this.cursor=n),n)};n.Group.prototype.addAt=function(n,t,i){return this.add(n,i,t)};n.Group.prototype.addToHash=function(n){return n.parent===this&&-1===this.hash.indexOf(n)&&(this.hash.push(n),!0)};n.Group.prototype.removeFromHash=function(n){if(n){var t=this.hash.indexOf(n);if(-1!==t)return this.hash.splice(t,1),!0}return!1};n.Group.prototype.addMultiple=function(t,i){if(t instanceof n.Group)t.moveAll(this,i);else if(Array.isArray(t))for(var r=0;r<t.length;r++)this.add(t[r],i);return t};n.Group.prototype.getAt=function(n){return n<0||n>=this.children.length?-1:this.getChildAt(n)};n.Group.prototype.create=function(n,t,i,r,u,f){void 0===u&&(u=!0);var e=new this.classType(this.game,n,t,i,r);return e.exists=u,e.visible=u,e.alive=u,this.add(e,!1,f)};n.Group.prototype.createMultiple=function(n,t,i,r,u,f){void 0===i&&(i=0);void 0===r&&(r=!1);Array.isArray(t)||(t=[t]);Array.isArray(i)||(i=[i]);var o=this,e=[];return t.forEach(function(t){i.forEach(function(i){for(var h,s=0;s<n;s++)h=o.create(0,0,t,i,r),u&&u.call(f||h,h,s),e.push(h)})}),e};n.Group.prototype.updateZ=function(){for(var n=this.children.length;n--;)this.children[n].z=n};n.Group.prototype.align=function(t,i,r,u,f,e){var h;if(void 0===f&&(f=n.TOP_LEFT),void 0===e&&(e=0),0===this.children.length||e>this.children.length||-1===t&&-1===i)return!1;for(var o=new n.Rectangle(0,0,r,u),c=t*r,l=i*u,s=e;s<this.children.length;s++)if(h=this.children[s],h.alignIn)if(h.alignIn(o,f),-1===t)o.y+=u,o.y===l&&(o.x+=r,o.y=0);else if(-1===i)o.x+=r,o.x===c&&(o.x=0,o.y+=u);else if(o.x+=r,o.x===c&&(o.x=0,o.y+=u,o.y===l))return!0;return!0};n.Group.prototype.resetCursor=function(n){if(void 0===n&&(n=0),n>this.children.length-1&&(n=0),this.cursor)return this.cursorIndex=n,this.cursor=this.children[this.cursorIndex],this.cursor};n.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor};n.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor};n.Group.prototype.swap=function(n,t){this.swapChildren(n,t);this.updateZ()};n.Group.prototype.bringToTop=function(n){return n.parent===this&&this.getIndex(n)<this.children.length&&(this.remove(n,!1,!0),this.add(n,!0)),n};n.Group.prototype.bringChildToTop=n.Group.prototype.bringToTop;n.Group.prototype.sendToBack=function(n){return n.parent===this&&this.getIndex(n)>0&&(this.remove(n,!1,!0),this.addAt(n,0,!0)),n};n.Group.prototype.sendChildToBack=n.Group.prototype.sendToBack;n.Group.prototype.moveUp=function(n){if(n.parent===this&&this.getIndex(n)<this.children.length-1){var i=this.getIndex(n),t=this.getAt(i+1);t&&this.swap(n,t)}return n};n.Group.prototype.moveDown=function(n){if(n.parent===this&&this.getIndex(n)>0){var i=this.getIndex(n),t=this.getAt(i-1);t&&this.swap(n,t)}return n};n.Group.prototype.xy=function(n,t,i){if(n<0||n>this.children.length)return-1;this.getChildAt(n).x=t;this.getChildAt(n).y=i};n.Group.prototype.reverse=function(){this.children.reverse();this.updateZ()};n.Group.prototype.getIndex=function(n){return this.children.indexOf(n)};n.Group.prototype.getByName=function(n){return this.getFirst("name",n)};n.Group.prototype.replace=function(t,i){var r=this.getIndex(t);if(-1!==r)return i.parent&&(i.parent instanceof n.Group?i.parent.remove(i):i.parent.removeChild(i)),this.remove(t),this.addAt(i,r),t};n.Group.prototype.hasProperty=function(n,t){var i=t.length;return 1===i&&t[0]in n||2===i&&t[0]in n&&t[1]in n[t[0]]||3===i&&t[0]in n&&t[1]in n[t[0]]&&t[2]in n[t[0]][t[1]]||4===i&&t[0]in n&&t[1]in n[t[0]]&&t[2]in n[t[0]][t[1]]&&t[3]in n[t[0]][t[1]][t[2]]};n.Group.prototype.setProperty=function(n,t,i,r,u){if(void 0===u&&(u=!1),r=r||0,!this.hasProperty(n,t)&&(!u||r>0))return!1;var f=t.length;return 1===f?0===r?n[t[0]]=i:1===r?n[t[0]]+=i:2===r?n[t[0]]-=i:3===r?n[t[0]]*=i:4===r&&(n[t[0]]/=i):2===f?0===r?n[t[0]][t[1]]=i:1===r?n[t[0]][t[1]]+=i:2===r?n[t[0]][t[1]]-=i:3===r?n[t[0]][t[1]]*=i:4===r&&(n[t[0]][t[1]]/=i):3===f?0===r?n[t[0]][t[1]][t[2]]=i:1===r?n[t[0]][t[1]][t[2]]+=i:2===r?n[t[0]][t[1]][t[2]]-=i:3===r?n[t[0]][t[1]][t[2]]*=i:4===r&&(n[t[0]][t[1]][t[2]]/=i):4===f&&(0===r?n[t[0]][t[1]][t[2]][t[3]]=i:1===r?n[t[0]][t[1]][t[2]][t[3]]+=i:2===r?n[t[0]][t[1]][t[2]][t[3]]-=i:3===r?n[t[0]][t[1]][t[2]][t[3]]*=i:4===r&&(n[t[0]][t[1]][t[2]][t[3]]/=i)),!0};n.Group.prototype.checkProperty=function(t,i,r,u){if(void 0===u&&(u=!1),this!==t.parent)return!1;var f=n.Utils.getProperty(t,i);return!(void 0===f&&u||f!==r)};n.Group.prototype.set=function(n,t,i,r,u,f,e){if(void 0===e&&(e=!1),t=t.split("."),void 0===r&&(r=!1),void 0===u&&(u=!1),(!1===r||r&&n.alive)&&(!1===u||u&&n.visible))return this.setProperty(n,t,i,f,e)};n.Group.prototype.setAll=function(n,t,i,r,u,f){var s,e,o;for(void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===f&&(f=!1),n=n.split("."),u=u||0,s=this.children.length,e=0;e<s;e++)o=this.children[e],i&&!o.alive||r&&!o.visible||this.setProperty(o,n,t,u,f)};n.Group.prototype.setAllChildren=function(t,i,r,u,f,e){var h,s,o;for(void 0===r&&(r=!1),void 0===u&&(u=!1),void 0===e&&(e=!1),f=f||0,h=this.children.length,s=0;s<h;s++)o=this.children[s],r&&!o.alive||u&&!o.visible||(o instanceof n.Group?o.setAllChildren(t,i,r,u,f,e):this.setProperty(o,t.split("."),i,f,e))};n.Group.prototype.checkAll=function(n,t,i,r,u){var f,e;for(void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===u&&(u=!1),f=0;f<this.children.length;f++)if(e=this.children[f],(!i||e.alive)&&(!r||e.visible)&&!this.checkProperty(e,n,t,u))return!1;return!0};n.Group.prototype.checkAny=function(n,t,i,r){var u,f;for(void 0===i&&(i=!1),void 0===r&&(r=!1),u=0;u<this.children.length;u++)if(f=this.children[u],(!i||f.alive)&&(!r||f.visible)&&this.checkProperty(f,n,t))return!0;return!1};n.Group.prototype.addAll=function(n,t,i,r){this.setAll(n,t,i,r,1)};n.Group.prototype.subAll=function(n,t,i,r){this.setAll(n,t,i,r,2)};n.Group.prototype.multiplyAll=function(n,t,i,r){this.setAll(n,t,i,r,3)};n.Group.prototype.divideAll=function(n,t,i,r){this.setAll(n,t,i,r,4)};n.Group.prototype.kill=function(){this.alive=!1;this.exists=!1;this.visible=!1};n.Group.prototype.killAll=function(){this.callAllExists("kill",!0)};n.Group.prototype.revive=function(){this.alive=!0;this.exists=!0;this.visible=!0};n.Group.prototype.reviveAll=function(){this.callAllExists("revive",!1)};n.Group.prototype.resetAll=function(n,t,i,r,u){this.forEach(this.resetChild,this,u,n,t,i,r)};n.Group.prototype.callAllExists=function(n,t){var u,i,r;if(arguments.length>2)for(u=[],i=2;i<arguments.length;i++)u.push(arguments[i]);for(i=0;i<this.children.length;i++)r=this.children[i],r.exists===t&&r[n]&&r[n].apply(r,u)};n.Group.prototype.callbackFromArray=function(n,t,i){if(1===i){if(n[t[0]])return n[t[0]]}else if(2===i){if(n[t[0]][t[1]])return n[t[0]][t[1]]}else if(3===i){if(n[t[0]][t[1]][t[2]])return n[t[0]][t[1]][t[2]]}else if(4===i){if(n[t[0]][t[1]][t[2]][t[3]])return n[t[0]][t[1]][t[2]][t[3]]}else if(n[t])return n[t];return!1};n.Group.prototype.callAll=function(n,t){var e,o,u,f;if(void 0!==n){if(e=(n=n.split(".")).length,void 0===t||null===t||""===t?t=null:"string"==typeof t&&(o=(t=t.split(".")).length),arguments.length>2)for(u=[],i=2;i<arguments.length;i++)u.push(arguments[i]);for(var r=null,s=null,i=0;i<this.children.length;i++)f=this.children[i],r=this.callbackFromArray(f,n,e),t&&r?(s=this.callbackFromArray(f,t,o),r.apply(s,u)):r&&r.apply(f,u)}};n.Group.prototype.preUpdate=function(){var n,t;if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(n=0;n<this.children.length;)t=this.children[n],t.preUpdate(),this===t.parent&&n++;return!0};n.Group.prototype.update=function(){for(var t,i,n=this.children.length;n--;)t=this.children.length,n>=t&&(n=t-1),i=this.children[n],this.updateOnlyExistingChildren&&!i.exists||i.update()};n.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);for(var n=0;n<this.children.length;n++)this.children[n].postUpdate()};n.Group.prototype.filter=function(t,i){for(var r,u=-1,e=this.children.length,f=[];++u<e;)r=this.children[u],(!i||i&&r.exists)&&t(r,u,this.children)&&f.push(r);return new n.ArraySet(f)};n.Group.prototype.forEach=function(n,t,i){var f,r,u;if(void 0===i&&(i=!1),arguments.length<=3)for(r=0;r<this.children.length;r++)u=this.children[r],i&&!u.exists||n.call(t,u);else{for(f=[null],r=3;r<arguments.length;r++)f.push(arguments[r]);for(r=0;r<this.children.length;r++)u=this.children[r],i&&!u.exists||(f[0]=u,n.apply(t,f))}};n.Group.prototype.forEachExists=function(t,i){var u,r;if(arguments.length>2)for(u=[null],r=2;r<arguments.length;r++)u.push(arguments[r]);this.iterate("exists",!0,n.Group.RETURN_TOTAL,t,i,u)};n.Group.prototype.forEachAlive=function(t,i){var u,r;if(arguments.length>2)for(u=[null],r=2;r<arguments.length;r++)u.push(arguments[r]);this.iterate("alive",!0,n.Group.RETURN_TOTAL,t,i,u)};n.Group.prototype.forEachDead=function(t,i){var u,r;if(arguments.length>2)for(u=[null],r=2;r<arguments.length;r++)u.push(arguments[r]);this.iterate("alive",!1,n.Group.RETURN_TOTAL,t,i,u)};n.Group.prototype.sort=function(t,i){this.children.length<2||(void 0===t&&(t="z"),void 0===i&&(i=n.Group.SORT_ASCENDING),this._sortProperty=t,i===n.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())};n.Group.prototype.customSort=function(n,t){this.children.length<2||(this.children.sort(n.bind(t)),this.updateZ())};n.Group.prototype.ascendingSortHandler=function(n,t){return n[this._sortProperty]<t[this._sortProperty]?-1:n[this._sortProperty]>t[this._sortProperty]?1:n.z<t.z?-1:1};n.Group.prototype.descendingSortHandler=function(n,t){return n[this._sortProperty]<t[this._sortProperty]?1:n[this._sortProperty]>t[this._sortProperty]?-1:0};n.Group.prototype.iterate=function(t,i,r,u,f,e){var s,h,o;if(0===this.children.length){if(r===n.Group.RETURN_TOTAL)return 0;if(r===n.Group.RETURN_ALL)return[]}for(s=0,r===n.Group.RETURN_ALL&&(h=[]),o=0;o<this.children.length;o++)if(this.children[o][t]===i){if(s++,u&&(e?(e[0]=this.children[o],u.apply(f,e)):u.call(f,this.children[o])),r===n.Group.RETURN_CHILD)return this.children[o];r===n.Group.RETURN_ALL&&h.push(this.children[o])}return r===n.Group.RETURN_TOTAL?s:r===n.Group.RETURN_ALL?h:null};n.Group.prototype.getFirst=function(t,i){return this.iterate(t,i,n.Group.RETURN_CHILD)};n.Group.prototype.getFirstExists=function(n,t,i,r,u,f){void 0===t&&(t=!1);"boolean"!=typeof n&&(n=!0);var e=this.getFirst("exists",n);return null===e&&t?this.create(i,r,u,f):this.resetChild(e,i,r,u,f)};n.Group.prototype.getFirstAlive=function(n,t,i,r,u){void 0===n&&(n=!1);var f=this.getFirst("alive",!0);return null===f&&n?this.create(t,i,r,u):this.resetChild(f,t,i,r,u)};n.Group.prototype.getFirstDead=function(n,t,i,r,u){void 0===n&&(n=!1);var f=this.getFirst("alive",!1);return null===f&&n?this.create(t,i,r,u):this.resetChild(f,t,i,r,u)};n.Group.prototype.resetChild=function(n,t,i,r,u){return null===n?null:(void 0===t&&(t=null),void 0===i&&(i=null),null!==t&&null!==i&&n.reset(t,i),void 0!==r&&n.loadTexture(r,u),n)};n.Group.prototype.getTop=function(){if(this.children.length>0)return this.children[this.children.length-1]};n.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]};n.Group.prototype.getClosestTo=function(t,i,r){for(var u,o=Number.MAX_VALUE,f=0,s=null,e=0;e<this.children.length;e++)u=this.children[e],u.exists&&(f=Math.abs(n.Point.distance(t,u)))<o&&(!i||i.call(r,u,f))&&(o=f,s=u);return s};n.Group.prototype.getFurthestFrom=function(t,i,r){for(var u,o=0,f=0,s=null,e=0;e<this.children.length;e++)u=this.children[e],u.exists&&(f=Math.abs(n.Point.distance(t,u)))>o&&(!i||i.call(r,u,f))&&(o=f,s=u);return s};n.Group.prototype.count=function(t,i){return this.iterate(t,i,n.Group.RETURN_TOTAL)};n.Group.prototype.countLiving=function(){return this.count("alive",!0)};n.Group.prototype.countDead=function(){return this.count("alive",!1)};n.Group.prototype.getRandom=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=this.children.length),0===i?null:n.ArrayUtils.getRandomItem(this.children,t,i)};n.Group.prototype.getRandomExists=function(n,t){var i=this.getAll("exists",!0,n,t);return this.game.rnd.pick(i)};n.Group.prototype.getAll=function(n,t,i,r){var u,f,e;for(void 0===i&&(i=0),void 0===r&&(r=this.children.length),u=[],f=i;f<r;f++)e=this.children[f],n?e[n]===t&&u.push(e):u.push(e);return u};n.Group.prototype.remove=function(n,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),0===this.children.length||-1===this.children.indexOf(n))return!1;i||!n.events||n.destroyPhase||n.events.onRemovedFromGroup$dispatch(n,this);var r=this.removeChild(n);return this.removeFromHash(n),this.updateZ(),this.cursor===n&&this.next(),t&&r&&r.destroy(!0),!0};n.Group.prototype.moveAll=function(t,i){if(void 0===i&&(i=!1),this.children.length>0&&t instanceof n.Group){do t.add(this.children[0],i);while(this.children.length>0);this.hash=[];this.cursor=null}return t};n.Group.prototype.removeAll=function(n,t,i){if(void 0===n&&(n=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),0!==this.children.length){do{!t&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var r=this.removeChild(this.children[0]);this.removeFromHash(r);n&&r&&r.destroy(!0,i)}while(this.children.length>0);this.hash=[];this.cursor=null}};n.Group.prototype.removeBetween=function(n,t,i,r){var u,f;if(void 0===t&&(t=this.children.length-1),void 0===i&&(i=!1),void 0===r&&(r=!1),0!==this.children.length){if(n>t||n<0||t>this.children.length)return!1;for(u=t;u>=n;)!r&&this.children[u].events&&this.children[u].events.onRemovedFromGroup$dispatch(this.children[u],this),f=this.removeChild(this.children[u]),this.removeFromHash(f),i&&f&&f.destroy(!0),this.cursor===this.children[u]&&(this.cursor=null),u--;this.updateZ()}};n.Group.prototype.scatter=function(n,t){null==n&&(n=this.game.world.bounds);this.forEach(function(t){t.position.set(n.randomX,n.randomY)},null,t)};n.Group.prototype.shuffle=function(){n.ArrayUtils.shuffle(this.children);this.updateZ()};n.Group.prototype.destroy=function(n,t){null===this.game||this.ignoreDestroy||(void 0===n&&(n=!0),void 0===t&&(t=!1),this.onDestroy.dispatch(this,n,t),this.removeAll(n),this.cursor=null,this.filters=null,this.pendingDestroy=!1,t||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))};Object.defineProperty(n.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,n.Group.RETURN_TOTAL)}});Object.defineProperty(n.Group.prototype,"length",{get:function(){return this.children.length}});Object.defineProperty(n.Group.prototype,"angle",{get:function(){return n.Math.radToDeg(this.rotation)},set:function(t){this.rotation=n.Math.degToRad(t)}});Object.defineProperty(n.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(n){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=n+i-t.halfWidth}});Object.defineProperty(n.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(n){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=n+i-t.halfHeight}});Object.defineProperty(n.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(n){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=n+i}});Object.defineProperty(n.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(n){var t=this.getBounds(this.parent),i=this.x-t.x;this.x=n+i-t.width}});Object.defineProperty(n.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(n){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=n+i}});Object.defineProperty(n.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(n){var t=this.getBounds(this.parent),i=this.y-t.y;this.y=n+i-t.height}});n.World=function(t){n.Group.call(this,t,null,"__world",!1);this.bounds=new n.Rectangle(0,0,t.width,t.height);this.camera=null;this._definedSize=!1;this._width=t.width;this._height=t.height;this.game.state.onStateChange.add(this.stateChange,this)};n.World.prototype=Object.create(n.Group.prototype);n.World.prototype.constructor=n.World;n.World.prototype.boot=function(){this.camera=new n.Camera(this.game,0,0,0,this.game.width,this.game.height);this.game.stage.addChild(this);this.camera.boot()};n.World.prototype.stateChange=function(){this.x=0;this.y=0;this.camera.reset()};n.World.prototype.setBounds=function(n,t,i,r){this._definedSize=!0;this._width=i;this._height=r;this.bounds.setTo(n,t,i,r);this.x=n;this.y=t;this.camera.bounds&&this.camera.bounds.setTo(n,t,Math.max(i,this.game.width),Math.max(r,this.game.height));this.game.physics.setBoundsToWorld()};n.World.prototype.resize=function(n,t){this._definedSize&&(n<this._width&&(n=this._width),t<this._height&&(t=this._height));this.bounds.width=n;this.bounds.height=t;this.game.camera.setBoundsToWorld();this.game.physics.setBoundsToWorld()};n.World.prototype.shutdown=function(){this.destroy(!0,!0)};n.World.prototype.wrap=function(n,t,i,r,u){void 0===t&&(t=0);void 0===i&&(i=!1);void 0===r&&(r=!0);void 0===u&&(u=!0);i?(n.getBounds(),r&&(n.x+n._currentBounds.width<this.bounds.x?n.x=this.bounds.right:n.x>this.bounds.right&&(n.x=this.bounds.left)),u&&(n.y+n._currentBounds.height<this.bounds.top?n.y=this.bounds.bottom:n.y>this.bounds.bottom&&(n.y=this.bounds.top))):(r&&n.x+t<this.bounds.x?n.x=this.bounds.right+t:r&&n.x-t>this.bounds.right&&(n.x=this.bounds.left-t),u&&n.y+t<this.bounds.top?n.y=this.bounds.bottom+t:u&&n.y-t>this.bounds.bottom&&(n.y=this.bounds.top-t))};n.World.prototype.wrapAll=function(n,t,i,r,u,f){n.forEach(this.wrap,this,t,i,r,u,f)};Object.defineProperty(n.World.prototype,"width",{get:function(){return this.bounds.width},set:function(n){n<this.game.width&&(n=this.game.width);this.bounds.width=n;this._width=n;this._definedSize=!0}});Object.defineProperty(n.World.prototype,"height",{get:function(){return this.bounds.height},set:function(n){n<this.game.height&&(n=this.game.height);this.bounds.height=n;this._height=n;this._definedSize=!0}});Object.defineProperty(n.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}});Object.defineProperty(n.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}});Object.defineProperty(n.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}});Object.defineProperty(n.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}});n.Game=function(t,i,r,u,f,e,o,s){return this.id=n.GAMES.push(this)-1,this.config=null,this.physicsConfig=s,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.multiTexture=!1,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=n.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=n.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.pendingDestroy=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this.rendersThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new n.Signal,this.forceSingleUpdate=!0,this.forceSingleRender=!0,this.dropFrames=!1,this._nextFpsNotification=0,1===arguments.length&&"object"==typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},void 0!==t&&(this._width=t),void 0!==i&&(this._height=i),void 0!==r&&(this.renderType=r),void 0!==u&&(this.parent=u),void 0!==e&&(this.transparent=e),void 0!==o&&(this.antialias=o),this.rnd=new n.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new n.StateManager(this,f)),this.device.whenReady(this.boot,this),this};n.Game.prototype={parseConfig:function(t){var i,r;this.config=t;void 0===t.enableDebug&&(this.config.enableDebug=!0);t.width&&(this._width=t.width);t.height&&(this._height=t.height);t.renderer&&(this.renderType=t.renderer);t.parent&&(this.parent=t.parent);void 0!==t.transparent&&(this.transparent=t.transparent);void 0!==t.antialias&&(this.antialias=t.antialias);void 0!==t.clearBeforeRender&&(this.clearBeforeRender=t.clearBeforeRender);void 0!==t.multiTexture&&(this.multiTexture=t.multiTexture);t.resolution&&(this.resolution=t.resolution);void 0!==t.preserveDrawingBuffer&&(this.preserveDrawingBuffer=t.preserveDrawingBuffer);t.physicsConfig&&(this.physicsConfig=t.physicsConfig);i=[(Date.now()*Math.random()).toString()];t.seed&&(i=t.seed);this.rnd=new n.RandomDataGenerator(i);r=null;t.state&&(r=t.state);this.state=new n.StateManager(this,r)},boot:function(){if(!this.isBooted){if(this.onPause=new n.Signal,this.onResume=new n.Signal,this.onBlur=new n.Signal,this.onFocus=new n.Signal,this.isBooted=!0,PIXI.game=this,this.math=n.Math,this.scale=new n.ScaleManager(this,this._width,this._height),this.stage=new n.Stage(this),this.setUpRenderer(),this.world=new n.World(this),this.add=new n.GameObjectFactory(this),this.make=new n.GameObjectCreator(this),this.cache=new n.Cache(this),this.load=new n.Loader(this),this.time=new n.Time(this),this.tweens=new n.TweenManager(this),this.input=new n.Input(this),this.sound=new n.SoundManager(this),this.physics=new n.Physics(this,this.physicsConfig),this.particles=new n.Particles(this),this.create=new n.Create(this),this.plugins=new n.PluginManager(this),this.net=new n.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(this.config),this.sound.boot(),this.state.boot(),this.config.enableDebug)this.debug=new n.Utils.Debug(this),this.debug.boot();else{var t=function(){};this.debug={preUpdate:t,update:t,reset:t,destroy:t,isDisabled:!0}}this.showDebugHeader();this.isRunning=!0;this.raf=this.config&&this.config.forceSetTimeOut?new n.RequestAnimationFrame(this,this.config.forceSetTimeOut):new n.RequestAnimationFrame(this,!1);this._kickstart=!0;this.focusWindow();this.config.disableStart||(this.cache.isReady?this.raf.start():this.cache.onReady.addOnce(function(){this.raf.start()},this))}},showDebugHeader:function(){var i,r;if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var e=n.VERSION,t="Canvas",u="HTML Audio",f=1;if(this.renderType===n.WEBGL?(t="WebGL",f++):this.renderType===n.HEADLESS&&(t="Headless"),this.device.webAudio&&(u="WebAudio",f++),this.device.ie)window.console&&console.log("Phaser v"+e+" | Pixi.js | "+t+" | "+u+" | http://phaser.io");else{for(i=["%c %c %c Phaser CE v"+e+" | Pixi.js | "+t+" | "+u+"  %c %c %c http://phaser.io %c♥%c♥%c♥","background: #fb8cb3","background: #d44a52","color: #ffffff; background: #871905;","background: #d44a52","background: #fb8cb3","background: #ffffff"],r=0;r<3;r++)r<f?i.push("color: #ff2424; background: #fff"):i.push("color: #959595; background: #fff");console.log.apply(console,i)}}},setUpRenderer:function(){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas 2d context, aborting.");if(this.canvas=this.config.canvas?this.config.canvas:n.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.config.crisp&&n.Canvas.setImageRenderingCrisp(this.canvas),this.renderType===n.WEBGL||this.renderType===n.WEBGL_MULTI||this.renderType===n.AUTO&&this.device.webGL){(this.multiTexture||this.renderType===n.WEBGL_MULTI)&&(PIXI.enableMultiTexture(),this.multiTexture=!0);try{this.renderer=new PIXI.WebGLRenderer(this,this.config);this.renderType=n.WEBGL;this.context=null;this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1);this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1)}catch(t){if(PIXI.defaultRenderer=null,this.renderer=null,this.multiTexture=!1,PIXI._enableMultiTextureToggle=!1,this.renderType===n.WEBGL)throw t;}}this.renderer||(this.renderer=new PIXI.CanvasRenderer(this,this.config),this.context=this.renderer.context,this.renderType===n.AUTO&&(this.renderType=n.CANVAS));this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===n.CANVAS);this.renderType!==n.HEADLESS&&(this.stage.smoothed=this.antialias,n.Canvas.addToDOM(this.canvas,this.parent,!1),n.Canvas.setTouchAction(this.canvas))},contextLost:function(n){n.preventDefault();this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext();this.cache.clearGLTextures();this.renderer.contextLost=!1},update:function(t){var r,i;if(this.pendingDestroy)this.destroy();else{if(this.time.update(t),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(this._spiraling>1&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.dropFrames?this.rendersThisFrame=0:(this.updateRender(this.time.slowMotion*this.time.desiredFps),this.rendersThisFrame=1);else{for(r=1e3*this.time.slowMotion/this.time.desiredFps,this._deltaTime+=Math.max(Math.min(3*r,this.time.elapsed),0),i=0,this.updatesThisFrame=Math.floor(this._deltaTime/r),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame)),this.rendersThisFrame=this.forceSingleRender?1:Math.min(1,this.updatesThisFrame);this._deltaTime>=r&&(this._deltaTime-=r,this.currentUpdateID=i,this.updateLogic(this.time.desiredFpsMult),i++,!this.forceSingleUpdate||1!==i);)this.time.refresh();i>this._lastCount?this._spiraling++:i<this._lastCount&&(this._spiraling=0);this._lastCount=i;this.rendersThisFrame>0&&this.updateRender(this._deltaTime/r)}this.renderer.type===n.WEBGL&&this.renderer.gl.flush()}},updateLogic:function(n){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(n),this.debug.preUpdate(),this.input.pauseUpdate()):(this.stepping&&(this.pendingStep=!0),this.time.countUpdate(),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(n),this.plugins.preUpdate(n),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.plugins.update(),this.stage.postUpdate(),this.state.postUpdate(),this.plugins.postUpdate());this.stage.updateTransform()},updateRender:function(t){this.lockRender||this.renderType===n.HEADLESS||(this.time.countRender(),this.state.preRender(t),this.renderer.render(this.stage),this.plugins.render(t),this.state.render(t),this.plugins.postRender(t))},enableStep:function(){this.stepping=!0;this.pendingStep=!1;this.stepCount=0},disableStep:function(){this.stepping=!1;this.pendingStep=!1},step:function(){this.pendingStep=!1;this.stepCount++},destroy:function(){this.raf.stop();this.debug.destroy();this.state.destroy();this.sound.destroy();this.scale.destroy();this.stage.destroy();this.input.destroy();this.physics.destroy();this.plugins.destroy();this.tweens.destroy();this.debug=null;this.state=null;this.sound=null;this.scale=null;this.stage=null;this.input=null;this.physics=null;this.plugins=null;this.tweens=null;this.cache=null;this.load=null;this.time=null;this.world=null;this.isBooted=!1;this.renderer.destroy(!1);n.Canvas.removeFromDOM(this.canvas);PIXI.game===this&&(PIXI.game=null);PIXI.defaultRenderer=null;n.GAMES[this.id]=null},gamePaused:function(n){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(n),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(n){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(n),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(n){this.onBlur.dispatch(n);this.stage.disableVisibilityChange||this.gamePaused(n)},focusGain:function(n){this.focusWindow();this.onFocus.dispatch(n);this.stage.disableVisibilityChange||this.gameResumed(n)},focusWindow:function(){window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus()}};n.Game.prototype.constructor=n.Game;Object.defineProperty(n.Game.prototype,"paused",{get:function(){return this._paused},set:function(n){!0===n?(!1===this._paused&&(this._paused=!0,this.sound.muteOnPause&&this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}});n.Input=function(t){this.game=t;this.hitCanvas=null;this.hitContext=null;this.moveCallbacks=[];this.customCandidateHandler=null;this.customCandidateHandlerContext=null;this.pollRate=0;this.enabled=!0;this.multiInputOverride=n.Input.MOUSE_TOUCH_COMBINE;this.position=null;this.speed=null;this.circle=null;this.scale=null;this.maxPointers=-1;this.tapRate=200;this.doubleTapRate=300;this.holdRate=2e3;this.justPressedRate=200;this.justReleasedRate=200;this.recordPointerHistory=!1;this.recordRate=100;this.recordLimit=100;this.touchLockCallbacks=[];this.pointer1=null;this.pointer2=null;this.pointer3=null;this.pointer4=null;this.pointer5=null;this.pointer6=null;this.pointer7=null;this.pointer8=null;this.pointer9=null;this.pointer10=null;this.pointers=[];this.activePointer=null;this.mousePointer=null;this.mouse=null;this.keyboard=null;this.touch=null;this.mspointer=null;this.gamepad=null;this.resetLocked=!1;this.onDown=null;this.onUp=null;this.onTap=null;this.onHold=null;this.minPriorityID=0;this.interactiveItems=new n.ArraySet;this._localPoint=new n.Point;this._pollCounter=0;this._oldPosition=null;this._x=0;this._y=0};n.Input.MOUSE_OVERRIDES_TOUCH=0;n.Input.TOUCH_OVERRIDES_MOUSE=1;n.Input.MOUSE_TOUCH_COMBINE=2;n.Input.MAX_POINTERS=10;n.Input.prototype={boot:function(t){"maxPointers"in t&&(this.maxPointers=t.maxPointers);this.mousePointer=new n.Pointer(this.game,0,n.PointerMode.CURSOR);this.addPointer();this.addPointer();this.mouse=new n.Mouse(this.game);this.touch=new n.Touch(this.game);this.mspointer=new n.MSPointer(this.game);this.mouseWheel=new n.MouseWheel(this.game);this.pointerLock=new n.PointerLock(this.game);n.Keyboard&&(this.keyboard=new n.Keyboard(this.game));n.Gamepad&&(this.gamepad=new n.Gamepad(this.game));this.onDown=new n.Signal;this.onUp=new n.Signal;this.onTap=new n.Signal;this.onHold=new n.Signal;this.scale=new n.Point(1,1);this.speed=new n.Point;this.position=new n.Point;this._oldPosition=new n.Point;this.circle=new n.Circle(0,0,45);this.activePointer=this.mousePointer;this.hitCanvas=n.CanvasPool.create(this,1,1);this.hitContext=this.hitCanvas.getContext("2d");this.game.device.mspointer&&!1!==t.mspointer?this.mspointer.start():this.game.device.touch&&!1!==t.touch&&this.touch.start();this.mspointer.active||!1===t.mouse||this.mouse.start();this.mousePointer.active=!0;!1!==t.mouseWheel&&this.mouseWheel.start();!1!==t.pointerLock&&this.pointerLock.start();this.keyboard&&!1!==t.keyboard&&this.keyboard.start();var i=this;this._onClickTrampoline=function(n){i.onClickTrampoline(n)};this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop();this.mouseWheel.stop();this.touch.stop();this.mspointer.stop();this.pointerLock.stop();this.keyboard&&this.keyboard.stop();this.gamepad&&this.gamepad.stop();this.moveCallbacks=[];n.CanvasPool.remove(this);this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(n,t){this.customCandidateHandler=n;this.customCandidateHandlerContext=t},addMoveCallback:function(n,t){this.moveCallbacks.push({callback:n,context:t})},addTouchLockCallback:function(n,t,i){void 0===i&&(i=!1);this.touchLockCallbacks.push({callback:n,context:t,onEnd:i})},removeTouchLockCallback:function(n,t){for(var i=this.touchLockCallbacks.length;i--;)if(this.touchLockCallbacks[i].callback===n&&this.touchLockCallbacks[i].context===t)return this.touchLockCallbacks.splice(i,1),!0;return!1},executeTouchLockCallbacks:function(n,t){for(var r,i=this.touchLockCallbacks.length;i--;)r=this.touchLockCallbacks[i],r.onEnd===n&&r.callback.call(r.context,this,t)&&this.touchLockCallbacks.splice(i,1)},deleteMoveCallback:function(n,t){for(var i=this.moveCallbacks.length;i--;)if(this.moveCallbacks[i].callback===n&&this.moveCallbacks[i].context===t)return void this.moveCallbacks.splice(i,1)},addPointer:function(){if(this.pointers.length>=n.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+n.Input.MAX_POINTERS+" pointers reached."),null;var i=this.pointers.length+1,t=new n.Pointer(this.game,i,n.PointerMode.CONTACT);return this.pointers.push(t),this["pointer"+i]=t,t},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter<this.pollRate)this._pollCounter++;else{this.speed.x=this.position.x-this._oldPosition.x;this.speed.y=this.position.y-this._oldPosition.y;this._oldPosition.copyFrom(this.position);this.mousePointer.update();this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var n=0;n<this.pointers.length;n++)this.pointers[n].update();this._pollCounter=0}},pauseUpdate:function(){this.gamepad&&this.gamepad.active&&this.gamepad.update()},reset:function(t){if(this.game.isBooted&&!this.resetLocked){void 0===t&&(t=!1);this.mousePointer.reset();this.keyboard&&this.keyboard.reset(t);for(var i=0;i<this.pointers.length;i++)this.pointers[i].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor="");t&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new n.Signal,this.onUp=new n.Signal,this.onTap=new n.Signal,this.onHold=new n.Signal,this.moveCallbacks=[]);this._pollCounter=0}},resetSpeed:function(n,t){this._oldPosition.setTo(n,t);this.speed.setTo(0,0)},startPointer:function(n){var t,i;if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(n);if(!this.pointer2.active)return this.pointer2.start(n);for(t=2;t<this.pointers.length;t++)if(i=this.pointers[t],!i.active)return i.start(n);return null},updatePointer:function(n){var t,i;if(this.pointer1.active&&this.pointer1.identifier===n.identifier)return this.pointer1.move(n);if(this.pointer2.active&&this.pointer2.identifier===n.identifier)return this.pointer2.move(n);for(t=2;t<this.pointers.length;t++)if(i=this.pointers[t],i.active&&i.identifier===n.identifier)return i.move(n);return null},stopPointer:function(n){var t,i;if(this.pointer1.active&&this.pointer1.identifier===n.identifier)return this.pointer1.stop(n);if(this.pointer2.active&&this.pointer2.identifier===n.identifier)return this.pointer2.stop(n);for(t=2;t<this.pointers.length;t++)if(i=this.pointers[t],i.active&&i.identifier===n.identifier)return i.stop(n);return null},countActivePointers:function(n){void 0===n&&(n=this.pointers.length);for(var t=n,i=0;i<this.pointers.length&&t>0;i++)this.pointers[i].active&&t--;return n-t},getPointer:function(n){var t,i;for(void 0===n&&(n=!1),t=0;t<this.pointers.length;t++)if(i=this.pointers[t],i.active===n)return i;return null},getPointerFromIdentifier:function(n){for(var i,t=0;t<this.pointers.length;t++)if(i=this.pointers[t],i.identifier===n)return i;return null},getPointerFromId:function(n){for(var i,t=0;t<this.pointers.length;t++)if(i=this.pointers[t],i.pointerId===n)return i;return null},getLocalPosition:function(t,i,r){void 0===r&&(r=new n.Point);var u=t.worldTransform,f=1/(u.a*u.d+u.c*-u.b);return r.setTo(u.d*f*i.x+-u.c*f*i.y+(u.ty*u.c-u.tx*u.d)*f,u.a*f*i.y+-u.b*f*i.x+(-u.ty*u.a+u.tx*u.b)*f)},hitTest:function(t,i,r){var u,h,s;if(!t.worldVisible)return!1;if(this.getLocalPosition(t,i,this._localPoint),r.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(n.Creature&&t instanceof n.Creature){var f=Math.abs(t.width),e=Math.abs(t.height),o=t.x-f*t.anchorX;if(this.game.camera.x+i.x>=o&&this.game.camera.x+i.x<o+f&&(u=t.y-e*t.anchorY,this.game.camera.y+i.y>=u&&this.game.camera.y+i.y<u+e))return!0}else if(t instanceof n.TileSprite){var f=t.width,e=t.height,o=-f*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+f&&(u=-e*t.anchor.y,this._localPoint.y>=u&&this._localPoint.y<u+e))return!0}else if(t instanceof PIXI.Sprite){var f=t.texture.frame.width/t.texture.baseTexture.resolution,e=t.texture.frame.height/t.texture.baseTexture.resolution,o=-f*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+f&&(u=-e*t.anchor.y,this._localPoint.y>=u&&this._localPoint.y<u+e))return!0}else if(t instanceof n.Graphics)for(s=0;s<t.graphicsData.length;s++)if(h=t.graphicsData[s],h.fill&&h.shape&&h.shape.contains(this._localPoint.x,this._localPoint.y))return!0;for(s=0;s<t.children.length;s++)if(this.hitTest(t.children[s],i,r))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()},callAll:function(n,t){for(var i,r=this.interactiveItems.list,u=r.length;u--;)i=r[u],i&&i.enabled&&i[n](t)}};n.Input.prototype.constructor=n.Input;Object.defineProperty(n.Input.prototype,"x",{get:function(){return this._x},set:function(n){this._x=Math.floor(n)}});Object.defineProperty(n.Input.prototype,"y",{get:function(){return this._y},set:function(n){this._y=Math.floor(n)}});Object.defineProperty(n.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter<this.pollRate}});Object.defineProperty(n.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}});Object.defineProperty(n.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}});Object.defineProperty(n.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}});Object.defineProperty(n.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}});n.Mouse=function(n){this.game=n;this.input=n.input;this.callbackContext=this.game;this.mouseDownCallback=null;this.mouseUpCallback=null;this.mouseOutCallback=null;this.mouseOverCallback=null;this.capture=!1;this.active=!1;this.enabled=!0;this.stopOnGameOut=!1;this.event=null;this._onMouseDown=null;this._onMouseMove=null;this._onMouseUp=null;this._onMouseOut=null;this._onMouseOver=null};n.Mouse.NO_BUTTON=-1;n.Mouse.LEFT_BUTTON=0;n.Mouse.MIDDLE_BUTTON=1;n.Mouse.RIGHT_BUTTON=2;n.Mouse.BACK_BUTTON=3;n.Mouse.FORWARD_BUTTON=4;n.Mouse.prototype={start:function(){var i=this.game.device,n,t;return i.isAndroidStockBrowser()&&this.input.touch.active?!1:null!==this._onMouseDown?!1:(n=this,this._onMouseDown=function(t){return n.onMouseDown(t)},this._onMouseMove=function(t){return n.onMouseMove(t)},this._onMouseUp=function(t){return n.onMouseUp(t)},this._onMouseUpGlobal=function(t){return n.onMouseUpGlobal(t)},this._onMouseOutGlobal=function(t){return n.onMouseOutGlobal(t)},this._onMouseOut=function(t){return n.onMouseOut(t)},this._onMouseOver=function(t){return n.onMouseOver(t)},t=this.game.canvas,t.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("mousemove",this._onMouseMove,!0),t.addEventListener("mouseup",this._onMouseUp,!0),i.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),t.addEventListener("mouseover",this._onMouseOver,!0),t.addEventListener("mouseout",this._onMouseOut,!0)),this.active=!0,!0)},onMouseDown:function(n){this.event=n;this.capture&&n.preventDefault();this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=0,this.input.mousePointer.start(n))},onMouseMove:function(n){this.event=n;this.capture&&n.preventDefault();this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=0,this.input.mousePointer.move(n))},onMouseUp:function(n){this.event=n;this.capture&&n.preventDefault();this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=0,this.input.mousePointer.stop(n))},onMouseUpGlobal:function(n){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,n),n.identifier=0,this.input.mousePointer.stop(n))},onMouseOutGlobal:function(n){this.event=n;this.capture&&n.preventDefault();this.input.mousePointer.withinGame=!1;this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(n),this.input.mousePointer.resetButtons())},onMouseOut:function(n){this.event=n;this.capture&&n.preventDefault();this.input.mousePointer.withinGame=!1;this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(this.input.mousePointer.updateButtons(n),this.stopOnGameOut&&(n.identifier=0,this.input.mousePointer.stop(n),this.input.callAll("_pointerOutHandler",this.input.mousePointer)))},onMouseOver:function(n){this.event=n;this.capture&&n.preventDefault();this.input.mousePointer.withinGame=!0;this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&this.input.mousePointer.updateButtons(n)},stop:function(){var n=this.game.canvas;n.removeEventListener("mousedown",this._onMouseDown,!0);n.removeEventListener("mousemove",this._onMouseMove,!0);n.removeEventListener("mouseup",this._onMouseUp,!0);n.removeEventListener("mouseover",this._onMouseOver,!0);n.removeEventListener("mouseout",this._onMouseOut,!0);window.removeEventListener("mouseup",this._onMouseUpGlobal,!0);window.removeEventListener("mouseout",this._onMouseOutGlobal,!0);this.active=!1}};n.Mouse.prototype.constructor=n.Mouse;n.MouseWheel=function(n){this.game=n;this.input=n.input;this.element=n.canvas;this.preventDefault=!0;this.active=!1;this.callback=null;this.callbackContext=n;this.delta=0;this.wheelEventName=n.device.wheelEvent;this.boundOnWheelHandler=this.onWheelHandler.bind(this);this.eventProxy=null};n.MouseWheel.UP=1;n.MouseWheel.DOWN=-1;n.MouseWheel.prototype.start=function(){return!(!this.wheelEventName||this.active)&&(this.element.addEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),"mousewheel"===this.wheelEventName?this.eventProxy=new n.WheelEventProxy(-.025,1):"DOMMouseScroll"===this.wheelEventName&&(this.eventProxy=new n.WheelEventProxy(1,1)),this.active=!0,!0)};n.MouseWheel.prototype.stop=function(){this.active&&(this.element.removeEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),this.active=!1)};n.MouseWheel.prototype.onWheelHandler=function(t){this.eventProxy&&(t=this.eventProxy.bindEvent(t));this.preventDefault&&t.preventDefault();this.delta=n.Math.clamp(-t.deltaY,-1,1);this.callback&&this.callback.call(this.callbackContext,t)};n.MSPointer=function(n){this.game=n;this.input=n.input;this.callbackContext=this.game;this.pointerDownCallback=null;this.pointerMoveCallback=null;this.pointerUpCallback=null;this.pointerOutCallback=null;this.pointerOverCallback=null;this.capture=!1;this.event=null;this.active=!1;this.enabled=!0;this.stopOnGameOut=!1;this._onMSPointerDown=null;this._onMSPointerMove=null;this._onMSPointerUp=null;this._onMSPointerUpGlobal=null;this._onMSPointerOut=null;this._onMSPointerOver=null};n.MSPointer.prototype={start:function(){var t,n;return this.game.device.mspointer?null!==this._onMSPointerDown?!1:(t=this,this._onMSPointerDown=function(n){return t.onPointerDown(n)},this._onMSPointerMove=function(n){return t.onPointerMove(n)},this._onMSPointerUp=function(n){return t.onPointerUp(n)},this._onMSPointerUpGlobal=function(n){return t.onPointerUpGlobal(n)},this._onMSPointerOut=function(n){return t.onPointerOut(n)},this._onMSPointerOver=function(n){return t.onPointerOver(n)},n=this.game.canvas,n.addEventListener("MSPointerDown",this._onMSPointerDown,!1),n.addEventListener("MSPointerMove",this._onMSPointerMove,!1),n.addEventListener("MSPointerUp",this._onMSPointerUp,!1),n.addEventListener("pointerdown",this._onMSPointerDown,!1),n.addEventListener("pointermove",this._onMSPointerMove,!1),n.addEventListener("pointerup",this._onMSPointerUp,!1),n.style["-ms-content-zooming"]="none",n.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),n.addEventListener("MSPointerOver",this._onMSPointerOver,!0),n.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),n.addEventListener("pointerover",this._onMSPointerOver,!0),n.addEventListener("pointerout",this._onMSPointerOut,!0)),this.active=!0,!0):!1},onPointerDown:function(n){this.game.input.executeTouchLockCallbacks(!1,n);this.event=n;this.capture&&n.preventDefault();this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=n.pointerId,"mouse"===n.pointerType||4===n.pointerType?this.input.mousePointer.start(n):this.input.startPointer(n))},onPointerMove:function(n){this.event=n;this.capture&&n.preventDefault();this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=n.pointerId,"mouse"===n.pointerType||4===n.pointerType?this.input.mousePointer.move(n):this.input.updatePointer(n))},onPointerUp:function(n){this.game.input.executeTouchLockCallbacks(!0,n);this.event=n;this.capture&&n.preventDefault();this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&(n.identifier=n.pointerId,"mouse"===n.pointerType||4===n.pointerType?this.input.mousePointer.stop(n):this.input.stopPointer(n))},onPointerUpGlobal:function(n){if(n.identifier=n.pointerId,"mouse"!==n.pointerType&&4!==n.pointerType||this.input.mousePointer.withinGame){var t=this.input.getPointerFromIdentifier(n.identifier);t&&t.withinGame&&this.onPointerUp(n)}else this.onPointerUp(n)},onPointerOut:function(n){if(this.event=n,this.capture&&n.preventDefault(),n.identifier=n.pointerId,"mouse"===n.pointerType||4===n.pointerType)this.input.mousePointer.withinGame=!1;else{var t=this.input.getPointerFromIdentifier(n.identifier);t&&(t.withinGame=!1)}this.pointerOutCallback&&this.pointerOutCallback.call(this.callbackContext,n);this.input.enabled&&this.enabled&&this.stopOnGameOut&&(n.identifier=0,t||(t=this.input.mousePointer),t.stop(n),this.input.callAll("_pointerOutHandler",t))},onPointerOver:function(n){if(this.event=n,this.capture&&n.preventDefault(),n.identifier=n.pointerId,"mouse"===n.pointerType||4===n.pointerType)this.input.mousePointer.withinGame=!0;else{var t=this.input.getPointerFromIdentifier(n.identifier);t&&(t.withinGame=!0)}this.pointerOverCallback&&this.pointerOverCallback.call(this.callbackContext,n)},stop:function(){var n=this.game.canvas;n.removeEventListener("MSPointerDown",this._onMSPointerDown,!1);n.removeEventListener("MSPointerMove",this._onMSPointerMove,!1);n.removeEventListener("MSPointerUp",this._onMSPointerUp,!1);n.removeEventListener("pointerdown",this._onMSPointerDown,!1);n.removeEventListener("pointermove",this._onMSPointerMove,!1);n.removeEventListener("pointerup",this._onMSPointerUp,!1);window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0);n.removeEventListener("MSPointerOver",this._onMSPointerOver,!0);n.removeEventListener("MSPointerOut",this._onMSPointerOut,!0);window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0);n.removeEventListener("pointerover",this._onMSPointerOver,!0);n.removeEventListener("pointerout",this._onMSPointerOut,!0);this.active=!1}};n.MSPointer.prototype.constructor=n.MSPointer;n.DeviceButton=function(t,i){this.parent=t;this.game=t.game;this.event=null;this.isDown=!1;this.isUp=!0;this.timeDown=0;this.timeUp=0;this.repeats=0;this.altKey=!1;this.shiftKey=!1;this.ctrlKey=!1;this.value=0;this.buttonCode=i;this.onDown=new n.Signal;this.onUp=new n.Signal;this.onFloat=new n.Signal};n.DeviceButton.prototype={start:function(n,t){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=n,this.value=t,n&&(this.altKey=n.altKey,this.shiftKey=n.shiftKey,this.ctrlKey=n.ctrlKey),this.onDown.dispatch(this,t))},stop:function(n,t){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=n,this.value=t,n&&(this.altKey=n.altKey,this.shiftKey=n.shiftKey,this.ctrlKey=n.ctrlKey),this.onUp.dispatch(this,t))},startStop:function(n,t,i){n?this.start(t,i):this.stop(t,i)},padFloat:function(n){this.isDown=!1;this.isUp=!1;this.value=n;this.onFloat.dispatch(this,n)},justPressed:function(n){return n=n||250,this.isDown&&this.timeDown+n>this.game.time.time},justReleased:function(n){return n=n||250,this.isUp&&this.timeUp+n>this.game.time.time},reset:function(){this.isDown=!1;this.isUp=!0;this.timeDown=this.game.time.time;this.repeats=0;this.altKey=!1;this.shiftKey=!1;this.ctrlKey=!1},destroy:function(){this.onDown.dispose();this.onUp.dispose();this.onFloat.dispose();this.parent=null;this.game=null}};n.DeviceButton.prototype.constructor=n.DeviceButton;Object.defineProperty(n.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}});n.Pointer=function(t,i,r){this.game=t;this.id=i;this.type=n.POINTER;this.exists=!0;this.identifier=0;this.pointerId=null;this.pointerMode=r||n.PointerMode.CURSOR|n.PointerMode.CONTACT;this.target=null;this.button=null;this.leftButton=new n.DeviceButton(this,n.Pointer.LEFT_BUTTON);this.middleButton=new n.DeviceButton(this,n.Pointer.MIDDLE_BUTTON);this.rightButton=new n.DeviceButton(this,n.Pointer.RIGHT_BUTTON);this.backButton=new n.DeviceButton(this,n.Pointer.BACK_BUTTON);this.forwardButton=new n.DeviceButton(this,n.Pointer.FORWARD_BUTTON);this.eraserButton=new n.DeviceButton(this,n.Pointer.ERASER_BUTTON);this._holdSent=!1;this._history=[];this._nextDrop=0;this._stateReset=!1;this.withinGame=!1;this.clientX=-1;this.clientY=-1;this.pageX=-1;this.pageY=-1;this.screenX=-1;this.screenY=-1;this.rawMovementX=0;this.rawMovementY=0;this.movementX=0;this.movementY=0;this.x=-1;this.y=-1;this.isMouse=0===i;this.isDown=!1;this.isUp=!0;this.timeDown=0;this.timeUp=0;this.previousTapTime=0;this.totalTouches=0;this.msSinceLastClick=Number.MAX_VALUE;this.targetObject=null;this.interactiveCandidates=[];this.active=!1;this.dirty=!1;this.position=new n.Point;this.positionDown=new n.Point;this.positionUp=new n.Point;this.circle=new n.Circle(0,0,44);this._clickTrampolines=null;this._trampolineTargetObject=null};n.Pointer.NO_BUTTON=0;n.Pointer.LEFT_BUTTON=1;n.Pointer.RIGHT_BUTTON=2;n.Pointer.MIDDLE_BUTTON=4;n.Pointer.BACK_BUTTON=8;n.Pointer.FORWARD_BUTTON=16;n.Pointer.ERASER_BUTTON=32;n.Pointer.prototype={resetButtons:function(){this.isDown=!1;this.isUp=!0;this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(t,i){switch(t){case n.Mouse.LEFT_BUTTON:this.leftButton.start(i);break;case n.Mouse.RIGHT_BUTTON:this.rightButton.start(i);break;case n.Mouse.MIDDLE_BUTTON:this.middleButton.start(i);break;case n.Mouse.BACK_BUTTON:this.backButton.start(i);break;case n.Mouse.FORWARD_BUTTON:this.forwardButton.start(i)}},processButtonsUp:function(t,i){switch(t){case n.Mouse.LEFT_BUTTON:this.leftButton.stop(i);break;case n.Mouse.RIGHT_BUTTON:this.rightButton.stop(i);break;case n.Mouse.MIDDLE_BUTTON:this.middleButton.stop(i);break;case n.Mouse.BACK_BUTTON:this.backButton.stop(i);break;case n.Mouse.FORWARD_BUTTON:this.forwardButton.stop(i)}},processButtonsUpDown:function(t,i){var u=i.type.toLowerCase().substr(-4),r="down"===u,f="move"===u;void 0!==t?(r&&1===t&&i.ctrlKey&&(t=2),this.leftButton.startStop(n.Pointer.LEFT_BUTTON&t,i),this.rightButton.startStop(n.Pointer.RIGHT_BUTTON&t,i),this.middleButton.startStop(n.Pointer.MIDDLE_BUTTON&t,i),this.backButton.startStop(n.Pointer.BACK_BUTTON&t,i),this.forwardButton.startStop(n.Pointer.FORWARD_BUTTON&t,i),this.eraserButton.startStop(n.Pointer.ERASER_BUTTON&t,i)):void 0!==i.button?r&&i.ctrlKey&&0===i.button?this.rightButton.start(i):r?this.processButtonsDown(i.button,i):f||this.processButtonsUp(i.button,i):r?i.ctrlKey?this.rightButton.start(i):this.leftButton.start(i):(this.leftButton.stop(i),this.rightButton.stop(i))},updateButtons:function(n){this.button=n.button;this.processButtonsUpDown(n.buttons,n);this.isUp=!0;this.isDown=!1;(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(t){var i=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(i.multiInputOverride===n.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===n.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===n.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.x=this.x,i.y=this.y,i.position.setTo(this.x,this.y),i.onDown.dispatch(this,t),i.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===n.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===n.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===n.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))},move:function(t,i){var r=this.game.input,u;if(!r.pollLocked){for(void 0===i&&(i=!1),void 0!==t.button&&(this.button=t.button),this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&r.pointerLock.locked&&!i&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*r.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*r.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(r.multiInputOverride===n.Input.MOUSE_OVERRIDES_TOUCH||r.multiInputOverride===n.Input.MOUSE_TOUCH_COMBINE||r.multiInputOverride===n.Input.TOUCH_OVERRIDES_MOUSE&&0===r.totalActivePointers)&&(r.activePointer=this,r.x=this.x,r.y=this.y,r.position.setTo(r.x,r.y),r.circle.x=r.x,r.circle.y=r.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY),u=r.moveCallbacks.length;u--;)r.moveCallbacks[u].callback.call(r.moveCallbacks[u].context,this,this.x,this.y,i,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?r.interactiveItems.total>0&&this.processInteractiveObjects(i):!1===this.targetObject.update(this)&&(this.targetObject=null),this}},processInteractiveObjects:function(n){var r=0,u=-1,i=null,t=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];t;)t.checked=!1,!t.validForInput(u,r,!1)||this.game.paused&&!t.sprite.noPause||(t.checked=!0,(n&&t.checkPointerDown(this,!0)||!n&&t.checkPointerOver(this,!0))&&(r=t.sprite.renderOrderID,u=t.priorityID,i=t,this.interactiveCandidates.push(t))),t=this.game.input.interactiveItems.next;for(t=this.game.input.interactiveItems.first;t;)!t.checked&&t.validForInput(u,r,!0)&&(n&&t.checkPointerDown(this,!1)||!n&&t.checkPointerOver(this,!1))&&(r=t.sprite.renderOrderID,u=t.priorityID,i=t,this.interactiveCandidates.push(t)),t=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(i=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,i)),this.swapTarget(i,!1),null!==this.targetObject},swapTarget:function(n,t){void 0===t&&(t=!1);null===n?this.targetObject&&(this.targetObject._pointerOutHandler(this,t),this.targetObject=null):null===this.targetObject?(this.targetObject=n,n._pointerOverHandler(this,t)):this.targetObject===n?!1===n.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,t),this.targetObject=n,this.targetObject._pointerOverHandler(this,t))},leave:function(n){this.withinGame=!1;this.move(n,!1)},stop:function(t){var i=this.game.input,r;if(!this._stateReset||!this.withinGame)return(this.timeUp=this.game.time.time,(i.multiInputOverride===n.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===n.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===n.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.onUp.dispatch(this,t),this.duration>=0&&this.duration<=i.tapRate))&&(r=this.timeUp-this.previousTapTime<i.doubleTapRate,i.onTap.dispatch(this,r,t),this.previousTapTime=this.timeUp),this.isMouse?this.updateButtons(t):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&i.currentPointers--,i.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this;t.preventDefault()},justPressed:function(n){return n=n||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+n>this.game.time.time},justReleased:function(n){return n=n||this.game.input.justReleasedRate,this.isUp&&this.timeUp+n>this.game.time.time},addClickTrampoline:function(n,t,i,r){if(this.isDown){for(var u=this._clickTrampolines=this._clickTrampolines||[],f=0;f<u.length;f++)if(u[f].name===n){u.splice(f,1);break}u.push({name:n,targetObject:this.targetObject,callback:t,callbackContext:i,callbackArgs:r})}},processClickTrampolines:function(){var i=this._clickTrampolines,t,n;if(i){for(t=0;t<i.length;t++)n=i[t],n.targetObject===this._trampolineTargetObject&&n.callback.apply(n.callbackContext,n.callbackArgs);this._clickTrampolines=null;this._trampolineTargetObject=null}},reset:function(){!1===this.isMouse&&(this.active=!1);this.pointerId=null;this.identifier=null;this.dirty=!1;this.totalTouches=0;this._holdSent=!1;this._history.length=0;this._stateReset=!0;this.resetButtons();this.targetObject&&this.targetObject._releasedHandler(this);this.targetObject=null},resetMovement:function(){this.movementX=0;this.movementY=0}};n.Pointer.prototype.constructor=n.Pointer;Object.defineProperty(n.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}});Object.defineProperty(n.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}});Object.defineProperty(n.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}});n.PointerMode={CURSOR:1,CONTACT:2};n.PointerModes={};n.PointerModes[n.PointerMode.CURSOR]="CURSOR";n.PointerModes[n.PointerMode.CONTACT]="CONTACT";n.Touch=function(n){this.game=n;this.active=!1;this.enabled=!0;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null;this.preventDefault=!0;this.event=null;this._onTouchStart=null;this._onTouchMove=null;this._onTouchEnd=null;this._onTouchEnter=null;this._onTouchLeave=null;this._onTouchCancel=null;this._onTouchMove=null};n.Touch.prototype={start:function(){if(!this.game.device.touch||null!==this._onTouchStart)return!1;var n=this;return this._onTouchStart=function(t){return n.onTouchStart(t)},this._onTouchMove=function(t){return n.onTouchMove(t)},this._onTouchEnd=function(t){return n.onTouchEnd(t)},this._onTouchEnter=function(t){return n.onTouchEnter(t)},this._onTouchLeave=function(t){return n.onTouchLeave(t)},this._onTouchCancel=function(t){return n.onTouchCancel(t)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.device.cocoonJS||(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)),this.active=!0,!0},consumeDocumentTouches:function(){this._documentTouchMove=function(n){n.preventDefault()};document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(n){if(this.game.input.executeTouchLockCallbacks(!1,n),this.event=n,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,n);this.preventDefault&&n.preventDefault();for(var t=0;t<n.changedTouches.length;t++)this.game.input.startPointer(n.changedTouches[t])}},onTouchCancel:function(n){if(this.event=n,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,n),this.game.input.enabled&&this.enabled){this.preventDefault&&n.preventDefault();for(var t=0;t<n.changedTouches.length;t++)this.game.input.stopPointer(n.changedTouches[t])}},onTouchEnter:function(n){this.event=n;this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,n);this.game.input.enabled&&this.enabled&&this.preventDefault&&n.preventDefault()},onTouchLeave:function(n){this.event=n;this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,n);this.preventDefault&&n.preventDefault()},onTouchMove:function(n){this.event=n;this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,n);this.preventDefault&&n.preventDefault();for(var t=0;t<n.changedTouches.length;t++)this.game.input.updatePointer(n.changedTouches[t])},onTouchEnd:function(n){this.game.input.executeTouchLockCallbacks(!0,n);this.event=n;this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,n);this.preventDefault&&n.preventDefault();for(var t=0;t<n.changedTouches.length;t++)this.game.input.stopPointer(n.changedTouches[t])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel),this.active=!1)}};n.Touch.prototype.constructor=n.Touch;n.InputHandler=function(t){this.sprite=t;this.game=t.game;this.enabled=!1;this.checked=!1;this.priorityID=0;this.useHandCursor=!1;this._setHandCursor=!1;this.isDragged=!1;this.allowHorizontalDrag=!0;this.allowVerticalDrag=!0;this.bringToTop=!1;this.snapOffset=null;this.snapOnDrag=!1;this.snapOnRelease=!1;this.snapX=0;this.snapY=0;this.snapOffsetX=0;this.snapOffsetY=0;this.pixelPerfectOver=!1;this.pixelPerfectClick=!1;this.pixelPerfectAlpha=255;this.draggable=!1;this.boundsRect=null;this.boundsSprite=null;this.scaleLayer=!1;this.dragOffset=new n.Point;this.dragFromCenter=!1;this.dragStopBlocksInputUp=!1;this.dragStartPoint=new n.Point;this.dragDistanceThreshold=0;this.dragTimeThreshold=0;this.downPoint=new n.Point;this.snapPoint=new n.Point;this._dragPoint=new n.Point;this._dragPhase=!1;this._pendingDrag=!1;this._dragTimePass=!1;this._dragDistancePass=!1;this._wasEnabled=!1;this._tempPoint=new n.Point;this._pointerData=[];this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})};n.InputHandler.prototype={start:function(t,i){if(t=t||0,void 0===i&&(i=!1),!1===this.enabled){this.game.input.interactiveItems.add(this);this.useHandCursor=i;this.priorityID=t;for(var r=0;r<10;r++)this._pointerData[r]={id:r,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new n.Point;this.enabled=!0;this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1;for(var n=0;n<10;n++)this._pointerData[n]={id:n,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){!1!==this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(n,t,i){return void 0===i&&(i=!0),!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput)&&!(!i&&(this.pixelPerfectClick||this.pixelPerfectOver))&&(this.priorityID>n||this.priorityID===n&&this.sprite.renderOrderID>t)},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(n){return n=n||0,this._pointerData[n].x},pointerY:function(n){return n=n||0,this._pointerData[n].y},pointerDown:function(n){return n=n||0,this._pointerData[n].isDown},pointerUp:function(n){return n=n||0,this._pointerData[n].isUp},pointerTimeDown:function(n){return n=n||0,this._pointerData[n].timeDown},pointerTimeUp:function(n){return n=n||0,this._pointerData[n].timeUp},pointerOver:function(n){if(!this.enabled)return!1;if(void 0===n){for(var t=0;t<10;t++)if(this._pointerData[t].isOver)return!0;return!1}return this._pointerData[n].isOver},pointerOut:function(n){if(!this.enabled)return!1;if(void 0!==n)return this._pointerData[n].isOut;for(var t=0;t<10;t++)if(this._pointerData[t].isOut)return!0},pointerTimeOver:function(n){return n=n||0,this._pointerData[n].timeOver},pointerTimeOut:function(n){return n=n||0,this._pointerData[n].timeOut},pointerDragged:function(n){return n=n||0,this._pointerData[n].isDragged},checkPointerDown:function(n,t){return!!(n.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,n,this._tempPoint)&&(void 0===t&&(t=!1),!(!t&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))},checkPointerOver:function(n,t){return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,n,this._tempPoint)&&(void 0===t&&(t=!1),!(!t&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))},checkPixel:function(n,t,i){if(this.sprite.texture.baseTexture.source){if(null===n&&null===t){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);var n=this._tempPoint.x,t=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(n-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(t-=-this.sprite.texture.frame.height*this.sprite.anchor.y),n+=this.sprite.texture.frame.x,t+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(n-=this.sprite.texture.trim.x,t-=this.sprite.texture.trim.y,n<this.sprite.texture.crop.x||n>this.sprite.texture.crop.right||t<this.sprite.texture.crop.y||t>this.sprite.texture.crop.bottom))return this._dx=n,this._dy=t,!1;if(this._dx=n,this._dy=t,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,n,t,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(t){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=n.Math.distance(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):this._pointerData[t.id].isOver?this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1):void 0:(this._pointerOutHandler(t),!1)},_pointerOverHandler:function(n,t){var i,r;null!==this.sprite&&(i=this._pointerData[n.id],(!1===i.isOver||n.dirty)&&(r=!1===i.isOver,i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=n.x-this.sprite.x,i.y=n.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!t&&r&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,n),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,n)))},_pointerOutHandler:function(n,t){if(null!==this.sprite){var i=this._pointerData[n.id];i.isOver=!1;i.isOut=!0;i.timeOut=this.game.time.time;this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1);!t&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,n),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,n))}},_touchedHandler:function(n){if(null!==this.sprite){var t=this._pointerData[n.id];if(!t.isDown&&t.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,n))return;if(t.isDown=!0,t.isUp=!1,t.timeDown=this.game.time.time,this.downPoint.set(n.x,n.y),n.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,n),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,n),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(n):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,n)):this._dragTimePass=!0));this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(n){this._dragTimePass=!0;this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(n)},_releasedHandler:function(n){var t,i;null!==this.sprite&&(t=this._pointerData[n.id],t.isDown&&n.isUp&&(t.isDown=!1,t.isUp=!0,t.timeUp=this.game.time.time,t.downDuration=t.timeUp-t.timeDown,i=this.checkPointerOver(n),this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===n.id)||this.sprite.events.onInputUp$dispatch(this.sprite,n,i),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,n,i),i&&(i=this.checkPointerOver(n))),t.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),n.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===n.id&&this.stopDrag(n)))},updateDrag:function(n,t){var u=this.game.camera,s=this.dragOffset,h=this._dragPoint,p=this._pointerData[n.id],a=this.snapPoint,i=this.sprite,o,f,e,c,l;if(void 0===t&&(t=!1),n.isUp)return this.stopDrag(n),!1;if(o=this.globalToLocal(n),i.fixedToCamera?(f=u.scale.x*o.x+h.x+s.x,e=u.scale.y*o.y+h.y+s.y):(f=o.x+h.x+s.x,e=o.y+h.y+s.y),i.fixedToCamera){var r=i.cameraOffset,v=r.x,y=r.y;this.allowHorizontalDrag&&(r.x=f-u.x);this.allowVerticalDrag&&(r.y=e-u.y);this.boundsRect&&this.checkBoundsRect();this.boundsSprite&&this.checkBoundsSprite();this.snapOnDrag&&(r.x=Math.round((r.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,r.y=Math.round((r.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,a.set(r.x,r.y));c=r.x-v;l=r.y-y}else{var w=u.x-p.camX,b=u.y-p.camY,v=i.x,y=i.y;this.allowHorizontalDrag&&(i.x=f+w);this.allowVerticalDrag&&(i.y=e+b);this.boundsRect&&this.checkBoundsRect();this.boundsSprite&&this.checkBoundsSprite();this.snapOnDrag&&(i.x=Math.round((i.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,i.y=Math.round((i.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,a.set(i.x,i.y));c=i.x-v;l=i.y-y}return this.sprite.events.onDragUpdate.dispatch(i,n,f,e,a,t,c,l),!0},justOver:function(n,t){return n=n||0,t=t||500,this._pointerData[n].isOver&&this.overDuration(n)<t},justOut:function(n,t){return n=n||0,t=t||500,this._pointerData[n].isOut&&this.game.time.time-this._pointerData[n].timeOut<t},justPressed:function(n,t){return n=n||0,t=t||500,this._pointerData[n].isDown&&this.downDuration(n)<t},justReleased:function(n,t){return n=n||0,t=t||500,this._pointerData[n].isUp&&this.game.time.time-this._pointerData[n].timeUp<t},overDuration:function(n){return n=n||0,this._pointerData[n].isOver?this.game.time.time-this._pointerData[n].timeOver:-1},downDuration:function(n){return n=n||0,this._pointerData[n].isDown?this.game.time.time-this._pointerData[n].timeDown:-1},enableDrag:function(t,i,r,u,f,e){void 0===t&&(t=!1);void 0===i&&(i=!1);void 0===r&&(r=!1);void 0===u&&(u=255);void 0===f&&(f=null);void 0===e&&(e=null);this._dragPoint=new n.Point;this.draggable=!0;this.bringToTop=i;this.dragOffset=new n.Point;this.dragFromCenter=t;this.pixelPerfectClick=r;this.pixelPerfectAlpha=u;f&&(this.boundsRect=f);e&&(this.boundsSprite=e)},disableDrag:function(){if(this._pointerData)for(var n=0;n<10;n++)this._pointerData[n].isDragged=!1;this.draggable=!1;this.isDragged=!1;this._draggedPointerID=-1;this._pendingDrag=!1},startDrag:function(t){var f=this.sprite.x,e=this.sprite.y,u=this.globalToLocal(t),i,r;(this.isDragged=!0,this._draggedPointerID=t.id,this._pointerData[t.id].camX=this.game.camera.x,this._pointerData[t.id].camY=this.game.camera.y,this._pointerData[t.id].isDragged=!0,this.sprite.fixedToCamera)?(this.dragFromCenter&&(i=this.sprite.getBounds(),r=this.globalToLocal(new n.Point(i.centerX,i.centerY)),this.sprite.cameraOffset.x=u.x+(this.sprite.cameraOffset.x-r.x),this.sprite.cameraOffset.y=u.y+(this.sprite.cameraOffset.y-r.y)),this._dragPoint.setTo(this.sprite.cameraOffset.x-t.x,this.sprite.cameraOffset.y-t.y)):(this.dragFromCenter&&(i=this.sprite.getBounds(),r=this.globalToLocal(new n.Point(i.centerX,i.centerY)),this.sprite.x=u.x+(this.sprite.x-r.x),this.sprite.y=u.y+(this.sprite.y-r.y)),this._dragPoint.setTo(this.sprite.x-u.x,this.sprite.y-u.y));this.updateDrag(t,!0);this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop());this.dragStartPoint.set(f,e);this.sprite.events.onDragStart$dispatch(this.sprite,t,f,e);this._pendingDrag=!1},globalToLocalX:function(n){return this.scaleLayer&&(n-=this.game.scale.grid.boundsFluid.x,n*=this.game.scale.grid.scaleFluidInversed.x),n},globalToLocalY:function(n){return this.scaleLayer&&(n-=this.game.scale.grid.boundsFluid.y,n*=this.game.scale.grid.scaleFluidInversed.y),n},globalToLocal:function(n){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:n.x,y:n.y}):n},stopDrag:function(n){this.isDragged=!1;this._draggedPointerID=-1;this._pointerData[n.id].isDragged=!1;this._dragPhase=!1;this._pendingDrag=!1;this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY));this.sprite.events.onDragStop$dispatch(this.sprite,n);!1===this.checkPointerOver(n)&&this._pointerOutHandler(n)},setDragLock:function(n,t){void 0===n&&(n=!0);void 0===t&&(t=!0);this.allowHorizontalDrag=n;this.allowVerticalDrag=t},enableSnap:function(n,t,i,r,u,f){void 0===i&&(i=!0);void 0===r&&(r=!1);void 0===u&&(u=0);void 0===f&&(f=0);this.snapX=n;this.snapY=t;this.snapOffsetX=u;this.snapOffsetY=f;this.snapOnDrag=i;this.snapOnRelease=r},disableSnap:function(){this.snapOnDrag=!1;this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}};n.InputHandler.prototype.constructor=n.InputHandler;n.PointerLock=function(t){this.game=t;this.input=t.input;this.element=t.canvas;this.active=!1;this.locked=!1;this.onChange=new n.Signal;this.onError=new n.Signal;this.boundOnChangeHandler=this.onChangeHandler.bind(this);this.boundOnErrorHandler=this.onErrorHandler.bind(this);var i=t.device;this.pointerLockElement=i.pointerLockElement;this.pointerlockchange=i.pointerlockchange;this.pointerlockerror=i.pointerlockerror};n.PointerLock.prototype.start=function(){return!(!this.game.device.pointerLock||this.active)&&(this.element.requestPointerLock||(this.element.requestPointerLock=this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock),document.exitPointerLock||(document.exitPointerLock=document.mozExitPointerLock||document.webkitExitPointerLock),document.addEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.addEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!0,!0)};n.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)};n.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()};n.PointerLock.prototype.exit=function(){document.exitPointerLock()};n.PointerLock.prototype.onChangeHandler=function(n){this.locked=document[this.pointerLockElement]===this.element;this.onChange.dispatch(this.locked,n)};n.PointerLock.prototype.onErrorHandler=function(n){this.onError.dispatch(n)};n.Gamepad=function(t){this.game=t;this._gamepadIndexMap={};this._rawPads=[];this._active=!1;this.enabled=!0;this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads;this._prevRawGamepadTypes=[];this._prevTimestamps=[];this.callbackContext=this;this.onConnectCallback=null;this.onDisconnectCallback=null;this.onDownCallback=null;this.onUpCallback=null;this.onAxisCallback=null;this.onFloatCallback=null;this._ongamepadconnected=null;this._gamepaddisconnected=null;this._gamepads=[new n.SinglePad(t,this),new n.SinglePad(t,this),new n.SinglePad(t,this),new n.SinglePad(t,this)]};n.Gamepad.prototype={addCallbacks:function(n,t){void 0!==t&&(this.onConnectCallback="function"==typeof t.onConnect?t.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof t.onDisconnect?t.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof t.onDown?t.onDown:this.onDownCallback,this.onUpCallback="function"==typeof t.onUp?t.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof t.onAxis?t.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof t.onFloat?t.onFloat:this.onFloatCallback,this.callbackContext=n)},start:function(){if(!this._active){this._active=!0;var n=this;this._onGamepadConnected=function(t){return n.onGamepadConnected(t)};this._onGamepadDisconnected=function(t){return n.onGamepadDisconnected(t)};window.addEventListener("gamepadconnected",this._onGamepadConnected,!1);window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(n){var t=n.gamepad;this._rawPads.push(t);this._gamepads[t.index].connect(t)},onGamepadDisconnected:function(n){var i=n.gamepad,t;for(t in this._rawPads)this._rawPads[t].index===i.index&&this._rawPads.splice(t,1);this._gamepads[i.index].disconnect()},update:function(){this._pollGamepads();this.pad1.pollStatus();this.pad2.pollStatus();this.pad3.pollStatus();this.pad4.pollStatus()},_pollGamepads:function(){var t,c,n,f,i,r,e,s,u,h,o;if(this._active&&(navigator.getGamepads?t=navigator.getGamepads():navigator.webkitGetGamepads?t=navigator.webkitGetGamepads():navigator.webkitGamepads&&(t=navigator.webkitGamepads()),t)){for(this._rawPads=[],c=!1,n=0;n<t.length&&(typeof t[n]!==this._prevRawGamepadTypes[n]&&(c=!0,this._prevRawGamepadTypes[n]=typeof t[n]),t[n]&&this._rawPads.push(t[n]),3!==n);n++);for(f=0;f<this._gamepads.length;f++)this._gamepads[f]._rawPad=this._rawPads[f];if(c){for(r={rawIndices:{},padIndices:{}},e=0;e<this._gamepads.length;e++)if((i=this._gamepads[e]).connected)for(s=0;s<this._rawPads.length;s++)this._rawPads[s].index===i.index&&(r.rawIndices[i.index]=!0,r.padIndices[e]=!0);for(u=0;u<this._gamepads.length;u++)if(i=this._gamepads[u],!r.padIndices[u])for(this._rawPads.length<1&&i.disconnect(),h=0;h<this._rawPads.length&&!r.padIndices[u];h++)if(o=this._rawPads[h],o){if(r.rawIndices[o.index]){i.disconnect();continue}i.connect(o);r.rawIndices[o.index]=!0;r.padIndices[u]=!0}else i.disconnect()}}},setDeadZones:function(n){for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].deadZone=n},stop:function(){this._active=!1;window.removeEventListener("gamepadconnected",this._onGamepadConnected);window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var n=0;n<this._gamepads.length;n++)this._gamepads[n].reset()},justPressed:function(n,t){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justPressed(n,t))return!0;return!1},justReleased:function(n,t){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justReleased(n,t))return!0;return!1},isDown:function(n){for(var t=0;t<this._gamepads.length;t++)if(!0===this._gamepads[t].isDown(n))return!0;return!1},destroy:function(){this.stop();for(var n=0;n<this._gamepads.length;n++)this._gamepads[n].destroy()}};n.Gamepad.prototype.constructor=n.Gamepad;Object.defineProperty(n.Gamepad.prototype,"active",{get:function(){return this._active}});Object.defineProperty(n.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}});Object.defineProperty(n.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}});Object.defineProperty(n.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}});Object.defineProperty(n.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}});Object.defineProperty(n.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}});Object.defineProperty(n.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}});n.Gamepad.BUTTON_0=0;n.Gamepad.BUTTON_1=1;n.Gamepad.BUTTON_2=2;n.Gamepad.BUTTON_3=3;n.Gamepad.BUTTON_4=4;n.Gamepad.BUTTON_5=5;n.Gamepad.BUTTON_6=6;n.Gamepad.BUTTON_7=7;n.Gamepad.BUTTON_8=8;n.Gamepad.BUTTON_9=9;n.Gamepad.BUTTON_10=10;n.Gamepad.BUTTON_11=11;n.Gamepad.BUTTON_12=12;n.Gamepad.BUTTON_13=13;n.Gamepad.BUTTON_14=14;n.Gamepad.BUTTON_15=15;n.Gamepad.AXIS_0=0;n.Gamepad.AXIS_1=1;n.Gamepad.AXIS_2=2;n.Gamepad.AXIS_3=3;n.Gamepad.AXIS_4=4;n.Gamepad.AXIS_5=5;n.Gamepad.AXIS_6=6;n.Gamepad.AXIS_7=7;n.Gamepad.AXIS_8=8;n.Gamepad.AXIS_9=9;n.Gamepad.XBOX360_A=0;n.Gamepad.XBOX360_B=1;n.Gamepad.XBOX360_X=2;n.Gamepad.XBOX360_Y=3;n.Gamepad.XBOX360_LEFT_BUMPER=4;n.Gamepad.XBOX360_RIGHT_BUMPER=5;n.Gamepad.XBOX360_LEFT_TRIGGER=6;n.Gamepad.XBOX360_RIGHT_TRIGGER=7;n.Gamepad.XBOX360_BACK=8;n.Gamepad.XBOX360_START=9;n.Gamepad.XBOX360_STICK_LEFT_BUTTON=10;n.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11;n.Gamepad.XBOX360_DPAD_LEFT=14;n.Gamepad.XBOX360_DPAD_RIGHT=15;n.Gamepad.XBOX360_DPAD_UP=12;n.Gamepad.XBOX360_DPAD_DOWN=13;n.Gamepad.XBOX360_STICK_LEFT_X=0;n.Gamepad.XBOX360_STICK_LEFT_Y=1;n.Gamepad.XBOX360_STICK_RIGHT_X=2;n.Gamepad.XBOX360_STICK_RIGHT_Y=3;n.Gamepad.PS3XC_X=0;n.Gamepad.PS3XC_CIRCLE=1;n.Gamepad.PS3XC_SQUARE=2;n.Gamepad.PS3XC_TRIANGLE=3;n.Gamepad.PS3XC_L1=4;n.Gamepad.PS3XC_R1=5;n.Gamepad.PS3XC_L2=6;n.Gamepad.PS3XC_R2=7;n.Gamepad.PS3XC_SELECT=8;n.Gamepad.PS3XC_START=9;n.Gamepad.PS3XC_STICK_LEFT_BUTTON=10;n.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11;n.Gamepad.PS3XC_DPAD_UP=12;n.Gamepad.PS3XC_DPAD_DOWN=13;n.Gamepad.PS3XC_DPAD_LEFT=14;n.Gamepad.PS3XC_DPAD_RIGHT=15;n.Gamepad.PS3XC_STICK_LEFT_X=0;n.Gamepad.PS3XC_STICK_LEFT_Y=1;n.Gamepad.PS3XC_STICK_RIGHT_X=2;n.Gamepad.PS3XC_STICK_RIGHT_Y=3;n.SinglePad=function(n,t){this.game=n;this.index=null;this.connected=!1;this.callbackContext=this;this.onConnectCallback=null;this.onDisconnectCallback=null;this.onDownCallback=null;this.onUpCallback=null;this.onAxisCallback=null;this.onFloatCallback=null;this.deadZone=.26;this._padParent=t;this._rawPad=null;this._prevTimestamp=null;this._buttons=[];this._buttonsLen=0;this._axes=[];this._axesLen=0};n.SinglePad.prototype={addCallbacks:function(n,t){void 0!==t&&(this.onConnectCallback="function"==typeof t.onConnect?t.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof t.onDisconnect?t.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof t.onDown?t.onDown:this.onDownCallback,this.onUpCallback="function"==typeof t.onUp?t.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof t.onAxis?t.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof t.onFloat?t.onFloat:this.onFloatCallback,this.callbackContext=n)},getButton:function(n){return this._buttons[n]?this._buttons[n]:null},pollStatus:function(){var n,t,i,r;if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&this._rawPad&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(n=0;n<this._buttonsLen;n++)t=isNaN(this._rawPad.buttons[n])?this._rawPad.buttons[n].value:this._rawPad.buttons[n],t!==this._buttons[n].value&&(1===t?this.processButtonDown(n,t):0===t?this.processButtonUp(n,t):this.processButtonFloat(n,t));for(i=0;i<this._axesLen;i++)r=this._rawPad.axes[i],r>0&&r>this.deadZone||r<0&&r<-this.deadZone?this.processAxisChange(i,r):this.processAxisChange(i,0);this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var u=!this.connected,i,r;for(this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length,i=0;i<this._axesLen;i++)this._axes[i]=t.axes[i];for(r in t.buttons)r=parseInt(r,10),this._buttons[r]=new n.DeviceButton(this,r);u&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index);u&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var t=this.connected,i=this.index,n;for(this.connected=!1,this.index=null,this._rawPad=void 0,n=0;n<this._buttonsLen;n++)this._buttons[n].destroy();this._buttons=[];this._buttonsLen=0;this._axes=[];this._axesLen=0;t&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,i);t&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var n=0;n<this._buttonsLen;n++)this._buttons[n].destroy();this._buttons=[];this._buttonsLen=0;this._axes=[];this._axesLen=0;this.onConnectCallback=null;this.onDisconnectCallback=null;this.onDownCallback=null;this.onUpCallback=null;this.onAxisCallback=null;this.onFloatCallback=null},processAxisChange:function(n,t){this._axes[n]!==t&&(this._axes[n]=t,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,n,t),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,n,t))},processButtonDown:function(n,t){this._buttons[n]&&this._buttons[n].start(null,t);this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,n,t,this.index);this.onDownCallback&&this.onDownCallback.call(this.callbackContext,n,t)},processButtonUp:function(n,t){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,n,t,this.index);this.onUpCallback&&this.onUpCallback.call(this.callbackContext,n,t);this._buttons[n]&&this._buttons[n].stop(null,t)},processButtonFloat:function(n,t){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,n,t,this.index);this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,n,t);this._buttons[n]&&this._buttons[n].padFloat(t)},axis:function(n){return!!this._axes[n]&&this._axes[n]},isDown:function(n){return!!this._buttons[n]&&this._buttons[n].isDown},isUp:function(n){return!!this._buttons[n]&&this._buttons[n].isUp},justReleased:function(n,t){if(this._buttons[n])return this._buttons[n].justReleased(t)},justPressed:function(n,t){if(this._buttons[n])return this._buttons[n].justPressed(t)},buttonValue:function(n){return this._buttons[n]?this._buttons[n].value:null},reset:function(){for(var n=0;n<this._axes.length;n++)this._axes[n]=0}};n.SinglePad.prototype.constructor=n.SinglePad;n.Key=function(t,i){this.game=t;this._enabled=!0;this.event=null;this.isDown=!1;this.isUp=!0;this.altKey=!1;this.ctrlKey=!1;this.shiftKey=!1;this.timeDown=0;this.duration=0;this.timeUp=-2500;this.durationUp=-2500;this.repeats=0;this.keyCode=i;this.onDown=new n.Signal;this.onHoldCallback=null;this.onHoldContext=null;this.onUp=new n.Signal;this._justDown=!1;this._justUp=!1};n.Key.prototype={update:function(){this._enabled&&(this.isDown?(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this)):this.durationUp=this.game.time.time-this.timeUp)},processKeyDown:function(n){this._enabled&&(this.event=n,this.isDown||(this.altKey=n.altKey,this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.durationUp=this.game.time.time-this.timeUp,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(n){this._enabled&&(this.event=n,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this.durationUp=0,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(n){void 0===n&&(n=!0);this.isDown=!1;this.isUp=!0;this.timeUp=this.game.time.time;this.duration=0;this.durationUp=-2500;this._enabled=!0;this._justDown=!1;this._justUp=!1;n&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(n){return void 0===n&&(n=50),this.isDown&&this.duration<n},upDuration:function(n){return void 0===n&&(n=50),!this.isDown&&this.game.time.time-this.timeUp<n},justPressed:function(){return this.isDown&&0===this.duration},justReleased:function(){return!this.isDown&&0===this.durationUp}};Object.defineProperty(n.Key.prototype,"justDown",{get:function(){var n=this._justDown;return this._justDown=!1,n}});Object.defineProperty(n.Key.prototype,"justUp",{get:function(){var n=this._justUp;return this._justUp=!1,n}});Object.defineProperty(n.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(n){(n=!!n)!==this._enabled&&(n||this.reset(!1),this._enabled=n)}});n.Key.prototype.constructor=n.Key;n.Keyboard=function(n){this.game=n;this.active=!1;this.enabled=!0;this.event=null;this.pressEvent=null;this.callbackContext=this;this.onDownCallback=null;this.onPressCallback=null;this.onUpCallback=null;this._keys=[];this._capture=[];this._onKeyDown=null;this._onKeyPress=null;this._onKeyUp=null;this._i=0;this._k=0};n.Keyboard.prototype={addCallbacks:function(n,t,i,r){this.callbackContext=n;void 0!==t&&null!==t&&(this.onDownCallback=t);void 0!==i&&null!==i&&(this.onUpCallback=i);void 0!==r&&null!==r&&(this.onPressCallback=r)},removeCallbacks:function(){this.callbackContext=this;this.onDownCallback=null;this.onUpCallback=null;this.onPressCallback=null},addKey:function(t){return this._keys[t]||(this._keys[t]=new n.Key(this.game,t),this.addKeyCapture(t)),this._keys[t]},addKeys:function(n){var i={},t;for(t in n)i[t]=this.addKey(n[t]);return i},removeKey:function(n){this._keys[n]&&(this._keys[n]=null,this.removeKeyCapture(n))},createCursorKeys:function(){return this.addKeys({up:n.KeyCode.UP,down:n.KeyCode.DOWN,left:n.KeyCode.LEFT,right:n.KeyCode.RIGHT})},start:function(){if(this.game.device.cocoonJS||this.active)return!1;var n=this;return this._onKeyDown=function(t){return n.processKeyDown(t)},this._onKeyUp=function(t){return n.processKeyUp(t)},this._onKeyPress=function(t){return n.processKeyPress(t)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1),this.active=!0,!0},stop:function(){window.removeEventListener("keydown",this._onKeyDown);window.removeEventListener("keyup",this._onKeyUp);window.removeEventListener("keypress",this._onKeyPress);this._onKeyDown=null;this._onKeyUp=null;this._onKeyPress=null;this.active=!1},destroy:function(){this.stop();this.clearCaptures();this._keys.length=0;this._i=0},addKeyCapture:function(n){if("object"==typeof n)for(var t in n)this._capture[n[t]]=!0;else this._capture[n]=!0},removeKeyCapture:function(n){delete this._capture[n]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault();this._keys[i]||(this._keys[i]=new n.Key(this.game,i));this._keys[i].processKeyDown(t);this._k=i;this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t)}},processKeyPress:function(n){this.pressEvent=n;this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(n.charCode),n)},processKeyUp:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault();this._keys[i]||(this._keys[i]=new n.Key(this.game,i));this._keys[i].processKeyUp(t);this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t)}},reset:function(n){void 0===n&&(n=!0);this.event=null;for(var t=this._keys.length;t--;)this._keys[t]&&this._keys[t].reset(n)},downDuration:function(n,t){return this._keys[n]?this._keys[n].downDuration(t):null},upDuration:function(n,t){return this._keys[n]?this._keys[n].upDuration(t):null},justPressed:function(n){return this._keys[n]?this._keys[n].justPressed():null},justReleased:function(n){return this._keys[n]?this._keys[n].justReleased():null},isDown:function(n){return this._keys[n]?this._keys[n].isDown:null}};Object.defineProperty(n.Keyboard.prototype,"lastChar",{get:function(){return this.event&&32===this.event.charCode?"":this.pressEvent?String.fromCharCode(this.pressEvent.charCode):null}});Object.defineProperty(n.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}});n.Keyboard.prototype.constructor=n.Keyboard;n.KeyCode={A:"A".charCodeAt(0),B:"B".charCodeAt(0),C:"C".charCodeAt(0),D:"D".charCodeAt(0),E:"E".charCodeAt(0),F:"F".charCodeAt(0),G:"G".charCodeAt(0),H:"H".charCodeAt(0),I:"I".charCodeAt(0),J:"J".charCodeAt(0),K:"K".charCodeAt(0),L:"L".charCodeAt(0),M:"M".charCodeAt(0),N:"N".charCodeAt(0),O:"O".charCodeAt(0),P:"P".charCodeAt(0),Q:"Q".charCodeAt(0),R:"R".charCodeAt(0),S:"S".charCodeAt(0),T:"T".charCodeAt(0),U:"U".charCodeAt(0),V:"V".charCodeAt(0),W:"W".charCodeAt(0),X:"X".charCodeAt(0),Y:"Y".charCodeAt(0),Z:"Z".charCodeAt(0),ZERO:"0".charCodeAt(0),ONE:"1".charCodeAt(0),TWO:"2".charCodeAt(0),THREE:"3".charCodeAt(0),FOUR:"4".charCodeAt(0),FIVE:"5".charCodeAt(0),SIX:"6".charCodeAt(0),SEVEN:"7".charCodeAt(0),EIGHT:"8".charCodeAt(0),NINE:"9".charCodeAt(0),NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144};for(r in n.KeyCode)n.KeyCode.hasOwnProperty(r)&&!r.match(/[a-z]/)&&(n.Keyboard[r]=n.KeyCode[r]);n.Component=function(){};n.Component.Angle=function(){};n.Component.Angle.prototype={angle:{get:function(){return n.Math.wrapAngle(n.Math.radToDeg(this.rotation))},set:function(t){this.rotation=n.Math.degToRad(n.Math.wrapAngle(t))}}};n.Component.Animation=function(){};n.Component.Animation.prototype={play:function(n,t,i,r){if(this.animations)return this.animations.play(n,t,i,r)}};n.Component.AutoCull=function(){};n.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}};n.Component.Bounds=function(){};n.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},centerX:{get:function(){return this.x-this.offsetX+.5*this.width},set:function(n){this.x=n+this.offsetX-.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+.5*this.height},set:function(n){this.y=n+this.offsetY-.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(n){this.x=n+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(n){this.x=n-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(n){this.y=n+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(n){this.y=n-this.height+this.offsetY}},alignIn:function(t,i,r,u){switch(void 0===r&&(r=0),void 0===u&&(u=0),i){default:case n.TOP_LEFT:this.left=t.left-r;this.top=t.top-u;break;case n.TOP_CENTER:this.centerX=t.centerX+r;this.top=t.top-u;break;case n.TOP_RIGHT:this.right=t.right+r;this.top=t.top-u;break;case n.LEFT_CENTER:this.left=t.left-r;this.centerY=t.centerY+u;break;case n.CENTER:this.centerX=t.centerX+r;this.centerY=t.centerY+u;break;case n.RIGHT_CENTER:this.right=t.right+r;this.centerY=t.centerY+u;break;case n.BOTTOM_LEFT:this.left=t.left-r;this.bottom=t.bottom+u;break;case n.BOTTOM_CENTER:this.centerX=t.centerX+r;this.bottom=t.bottom+u;break;case n.BOTTOM_RIGHT:this.right=t.right+r;this.bottom=t.bottom+u}return this},alignTo:function(t,i,r,u){switch(void 0===r&&(r=0),void 0===u&&(u=0),i){default:case n.TOP_LEFT:this.left=t.left-r;this.bottom=t.top-u;break;case n.TOP_CENTER:this.centerX=t.centerX+r;this.bottom=t.top-u;break;case n.TOP_RIGHT:this.right=t.right+r;this.bottom=t.top-u;break;case n.LEFT_TOP:this.right=t.left-r;this.top=t.top-u;break;case n.LEFT_CENTER:this.right=t.left-r;this.centerY=t.centerY+u;break;case n.LEFT_BOTTOM:this.right=t.left-r;this.bottom=t.bottom+u;break;case n.RIGHT_TOP:this.left=t.right+r;this.top=t.top-u;break;case n.RIGHT_CENTER:this.left=t.right+r;this.centerY=t.centerY+u;break;case n.RIGHT_BOTTOM:this.left=t.right+r;this.bottom=t.bottom+u;break;case n.BOTTOM_LEFT:this.left=t.left-r;this.top=t.bottom+u;break;case n.BOTTOM_CENTER:this.centerX=t.centerX+r;this.top=t.bottom+u;break;case n.BOTTOM_RIGHT:this.right=t.right+r;this.top=t.bottom+u}return this}};n.Group.prototype.alignIn=n.Component.Bounds.prototype.alignIn;n.Group.prototype.alignTo=n.Component.Bounds.prototype.alignTo;n.Component.BringToTop=function(){};n.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringChildToTop&&this.parent.bringChildToTop(this),this};n.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendChildToBack&&this.parent.sendChildToBack(this),this};n.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this};n.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this};n.Component.Core=function(){};n.Component.Core.skipTypeChecks=!1;n.Component.Core.install=function(t){var i,r,u;for(n.Utils.mixinPrototype(this,n.Component.Core.prototype),this.components={},i=0;i<t.length;i++)r=t[i],u=!1,"Destroy"===r&&(u=!0),n.Utils.mixinPrototype(this,n.Component[r].prototype,u),this.components[r]=!0};n.Component.Core.init=function(t,i,r,u,f){if(!n.Component.Core.skipTypeChecks){if(!(t instanceof n.Game))throw new Error("The value passed as the `game` argument ("+t+") is not an instance of Phaser.Game.");"number"!=typeof i&&(console.warn("The `x` argument value (%s) should be a number.",i),i=0);"number"!=typeof r&&(console.warn("The `y` argument value (%s) should be a number.",r),r=0)}this.game=t;this.key=u;this.data={};this.position.set(i,r);this.world=new n.Point(i,r);this.previousPosition=new n.Point(i,r);this.events=new n.Events(this);this._bounds=new n.Rectangle;this.components.PhysicsBody&&(this.body=this.body);this.components.Animation&&(this.animations=new n.AnimationManager(this));this.components.LoadTexture&&null!==u&&this.loadTexture(u,f);this.components.FixedToCamera&&(this.cameraOffset=new n.Point(i,r))};n.Component.Core.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.exists&&this.parent.exists?(this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.animations&&this.animations.update(),this.body&&this.body.preUpdate(),this.preUpdateChildren(),!0):(this.renderOrderID=-1,!1))};n.Component.Core.prototype={game:null,name:"",data:{},components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(t){t?(this._exists=!0,this.body&&this.body.type===n.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===n.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},preUpdateChildren:function(){for(var t,n=0;n<this.children.length;)t=this.children[n],t.preUpdate(),this===t.parent&&n++},update:function(){},postUpdate:function(){this.customRender&&this.key.render();this.components.PhysicsBody&&n.Component.PhysicsBody.postUpdate.call(this);this.components.FixedToCamera&&n.Component.FixedToCamera.postUpdate.call(this);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()}};n.Component.Crop=function(){};n.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(t,i){void 0===i&&(i=!1);t?(i&&null!==this.cropRect?this.cropRect.setTo(t.x,t.y,t.width,t.height):this.cropRect=i&&null===this.cropRect?new n.Rectangle(t.x,t.y,t.width,t.height):t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var f=this.texture.crop.x,e=this.texture.crop.y,o=this.texture.crop.width,s=this.texture.crop.height;this._crop=n.Rectangle.clone(this.cropRect,this._crop);this._crop.x+=this._frame.x;this._crop.y+=this._frame.y;var t=Math.max(this._frame.x,this._crop.x),i=Math.max(this._frame.y,this._crop.y),r=Math.min(this._frame.right,this._crop.right)-t,u=Math.min(this._frame.bottom,this._crop.bottom)-i;this.texture.crop.x=t;this.texture.crop.y=i;this.texture.crop.width=r;this.texture.crop.height=u;this.texture.frame.width=Math.min(r,this.cropRect.width);this.texture.frame.height=Math.min(u,this.cropRect.height);this.texture.width=this.texture.frame.width;this.texture.height=this.texture.frame.height;this.texture._updateUvs();16777215===this.tint||f===t&&e===i&&o===r&&s===u||(this.texture.requiresReTint=!0)}}};n.Component.Delta=function(){};n.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}};n.Component.Destroy=function(){};n.Component.Destroy.prototype={destroyPhase:!1,destroy:function(t,i){if(null!==this.game&&!this.destroyPhase){void 0===t&&(t=!0);void 0===i&&(i=!1);this.destroyPhase=!0;this.events&&this.events.onDestroy$dispatch(this);this.parent&&(this.parent instanceof n.Group?this.parent.remove(this):this.parent.removeChild(this));this.input&&this.input.destroy();this.animations&&this.animations.destroy();this.body&&this.body.destroy();this.events&&this.events.destroy();this.game.tweens.removeFrom(this);var r=this.children.length;if(t)for(;r--;)this.children[r].destroy(t);else for(;r--;)this.removeChild(this.children[r]);this._crop&&(this._crop=null,this.cropRect=null);this._frame&&(this._frame=null);n.Video&&this.key instanceof n.Video&&this.key.onChangeSource.remove(this.resizeFrame,this);n.BitmapText&&this._glyphs&&(this._glyphs=[]);this.alive=!1;this.exists=!1;this.visible=!1;this.filters=null;this.mask=null;this.game=null;this.data={};this.renderable=!1;this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null);this.hitArea=null;this.parent=null;this.stage=null;this.worldTransform=null;this.filterArea=null;this._bounds=null;this._currentBounds=null;this._mask=null;this._destroyCachedSprite();i&&this.texture.destroy(!0);this.destroyPhase=!1;this.pendingDestroy=!1}}};n.Events=function(n){this.parent=n};n.Events.prototype={destroy:function(){this._parent=null;this._onDestroy&&this._onDestroy.dispose();this._onAddedToGroup&&this._onAddedToGroup.dispose();this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose();this._onKilled&&this._onKilled.dispose();this._onRevived&&this._onRevived.dispose();this._onEnterBounds&&this._onEnterBounds.dispose();this._onOutOfBounds&&this._onOutOfBounds.dispose();this._onInputOver&&this._onInputOver.dispose();this._onInputOut&&this._onInputOut.dispose();this._onInputDown&&this._onInputDown.dispose();this._onInputUp&&this._onInputUp.dispose();this._onDragStart&&this._onDragStart.dispose();this._onDragUpdate&&this._onDragUpdate.dispose();this._onDragStop&&this._onDragStop.dispose();this._onAnimationStart&&this._onAnimationStart.dispose();this._onAnimationComplete&&this._onAnimationComplete.dispose();this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null};n.Events.prototype.constructor=n.Events;for(i in n.Events.prototype)n.Events.prototype.hasOwnProperty(i)&&0===i.indexOf("on")&&null===n.Events.prototype[i]&&function(t,i){"use strict";Object.defineProperty(n.Events.prototype,t,{get:function(){return this[i]||(this[i]=new n.Signal)}});n.Events.prototype[t+"$dispatch"]=function(){return this[i]?this[i].dispatch.apply(this[i],arguments):null}}(i,"_"+i);return n.Component.FixedToCamera=function(){},n.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},n.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(n){n?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new n.Point},n.Component.Health=function(){},n.Component.Health.prototype={health:1,maxHealth:100,damage:function(n){return this.alive&&(this.health-=n,this.health<=0&&this.kill()),this},setHealth:function(n){return this.health=n,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(n){return this.alive&&(this.health+=n,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},n.Component.InCamera=function(){},n.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},n.Component.InputEnabled=function(){},n.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new n.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},n.Component.InWorld=function(){},n.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},n.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},n.Component.LifeSpan=function(){},n.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):!(this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0))||(this.kill(),!1)},n.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(n){return void 0===n&&(n=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(n),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},n.Component.LoadTexture=function(){},n.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,i,r){var s,u;t===n.PENDING_ATLAS?(t=i,i=0):i=i||0;(r||void 0===r)&&this.animations&&this.animations.stop();this.key=t;this.customRender=!1;var f=this.game.cache,e=!0,o=this.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;n.RenderTexture&&t instanceof n.RenderTexture?(this.key=t.key,this.setTexture(t)):n.BitmapData&&t instanceof n.BitmapData?(this.customRender=!0,this.setTexture(t.texture),e=f.hasFrameData(t.key,n.Cache.BITMAPDATA)?!this.animations.loadFrameData(f.getFrameData(t.key,n.Cache.BITMAPDATA),i):!this.animations.loadFrameData(t.frameData,0)):n.Video&&t instanceof n.Video?(this.customRender=!0,s=t.texture.valid,this.setTexture(t.texture),this.setFrame(t.texture.frame.clone()),t.onChangeSource.add(this.resizeFrame,this),this.texture.valid=s):n.Tilemap&&t instanceof n.TilemapLayer?this.setTexture(PIXI.Texture.fromCanvas(t.canvas)):t instanceof PIXI.Texture?(o=t.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,this.setTexture(t)):(u=f.getImage(t,!0),this.key=u.key,this.setTexture(new PIXI.Texture(u.base)),this.texture.baseTexture.skipRender="__default"===t,e=!this.animations.loadFrameData(u.frameData,i));e&&(this._frame=n.Rectangle.clone(this.texture.frame));o||(this.texture.baseTexture.scaleMode=1)},setFrame:function(n){this._frame=n;this.texture.frame.x=n.x;this.texture.frame.y=n.y;this.texture.frame.width=n.width;this.texture.frame.height=n.height;this.texture.crop.x=n.x;this.texture.crop.y=n.y;this.texture.crop.width=n.width;this.texture.crop.height=n.height;n.trimmed?(this.texture.trim?(this.texture.trim.x=n.spriteSourceSizeX,this.texture.trim.y=n.spriteSourceSizeY,this.texture.trim.width=n.sourceSizeW,this.texture.trim.height=n.sourceSizeH):this.texture.trim={x:n.spriteSourceSizeX,y:n.spriteSourceSizeY,width:n.sourceSizeW,height:n.sourceSizeH},this.texture.width=n.sourceSizeW,this.texture.height=n.sourceSizeH,this.texture.frame.width=n.sourceSizeW,this.texture.frame.height=n.sourceSizeH):!n.trimmed&&this.texture.trim&&(this.texture.trim=null);n.rotated&&(this.texture.rotated=!0);this.cropRect&&this.updateCrop();this.texture.requiresReTint=!0;this.texture._updateUvs();this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(n,t,i){this.texture.frame.resize(t,i);this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(n){this.animations.frame=n}},frameName:{get:function(){return this.animations.frameName},set:function(n){this.animations.frameName=n}}},n.Component.Overlap=function(){},n.Component.Overlap.prototype={overlap:function(t){return n.Rectangle.intersects(this.getBounds(),t.getBounds())}},n.Component.PhysicsBody=function(){},n.Component.PhysicsBody.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,this.preUpdateChildren(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!(!this._exists||!this.parent.exists)||(this.renderOrderID=-1,!1))},n.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},n.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(n){this.position.x=n;this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(n){this.position.y=n;this.body&&!this.body.dirty&&(this.body._reset=!0)}}},n.Component.Reset=function(){},n.Component.Reset.prototype.reset=function(n,t,i){return void 0===i&&(i=1),this.world.set(n,t),this.position.set(n,t),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=i),this.components.PhysicsBody&&this.body&&this.body.reset(n,t,!1,!1),this},n.Component.ScaleMinMax=function(){},n.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(n){this.scaleMin&&(n.a<this.scaleMin.x&&(n.a=this.scaleMin.x),n.d<this.scaleMin.y&&(n.d=this.scaleMin.y));this.scaleMax&&(n.a>this.scaleMax.x&&(n.a=this.scaleMax.x),n.d>this.scaleMax.y&&(n.d=this.scaleMax.y))},setScaleMinMax:function(t,i,r,u){void 0===i?i=r=u=t:void 0===r&&(r=u=i,i=t);null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,i):this.scaleMin=new n.Point(t,i);null===r?this.scaleMax=null:this.scaleMax?this.scaleMax.set(r,u):this.scaleMax=new n.Point(r,u);null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},n.Component.Smoothed=function(){},n.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(n){n?this.texture&&0!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&1!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}},n.GameObjectFactory=function(n){this.game=n;this.world=this.game.world},n.GameObjectFactory.prototype={existing:function(n){return this.world.add(n)},weapon:function(t,i,r,u,f){var e=this.game.plugins.add(n.Weapon);return f&&(e.bulletClass=f),e.createBullets(t,i,r,u),e},image:function(t,i,r,u,f){return void 0===f&&(f=this.world),f.add(new n.Image(this.game,t,i,r,u))},sprite:function(t,i,r,u,f){return void 0===f&&(f=this.world),f.add(new n.Sprite(this.game,t,i,r,u))},creature:function(t,i,r,u,f,e,o){void 0===f&&(f=this.world);var s=new n.Creature(this.game,t,i,r,u,e,o);return f.add(s),s},tween:function(n){return this.game.tweens.create(n)},group:function(t,i,r,u,f){return new n.Group(this.game,t,i,r,u,f)},physicsGroup:function(t,i,r,u){return new n.Group(this.game,i,r,u,!0,t)},spriteBatch:function(t,i,r){return void 0===t&&(t=null),void 0===i&&(i="group"),void 0===r&&(r=!1),new n.SpriteBatch(this.game,t,i,r)},audio:function(n,t,i,r){return this.game.sound.add(n,t,i,r)},sound:function(n,t,i,r){return this.game.sound.add(n,t,i,r)},audioSprite:function(n){return this.game.sound.addSprite(n)},tileSprite:function(t,i,r,u,f,e,o){return void 0===o&&(o=this.world),o.add(new n.TileSprite(this.game,t,i,r,u,f,e))},rope:function(t,i,r,u,f,e){return void 0===e&&(e=this.world),e.add(new n.Rope(this.game,t,i,r,u,f))},text:function(t,i,r,u,f){return void 0===f&&(f=this.world),f.add(new n.Text(this.game,t,i,r,u))},button:function(t,i,r,u,f,e,o,s,h,c){return void 0===c&&(c=this.world),c.add(new n.Button(this.game,t,i,r,u,f,e,o,s,h))},graphics:function(t,i,r){return void 0===r&&(r=this.world),r.add(new n.Graphics(this.game,t,i))},emitter:function(t,i,r){return this.game.particles.add(new n.Particles.Arcade.Emitter(this.game,t,i,r))},retroFont:function(t,i,r,u,f,e,o,s,h){return new n.RetroFont(this.game,t,i,r,u,f,e,o,s,h)},bitmapText:function(t,i,r,u,f,e){return void 0===e&&(e=this.world),e.add(new n.BitmapText(this.game,t,i,r,u,f))},tilemap:function(t,i,r,u,f){return new n.Tilemap(this.game,t,i,r,u,f)},renderTexture:function(t,i,r,u){void 0!==r&&""!==r||(r=this.game.rnd.uuid());void 0===u&&(u=!1);var f=new n.RenderTexture(this.game,t,i,r);return u&&this.game.cache.addRenderTexture(r,f),f},video:function(t,i){return new n.Video(this.game,t,i)},bitmapData:function(t,i,r,u){void 0===u&&(u=!1);void 0!==r&&""!==r||(r=this.game.rnd.uuid());var f=new n.BitmapData(this.game,r,t,i);return u&&this.game.cache.addBitmapData(r,f),f},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new n.Filter[t](this.game)).init.apply(t,i),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},n.GameObjectFactory.prototype.constructor=n.GameObjectFactory,n.GameObjectCreator=function(n){this.game=n;this.world=this.game.world},n.GameObjectCreator.prototype={image:function(t,i,r,u){return new n.Image(this.game,t,i,r,u)},sprite:function(t,i,r,u){return new n.Sprite(this.game,t,i,r,u)},tween:function(t){return new n.Tween(t,this.game,this.game.tweens)},group:function(t,i,r,u,f){return new n.Group(this.game,t||null,i,r,u,f)},spriteBatch:function(t,i,r){return void 0===i&&(i="group"),void 0===r&&(r=!1),new n.SpriteBatch(this.game,t,i,r)},audio:function(n,t,i,r){return this.game.sound.add(n,t,i,r)},audioSprite:function(n){return this.game.sound.addSprite(n)},sound:function(n,t,i,r){return this.game.sound.add(n,t,i,r)},tileSprite:function(t,i,r,u,f,e){return new n.TileSprite(this.game,t,i,r,u,f,e)},rope:function(t,i,r,u,f){return new n.Rope(this.game,t,i,r,u,f)},text:function(t,i,r,u){return new n.Text(this.game,t,i,r,u)},button:function(t,i,r,u,f,e,o,s,h){return new n.Button(this.game,t,i,r,u,f,e,o,s,h)},graphics:function(t,i){return new n.Graphics(this.game,t,i)},emitter:function(t,i,r){return new n.Particles.Arcade.Emitter(this.game,t,i,r)},retroFont:function(t,i,r,u,f,e,o,s,h){return new n.RetroFont(this.game,t,i,r,u,f,e,o,s,h)},bitmapText:function(t,i,r,u,f,e){return new n.BitmapText(this.game,t,i,r,u,f,e)},tilemap:function(t,i,r,u,f){return new n.Tilemap(this.game,t,i,r,u,f)},renderTexture:function(t,i,r,u){void 0!==r&&""!==r||(r=this.game.rnd.uuid());void 0===u&&(u=!1);var f=new n.RenderTexture(this.game,t,i,r);return u&&this.game.cache.addRenderTexture(r,f),f},bitmapData:function(t,i,r,u){void 0===u&&(u=!1);void 0!==r&&""!==r||(r=this.game.rnd.uuid());var f=new n.BitmapData(this.game,r,t,i);return u&&this.game.cache.addBitmapData(r,f),f},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new n.Filter[t](this.game)).init.apply(t,i),t}},n.GameObjectCreator.prototype.constructor=n.GameObjectCreator,n.Sprite=function(t,i,r,u,f){i=i||0;r=r||0;u=u||null;f=f||null;this.type=n.SPRITE;this.physicsType=n.SPRITE;PIXI.Sprite.call(this,n.Cache.DEFAULT);n.Component.Core.init.call(this,t,i,r,u,f)},n.Sprite.prototype=Object.create(PIXI.Sprite.prototype),n.Sprite.prototype.constructor=n.Sprite,n.Component.Core.install.call(n.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),n.Sprite.prototype.preUpdatePhysics=n.Component.PhysicsBody.preUpdate,n.Sprite.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.Sprite.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.Sprite.prototype.preUpdateCore=n.Component.Core.preUpdate,n.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.Image=function(t,i,r,u,f){i=i||0;r=r||0;u=u||null;f=f||null;this.type=n.IMAGE;PIXI.Sprite.call(this,n.Cache.DEFAULT);n.Component.Core.init.call(this,t,i,r,u,f)},n.Image.prototype=Object.create(PIXI.Sprite.prototype),n.Image.prototype.constructor=n.Image,n.Component.Core.install.call(n.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),n.Image.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.Image.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.Image.prototype.preUpdateCore=n.Component.Core.preUpdate,n.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},n.Button=function(t,i,r,u,f,e,o,s,h,c){i=i||0;r=r||0;u=u||null;f=f||null;e=e||this;n.Image.call(this,t,i,r,u,s);this.type=n.BUTTON;this.physicsType=n.SPRITE;this._onOverFrame=null;this._onOutFrame=null;this._onDownFrame=null;this._onUpFrame=null;this.onOverSound=null;this.onOutSound=null;this.onDownSound=null;this.onUpSound=null;this.onOverSoundMarker="";this.onOutSoundMarker="";this.onDownSoundMarker="";this.onUpSoundMarker="";this.onInputOver=new n.Signal;this.onInputOut=new n.Signal;this.onInputDown=new n.Signal;this.onInputUp=new n.Signal;this.onOverMouseOnly=!0;this.justReleasedPreventsOver=n.PointerMode.CONTACT;this.freezeFrames=!1;this.forceOut=!1;this.inputEnabled=!0;this.input.start(0,!0);this.input.useHandCursor=!0;this.setFrames(o,s,h,c);null!==f&&this.onInputUp.add(f,e);this.events.onInputOver.add(this.onInputOverHandler,this);this.events.onInputOut.add(this.onInputOutHandler,this);this.events.onInputDown.add(this.onInputDownHandler,this);this.events.onInputUp.add(this.onInputUpHandler,this)},n.Button.prototype=Object.create(n.Image.prototype),n.Button.prototype.constructor=n.Button,n.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},n.Button.prototype.setStateFrame=function(n,t,i){var r="_on"+n+"Frame";null!==t?(this[r]=t,i&&this.changeStateFrame(n)):this[r]=null},n.Button.prototype.changeStateFrame=function(n){if(this.freezeFrames)return!1;var t=this["_on"+n+"Frame"];return"string"==typeof t?(this.frameName=t,!0):"number"==typeof t&&(this.frame=t,!0)},n.Button.prototype.setFrames=function(n,t,i,r){this.setStateFrame("Over",n,this.input.pointerOver());this.setStateFrame("Out",t,!this.input.pointerOver());this.setStateFrame("Down",i,this.input.pointerDown());this.setStateFrame("Up",r,this.input.pointerUp())},n.Button.prototype.setStateSound=function(t,i,r){var u="on"+t+"Sound",f="on"+t+"SoundMarker";i instanceof n.Sound||i instanceof n.AudioSprite?(this[u]=i,this[f]="string"==typeof r?r:""):(this[u]=null,this[f]="")},n.Button.prototype.playStateSound=function(n){var t=this["on"+n+"Sound"],i;return t?(i=this["on"+n+"SoundMarker"],t.play(i),!0):!1},n.Button.prototype.setSounds=function(n,t,i,r,u,f,e,o){this.setStateSound("Over",n,t);this.setStateSound("Out",u,f);this.setStateSound("Down",i,r);this.setStateSound("Up",e,o)},n.Button.prototype.setOverSound=function(n,t){this.setStateSound("Over",n,t)},n.Button.prototype.setOutSound=function(n,t){this.setStateSound("Out",n,t)},n.Button.prototype.setDownSound=function(n,t){this.setStateSound("Down",n,t)},n.Button.prototype.setUpSound=function(n,t){this.setStateSound("Up",n,t)},n.Button.prototype.onInputOverHandler=function(n,t){t.justReleased()&&(this.justReleasedPreventsOver&t.pointerMode)===t.pointerMode||(this.changeStateFrame("Over"),this.onOverMouseOnly&&!t.isMouse||(this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,t)))},n.Button.prototype.onInputOutHandler=function(n,t){this.changeStateFrame("Out");this.playStateSound("Out");this.onInputOut&&this.onInputOut.dispatch(this,t)},n.Button.prototype.onInputDownHandler=function(n,t){this.changeStateFrame("Down");this.playStateSound("Down");this.onInputDown&&this.onInputDown.dispatch(this,t)},n.Button.prototype.onInputUpHandler=function(n,t,i){this.playStateSound("Up");this.onInputUp&&this.onInputUp.dispatch(this,t,i);this.freezeFrames||(!0===this.forceOut||(this.forceOut&t.pointerMode)===t.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(i?this.changeStateFrame("Over"):this.changeStateFrame("Out")))},n.SpriteBatch=function(t,i,r,u){void 0!==i&&null!==i||(i=t.world);n.Group.call(this,t,i,r,u);this.type=n.SPRITEBATCH;this.fastSpriteBatch=null;this.ready=!1},n.SpriteBatch.prototype=Object.create(n.Group.prototype),n.SpriteBatch.prototype.constructor=n.SpriteBatch,n.SpriteBatch.prototype._renderWebGL=function(n){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(n.gl),this.ready=!0),this.fastSpriteBatch.gl!==n.gl&&this.fastSpriteBatch.setContext(n.gl),n.spriteBatch.stop(),n.shaderManager.setShader(n.shaderManager.fastShader),this.fastSpriteBatch.begin(this,n),this.fastSpriteBatch.render(this),n.spriteBatch.start())},n.SpriteBatch.prototype._renderCanvas=function(n){var u,t,o,i;if(this.visible&&!(this.alpha<=0)&&this.children.length){u=n.context;u.globalAlpha=this.worldAlpha;this.displayObjectUpdateTransform();for(var f=this.worldTransform,e=!0,s=0;s<this.children.length;s++)if(t=this.children[s],t.visible)if(o=t.texture,i=o.frame,u.globalAlpha=this.worldAlpha*t.alpha,t.rotation%(2*Math.PI)==0)e&&(u.setTransform(f.a,f.b,f.c,f.d,f.tx,f.ty),e=!1),u.drawImage(o.baseTexture.source,i.x,i.y,i.width,i.height,t.anchor.x*-i.width*t.scale.x+t.position.x+.5+n.shakeX|0,t.anchor.y*-i.height*t.scale.y+t.position.y+.5+n.shakeY|0,i.width*t.scale.x,i.height*t.scale.y);else{e||(e=!0);t.displayObjectUpdateTransform();var r=t.worldTransform,h=r.tx*n.resolution+n.shakeX,c=r.ty*n.resolution+n.shakeY;n.roundPixels?u.setTransform(r.a,r.b,r.c,r.d,0|h,0|c):u.setTransform(r.a,r.b,r.c,r.d,h,c);u.drawImage(o.baseTexture.source,i.x,i.y,i.width,i.height,t.anchor.x*-i.width+.5|0,t.anchor.y*-i.height+.5|0,i.width,i.height)}}},n.BitmapData=function(t,i,r,u,f){void 0!==r&&0!==r||(r=256);void 0!==u&&0!==u||(u=256);void 0===f&&(f=!1);this.game=t;this.key=i;this.width=r;this.height=u;this.canvas=n.Canvas.create(this,r,u,null,f);this.context=this.canvas.getContext("2d",{alpha:!0});this.ctx=this.context;this.smoothProperty=t.renderType===n.CANVAS?t.renderer.renderSession.smoothProperty:n.Canvas.getSmoothingPrefix(this.context);this.imageData=this.context.getImageData(0,0,r,u);this.data=null;this.imageData&&(this.data=this.imageData.data);this.pixels=null;this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data);this.baseTexture=new PIXI.BaseTexture(this.canvas,null,this.game.resolution);this.texture=new PIXI.Texture(this.baseTexture);this.frameData=new n.FrameData;this.textureFrame=this.frameData.addFrame(new n.Frame(0,0,0,r,u,"bitmapData"));this.texture.frame=this.textureFrame;this.type=n.BITMAPDATA;this.disableTextureUpload=!1;this.dirty=!1;this.cls=this.clear;this._image=null;this._pos=new n.Point;this._size=new n.Point;this._scale=new n.Point;this._rotate=0;this._alpha={prev:1,current:1};this._anchor=new n.Point;this._tempR=0;this._tempG=0;this._tempB=0;this._circle=new n.Circle;this._swapCanvas=void 0},n.BitmapData.prototype={move:function(n,t,i){return 0!==n&&this.moveH(n,i),0!==t&&this.moveV(t,i),this},moveH:function(t,i){var u;void 0===i&&(i=!0);void 0===this._swapCanvas&&(this._swapCanvas=n.CanvasPool.create(this,this.width,this.height));var f=this._swapCanvas.getContext("2d"),r=this.height,e=this.canvas;return(f.clearRect(0,0,this.width,this.height),t<0)?(t=Math.abs(t),u=this.width-t,i&&f.drawImage(e,0,0,t,r,u,0,t,r),f.drawImage(e,t,0,u,r,0,0,u,r)):(u=this.width-t,i&&f.drawImage(e,u,0,t,r,0,0,t,r),f.drawImage(e,0,0,u,r,t,0,u,r)),this.clear(),this.copy(this._swapCanvas)},moveV:function(t,i){var u;void 0===i&&(i=!0);void 0===this._swapCanvas&&(this._swapCanvas=n.CanvasPool.create(this,this.width,this.height));var f=this._swapCanvas.getContext("2d"),r=this.width,e=this.canvas;return(f.clearRect(0,0,this.width,this.height),t<0)?(t=Math.abs(t),u=this.height-t,i&&f.drawImage(e,0,0,r,t,0,u,r,t),f.drawImage(e,0,t,r,u,0,0,r,u)):(u=this.height-t,i&&f.drawImage(e,0,u,r,t,0,0,r,t),f.drawImage(e,0,0,r,u,0,t,r,u)),this.clear(),this.copy(this._swapCanvas)},add:function(n){if(Array.isArray(n))for(var t=0;t<n.length;t++)n[t].loadTexture&&n[t].loadTexture(this);else n.loadTexture(this);return this},load:function(n){if("string"==typeof n&&(n=this.game.cache.getImage(n)),n)return this.resize(n.width,n.height),this.cls(),this.draw(n),this.update(),this},clear:function(n,t,i,r){return void 0===n&&(n=0),void 0===t&&(t=0),void 0===i&&(i=this.width),void 0===r&&(r=this.height),this.context.clearRect(n,t,i,r),this.dirty=!0,this},fill:function(n,t,i,r){return void 0===r&&(r=1),this.context.fillStyle="rgba("+n+","+t+","+i+","+r+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(n,t,i){var u=this.game.cache,r=new Image,f;return(t&&(r.onload=function(){var f=u.addImage(n,"",r),e=new PIXI.Texture(f.base);t.call(i||null,e);r.onload=null}),r.src=this.canvas.toDataURL("image/png"),!t)?(f=u.addImage(n,"",r),new PIXI.Texture(f.base)):null},resize:function(n,t){return n===this.width&&t===this.height||(this.width=n,this.height=t,this.canvas.width=n,this.canvas.height=t,void 0!==this._swapCanvas&&(this._swapCanvas.width=n,this._swapCanvas.height=t),this.baseTexture.width=n,this.baseTexture.height=t,this.textureFrame.width=n,this.textureFrame.height=t,this.texture.width=n,this.texture.height=t,this.texture.crop.width=n,this.texture.crop.height=t,this.update(),this.dirty=!0),this},update:function(n,t,i,r){return void 0===n&&(n=0),void 0===t&&(t=0),void 0===i&&(i=Math.max(1,this.width)),void 0===r&&(r=Math.max(1,this.height)),this.imageData=this.context.getImageData(n,t,i,r),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(t,i,r,u,f,e){var s;void 0===r&&(r=0);void 0===u&&(u=0);void 0===f&&(f=this.width);void 0===e&&(e=this.height);for(var a=r+f,v=u+e,c=n.Color.createColor(),o={r:0,g:0,b:0,a:0},l=!1,h=u;h<v;h++)for(s=r;s<a;s++)n.Color.unpackPixel(this.getPixel32(s,h),c),!1!==(o=t.call(i,c,s,h))&&null!==o&&void 0!==o&&(this.setPixel32(s,h,o.r,o.g,o.b,o.a,!1),l=!0);return l&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(n,t,i,r,u,f){var e;void 0===i&&(i=0);void 0===r&&(r=0);void 0===u&&(u=this.width);void 0===f&&(f=this.height);for(var l=i+u,a=r+f,s=0,h=0,c=!1,o=r;o<a;o++)for(e=i;e<l;e++)s=this.getPixel32(e,o),(h=n.call(t,s,e,o))!==s&&(this.pixels[o*this.width+e]=h,c=!0);return c&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(t,i,r,u,f,e,o,s,h){var a=0,v=0,y=this.width,p=this.height,w=n.Color.packPixel(t,i,r,u),c,l;for(void 0!==h&&h instanceof n.Rectangle&&(a=h.x,v=h.y,y=h.width,p=h.height),c=0;c<p;c++)for(l=0;l<y;l++)this.getPixel32(a+l,v+c)===w&&this.setPixel32(a+l,v+c,f,e,o,s,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(t,i,r,u){var s=t||0===t,h=i||0===i,c=r||0===r,f,e,o;if(s||h||c){for(void 0===u&&(u=new n.Rectangle(0,0,this.width,this.height)),f=n.Color.createColor(),e=u.y;e<u.bottom;e++)for(o=u.x;o<u.right;o++)n.Color.unpackPixel(this.getPixel32(o,e),f,!0),s&&(f.h=t),h&&(f.s=i),c&&(f.l=r),n.Color.HSLtoRGB(f.h,f.s,f.l,f),this.setPixel32(o,e,f.r,f.g,f.b,f.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(t,i,r,u){var f,e,o;if(void 0!==t&&null!==t||(t=!1),void 0!==i&&null!==i||(i=!1),void 0!==r&&null!==r||(r=!1),t||i||r){for(void 0===u&&(u=new n.Rectangle(0,0,this.width,this.height)),f=n.Color.createColor(),e=u.y;e<u.bottom;e++)for(o=u.x;o<u.right;o++)n.Color.unpackPixel(this.getPixel32(o,e),f,!0),t&&(f.h=this.game.math.wrap(f.h+t,0,1)),i&&(f.s=this.game.math.clamp(f.s+i,0,1)),r&&(f.l=this.game.math.clamp(f.l+r,0,1)),n.Color.HSLtoRGB(f.h,f.s,f.l,f),this.setPixel32(o,e,f.r,f.g,f.b,f.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(t,i,r,u,f,e,o){return void 0===o&&(o=!0),t>=0&&t<=this.width&&i>=0&&i<=this.height&&(this.pixels[i*this.width+t]=n.Device.LITTLE_ENDIAN?e<<24|f<<16|u<<8|r:r<<24|u<<16|f<<8|e,o&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(n,t,i,r,u,f){return this.setPixel32(n,t,i,r,u,255,f)},getPixel:function(t,i,r){r||(r=n.Color.createColor());var u=~~(t+i*this.width);return u*=4,r.r=this.data[u],r.g=this.data[++u],r.b=this.data[++u],r.a=this.data[++u],r},getPixel32:function(n,t){if(n>=0&&n<=this.width&&t>=0&&t<=this.height)return this.pixels[t*this.width+n]},getPixelRGB:function(t,i,r,u,f){return n.Color.unpackPixel(this.getPixel32(t,i),r,u,f)},getPixels:function(n){return this.context.getImageData(n.x,n.y,n.width,n.height)},getFirstPixel:function(t){void 0===t&&(t=0);var u=n.Color.createColor(),i=0,r=0,f=1,e=!1;1===t?(f=-1,r=this.height):3===t&&(f=-1,i=this.width);do n.Color.unpackPixel(this.getPixel32(i,r),u),0===t||1===t?++i===this.width&&(i=0,((r+=f)>=this.height||r<=0)&&(e=!0)):2!==t&&3!==t||++r===this.height&&(r=0,((i+=f)>=this.width||i<=0)&&(e=!0));while(0===u.a&&!e);return u.x=i,u.y=r,u},getBounds:function(t){return void 0===t&&(t=new n.Rectangle),t.x=this.getFirstPixel(2).x,t.x===this.width?t.setTo(0,0,0,0):(t.y=this.getFirstPixel(0).y,t.width=this.getFirstPixel(3).x-t.x+1,t.height=this.getFirstPixel(1).y-t.y+1,t)},addToWorld:function(n,t,i,r,u,f){u=u||1;f=f||1;var e=this.game.add.image(n,t,this);return e.anchor.set(i,r),e.scale.set(u,f),e},copy:function(t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b){if(void 0!==t&&null!==t||(t=this),t instanceof n.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof n.Sprite||t instanceof n.Image||t instanceof n.Text||t instanceof PIXI.Sprite)this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),this._scale.set(t.scale.x,t.scale.y),this._anchor.set(t.anchor.x,t.anchor.y),this._rotate=t.rotation,this._alpha.current=t.alpha,this._image=t.texture instanceof n.RenderTexture?t.texture.getCanvas():t.texture.baseTexture.source,void 0!==e&&null!==e||(e=t.x),void 0!==o&&null!==o||(o=t.y),t.texture.trim&&(e+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,t instanceof n.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return this;this._image=t}this._size.set(this._image.width,this._image.height)}if(void 0!==i&&null!==i||(i=0),void 0!==r&&null!==r||(r=0),u&&(this._size.x=u),f&&(this._size.y=f),void 0!==e&&null!==e||(e=i),void 0!==o&&null!==o||(o=r),void 0!==s&&null!==s||(s=this._size.x),void 0!==h&&null!==h||(h=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof l&&(this._anchor.x=l),"number"==typeof a&&(this._anchor.y=a),"number"==typeof v&&(this._scale.x=v),"number"==typeof y&&(this._scale.y=y),"number"==typeof p&&(this._alpha.current=p),void 0===w&&(w=null),void 0===b&&(b=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var k=this.context;return this._alpha.prev=k.globalAlpha,k.save(),k.globalAlpha=this._alpha.current,w&&(this.op=w),b&&(e|=0,o|=0),k.translate(e,o),k.scale(this._scale.x,this._scale.y),k.rotate(this._rotate),k.drawImage(this._image,this._pos.x+i,this._pos.y+r,this._size.x,this._size.y,-s*this._anchor.x,-h*this._anchor.y,s,h),k.restore(),k.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,i,r){var u,e,o,f;return(void 0===i&&(i=null),void 0===r&&(r=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)?this:(u=t.worldTransform,this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===u.a||0===u.d||0===this._size.x||0===this._size.y)?this:(this._image=t.texture instanceof n.RenderTexture?t.texture.getCanvas():t.texture.baseTexture.source,e=u.tx,o=u.ty,t.texture.trim&&(e+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0)),r&&(e|=0,o|=0),f=this.context,this._alpha.prev=f.globalAlpha,f.save(),f.globalAlpha=this._alpha.current,i&&(this.op=i),f[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,f.setTransform(u.a,u.b,u.c,u.d,e,o),f.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*t.anchor.x,-this._size.y*t.anchor.y,this._size.x,this._size.y),f.restore(),f.globalAlpha=this._alpha.prev,this.dirty=!0,this)},copyRect:function(n,t,i,r,u,f,e){return this.copy(n,t.x,t.y,t.width,t.height,i,r,t.width,t.height,0,0,0,1,1,u,f,e)},draw:function(n,t,i,r,u,f,e){return this.copy(n,null,null,null,null,t,i,r,u,null,null,null,null,null,null,f,e)},drawGroup:function(n,t,i){return n.total>0&&n.forEachExists(this.drawGroupProxy,this,t,i),this},drawGroupProxy:function(t,i,r){if(t.hasOwnProperty("texture")&&this.copyTransform(t,i,r),t.type===n.GROUP&&t.exists)this.drawGroup(t,i,r);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var u=0;u<t.children.length;u++)t.children[u].exists&&this.copyTransform(t.children[u],i,r)},drawFull:function(t,i,r){var f,u;if(!1===t.worldVisible||0===t.worldAlpha||t.hasOwnProperty("exists")&&!1===t.exists)return this;if(t.type!==n.GROUP&&t.type!==n.EMITTER&&t.type!==n.BITMAPTEXT&&(t.type===n.GRAPHICS?(f=t.getBounds(),this.ctx.save(),this.ctx.translate(f.x,f.y),PIXI.CanvasGraphics.renderGraphics(t,this.ctx),this.ctx.restore()):this.copy(t,null,null,null,null,t.worldPosition.x,t.worldPosition.y,null,null,t.worldRotation,null,null,t.worldScale.x,t.worldScale.y,t.worldAlpha,i,r)),t.children)for(u=0;u<t.children.length;u++)this.drawFull(t.children[u],i,r);return this},shadow:function(n,t,i,r){var u=this.context;return void 0===n||null===n?u.shadowColor="rgba(0,0,0,0)":(u.shadowColor=n,u.shadowBlur=0===t?0:t||5,u.shadowOffsetX=0===i?0:i||10,u.shadowOffsetY=0===r?0:r||10),this},alphaMask:function(n,t,i,r){return void 0===r||null===r?this.draw(t).blendSourceAtop():this.draw(t,r.x,r.y,r.width,r.height).blendSourceAtop(),void 0===i||null===i?this.draw(n).blendReset():this.draw(n,i.x,i.y,i.width,i.height).blendReset(),this},extract:function(n,t,i,r,u,f,e,o,s){return void 0===u&&(u=255),void 0===f&&(f=!1),void 0===e&&(e=t),void 0===o&&(o=i),void 0===s&&(s=r),f&&n.resize(this.width,this.height),this.processPixelRGB(function(f,h,c){return f.r===t&&f.g===i&&f.b===r&&n.setPixel32(h,c,e,o,s,u,!1),!1},this),n.context.putImageData(n.imageData,0,0),n.dirty=!0,n},rect:function(n,t,i,r,u){return void 0!==u&&(this.context.fillStyle=u),this.context.fillRect(n,t,i,r),this},text:function(n,t,i,r,u,f){void 0===t&&(t=0);void 0===i&&(i=0);void 0===r&&(r="14px Courier");void 0===u&&(u="rgb(255,255,255)");void 0===f&&(f=!0);var e=this.context,o=e.font;return e.font=r,f&&(e.fillStyle="rgb(0,0,0)",e.fillText(n,t+1,i+1)),e.fillStyle=u,e.fillText(n,t,i),e.font=o,this},circle:function(n,t,i,r){var u=this.context;return void 0!==r&&(u.fillStyle=r),u.beginPath(),u.arc(n,t,i,0,2*Math.PI,!1),u.closePath(),u.fill(),this},line:function(n,t,i,r,u,f){void 0===u&&(u="#fff");void 0===f&&(f=1);var e=this.context;return e.beginPath(),e.moveTo(n,t),e.lineTo(i,r),e.lineWidth=f,e.strokeStyle=u,e.stroke(),e.closePath(),this},polygon:function(n,t,i,r){var u,f,o,e;for(void 0===r&&(r="#fff"),void 0===i&&(i=0),u=this.context,t&&(u.fillStyle=t),i&&(u.lineWidth=i,u.strokeStyle=r),u.beginPath(),u.moveTo(n[0].x,n[0].y),f=1,o=n.length;f<o;f++)e=n[f],u.lineTo(e.x,e.y);return u.closePath(),t&&u.fill(),i&&u.stroke(),this},textureLine:function(t,i,r){var f,u;if(void 0===r&&(r="repeat-x"),"string"!=typeof i||(i=this.game.cache.getImage(i)))return f=t.length,"no-repeat"===r&&f>i.width&&(f=i.width),u=this.context,u.fillStyle=u.createPattern(i,r),this._circle=new n.Circle(t.start.x,t.start.y,i.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),u.save(),u.translate(this._pos.x,this._pos.y),u.rotate(t.angle),u.fillRect(0,0,f,i.height),u.restore(),this.dirty=!0,this},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy();this.texture.destroy(!0);n.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(n,t,i){var f,r,u;for(n.update(),r=0;r<n.height;r++)for(f=(i+r)*this.width+t,u=0;u<n.width;u++)this.pixels[f+u]=n.pixels[r*n.width+u];return this}},Object.defineProperty(n.BitmapData.prototype,"smoothed",{get:function(){return n.Canvas.getSmoothingEnabled(this.context)},set:function(t){n.Canvas.setSmoothingEnabled(this.context,t)}}),Object.defineProperty(n.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(n){this.context.globalCompositeOperation=n}}),n.BitmapData.getTransform=function(n,t,i,r,u,f){return"number"!=typeof n&&(n=0),"number"!=typeof t&&(t=0),"number"!=typeof i&&(i=1),"number"!=typeof r&&(r=1),"number"!=typeof u&&(u=0),"number"!=typeof f&&(f=0),{sx:i,sy:r,scaleX:i,scaleY:r,skewX:u,skewY:f,translateX:n,translateY:t,tx:n,ty:t}},n.BitmapData.prototype.constructor=n.BitmapData,n.EarCut={},n.EarCut.Triangulate=function(t,i,r){var u,f,c,l,e,o,p,s;r=r||2;var v=i&&i.length,y=v?i[0]*r:t.length,h=n.EarCut.linkedList(t,0,y,r,!0),a=[];if(!h)return a;if(v&&(h=n.EarCut.eliminateHoles(t,i,h,r)),t.length>80*r){for(u=c=t[0],f=l=t[1],s=r;s<y;s+=r)e=t[s],o=t[s+1],e<u&&(u=e),o<f&&(f=o),e>c&&(c=e),o>l&&(l=o);p=Math.max(c-u,l-f)}return n.EarCut.earcutLinked(h,a,r,u,f,p),a},n.EarCut.linkedList=function(t,i,r,u,f){for(var o,h=0,e=i,s=r-u;e<r;e+=u)h+=(t[s]-t[e])*(t[e+1]+t[s+1]),s=e;if(f===h>0)for(e=i;e<r;e+=u)o=n.EarCut.insertNode(e,t[e],t[e+1],o);else for(e=r-u;e>=i;e-=u)o=n.EarCut.insertNode(e,t[e],t[e+1],o);return o},n.EarCut.filterPoints=function(t,i){if(!t)return t;i||(i=t);var u,r=t;do if(u=!1,r.steiner||!n.EarCut.equals(r,r.next)&&0!==n.EarCut.area(r.prev,r,r.next))r=r.next;else{if(n.EarCut.removeNode(r),(r=i=r.prev)===r.next)return null;u=!0}while(u||r!==i);return i},n.EarCut.earcutLinked=function(t,i,r,u,f,e,o){if(t){!o&&e&&n.EarCut.indexCurve(t,u,f,e);for(var h,s,c=t;t.prev!==t.next;)if(h=t.prev,s=t.next,e?n.EarCut.isEarHashed(t,u,f,e):n.EarCut.isEar(t))i.push(h.i/r),i.push(t.i/r),i.push(s.i/r),n.EarCut.removeNode(t),t=s.next,c=s.next;else if((t=s)===c){o?1===o?(t=n.EarCut.cureLocalIntersections(t,i,r),n.EarCut.earcutLinked(t,i,r,u,f,e,2)):2===o&&n.EarCut.splitEarcut(t,i,r,u,f,e):n.EarCut.earcutLinked(n.EarCut.filterPoints(t),i,r,u,f,e,1);break}}},n.EarCut.isEar=function(t){var r=t.prev,u=t,f=t.next,i;if(n.EarCut.area(r,u,f)>=0)return!1;for(i=t.next.next;i!==t.prev;){if(n.EarCut.pointInTriangle(r.x,r.y,u.x,u.y,f.x,f.y,i.x,i.y)&&n.EarCut.area(i.prev,i,i.next)>=0)return!1;i=i.next}return!0},n.EarCut.isEarHashed=function(t,i,r,u){var o=t.prev,s=t,e=t.next;if(n.EarCut.area(o,s,e)>=0)return!1;for(var h=o.x<s.x?o.x<e.x?o.x:e.x:s.x<e.x?s.x:e.x,c=o.y<s.y?o.y<e.y?o.y:e.y:s.y<e.y?s.y:e.y,l=o.x>s.x?o.x>e.x?o.x:e.x:s.x>e.x?s.x:e.x,a=o.y>s.y?o.y>e.y?o.y:e.y:s.y>e.y?s.y:e.y,v=n.EarCut.zOrder(h,c,i,r,u),y=n.EarCut.zOrder(l,a,i,r,u),f=t.nextZ;f&&f.z<=y;){if(f!==t.prev&&f!==t.next&&n.EarCut.pointInTriangle(o.x,o.y,s.x,s.y,e.x,e.y,f.x,f.y)&&n.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=v;){if(f!==t.prev&&f!==t.next&&n.EarCut.pointInTriangle(o.x,o.y,s.x,s.y,e.x,e.y,f.x,f.y)&&n.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},n.EarCut.cureLocalIntersections=function(t,i,r){var u=t,e,f;do e=u.prev,f=u.next.next,n.EarCut.intersects(e,u,u.next,f)&&n.EarCut.locallyInside(e,f)&&n.EarCut.locallyInside(f,e)&&(i.push(e.i/r),i.push(u.i/r),i.push(f.i/r),n.EarCut.removeNode(u),n.EarCut.removeNode(u.next),u=t=f),u=u.next;while(u!==t);return u},n.EarCut.splitEarcut=function(t,i,r,u,f,e){var o=t,s,h;do{for(s=o.next.next;s!==o.prev;){if(o.i!==s.i&&n.EarCut.isValidDiagonal(o,s))return h=n.EarCut.splitPolygon(o,s),o=n.EarCut.filterPoints(o,o.next),h=n.EarCut.filterPoints(h,h.next),n.EarCut.earcutLinked(o,i,r,u,f,e),void n.EarCut.earcutLinked(h,i,r,u,f,e);s=s.next}o=o.next}while(o!==t)},n.EarCut.eliminateHoles=function(t,i,r,u){for(var h,c,e,o=[],f=0,s=i.length;f<s;f++)h=i[f]*u,c=f<s-1?i[f+1]*u:t.length,(e=n.EarCut.linkedList(t,h,c,u,!1))===e.next&&(e.steiner=!0),o.push(n.EarCut.getLeftmost(e));for(o.sort(n.EarCut.compareX),f=0;f<o.length;f++)n.EarCut.eliminateHole(o[f],r),r=n.EarCut.filterPoints(r,r.next);return r},n.EarCut.compareX=function(n,t){return n.x-t.x},n.EarCut.eliminateHole=function(t,i){if(i=n.EarCut.findHoleBridge(t,i)){var r=n.EarCut.splitPolygon(i,t);n.EarCut.filterPoints(r,r.next)}},n.EarCut.findHoleBridge=function(t,i){var u,r=i,e=t.x,f=t.y,o=-1/0,s,c,l,h;do f<=r.y&&f>=r.next.y&&(s=r.x+(f-r.y)*(r.next.x-r.x)/(r.next.y-r.y),s<=e&&s>o&&(o=s,u=r.x<r.next.x?r:r.next)),r=r.next;while(r!==i);if(!u)return null;if(t.x===u.x)return u.prev;for(l=u,h=1/0,r=u.next;r!==l;)e>=r.x&&r.x>=u.x&&n.EarCut.pointInTriangle(f<u.y?e:o,f,u.x,u.y,f<u.y?o:e,f,r.x,r.y)&&((c=Math.abs(f-r.y)/(e-r.x))<h||c===h&&r.x>u.x)&&n.EarCut.locallyInside(r,t)&&(u=r,h=c),r=r.next;return u},n.EarCut.indexCurve=function(t,i,r,u){var f=t;do null===f.z&&(f.z=n.EarCut.zOrder(f.x,f.y,i,r,u)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==t);f.prevZ.nextZ=null;f.prevZ=null;n.EarCut.sortLinked(f)},n.EarCut.sortLinked=function(n){var o,i,t,r,u,s,f,e,h=1;do{for(i=n,n=null,u=null,s=0;i;){for(s++,t=i,f=0,o=0;o<h&&(f++,t=t.nextZ);o++);for(e=h;f>0||e>0&&t;)0===f?(r=t,t=t.nextZ,e--):0!==e&&t?i.z<=t.z?(r=i,i=i.nextZ,f--):(r=t,t=t.nextZ,e--):(r=i,i=i.nextZ,f--),u?u.nextZ=r:n=r,r.prevZ=u,u=r;i=t}u.nextZ=null;h*=2}while(s>1);return n},n.EarCut.zOrder=function(n,t,i,r,u){return n=32767*(n-i)/u,t=32767*(t-r)/u,n=16711935&(n|n<<8),n=252645135&(n|n<<4),n=858993459&(n|n<<2),n=1431655765&(n|n<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),n|t<<1},n.EarCut.getLeftmost=function(n){var t=n,i=n;do t.x<i.x&&(i=t),t=t.next;while(t!==n);return i},n.EarCut.pointInTriangle=function(n,t,i,r,u,f,e,o){return(u-e)*(t-o)-(n-e)*(f-o)>=0&&(n-e)*(r-o)-(i-e)*(t-o)>=0&&(i-e)*(f-o)-(u-e)*(r-o)>=0},n.EarCut.isValidDiagonal=function(t,i){return n.EarCut.equals(t,i)||t.next.i!==i.i&&t.prev.i!==i.i&&!n.EarCut.intersectsPolygon(t,i)&&n.EarCut.locallyInside(t,i)&&n.EarCut.locallyInside(i,t)&&n.EarCut.middleInside(t,i)},n.EarCut.area=function(n,t,i){return(t.y-n.y)*(i.x-t.x)-(t.x-n.x)*(i.y-t.y)},n.EarCut.equals=function(n,t){return n.x===t.x&&n.y===t.y},n.EarCut.intersects=function(t,i,r,u){return n.EarCut.area(t,i,r)>0!=n.EarCut.area(t,i,u)>0&&n.EarCut.area(r,u,t)>0!=n.EarCut.area(r,u,i)>0},n.EarCut.intersectsPolygon=function(t,i){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==i.i&&r.next.i!==i.i&&n.EarCut.intersects(r,r.next,t,i))return!0;r=r.next}while(r!==t);return!1},n.EarCut.locallyInside=function(t,i){return n.EarCut.area(t.prev,t,t.next)<0?n.EarCut.area(t,i,t.next)>=0&&n.EarCut.area(t,t.prev,i)>=0:n.EarCut.area(t,i,t.prev)<0||n.EarCut.area(t,t.next,i)<0},n.EarCut.middleInside=function(n,t){var i=n,r=!1,f=(n.x+t.x)/2,u=(n.y+t.y)/2;do i.y>u!=i.next.y>u&&f<(i.next.x-i.x)*(u-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==n);return r},n.EarCut.splitPolygon=function(t,i){var u=new n.EarCut.Node(t.i,t.x,t.y),r=new n.EarCut.Node(i.i,i.x,i.y),f=t.next,e=i.prev;return t.next=i,i.prev=t,u.next=f,f.prev=u,r.next=u,u.prev=r,e.next=r,r.prev=e,r},n.EarCut.insertNode=function(t,i,r,u){var f=new n.EarCut.Node(t,i,r);return u?(f.next=u.next,f.prev=u,u.next.prev=f,u.next=f):(f.prev=f,f.next=f),f},n.EarCut.removeNode=function(n){n.next.prev=n.prev;n.prev.next=n.next;n.prevZ&&(n.prevZ.nextZ=n.nextZ);n.nextZ&&(n.nextZ.prevZ=n.prevZ)},n.EarCut.Node=function(n,t,i){this.i=n;this.x=t;this.y=i;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(t,i){var f,r=i.gl,s=i.projection,h=i.offset,u=i.shaderManager.primitiveShader,e,o;if(t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,r),e=t._webGL[r.id],e)for(o=0;o<e.data.length;o++)1===e.data[o].mode?(f=e.data[o],i.stencilManager.pushStencil(t,f,i),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(f.indices.length-4)),i.stencilManager.popStencil(t,f,i)):(f=e.data[o],i.shaderManager.setShader(u),u=i.shaderManager.primitiveShader,r.uniformMatrix3fv(u.translationMatrix,!1,t.worldTransform.toArray(!0)),r.uniform1f(u.flipY,1),r.uniform2f(u.projectionVector,s.x,-s.y),r.uniform2f(u.offsetVector,-h.x,-h.y),r.uniform3fv(u.tintColor,n.Color.hexToRGBArray(t.tint)),r.uniform1f(u.alpha,t.worldAlpha),r.bindBuffer(r.ARRAY_BUFFER,f.buffer),r.vertexAttribPointer(u.aVertexPosition,2,r.FLOAT,!1,24,0),r.vertexAttribPointer(u.colorAttribute,4,r.FLOAT,!1,24,8),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,f.indexBuffer),r.drawElements(r.TRIANGLE_STRIP,f.indices.length,r.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(t,i){var u=t._webGL[i.id],e,o,f,r;if(u||(u=t._webGL[i.id]={lastIndex:0,data:[],gl:i}),t.dirty=!1,t.clearDirty){for(t.clearDirty=!1,e=0;e<u.data.length;e++)o=u.data[e],o.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(o);u.data=[];u.lastIndex=0}for(e=u.lastIndex;e<t.graphicsData.length;e++)r=t.graphicsData[e],r.type===n.POLYGON?(r.points=r.shape.points.slice(),r.shape.closed&&(r.points[0]===r.points[r.points.length-2]&&r.points[1]===r.points[r.points.length-1]||r.points.push(r.points[0],r.points[1])),r.fill&&r.points.length>=PIXI.WebGLGraphics.stencilBufferLimit&&(r.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(f=PIXI.WebGLGraphics.switchMode(u,0),PIXI.WebGLGraphics.buildPoly(r,f)||(f=PIXI.WebGLGraphics.switchMode(u,1),PIXI.WebGLGraphics.buildComplexPoly(r,f))):(f=PIXI.WebGLGraphics.switchMode(u,1),PIXI.WebGLGraphics.buildComplexPoly(r,f))),r.lineWidth>0&&(f=PIXI.WebGLGraphics.switchMode(u,0),PIXI.WebGLGraphics.buildLine(r,f))):(f=PIXI.WebGLGraphics.switchMode(u,0),r.type===n.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(r,f):r.type===n.CIRCLE||r.type===n.ELLIPSE?PIXI.WebGLGraphics.buildCircle(r,f):r.type===n.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(r,f)),u.lastIndex++;for(e=0;e<u.data.length;e++)(f=u.data[e]).dirty&&f.upload()},PIXI.WebGLGraphics.switchMode=function(n,t){var i;return n.data.length?(i=n.data[n.data.length-1]).mode===t&&1!==t||((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(n.gl)).mode=t,n.data.push(i)):((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(n.gl)).mode=t,n.data.push(i)),i.dirty=!0,i},PIXI.WebGLGraphics.buildRectangle=function(t,i){var s=t.shape,r=s.x,u=s.y,h=s.width,c=s.height,p;if(t.fill){var y=n.Color.hexToRGBArray(t.fillColor),e=t.fillAlpha,l=y[0]*e,a=y[1]*e,v=y[2]*e,f=i.points,w=i.indices,o=f.length/6;f.push(r,u);f.push(l,a,v,e);f.push(r+h,u);f.push(l,a,v,e);f.push(r,u+c);f.push(l,a,v,e);f.push(r+h,u+c);f.push(l,a,v,e);w.push(o,o,o+1,o+2,o+3,o+3)}t.lineWidth&&(p=t.points,t.points=[r,u,r+h,u,r+h,u+c,r,u+c,r,u],PIXI.WebGLGraphics.buildLine(t,i),t.points=p)},PIXI.WebGLGraphics.buildRoundedRectangle=function(t,i){var l=t.shape,u=l.x,f=l.y,s=l.width,h=l.height,o=l.radius,r=[],b;if(r.push(u,f+o),r=r.concat(PIXI.WebGLGraphics.quadraticBezierCurve(u,f+h-o,u,f+h,u+o,f+h)),r=r.concat(PIXI.WebGLGraphics.quadraticBezierCurve(u+s-o,f+h,u+s,f+h,u+s,f+h-o)),r=r.concat(PIXI.WebGLGraphics.quadraticBezierCurve(u+s,f+o,u+s,f,u+s-o,f)),r=r.concat(PIXI.WebGLGraphics.quadraticBezierCurve(u+o,f,u,f,u,f+o)),t.fill){for(var p=n.Color.hexToRGBArray(t.fillColor),y=t.fillAlpha,k=p[0]*y,d=p[1]*y,g=p[2]*y,w=i.points,a=i.indices,v=w.length/6,c=n.EarCut.Triangulate(r,null,2),e=0,e=0;e<c.length;e+=3)a.push(c[e]+v),a.push(c[e]+v),a.push(c[e+1]+v),a.push(c[e+2]+v),a.push(c[e+2]+v);for(e=0;e<r.length;e++)w.push(r[e],r[++e],k,d,g,y)}t.lineWidth&&(b=t.points,t.points=r,PIXI.WebGLGraphics.buildLine(t,i),t.points=b)},PIXI.WebGLGraphics.quadraticBezierCurve=function(n,t,i,r,u,f){function e(n,t,i){return n+(t-n)*i}for(var h,c,l,a,v,y,p=[],o=0,s=0;s<=20;s++)h=e(n,i,o=s/20),c=e(t,r,o),l=e(i,u,o),a=e(r,f,o),v=e(h,l,o),y=e(c,a,o),p.push(v,y);return p},PIXI.WebGLGraphics.buildCircle=function(t,i){var o,s,u=t.shape,c=u.x,l=u.y,f,r,k;if(t.type===n.CIRCLE?(o=u.radius,s=u.radius):(o=u.width,s=u.height),f=Math.PI/20,r=0,t.fill){var a=n.Color.hexToRGBArray(t.fillColor),e=t.fillAlpha,p=a[0]*e,w=a[1]*e,b=a[2]*e,v=i.points,y=i.indices,h=v.length/6;for(y.push(h),r=0;r<41;r++)v.push(c,l,p,w,b,e),v.push(c+Math.sin(f*r)*o,l+Math.cos(f*r)*s,p,w,b,e),y.push(h++,h++);y.push(h-1)}if(t.lineWidth){for(k=t.points,t.points=[],r=0;r<41;r++)t.points.push(c+Math.sin(f*r)*o,l+Math.cos(f*r)*s);PIXI.WebGLGraphics.buildLine(t,i);t.points=k}},PIXI.WebGLGraphics.buildLine=function(t,i){var h=0,r=t.points,it,tt,ht,ct;if(0!==r.length){if(t.lineWidth%2)for(h=0;h<r.length;h++)r[h]+=.5;it=new PIXI.Point(r[0],r[1]);tt=new PIXI.Point(r[r.length-2],r[r.length-1]);it.x===tt.x&&it.y===tt.y&&((r=r.slice()).pop(),r.pop(),ht=(tt=new PIXI.Point(r[r.length-2],r[r.length-1])).x+.5*(it.x-tt.x),ct=tt.y+.5*(it.y-tt.y),r.unshift(ht,ct),r.push(ht,ct));var ft,et,y,p,e,o,ot,st,u,f,k,d,g,nt,wt,bt,lt,kt,dt,at,rt,w,s=i.points,vt=i.indices,ut=r.length/2,gt=r.length,yt=s.length/6,b=t.lineWidth/2,pt=n.Color.hexToRGBArray(t.lineColor),c=t.lineAlpha,l=pt[0]*c,a=pt[1]*c,v=pt[2]*c;for(y=r[0],p=r[1],e=r[2],u=-(p-(o=r[3])),f=y-e,u/=w=Math.sqrt(u*u+f*f),f/=w,u*=b,f*=b,s.push(y-u,p-f,l,a,v,c),s.push(y+u,p+f,l,a,v,c),h=1;h<ut-1;h++)y=r[2*(h-1)],p=r[2*(h-1)+1],e=r[2*h],o=r[2*h+1],ot=r[2*(h+1)],st=r[2*(h+1)+1],u=-(p-o),f=y-e,u/=w=Math.sqrt(u*u+f*f),f/=w,u*=b,f*=b,k=-(o-st),d=e-ot,k/=w=Math.sqrt(k*k+d*d),d/=w,lt=(-u+y)*(-f+o)-(-u+e)*(-f+p),at=(-(k*=b)+ot)*(-(d*=b)+o)-(-k+e)*(-d+st),rt=(wt=-f+p-(-f+o))*(dt=-k+e-(-k+ot))-(kt=-d+st-(-d+o))*(bt=-u+e-(-u+y)),Math.abs(rt)<.1?(rt+=10.1,s.push(e-u,o-f,l,a,v,c),s.push(e+u,o+f,l,a,v,c)):((ft=(bt*at-dt*lt)/rt)-e)*(ft-e)+((et=(kt*lt-wt*at)/rt)-o)+(et-o)>19600?(g=u-k,nt=f-d,g/=w=Math.sqrt(g*g+nt*nt),nt/=w,g*=b,nt*=b,s.push(e-g,o-nt),s.push(l,a,v,c),s.push(e+g,o+nt),s.push(l,a,v,c),s.push(e-g,o-nt),s.push(l,a,v,c),gt++):(s.push(ft,et),s.push(l,a,v,c),s.push(e-(ft-e),o-(et-o)),s.push(l,a,v,c));for(y=r[2*(ut-2)],p=r[2*(ut-2)+1],e=r[2*(ut-1)],u=-(p-(o=r[2*(ut-1)+1])),f=y-e,u/=w=Math.sqrt(u*u+f*f),f/=w,u*=b,f*=b,s.push(e-u,o-f),s.push(l,a,v,c),s.push(e+u,o+f),s.push(l,a,v,c),vt.push(yt),h=0;h<gt;h++)vt.push(yt++);vt.push(yt-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(t,i){var u=t.points.slice(),l,a;if(!(u.length<6)){l=i.indices;i.points=u;i.alpha=t.fillAlpha;i.color=n.Color.hexToRGBArray(t.fillColor);for(var f,e,o=1/0,s=-1/0,h=1/0,c=-1/0,r=0;r<u.length;r+=2)f=u[r],e=u[r+1],o=f<o?f:o,s=f>s?f:s,h=e<h?e:h,c=e>c?e:c;for(u.push(o,h,s,h,s,c,o,c),a=u.length/2,r=0;r<a;r++)l.push(r)}},PIXI.WebGLGraphics.buildPoly=function(t,i){var e=t.points,f,r;if(!(e.length<6)){var c=i.points,o=i.indices,l=e.length/2,h=n.Color.hexToRGBArray(t.fillColor),s=t.fillAlpha,a=h[0]*s,v=h[1]*s,y=h[2]*s,u=n.EarCut.Triangulate(e,null,2);if(!u)return!1;for(f=c.length/6,r=0,r=0;r<u.length;r+=3)o.push(u[r]+f),o.push(u[r]+f),o.push(u[r+1]+f),o.push(u[r+2]+f),o.push(u[r+2]+f);for(r=0;r<l;r++)c.push(e[2*r],e[2*r+1],a,v,y,s);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(n){this.gl=n;this.color=[0,0,0];this.points=[];this.indices=[];this.buffer=n.createBuffer();this.indexBuffer=n.createBuffer();this.mode=1;this.alpha=1;this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[];this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var n=this.gl;this.glPoints=new Float32Array(this.points);n.bindBuffer(n.ARRAY_BUFFER,this.buffer);n.bufferData(n.ARRAY_BUFFER,this.glPoints,n.STATIC_DRAW);this.glIndicies=new Uint16Array(this.indices);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,this.glIndicies,n.STATIC_DRAW);this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(t,i){var h=t.worldAlpha,d,f,b;for(t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1),d=0;d<t.graphicsData.length;d++){var r=t.graphicsData[d],u=r.shape,p=r._fillTint,w=r._lineTint;if(i.lineWidth=r.lineWidth,r.type===n.POLYGON){for(i.beginPath(),f=u.points,i.moveTo(f[0],f[1]),b=1;b<f.length/2;b++)i.lineTo(f[2*b],f[2*b+1]);u.closed&&i.lineTo(f[0],f[1]);f[0]===f[f.length-2]&&f[1]===f[f.length-1]&&i.closePath();r.fill&&(i.globalAlpha=r.fillAlpha*h,i.fillStyle="#"+("00000"+(0|p).toString(16)).substr(-6),i.fill());r.lineWidth&&(i.globalAlpha=r.lineAlpha*h,i.strokeStyle="#"+("00000"+(0|w).toString(16)).substr(-6),i.stroke())}else if(r.type===n.RECTANGLE)(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*h,i.fillStyle="#"+("00000"+(0|p).toString(16)).substr(-6),i.fillRect(u.x,u.y,u.width,u.height)),r.lineWidth&&(i.globalAlpha=r.lineAlpha*h,i.strokeStyle="#"+("00000"+(0|w).toString(16)).substr(-6),i.strokeRect(u.x,u.y,u.width,u.height));else if(r.type===n.CIRCLE)i.beginPath(),i.arc(u.x,u.y,u.radius,0,2*Math.PI),i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*h,i.fillStyle="#"+("00000"+(0|p).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*h,i.strokeStyle="#"+("00000"+(0|w).toString(16)).substr(-6),i.stroke());else if(r.type===n.ELLIPSE){var g=2*u.width,nt=2*u.height,v=u.x-g/2,k=u.y-nt/2;i.beginPath();var tt=g/2*.5522848,it=nt/2*.5522848,rt=v+g,ut=k+nt,y=v+g/2,c=k+nt/2;i.moveTo(v,c);i.bezierCurveTo(v,c-it,y-tt,k,y,k);i.bezierCurveTo(y+tt,k,rt,c-it,rt,c);i.bezierCurveTo(rt,c+it,y+tt,ut,y,ut);i.bezierCurveTo(y-tt,ut,v,c+it,v,c);i.closePath();r.fill&&(i.globalAlpha=r.fillAlpha*h,i.fillStyle="#"+("00000"+(0|p).toString(16)).substr(-6),i.fill());r.lineWidth&&(i.globalAlpha=r.lineAlpha*h,i.strokeStyle="#"+("00000"+(0|w).toString(16)).substr(-6),i.stroke())}else if(r.type===n.ROUNDEDRECTANGLE){var e=u.x,o=u.y,l=u.width,a=u.height,s=u.radius,ft=Math.min(l,a)/2|0;s=s>ft?ft:s;i.beginPath();i.moveTo(e,o+s);i.lineTo(e,o+a-s);i.quadraticCurveTo(e,o+a,e+s,o+a);i.lineTo(e+l-s,o+a);i.quadraticCurveTo(e+l,o+a,e+l,o+a-s);i.lineTo(e+l,o+s);i.quadraticCurveTo(e+l,o,e+l-s,o);i.lineTo(e+s,o);i.quadraticCurveTo(e,o,e,o+s);i.closePath();(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*h,i.fillStyle="#"+("00000"+(0|p).toString(16)).substr(-6),i.fill());r.lineWidth&&(i.globalAlpha=r.lineAlpha*h,i.strokeStyle="#"+("00000"+(0|w).toString(16)).substr(-6),i.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,i){var it=t.graphicsData.length,w,s,r,e,y;if(0!==it)for(i.beginPath(),w=0;w<it;w++)if(s=t.graphicsData[w],r=s.shape,s.type===n.POLYGON){for(e=r.points,i.moveTo(e[0],e[1]),y=1;y<e.length/2;y++)i.lineTo(e[2*y],e[2*y+1]);e[0]===e[e.length-2]&&e[1]===e[e.length-1]&&i.closePath()}else if(s.type===n.RECTANGLE)i.rect(r.x,r.y,r.width,r.height),i.closePath();else if(s.type===n.CIRCLE)i.arc(r.x,r.y,r.radius,0,2*Math.PI),i.closePath();else if(s.type===n.ELLIPSE){var b=2*r.width,k=2*r.height,a=r.x-b/2,p=r.y-k/2,d=b/2*.5522848,g=k/2*.5522848,nt=a+b,tt=p+k,v=a+b/2,h=p+k/2;i.moveTo(a,h);i.bezierCurveTo(a,h-g,v-d,p,v,p);i.bezierCurveTo(v+d,p,nt,h-g,nt,h);i.bezierCurveTo(nt,h+g,v+d,tt,v,tt);i.bezierCurveTo(v-d,tt,a,h+g,a,h);i.closePath()}else if(s.type===n.ROUNDEDRECTANGLE){var u=r.x,f=r.y,c=r.width,l=r.height,o=r.radius,rt=Math.min(c,l)/2|0;o=o>rt?rt:o;i.moveTo(u,f+o);i.lineTo(u,f+l-o);i.quadraticCurveTo(u,f+l,u+o,f+l);i.lineTo(u+c-o,f+l);i.quadraticCurveTo(u+c,f+l,u+c,f+l-o);i.lineTo(u+c,f+o);i.quadraticCurveTo(u+c,f,u+c-o,f);i.lineTo(u+o,f);i.quadraticCurveTo(u,f,u,f+o);i.closePath()}},PIXI.CanvasGraphics.updateGraphicsTint=function(n){if(16777215!==n.tint)for(var f=(n.tint>>16&255)/255,e=(n.tint>>8&255)/255,o=(255&n.tint)/255,i=0;i<n.graphicsData.length;i++){var t=n.graphicsData[i],r=0|t.fillColor,u=0|t.lineColor;t._fillTint=((r>>16&255)/255*f*255<<16)+((r>>8&255)/255*e*255<<8)+(255&r)/255*o*255;t._lineTint=((u>>16&255)/255*f*255<<16)+((u>>8&255)/255*e*255<<8)+(255&u)/255*o*255}},n.GraphicsData=function(n,t,i,r,u,f,e){this.lineWidth=n;this.lineColor=t;this.lineAlpha=i;this._lineTint=t;this.fillColor=r;this.fillAlpha=u;this._fillTint=r;this.fill=f;this.shape=e;this.type=e.type},n.GraphicsData.prototype.constructor=n.GraphicsData,n.GraphicsData.prototype.clone=function(){return new n.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},n.Graphics=function(t,i,r){void 0===i&&(i=0);void 0===r&&(r=0);this.type=n.GRAPHICS;this.physicsType=n.SPRITE;this.anchor=new n.Point;PIXI.DisplayObjectContainer.call(this);this.renderable=!0;this.fillAlpha=1;this.lineWidth=0;this.lineColor=0;this.graphicsData=[];this.tint=16777215;this.blendMode=PIXI.blendModes.NORMAL;this.currentPath=null;this._webGL=[];this.isMask=!1;this.boundsPadding=0;this._localBounds=new n.Rectangle(0,0,1,1);this.dirty=!0;this._boundsDirty=!1;this.webGLDirty=!1;this.cachedSpriteDirty=!1;n.Component.Core.init.call(this,t,i,r,"",null)},n.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),n.Graphics.prototype.constructor=n.Graphics,n.Component.Core.install.call(n.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),n.Graphics.prototype.preUpdatePhysics=n.Component.PhysicsBody.preUpdate,n.Graphics.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.Graphics.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.Graphics.prototype.preUpdateCore=n.Component.Core.preUpdate,n.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.Graphics.prototype.postUpdate=function(){n.Component.PhysicsBody.postUpdate.call(this);n.Component.FixedToCamera.postUpdate.call(this);this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()},n.Graphics.prototype.destroy=function(t){this.clear();n.Component.Destroy.prototype.destroy.call(this,t)},n.Graphics.prototype.drawTriangle=function(t,i){var r;if(void 0===i&&(i=!1),r=new n.Polygon(t),i){var u=new n.Point(this.game.camera.x-t[0].x,this.game.camera.y-t[0].y),f=new n.Point(t[1].x-t[0].x,t[1].y-t[0].y),e=new n.Point(t[1].x-t[2].x,t[1].y-t[2].y).cross(f);u.dot(e)>0&&this.drawPolygon(r)}else this.drawPolygon(r)},n.Graphics.prototype.drawTriangles=function(t,i,r){void 0===r&&(r=!1);var u,e=new n.Point,o=new n.Point,s=new n.Point,f=[];if(i)if(t[0]instanceof n.Point)for(u=0;u<i.length/3;u++)f.push(t[i[3*u]]),f.push(t[i[3*u+1]]),f.push(t[i[3*u+2]]),3===f.length&&(this.drawTriangle(f,r),f=[]);else for(u=0;u<i.length;u++)e.x=t[2*i[u]],e.y=t[2*i[u]+1],f.push(e.copyTo({})),3===f.length&&(this.drawTriangle(f,r),f=[]);else if(t[0]instanceof n.Point)for(u=0;u<t.length/3;u++)this.drawTriangle([t[3*u],t[3*u+1],t[3*u+2]],r);else for(u=0;u<t.length/6;u++)e.x=t[6*u+0],e.y=t[6*u+1],o.x=t[6*u+2],o.y=t[6*u+3],s.x=t[6*u+4],s.y=t[6*u+5],this.drawTriangle([e,o,s],r)},n.Graphics.prototype.lineStyle=function(t,i,r){return this.lineWidth=t||0,this.lineColor=i||0,this.lineAlpha=void 0===r?1:r,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new n.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},n.Graphics.prototype.moveTo=function(t,i){return this.drawShape(new n.Polygon([t,i])),this},n.Graphics.prototype.lineTo=function(n,t){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(n,t),this.dirty=!0,this._boundsDirty=!0,this},n.Graphics.prototype.quadraticCurveTo=function(n,t,i,r){var e,o,u;this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);u=this.currentPath.shape.points;0===u.length&&this.moveTo(0,0);for(var h=u[u.length-2],c=u[u.length-1],f=0,s=1;s<=20;++s)e=h+(n-h)*(f=s/20),o=c+(t-c)*f,u.push(e+(n+(i-n)*f-e)*f,o+(t+(r-t)*f-o)*f);return this.dirty=!0,this._boundsDirty=!0,this},n.Graphics.prototype.bezierCurveTo=function(n,t,i,r,u,f){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var o,h,c,l,a,s=this.currentPath.shape.points,y=s[s.length-2],p=s[s.length-1],e=0,v=1;v<=20;++v)c=(h=(o=1-(e=v/20))*o)*o,a=(l=e*e)*e,s.push(c*y+3*h*e*n+3*o*l*i+a*u,c*p+3*h*e*t+3*o*l*r+a*f);return this.dirty=!0,this._boundsDirty=!0,this},n.Graphics.prototype.arcTo=function(n,t,i,r,u){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(n,t):this.moveTo(n,t);var f=this.currentPath.shape.points,g=f[f.length-2],e=f[f.length-1]-t,o=g-n,s=r-t,h=i-n,a=Math.abs(e*h-o*s);if(a<1e-8||0===u)f[f.length-2]===n&&f[f.length-1]===t||f.push(n,t);else{var p=e*e+o*o,w=s*s+h*h,b=e*s+o*h,c=u*Math.sqrt(p)/a,l=u*Math.sqrt(w)/a,k=c*b/p,d=l*b/w,v=c*h+l*o,y=c*s+l*e,nt=o*(l+k),tt=e*(l+k),it=h*(c+d),rt=s*(c+d),ut=Math.atan2(tt-y,nt-v),ft=Math.atan2(rt-y,it-v);this.arc(v+n,y+t,u,ut,ft,o*s>h*e)}return this.dirty=!0,this._boundsDirty=!0,this},n.Graphics.prototype.arc=function(n,t,i,r,u,f,e){var o,c,a,v;if(r===u||(void 0===f&&(f=!1),void 0===e&&(e=40),!f&&u<=r?u+=2*Math.PI:f&&r<=u&&(r+=2*Math.PI),o=f?-1*(r-u):u-r,c=Math.ceil(Math.abs(o)/(2*Math.PI))*e,0===o))return this;a=n+Math.cos(r)*i;v=t+Math.sin(r)*i;f&&this.filling?this.moveTo(n,t):this.moveTo(a,v);for(var d=this.currentPath.shape.points,s=o/(2*c),g=2*s,y=Math.cos(s),p=Math.sin(s),l=c-1,nt=l%1/l,h=0;h<=l;h++){var w=s+r+g*(h+nt*h),b=Math.cos(w),k=-Math.sin(w);d.push((y*b+p*k)*i+n,(y*-k+p*b)*i+t)}return this.dirty=!0,this._boundsDirty=!0,this},n.Graphics.prototype.beginFill=function(n,t){return this.filling=!0,this.fillColor=n||0,this.fillAlpha=void 0===t?1:t,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},n.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},n.Graphics.prototype.drawRect=function(t,i,r,u){return this.drawShape(new n.Rectangle(t,i,r,u)),this},n.Graphics.prototype.drawRoundedRect=function(t,i,r,u,f){return this.drawShape(new n.RoundedRectangle(t,i,r,u,f)),this},n.Graphics.prototype.drawCircle=function(t,i,r){return this.drawShape(new n.Circle(t,i,r)),this},n.Graphics.prototype.drawEllipse=function(t,i,r,u){return this.drawShape({x:t,y:i,width:r,height:u,type:n.ELLIPSE}),this},n.Graphics.prototype.drawPolygon=function(t){var i,r;if(t instanceof n.Polygon&&(t=t.points),i=t,!Array.isArray(i))for(i=new Array(arguments.length),r=0;r<i.length;++r)i[r]=arguments[r];return this.drawShape(new n.Polygon(i)),this},n.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this},n.Graphics.prototype.generateTexture=function(n,t,i){var r,u,f;return void 0===n&&(n=1),void 0===t&&(t=PIXI.scaleModes.DEFAULT),void 0===i&&(i=0),r=this.getBounds(),r.width+=i,r.height+=i,u=new PIXI.CanvasBuffer(r.width*n,r.height*n),f=PIXI.Texture.fromCanvas(u.canvas,t),f.baseTexture.resolution=n,u.context.scale(n,n),u.context.translate(-r.x,-r.y),PIXI.CanvasGraphics.renderGraphics(this,u.context),f},n.Graphics.prototype._renderWebGL=function(n){var i,t;if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,n);if((n.spriteBatch.stop(),n.blendModeManager.setBlendMode(this.blendMode),this._mask&&n.maskManager.pushMask(this._mask,n),this._filters&&n.filterManager.pushFilter(this._filterBlock),this.blendMode!==n.spriteBatch.currentBlendMode)&&(n.spriteBatch.currentBlendMode=this.blendMode,i=PIXI.blendModesWebGL[n.spriteBatch.currentBlendMode],n.spriteBatch.gl.blendFunc(i[0],i[1])),this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,n),this.children.length){for(n.spriteBatch.start(),t=0;t<this.children.length;t++)this.children[t]._renderWebGL(n);n.spriteBatch.stop()}this._filters&&n.filterManager.popFilter();this._mask&&n.maskManager.popMask(this.mask,n);n.drawCount++;n.spriteBatch.start()}},n.Graphics.prototype._renderCanvas=function(n){var i,t,u;if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,n);i=n.context;t=this.worldTransform;this.blendMode!==n.currentBlendMode&&(n.currentBlendMode=this.blendMode,i.globalCompositeOperation=PIXI.blendModesCanvas[n.currentBlendMode]);this._mask&&n.maskManager.pushMask(this._mask,n);var r=n.resolution,f=t.tx*n.resolution+n.shakeX,e=t.ty*n.resolution+n.shakeY;for(i.setTransform(t.a*r,t.b*r,t.c*r,t.d*r,f,e),PIXI.CanvasGraphics.renderGraphics(this,i),u=0;u<this.children.length;u++)this.children[u]._renderCanvas(n);this._mask&&n.maskManager.popMask(n)}},n.Graphics.prototype.getBounds=function(t){if(this._currentBounds)return this._currentBounds;if(this.isMask)return n.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var e=this._localBounds,s=e.x,h=e.width+e.x,c=e.y,l=e.height+e.y,o=t||this.worldTransform,a=o.a,v=o.b,y=o.c,p=o.d,w=o.tx,b=o.ty,rt=a*h+y*l+w,ut=p*l+v*h+b,k=a*s+y*l+w,d=p*l+v*s+b,g=a*s+y*c+w,nt=p*c+v*s+b,tt=a*h+y*c+w,it=p*c+v*h+b,u=rt,f=ut,i=rt,r=ut;return i=k<i?k:i,i=g<i?g:i,i=tt<i?tt:i,r=d<r?d:r,r=nt<r?nt:r,r=it<r?it:r,u=k>u?k:u,u=g>u?g:u,u=tt>u?tt:u,f=d>f?d:f,f=nt>f?nt:f,f=it>f?it:f,this._bounds.x=i,this._bounds.width=u-i,this._bounds.y=r,this._bounds.height=f-r,this._currentBounds=this._bounds,this._currentBounds},n.Graphics.prototype.getLocalBounds=function(){var r=this.worldTransform,t,i;for(this.worldTransform=n.identityMatrix,t=0;t<this.children.length;t++)this.children[t].updateTransform();for(i=this.getBounds(),this.worldTransform=r,t=0;t<this.children.length;t++)this.children[t].updateTransform();return i},n.Graphics.prototype.containsPoint=function(t,i){var f,r,u;for(void 0===i&&(i=new n.Point),this.worldTransform.applyInverse(t,i),f=this.graphicsData,r=0;r<f.length;r++)if(u=f[r],u.fill&&u.shape&&u.shape.contains(i.x,i.y))return!0;return!1},n.Graphics.prototype.getVisualBounds=function(n){return this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1),this._localBounds.clone(n)},n.Graphics.prototype.updateLocalBounds=function(){var u=1/0,e=-1/0,f=1/0,o=-1/0,s,a,t,i,h,c,y,l,v;if(this.graphicsData.length)for(y=0;y<this.graphicsData.length;y++){var w=this.graphicsData[y],p=w.type,r=w.lineWidth;if(s=w.shape,p===n.RECTANGLE||p===n.ROUNDEDRECTANGLE)t=s.x-r/2,i=s.y-r/2,h=s.width+r,c=s.height+r,u=t<u?t:u,e=t+h>e?t+h:e,f=i<f?i:f,o=i+c>o?i+c:o;else if(p===n.CIRCLE)t=s.x,i=s.y,h=s.radius+r/2,c=s.radius+r/2,u=t-h<u?t-h:u,e=t+h>e?t+h:e,f=i-c<f?i-c:f,o=i+c>o?i+c:o;else if(p===n.ELLIPSE)t=s.x,i=s.y,h=s.width+r/2,c=s.height+r/2,u=t-h<u?t-h:u,e=t+h>e?t+h:e,f=i-c<f?i-c:f,o=i+c>o?i+c:o;else for(a=s.points,l=0;l<a.length;l++)a[l]instanceof n.Point?(t=a[l].x,i=a[l].y):(t=a[l],i=a[l+1],l<a.length-1&&l++),u=t-r<u?t-r:u,e=t+r>e?t+r:e,f=i-r<f?i-r:f,o=i+r>o?i+r:o}else u=0,e=0,f=0,o=0;v=this.boundsPadding;this._localBounds.x=u-v;this._localBounds.width=e-u+2*v;this._localBounds.y=f-v;this._localBounds.height=o-f+2*v},n.Graphics.prototype._generateCachedSprite=function(){var n=this.getLocalBounds(),t,i;this._cachedSprite?this._cachedSprite.buffer.resize(n.width,n.height):(t=new PIXI.CanvasBuffer(n.width,n.height),i=PIXI.Texture.fromCanvas(t.canvas),this._cachedSprite=new PIXI.Sprite(i),this._cachedSprite.buffer=t,this._cachedSprite.worldTransform=this.worldTransform);this._cachedSprite.anchor.x=-n.x/n.width;this._cachedSprite.anchor.y=-n.y/n.height;this._cachedSprite.buffer.context.translate(-n.x,-n.y);this.worldAlpha=1;PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context);this._cachedSprite.alpha=this.alpha},n.Graphics.prototype.updateCachedSpriteTexture=function(){var i=this._cachedSprite,n=i.texture,t=i.buffer.canvas;n.baseTexture.width=t.width;n.baseTexture.height=t.height;n.crop.width=n.frame.width=t.width;n.crop.height=n.frame.height=t.height;i._width=t.width;i._height=t.height;n.baseTexture.dirty()},n.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0);this._cachedSprite=null},n.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop();this.currentPath=null;t instanceof n.Polygon&&(t=t.clone()).flatten();var i=new n.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(i),i.type===n.POLYGON&&(i.shape.closed=this.filling,this.currentPath=i),this.dirty=!0,this._boundsDirty=!0,i},Object.defineProperty(n.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(n){this._cacheAsBitmap=n;this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite();this.dirty=!0;this.webGLDirty=!0}}),n.RenderTexture=function(t,i,r,u,f,e,o,s){if(void 0===i&&(i=100),void 0===r&&(r=100),void 0===u&&(u=""),void 0===f&&(f=n.scaleModes.DEFAULT),void 0===e&&(e=1),void 0===o&&(o=PIXI.defaultRenderer),void 0===s&&(s=0),this.game=t,this.key=u,this.type=n.RENDERTEXTURE,this._tempMatrix=new n.Matrix,this.width=i,this.height=r,this.resolution=e,this.frame=new n.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=this.frame.clone(),this.baseTexture=new PIXI.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=f,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=o,this.renderer.type===n.WEBGL){var h=this.renderer.gl;this.baseTexture.textureIndex=s;this.baseTexture._dirty[h.id]=!1;this.textureBuffer=new PIXI.FilterTexture(h,this.width,this.height,this.baseTexture.scaleMode,s);this.baseTexture._glTextures[h.id]=this.textureBuffer.texture;this.projection=new n.Point(.5*this.width,.5*-this.height)}else this.textureBuffer=new PIXI.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0;this.tempMatrix=new n.Matrix;this._updateUvs()},n.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),n.RenderTexture.prototype.constructor=n.RenderTexture,n.RenderTexture.prototype.renderXY=function(t,i,r,u){t.updateTransform();this._tempMatrix.copyFrom(t.worldTransform);this._tempMatrix.tx=i;this._tempMatrix.ty=r;this.renderer.type===n.WEBGL?this._renderWebGL(t,this._tempMatrix,u):this._renderCanvas(t,this._tempMatrix,u)},n.RenderTexture.prototype.renderRawXY=function(t,i,r,u){this._tempMatrix.identity().translate(i,r);this.renderer.type===n.WEBGL?this._renderWebGL(t,this._tempMatrix,u):this._renderCanvas(t,this._tempMatrix,u)},n.RenderTexture.prototype.render=function(t,i,r){void 0===i||null===i?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(i);this.renderer.type===n.WEBGL?this._renderWebGL(t,this._tempMatrix,r):this._renderCanvas(t,this._tempMatrix,r)},n.RenderTexture.prototype.resize=function(t,i,r){t===this.width&&i===this.height||(this.valid=t>0&&i>0,this.width=t,this.height=i,this.frame.width=this.crop.width=t*this.resolution,this.frame.height=this.crop.height=i*this.resolution,r&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===n.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},n.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===n.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},n.RenderTexture.prototype._renderWebGL=function(n,t,i){var u,f,r;if(this.valid&&0!==n.alpha){for(u=n.worldTransform,u.identity(),u.translate(0,2*this.projection.y),t&&u.append(t),u.scale(1,-1),f=0;f<n.children.length;f++)n.children[f].updateTransform();r=this.renderer.gl;r.viewport(0,0,this.width*this.resolution,this.height*this.resolution);r.bindFramebuffer(r.FRAMEBUFFER,this.textureBuffer.frameBuffer);i&&this.textureBuffer.clear();this.renderer.spriteBatch.dirty=!0;this.renderer.renderDisplayObject(n,this.projection,this.textureBuffer.frameBuffer,t);this.renderer.spriteBatch.dirty=!0;r.bindFramebuffer(r.FRAMEBUFFER,null)}},n.RenderTexture.prototype._renderCanvas=function(n,t,i){var u,r,f;if(this.valid&&0!==n.alpha){for(u=n.worldTransform,u.identity(),t&&u.append(t),r=0;r<n.children.length;r++)n.children[r].updateTransform();i&&this.textureBuffer.clear();f=this.renderer.resolution;this.renderer.resolution=this.resolution;this.renderer.renderDisplayObject(n,this.textureBuffer.context,t);this.renderer.resolution=f}},n.RenderTexture.prototype.getImage=function(){var n=new Image;return n.src=this.getBase64(),n},n.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},n.RenderTexture.prototype.getCanvas=function(){var u,f;if(this.renderer.type===n.WEBGL){var t=this.renderer.gl,i=this.textureBuffer.width,r=this.textureBuffer.height,e=new Uint8Array(4*i*r);return t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,i,r,t.RGBA,t.UNSIGNED_BYTE,e),t.bindFramebuffer(t.FRAMEBUFFER,null),u=new PIXI.CanvasBuffer(i,r),f=u.context.getImageData(0,0,i,r),f.data.set(e),u.context.putImageData(f,0,0),u.canvas}return this.textureBuffer.canvas},n.Text=function(t,i,r,u,f){i=i||0;r=r||0;u=void 0===u||null===u?"":u.toString();this.canvas=n.CanvasPool.create(this);n.Sprite.call(this,t,i,r,PIXI.Texture.fromCanvas(this.canvas));this.type=n.TEXT;this.physicsType=n.SPRITE;this.padding=new n.Point;this.textBounds=null;this.context=this.canvas.getContext("2d");this.colors=[];this.strokeColors=[];this.fontStyles=[];this.fontWeights=[];this.autoRound=!1;this.useAdvancedWrap=!1;this.splitRegExp=/(?:\r\n|\r|\n)/;this.characterLimitSize=-1;this.characterLimitSuffix="";this._testString="|MÉq";this._res=t.renderer.resolution;this._text=u;this._fontComponents=null;this._lineSpacing=0;this._charCount=0;this._width=0;this._height=0;this.style={};this.setStyle(f||{});""!==u&&this.updateText()},n.Text.prototype=Object.create(n.Sprite.prototype),n.Text.prototype.constructor=n.Text,n.Text.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.Text.prototype.update=function(){},n.Text.prototype.destroy=function(t){this.texture.destroy(!0);n.Component.Destroy.prototype.destroy.call(this,t)},n.Text.prototype.setShadow=function(n,t,i,r,u,f){return void 0===n&&(n=0),void 0===t&&(t=0),void 0===i&&(i="rgba(0, 0, 0, 1)"),void 0===r&&(r=0),void 0===u&&(u=!0),void 0===f&&(f=!0),this.style.shadowOffsetX=n,this.style.shadowOffsetY=t,this.style.shadowColor=i,this.style.shadowBlur=r,this.style.shadowStroke=u,this.style.shadowFill=f,this.dirty=!0,this},n.Text.prototype.setStyle=function(n,t){var i,r;return void 0===t&&(t=!1),i=Object.assign({},n),i.font=n.font||"bold 20pt Arial",i.backgroundColor=n.backgroundColor||null,i.fill=n.fill||"black",i.align=(n.align||"left").toLowerCase(),i.boundsAlignH=(n.boundsAlignH||"left").toLowerCase(),i.boundsAlignV=(n.boundsAlignV||"top").toLowerCase(),i.stroke=n.stroke||"black",i.strokeThickness=Number(n.strokeThickness)||0,i.wordWrap=n.wordWrap||!1,i.wordWrapWidth=n.wordWrapWidth||100,i.maxLines=n.maxLines||0,i.shadowOffsetX=n.shadowOffsetX||0,i.shadowOffsetY=n.shadowOffsetY||0,i.shadowColor=n.shadowColor||"rgba(0,0,0,0)",i.shadowBlur=n.shadowBlur||0,i.tabs=n.tabs||0,r=this.fontToComponents(i.font),i.fontStyle&&(r.fontStyle=i.fontStyle),i.fontVariant&&(r.fontVariant=i.fontVariant),i.fontWeight&&(r.fontWeight=i.fontWeight),i.fontSize&&("number"==typeof i.fontSize&&(i.fontSize=i.fontSize+"px"),r.fontSize=i.fontSize),this._fontComponents=r,i.font=this.componentsToFont(this._fontComponents),this.style=i,this.dirty=!0,t&&this.updateText(),this},n.Text.prototype.updateText=function(){var h,n,o,r,y,i,p,u,f;this.texture.baseTexture.resolution=this._res;this.context.font=this.style.font;h=this.text;this.characterLimitSize>-1&&this.characterLimitSize<h.length&&(h=this.text.substring(0,this.characterLimitSize)+this.characterLimitSuffix);this.style.wordWrap&&(h=this.runWordWrap(this.text));var t=h.split(this.splitRegExp),s=this.style.tabs,l=[],c=0,w=this.determineFontProperties(this.style.font),a=t.length;for(this.style.maxLines>0&&this.style.maxLines<t.length&&(a=this.style.maxLines),this._charCount=0,n=0;n<a;n++){if(0===s)r=this.style.strokeThickness+this.padding.x,r+=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(t[n]):this.context.measureText(t[n]).width,this.style.wordWrap&&(r-=this.context.measureText(" ").width);else if(o=t[n].split(/(?:\t)/),r=this.padding.x+this.style.strokeThickness,Array.isArray(s))for(y=0,i=0;i<o.length;i++)p=0,p=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(o[i]):Math.ceil(this.context.measureText(o[i]).width),i>0&&(y+=s[i-1]),r=y+p;else for(i=0;i<o.length;i++)r+=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(o[i]):Math.ceil(this.context.measureText(o[i]).width),r+=this.game.math.snapToCeil(r,s)-r;l[n]=Math.ceil(r);c=Math.max(c,l[n])}this.canvas.width=c*this._res;var v=w.fontSize+this.style.strokeThickness+this.padding.y,b=v*a,e=this._lineSpacing;for(e<0&&Math.abs(e)>v&&(e=-v),0!==e&&(b+=e>0?e*t.length:e*(t.length-1)),this.canvas.height=b*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round",this._charCount=0,n=0;n<a;n++)u=this.style.strokeThickness/2,f=this.style.strokeThickness/2+n*v+w.ascent,n>0&&(f+=e*n),"right"===this.style.align?u+=c-l[n]:"center"===this.style.align&&(u+=(c-l[n])/2),this.autoRound&&(u=Math.round(u),f=Math.round(f)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(t[n],u,f):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===s?this.context.strokeText(t[n],u,f):this.renderTabLine(t[n],u,f,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===s?this.context.fillText(t[n],u,f):this.renderTabLine(t[n],u,f,!0)));this.updateTexture();this.dirty=!1},n.Text.prototype.renderTabLine=function(n,t,i,r){var f=n.split(/(?:\t)/),o=this.style.tabs,e=0,s,u,h;if(Array.isArray(o))for(s=0,u=0;u<f.length;u++)u>0&&(s+=o[u-1]),e=t+s,r?this.context.fillText(f[u],e,i):this.context.strokeText(f[u],e,i);else for(u=0;u<f.length;u++)h=Math.ceil(this.context.measureText(f[u]).width),e=this.game.math.snapToCeil(t,o),r?this.context.fillText(f[u],e,i):this.context.strokeText(f[u],e,i),t=e+h},n.Text.prototype.updateShadow=function(n){n?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},n.Text.prototype.measureLine=function(n){for(var u,i,r=0,t=0;t<n.length;t++)u=n[t],(this.fontWeights.length>0||this.fontStyles.length>0)&&(i=this.fontToComponents(this.context.font),this.fontStyles[this._charCount]&&(i.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(i.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(i)),this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),r+=this.context.measureText(u).width,this._charCount++;return Math.ceil(r)},n.Text.prototype.updateLine=function(n,t,i){for(var u,f,r=0;r<n.length;r++)u=n[r],(this.fontWeights.length>0||this.fontStyles.length>0)&&(f=this.fontToComponents(this.context.font),this.fontStyles[this._charCount]&&(f.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(f.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(f)),this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(u,t,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(u,t,i)),t+=this.context.measureText(u).width,this._charCount++},n.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},n.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},n.Text.prototype.addColor=function(n,t){return this.colors[t]=n,this.dirty=!0,this},n.Text.prototype.addStrokeColor=function(n,t){return this.strokeColors[t]=n,this.dirty=!0,this},n.Text.prototype.addFontStyle=function(n,t){return this.fontStyles[t]=n,this.dirty=!0,this},n.Text.prototype.addFontWeight=function(n,t){return this.fontWeights[t]=n,this.dirty=!0,this},n.Text.prototype.precalculateWordWrap=function(n){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(n).split(/(?:\r\n|\r|\n)/)},n.Text.prototype.runWordWrap=function(n){return this.useAdvancedWrap?this.advancedWordWrap(n):this.basicWordWrap(n)},n.Text.prototype.advancedWordWrap=function(n){for(var r,o,i,w,b,k,s=this.context,v=this.style.wordWrapWidth,h="",u=n.replace(/ +/gi," ").split(/\r?\n/gi),y=u.length,f=0;f<y;f++)if(r=u[f],o="",r=r.replace(/^ *|\s*$/gi,""),s.measureText(r).width<v)h+=r+"\n";else{for(var c=v,e=r.split(" "),t=0;t<e.length;t++){var p=e[t],l=p+" ",a=s.measureText(l).width;if(a>c){if(0===t){for(i=l;i.length&&(i=i.slice(0,-1),!((a=s.measureText(i).width)<=c)););if(!i.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");w=p.substr(i.length);e[t]=w;o+=i}b=e[t].length?t:t+1;k=e.slice(b).join(" ").replace(/[ \n]*$/gi,"");u[f+1]=k+" "+(u[f+1]||"");y=u.length;break}o+=l;c-=a}h+=o.replace(/[ \n]*$/gi,"")+"\n"}return h.replace(/[\s|\n]*$/gi,"")},n.Text.prototype.basicWordWrap=function(n){for(var o,s,i="",f=n.split("\n"),r=0;r<f.length;r++){for(var e=this.style.wordWrapWidth,u=f[r].split(" "),t=0;t<u.length;t++)o=this.context.measureText(u[t]).width,s=o+this.context.measureText(" ").width,s>e?(t>0&&(i+="\n"),i+=u[t]+" ",e=this.style.wordWrapWidth-o):(e-=s,i+=u[t]+" ");r<f.length-1&&(i+="\n")}return i},n.Text.prototype.updateFont=function(n){var t=this.componentsToFont(n);this.style.font!==t&&(this.style.font=t,this.dirty=!0,this.parent&&this.updateTransform())},n.Text.prototype.fontToComponents=function(n){var t=n.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/),i;return t?(i=t[5].trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:n,fontStyle:t[1]||"normal",fontVariant:t[2]||"normal",fontWeight:t[3]||"normal",fontSize:t[4]||"medium",fontFamily:i}):(console.warn("Phaser.Text - unparsable CSS font: "+n),{font:n})},n.Text.prototype.componentsToFont=function(n){var t,i=[];return(t=n.fontStyle)&&"normal"!==t&&i.push(t),(t=n.fontVariant)&&"normal"!==t&&i.push(t),(t=n.fontWeight)&&"normal"!==t&&i.push(t),(t=n.fontSize)&&"medium"!==t&&i.push(t),(t=n.fontFamily)&&i.push(t),i.length||i.push(n.font),i.join(" ")},n.Text.prototype.setText=function(n,t){return void 0===t&&(t=!1),(n=n.toString()||"")===this._text?this:(this.text=n,t?this.updateText():this.dirty=!0,this)},n.Text.prototype.parseList=function(n){if(!Array.isArray(n))return this;for(var i="",t=0;t<n.length;t++)Array.isArray(n[t])?(i+=n[t].join("\t"),t<n.length-1&&(i+="\n")):(i+=n[t],t<n.length-1&&(i+="\t"));return this.text=i,this.dirty=!0,this},n.Text.prototype.setTextBounds=function(t,i,r,u){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,i,r,u):this.textBounds=new n.Rectangle(t,i,r,u),this.style.wordWrapWidth>r&&(this.style.wordWrapWidth=r)),this.updateTexture(),this},n.Text.prototype.updateTexture=function(){var u=this.texture.baseTexture,f=this.texture.crop,e=this.texture.frame,n=this.canvas.width,t=this.canvas.height,i,r;(u.width=n,u.height=t,f.width=n,f.height=t,e.width=n,e.height=t,this.texture.width=n,this.texture.height=t,this._width=n,this._height=t,this.textBounds)&&(i=this.textBounds.x,r=this.textBounds.y,"right"===this.style.boundsAlignH?i+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(i+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?r+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(r+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-i,this.pivot.y=-r);this.renderable=0!==n&&0!==t;this.texture.requiresReTint=!0;this.texture.baseTexture.dirty()},n.Text.prototype._renderWebGL=function(n){this.dirty&&(this.updateText(),this.dirty=!1);PIXI.Sprite.prototype._renderWebGL.call(this,n)},n.Text.prototype._renderCanvas=function(n){this.dirty&&(this.updateText(),this.dirty=!1);PIXI.Sprite.prototype._renderCanvas.call(this,n)},n.Text.prototype.determineFontProperties=function(t){var i=n.Text.fontPropertiesCache[t],a=this.testString||"|MÉq",v,r;if(!i){i={};v=n.Text.fontPropertiesCanvas;r=n.Text.fontPropertiesContext;r.font=t;var o=Math.ceil(r.measureText(a).width),u=Math.ceil(r.measureText(a).width),s=2*u;if(u=1.4*u|0,v.width=o,v.height=s,r.fillStyle="#f00",r.fillRect(0,0,o,s),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(a,0,u),!r.getImageData(0,0,o,s))return i.ascent=u,i.descent=u+6,i.fontSize=i.ascent+i.descent,n.Text.fontPropertiesCache[t]=i,i;for(var e,y=r.getImageData(0,0,o,s).data,p=y.length,h=4*o,c=0,l=!1,f=0;f<u;f++){for(e=0;e<h;e+=4)if(255!==y[c+e]){l=!0;break}if(l)break;c+=h}for(i.ascent=u-f,c=p-h,l=!1,f=s;f>u;f--){for(e=0;e<h;e+=4)if(255!==y[c+e]){l=!0;break}if(l)break;c-=h}i.descent=f-u;i.descent+=6;i.fontSize=i.ascent+i.descent;n.Text.fontPropertiesCache[t]=i}return i},n.Text.prototype.getBounds=function(n){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,n)},n.Text.prototype.setCharacterLimit=function(n,t){this.characterLimitSuffix=void 0===t?"":t;this.characterLimitSize=n;this.updateText()},Object.defineProperty(n.Text.prototype,"text",{get:function(){return this._text},set:function(n){n!==this._text&&(this._text=n.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(n.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(n){n=n||"bold 20pt Arial";this._fontComponents=this.fontToComponents(n);this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(n){n=(n=n||"Arial").trim();/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(n)||/['",]/.exec(n)||(n="'"+n+"'");this._fontComponents.fontFamily=n;this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"fontSize",{get:function(){var n=this._fontComponents.fontSize;return n&&/(?:^0$|px$)/.exec(n)?parseInt(n,10):n},set:function(n){"number"==typeof(n=n||"0")&&(n+="px");this._fontComponents.fontSize=n;this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(n){n=n||"normal";this._fontComponents.fontWeight=n;this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(n){n=n||"normal";this._fontComponents.fontStyle=n;this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(n){n=n||"normal";this._fontComponents.fontVariant=n;this.updateFont(this._fontComponents)}}),Object.defineProperty(n.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(n){n!==this.style.fill&&(this.style.fill=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"align",{get:function(){return this.style.align},set:function(n){(n=n.toLowerCase())!==this.style.align&&(this.style.align=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"resolution",{get:function(){return this._res},set:function(n){n!==this._res&&(this._res=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(n){n!==this.style.tabs&&(this.style.tabs=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(n){(n=n.toLowerCase())!==this.style.boundsAlignH&&(this.style.boundsAlignH=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(n){(n=n.toLowerCase())!==this.style.boundsAlignV&&(this.style.boundsAlignV=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(n){n!==this.style.stroke&&(this.style.stroke=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(n){n!==this.style.strokeThickness&&(this.style.strokeThickness=Number(n),this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(n){n!==this.style.wordWrap&&(this.style.wordWrap=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(n){n!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(n){n!==this._lineSpacing&&(this._lineSpacing=parseFloat(n),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(n.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(n){n!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(n){n!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(n){n!==this.style.shadowColor&&(this.style.shadowColor=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(n){n!==this.style.shadowBlur&&(this.style.shadowBlur=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(n){n!==this.style.shadowStroke&&(this.style.shadowStroke=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(n){n!==this.style.shadowFill&&(this.style.shadowFill=n,this.dirty=!0)}}),Object.defineProperty(n.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(n){this.scale.x=n/this.texture.frame.width;this._width=n}}),Object.defineProperty(n.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(n){this.scale.y=n/this.texture.frame.height;this._height=n}}),Object.defineProperty(n.Text.prototype,"testString",{get:function(){return this._testString},set:function(n){this._testString=n;this.updateText()}}),n.Text.fontPropertiesCache={},n.Text.fontPropertiesCanvas=document.createElement("canvas"),n.Text.fontPropertiesContext=n.Text.fontPropertiesCanvas.getContext("2d"),n.BitmapText=function(t,i,r,u,f,e,o){i=i||0;r=r||0;u=u||"";f=f||"";e=e||32;o=o||"left";PIXI.DisplayObjectContainer.call(this);this.type=n.BITMAPTEXT;this.physicsType=n.SPRITE;this.textWidth=0;this.textHeight=0;this.anchor=new n.Point;this._prevAnchor=new n.Point;this._glyphs=[];this._maxWidth=0;this._text=f.toString()||"";this._data=t.cache.getBitmapFont(u);this._font=u;this._fontSize=e;this._align=o;this._letterSpacing=0;this._tint=16777215;this.updateText();this.dirty=!1;n.Component.Core.init.call(this,t,i,r,"",null)},n.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),n.BitmapText.prototype.constructor=n.BitmapText,n.Component.Core.install.call(n.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),n.BitmapText.prototype.preUpdatePhysics=n.Component.PhysicsBody.preUpdate,n.BitmapText.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.BitmapText.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.BitmapText.prototype.preUpdateCore=n.Component.Core.preUpdate,n.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.BitmapText.prototype.postUpdate=function(){n.Component.PhysicsBody.postUpdate.call(this);n.Component.FixedToCamera.postUpdate.call(this);this.body&&this.body.type===n.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},n.BitmapText.prototype.setText=function(n){this.text=n},n.BitmapText.prototype.scanLine=function(n,t,i){for(var l,e,a=0,f=0,c=-1,v=0,o=null,y=this._maxWidth>0?this._maxWidth:null,s=[],r=0;r<i.length;r++){if(l=r===i.length-1,/(?:\r\n|\r|\n)/.test(i.charAt(r)))return{width:f,text:i.substr(0,r),end:l,chars:s};var h=i.charCodeAt(r),u=n.chars[h],p=0;if(void 0===u&&(h=32,u=n.chars[h]),e=o&&u.kerning[o]?u.kerning[o]:0,/(\s)/.test(i.charAt(r))&&(c=r,v=f),p=(e+u.texture.width+u.xOffset)*t,y&&f+p>=y&&c>-1)return{width:v||f,text:i.substr(0,r-(r-c)),end:!1,chars:s};f+=(u.xAdvance+e+this.letterSpacing)*t;s.push(a+(u.xOffset+e+this.letterSpacing)*t);a+=(u.xAdvance+e+this.letterSpacing)*t;o=h}return{width:f,text:i,end:l,chars:s}},n.BitmapText.prototype.cleanText=function(n,t){var e;if(void 0===t&&(t=""),e=this._data.font,!e)return"";for(var i=n.replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),r=0;r<i.length;r++){for(var u="",o=i[r],f=0;f<o.length;f++)u=e.chars[o.charCodeAt(f)]?u.concat(o[f]):u.concat(t);i[r]=u}return i.join("\n")},n.BitmapText.prototype.updateText=function(){var r=this._data.font,n,u,o,f,t;if(r){var s=this.text,e=this._fontSize/r.size,h=[],c=0;this.textWidth=0;do(n=this.scanLine(r,e,s)).y=c,h.push(n),n.width>this.textWidth&&(this.textWidth=n.width),c+=r.lineHeight*e,s=s.substr(n.text.length+1);while(!1===n.end);this.textHeight=c;for(var l=0,a=0,v=this.textWidth*this.anchor.x,y=this.textHeight*this.anchor.y,i=0;i<h.length;i++)for(n=h[i],"right"===this._align?a=this.textWidth-n.width:"center"===this._align&&(a=(this.textWidth-n.width)/2),u=0;u<n.text.length;u++)o=n.text.charCodeAt(u),f=r.chars[o],void 0===f&&(o=32,f=r.chars[o]),t=this._glyphs[l],t?t.texture=f.texture:((t=new PIXI.Sprite(f.texture)).name=n.text[u],this._glyphs.push(t)),t.position.x=n.chars[u]+a-v,t.position.y=n.y+f.yOffset*e-y,t.scale.set(e),t.tint=this.tint,t.texture.requiresReTint=!0,t.cachedTint=16777215,t.parent||this.addChild(t),l++;for(i=l;i<this._glyphs.length;i++)this.removeChild(this._glyphs[i])}},n.BitmapText.prototype.purgeGlyphs=function(){for(var i=this._glyphs.length,t=[],n=0;n<this._glyphs.length;n++)this._glyphs[n].parent!==this?this._glyphs[n].destroy():t.push(this._glyphs[n]);return this._glyphs=[],this._glyphs=t,this.updateText(),i-t.length},n.BitmapText.prototype.updateTransform=function(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor));PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(n.BitmapText.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(n){"number"==typeof n&&(this._letterSpacing=n,this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"align",{get:function(){return this._align},set:function(n){n===this._align||"left"!==n&&"center"!==n&&"right"!==n||(this._align=n,this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(n){n!==this._tint&&(this._tint=n,this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"font",{get:function(){return this._font},set:function(n){n!==this._font&&(this._font=n.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(n){(n=parseInt(n,10))!==this._fontSize&&n>0&&(this._fontSize=n,this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"text",{get:function(){return this._text},set:function(n){n!==this._text&&(this._text=n.toString()||"",this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(n){n!==this._maxWidth&&(this._maxWidth=n,this.updateText())}}),Object.defineProperty(n.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(n){this._data.base.scaleMode=n?0:1;this._data.base.dirty()}}),n.RetroFont=function(t,i,r,u,f,e,o,s,h,c){var p;if(!t.cache.checkImageKey(i))return!1;void 0!==e&&null!==e||(e=t.cache.getImage(i).width/r);this.characterWidth=r;this.characterHeight=u;this.characterSpacingX=o||0;this.characterSpacingY=s||0;this.characterPerRow=e;this.offsetX=h||0;this.offsetY=c||0;this.align="left";this.multiLine=!1;this.autoUpperCase=!0;this.customSpacingX=0;this.customSpacingY=0;this.fixedWidth=0;this.fontSet=t.cache.getImage(i);this._text="";this.grabData=[];this.frameData=new n.FrameData;for(var a=this.offsetX,v=this.offsetY,y=0,l=0;l<f.length;l++)p=this.frameData.addFrame(new n.Frame(l,a,v,this.characterWidth,this.characterHeight)),this.grabData[f.charCodeAt(l)]=p.index,++y===this.characterPerRow?(y=0,a=this.offsetX,v+=this.characterHeight+this.characterSpacingY):a+=this.characterWidth+this.characterSpacingX;t.cache.updateFrameData(i,this.frameData);this.stamp=new n.Image(t,0,0,i,0);n.RenderTexture.call(this,t,100,100,"",n.scaleModes.NEAREST);this.type=n.RETROFONT},n.RetroFont.prototype=Object.create(n.RenderTexture.prototype),n.RetroFont.prototype.constructor=n.RetroFont,n.RetroFont.ALIGN_LEFT="left",n.RetroFont.ALIGN_RIGHT="right",n.RetroFont.ALIGN_CENTER="center",n.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",n.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",n.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",n.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",n.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",n.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",n.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",n.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",n.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",n.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",n.RetroFont.prototype.setFixedWidth=function(n,t){void 0===t&&(t="left");this.fixedWidth=n;this.align=t},n.RetroFont.prototype.setText=function(n,t,i,r,u,f){this.multiLine=t||!1;this.customSpacingX=i||0;this.customSpacingY=r||0;this.align=u||"left";this.autoUpperCase=!f;n.length>0&&(this.text=n)},n.RetroFont.prototype.buildRetroFontText=function(){var t=0,u=0,i,r;if(this.clear(),this.multiLine)for(i=this._text.split("\n"),this.fixedWidth>0?this.resize(this.fixedWidth,i.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),i.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0),r=0;r<i.length;r++)t=0,this.align===n.RetroFont.ALIGN_RIGHT?t=this.width-i[r].length*(this.characterWidth+this.customSpacingX):this.align===n.RetroFont.ALIGN_CENTER&&(t=this.width/2-i[r].length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(i[r],t,u,this.customSpacingX),u+=this.characterHeight+this.customSpacingY;else this.fixedWidth>0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),t=0,this.align===n.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===n.RetroFont.ALIGN_CENTER&&(t=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(this._text,t,0,this.customSpacingX);this.requiresReTint=!0},n.RetroFont.prototype.pasteLine=function(n,t,i,r){for(var u=0;u<n.length;u++)if(" "===n.charAt(u))t+=this.characterWidth+r;else if(this.grabData[n.charCodeAt(u)]>=0&&(this.stamp.frame=this.grabData[n.charCodeAt(u)],this.renderXY(this.stamp,t,i,!1),(t+=this.characterWidth+r)>this.width))break},n.RetroFont.prototype.getLongestLine=function(){var i=0,t,n;if(this._text.length>0)for(t=this._text.split("\n"),n=0;n<t.length;n++)t[n].length>i&&(i=t[n].length);return i},n.RetroFont.prototype.removeUnsupportedCharacters=function(n){for(var r,u,t="",i=0;i<this._text.length;i++)r=this._text[i],u=r.charCodeAt(0),(this.grabData[u]>=0||!n&&"\n"===r)&&(t=t.concat(r));return t},n.RetroFont.prototype.updateOffset=function(n,t){if(this.offsetX!==n||this.offsetY!==t){for(var u=n-this.offsetX,f=t-this.offsetY,i=this.game.cache.getFrameData(this.stamp.key).getFrames(),r=i.length;r--;)i[r].x+=u,i[r].y+=f;this.buildRetroFontText()}},Object.defineProperty(n.RetroFont.prototype,"text",{get:function(){return this._text},set:function(n){var t;(t=this.autoUpperCase?n.toUpperCase():n)!==this._text&&(this._text=t,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(n.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(n){this.stamp.smoothed=n;this.buildRetroFontText()}}),n.Rope=function(t,i,r,u,f,e){this.points=e||[];this._hasUpdateAnimation=!1;this._updateAnimationCallback=null;i=i||0;r=r||0;u=u||null;f=f||null;this.type=n.ROPE;PIXI.DisplayObjectContainer.call(this);this.texture=n.Cache.DEFAULT;this.uvs=new Float32Array([0,1,1,1,1,0,0,1]);this.vertices=new Float32Array([0,0,100,0,100,100,0,100]);this.colors=new Float32Array([1,1,1,1]);this.indices=new Uint16Array([0,1,2,3]);e&&(this.vertices=new Float32Array(4*e.length),this.uvs=new Float32Array(4*e.length),this.colors=new Float32Array(2*e.length),this.indices=new Uint16Array(2*e.length));this.dirty=!0;this.canvasPadding=0;this.drawMode=n.Rope.TRIANGLE_STRIP;n.Component.Core.init.call(this,t,i,r,u,f);this.refresh()},n.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),n.Rope.prototype.constructor=n.Rope,n.Component.Core.install.call(n.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),n.Rope.prototype.preUpdatePhysics=n.Component.PhysicsBody.preUpdate,n.Rope.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.Rope.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.Rope.prototype.preUpdateCore=n.Component.Core.preUpdate,n.Rope.TRIANGLE_STRIP=0,n.Rope.TRIANGLES=1,n.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},n.Rope.prototype.reset=function(t,i){return n.Component.Reset.prototype.reset.call(this,t,i),this},n.Rope.prototype.refresh=function(){var o=this.points,n,f,e,i;if(!(o.length<1)){var t=this.uvs,r=this.indices,u=this.colors;for(this.count-=.2,t[0]=0,t[1]=0,t[2]=0,t[3]=1,u[0]=1,u[1]=1,r[0]=0,r[1]=1,e=o.length,i=1;i<e;i++)f=i/(e-1),t[n=4*i]=f,t[n+1]=0,t[n+2]=f,t[n+3]=1,u[n=2*i]=1,u[n+1]=1,r[n=2*i]=n,r[n+1]=n+1}},n.Rope.prototype.updateTransform=function(){var r=this.points,o,f,n;if(!(r.length<1)){f=r[0];n={x:0,y:0};this.count-=.2;for(var t,u,s,h,e=this.vertices,c=r.length,i=0;i<c;i++)t=r[i],u=4*i,o=i<r.length-1?r[i+1]:t,n.y=-(o.x-f.x),n.x=o.y-f.y,10*(1-i/(c-1))>1&&1,s=Math.sqrt(n.x*n.x+n.y*n.y),h=this.texture.height/2,n.x/=s,n.y/=s,n.x*=h,n.y*=h,e[u]=t.x+n.x,e[u+1]=t.y+n.y,e[u+2]=t.x-n.x,e[u+3]=t.y-n.y,f=t;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},n.Rope.prototype.setTexture=function(n){this.texture=n},n.Rope.prototype._renderWebGL=function(n){!this.visible||this.alpha<=0||(n.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(n),n.shaderManager.setShader(n.shaderManager.stripShader),this._renderStrip(n),n.spriteBatch.start())},n.Rope.prototype._initWebGL=function(n){var t=n.gl;this._vertexBuffer=t.createBuffer();this._indexBuffer=t.createBuffer();this._uvBuffer=t.createBuffer();this._colorBuffer=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer);t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW);t.bindBuffer(t.ARRAY_BUFFER,this._uvBuffer);t.bufferData(t.ARRAY_BUFFER,this.uvs,t.STATIC_DRAW);t.bindBuffer(t.ARRAY_BUFFER,this._colorBuffer);t.bufferData(t.ARRAY_BUFFER,this.colors,t.STATIC_DRAW);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer);t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW)},n.Rope.prototype._renderStrip=function(t){var i=t.gl,u=t.projection,f=t.offset,r=t.shaderManager.stripShader,e=this.drawMode===n.Rope.TRIANGLE_STRIP?i.TRIANGLE_STRIP:i.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode);i.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0));i.uniform2f(r.projectionVector,u.x,-u.y);i.uniform2f(r.offsetVector,-f.x,-f.y);i.uniform1f(r.alpha,this.worldAlpha);this.dirty?(this.dirty=!1,i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferData(i.ARRAY_BUFFER,this.vertices,i.STATIC_DRAW),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.bufferData(i.ARRAY_BUFFER,this.uvs,i.STATIC_DRAW),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,this.indices,i.STATIC_DRAW)):(i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.vertices),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer));i.drawElements(e,this.indices.length,i.UNSIGNED_SHORT,0)},n.Rope.prototype._renderCanvas=function(t){var r=t.context,i=this.worldTransform,u=i.tx*t.resolution+t.shakeX,f=i.ty*t.resolution+t.shakeY;t.roundPixels?r.setTransform(i.a,i.b,i.c,i.d,0|u,0|f):r.setTransform(i.a,i.b,i.c,i.d,u,f);this.drawMode===n.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(r):this._renderCanvasTriangles(r)},n.Rope.prototype._renderCanvasTriangleStrip=function(n){var r=this.vertices,u=this.uvs,f=r.length/2,t,i;for(this.count++,t=0;t<f-2;t++)i=2*t,this._renderCanvasDrawTriangle(n,r,u,i,i+2,i+4)},n.Rope.prototype._renderCanvasTriangles=function(n){var r=this.vertices,u=this.uvs,i=this.indices,f=i.length,t;for(this.count++,t=0;t<f;t+=3){var e=2*i[t],o=2*i[t+1],s=2*i[t+2];this._renderCanvasDrawTriangle(n,r,u,e,o,s)}},n.Rope.prototype._renderCanvasDrawTriangle=function(n,t,i,r,u,f){var ot=this.texture.baseTexture.source,rt=this.texture.width,ut=this.texture.height,s=t[r],h=t[u],c=t[f],l=t[r+1],a=t[u+1],v=t[f+1],y=i[r]*rt,p=i[u]*rt,w=i[f]*rt,b=i[r+1]*ut,k=i[u+1]*ut,d=i[f+1]*ut;if(this.canvasPadding>0){var ft=this.canvasPadding/this.worldTransform.a,et=this.canvasPadding/this.worldTransform.d,nt=(s+h+c)/3,tt=(l+a+v)/3,g=s-nt,o=l-tt,e=Math.sqrt(g*g+o*o);s=nt+g/e*(e+ft);l=tt+o/e*(e+et);o=a-tt;h=nt+(g=h-nt)/(e=Math.sqrt(g*g+o*o))*(e+ft);a=tt+o/e*(e+et);o=v-tt;c=nt+(g=c-nt)/(e=Math.sqrt(g*g+o*o))*(e+ft);v=tt+o/e*(e+et)}n.save();n.beginPath();n.moveTo(s,l);n.lineTo(h,a);n.lineTo(c,v);n.closePath();n.clip();var it=y*k+b*w+p*d-k*w-b*p-y*d,st=s*k+b*c+h*d-k*c-b*h-s*d,ht=y*h+s*w+p*c-h*w-s*p-y*c,ct=y*k*c+b*h*w+s*p*d-s*k*w-b*p*c-y*h*d,lt=l*k+b*v+a*d-k*v-b*a-l*d,at=y*a+l*w+p*v-a*w-l*p-y*v,vt=y*k*v+b*a*w+l*p*d-l*k*w-b*p*v-y*a*d;n.transform(st/it,lt/it,ht/it,at/it,ct/it,vt/it);n.drawImage(ot,0,0);n.restore()},n.Rope.prototype.renderStripFlat=function(n){var t=this.context,i=n.vertices,f=i.length/2,u;for(this.count++,t.beginPath(),u=1;u<f-2;u++){var r=2*u,e=i[r],o=i[r+2],s=i[r+4],h=i[r+1],c=i[r+3],l=i[r+5];t.moveTo(e,h);t.lineTo(o,c);t.lineTo(s,l)}t.fillStyle="#FF0000";t.fill();t.closePath()},n.Rope.prototype.getBounds=function(t){for(var i,r=t||this.worldTransform,y=r.a,p=r.b,w=r.c,b=r.d,k=r.tx,d=r.ty,o=-1/0,f=-1/0,u=1/0,e=1/0,l=this.vertices,s=0;s<l.length;s+=2){var a=l[s],v=l[s+1],h=y*a+w*v+k,c=b*v+p*a+d;u=h<u?h:u;e=c<e?c:e;o=h>o?h:o;f=c>f?c:f}return u===-1/0||f===1/0?n.EmptyRectangle:(i=this._bounds,i.x=u,i.width=o-u,i.y=e,i.height=f-e,this._currentBounds=i,i)},Object.defineProperty(n.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(n){n&&"function"==typeof n?(this._hasUpdateAnimation=!0,this._updateAnimation=n):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(n.Rope.prototype,"segments",{get:function(){for(var t,i,r,f,e,o,s,h,c=[],u=0;u<this.points.length;u++)t=4*u,i=this.vertices[t]*this.scale.x,r=this.vertices[t+1]*this.scale.y,f=this.vertices[t+4]*this.scale.x,e=this.vertices[t+3]*this.scale.y,o=n.Math.difference(i,f),s=n.Math.difference(r,e),i+=this.world.x,r+=this.world.y,h=new n.Rectangle(i,r,o,s),c.push(h);return c}}),n.TileSprite=function(t,i,r,u,f,e,o){i=i||0;r=r||0;u=u||256;f=f||256;e=e||null;o=o||null;PIXI.Sprite.call(this,new PIXI.Texture(n.Cache.DEFAULT.baseTexture),u,f);this.type=n.TILESPRITE;this.physicsType=n.SPRITE;this._scroll=new n.Point;this.tileScale=new n.Point(1,1);this.tileScaleOffset=new n.Point(1,1);this.tilePosition=new n.Point;this.textureDebug=!1;this.canvasBuffer=null;this.tilingTexture=null;this.tilePattern=null;this.refreshTexture=!0;this.frameWidth=0;this.frameHeight=0;this._width=u;this._height=f;n.Component.Core.init.call(this,t,i,r,e,o)},n.TileSprite.prototype=Object.create(PIXI.Sprite.prototype),n.TileSprite.prototype.constructor=n.TileSprite,n.Component.Core.install.call(n.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),n.TileSprite.prototype.preUpdatePhysics=n.Component.PhysicsBody.preUpdate,n.TileSprite.prototype.preUpdateLifeSpan=n.Component.LifeSpan.preUpdate,n.TileSprite.prototype.preUpdateInWorld=n.Component.InWorld.preUpdate,n.TileSprite.prototype.preUpdateCore=n.Component.Core.preUpdate,n.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},n.TileSprite.prototype.autoScroll=function(n,t){return this._scroll.set(n,t),this},n.TileSprite.prototype.stopScroll=function(){return this._scroll.set(0,0),this},n.TileSprite.prototype.destroy=function(t){n.Component.Destroy.prototype.destroy.call(this,t);PIXI.Sprite.prototype.destroy.call(this);this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null);this.tileScale=null;this.tileScaleOffset=null;this.tilePosition=null;this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},n.TileSprite.prototype.reset=function(t,i){return n.Component.Reset.prototype.reset.call(this,t,i),this.tilePosition.x=0,this.tilePosition.y=0,this},n.TileSprite.prototype.setTexture=function(n){return this.texture!==n&&(this.texture=n,this.refreshTexture=!0,this.cachedTint=16777215),this},n.TileSprite.prototype._renderWebGL=function(n){var t,i;if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(n.spriteBatch.stop(),n.maskManager.pushMask(this.mask,n),n.spriteBatch.start()),this._filters&&(n.spriteBatch.flush(),n.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,n),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,n.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}for(n.spriteBatch.renderTilingSprite(this),t=0;t<this.children.length;t++)this.children[t]._renderWebGL(n);i=!1;this._filters&&(i=!0,n.spriteBatch.stop(),n.filterManager.popFilter());this._mask&&(i||n.spriteBatch.stop(),n.maskManager.popMask(this._mask,n));i&&n.spriteBatch.start()}},n.TileSprite.prototype._renderCanvas=function(n){var t,s,i,r,c,l,h;if(this.visible&&this.renderable&&0!==this.alpha){t=n.context;this._mask&&n.maskManager.pushMask(this._mask,n);t.globalAlpha=this.worldAlpha;var u=this.worldTransform,f=n.resolution,e=u.tx*f+n.shakeX,o=u.ty*f+n.shakeY;if(t.setTransform(u.a*f,u.b*f,u.c*f,u.d*f,e,o),16777215===this.tint||!this.texture.requiresReTint&&this.cachedTint===this.tint||(this.tintedTexture=PIXI.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1,this.refreshTexture=!0),this.refreshTexture){if(this.generateTilingTexture(!1,n),!this.tilingTexture)return;this.tilePattern=t.createPattern(this.tilingTexture.baseTexture.source,"repeat")}for(s=n.currentBlendMode,this.blendMode!==n.currentBlendMode&&(n.currentBlendMode=this.blendMode,t.globalCompositeOperation=PIXI.blendModesCanvas[n.currentBlendMode]),i=this.tilePosition,r=this.tileScale,i.x%=this.tilingTexture.baseTexture.width,i.y%=this.tilingTexture.baseTexture.height,t.scale(r.x,r.y),t.translate(i.x+this.anchor.x*-this._width,i.y+this.anchor.y*-this._height),t.fillStyle=this.tilePattern,e=-i.x,o=-i.y,c=this._width/r.x,l=this._height/r.y,n.roundPixels&&(e|=0,o|=0,c|=0,l|=0),t.fillRect(e,o,c,l),t.scale(1/r.x,1/r.y),t.translate(-i.x+this.anchor.x*this._width,-i.y+this.anchor.y*this._height),this._mask&&n.maskManager.popMask(n),h=0;h<this.children.length;h++)this.children[h]._renderCanvas(n);s!==this.blendMode&&(n.currentBlendMode=s,t.globalCompositeOperation=PIXI.blendModesCanvas[s])}},n.TileSprite.prototype.onTextureUpdate=function(){},n.TileSprite.prototype.generateTilingTexture=function(t){var f,e,c;if(this.texture.baseTexture.hasLoaded){var u=this.texture,o=u.frame,i=this._frame.sourceSizeW||this._frame.width,r=this._frame.sourceSizeH||this._frame.height,s=0,h=0;this._frame.trimmed&&(s=this._frame.spriteSourceSizeX,h=this._frame.spriteSourceSizeY);t&&(i=n.Math.getNextPowerOfTwo(i),r=n.Math.getNextPowerOfTwo(r));this.canvasBuffer?(this.canvasBuffer.resize(i,r),this.tilingTexture.baseTexture.width=i,this.tilingTexture.baseTexture.height=r,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new PIXI.CanvasBuffer(i,r),this.tilingTexture=PIXI.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,this.tilingTexture.needsUpdate=!0);this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,i,r));f=u.crop.width;e=u.crop.height;f===i&&e===r||(f=i,e=r);c=this.tintedTexture?this.tintedTexture:u.baseTexture.source;this.canvasBuffer.context.drawImage(c,u.crop.x,u.crop.y,u.crop.width,u.crop.height,s,h,f,e);this.tileScaleOffset.x=o.width/i;this.tileScaleOffset.y=o.height/r;this.refreshTexture=!1;this.tilingTexture.baseTexture._powerOf2=!0}},n.TileSprite.prototype.getBounds=function(){var rt=this._width,ut=this._height,e=rt*(1-this.anchor.x),o=rt*-this.anchor.x,s=ut*(1-this.anchor.y),h=ut*-this.anchor.y,f=this.worldTransform,c=f.a,l=f.b,a=f.c,v=f.d,y=f.tx,p=f.ty,w=c*o+a*h+y,b=v*h+l*o+p,k=c*e+a*h+y,d=v*h+l*e+p,g=c*e+a*s+y,nt=v*s+l*e+p,tt=c*o+a*s+y,it=v*s+l*o+p,i=-1/0,r=-1/0,n=1/0,t=1/0,u;return n=tt<(n=g<(n=k<(n=w<n?w:n)?k:n)?g:n)?tt:n,t=it<(t=nt<(t=d<(t=b<t?b:t)?d:t)?nt:t)?it:t,i=tt>(i=g>(i=k>(i=w>i?w:i)?k:i)?g:i)?tt:i,r=it>(r=nt>(r=d>(r=b>r?b:r)?d:r)?nt:r)?it:r,u=this._bounds,u.x=n,u.width=i-n,u.y=t,u.height=r-t,this._currentBounds=u,u},Object.defineProperty(n.TileSprite.prototype,"width",{get:function(){return this._width},set:function(n){this._width=n}}),Object.defineProperty(n.TileSprite.prototype,"height",{get:function(){return this._height},set:function(n){this._height=n}}),n.CanvasPool={create:function(t,i,r){var u,f=n.CanvasPool.getFirst(),e;return-1===f?(e={parent:t,canvas:document.createElement("canvas")},n.CanvasPool.pool.push(e),u=e.canvas):(n.CanvasPool.pool[f].parent=t,u=n.CanvasPool.pool[f].canvas),void 0!==i&&(u.width=i,u.height=r),u},getFirst:function(){for(var i=n.CanvasPool.pool,t=0;t<i.length;t++)if(!i[t].parent)return t;return-1},remove:function(t){for(var r=n.CanvasPool.pool,i=0;i<r.length;i++)r[i].parent===t&&(r[i].parent=null,r[i].canvas.width=1,r[i].canvas.height=1)},removeByCanvas:function(t){for(var r=n.CanvasPool.pool,i=0;i<r.length;i++)r[i].canvas===t&&(r[i].parent=null,r[i].canvas.width=1,r[i].canvas.height=1)},getTotal:function(){for(var i=n.CanvasPool.pool,r=0,t=0;t<i.length;t++)i[t].parent&&r++;return r},getFree:function(){for(var i=n.CanvasPool.pool,r=0,t=0;t<i.length;t++)i[t].parent||r++;return r},log:function(){console.log("CanvasPool: %s used, %s free, %s total",this.getTotal(),this.getFree(),this.pool.length)}},n.CanvasPool.pool=[],Object.defineProperty(n.CanvasPool,"length",{get:function(){return this.pool.length}}),n.Device=function(){this.deviceReadyAt=0;this.initialized=!1;this.desktop=!1;this.iOS=!1;this.iOSVersion=0;this.cocoonJS=!1;this.cocoonJSApp=!1;this.cordova=!1;this.node=!1;this.nodeWebkit=!1;this.electron=!1;this.ejecta=!1;this.crosswalk=!1;this.android=!1;this.chromeOS=!1;this.linux=!1;this.macOS=!1;this.windows=!1;this.windowsPhone=!1;this.canvas=!1;this.canvasBitBltShift=null;this.canHandleAlpha=!1;this.canUseMultiply=!1;this.webGL=!1;this.file=!1;this.fileSystem=!1;this.localStorage=!1;this.worker=!1;this.css3D=!1;this.pointerLock=!1;this.typedArray=!1;this.vibration=!1;this.getUserMedia=!0;this.quirksMode=!1;this.touch=!1;this.mspointer=!1;this.wheelEvent=null;this.arora=!1;this.chrome=!1;this.chromeVersion=0;this.epiphany=!1;this.firefox=!1;this.firefoxVersion=0;this.ie=!1;this.ieVersion=0;this.trident=!1;this.tridentVersion=0;this.edge=!1;this.mobileSafari=!1;this.midori=!1;this.opera=!1;this.safari=!1;this.safariVersion=0;this.webApp=!1;this.silk=!1;this.audioData=!1;this.webAudio=!1;this.ogg=!1;this.opus=!1;this.mp3=!1;this.wav=!1;this.m4a=!1;this.webm=!1;this.dolby=!1;this.oggVideo=!1;this.h264Video=!1;this.mp4Video=!1;this.webmVideo=!1;this.vp9Video=!1;this.hlsVideo=!1;this.iPhone=!1;this.iPhone4=!1;this.iPad=!1;this.pixelRatio=0;this.littleEndian=!1;this.LITTLE_ENDIAN=!1;this.support32bit=!1;this.fullscreen=!1;this.requestFullscreen="";this.cancelFullscreen="";this.fullscreenKeyboard=!1},n.Device=new n.Device,n.Device.onInitialized=new n.Signal,n.Device.whenReady=function(n,t,i){var r=this._readyCheck,u,f;this.deviceReadyAt||!r?n.call(t,this):r._monitor||i?(r._queue=r._queue||[],r._queue.push([n,t])):(r._monitor=r.bind(this),r._queue=r._queue||[],r._queue.push([n,t]),u=void 0!==window.cordova,f=navigator.isCocoonJS,"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(r._monitor,0):u&&!f?document.addEventListener("deviceready",r._monitor,!1):(document.addEventListener("DOMContentLoaded",r._monitor,!1),window.addEventListener("load",r._monitor,!1)))},n.Device._readyCheck=function(){var n=this._readyCheck,t,i,r;if(document.body){if(!this.deviceReadyAt){for(this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",n._monitor),document.removeEventListener("DOMContentLoaded",n._monitor),window.removeEventListener("load",n._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);t=n._queue.shift();)i=t[0],r=t[1],i.call(r,this);this._readyCheck=null;this._initialize=null;this.onInitialized=null}}else window.setTimeout(n._monitor,20)},n.Device._initialize=function(){function i(){var t=new ArrayBuffer(4),n=new Uint8Array(t),i=new Uint32Array(t);return n[0]=161,n[1]=178,n[2]=195,n[3]=212,3569595041===i[0]||2712847316!==i[0]&&null}function r(){var t,i;return void 0===Uint8ClampedArray?!1:(t=n.CanvasPool.create(this,1,1).getContext("2d"),!t)?!1:(i=t.createImageData(1,1),n.CanvasPool.remove(this),i.data instanceof Uint8ClampedArray)}var t=this;!function(){var n=navigator.userAgent,i;/Playstation Vita/.test(n)?t.vita=!0:/Kindle/.test(n)||/\bKF[A-Z][A-Z]+/.test(n)||/Silk.*Mobile Safari/.test(n)?t.kindle=!0:/Android/.test(n)?t.android=!0:/CrOS/.test(n)?t.chromeOS=!0:/iP[ao]d|iPhone/i.test(n)?(t.iOS=!0,navigator.appVersion.match(/OS (\d+)/),t.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(n)?t.linux=!0:/Mac OS/.test(n)?t.macOS=!0:/Windows/.test(n)&&(t.windows=!0);(/Windows Phone/i.test(n)||/IEMobile/i.test(n))&&(t.android=!1,t.iOS=!1,t.macOS=!1,t.windows=!0,t.windowsPhone=!0);i=/Silk/.test(n);(t.windows||t.macOS||t.linux&&!i||t.chromeOS)&&(t.desktop=!0);(t.windowsPhone||/Windows NT/i.test(n)&&/Touch/i.test(n))&&(t.desktop=!1)}(),function(){var n=navigator.userAgent;if(/Arora/.test(n)?t.arora=!0:/Edge\/\d+/.test(n)?t.edge=!0:/Chrome\/(\d+)/.test(n)&&!t.windowsPhone?(t.chrome=!0,t.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(n)?t.epiphany=!0:/Firefox\D+(\d+)/.test(n)?(t.firefox=!0,t.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&t.iOS?t.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(t.ie=!0,t.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(n)?t.midori=!0:/Opera/.test(n)?t.opera=!0:/Safari\/(\d+)/.test(n)&&!t.windowsPhone?(t.safari=!0,/Version\/(\d+)\./.test(n)&&(t.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(t.ie=!0,t.trident=!0,t.tridentVersion=parseInt(RegExp.$1,10),t.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(t.silk=!0),navigator.standalone&&(t.webApp=!0),void 0!==window.cordova&&(t.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(t.node=!0),t.node&&"object"==typeof process.versions&&(t.nodeWebkit=!!process.versions["node-webkit"],t.electron=!!process.versions.electron),navigator.isCocoonJS&&(t.cocoonJS=!0),t.cocoonJS)try{t.cocoonJSApp="undefined"!=typeof CocoonJS}catch(n){t.cocoonJSApp=!1}void 0!==window.ejecta&&(t.ejecta=!0);/Crosswalk/.test(n)&&(t.crosswalk=!0)}(),function(){var n,i,r;t.audioData=!!window.Audio;t.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);n=document.createElement("audio");try{n.canPlayType&&(n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(t.ogg=!0),(n.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||n.canPlayType("audio/opus;").replace(/^no$/,""))&&(t.opus=!0),n.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(t.mp3=!0),n.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(t.wav=!0),(n.canPlayType("audio/x-m4a;")||n.canPlayType("audio/aac;").replace(/^no$/,""))&&(t.m4a=!0),n.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(t.webm=!0),""!==n.canPlayType('audio/mp4;codecs="ec-3"'))&&(t.edge?t.dolby=!0:t.safari&&t.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)&&(i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10),(10===i&&r>=11||i>10)&&(t.dolby=!0)))}catch(n){}}(),function(){var n=document.createElement("video");try{n.canPlayType&&(n.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(t.oggVideo=!0),n.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(t.h264Video=!0,t.mp4Video=!0),n.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(t.webmVideo=!0),n.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(t.vp9Video=!0),n.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(t.hlsVideo=!0))}catch(n){}}(),function(){var i,n=document.createElement("p"),u={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"},r;document.body.insertBefore(n,null);for(r in u)void 0!==n.style[r]&&(n.style[r]="translate3d(1px,1px,1px)",i=window.getComputedStyle(n).getPropertyValue(u[r]));document.body.removeChild(n);t.css3D=void 0!==i&&i.length>0&&"none"!==i}();t.pixelRatio=window.devicePixelRatio||1;t.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone");t.iPhone4=2===t.pixelRatio&&t.iPhone;t.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad");t.typedArray="undefined"!=typeof Int8Array?!0:!1;"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(t.littleEndian=i(),t.LITTLE_ENDIAN=t.littleEndian);t.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==t.littleEndian&&r();navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate;navigator.vibrate&&(t.vibration=!0),function(){t.canvas=!!window.CanvasRenderingContext2D||t.cocoonJS;try{t.localStorage=!!localStorage.getItem}catch(n){t.localStorage=!1}t.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob);t.fileSystem=!!window.requestFileSystem;t.webGL=!!window.WebGLRenderingContext;t.worker=!!window.Worker;t.pointerLockElement="pointerLockElement"in document&&"pointerLockElement"||"mozPointerLockElement"in document&&"mozPointerLockElement"||"webkitPointerLockElement"in document&&"webkitPointerLockElement";t.pointerlockchange="onpointerlockchange"in document&&"pointerlockchange"||"onmozpointerlockchange"in document&&"mozpointerlockchange"||"onwebkitpointerlockchange"in document&&"webkitpointerlockchange";t.pointerlockerror="onpointerlockerror"in document&&"pointerlockerror"||"onmozpointerlockerror"in document&&"mozpointerlockerror"||"onwebkitpointerlockerror"in document&&"webkitpointerlockerror";t.pointerLock=!!t.pointerLockElement;t.quirksMode="CSS1Compat"!==document.compatMode;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia;window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL;t.getUserMedia=t.getUserMedia&&!!navigator.getUserMedia&&!!window.URL;t.firefox&&t.firefoxVersion<21&&(t.getUserMedia=!1);!t.iOS&&(t.ie||t.firefox||t.chrome)&&(t.canvasBitBltShift=!0);(t.safari||t.mobileSafari)&&(t.canvasBitBltShift=!1)}(),function(){var f=n.CanvasPool.create(this,6,1),i=f.getContext("2d"),r,u;i.fillStyle="rgba(10, 20, 30, 0.5)";i.fillRect(0,0,1,1);r=i.getImageData(0,0,1,1);r&&(i.putImageData(r,1,0),u=i.getImageData(1,0,1,1),t.canHandleAlpha=u.data[0]===r.data[0]&&u.data[1]===r.data[1]&&u.data[2]===r.data[2]&&u.data[3]===r.data[3]);i.globalCompositeOperation="multiply";t.canUseMultiply="multiply"===i.globalCompositeOperation;n.CanvasPool.removeByCanvas(f);PIXI.CanvasTinter.tintMethod=t.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var i,r=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],u=document.createElement("div"),n=0;n<r.length;n++)if(u[r[n]]){t.fullscreen=!0;t.requestFullscreen=r[n];break}if(i=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"],t.fullscreen)for(n=0;n<i.length;n++)if(document[i[n]]){t.cancelFullscreen=i[n];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(t.fullscreenKeyboard=!0)}();("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(t.touch=!0);(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(t.mspointer=!0);t.cocoonJS||("onwheel"in window||t.ie&&"WheelEvent"in window?t.wheelEvent="wheel":"onmousewheel"in window?t.wheelEvent="mousewheel":t.firefox&&"MouseScrollEvent"in window&&(t.wheelEvent="DOMMouseScroll"))},n.Device.canPlayAudio=function(n){return!("mp3"!==n||!this.mp3)||!("ogg"!==n||!this.ogg&&!this.opus)||!("m4a"!==n||!this.m4a)||!("opus"!==n||!this.opus)||!("wav"!==n||!this.wav)||!("webm"!==n||!this.webm)||!("mp4"!==n||!this.dolby)},n.Device.canPlayVideo=function(n){return!("webm"!==n||!this.webmVideo&&!this.vp9Video)||!("mp4"!==n||!this.mp4Video&&!this.h264Video)||!("ogg"!==n&&"ogv"!==n||!this.oggVideo)||!("mpeg"!==n||!this.hlsVideo)},n.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},n.Device.isAndroidStockBrowser=function(){var n=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return n&&n[1]<537},n.Canvas={create:function(t,i,r,u,f){i=i||256;r=r||256;var e=f?document.createElement("canvas"):n.CanvasPool.create(t,i,r);return"string"==typeof u&&""!==u&&(e.id=u),e.width=i,e.height=r,e.style.display="block",e},setBackgroundColor:function(n,t){return t=t||"rgb(0,0,0)",n.style.backgroundColor=t,n},setTouchAction:function(n,t){return t=t||"none",n.style.msTouchAction=t,n.style["ms-touch-action"]=t,n.style["touch-action"]=t,n},setUserSelect:function(n,t){return t=t||"none",n.style["-webkit-touch-callout"]=t,n.style["-webkit-user-select"]=t,n.style["-khtml-user-select"]=t,n.style["-moz-user-select"]=t,n.style["-ms-user-select"]=t,n.style["user-select"]=t,n.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",n},addToDOM:function(n,t,i){var r;return void 0===i&&(i=!0),t&&("string"==typeof t?r=document.getElementById(t):"object"==typeof t&&1===t.nodeType&&(r=t)),r||(r=document.body),i&&r.style&&(r.style.overflow="hidden"),r.appendChild(n),n},removeFromDOM:function(n){n.parentNode&&n.parentNode.removeChild(n)},setTransform:function(n,t,i,r,u,f,e){return n.setTransform(r,f,e,u,t,i),n},setSmoothingEnabled:function(t,i){var r=n.Canvas.getSmoothingPrefix(t);return r&&(t[r]=i),t},getSmoothingPrefix:function(n){var i=["i","webkitI","msI","mozI","oI"],r,t;for(r in i)if(t=i[r]+"mageSmoothingEnabled",t in n)return t;return null},getSmoothingEnabled:function(t){var i=n.Canvas.getSmoothingPrefix(t);if(i)return t[i]},setImageRenderingCrisp:function(n){for(var i=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges","pixelated"],t=0;t<i.length;t++)n.style["image-rendering"]=i[t];return n.style.msInterpolationMode="nearest-neighbor",n},setImageRenderingBicubic:function(n){return n.style["image-rendering"]="auto",n.style.msInterpolationMode="bicubic",n}},n.RequestAnimationFrame=function(n,t){void 0===t&&(t=!1);this.game=n;this.isRunning=!1;this.forceSetTimeOut=t;for(var r=["ms","moz","webkit","o"],i=0;i<r.length&&!window.requestAnimationFrame;i++)window.requestAnimationFrame=window[r[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[r[i]+"CancelAnimationFrame"]||window[r[i]+"CancelRequestAnimationFrame"];this._isSetTimeOut=!1;this._onLoop=null;this._timeOutID=null},n.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var n=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return n.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(t){return n.updateRAF(t)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(n){this.isRunning&&(this.game.update(Math.floor(n)),this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateSetTimeout:function(){this.isRunning&&(this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall))},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID);this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return!1===this._isSetTimeOut}},n.RequestAnimationFrame.prototype.constructor=n.RequestAnimationFrame,n.Math={PI2:2*Math.PI,HALF_PI:.5*Math.PI,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,degToRad:function(t){return t*n.Math.DEG_TO_RAD},radToDeg:function(t){return t*n.Math.RAD_TO_DEG},getNextPowerOfTwo:function(n){if(n>0&&0==(n&n-1))return n;for(var t=1;t<n;)t<<=1;return t},isPowerOfTwo:function(n,t){return n>0&&0==(n&n-1)&&t>0&&0==(t&t-1)},random:function(n,t){if(void 0===n&&(n=0),void 0===t&&(t=1),n===t)return n;if(n>t){var i=n;n=t;t=i}return Math.random()*(t-n)+n},between:function(n,t){if(void 0===n&&(n=0),void 0===t&&(t=1),n===t)return n;if(n>t){var i=n;n=t;t=i}return n=Math.ceil(n),t=Math.floor(t),Math.floor(Math.random()*(t-n+1))+n},fuzzyEqual:function(n,t,i){return void 0===i&&(i=.0001),Math.abs(n-t)<i},fuzzyLessThan:function(n,t,i){return void 0===i&&(i=.0001),n<t+i},fuzzyGreaterThan:function(n,t,i){return void 0===i&&(i=.0001),n>t-i},fuzzyCeil:function(n,t){return void 0===t&&(t=.0001),Math.ceil(n-t)},fuzzyFloor:function(n,t){return void 0===t&&(t=.0001),Math.floor(n+t)},average:function(){for(var t=0,i=arguments.length,n=0;n<i;n++)t+=+arguments[n];return t/i},shear:function(n){return n%1},snapTo:function(n,t,i){return void 0===i&&(i=0),0===t?n:(n-=i,n=t*Math.round(n/t),i+n)},snapToFloor:function(n,t,i){return void 0===i&&(i=0),0===t?n:(n-=i,n=t*Math.floor(n/t),i+n)},snapToCeil:function(n,t,i){return void 0===i&&(i=0),0===t?n:(n-=i,n=t*Math.ceil(n/t),i+n)},roundTo:function(n,t,i){void 0===t&&(t=0);void 0===i&&(i=10);var r=Math.pow(i,-t);return Math.round(n*r)/r},floorTo:function(n,t,i){void 0===t&&(t=0);void 0===i&&(i=10);var r=Math.pow(i,-t);return Math.floor(n*r)/r},ceilTo:function(n,t,i){void 0===t&&(t=0);void 0===i&&(i=10);var r=Math.pow(i,-t);return Math.ceil(n*r)/r},trunc:function(n){return isFinite(n)?n-n%1||(n<0?-0:0===n?n:0):n},rotateToAngle:function(t,i,r){return void 0===r&&(r=.05),t===i?t:(Math.abs(i-t)<=r||Math.abs(i-t)>=n.Math.PI2-r?t=i:(Math.abs(i-t)>Math.PI&&(i<t?i+=n.Math.PI2:i-=n.Math.PI2),i>t?t+=r:i<t&&(t-=r)),t)},getShortestAngle:function(n,t){var i=t-n;return 0===i?0:i-360*Math.floor((i- -180)/360)},angleBetween:function(n,t,i,r){return Math.atan2(r-t,i-n)},angleBetweenY:function(n,t,i,r){return Math.atan2(i-n,r-t)},angleBetweenPoints:function(n,t){return Math.atan2(t.y-n.y,t.x-n.x)},angleBetweenPointsY:function(n,t){return Math.atan2(t.x-n.x,t.y-n.y)},reverseAngle:function(n){return this.normalizeAngle(n+Math.PI,!0)},normalizeAngle:function(n){return(n%=2*Math.PI)>=0?n:n+2*Math.PI},maxAdd:function(n,t,i){return Math.min(n+t,i)},minSub:function(n,t,i){return Math.max(n-t,i)},wrap:function(n,t,i){var u=i-t,r;return u<=0?0:(r=(n-t)%u,r<0&&(r+=u),r+t)},wrapValue:function(n,t,i){return n=Math.abs(n),t=Math.abs(t),i=Math.abs(i),(n+t)%i},isOdd:function(n){return!!(1&n)},isEven:function(n){return!(1&n)},min:function(){for(var n=1===arguments.length&&"object"==typeof arguments[0]?arguments[0]:arguments,t=1,i=0,r=n.length;t<r;t++)n[t]<n[i]&&(i=t);return n[i]},max:function(){for(var n=1===arguments.length&&"object"==typeof arguments[0]?arguments[0]:arguments,t=1,i=0,r=n.length;t<r;t++)n[t]>n[i]&&(i=t);return n[i]},minProperty:function(n){for(var t=2===arguments.length&&"object"==typeof arguments[1]?arguments[1]:arguments.slice(1),i=1,r=0,u=t.length;i<u;i++)t[i][n]<t[r][n]&&(r=i);return t[r][n]},maxProperty:function(n){for(var t=2===arguments.length&&"object"==typeof arguments[1]?arguments[1]:arguments.slice(1),i=1,r=0,u=t.length;i<u;i++)t[i][n]>t[r][n]&&(r=i);return t[r][n]},wrapAngle:function(n,t){return t?this.wrap(n,-Math.PI,Math.PI):this.wrap(n,-180,180)},linearInterpolation:function(n,t){var i=n.length-1,r=i*t,u=Math.floor(r);return t<0?this.linear(n[0],n[1],r):t>1?this.linear(n[i],n[i-1],i-r):this.linear(n[u],n[u+1>i?i:u+1],r-u)},bezierInterpolation:function(n,t){for(var u=0,r=n.length-1,i=0;i<=r;i++)u+=Math.pow(1-t,r-i)*Math.pow(t,i)*n[i]*this.bernstein(r,i);return u},catmullRomInterpolation:function(n,t){var i=n.length-1,u=i*t,r=Math.floor(u);return n[0]===n[i]?(t<0&&(r=Math.floor(u=i*(1+t))),this.catmullRom(n[(r-1+i)%i],n[r],n[(r+1)%i],n[(r+2)%i],u-r)):t<0?n[0]-(this.catmullRom(n[0],n[0],n[1],n[1],-u)-n[0]):t>1?n[i]-(this.catmullRom(n[i],n[i],n[i-1],n[i-1],u-i)-n[i]):this.catmullRom(n[r?r-1:0],n[r],n[i<r+1?i:r+1],n[i<r+2?i:r+2],u-r)},linear:function(n,t,i){return(t-n)*i+n},bernstein:function(n,t){return this.factorial(n)/this.factorial(t)/this.factorial(n-t)},factorial:function(n){if(0===n)return 1;for(var t=n;--n;)t*=n;return t},catmullRom:function(n,t,i,r,u){var f=.5*(i-n),e=.5*(r-t),o=u*u;return(2*t-2*i+f+e)*u*o+(-3*t+3*i-2*f-e)*o+f*u+t},difference:function(n,t){return Math.abs(n-t)},roundAwayFromZero:function(n){return n>0?Math.ceil(n):Math.floor(n)},sinCosGenerator:function(n,t,i,r){void 0===t&&(t=1);void 0===i&&(i=1);void 0===r&&(r=1);for(var f=t,e=i,o=r*Math.PI/n,s=[],h=[],u=0;u<n;u++)f+=(e-=f*o)*o,s[u]=e,h[u]=f;return{sin:h,cos:s,length:n}},hypot:function(n,t){return Math.sqrt(n*n+t*t)},distance:function(n,t,i,r){var u=n-i,f=t-r;return Math.sqrt(u*u+f*f)},distanceSq:function(n,t,i,r){var u=n-i,f=t-r;return u*u+f*f},distancePow:function(n,t,i,r,u){return void 0===u&&(u=2),Math.sqrt(Math.pow(i-n,u)+Math.pow(r-t,u))},clamp:function(n,t,i){return n<t?t:i<n?i:n},clampBottom:function(n,t){return n<t?t:n},within:function(n,t,i){return Math.abs(n-t)<=i},mapLinear:function(n,t,i,r,u){return r+(n-t)*(u-r)/(i-t)},smoothstep:function(n,t,i){return(n=Math.max(0,Math.min(1,(n-t)/(i-t))))*n*(3-2*n)},smootherstep:function(n,t,i){return(n=Math.max(0,Math.min(1,(n-t)/(i-t))))*n*n*(n*(6*n-15)+10)},sign:function(n){return n<0?-1:n>0?1:0},percent:function(n,t,i){return void 0===i&&(i=0),n>t||i>t?1:n<i||i>n?0:(n-i)/t}},n.RandomDataGenerator=function(n){void 0===n&&(n=[]);this.c=1;this.s0=0;this.s1=0;this.s2=0;"string"==typeof n?this.state(n):this.sow(n)},n.RandomDataGenerator.prototype={rnd:function(){var n=2091639*this.s0+23283064365386963e-26*this.c;return this.c=0|n,this.s0=this.s1,this.s1=this.s2,this.s2=n-this.c,this.s2},sow:function(n){var t,i;if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,n)for(t=0;t<n.length&&null!=n[t];t++)i=n[t],this.s0-=this.hash(i),this.s0+=~~(this.s0<0),this.s1-=this.hash(i),this.s1+=~~(this.s1<0),this.s2-=this.hash(i),this.s2+=~~(this.s2<0)},hash:function(n){var i,r,t;for(t=4022871197,n=n.toString(),r=0;r<n.length;r++)i=.025196032824169379*(t+=n.charCodeAt(r)),i-=t=i>>>0,t=(i*=t)>>>0,t+=4294967296*(i-=t);return 23283064365386963e-26*(t>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+11102230246251565e-32*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(n,t){return Math.floor(this.realInRange(0,t-n+1)+n)},between:function(n,t){return this.integerInRange(n,t)},realInRange:function(n,t){return this.frac()*(t-n)+n},normal:function(){return 1-2*this.frac()},uuid:function(){for(var n="",t="",t=n="";n++<36;t+=~n%5|3*n&4?(15^n?8^this.frac()*(20^n?16:4):4).toString(16):"-");return t},pick:function(n){return n[this.integerInRange(0,n.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(n){return n[~~(Math.pow(this.frac(),2)*(n.length-1)+.5)]},timestamp:function(n,t){return this.realInRange(n||9466848e5,t||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(n){return"string"==typeof n&&n.match(/^!rnd/)&&(n=n.split(","),this.c=parseFloat(n[1]),this.s0=parseFloat(n[2]),this.s1=parseFloat(n[3]),this.s2=parseFloat(n[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},n.RandomDataGenerator.prototype.constructor=n.RandomDataGenerator,n.QuadTree=function(n,t,i,r,u,f,e){this.maxObjects=10;this.maxLevels=4;this.level=0;this.bounds={};this.objects=[];this.nodes=[];this._empty=[];this.reset(n,t,i,r,u,f,e)},n.QuadTree.prototype={reset:function(n,t,i,r,u,f,e){this.maxObjects=u||10;this.maxLevels=f||4;this.level=e||0;this.bounds={x:Math.round(n),y:Math.round(t),width:i,height:r,subWidth:Math.floor(i/2),subHeight:Math.floor(r/2),right:Math.round(n)+Math.floor(i/2),bottom:Math.round(t)+Math.floor(r/2)};this.objects.length=0;this.nodes.length=0},populate:function(n){n.forEach(this.populateHandler,this,!0)},populateHandler:function(n){n.body&&n.exists&&this.insert(n.body)},split:function(){this.nodes[0]=new n.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[1]=new n.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[2]=new n.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[3]=new n.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(n){var t,i=0;if(null==this.nodes[0]||-1===(t=this.getIndex(n))){if(this.objects.push(n),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();i<this.objects.length;)-1!==(t=this.getIndex(this.objects[i]))?this.nodes[t].insert(this.objects.splice(i,1)[0]):i++}else this.nodes[t].insert(n)},getIndex:function(n){var t=-1;return n.x<this.bounds.right&&n.right<this.bounds.right?n.y<this.bounds.bottom&&n.bottom<this.bounds.bottom?t=1:n.y>this.bounds.bottom&&(t=2):n.x>this.bounds.right&&(n.y<this.bounds.bottom&&n.bottom<this.bounds.bottom?t=0:n.y>this.bounds.bottom&&(t=3)),t},retrieve:function(t){var i,r;if(t instanceof n.Rectangle)i=this.objects,r=this.getIndex(t);else{if(!t.body)return this._empty;i=this.objects;r=this.getIndex(t.body)}return this.nodes[0]&&(i=-1!==r?i.concat(this.nodes[r].retrieve(t)):(i=(i=(i=i.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))),i},clear:function(){this.objects.length=0;for(var n=this.nodes.length;n--;)this.nodes[n].clear(),this.nodes.splice(n,1);this.nodes.length=0}},n.QuadTree.prototype.constructor=n.QuadTree,n.Net=function(n){this.game=n},n.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(n){return-1!==window.location.hostname.indexOf(n)},updateQueryString:function(n,t,i,r){var u,f,o,e;if(void 0===i&&(i=!1),void 0!==r&&""!==r||(r=window.location.href),u="",f=new RegExp("([?|&])"+n+"=.*?(&|#|$)(.*)","gi"),f.test(r)?u=void 0!==t&&null!==t?r.replace(f,"$1"+n+"="+t+"$2$3"):r.replace(f,"$1$3").replace(/(&|\?)$/,""):void 0!==t&&null!==t?(o=-1!==r.indexOf("?")?"&":"?",e=r.split("#"),r=e[0]+o+n+"="+t,e[1]&&(r+="#"+e[1]),u=r):u=r,!i)return u;window.location.href=u},getQueryString:function(n){var i,r,u,t;void 0===n&&(n="");i={};r=location.search.substring(1).split("&");for(u in r)if(t=r[u].split("="),t.length>1){if(n&&n===this.decodeURI(t[0]))return this.decodeURI(t[1]);i[this.decodeURI(t[0])]=this.decodeURI(t[1])}return i},decodeURI:function(n){return decodeURIComponent(n.replace(/\+/g," "))}},n.Net.prototype.constructor=n.Net,n.TweenManager=function(t){this.game=t;this.frameBased=!1;this._tweens=[];this._add=[];this.easeMap={Power0:n.Easing.Power0,Power1:n.Easing.Power1,Power2:n.Easing.Power2,Power3:n.Easing.Power3,Power4:n.Easing.Power4,Linear:n.Easing.Linear.None,Quad:n.Easing.Quadratic.Out,Cubic:n.Easing.Cubic.Out,Quart:n.Easing.Quartic.Out,Quint:n.Easing.Quintic.Out,Sine:n.Easing.Sinusoidal.Out,Expo:n.Easing.Exponential.Out,Circ:n.Easing.Circular.Out,Elastic:n.Easing.Elastic.Out,Back:n.Easing.Back.Out,Bounce:n.Easing.Bounce.Out,"Quad.easeIn":n.Easing.Quadratic.In,"Cubic.easeIn":n.Easing.Cubic.In,"Quart.easeIn":n.Easing.Quartic.In,"Quint.easeIn":n.Easing.Quintic.In,"Sine.easeIn":n.Easing.Sinusoidal.In,"Expo.easeIn":n.Easing.Exponential.In,"Circ.easeIn":n.Easing.Circular.In,"Elastic.easeIn":n.Easing.Elastic.In,"Back.easeIn":n.Easing.Back.In,"Bounce.easeIn":n.Easing.Bounce.In,"Quad.easeOut":n.Easing.Quadratic.Out,"Cubic.easeOut":n.Easing.Cubic.Out,"Quart.easeOut":n.Easing.Quartic.Out,"Quint.easeOut":n.Easing.Quintic.Out,"Sine.easeOut":n.Easing.Sinusoidal.Out,"Expo.easeOut":n.Easing.Exponential.Out,"Circ.easeOut":n.Easing.Circular.Out,"Elastic.easeOut":n.Easing.Elastic.Out,"Back.easeOut":n.Easing.Back.Out,"Bounce.easeOut":n.Easing.Bounce.Out,"Quad.easeInOut":n.Easing.Quadratic.InOut,"Cubic.easeInOut":n.Easing.Cubic.InOut,"Quart.easeInOut":n.Easing.Quartic.InOut,"Quint.easeInOut":n.Easing.Quintic.InOut,"Sine.easeInOut":n.Easing.Sinusoidal.InOut,"Expo.easeInOut":n.Easing.Exponential.InOut,"Circ.easeInOut":n.Easing.Circular.InOut,"Elastic.easeInOut":n.Easing.Elastic.InOut,"Back.easeInOut":n.Easing.Back.InOut,"Bounce.easeInOut":n.Easing.Bounce.InOut};this.game.onPause.add(this._pauseAll,this);this.game.onResume.add(this._resumeAll,this)},n.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var n=0;n<this._tweens.length;n++)this._tweens[n].pendingDelete=!0;this._add=[]},removeFrom:function(t,i){if(void 0===i&&(i=!0),Array.isArray(t))for(r=0,u=t.length;r<u;r++)this.removeFrom(t[r]);else if(t.type===n.GROUP&&i)for(var r=0,u=t.children.length;r<u;r++)this.removeFrom(t.children[r]);else{for(r=0,u=this._tweens.length;r<u;r++)t===this._tweens[r].target&&this.remove(this._tweens[r]);for(r=0,u=this._add.length;r<u;r++)t===this._add[r].target&&this.remove(this._add[r])}},add:function(n){n._manager=this;this._add.push(n)},create:function(t){return new n.Tween(t,this.game,this)},remove:function(n){var t=this._tweens.indexOf(n);-1!==t?this._tweens[t].pendingDelete=!0:-1!==(t=this._add.indexOf(n))&&(this._add[t].pendingDelete=!0)},update:function(){var i=this._add.length,t=this._tweens.length,n;if(0===t&&0===i)return!1;for(n=0;n<t;)this._tweens[n].update(this.game.time.time)?n++:(this._tweens.splice(n,1),t--);return i>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(n,t){return t||(t=!1),this._tweens.some(function(i){return i.target===n&&(!t||i.isRunning&&!i.pendingDelete)})},_pauseAll:function(){for(var n=this._tweens.length-1;n>=0;n--)this._tweens[n]._pause()},_resumeAll:function(){for(var n=this._tweens.length-1;n>=0;n--)this._tweens[n]._resume()},pauseAll:function(){for(var n=this._tweens.length-1;n>=0;n--)this._tweens[n].pause()},resumeAll:function(){for(var n=this._tweens.length-1;n>=0;n--)this._tweens[n].resume(!0)},destroy:function(){this.game.onPause.remove(this._pauseAll,this);this.game.onResume.remove(this._resumeAll,this);this.game=null;this._add=null;this._tweens=null}},n.TweenManager.prototype.constructor=n.TweenManager,n.Tween=function(t,i,r){this.game=i;this.target=t;this.manager=r;this.timeline=[];this.reverse=!1;this.timeScale=1;this.repeatCounter=0;this.pendingDelete=!1;this.onStart=new n.Signal;this.onLoop=new n.Signal;this.onRepeat=new n.Signal;this.onChildComplete=new n.Signal;this.onComplete=new n.Signal;this.isRunning=!1;this.current=0;this.properties={};this.chainedTween=null;this.isPaused=!1;this.frameBased=r.frameBased;this._onUpdateCallback=null;this._onUpdateCallbackContext=null;this._pausedTime=0;this._codePaused=!1;this._hasStarted=!1},n.Tween.updateColor=function(t){n.Color.updateColor(t.target)},n.Tween.prototype={to:function(t,i,r,u,f,e,o){return(void 0===i||i<=0)&&(i=1e3),void 0!==r&&null!==r||(r=n.Easing.Default),void 0===u&&(u=!1),void 0===f&&(f=0),void 0===e&&(e=0),void 0===o&&(o=!1),"string"==typeof r&&this.manager.easeMap[r]&&(r=this.manager.easeMap[r]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new n.TweenData(this).to(t,i,r,f,e,o)),u&&this.start(),this)},from:function(t,i,r,u,f,e,o){return void 0===i&&(i=1e3),void 0!==r&&null!==r||(r=n.Easing.Default),void 0===u&&(u=!1),void 0===f&&(f=0),void 0===e&&(e=0),void 0===o&&(o=!1),"string"==typeof r&&this.manager.easeMap[r]&&(r=this.manager.easeMap[r]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new n.TweenData(this).from(t,i,r,f,e,o)),u&&this.start(),this)},start:function(n){var i,t;if(void 0===n&&(n=0),this.pendingDelete)return console.warn("Phaser.Tween.start cannot be called after Tween.stop"),this;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(t=0;t<this.timeline.length;t++)for(i in this.timeline[t].vEnd)this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1);for(t=0;t<this.timeline.length;t++)this.timeline[t].loadValues();return this.manager.add(this),this.isRunning=!0,(n<0||n>this.timeline.length-1)&&(n=0),this.current=n,this.timeline[this.current].start(),this},stop:function(n){return void 0===n&&(n=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,n&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(n,t,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var r=0;r<this.timeline.length;r++)this.timeline[r][n]=t;else this.timeline[i][n]=t;return this},delay:function(n,t){return this.updateTweenData("delay",n,t)},repeat:function(n,t,i){return void 0===t&&(t=0),this.updateTweenData("repeatCounter",n,i),this.updateTweenData("repeatTotal",n,i),this.updateTweenData("repeatDelay",t,i)},repeatDelay:function(n,t){return this.updateTweenData("repeatDelay",n,t)},yoyo:function(n,t,i){return void 0===t&&(t=0),this.updateTweenData("yoyo",n,i),this.updateTweenData("yoyoDelay",t,i)},yoyoDelay:function(n,t){return this.updateTweenData("yoyoDelay",n,t)},easing:function(n,t){return"string"==typeof n&&this.manager.easeMap[n]&&(n=this.manager.easeMap[n]),this.updateTweenData("easingFunction",n,t)},interpolation:function(t,i,r){return void 0===i&&(i=n.Math),this.updateTweenData("interpolationFunction",t,r),this.updateTweenData("interpolationContext",i,r)},repeatAll:function(n){return void 0===n&&(n=0),this.repeatCounter=n,this},chain:function(){for(var n=arguments.length;n--;)n>0?arguments[n-1].chainedTween=arguments[n]:this.chainedTween=arguments[n];return this},loop:function(n){return void 0===n&&(n=!0),this.repeatCounter=n?-1:0,this},onUpdateCallback:function(n,t){return this._onUpdateCallback=n,this._onUpdateCallbackContext=t,this},pause:function(){this.isPaused=!0;this._codePaused=!0;this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1;this._codePaused=!1;for(var n=0;n<this.timeline.length;n++)this.timeline[n].isRunning||(this.timeline[n].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(t){var i,r;return this.pendingDelete||!this.target?!1:this.isPaused?!0:(i=this.timeline[this.current].update(t),i===n.TweenData.PENDING)?!0:i===n.TweenData.RUNNING?(this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning):i===n.TweenData.LOOPED?(-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0):i===n.TweenData.COMPLETE?(r=!1,this.reverse?--this.current<0&&(this.current=this.timeline.length-1,r=!0):++this.current===this.timeline.length&&(this.current=0,r=!0),r?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)):void 0},generateData:function(n,t){var r,i;if(null===this.game||null===this.target)return null;for(void 0===n&&(n=60),void 0===t&&(t=[]),i=0;i<this.timeline.length;i++)for(r in this.timeline[i].vEnd)this.properties[r]=this.target[r]||0,Array.isArray(this.properties[r])||(this.properties[r]*=1);for(i=0;i<this.timeline.length;i++)this.timeline[i].loadValues();for(i=0;i<this.timeline.length;i++)t=t.concat(this.timeline[i].generateData(n));return t}},Object.defineProperty(n.Tween.prototype,"totalDuration",{get:function(){for(var t=0,n=0;n<this.timeline.length;n++)t+=this.timeline[n].duration;return t}}),n.Tween.prototype.constructor=n.Tween,n.TweenData=function(t){this.parent=t;this.game=t.game;this.vStart={};this.vStartCache={};this.vEnd={};this.vEndCache={};this.duration=1e3;this.percent=0;this.value=0;this.repeatCounter=0;this.repeatDelay=0;this.repeatTotal=0;this.interpolate=!1;this.yoyo=!1;this.yoyoDelay=0;this.inReverse=!1;this.delay=0;this.dt=0;this.startTime=null;this.easingFunction=n.Easing.Default;this.interpolationFunction=n.Math.linearInterpolation;this.interpolationContext=n.Math;this.isRunning=!1;this.isFrom=!1},n.TweenData.PENDING=0,n.TweenData.RUNNING=1,n.TweenData.LOOPED=2,n.TweenData.COMPLETE=3,n.TweenData.prototype={to:function(n,t,i,r,u,f){return this.vEnd=n,this.duration=t,this.easingFunction=i,this.delay=r,this.repeatTotal=u,this.yoyo=f,this.isFrom=!1,this},from:function(n,t,i,r,u,f){return this.vEnd=n,this.duration=t,this.easingFunction=i,this.delay=r,this.repeatTotal=u,this.yoyo=f,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.dt=this.parent.reverse?this.duration:0,this.isRunning=this.delay>0?!1:!0,this.isFrom)for(var n in this.vStartCache)this.vStart[n]=this.vEndCache[n],this.vEnd[n]=this.vStartCache[n],this.parent.target[n]=this.vStart[n];return this.value=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var n in this.parent.properties){if(this.vStart[n]=this.parent.properties[n],Array.isArray(this.vEnd[n])){if(0===this.vEnd[n].length)continue;0===this.percent&&(this.vEnd[n]=[this.vStart[n]].concat(this.vEnd[n]))}void 0!==this.vEnd[n]?("string"==typeof this.vEnd[n]&&(this.vEnd[n]=this.vStart[n]+parseFloat(this.vEnd[n])),this.parent.properties[n]=this.vEnd[n]):this.vEnd[n]=this.vStart[n];this.vStartCache[n]=this.vStart[n];this.vEndCache[n]=this.vEnd[n]}return this},update:function(t){var u,i,f,r;if(this.isRunning){if(t<this.startTime)return n.TweenData.RUNNING}else{if(!(t>=this.startTime))return n.TweenData.PENDING;this.isRunning=!0}u=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=u*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=u*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration));this.percent=this.dt/this.duration;this.value=this.easingFunction(this.percent);for(i in this.vEnd)f=this.vStart[i],r=this.vEnd[i],this.parent.target[i]=Array.isArray(r)?this.interpolationFunction.call(this.interpolationContext,r,this.value):f+(r-f)*this.value;return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():n.TweenData.RUNNING},generateData:function(n){var u,i,f,r,e;this.dt=this.parent.reverse?this.duration:0;var t=[],o=!1,s=1e3/n;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration));this.percent=this.dt/this.duration;this.value=this.easingFunction(this.percent);u={};for(i in this.vEnd)f=this.vStart[i],r=this.vEnd[i],u[i]=Array.isArray(r)?this.interpolationFunction.call(this.interpolationContext,r,this.value):f+(r-f)*this.value;t.push(u);(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(o=!0)}while(!o);return this.yoyo&&(e=t.slice(),e.reverse(),t=t.concat(e)),t},repeat:function(){var t;if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,n.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return n.TweenData.COMPLETE;if(this.inReverse)for(t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];this.repeatCounter>0&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.dt=this.parent.reverse?this.duration:0,n.TweenData.LOOPED}},n.TweenData.prototype.constructor=n.TweenData,n.Easing={Linear:{None:function(n){return n}},Quadratic:{In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}},Cubic:{In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}},Quartic:{In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}},Quintic:{In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}},Sinusoidal:{In:function(n){return 0===n?0:1===n?1:1-Math.cos(n*Math.PI/2)},Out:function(n){return 0===n?0:1===n?1:Math.sin(n*Math.PI/2)},InOut:function(n){return 0===n?0:1===n?1:.5*(1-Math.cos(Math.PI*n))}},Exponential:{In:function(n){return 0===n?0:Math.pow(1024,n-1)},Out:function(n){return 1===n?1:1-Math.pow(2,-10*n)},InOut:function(n){return 0===n?0:1===n?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(2-Math.pow(2,-10*(n-1)))}},Circular:{In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}},Elastic:{In:function(n){return 0===n?0:1===n?1:-1*Math.pow(2,10*(n-=1))*Math.sin((n-.1)*2*Math.PI/.4)},Out:function(n){return 0===n?0:1===n?1:1*Math.pow(2,-10*n)*Math.sin((n-.1)*2*Math.PI/.4)+1},InOut:function(n){return 0===n?0:1===n?1:(n*=2)<1?1*Math.pow(2,10*(n-=1))*Math.sin((n-.1)*2*Math.PI/.4)*-.5:1*Math.pow(2,-10*(n-=1))*Math.sin((n-.1)*2*Math.PI/.4)*.5+1}},Back:{In:function(n){var t=1.70158;return n*n*((t+1)*n-t)},Out:function(n){var t=1.70158;return--n*n*((t+1)*n+t)+1},InOut:function(n){var t=2.5949095;return(n*=2)<1?n*n*((t+1)*n-t)*.5:.5*((n-=2)*n*((t+1)*n+t)+2)}},Bounce:{In:function(t){return 1-n.Easing.Bounce.Out(1-t)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(t){return t<.5?.5*n.Easing.Bounce.In(2*t):.5*n.Easing.Bounce.Out(2*t-1)+.5}}},n.Easing.Default=n.Easing.Linear.None,n.Easing.Power0=n.Easing.Linear.None,n.Easing.Power1=n.Easing.Quadratic.Out,n.Easing.Power2=n.Easing.Cubic.Out,n.Easing.Power3=n.Easing.Quartic.Out,n.Easing.Power4=n.Easing.Quintic.Out,n.Time=function(t){this.game=t;this.time=0;this.prevTime=0;this.now=0;this.elapsed=0;this.elapsedMS=0;this.physicsElapsed=1/60;this.physicsElapsedMS=1/60*1e3;this.desiredFpsMult=1/60;this._desiredFps=60;this.suggestedFps=this.desiredFps;this.slowMotion=1;this.advancedTiming=!1;this.frames=0;this.updates=0;this.renders=0;this.fps=0;this.ups=0;this.rps=0;this.fpsMin=1e3;this.fpsMax=0;this.msMin=1e3;this.msMax=0;this.pauseDuration=0;this.timeToCall=0;this.timeExpected=0;this.events=new n.Timer(this.game,!1);this._frameCount=0;this._elapsedAccumulator=0;this._started=0;this._timeLastSecond=0;this._pauseStarted=0;this._justResumed=!1;this._timers=[]},n.Time.prototype={boot:function(){this._started=Date.now();this.time=Date.now();this.events.start();this.timeExpected=this.time},add:function(n){return this._timers.push(n),n},create:function(t){void 0===t&&(t=!0);var i=new n.Timer(this.game,t);return this._timers.push(i),i},removeAll:function(){for(var n=0;n<this._timers.length;n++)this._timers[n].destroy();this._timers=[];this.events.removeAll()},refresh:function(){var n=this.time;this.time=Date.now();this.elapsedMS=this.time-n},update:function(n){var t=this.time;this.time=Date.now();this.elapsedMS=this.time-t;this.prevTime=this.now;this.now=n;this.elapsed=this.now-this.prevTime;this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-n))),this.timeExpected=n+this.timeToCall);this.advancedTiming&&this.updateAdvancedTiming();this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var n=0,t=this._timers.length;n<t;)this._timers[n].update(this.time)?n++:(this._timers.splice(n,1),t--)},updateAdvancedTiming:function(){if(this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3){var n=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/n);this.ups=Math.round(1e3*this.updates/n);this.rps=Math.round(1e3*this.renders/n);this.fpsMin=Math.min(this.fpsMin,this.fps);this.fpsMax=Math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0;this.updates=0;this.renders=0}},countUpdate:function(){this.advancedTiming&&this.updates++},countRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now();this.events.pause();for(var n=this._timers.length;n--;)this._timers[n]._pause()},gameResumed:function(){this.time=Date.now();this.pauseDuration=this.time-this._pauseStarted;this.events.resume();for(var n=this._timers.length;n--;)this._timers[n]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(n){return this.time-n},elapsedSecondsSince:function(n){return.001*(this.time-n)},reset:function(){this._started=this.time;this.removeAll()}},Object.defineProperty(n.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(n){this._desiredFps=n;this.physicsElapsed=1/n;this.physicsElapsedMS=1e3*this.physicsElapsed;this.desiredFpsMult=1/n}}),n.Time.prototype.constructor=n.Time,n.Timer=function(t,i){void 0===i&&(i=!0);this.game=t;this.running=!1;this.autoDestroy=i;this.expired=!1;this.elapsed=0;this.events=[];this.onComplete=new n.Signal;this.nextTick=0;this.timeCap=1e3;this.paused=!1;this._codePaused=!1;this._started=0;this._pauseStarted=0;this._pauseTotal=0;this._now=Date.now();this._len=0;this._marked=0;this._i=0;this._diff=0;this._newTick=0},n.Timer.MINUTE=6e4,n.Timer.SECOND=1e3,n.Timer.HALF=500,n.Timer.QUARTER=250,n.Timer.prototype={create:function(t,i,r,u,f,e){var s=t=Math.round(t),o;return s+=0===this._now?this.game.time.time:this._now,o=new n.TimerEvent(this,t,s,r,i,u,f,e),this.events.push(o),this.order(),this.expired=!1,o},add:function(n,t,i){return this.create(n,!1,0,t,i,Array.prototype.slice.call(arguments,3))},repeat:function(n,t,i,r){return this.create(n,!1,t,i,r,Array.prototype.slice.call(arguments,4))},loop:function(n,t,i){return this.create(n,!0,0,t,i,Array.prototype.slice.call(arguments,3))},start:function(n){if(!this.running){this._started=this.game.time.time+(n||0);this.running=!0;for(var t=0;t<this.events.length;t++)this.events[t].tick=this.events[t].delay+this._started}},stop:function(n){this.running=!1;void 0===n&&(n=!0);n&&(this.events.length=0)},remove:function(n){for(var t=0;t<this.events.length;t++)if(this.events[t]===n)return this.events[t].pendingDelete=!0,!0;return!1},order:function(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(n,t){return n.tick<t.tick?-1:n.tick>t.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length;this._i=0},update:function(n){if(this.paused)return!0;if(this.elapsed=n-this._now,this._now=n,this.elapsed>this.timeCap&&this.adjustEvents(n-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running;){var t=this.events[this._i];if(!(this._now>=t.tick)||t.pendingDelete)break;this._newTick=this._now+t.delay-(this._now-t.tick);this._newTick<0&&(this._newTick=this._now+t.delay);!0===t.loop?(t.tick=this._newTick,t.callback.apply(t.callbackContext,t.args)):t.repeatCount>0?(t.repeatCount--,t.tick=this._newTick,t.callback.apply(t.callbackContext,t.args)):(this._marked++,t.pendingDelete=!0,t.callback.apply(t.callbackContext,t.args));this._i++}this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(n){for(var i,r,t=0;t<this.events.length;t++)this.events[t].pendingDelete||(i=this.events[t].tick-n,i<0&&(i=0),this.events[t].tick=this._now+i);r=this.nextTick-n;this.nextTick=r<0?this._now:this._now+r},resume:function(){if(this.paused){var n=this.game.time.time;this._pauseTotal+=n-this._now;this._now=n;this.adjustEvents(this._pauseStarted);this.paused=!1;this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll();this.events.length=0;this._len=0;this._i=0},destroy:function(){this.onComplete.removeAll();this.running=!1;this.expired=!0;this.events=[];this._len=0;this._i=0}},Object.defineProperty(n.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(n.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(n.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(n.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(n.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),n.Timer.prototype.constructor=n.Timer,n.TimerEvent=function(n,t,i,r,u,f,e,o){this.timer=n;this.delay=t;this.tick=i;this.repeatCount=r-1;this.loop=u;this.callback=f;this.callbackContext=e;this.args=o;this.pendingDelete=!1},n.TimerEvent.prototype.constructor=n.TimerEvent,n.AnimationManager=function(n){this.sprite=n;this.game=n.game;this.currentFrame=null;this.currentAnim=null;this.updateIfVisible=!0;this.isLoaded=!1;this._frameData=null;this._anims={};this._outputFrames=[]},n.AnimationManager.prototype={loadFrameData:function(n,t){if(void 0===n)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(n);return this._frameData=n,void 0===t||null===t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0,!0},copyFrameData:function(n,t){if(this._frameData=n.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return void 0===t||null===t?this.frame=0:"string"==typeof t?this.frameName=t:this.frame=t,this.isLoaded=!0,!0},add:function(t,i,r,u,f){return i=i||[],r=r||60,void 0===u&&(u=!1),void 0===f&&(f=!(!i||"number"!=typeof i[0])),this._outputFrames=[],this._frameData.getFrameIndexes(i,f,this._outputFrames),this._anims[t]=new n.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,r,u),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(n,t){void 0===t&&(t=!0);for(var i=0;i<n.length;i++)if(!0===t){if(n[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(n[i]))return!1;return!0},play:function(n,t,i,r){if(this._anims[n])return this.currentAnim===this._anims[n]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(t,i,r)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[n],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(t,i,r))},stop:function(n,t){void 0===t&&(t=!1);this.currentAnim&&("string"!=typeof n||n===this.currentAnim.name)&&this.currentAnim.stop(t)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0)},next:function(n){this.currentAnim&&(this.currentAnim.next(n),this.currentFrame=this.currentAnim.currentFrame)},previous:function(n){this.currentAnim&&(this.currentAnim.previous(n),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(n){return"string"==typeof n&&this._anims[n]?this._anims[n]:null},refreshFrame:function(){},destroy:function(){n=null;for(var n in this._anims)this._anims.hasOwnProperty(n)&&this._anims[n].destroy();this._anims={};this._outputFrames=[];this._frameData=null;this.currentAnim=null;this.currentFrame=null;this.sprite=null;this.game=null}},n.AnimationManager.prototype.constructor=n.AnimationManager,Object.defineProperty(n.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(n.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(n.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(n){this.currentAnim.paused=n}}),Object.defineProperty(n.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}}),Object.defineProperty(n.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},set:function(n){var t;"number"==typeof n&&this._frameData&&(t=this._frameData.getFrame(n))&&(this.currentFrame=t,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(n.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},set:function(n){var t;"string"==typeof n&&this._frameData&&(t=this._frameData.getFrameByName(n))?(this.currentFrame=t,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+n)}}),n.Animation=function(t,i,r,u,f,e,o){void 0===o&&(o=!1);this.game=t;this._parent=i;this._frameData=u;this.name=r;this._frames=[];this._frames=this._frames.concat(f);this.delay=1e3/e;this.loop=o;this.loopCount=0;this.killOnComplete=!1;this.isFinished=!1;this.isPlaying=!1;this.isPaused=!1;this._pauseStartTime=0;this._frameIndex=0;this._frameDiff=0;this._frameSkip=1;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this.onStart=new n.Signal;this.onUpdate=null;this.onComplete=new n.Signal;this.onLoop=new n.Signal;this.isReversed=!1;this.game.onPause.add(this.onPause,this);this.game.onResume.add(this.onResume,this)},n.Animation.prototype={play:function(n,t,i){return"number"==typeof n&&(this.delay=1e3/n),"boolean"==typeof t&&(this.loop=t),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0;this.isFinished=!1;this.paused=!1;this.loopCount=0;this._timeLastFrame=this.game.time.time;this._timeNextFrame=this.game.time.time+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setFrame(this.currentFrame);this._parent.animations.currentAnim=this;this._parent.animations.currentFrame=this.currentFrame;this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(n,t){var r,i,u;if(void 0===t&&(t=!1),"string"==typeof n)for(i=0;i<this._frames.length;i++)this._frameData.getFrame(this._frames[i]).name===n&&(r=i);else if("number"==typeof n)if(t)r=n;else for(i=0;i<this._frames.length;i++)this._frames[i]===n&&(r=i);r&&(u=this.isReversed?-1:1,this._frameIndex=r-u,this._timeNextFrame=this.game.time.time,this.update())},stop:function(n,t){void 0===n&&(n=!1);void 0===t&&(t=!1);this.isPlaying=!1;this.isFinished=!0;this.paused=!1;n&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame));t&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){if(this.isPaused)return!1;var n=this.game.time.time,t=n-this._timeNextFrame;return!!(this.isPlaying&&t>=0)&&(this._frameSkip=1,this._frameDiff=t,this._timeLastFrame=n,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=n+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(n,t){if(void 0===t&&(t=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(t||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!n||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(n){void 0===n&&(n=1);var t=this._frameIndex+n;t>=this._frames.length&&(this.loop?t%=this._frames.length:t=this._frames.length-1);t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},previous:function(n){void 0===n&&(n=1);var t=this._frameIndex-n;t<0&&(this.loop?t=this._frames.length+t:t++);t!==this._frameIndex&&(this._frameIndex=t,this.updateCurrentFrame(!0))},updateFrameData:function(n){this._frameData=n;this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this.updateCurrentFrame(!1);this.isPlaying=!1;this.isFinished=!0;this.paused=!1;this._parent.events.onAnimationComplete$dispatch(this._parent,this);this.onComplete.dispatch(this._parent,this);this.killOnComplete&&this._parent.kill()}},n.Animation.prototype.constructor=n.Animation,Object.defineProperty(n.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(n){this.isPaused=n;n?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(n.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(n){this.isReversed=n}}),Object.defineProperty(n.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(n.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(n){this.currentFrame=this._frameData.getFrame(this._frames[n]);null!==this.currentFrame&&(this._frameIndex=n,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(n.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(n){n>0&&(this.delay=1e3/n)}}),Object.defineProperty(n.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new n.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),n.Animation.generateFrameNames=function(t,i,r,u,f){var s,o,e;if(void 0===u&&(u=""),s=[],o="",i<r)for(e=i;e<=r;e++)o=t+(o="number"==typeof f?n.Utils.pad(e.toString(),f,"0",1):e.toString())+u,s.push(o);else for(e=i;e>=r;e--)o=t+(o="number"==typeof f?n.Utils.pad(e.toString(),f,"0",1):e.toString())+u,s.push(o);return s},n.Frame=function(t,i,r,u,f,e){this.index=t;this.x=i;this.y=r;this.width=u;this.height=f;0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+this.name+'" has a width or height of zero');this.name=e;this.centerX=Math.floor(u/2);this.centerY=Math.floor(f/2);this.distance=n.Math.distance(0,0,u,f);this.rotated=!1;this.trimmed=!1;this.sourceSizeW=u;this.sourceSizeH=f;this.spriteSourceSizeX=0;this.spriteSourceSizeY=0;this.spriteSourceSizeW=0;this.spriteSourceSizeH=0;this.right=this.x+this.width;this.bottom=this.y+this.height},n.Frame.prototype={resize:function(t,i){this.width=t;this.height=i;this.centerX=Math.floor(t/2);this.centerY=Math.floor(i/2);this.distance=n.Math.distance(0,0,t,i);this.sourceSizeW=t;this.sourceSizeH=i;this.right=this.x+t;this.bottom=this.y+i},setTrim:function(n,t,i,r,u,f,e){this.trimmed=n;n&&(this.sourceSizeW=t,this.sourceSizeH=i,this.centerX=Math.floor(t/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=r,this.spriteSourceSizeY=u,this.spriteSourceSizeW=f,this.spriteSourceSizeH=e)},clone:function(){var i=new n.Frame(this.index,this.x,this.y,this.width,this.height,this.name),t;for(t in this)this.hasOwnProperty(t)&&(i[t]=this[t]);return i},getRect:function(t){return void 0===t?t=new n.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},n.Frame.prototype.constructor=n.Frame,n.FrameData=function(){this._frames=[];this._frameNames=[]},n.FrameData.prototype={addFrame:function(n){return n.index=this._frames.length,this._frames.push(n),""!==n.name&&(this._frameNames[n.name]=n.index),n},getFrame:function(n){return n>=this._frames.length&&(n=0),this._frames[n]},getFrameByName:function(n){return"number"==typeof this._frameNames[n]?this._frames[this._frameNames[n]]:null},checkFrameName:function(n){return null!=this._frameNames[n]},clone:function(){for(var r,t=new n.FrameData,i=0;i<this._frames.length;i++)t._frames.push(this._frames[i].clone());for(r in this._frameNames)this._frameNames.hasOwnProperty(r)&&(t._frameNames[r]=this._frameNames[r]);return t},getFrameRange:function(n,t,i){void 0===i&&(i=[]);for(var r=n;r<=t;r++)i.push(this._frames[r]);return i},getFrames:function(n,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=[]),void 0===n||0===n.length)for(r=0;r<this._frames.length;r++)i.push(this._frames[r]);else for(var r=0;r<n.length;r++)t?i.push(this.getFrame(n[r])):i.push(this.getFrameByName(n[r]));return i},getFrameIndexes:function(n,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=[]),void 0===n||0===n.length)for(r=0;r<this._frames.length;r++)i.push(this._frames[r].index);else for(var r=0;r<n.length;r++)t&&this._frames[n[r]]?i.push(this._frames[n[r]].index):this.getFrameByName(n[r])&&i.push(this.getFrameByName(n[r]).index);return i},destroy:function(){this._frames=null;this._frameNames=null}},n.FrameData.prototype.constructor=n.FrameData,Object.defineProperty(n.FrameData.prototype,"total",{get:function(){return this._frames.length}}),n.AnimationParser={spriteSheet:function(t,i,r,u,f,e,o,s){var a,c,l;if(void 0===f&&(f=-1),void 0===e&&(e=0),void 0===o&&(o=0),void 0===s&&(s=0),a=i,"string"==typeof i?a=t.cache.getImage(i):i=a.name,null===a)return null;if(r<=0||u<=0)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' frameWidth (%s) or frameHeight (%s) must be positive",i,r,u),null;if(c=a.width,l=a.height,0===c||0===l)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is zero",i,c,l),null;if(c<r||l<u)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is less than the given frameWidth (%s) or frameHeight (%s)",i,c,l,r,u),null;var d=Math.floor((c-e)/(r+o)),g=Math.floor((l-e)/(u+o)),h=d*g,w=h,y=h-1,p=0,v=y;if(s>h||s<-h)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",i,s,h),null;if(f>-1&&(v=(h=f)-1),d<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has width %d, but it should be at least %d (frameWidth=%s, margin=%s, spacing=%s)",i,c,r+e+o,r,e,o),g<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has height %d, but it should be at least %d (frameHeight=%s, margin=%s, spacing=%s)",i,l,u+e+o,u,e,o),0===w)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' zero frames were produced",i),null;if(s>0?v=(p=s)+(h=Math.min(h,w-s))-1:s<0&&(p=(v=y+s)-(h=Math.min(h,w+s))+1),p<0)return console.warn("First frame index %s is outside of range [0, %d]",p,y),null;if(v>y)return console.warn("Last frame index %s is outside of range [0, %d]",v,y),null;for(var nt=new n.FrameData,k=e,tt=e,it=0,b=0;b<w&&!(b>v);b++)b>=p&&nt.addFrame(new n.Frame(it++,k,tt,r,u,"")),(k+=r+o)+r>c&&(k=e,tt+=u+o);return nt},JSONData:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(i);for(var f,e=new n.FrameData,u=i.frames,r=0;r<u.length;r++)f=e.addFrame(new n.Frame(r,u[r].frame.x,u[r].frame.y,u[r].frame.w,u[r].frame.h,u[r].filename)),u[r].trimmed&&f.setTrim(u[r].trimmed,u[r].sourceSize.w,u[r].sourceSize.h,u[r].spriteSourceSize.x,u[r].spriteSourceSize.y,u[r].spriteSourceSize.w,u[r].spriteSourceSize.h),u[r].rotated&&(f.rotated=!0);return e},JSONDataPyxel:function(t,i){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(n){if(!i[n])return console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "'+n+'" key.'),void console.log(i)}),1!==i.layers.length)return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps."),void console.log(i);for(var f=new n.FrameData,e=i.tileheight,o=i.tilewidth,u=i.layers[0].tiles,r=0;r<u.length;r++)f.addFrame(new n.Frame(r,u[r].x,u[r].y,o,e,"frame_"+r)).setTrim(!1);return f},JSONDataHash:function(t,i){var r;if(!i.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(i);var f,e=new n.FrameData,u=i.frames,o=0;for(r in u)f=e.addFrame(new n.Frame(o,u[r].frame.x,u[r].frame.y,u[r].frame.w,u[r].frame.h,r)),u[r].trimmed&&f.setTrim(u[r].trimmed,u[r].sourceSize.w,u[r].sourceSize.h,u[r].spriteSourceSize.x,u[r].spriteSourceSize.y,u[r].spriteSourceSize.w,u[r].spriteSourceSize.h),u[r].rotated&&(f.rotated=!0),o++;return e},XMLData:function(t,i){if(i.getElementsByTagName("TextureAtlas")){for(var h,c,r,l,a,o,s,u,f,v,y,p=new n.FrameData,w=i.getElementsByTagName("SubTexture"),e=0;e<w.length;e++)c=(r=w[e].attributes).name.value,l=parseInt(r.x.value,10),a=parseInt(r.y.value,10),o=parseInt(r.width.value,10),s=parseInt(r.height.value,10),u=null,f=null,r.frameX&&(u=Math.abs(parseInt(r.frameX.value,10)),f=Math.abs(parseInt(r.frameY.value,10)),v=parseInt(r.frameWidth.value,10),y=parseInt(r.frameHeight.value,10)),h=p.addFrame(new n.Frame(e,l,a,o,s,c)),null===u&&null===f||h.setTrim(!0,o,s,u,f,v,y);return p}console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag")}},n.Cache=function(t){this.game=t;this.autoResolveURL=!1;this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{}};this._urlMap={};this._urlResolver=new Image;this._urlTemp=null;this.onSoundUnlock=new n.Signal;this._cacheMap=[];this._cacheMap[n.Cache.CANVAS]=this._cache.canvas;this._cacheMap[n.Cache.IMAGE]=this._cache.image;this._cacheMap[n.Cache.TEXTURE]=this._cache.texture;this._cacheMap[n.Cache.SOUND]=this._cache.sound;this._cacheMap[n.Cache.TEXT]=this._cache.text;this._cacheMap[n.Cache.PHYSICS]=this._cache.physics;this._cacheMap[n.Cache.TILEMAP]=this._cache.tilemap;this._cacheMap[n.Cache.BINARY]=this._cache.binary;this._cacheMap[n.Cache.BITMAPDATA]=this._cache.bitmapData;this._cacheMap[n.Cache.BITMAPFONT]=this._cache.bitmapFont;this._cacheMap[n.Cache.JSON]=this._cache.json;this._cacheMap[n.Cache.XML]=this._cache.xml;this._cacheMap[n.Cache.VIDEO]=this._cache.video;this._cacheMap[n.Cache.SHADER]=this._cache.shader;this._cacheMap[n.Cache.RENDER_TEXTURE]=this._cache.renderTexture;this._pendingCount=0;this.onReady=new n.Signal;this._addImages()},n.Cache.CANVAS=1,n.Cache.IMAGE=2,n.Cache.TEXTURE=3,n.Cache.SOUND=4,n.Cache.TEXT=5,n.Cache.PHYSICS=6,n.Cache.TILEMAP=7,n.Cache.BINARY=8,n.Cache.BITMAPDATA=9,n.Cache.BITMAPFONT=10,n.Cache.JSON=11,n.Cache.XML=12,n.Cache.VIDEO=13,n.Cache.SHADER=14,n.Cache.RENDER_TEXTURE=15,n.Cache.DEFAULT=null,n.Cache.DEFAULT_KEY="__default",n.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",n.Cache.MISSING=null,n.Cache.MISSING_KEY="__missing",n.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",n.Cache.READY_TIMEOUT=1e3,n.Cache.prototype={addCompressedTextureMetaData:function(t,i,r,u){this.checkImageKey(t)&&this.removeImage(t);var f=r in n.LoaderParser?n.LoaderParser[r](u):u,e={key:t,url:i,data:f,base:new PIXI.BaseTexture(f,null,this.game.resolution),frame:new n.Frame(0,0,0,f.width,f.height,t),frameData:new n.FrameData,fileFormat:r};return e.frameData.addFrame(new n.Frame(0,0,0,f.width,f.height,i)),this._cache.image[t]=e,this._resolveURL(i,e),e},addCanvas:function(n,t,i){void 0===i&&(i=t.getContext("2d"));this._cache.canvas[n]={canvas:t,context:i}},addImage:function(t,i,r){this.checkImageKey(t)&&this.removeImage(t);!1===r.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var u={key:t,url:i,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new n.Frame(0,0,0,r.width,r.height,t),frameData:new n.FrameData};return u.frameData.addFrame(new n.Frame(0,0,0,r.width,r.height,i)),this._cache.image[t]=u,this._resolveURL(i,u),"__default"===t?n.Cache.DEFAULT=new PIXI.Texture(u.base):"__missing"===t&&(n.Cache.MISSING=new PIXI.Texture(u.base)),u},addImageAsync:function(n,t,i){var u=this,r=new Image;r.onload=function(){i.call(this,u.addImage(n,null,r));u._removePending();r.onload=null};this._addPending();r.src=t},addDefaultImage:function(){this.addImageAsync(n.Cache.DEFAULT_KEY,n.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0;n.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(n.Cache.MISSING_KEY,n.Cache.MISSING_SRC,function(t){n.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(n,t,i,r,u){void 0===r&&(r=!0,u=!1);void 0===u&&(r=!1,u=!0);var f=!1;u&&(f=!0);this._cache.sound[n]={url:t,data:i,isDecoding:!1,decoded:f,webAudio:r,audioTag:u,locked:this.game.sound.touchLocked};this._resolveURL(t,this._cache.sound[n])},addText:function(n,t,i){this._cache.text[n]={url:t,data:i};this._resolveURL(t,this._cache.text[n])},addPhysicsData:function(n,t,i,r){this._cache.physics[n]={url:t,data:i,format:r};this._resolveURL(t,this._cache.physics[n])},addTilemap:function(n,t,i,r){this._cache.tilemap[n]={url:t,data:i,format:r};this._resolveURL(t,this._cache.tilemap[n])},addBinary:function(n,t){this._cache.binary[n]=t},addBitmapData:function(t,i,r){return i.key=t,void 0===r&&(r=new n.FrameData).addFrame(i.textureFrame),this._cache.bitmapData[t]={data:i,frameData:r},i},addBitmapFont:function(t,i,r,u,f,e,o){var s={url:i,data:r,font:null,base:new PIXI.BaseTexture(r,null,this.game.resolution)};void 0===e&&(e=0);void 0===o&&(o=0);s.font="json"===f?n.LoaderParser.jsonBitmapFont(u,s.base,e,o,!1,this.game.resolution):n.LoaderParser.xmlBitmapFont(u,s.base,e,o,!1,this.game.resolution);this._cache.bitmapFont[t]=s;this._resolveURL(i,s)},addBitmapFontFromAtlas:function(t,i,r,u,f,e,o){var h=this.getFrameByName(i,r),s,c;h&&(s={font:null,base:this.getBaseTexture(i),frame:h},void 0===e&&(e=0),void 0===o&&(o=0),"json"===f?(c=this.getJSON(u),s.font=n.LoaderParser.jsonBitmapFont(c,s.base,e,o,h,this.game.resolution)):(c=this.getXML(u),s.font=n.LoaderParser.xmlBitmapFont(c,s.base,e,o,h,this.game.resolution)),this._cache.bitmapFont[t]=s)},addJSON:function(n,t,i){this._cache.json[n]={url:t,data:i};this._resolveURL(t,this._cache.json[n])},addXML:function(n,t,i){this._cache.xml[n]={url:t,data:i};this._resolveURL(t,this._cache.xml[n])},addVideo:function(n,t,i,r){this._cache.video[n]={url:t,data:i,isBlob:r,locked:!0};this._resolveURL(t,this._cache.video[n])},addShader:function(n,t,i){this._cache.shader[n]={url:t,data:i};this._resolveURL(t,this._cache.shader[n])},addRenderTexture:function(t,i){this._cache.renderTexture[t]={texture:i,frame:new n.Frame(0,0,0,i.width,i.height,"","")}},addSpriteSheet:function(t,i,r,u,f,e,o,s,h){void 0===e&&(e=-1);void 0===o&&(o=0);void 0===s&&(s=0);var c={key:t,url:i,data:r,frameWidth:u,frameHeight:f,margin:o,spacing:s,base:new PIXI.BaseTexture(r,null,this.game.resolution),frameData:n.AnimationParser.spriteSheet(this.game,r,u,f,e,o,s,h)};this._cache.image[t]=c;this._resolveURL(i,c)},addTextureAtlas:function(t,i,r,u,f){var e={key:t,url:i,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution)};e.frameData=f===n.Loader.TEXTURE_ATLAS_XML_STARLING?n.AnimationParser.XMLData(this.game,u,t):f===n.Loader.TEXTURE_ATLAS_JSON_PYXEL?n.AnimationParser.JSONDataPyxel(this.game,u,t):Array.isArray(u.frames)?n.AnimationParser.JSONData(this.game,u,t):n.AnimationParser.JSONDataHash(this.game,u,t);this._cache.image[t]=e;this._resolveURL(i,e)},reloadSound:function(n){var i=this,t=this.getSound(n);t&&(t.data.src=t.url,t.data.addEventListener("canplaythrough",function(){return i.reloadSoundComplete(n)},!1),t.data.load())},reloadSoundComplete:function(n){var t=this.getSound(n);t&&(t.locked=!1,this.onSoundUnlock.dispatch(n))},updateSound:function(n,t,i){var r=this.getSound(n);r&&(r[t]=i)},decodedSound:function(n,t){var i=this.getSound(n);i.data=t;i.decoded=!0;i.isDecoding=!1},isSoundDecoded:function(t){var i=this.getItem(t,n.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded},isSoundReady:function(t){var i=this.getItem(t,n.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded&&!this.game.sound.touchLocked},checkKey:function(n,t){return!!this._cacheMap[n][t]},checkURL:function(n){return!!this._urlMap[this._resolveURL(n)]},checkCanvasKey:function(t){return this.checkKey(n.Cache.CANVAS,t)},checkImageKey:function(t){return this.checkKey(n.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(n.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(n.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(n.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(n.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(n.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(n.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(n.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(n.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(n.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(n.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(n.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(n.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(n.Cache.RENDER_TEXTURE,t)},getItem:function(n,t,i,r){return this.checkKey(t,n)?void 0===r?this._cacheMap[t][n]:this._cacheMap[t][n][r]:(i&&console.warn("Phaser.Cache."+i+': Key "'+n+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,n.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,i){void 0!==t&&null!==t||(t="__default");void 0===i&&(i=!1);var r=this.getItem(t,n.Cache.IMAGE,"getImage");return null===r&&(r=this.getItem("__missing",n.Cache.IMAGE,"getImage")),i?r:r.data},getTextureFrame:function(t){return this.getItem(t,n.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,n.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,n.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,n.Cache.TEXT,"getText","data")},getPhysicsData:function(t,i,r){var f=this.getItem(t,n.Cache.PHYSICS,"getPhysicsData","data"),u,e;if(null===f||void 0===i||null===i)return f;if(f[i]){if(u=f[i],!u||!r)return u;for(e in u)if((e=u[e]).fixtureKey===r)return e;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+r+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+i+'"');return null},getTilemapData:function(t){return this.getItem(t,n.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,n.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,n.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,n.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,i){var r=this.getItem(t,n.Cache.JSON,"getJSON","data");return r?i?n.Utils.extend(!0,Array.isArray(r)?[]:{},r):r:null},getXML:function(t){return this.getItem(t,n.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,n.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,n.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,n.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(t,i){return void 0===i&&(i=n.Cache.IMAGE),this.getItem(t,i,"getBaseTexture","base")},getFrame:function(t,i){return void 0===i&&(i=n.Cache.IMAGE),this.getItem(t,i,"getFrame","frame")},getFrameCount:function(n,t){var i=this.getFrameData(n,t);return i?i.total:0},getFrameData:function(t,i){return void 0===i&&(i=n.Cache.IMAGE),this.getItem(t,i,"getFrameData","frameData")},hasFrameData:function(t,i){return void 0===i&&(i=n.Cache.IMAGE),null!==this.getItem(t,i,"","frameData")},updateFrameData:function(t,i,r){void 0===r&&(r=n.Cache.IMAGE);this._cacheMap[r][t]&&(this._cacheMap[r][t].frameData=i)},getFrameByIndex:function(n,t,i){var r=this.getFrameData(n,i);return r?r.getFrame(t):null},getFrameByName:function(n,t,i){var r=this.getFrameData(n,i);return r?r.getFrameByName(t):null},getURL:function(n){return(n=this._resolveURL(n))?this._urlMap[n]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+n+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){var r,i;if(void 0===t&&(t=n.Cache.IMAGE),r=[],this._cacheMap[t])for(i in this._cacheMap[t])"__default"!==i&&"__missing"!==i&&r.push(i);return r},removeCanvas:function(n){delete this._cache.canvas[n]},removeImage:function(n,t){void 0===t&&(t=!0);var i=this.getImage(n,!0);t&&i.base&&i.base.destroy();delete this._cache.image[n]},removeSound:function(n){delete this._cache.sound[n]},removeText:function(n){delete this._cache.text[n]},removePhysics:function(n){delete this._cache.physics[n]},removeTilemap:function(n){delete this._cache.tilemap[n]},removeBinary:function(n){delete this._cache.binary[n]},removeBitmapData:function(n){delete this._cache.bitmapData[n]},removeBitmapFont:function(n){delete this._cache.bitmapFont[n]},removeJSON:function(n){delete this._cache.json[n]},removeXML:function(n){delete this._cache.xml[n]},removeVideo:function(n){delete this._cache.video[n]},removeShader:function(n){delete this._cache.shader[n]},removeRenderTexture:function(n){delete this._cache.renderTexture[n]},removeSpriteSheet:function(n){delete this._cache.spriteSheet[n]},removeTextureAtlas:function(n){delete this._cache.image[n]},clearGLTextures:function(){for(var n in this._cache.image)this._cache.image[n].base._glTextures=[]},_resolveURL:function(n,t){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+n,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",t&&(this._urlMap[this._urlTemp]=t),this._urlTemp):null},destroy:function(){for(var i,n,t=0;t<this._cacheMap.length;t++){i=this._cacheMap[t];for(n in i)"__default"!==n&&"__missing"!==n&&(this.destroyItem(i[n]),delete i[n])}this._urlMap=null;this._urlResolver=null;this._urlTemp=null},destroyItem:function(n){n.destroy?n.destroy():(n.base&&n.base.destroy&&n.base.destroy(),n.data&&n.data.destroy&&n.data.destroy(),n.frameData&&n.frameData.destroy&&n.frameData.destroy(),n.texture&&n.texture.destroy&&n.texture.destroy(!0))},_addImages:function(){this._pendingCount=0;this.addDefaultImage();this.addMissingImage();var t=this,i=n.Cache.READY_TIMEOUT;n.Cache.READY_TIMEOUT>0?setTimeout(function(){t.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",i),t._ready())},n.Cache.READY_TIMEOUT):this._ready()},_addPending:function(){this._pendingCount+=1},_removePending:function(){this._pendingCount-=1;this._checkReady()},_checkReady:function(){this.isReady&&this._ready()},_ready:function(){this._pendingCount=0;this.onReady.dispatch(this)}},n.Cache.prototype.constructor=n.Cache,Object.defineProperty(n.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),n.Loader=function(t){this.game=t;this.cache=t.cache;this.resetLocked=!1;this.isLoading=!1;this.hasLoaded=!1;this.preloadSprite=null;this.crossOrigin=!1;this.baseURL="";this.path="";this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"};this.onLoadStart=new n.Signal;this.onBeforeLoadComplete=new n.Signal;this.onLoadComplete=new n.Signal;this.onPackComplete=new n.Signal;this.onFileStart=new n.Signal;this.onFileComplete=new n.Signal;this.onFileError=new n.Signal;this.enableParallel=!0;this.maxParallelDownloads=4;this._withSyncPointDepth=0;this._fileList=[];this._flightQueue=[];this._processingHead=0;this._fileLoadStarted=!1;this._totalPackCount=0;this._totalFileCount=0;this._loadedPackCount=0;this._loadedFileCount=0},n.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,n.Loader.TEXTURE_ATLAS_JSON_HASH=1,n.Loader.TEXTURE_ATLAS_XML_STARLING=2,n.Loader.PHYSICS_LIME_CORONA_JSON=3,n.Loader.PHYSICS_PHASER_JSON=4,n.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,n.Loader.prototype={setPreloadSprite:function(t,i){i=i||0;this.preloadSprite={sprite:t,direction:i,width:t.width,height:t.height,rect:null};this.preloadSprite.rect=0===i?new n.Rectangle(0,0,1,t.height):new n.Rectangle(0,0,t.width,1);t.crop(this.preloadSprite.rect);t.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(n,t){return this.getAssetIndex(n,t)>-1},getAssetIndex:function(n,t){for(var r,u=-1,i=0;i<this._fileList.length;i++)if(r=this._fileList[i],r.type===n&&r.key===t&&(u=i,!r.loaded&&!r.loading))break;return u},getAsset:function(n,t){var i=this.getAssetIndex(n,t);return i>-1&&{index:i,file:this._fileList[i]}},reset:function(n,t){void 0===t&&(t=!1);this.resetLocked||(n&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,t&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(n,t,i,r,u,f){var e,s,o,h;if(void 0===u&&(u=!1),void 0===t||""===t)return console.warn("Phaser.Loader: Invalid or no key given of type "+n),this;if(void 0===i||null===i){if(!f)return console.warn("Phaser.Loader: No URL given for file type: "+n+" key: "+t),this;i=t+f}if(e={type:n,key:t,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1},r)for(s in r)e[s]=r[s];return o=this.getAssetIndex(n,t),u&&o>-1?(h=this._fileList[o],h.loading||h.loaded?(this._fileList.push(e),this._totalFileCount++):this._fileList[o]=e):-1===o&&(this._fileList.push(e),this._totalFileCount++),this},replaceInFileList:function(n,t,i,r){return this.addToFileList(n,t,i,r,!0)},pack:function(n,t,i,r){var e,u,f;if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),!t&&!i)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;for(e={type:"packfile",key:n,url:t,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:r},i&&("string"==typeof i&&(i=JSON.parse(i)),e.data=i||{},e.loaded=!0),u=0;u<this._fileList.length+1;u++)if(f=this._fileList[u],!f||!f.loaded&&!f.loading&&"packfile"!==f.type){this._fileList.splice(u,0,e);this._totalPackCount++;break}return this},image:function(n,t,i){return"object"==typeof t?this.texture(n,t,i):this.addToFileList("image",n,t,void 0,i,".png")},imageFromBitmapData:function(n,t,i){return this.image(n,t.canvas.toDataURL("image/png"),i)},imageFromGrid:function(n,t,i,r,u,f){return this.imageFromBitmapData(n,this.game.create.grid(n,t,i,r,u,f,!1))},imageFromTexture:function(n,t,i,r,u){return this.imageFromBitmapData(n,this.game.create.texture(n,t,i,r,u,!1))},texture:function(t,i,r){if(this.game.renderType===n.WEBGL){var u,f=this.game.renderer.extensions.compression;for(u in i)if(u.toUpperCase()in f)return this.addToFileList("texture",t,i[u],void 0,r,".pvr")}return i.truecolor&&this.addToFileList("image",t,i.truecolor,void 0,r,".png"),this},images:function(n,t){if(Array.isArray(t))for(i=0;i<n.length;i++)this.image(n[i],t[i]);else for(var i=0;i<n.length;i++)this.image(n[i]);return this},text:function(n,t,i){return this.addToFileList("text",n,t,void 0,i,".txt")},json:function(n,t,i){return this.addToFileList("json",n,t,void 0,i,".json")},shader:function(n,t,i){return this.addToFileList("shader",n,t,void 0,i,".frag")},xml:function(n,t,i){return this.addToFileList("xml",n,t,void 0,i,".xml")},script:function(n,t,i,r){return void 0===i&&(i=!1),!1!==i&&void 0===r&&(r=this),this.addToFileList("script",n,t,{syncPoint:!0,callback:i,callbackContext:r},!1,".js")},binary:function(n,t,i,r){return void 0===i&&(i=!1),!1!==i&&void 0===r&&(r=i),this.addToFileList("binary",n,t,{callback:i,callbackContext:r},!1,".bin")},spritesheet:function(n,t,i,r,u,f,e,o){return void 0===u&&(u=-1),void 0===f&&(f=0),void 0===e&&(e=0),void 0===o&&(o=0),this.addToFileList("spritesheet",n,t,{frameWidth:i,frameHeight:r,frameMax:u,margin:f,spacing:e,skipFrames:o},!1,".png")},audio:function(n,t,i){return this.game.sound.noAudio?this:(void 0===i&&(i=!0),"string"==typeof t&&(t=[t]),this.addToFileList("audio",n,t,{buffer:null,autoDecode:i}))},audioSprite:function(n,t,i,r,u){return this.game.sound.noAudio?this:(void 0===i&&(i=null),void 0===r&&(r=null),void 0===u&&(u=!0),this.audio(n,t,u),i?this.json(n+"-audioatlas",i):r?("string"==typeof r&&(r=JSON.parse(r)),this.cache.addJSON(n+"-audioatlas","",r)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},audiosprite:function(n,t,i,r,u){return this.audioSprite(n,t,i,r,u)},video:function(n,t,i,r){return void 0===i&&(i=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===r&&(r=!1),"string"==typeof t&&(t=[t]),this.addToFileList("video",n,t,{buffer:null,asBlob:r,loadEvent:i})},tilemap:function(t,i,r,u){if(void 0===i&&(i=null),void 0===r&&(r=null),void 0===u&&(u=n.Tilemap.CSV),i||r||(i=u===n.Tilemap.CSV?t+".csv":t+".json"),r){switch(u){case n.Tilemap.TILED_JSON:"string"==typeof r&&(r=JSON.parse(r))}this.cache.addTilemap(t,null,r,u)}else this.addToFileList("tilemap",t,i,{format:u});return this},tilemapCSV:function(t,i,r){return this.tilemap(t,i,r,n.Tilemap.CSV)},tilemapTiledJSON:function(t,i,r){return this.tilemap(t,i,r,n.Tilemap.TILED_JSON)},physics:function(t,i,r,u){return void 0===i&&(i=null),void 0===r&&(r=null),void 0===u&&(u=n.Physics.LIME_CORONA_JSON),i||r||(i=t+".json"),r?("string"==typeof r&&(r=JSON.parse(r)),this.cache.addPhysicsData(t,null,r,u)):this.addToFileList("physics",t,i,{format:u}),this},bitmapFont:function(n,t,i,r,u,f){if(void 0!==t&&null!==t||(t=n+".png"),void 0===i&&(i=null),void 0===r&&(r=null),null===i&&null===r&&(i=n+".xml"),void 0===u&&(u=0),void 0===f&&(f=0),i)this.addToFileList("bitmapfont",n,t,{atlasURL:i,xSpacing:u,ySpacing:f});else if("string"==typeof r){var e,o;try{e=JSON.parse(r)}catch(n){o=this.parseXml(r)}if(!o&&!e)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",n,t,{atlasURL:null,atlasData:e||o,atlasType:e?"json":"xml",xSpacing:u,ySpacing:f})}return this},atlasJSONArray:function(t,i,r,u){return this.atlas(t,i,r,u,n.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(t,i,r,u){return this.atlas(t,i,r,u,n.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(t,i,r,u){return void 0===r&&(r=null),void 0===u&&(u=null),r||u||(r=t+".xml"),this.atlas(t,i,r,u,n.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(t,i,r,u,f){if(void 0!==i&&null!==i||(i=t+".png"),void 0===r&&(r=null),void 0===u&&(u=null),void 0===f&&(f=n.Loader.TEXTURE_ATLAS_JSON_ARRAY),r||u||(r=f===n.Loader.TEXTURE_ATLAS_XML_STARLING?t+".xml":t+".json"),r)this.addToFileList("textureatlas",t,i,{atlasURL:r,format:f});else{switch(f){case n.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof u&&(u=JSON.parse(u));break;case n.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof u){var e=this.parseXml(u);if(!e)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");u=e}}this.addToFileList("textureatlas",t,i,{atlasURL:null,atlasData:u,format:f})}return this},withSyncPoint:function(n,t){this._withSyncPointDepth++;try{n.call(t||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(n,t){var i=this.getAsset(n,t);return i&&(i.file.syncPoint=!0),this},removeFile:function(n,t){var i=this.getAsset(n,t);i&&(i.loaded||i.loading||this._fileList.splice(i.index,1))},removeAll:function(){this._fileList.length=0;this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){var n,u;if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(t=0;t<this._flightQueue.length;t++)((n=this._flightQueue[t]).loaded||n.error)&&(this._flightQueue.splice(t,1),t--,n.loading=!1,n.requestUrl=null,n.requestObject=null,n.error&&this.onFileError.dispatch(n.key,n),"packfile"!==n.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,n.key,!n.error,this._loadedFileCount,this._totalFileCount)):"packfile"===n.type&&n.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(n.key,!n.error,this._loadedPackCount,this._totalPackCount)));for(var i=!1,r=this.enableParallel?Math.max(1,this.maxParallelDownloads):1,t=this._processingHead;t<this._fileList.length;t++)if(n=this._fileList[t],"packfile"===n.type&&!n.error&&n.loaded&&t===this._processingHead&&(this.processPack(n),this._loadedPackCount++,this.onPackComplete.dispatch(n.key,!n.error,this._loadedPackCount,this._totalPackCount)),n.loaded||n.error?t===this._processingHead&&(this._processingHead=t+1):!n.loading&&this._flightQueue.length<r&&("packfile"!==n.type||n.data?i||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(n),n.loading=!0,this.onFileStart.dispatch(this.progress,n.key,n.url),this.loadFile(n)):(this._flightQueue.push(n),n.loading=!0,this.loadFile(n))),!n.loaded&&n.syncPoint&&(i=!0),this._flightQueue.length>=r||i&&this._loadedPackCount===this._totalPackCount)break;(this.updateProgress(),this._processingHead>=this._fileList.length)?this.finishedLoading():this._flightQueue.length||(console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled"),u=this,setTimeout(function(){u.finishedLoading(!0)},2e3))},finishedLoading:function(n){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,n||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state&&this.game.state.loadComplete())},asyncComplete:function(n,t){void 0===t&&(t="");n.loaded=!0;n.error=!!t;t&&(n.errorMessage=t,console.warn("Phaser.Loader - "+n.type+"["+n.key+"]: "+t));this.processLoadQueue()},processPack:function(t){var u=t.data[t.key],r,i;if(u)for(r=0;r<u.length;r++){i=u[r];switch(i.type){case"image":this.image(i.key,i.url,i.overwrite);break;case"text":this.text(i.key,i.url,i.overwrite);break;case"json":this.json(i.key,i.url,i.overwrite);break;case"xml":this.xml(i.key,i.url,i.overwrite);break;case"script":this.script(i.key,i.url,i.callback,t.callbackContext||this);break;case"binary":this.binary(i.key,i.url,i.callback,t.callbackContext||this);break;case"spritesheet":this.spritesheet(i.key,i.url,i.frameWidth,i.frameHeight,i.frameMax,i.margin,i.spacing,i.skipFrames);break;case"video":this.video(i.key,i.urls);break;case"audio":this.audio(i.key,i.urls,i.autoDecode);break;case"audiosprite":this.audiosprite(i.key,i.urls,i.jsonURL,i.jsonData,i.autoDecode);break;case"tilemap":this.tilemap(i.key,i.url,i.data,n.Tilemap[i.format]);break;case"physics":this.physics(i.key,i.url,i.data,n.Loader[i.format]);break;case"bitmapFont":this.bitmapFont(i.key,i.textureURL,i.atlasURL,i.atlasData,i.xSpacing,i.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(i.key,i.textureURL,i.atlasURL,i.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(i.key,i.textureURL,i.atlasURL,i.atlasData);break;case"atlasXML":this.atlasXML(i.key,i.textureURL,i.atlasURL,i.atlasData);break;case"atlas":this.atlas(i.key,i.textureURL,i.atlasURL,i.atlasData,n.Loader[i.format]);break;case"shader":this.shader(i.key,i.url,i.overwrite)}}else console.warn("Phaser.Loader - "+t.key+": pack has data, but not for pack key")},transformUrl:function(n,t){return!!n&&(n.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?n:this.baseURL+t.path+n)},loadFile:function(t){switch(t.type){case"packfile":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(t);break;case"audio":t.url=this.getAudioURL(t.url);t.url?this.game.sound.usingWebAudio?this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(t):this.fileError(t,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":t.url=this.getVideoURL(t.url);t.url?t.asBlob?this.xhrLoad(t,this.transformUrl(t.url,t),"blob",this.fileComplete):this.loadVideoTag(t):this.fileError(t,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.xmlLoadComplete);break;case"tilemap":t.format===n.Tilemap.TILED_JSON?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete):t.format===n.Tilemap.CSV?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.csvLoadComplete):this.asyncComplete(t,"invalid Tilemap format: "+t.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"texture":"truecolor"===t.key.split("_").pop()?this.loadImageTag(t):this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete);break;case"binary":this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete)}},loadImageTag:function(n){var t=this;n.data=new Image;n.data.name=n.key;this.crossOrigin&&(n.data.crossOrigin=this.crossOrigin);n.data.onload=function(){n.data.onload&&(n.data.onload=null,n.data.onerror=null,t.fileComplete(n))};n.data.onerror=function(){n.data.onload&&(n.data.onload=null,n.data.onerror=null,t.fileError(n))};n.data.src=this.transformUrl(n.url,n);!this.game.device.firefox&&n.data.complete&&n.data.width&&n.data.height&&(n.data.onload=null,n.data.onerror=null,this.fileComplete(n))},loadVideoTag:function(t){var r=this,i;t.data=document.createElement("video");t.data.name=t.key;t.data.controls=!1;t.data.autoplay=!1;t.data.playsInline=!0;i=function(){t.data.removeEventListener(t.loadEvent,i,!1);t.data.onerror=null;t.data.canplay=!0;n.GAMES[r.game.id].load.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener(t.loadEvent,i,!1);t.data.onerror=null;t.data.canplay=!1;r.fileError(t)};t.data.addEventListener(t.loadEvent,i,!1);t.data.src=this.transformUrl(t.url,t);t.data.load()},loadAudioTag:function(n){var i=this,t;this.game.sound.touchLocked?(n.data=new Audio,n.data.name=n.key,n.data.preload="auto",n.data.src=this.transformUrl(n.url,n),this.fileComplete(n)):(n.data=new Audio,n.data.name=n.key,t=function(){n.data.removeEventListener("canplaythrough",t,!1);n.data.onerror=null;i.fileComplete(n)},n.data.onerror=function(){n.data.removeEventListener("canplaythrough",t,!1);n.data.onerror=null;i.fileError(n)},n.data.preload="auto",n.data.src=this.transformUrl(n.url,n),n.data.addEventListener("canplaythrough",t,!1),n.data.load())},xhrLoad:function(n,t,i,r,u){var f=new XMLHttpRequest,e;f.open("GET",t,!0);f.responseType=i;!1!==this.headers.requestedWith&&f.setRequestHeader("X-Requested-With",this.headers.requestedWith);this.headers[n.type]&&f.setRequestHeader("Accept",this.headers[n.type]);u=u||this.fileError;e=this;f.onload=function(){try{return 4===f.readyState&&f.status>=400&&f.status<=599?u.call(e,n,f):r.call(e,n,f)}catch(t){e.hasLoaded?window.console&&console.error(t):e.asyncComplete(n,t.message||"Exception")}};f.onerror=function(){try{return u.call(e,n,f)}catch(t){e.hasLoaded?window.console&&console.error(t):e.asyncComplete(n,t.message||"Exception")}};n.requestObject=f;n.requestUrl=t;f.send()},getVideoURL:function(n){for(var r,t,i=0;i<n.length;i++)if(t=n[i],t.uri){if(r=t.type,t=t.uri,this.game.device.canPlayVideo(r))return t}else{if(0===t.indexOf("blob:")||0===t.indexOf("data:"))return t;if(t.indexOf("?")>=0&&(t=t.substr(0,t.indexOf("?"))),r=t.substr((Math.max(0,t.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(r))return n[i]}return null},getAudioURL:function(n){var i,r,t;if(this.game.sound.noAudio)return null;for(i=0;i<n.length;i++)if(t=n[i],t.uri){if(r=t.type,t=t.uri,this.game.device.canPlayAudio(r))return t}else{if(0===t.indexOf("blob:")||0===t.indexOf("data:"))return t;if(t.indexOf("?")>=0&&(t=t.substr(0,t.indexOf("?"))),r=t.substr((Math.max(0,t.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(r))return n[i]}return null},fileError:function(n,t,i){var r="error loading asset from URL "+(n.requestUrl||this.transformUrl(n.url,n));!i&&t&&(i=t.status);i&&(r=r+" ("+i+")");this.asyncComplete(n,r)},fileComplete:function(t,i){var u=!0,f,r;switch(t.type){case"packfile":r=JSON.parse(i.responseText);t.data=r||{};break;case"texture":f=/\.([^.]+)$/.exec(t.url.split("?",1)[0])[1].toLowerCase();null!==t.data?this.cache.addCompressedTextureMetaData(t.key,t.url,f,t.data):this.cache.addCompressedTextureMetaData(t.key,t.url,f,i.response);break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing,t.skipFrames);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else if(u=!1,t.format===n.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===n.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===n.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==n.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.xmlLoadComplete)}break;case"bitmapfont":t.atlasURL?(u=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",function(n,t){var i;try{i=JSON.parse(t.responseText)}catch(n){}i?(n.atlasType="json",this.jsonLoadComplete(n,t)):(n.atlasType="xml",this.xmlLoadComplete(n,t))})):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"video":if(t.asBlob)try{t.data=i.response}catch(n){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+t.key);}this.cache.addVideo(t.key,t.url,t.data,t.asBlob);break;case"audio":this.game.sound.usingWebAudio?(t.data=i.response,this.cache.addSound(t.key,t.url,t.data,!0,!1),t.autoDecode&&this.game.sound.decode(t.key)):this.cache.addSound(t.key,t.url,t.data,!1,!0);break;case"text":t.data=i.responseText;this.cache.addText(t.key,t.url,t.data);break;case"shader":t.data=i.responseText;this.cache.addShader(t.key,t.url,t.data);break;case"physics":r=JSON.parse(i.responseText);this.cache.addPhysicsData(t.key,t.url,r,t.format);break;case"script":t.data=document.createElement("script");t.data.language="javascript";t.data.type="text/javascript";t.data.defer=!1;t.data.text=i.responseText;document.head.appendChild(t.data);t.callback&&(t.data=t.callback.call(t.callbackContext,t.key,i.responseText));break;case"binary":t.data=t.callback?t.callback.call(t.callbackContext,t.key,i.response):i.response;this.cache.addBinary(t.key,t.data)}u&&this.asyncComplete(t)},jsonLoadComplete:function(n,t){var i=JSON.parse(t.responseText);"tilemap"===n.type?this.cache.addTilemap(n.key,n.url,i,n.format):"bitmapfont"===n.type?this.cache.addBitmapFont(n.key,n.url,n.data,i,n.atlasType,n.xSpacing,n.ySpacing):"json"===n.type?this.cache.addJSON(n.key,n.url,i):this.cache.addTextureAtlas(n.key,n.url,n.data,i,n.format);this.asyncComplete(n)},csvLoadComplete:function(n,t){var i=t.responseText;this.cache.addTilemap(n.key,n.url,i,n.format);this.asyncComplete(n)},xmlLoadComplete:function(n,t){var u=t.responseText,i=this.parseXml(u),r;if(!i)return r=t.responseType||t.contentType,console.warn("Phaser.Loader - "+n.key+": invalid XML ("+r+")"),void this.asyncComplete(n,"invalid XML");"bitmapfont"===n.type?this.cache.addBitmapFont(n.key,n.url,n.data,i,n.atlasType,n.xSpacing,n.ySpacing):"textureatlas"===n.type?this.cache.addTextureAtlas(n.key,n.url,n.data,i,n.format):"xml"===n.type&&this.cache.addXML(n.key,n.url,i);this.asyncComplete(n)},parseXml:function(n){var t,i;try{window.DOMParser?(i=new DOMParser,t=i.parseFromString(n,"text/xml")):((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(n))}catch(n){t=null}return t&&t.documentElement&&!t.getElementsByTagName("parsererror").length?t:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(n.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return n.Math.clamp(t||0,0,100)}}),Object.defineProperty(n.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),n.Loader.prototype.constructor=n.Loader,n.LoaderParser={bitmapFont:function(n,t,i,r,u,f){return this.xmlBitmapFont(n,t,i,r,u,f)},xmlBitmapFont:function(n,t,i,r,u,f){var v,e,c,l;null==f&&(f=1);var h={},a=n.getElementsByTagName("info")[0],p=n.getElementsByTagName("common")[0];h.font=a.getAttribute("face");h.size=parseInt(a.getAttribute("size"),10);h.lineHeight=parseInt(p.getAttribute("lineHeight"),10)+r;h.chars={};for(var s=n.getElementsByTagName("char"),w=u?u.x:0,b=u?u.y:0,o=0;o<s.length;o++)v=parseInt(s[o].getAttribute("id"),10),e=h.chars[v]={x:parseInt(s[o].getAttribute("x"),10),y:parseInt(s[o].getAttribute("y"),10),width:parseInt(s[o].getAttribute("width"),10),height:parseInt(s[o].getAttribute("height"),10),xOffset:parseInt(s[o].getAttribute("xoffset"),10)/f,yOffset:parseInt(s[o].getAttribute("yoffset"),10)/f,xAdvance:(parseInt(s[o].getAttribute("xadvance"),10)+i)/f,kerning:{}},u&&u.trimmed&&((e.x+e.width>u.spriteSourceSizeX+u.spriteSourceSizeW&&(e.width-=e.x+e.width-u.spriteSourceSizeX-u.spriteSourceSizeW),e.y+e.height>u.spriteSourceSizeY+u.spriteSourceSizeH&&(e.height-=e.y+e.height-u.spriteSourceSizeY-u.spriteSourceSizeH),e.x<u.spriteSourceSizeX)&&(c=u.spriteSourceSizeX-e.x,e.x=0,e.width-=c,e.xOffset+=c),e.y<u.spriteSourceSizeY&&(c=u.spriteSourceSizeY-e.y,e.y=0,e.height-=c,e.yOffset+=c)),e.x+=w,e.y+=b;for(l=n.getElementsByTagName("kerning"),o=0;o<l.length;o++){var k=parseInt(l[o].getAttribute("first"),10),y=parseInt(l[o].getAttribute("second"),10),d=parseInt(l[o].getAttribute("amount"),10)/f;h.chars[y]&&(h.chars[y].kerning[k]=d)}return this.finalizeBitmapFont(t,h)},jsonBitmapFont:function(n,t,i,r,u,f){null==f&&(f=1);var e={font:n.font.info._face,size:parseInt(n.font.info._size,10),lineHeight:parseInt(n.font.common._lineHeight,10)+r,chars:{}},o=u?u.x:0,s=u?u.y:0;return n.font.chars.char.forEach(function(n){var h=parseInt(n._id,10),t=e.chars[h]={x:parseInt(n._x,10),y:parseInt(n._y,10),width:parseInt(n._width,10),height:parseInt(n._height,10),xOffset:parseInt(n._xoffset,10)/f,yOffset:parseInt(n._yoffset,10)/f,xAdvance:(parseInt(n._xadvance,10)+i)/f,kerning:{}},r;u&&u.trimmed&&((t.x+t.width>u.spriteSourceSizeX+u.spriteSourceSizeW&&(t.width-=t.x+t.width-u.spriteSourceSizeX-u.spriteSourceSizeW),t.y+t.height>u.spriteSourceSizeY+u.spriteSourceSizeH&&(t.height-=t.y+t.height-u.spriteSourceSizeY-u.spriteSourceSizeH),t.x<u.spriteSourceSizeX)&&(r=u.spriteSourceSizeX-t.x,t.x=0,t.width-=r,t.xOffset+=r),t.y<u.spriteSourceSizeY&&(r=u.spriteSourceSizeY-t.y,t.y=0,t.height-=r,t.yOffset+=r));t.x+=o;t.y+=s}),n.font.kernings&&n.font.kernings.kerning&&n.font.kernings.kerning.forEach(function(n){e.chars[n._second]&&(e.chars[n._second].kerning[n._first]=parseInt(n._amount,10)/f)}),this.finalizeBitmapFont(t,e)},finalizeBitmapFont:function(t,i){return Object.keys(i.chars).forEach(function(r){var u=i.chars[r];u.texture=new PIXI.Texture(t,new n.Rectangle(u.x,u.y,u.width,u.height))}),i},pvr:function(n){var u,t=new Uint32Array(n.slice(0,52)),f=new Uint8Array(n),e=null,r=t[3]<<32|t[2],i=0;if(55727696===t[0]&&[0,1,2,3,6,7,9,11].indexOf(r)>=0){switch(r>=0&&r<=3?u="PVRTC":r>=7&&r<=11?u="S3TC":6===r&&(u="ETC1"),r){case 0:i=35841;break;case 1:i=35843;break;case 2:i=35840;break;case 3:i=35842;break;case 6:i=36196;break;case 7:i=33777;break;case 9:i=33778;break;case 11:i=33779;break;default:i=-1}e={complete:!0,fileFormat:"PVR",compressionAlgorithm:u,flags:t[1],pixelFormat:r,colorSpace:t[4],channelType:t[5],height:t[6],width:t[7],depth:t[8],numberOfSurfaces:t[9],numberOfFaces:t[10],numberOfMipmaps:t[11],metaDataSize:t[12],textureData:f.subarray(52+t[12],f.byteLength),glExtensionFormat:i}}return e},dds:function(n){var r=new Uint8Array(n),t=new Uint32Array(n),i=null;return 68===r[0]&&68===r[1]&&83===r[2]&&32===r[3]&&("DX10"===(i={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:t[1],flags:t[2],height:t[3],width:t[4],pitch:t[5],depth:t[6],mipmapCount:t[7],formatSize:t[19],formatFlag:t[19],formatFourCC:[String.fromCharCode(r[84]),String.fromCharCode(r[85]),String.fromCharCode(r[86]),String.fromCharCode(r[87])].join(""),formatBitCount:t[21],formatRBitMask:t[22],formatGBitMask:t[23],formatBBitMask:t[24],formatABitMask:t[25],caps1:t[26],caps2:t[27],caps3:t[28],caps4:t[29],reserved2:t[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:r.subarray(t[1]+4,r.byteLength)}).formatFourCC?(i.DXGIFormat=t[31],i.resourceDimension=t[32],i.miscFlag=t[33],i.arraySize=t[34],i.miscFlag=t[35]):"DXT5"===i.formatFourCC?i.glExtensionFormat=33779:"DXT3"===i.formatFourCC&&(i.glExtensionFormat=33778)),i},ktx:function(n){var i=new Uint8Array(n),t=new Uint32Array(n),u=null,f=16+t[15]/4|0,e=t[f],o=t[7],r=0;if(171===i[0]&&75===i[1]&&84===i[2]&&88===i[3]&&32===i[4]&&49===i[5]&&49===i[6]&&187===i[7]&&13===i[8]&&10===i[9]&&26===i[10]&&10===i[11]&&[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(o)>=0){switch(o){case 36196:r="ETC1";break;case 35840:case 35841:case 35842:case 35843:r="PVRTC";break;case 33776:case 33777:case 33778:case 33779:r="S3TC"}u={complete:!0,fileFormat:"KTX",compressionAlgorithm:r,endianness:t[3],glType:t[4],glTypeSize:t[5],glFormat:t[6],glInternalFormat:t[7],glBaseInternalFormat:t[8],width:t[9],height:t[10],pixelDepth:t[11],numberOfArrayElements:t[12],numberOfFaces:t[13],numberOfMipmapLevels:t[14],bytesOfKeyValueData:t[15],keyAndValueByteSize:t[16],imageSize:e,textureData:i.subarray(4*(f+1),e+100)}}return u},pkm:function(n){var t=new Uint8Array(n),i=null;return 80===t[0]&&75===t[1]&&77===t[2]&&32===t[3]&&(i={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(t[6]<<8|t[7]),width:65535&(t[8]<<8|t[9]),height:65535&(t[10]<<8|t[11]),originalWidth:65535&(t[12]<<8|t[13]),originalHeight:65535&(t[14]<<8|t[15]),textureData:t.subarray(16,t.length)}),i}},n.AudioSprite=function(n,t){var r,i,u;this.game=n;this.key=t;this.config=this.game.cache.getJSON(t+"-audioatlas");this.autoplayKey=null;this.autoplay=!1;this.sounds={};for(r in this.config.spritemap)i=this.config.spritemap[r],u=this.game.add.sound(this.key),u.addMarker(r,i.start,i.end-i.start,null,i.loop),this.sounds[r]=u;this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},n.AudioSprite.prototype={play:function(n,t){return void 0===t&&(t=1),this.sounds[n].play(n,null,t)},stop:function(n){if(n)this.sounds[n].stop();else for(var t in this.sounds)this.sounds[t].stop()},get:function(n){return this.sounds[n]}},n.AudioSprite.prototype.constructor=n.AudioSprite,n.Sound=function(t,i,r,u,f){void 0===r&&(r=1);void 0===u&&(u=!1);void 0===f&&(f=t.sound.connectToMaster);this.game=t;this.name=i;this.key=i;this.loop=u;this.markers={};this.context=null;this.autoplay=!1;this.totalDuration=0;this.startTime=0;this.currentTime=0;this.duration=0;this.durationMS=0;this.position=0;this.stopTime=0;this.paused=!1;this.pausedPosition=0;this.pausedTime=0;this.isPlaying=!1;this.currentMarker="";this.fadeTween=null;this.pendingPlayback=!1;this.override=!1;this.allowMultiple=!1;this.playOnce=!1;this.usingWebAudio=this.game.sound.usingWebAudio;this.usingAudioTag=this.game.sound.usingAudioTag;this.externalNode=null;this.masterGainNode=null;this.gainNode=null;this._sound=null;this._globalVolume=1;this._markedToDelete=!1;this._pendingStart=!1;this._removeFromSoundManager=!1;this._sourceId=0;this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,this.gainNode=void 0===this.context.createGain?this.context.createGainNode():this.context.createGain(),this.gainNode.gain.value=r,f&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(i)&&this.game.cache.isSoundReady(i)?(this._sound=this.game.cache.getSoundData(i),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this));this.onDecoded=new n.Signal;this.onPlay=new n.Signal;this.onPause=new n.Signal;this.onResume=new n.Signal;this.onLoop=new n.Signal;this.onStop=new n.Signal;this.onMute=new n.Signal;this.onMarkerComplete=new n.Signal;this.onFadeComplete=new n.Signal;this._volume=r;this._buffer=null;this._muted=!1;this._tempMarker=0;this._tempPosition=0;this._tempVolume=0;this._tempPause=0;this._muteVolume=0;this._tempLoop=0;this._paused=!1;this._onDecodedEventDispatched=!1},n.Sound.prototype={soundHasUnlocked:function(n){n===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(n,t,i,r,u){void 0!==i&&null!==i||(i=1);void 0!==r&&null!==r||(r=1);void 0===u&&(u=!1);this.markers[n]={name:n,start:t,stop:t+i,volume:r,duration:i,durationMS:1e3*i,loop:u}},removeMarker:function(n){delete this.markers[n]},onEndedHandler:function(){this._removeOnEndedHandler();this.isPlaying=!1;this.currentTime=this.durationMS;this.stop();this.playOnce&&(this._markedToDelete=!0,this._removeFromSoundManager=!0);this._markedToDelete&&(this._disconnectSource(),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))},update:function(){var n,t;if(this.game.cache.checkSoundKey(this.key)){if(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),n=this.game.time.time,this.isPlaying){if(this._pendingStart){if(t=this._sound.currentTime,!(t>((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1;this.startTime=n-1e3*t;this.stopTime=this.startTime+this.durationMS}this.currentTime=n-this.startTime;this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=n,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=n),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop())}}else this.destroy()},loopFull:function(n){return this.play(null,0,n,!0)},play:function(n,t,i,r,u){if((void 0!==n&&!1!==n&&null!==n||(n=""),void 0===u&&(u=!0),this.isPlaying&&!this.allowMultiple&&!u&&!this.override)||(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||u)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===n&&Object.keys(this.markers).length>0))return this;if(""!==n){if(!this.markers[n])return console.warn("Phaser.Sound.play: audio marker "+n+" doesn't exist"),this;this.currentMarker=n;this.position=this.markers[n].start;this.volume=this.markers[n].volume;this.loop=this.markers[n].loop;this.duration=this.markers[n].duration;this.durationMS=this.markers[n].durationMS;void 0!==i&&(this.volume=i);void 0!==r&&(this.loop=r);this._tempMarker=n;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else t=t||0,void 0===i&&(i=this._volume),void 0===r&&(r=this.loop),this.position=Math.max(0,t),this.volume=i,this.loop=r,this.duration=0,this.durationMS=0,this._tempMarker=n,this._tempPosition=t,this._tempVolume=i,this._tempLoop=r;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._createSourceAndConnect(),this.loop&&""===n&&(this._sound.loop=!0),this.loop||""!==n||this._addOnEndedHandler(),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),this.loop&&""===n?this._startSource(0,0):this._startSource(0,this.position,this.duration),this.isPlaying=!0,this.paused=!1,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this._sound.loop=this.loop,this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._globalVolume=this.game.sound.volume,this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted||this.game.sound.mute?0:this._volume*this._globalVolume,this._pendingStart=!0,this.isPlaying=!0,this.paused=!1,this._tempPause=0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0,this.playOnce&&(this.loop&&console.warn("Phaser.Sound.play: audio clip "+this.name+" cannot be deleted while looping."),this._markedToDelete=!0,this._removeFromSoundManager=!0),this},restart:function(n,t,i,r){n=n||"";t=t||0;i=i||1;void 0===r&&(r=!1);this.play(n,t,i,r,!0)},pause:function(){this.isPlaying&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){var n,t;this.paused&&(this.usingWebAudio?(n=Math.max(0,this.position+this.pausedPosition/1e3),this._createSourceAndConnect(),""===this.currentMarker&&(this.loop?this._sound.loop=!0:this._addOnEndedHandler()),t=this.duration-this.pausedPosition/1e3,this.loop&&""===this.currentMarker?this._startSource(0,n):this._startSource(0,n,t)):(this._pendingStart=!0,this._sound.currentTime=this._tempPause,this._tempPause=0,this._sound.play()),this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this))},stop:function(){if(this.isPlaying&&this._sound&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var n=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this);this.currentMarker="";null!==this.fadeTween&&this.fadeTween.stop();this.onStop.dispatch(this,n)}},fadeIn:function(n,t,i){void 0===t&&(t=!1);void 0===i&&(i=this.currentMarker);this.paused||(this.play(i,0,0,t),this.fadeTo(n,1))},fadeOut:function(n){this.fadeTo(n,0)},fadeTo:function(t,i){this.isPlaying&&!this.paused&&i!==this.volume&&(void 0===t&&(t=1e3),void 0!==i?(this.fadeTween=this.game.add.tween(this).to({volume:i},t,n.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)):console.warn("Phaser.Sound.fadeTo: No Volume Specified."))},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume);0===this.volume&&this.stop()},updateGlobalVolume:function(n){this.usingAudioTag&&this._sound&&(this._globalVolume=n,this._sound.volume=this._globalVolume*this._volume)},destroy:function(n){void 0===n&&(n=!0);this._markedToDelete=!0;this._removeFromSoundManager=n;this.stop();n?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())},_createSourceAndConnect:function(){this._sound=this.context.createBufferSource();this._sound.connect(this.externalNode||this.gainNode);this._buffer=this.game.cache.getSoundData(this.key);this._sound.buffer=this._buffer;this._sourceId++},_disconnectSource:function(){this._sound.disconnect(this.externalNode||this.gainNode)},_startSource:function(n,t,i){void 0===i?this._sound.start(n||0,t||0):this._sound.start(n||0,t||0,i)},_stopSourceAndDisconnect:function(){this._removeOnEndedHandler();try{this._sound.stop(0)}catch(n){}this._disconnectSource();this._sound=null},_addOnEndedHandler:function(){this._sound.onended=this.onEndedHandler.bind(this)},_removeOnEndedHandler:function(){this._sound.onended=null}},n.Sound.prototype.constructor=n.Sound,Object.defineProperty(n.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(n.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(n.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(n){(n=n||!1)!==this._muted&&(n?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(n.Sound.prototype,"volume",{get:function(){return this._volume},set:function(n){this.usingAudioTag&&(n=this.game.math.clamp(n,0,1));this._muted?this._muteVolume=n:(this._tempVolume=n,this._volume=n,this.usingWebAudio?this.gainNode.gain.value=n:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*n))}}),Object.defineProperty(n.Sound.prototype,"sourceId",{get:function(){return this._sound?this._sourceId:null}}),n.SoundManager=function(t){this.game=t;this.onSoundDecode=new n.Signal;this.onVolumeChange=new n.Signal;this.onMute=new n.Signal;this.onUnMute=new n.Signal;this.onTouchUnlock=new n.Signal;this.context=null;this.baseLatency=null;this.usingWebAudio=!1;this.usingAudioTag=!1;this.noAudio=!1;this.connectToMaster=!0;this.touchLocked=!1;this.channels=32;this.muteOnPause=!0;this._codeMuted=!1;this._muted=!1;this._unlockSource=null;this._volume=1;this._sounds=[];this._watchList=new n.ArraySet;this._watching=!1;this._watchCallback=null;this._watchContext=null;this._resumeWebAudioOnClick=this._resumeWebAudioOnClick.bind(this)},n.SoundManager.prototype={boot:function(){var n=this.game.device,t=window.PhaserGlobal,i;if(n.iOS&&!1===n.webAudio&&(this.channels=1),t){if(!0===t.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===t.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(t&&t.audioContext)this.context=t.audioContext;else if(i=window.AudioContext||window.webkitAudioContext,i)try{this.context=new i}catch(n){this.context=null;this.usingWebAudio=!1;this.touchLocked=!1;console.warn(n)}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),this.masterGain=void 0===this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),"suspended"===this.context.state&&this.game.canvas.addEventListener("click",this._resumeWebAudioOnClick);this.noAudio||n.needsTouchUnlock()&&this.setTouchLock();this.usingWebAudio&&n.chrome&&n.chromeVersion<=65&&console.log('A "GainNode.gain.value setter smoothing is deprecated" notice in Chrome is normal. <https://github.com/photonstorm/phaser-ce/issues/385>')},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0)},setTouchUnlock:function(){this.touchLocked=!1;this._unlockSource=null;this.onTouchUnlock.dispatch()},resumeWebAudio:function(){if(this.usingWebAudio&&"suspended"===this.context.state)return this.context.resume()},unlock:function(){var t,n;return this.noAudio||!this.touchLocked||null!==this._unlockSource?!0:(this.usingAudioTag?this.setTouchUnlock():this.usingWebAudio&&(t=this.context.createBuffer(1,1,22050),this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination),n=this,this._unlockSource.onended=function(){n.setTouchUnlock();n.resumeWebAudio()},void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),this.resumeWebAudio()),!0)},stopAll:function(){if(!this.noAudio)for(var n=0;n<this._sounds.length;n++)this._sounds[n]&&this._sounds[n].stop()},pauseAll:function(){if(!this.noAudio)for(var n=0;n<this._sounds.length;n++)this._sounds[n]&&this._sounds[n].pause()},resumeAll:function(){if(!this.noAudio)for(var n=0;n<this._sounds.length;n++)this._sounds[n]&&this._sounds[n].resume()},decode:function(n,t){var i,r;if(t=t||null,i=this.game.cache.getSoundData(n),i&&!1===this.game.cache.isSoundDecoded(n)){this.game.cache.updateSound(n,"isDecoding",!0);r=this;try{this.context.decodeAudioData(i,function(i){i&&(r.game.cache.decodedSound(n,i),r.onSoundDecode.dispatch(n,t))})}catch(n){}}},setDecodedCallback:function(t,i,r){"string"==typeof t&&(t=[t]);this._watchList.reset();for(var u=0;u<t.length;u++)t[u]instanceof n.Sound?this.game.cache.isSoundDecoded(t[u].key)||this._watchList.add(t[u].key):this.game.cache.isSoundDecoded(t[u])||this._watchList.add(t[u]);0===this._watchList.total?(this._watching=!1,i.call(r)):(this._watching=!0,this._watchCallback=i,this._watchContext=r)},update:function(){var t,n;if(!this.noAudio){for(t=0;t<this._sounds.length;t++)this._sounds[t].update();if(this._watching){for(n=this._watchList.first;n;)this.game.cache.isSoundDecoded(n)&&this._watchList.remove(n),n=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(t,i,r,u){void 0===i&&(i=1);void 0===r&&(r=!1);void 0===u&&(u=this.connectToMaster);var f=new n.Sound(this.game,t,i,r,u);return this._sounds.push(f),f},addSprite:function(t){return new n.AudioSprite(this.game,t)},remove:function(n){for(var t=this._sounds.length;t--;)if(this._sounds[t]===n)return this._sounds[t].destroy(!1),this._sounds.splice(t,1),!0;return!1},removeAll:function(){this.stopAll();for(var n=0;n<this._sounds.length;n++)this._sounds[n]&&this._sounds[n].destroy();this._sounds.length=0},removeByKey:function(n){for(var t=this._sounds.length,i=0;t--;)this._sounds[t].key===n&&(this._sounds[t].destroy(!1),this._sounds.splice(t,1),i++);return i},play:function(n,t,i){if(!this.noAudio){var r=this.add(n,t,i);return r.play(),r}},setMute:function(){if(!this._muted){this._muted=!0;this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var n=0;n<this._sounds.length;n++)this._sounds[n].usingAudioTag&&(this._sounds[n].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1;this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var n=0;n<this._sounds.length;n++)this._sounds[n].usingAudioTag&&(this._sounds[n].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.removeAll();this.onSoundDecode.dispose();this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick);this.context&&(window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close())},_resumeWebAudioOnClick:function(){this.resumeWebAudio();this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick)}},n.SoundManager.prototype.constructor=n.SoundManager,Object.defineProperty(n.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(n){if(n=n||!1){if(this._muted)return;this._codeMuted=!0;this.setMute()}else{if(!this._muted)return;this._codeMuted=!1;this.unsetMute()}}}),Object.defineProperty(n.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(n){if(n<0?n=0:n>1&&(n=1),this._volume!==n){if(this._volume=n,this.usingWebAudio)this.masterGain.gain.value=n;else for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&this._sounds[t].updateGlobalVolume(n);this.onVolumeChange.dispatch(n)}}}),n.ScaleManager=function(t,i,r){this.game=t;this.dom=n.DOM;this.grid=null;this.width=0;this.height=0;this.minWidth=null;this.maxWidth=null;this.minHeight=null;this.maxHeight=null;this.offset=new n.Point;this.forceLandscape=!1;this.forcePortrait=!1;this.incorrectOrientation=!1;this._pageAlignHorizontally=!1;this._pageAlignVertically=!1;this.onOrientationChange=new n.Signal;this.enterIncorrectOrientation=new n.Signal;this.leaveIncorrectOrientation=new n.Signal;this.hasPhaserSetFullScreen=!1;this.fullScreenTarget=null;this._createdFullScreenTarget=null;this.onFullScreenInit=new n.Signal;this.onFullScreenChange=new n.Signal;this.onFullScreenError=new n.Signal;this.screenOrientation=this.dom.getScreenOrientation();this.scaleFactor=new n.Point(1,1);this.scaleFactorInversed=new n.Point(1,1);this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0};this.bounds=new n.Rectangle;this.aspectRatio=0;this.sourceAspectRatio=0;this.event=null;this.windowConstraints={right:"layout",bottom:""};this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""};this._scaleMode=n.ScaleManager.NO_SCALE;this._fullScreenScaleMode=n.ScaleManager.NO_SCALE;this.parentIsWindow=!1;this.parentNode=null;this.parentScaleFactor=new n.Point(1,1);this.trackParentInterval=2e3;this.onSizeChange=new n.Signal;this.onResize=null;this.onResizeContext=null;this._pendingScaleMode=null;this._fullScreenRestore=null;this._gameSize=new n.Rectangle;this._userScaleFactor=new n.Point(1,1);this._userScaleTrim=new n.Point(0,0);this._lastUpdate=0;this._updateThrottle=0;this._updateThrottleReset=100;this._parentBounds=new n.Rectangle;this._tempBounds=new n.Rectangle;this._lastReportedCanvasSize=new n.Rectangle;this._lastReportedGameSize=new n.Rectangle;this._booted=!1;t.config&&this.parseConfig(t.config);this.setupScale(i,r)},n.ScaleManager.EXACT_FIT=0,n.ScaleManager.NO_SCALE=1,n.ScaleManager.SHOW_ALL=2,n.ScaleManager.RESIZE=3,n.ScaleManager.USER_SCALE=4,n.ScaleManager.MODES=["EXACT_FIT","NO_SCALE","SHOW_ALL","RESIZE","USER_SCALE"],n.ScaleManager.prototype={boot:function(){var t=this.compatibility,i;t.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS;this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(t.scrollTo=this.game.device.android&&!this.game.device.chrome?new n.Point(0,1):new n.Point(0,0));this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");i=this;this._orientationChange=function(n){return i.orientationChange(n)};this._windowResize=function(n){return i.windowResize(n)};window.addEventListener("orientationchange",this._orientationChange,!1);window.addEventListener("resize",this._windowResize,!1);this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(n){return i.fullScreenChange(n)},this._fullScreenError=function(n){return i.fullScreenError(n)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1));this.game.onResume.add(this._gameResumed,this);this.dom.getOffset(this.game.canvas,this.offset);this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height);this.setGameSize(this.game.width,this.game.height);this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback);n.FlexGrid&&(this.grid=new n.FlexGrid(this,this.width,this.height));this._booted=!0;null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(n){void 0!==n.scaleMode&&(this._booted?this.scaleMode=n.scaleMode:this._pendingScaleMode=n.scaleMode);void 0!==n.fullScreenScaleMode&&(this.fullScreenScaleMode=n.fullScreenScaleMode);n.fullScreenTarget&&(this.fullScreenTarget=n.fullScreenTarget);this.pageAlignHorizontally=n.alignH||!1;this.pageAlignVertically=n.alignV||!1;n.scaleH&&n.scaleV&&this.setUserScale(n.scaleH,n.scaleV,n.trimH,n.trimV)},setupScale:function(t,i){var e,f=new n.Rectangle,r,u;""!==this.game.parent&&("string"==typeof this.game.parent?e=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(e=this.game.parent));e?(this.parentNode=e,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds,this.parentNode),f.width=this._parentBounds.width,f.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,f.width=this.dom.visualBounds.width,f.height=this.dom.visualBounds.height,this.offset.set(0,0));r=0;u=0;"number"==typeof t?r=t:(this.parentScaleFactor.x=parseInt(t,10)/100,r=f.width*this.parentScaleFactor.x);"number"==typeof i?u=i:(this.parentScaleFactor.y=parseInt(i,10)/100,u=f.height*this.parentScaleFactor.y);r=Math.floor(r);u=Math.floor(u);this._gameSize.setTo(0,0,r,u);this.updateDimensions(r,u,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(t,i){this._gameSize.setTo(0,0,t,i);this.currentScaleMode!==n.ScaleManager.RESIZE&&this.updateDimensions(t,i,!0);this.queueUpdate(!0)},setUserScale:function(n,t,i,r,u,f){this._userScaleFactor.setTo(n,t);this._userScaleTrim.setTo(0|i,0|r);void 0===u&&(u=!0);void 0===f&&(f=!0);u&&this.queueUpdate(f)},setResizeCallback:function(n,t){this.onResize=n;this.onResizeContext=t},signalSizeChange:function(){if(!n.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!n.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var t=this.width,i=this.height;this._lastReportedCanvasSize.setTo(0,0,t,i);this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height);this.grid&&this.grid.onResize(t,i);this.onSizeChange.dispatch(this,t,i);this.currentScaleMode===n.ScaleManager.RESIZE&&(this.game.state.resize(t,i),this.game.load.resize(t,i))}},setMinMax:function(n,t,i,r){this.minWidth=n;this.minHeight=t;void 0!==i&&(this.maxWidth=i);void 0!==r&&(this.maxHeight=r)},preUpdate:function(){var t,r;if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100;this.dom.getOffset(this.game.canvas,this.offset);var u=this._parentBounds.width,f=this._parentBounds.height,i=this.getParentBounds(this._parentBounds),e=i.width!==u||i.height!==f,o=this.updateOrientationState();(e||o)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,i),this.updateLayout(),this.signalSizeChange());r=2*this._updateThrottle;this._updateThrottle<t&&(r=Math.min(t,this._updateThrottleReset));this._updateThrottle=n.Math.clamp(r,25,this.trackParentInterval);this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate();this._updateThrottle=this.trackParentInterval},updateDimensions:function(n,t,i){this.width=n*this.parentScaleFactor.x;this.height=t*this.parentScaleFactor.y;this.game.width=this.width;this.game.height=this.height;this.sourceAspectRatio=this.width/this.height;this.updateScalingAndBounds();i&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width;this.scaleFactor.y=this.game.height/this.height;this.scaleFactorInversed.x=this.width/this.game.width;this.scaleFactorInversed.y=this.height/this.game.height;this.aspectRatio=this.width/this.height;this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset);this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height);this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(n,t){void 0===t&&(t=!1);!0!==n||!0!==t?(this.forceLandscape=n,this.forcePortrait=t,this.queueUpdate(!0)):console.warn("Phaser.ScaleManager: forceLandscape and forcePortrait cannot both be true.")},classifyOrientation:function(n){return"portrait-primary"===n||"portrait-secondary"===n?"portrait":"landscape-primary"===n||"landscape-secondary"===n?"landscape":null},updateOrientationState:function(){var i=this.screenOrientation,r=this.incorrectOrientation,t,n;return this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait,t=i!==this.screenOrientation,n=r!==this.incorrectOrientation,n&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(t||n)&&this.onOrientationChange.dispatch(this,i,r),t||n},orientationChange:function(n){this.event=n;this.queueUpdate(!0)},windowResize:function(n){this.event=n;this.queueUpdate(!0)},scrollTop:function(){var n=this.compatibility.scrollTo;n&&window.scrollTo(n.x,n.y)},refresh:function(){this.scrollTop();this.queueUpdate(!0)},updateLayout:function(){var t=this.currentScaleMode,i;t!==n.ScaleManager.RESIZE?((this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():t===n.ScaleManager.EXACT_FIT?this.setExactFit():t===n.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===n.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):t===n.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),this.compatibility.canExpandParent||t!==n.ScaleManager.SHOW_ALL&&t!==n.ScaleManager.USER_SCALE)||(i=this.getParentBounds(this._tempBounds),this.width=Math.min(this.width,i.width),this.height=Math.min(this.height,i.height)),this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()):this.reflowGame()},getParentBounds:function(t,i){var r=t||new n.Rectangle,u=i||this.boundingParent,o=this.dom.visualBounds,c=this.dom.layoutBounds,f,h,e,s;return u?(f=u.getBoundingClientRect(),h=u.offsetParent?u.offsetParent.getBoundingClientRect():u.getBoundingClientRect(),r.setTo(f.left-h.left,f.top-h.top,f.width,f.height),e=this.windowConstraints,e.right&&(s="layout"===e.right?c:o,r.right=Math.min(r.right,s.width)),e.bottom&&(s="layout"===e.bottom?c:o,r.bottom=Math.min(r.bottom,s.height))):r.setTo(0,0,o.width,o.height),r.setTo(Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height)),r},align:function(n,t){null!=n&&(this.pageAlignHorizontally=n);null!=t&&(this.pageAlignVertically=t)},alignCanvas:function(n,t){var r=this.getParentBounds(this._tempBounds),u=this.game.canvas,i=this.margin,f;if(n){if(i.left=i.right=0,f=u.getBoundingClientRect(),this.width<r.width&&!this.incorrectOrientation){var o=f.left-r.x,e=r.width/2-this.width/2,s=(e=Math.max(e,0))-o;i.left=Math.round(s)}u.style.marginLeft=i.left+"px";0!==i.left&&(i.right=-(r.width-f.width-i.left),u.style.marginRight=i.right+"px")}if(t){if(i.top=i.bottom=0,f=u.getBoundingClientRect(),this.height<r.height&&!this.incorrectOrientation){var o=f.top-r.y,e=r.height/2-this.height/2,s=(e=Math.max(e,0))-o;i.top=Math.round(s)}u.style.marginTop=i.top+"px";0!==i.top&&(i.bottom=-(r.height-f.height-i.top),u.style.marginBottom=i.bottom+"px")}i.x=i.left;i.y=i.top},reflowGame:function(){this.resetCanvas("","");var n=this.getParentBounds(this._tempBounds);this.updateDimensions(n.width,n.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=n.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=n.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height));this.resetCanvas();this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically));this.updateScalingAndBounds()},resetCanvas:function(n,t){void 0===n&&(n=this.width+"px");void 0===t&&(t=this.height+"px");var i=this.game.canvas;this.compatibility.noMargins||(i.style.marginLeft="",i.style.marginTop="",i.style.marginRight="",i.style.marginBottom="");i.style.width=n;i.style.height=t},queueUpdate:function(n){n&&(this._parentBounds.width=0,this._parentBounds.height=0);this._updateThrottle=this._updateThrottleReset},reset:function(n){n&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width;this.height=this.dom.visualBounds.height},setShowAll:function(n){var t,i=this.getParentBounds(this._tempBounds),r=i.width,u=i.height;t=n?Math.max(u/this.game.height,r/this.game.width):Math.min(u/this.game.height,r/this.game.width);this.width=Math.round(this.game.width*t);this.height=Math.round(this.game.height*t)},setExactFit:function(){var n=this.getParentBounds(this._tempBounds);this.width=n.width;this.height=n.height;this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))},createFullScreenTarget:function(){var n=document.createElement("div");return n.style.margin="0",n.style.padding="0",n.style.background="#000",n},startFullScreen:function(t,i,r){var f,u,o,e,s;if(this.isFullScreen)return!1;if(this.compatibility.supportsFullScreen)return"when-not-mouse"===this.compatibility.clickTrampoline&&(f=this.game.input,f.activePointer&&f.activePointer!==f.mousePointer&&(i||!1!==i))?void f.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1]):(void 0!==t&&this.game.renderType===n.CANVAS&&(this.game.stage.smoothed=t),u=this.fullScreenTarget,u||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),u=this._createdFullScreenTarget),o={targetElement:u},(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,o),this._createdFullScreenTarget)&&(e=this.game.canvas,e.parentNode.insertBefore(u,e),u.appendChild(e)),void 0===r&&(r={navigationUI:"hide"}),this.game.device.fullscreenKeyboard?u[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):u[this.game.device.requestFullscreen](r),!0);s=this;setTimeout(function(){s.fullScreenError()},10)},stopFullScreen:function(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen)&&(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),!0)},cleanupCreatedTarget:function(){var n=this._createdFullScreenTarget,t;n&&n.parentNode&&(t=n.parentNode,t.insertBefore(this.game.canvas,n),t.removeChild(n));this._createdFullScreenTarget=null},prepScreenMode:function(t){var r=!!this._createdFullScreenTarget,i=this._createdFullScreenTarget||this.fullScreenTarget;t?(r||this.fullScreenScaleMode===n.ScaleManager.EXACT_FIT)&&i!==this.game.canvas&&(this._fullScreenRestore={targetWidth:i.style.width,targetHeight:i.style.height},i.style.width="100%",i.style.height="100%"):(this._fullScreenRestore&&(i.style.width=this._fullScreenRestore.targetWidth,i.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(n){this.event=n;this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0));this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(n){this.event=n;this.cleanupCreatedTarget();console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API");this.onFullScreenError.dispatch(this)},scaleSprite:function(n,t,i,r){if((void 0===t&&(t=this.width),void 0===i&&(i=this.height),void 0===r&&(r=!1),!n||!n.scale)||(n.scale.x=1,n.scale.y=1,n.width<=0||n.height<=0||t<=0||i<=0))return n;var e=t,o=n.height*t/n.width,u=n.width*i/n.height,s=i,f=u>t;return(f=f?r:!r)?(n.width=Math.floor(e),n.height=Math.floor(o)):(n.width=Math.floor(u),n.height=Math.floor(s)),n},destroy:function(){this.game.onResume.remove(this._gameResumed,this);window.removeEventListener("orientationchange",this._orientationChange,!1);window.removeEventListener("resize",this._windowResize,!1);this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},n.ScaleManager.prototype.constructor=n.ScaleManager,Object.defineProperty(n.ScaleManager.prototype,"boundingParent",{get:function(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}}),Object.defineProperty(n.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(n){return n!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=n),this._scaleMode}}),Object.defineProperty(n.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(n){return n!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=n,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=n),this._fullScreenScaleMode}}),Object.defineProperty(n.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(n.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(n){n!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=n,this.queueUpdate(!0))}}),Object.defineProperty(n.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(n){n!==this._pageAlignVertically&&(this._pageAlignVertically=n,this.queueUpdate(!0))}}),Object.defineProperty(n.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(n.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(n.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(n.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(n.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),n.Utils.Debug=function(n){this.game=n;this.sprite=null;this.bmd=null;this.canvas=null;this.context=null;this.font="14px monospace";this.columnWidth=100;this.lineHeight=16;this.lineWidth=1;this.renderShadow=!0;this.currentColor=null;this.currentX=0;this.currentY=0;this.currentAlpha=1;this.dirty=!1;this.isDisabled=!1;this._line=null;this._rect=null},n.Utils.Debug.GEOM_AUTO=0,n.Utils.Debug.GEOM_RECTANGLE=1,n.Utils.Debug.GEOM_CIRCLE=2,n.Utils.Debug.GEOM_POINT=3,n.Utils.Debug.GEOM_LINE=4,n.Utils.Debug.GEOM_ELLIPSE=5,n.Utils.Debug.prototype={boot:function(){this.game.renderType===n.CANVAS?this.context=this.game.context:(this.bmd=new n.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=n.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d"));this._line=new n.Line;this._rect=new n.Rectangle},resize:function(){this.bmd.resize(this.game.width,this.game.height);this.canvas.width=this.game.width;this.canvas.height=this.game.height},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height);this.sprite&&this.bmd.clear()},start:function(n,t,i,r){"number"!=typeof n&&(n=0);"number"!=typeof t&&(t=0);i=i||"rgb(255,255,255)";void 0===r&&(r=0);this.currentX=n;this.currentY=t;this.currentColor=i;this.columnWidth=r;this.dirty=!0;this.context.save();this.context.setTransform(1,0,0,1,0,0);this.context.strokeStyle=i;this.context.fillStyle=i;this.context.font=this.font;this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var t=this.currentX,n=0;n<arguments.length;n++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[n],t+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[n],t,this.currentY),t+=this.columnWidth;this.currentY+=this.lineHeight},sound:function(n,t,i){var r=this.game.sound;this.start(n,t,i);r.noAudio?this.line("Audio is disabled"):(this.line("Volume: "+r.volume.toFixed(2)+(r.mute?" (Mute)":"")),this.line("Mute on pause: "+r.muteOnPause),this.line("Using: "+(r.usingWebAudio?"Web Audio - "+r.context.state:"Audio Tag")),this.line("Touch locked: "+r.touchLocked),this.line("Sounds: "+r._sounds.length));this.stop()},soundInfo:function(n,t,i,r){this.start(t,i,r);this.line("Sound: "+n.key+"  Touch locked: "+n.game.sound.touchLocked);this.line("Is Ready?: "+this.game.cache.isSoundReady(n.key)+"  Pending Playback: "+n.pendingPlayback);this.line("Decoded: "+n.isDecoded+"  Decoding: "+n.isDecoding);this.line("Playing: "+n.isPlaying+"  Loop: "+n.loop);this.line("Time: "+(n.currentTime/1e3).toFixed(3)+"s  Total: "+n.totalDuration.toFixed(3)+"s");this.line("Volume: "+n.volume.toFixed(2)+(n.mute?" (Mute)":""));this.line("Using: "+(n.usingWebAudio?"Web Audio":"Audio Tag")+"  "+(n.usingWebAudio?"Source: "+(n.sourceId||"none"):""));""!==n.currentMarker&&(this.line("Marker: "+n.currentMarker+"  Duration: "+n.duration.toFixed(3)+"s ("+n.durationMS+"ms)"),this.line("Start: "+n.markers[n.currentMarker].start+"  Stop: "+n.markers[n.currentMarker].stop),this.line("Position: "+n.position));this.stop()},camera:function(n,t,i){var r=n.deadzone,u=n.target,f=n.view;r&&(this._rect.setTo(f.x+r.x,f.y+r.y,r.width,r.height),this.rectangle(this._rect,t,i));u&&(this._line.setTo(f.centerX,f.centerY,u.x,u.y),this.geom(this._line,t,i),this.geom(u,t,!1,3))},cameraInfo:function(n,t,i,r){var f=n.bounds,u=n.deadzone,o=n.target,e=n.view;this.start(t,i,r);this.line("Camera ("+n.width+" x "+n.height+")");this.line("x: "+n.x+" y: "+n.y);this.line("Bounds: "+(f?"x: "+f.x+" y: "+f.y+" w: "+f.width+" h: "+f.height:"none"));this.line("View: x: "+e.x+" y: "+e.y+" w: "+e.width+" h: "+e.height);this.line("Center: x: "+n.centerX+" y: "+n.centerY);this.line("Deadzone: "+(u?"x: "+u.x+" y: "+u.y+" w: "+u.width+" h: "+u.height:u));this.line("Total in view: "+n.totalInView);this.line("At limit: x: "+n.atLimit.x+" y: "+n.atLimit.y);this.line("Target: "+(o?o.name||o:"none"));this.stop()},timer:function(n,t,i,r){this.start(t,i,r);this.line("Timer (running: "+n.running+" expired: "+n.expired+")");this.line("Next Tick: "+n.next+" Duration: "+n.duration);this.line("Paused: "+n.paused+" Length: "+n.length);this.stop()},pointer:function(n,t,i,r,u,f){if(null!=n&&(void 0===t&&(t=!1),i=i||"rgba(0,255,0,0.5)",r=r||"rgba(255,255,0,0.5)",f=f||"rgba(255,0,0,0.5)",!0!==t||!0!==n.isUp)){this.start(n.x,n.y-150,u);this.context.beginPath();this.context.arc(n.x,n.y,n.circle.radius,0,2*Math.PI);this.context.fillStyle=n.active?n.isDown?i:r:f;this.context.fill();this.context.closePath();this.context.beginPath();this.context.moveTo(n.positionDown.x,n.positionDown.y);this.context.lineTo(n.position.x,n.position.y);this.context.lineWidth=2;this.context.stroke();this.context.closePath();var e=n.movementX,o=n.movementY;(e||o)&&(this.context.beginPath(),this.context.moveTo(e+n.position.x,o+n.position.y),this.context.lineTo(n.position.x,n.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath());this.line("ID: "+n.id+" Active: "+n.active);this.line("World X: "+n.worldX.toFixed(1)+" World Y: "+n.worldY.toFixed(1));this.line("Screen X: "+n.x.toFixed(1)+" Screen Y: "+n.y.toFixed(1)+" In: "+n.withinGame);this.line("Movement: X: "+e+" Y: "+o);this.line("Duration: "+n.duration+" ms");this.line("is Down: "+n.isDown+" is Up: "+n.isUp);n.isMouse&&this.line("Buttons: "+this._pointerButtonIcon(n.leftButton)+" "+this._pointerButtonIcon(n.middleButton)+" "+this._pointerButtonIcon(n.rightButton));this.stop()}},_pointerButtonIcon:function(n){return n.isDown?"x":n.isUp?"o":"-"},spriteInputInfo:function(n,t,i,r){this.start(t,i,r);this.line("Sprite Input: ("+n.width+" x "+n.height+")");this.line("x: "+n.input.pointerX().toFixed(1)+" y: "+n.input.pointerY().toFixed(1));this.line("over: "+n.input.pointerOver()+" duration: "+n.input.overDuration().toFixed(0));this.line("down: "+n.input.pointerDown()+" duration: "+n.input.downDuration().toFixed(0));this.line("just over: "+n.input.justOver()+" just out: "+n.input.justOut());this.stop()},key:function(n,t,i,r){this.start(t,i,r,150);this.line("Key:",n.keyCode,"isDown:",n.isDown);this.line("justDown:",n.justDown,"justUp:",n.justUp);this.line("Time Down:",n.timeDown.toFixed(0),"duration:",n.duration.toFixed(0));this.stop()},inputInfo:function(t,i,r,u){var f=this.game.input,e,o;if(void 0===u&&(u=!0),this.start(t,i,r),this.line("Input"),this.line("X: "+f.x+" Y: "+f.y),this.line("World X: "+f.worldX+" World Y: "+f.worldY),this.line("Scale X: "+f.scale.x.toFixed(2)+" Scale Y: "+f.scale.x.toFixed(2)),this.line("Screen X: "+f.activePointer.screenX.toFixed(1)+" Screen Y: "+f.activePointer.screenY.toFixed(1)),u){this.line("Sources:");this.line("  "+this._inputHandler(f.mouse,"mouse"));this.line("  "+this._inputHandler(f.mspointer,"mspointer"));this.line("  "+this._inputHandler(f.touch,"touch"));var h=f.pointers,s=f.mousePointer,c=n.PointerModes;for(this.line("Pointers: (Max: "+f.maxPointers+")"),this.line("  "+(s.isDown?"x":"o")+" "+c[s.pointerMode]+" "+s.identifier),e=0;e<h.length;e++)o=h[e],this.line("  "+(o.active?"+":"-")+" "+c[o.pointerMode]+" "+o.identifier);this.stop()}else this.stop()},_inputHandler:function(n,t){return this._inputHandlerStatusIcon(n)+" "+t+" "+this._inputHandlerCaptureIcon(n)},_inputHandlerStatusIcon:function(n){return n.active?n.enabled?"+":"-":" "},_inputHandlerCaptureIcon:function(n){return n.active&&(n.capture||n.preventDefault)?"*":" "},spriteBounds:function(n,t,i){var r=n.getBounds();r.x+=this.game.camera.x;r.y+=this.game.camera.y;this.rectangle(r,t,i)},ropeSegments:function(n,t,i){var r=this;n.segments.forEach(function(n){r.rectangle(n,t,i)},this)},spriteInfo:function(n,t,i,r){this.start(t,i,r);this.line("Sprite: "+(n.name||"")+" ("+n.width+" x "+n.height+") anchor: "+n.anchor.x+" x "+n.anchor.y);this.line("x: "+n.x.toFixed(1)+" y: "+n.y.toFixed(1));this.line("angle: "+n.angle.toFixed(1)+" rotation: "+n.rotation.toFixed(1));this.line("visible: "+n.visible+" in camera: "+n.inCamera);this.line("bounds x: "+n._bounds.x.toFixed(1)+" y: "+n._bounds.y.toFixed(1)+" w: "+n._bounds.width.toFixed(1)+" h: "+n._bounds.height.toFixed(1));this.line("parent: "+(n.parent?n.parent.name||"(DisplayObject)":"(none)"));this.stop()},spriteCoords:function(n,t,i,r){this.start(t,i,r,100);n.name&&this.line(n.name);this.line("x:",n.x.toFixed(2),"y:",n.y.toFixed(2));this.line("pos x:",n.position.x.toFixed(2),"pos y:",n.position.y.toFixed(2));this.line("world x:",n.world.x.toFixed(2),"world y:",n.world.y.toFixed(2));this.stop()},lineInfo:function(n,t,i,r){this.start(t,i,r,80);this.line("start.x:",n.start.x.toFixed(2),"start.y:",n.start.y.toFixed(2));this.line("end.x:",n.end.x.toFixed(2),"end.y:",n.end.y.toFixed(2));this.line("length:",n.length.toFixed(2),"angle:",n.angle);this.stop()},pixel:function(n,t,i,r){r=r||2;this.start();this.context.fillStyle=i;this.context.fillRect(n,t,r,r);this.stop()},geom:function(t,i,r,u){void 0===r&&(r=!0);void 0===u&&(u=0);i=i||"rgba(0,255,0,0.4)";this.start();this.context.fillStyle=i;this.context.strokeStyle=i;this.context.lineWidth=this.lineWidth;var f=n.Utils.Debug;u===f.GEOM_RECTANGLE||t instanceof n.Rectangle?r?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):u===f.GEOM_CIRCLE||t instanceof n.Circle?(this.context.beginPath(),this.context.arc(t.x-this.game.camera.x,t.y-this.game.camera.y,t.radius,0,2*Math.PI,!1),this.context.closePath(),r?this.context.fill():this.context.stroke()):u===f.GEOM_POINT||t instanceof n.Point?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,4,4):u===f.GEOM_LINE||t instanceof n.Line?(this.context.beginPath(),this.context.moveTo(t.start.x+.5-this.game.camera.x,t.start.y+.5-this.game.camera.y),this.context.lineTo(t.end.x+.5-this.game.camera.x,t.end.y+.5-this.game.camera.y),this.context.closePath(),this.context.stroke()):(u===f.GEOM_ELLIPSE||t instanceof n.Ellipse)&&(this.context.beginPath(),this.context.ellipse(t.centerX-this.game.camera.x,t.centerY-this.game.camera.y,t.width/2,t.height/2,0,2*Math.PI,!1),this.context.closePath(),r?this.context.fill():this.context.stroke());this.stop()},rectangle:function(n,t,i){void 0===i&&(i=!0);t=t||"rgba(0, 255, 0, 0.4)";this.start();i?(this.context.fillStyle=t,this.context.fillRect(n.x-this.game.camera.x,n.y-this.game.camera.y,n.width,n.height)):(this.context.lineWidth=this.lineWidth,this.context.strokeStyle=t,this.context.strokeRect(n.x-this.game.camera.x,n.y-this.game.camera.y,n.width,n.height));this.stop()},text:function(n,t,i,r,u){r=r||"rgb(255,255,255)";u=u||this.font;this.start();this.context.font=u;this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(n,t+1,i+1));this.context.fillStyle=r;this.context.fillText(n,t,i);this.stop()},quadTree:function(n,t){var r,i;if(t=t||"rgba(255,0,0,0.3)",this.start(),r=n.bounds,0===n.nodes.length)for(this.context.strokeStyle=t,this.context.strokeRect(r.x,r.y,r.width,r.height),this.text("size: "+n.objects.length,r.x+4,r.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)",i=0;i<n.objects.length;i++)this.context.strokeRect(n.objects[i].x,n.objects[i].y,n.objects[i].width,n.objects[i].height);else for(i=0;i<n.nodes.length;i++)this.quadTree(n.nodes[i]);this.stop()},body:function(t,i,r){t.body&&(this.start(),t.body.type===n.Physics.ARCADE?n.Physics.Arcade.Body.render(this.context,t.body,i,r,this.lineWidth):t.body.type===n.Physics.NINJA?n.Physics.Ninja.Body.render(this.context,t.body,i,r):t.body.type===n.Physics.BOX2D&&n.Physics.Box2D.renderBody(this.context,t.body,i),this.stop())},bodyInfo:function(t,i,r,u){t.body&&(this.start(i,r,u,210),t.body.type===n.Physics.ARCADE?n.Physics.Arcade.Body.renderBodyInfo(this,t.body):t.body.type===n.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,t.body),this.stop())},box2dWorld:function(){this.start();this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0);this.game.physics.box2d.renderDebugDraw(this.context);this.stop()},box2dBody:function(t,i){this.start();n.Physics.Box2D.renderBody(this.context,t,i);this.stop()},displayList:function(n){if(void 0===n&&(n=this.game.world),n.hasOwnProperty("renderOrderID")?console.log("["+n.renderOrderID+"]",n):console.log("[]",n),n.children&&n.children.length>0)for(var t=0;t<n.children.length;t++)this.game.debug.displayList(n.children[t])},renderer:function(n,t,i){var r=this.game.renderer,u=r.renderSession,f;if(this.start(n,t,i),this.line((r.gl?"WebGL":"Canvas")+" Renderer ("+r.width+" x "+r.height+")"),this.line("autoResize: "+r.autoResize),this.line("clearBeforeRender: "+r.clearBeforeRender),this.line("resolution: "+r.resolution),this.line("transparent: "+r.transparent),this.line("renderSession:"),r.gl){for(this.line("  currentBatchedTextures: ("+r.currentBatchedTextures.length+")"),f=0;f<r.currentBatchedTextures.length;f++)this.line("    "+r.currentBatchedTextures[f]);this.line("  drawCount: "+u.drawCount);this.line("  maxTextures: "+r.maxTextures);this.line("  maxTextureSize: "+r.maxTextureSize);this.line("  maxTextureAvailableSpace: "+u.maxTextureAvailableSpace);this.line("  roundPixels: "+u.roundPixels)}else this.line("  roundPixels: "+u.roundPixels),this.line("  scaleMode: "+(0===u.scaleMode?"LINEAR":1===u.scaleMode?"NEAREST":u.scaleMode));this.stop()},canvasPool:function(t,i,r,u){var f=n.CanvasPool;this.start(t,i,r,u||100);this.line("Canvas Pool");this.line("Used:",f.getTotal());this.line("Free:",f.getFree());this.line("Total:",f.length);this.stop()},physicsGroup:function(n,t,i,r){n.forEach(this.body,this,r,t,i)},phaser:function(t,i,r){this.text("Phaser v"+n.VERSION+" "+(this.game.renderType===n.WEBGL?"WebGL":"Canvas")+" "+(this.game.device.webAudio?"WebAudio":"HTML Audio"),t,i,r,this.font)},scale:function(t,i,r){this.start(t,i,r);var u=this.game.scale,e=u.scaleFactorInversed,f=u._parentBounds,t=" x ";this.line("Game: "+this.game.width+t+this.game.height);this.line("Canvas: "+u.width+t+u.height+" ("+e.x.toFixed(2)+t+e.y.toFixed(2)+") ["+u.aspectRatio.toFixed(2)+"]");this.line("Mode: "+n.ScaleManager.MODES[u.currentScaleMode]+(u.currentScaleMode===n.ScaleManager.USER_SCALE?" ("+u._userScaleFactor.x+t+u._userScaleFactor.y+")":""));this.line("Parent: "+(u.parentIsWindow?"window":u.parentNode)+(f.empty?"":" ("+f.width+t+f.height+")"));this.line("Screen: "+u.classifyOrientation(u.screenOrientation)+(u.incorrectOrientation?" (incorrect)":""));this.stop()},loader:function(t,i,r,u){var f=n.Utils.pad;this.start(i,r,u);t.hasLoaded?this.line("Complete"+(t.resetLocked?" [locked]":"")):t.isLoading?this.line("Loading"):this.line("Not started");t.hasLoaded&&!t.resetLocked||(this.line("Progress: "+f(t.progress,3)+"%"),this.line("Files: "+t._loadedFileCount+" of "+t._totalFileCount),this.line("Packs: "+t._loadedPackCount+" of "+t._loadedPackCount));this.stop()},device:function(n,t,i){var r=this.game.device;this.start(n,t,i);this.line("Device");this.line("Pointer Events: "+r.mspointer);this.line("Touch: "+r.touch);this.line("Web Audio: "+r.webAudio);this.line("WebGL: "+r.webGL);this.stop()},destroy:function(){n.CanvasPool.remove(this)}},n.Utils.Debug.prototype.constructor=n.Utils.Debug,n.DOM={getOffset:function(t,i){i=i||new n.Point;var r=t.getBoundingClientRect(),u=n.DOM.scrollY,f=n.DOM.scrollX,e=document.documentElement.clientTop,o=document.documentElement.clientLeft;return i.x=r.left+f-o,i.y=r.top+u-e,i},getBounds:function(n,t){return void 0===t&&(t=0),!(!(n=n&&!n.nodeType?n[0]:n)||1!==n.nodeType)&&this.calibrate(n.getBoundingClientRect(),t)},calibrate:function(n,t){t=+t||0;var i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=n.right+t)-(i.left=n.left-t),i.height=(i.bottom=n.bottom+t)-(i.top=n.top-t),i},getAspectRatio:function(n){var t=(n=null==n?this.visualBounds:1===n.nodeType?this.getBounds(n):n).width,i=n.height;return"function"==typeof t&&(t=t.call(n)),"function"==typeof i&&(i=i.call(n)),t/i},inLayoutViewport:function(n,t){var i=this.getBounds(n,t);return!!i&&i.bottom>=0&&i.right>=0&&i.top<=this.layoutBounds.width&&i.left<=this.layoutBounds.height},getScreenOrientation:function(n){var r=window.screen,u=r.orientation||r.mozOrientation||r.msOrientation,t,i;if(u&&"string"==typeof u.type)return u.type;if("string"==typeof u)return u;if(t="portrait-primary",i="landscape-primary","screen"===n)return r.height>r.width?t:i;if("viewport"===n)return this.visualBounds.height>this.visualBounds.width?t:i;if("window.orientation"===n&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?t:i;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return t;if(window.matchMedia("(orientation: landscape)").matches)return i}return this.visualBounds.height>this.visualBounds.width?t:i},visualBounds:new n.Rectangle,layoutBounds:new n.Rectangle,documentBounds:new n.Rectangle},n.Device.whenReady(function(t){var u=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},f=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop},i,r;(Object.defineProperty(n.DOM,"scrollX",{get:u}),Object.defineProperty(n.DOM,"scrollY",{get:f}),Object.defineProperty(n.DOM.visualBounds,"x",{get:u}),Object.defineProperty(n.DOM.visualBounds,"y",{get:f}),Object.defineProperty(n.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(n.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight)?(i=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},r=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)},Object.defineProperty(n.DOM.visualBounds,"width",{get:i}),Object.defineProperty(n.DOM.visualBounds,"height",{get:r}),Object.defineProperty(n.DOM.layoutBounds,"width",{get:i}),Object.defineProperty(n.DOM.layoutBounds,"height",{get:r})):(Object.defineProperty(n.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(n.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(n.DOM.layoutBounds,"width",{get:function(){var n=document.documentElement.clientWidth,t=window.innerWidth;return n<t?t:n}}),Object.defineProperty(n.DOM.layoutBounds,"height",{get:function(){var n=document.documentElement.clientHeight,t=window.innerHeight;return n<t?t:n}}));Object.defineProperty(n.DOM.documentBounds,"x",{value:0});Object.defineProperty(n.DOM.documentBounds,"y",{value:0});Object.defineProperty(n.DOM.documentBounds,"width",{get:function(){var n=document.documentElement;return Math.max(n.clientWidth,n.offsetWidth,n.scrollWidth)}});Object.defineProperty(n.DOM.documentBounds,"height",{get:function(){var n=document.documentElement;return Math.max(n.clientHeight,n.offsetHeight,n.scrollHeight)}})},null,!0),n.ArraySet=function(n){this.position=0;this.list=n||[]},n.ArraySet.prototype={add:function(n){return this.exists(n)||this.list.push(n),n},getIndex:function(n){return this.list.indexOf(n)},getByKey:function(n,t){for(var i=this.list.length;i--;)if(this.list[i][n]===t)return this.list[i];return null},exists:function(n){return this.list.indexOf(n)>-1},reset:function(){this.list.length=0},remove:function(n){var t=this.list.indexOf(n);if(t>-1)return this.list.splice(t,1),n},setAll:function(n,t){for(var i=this.list.length;i--;)this.list[i]&&(this.list[i][n]=t)},callAll:function(n){for(var i=Array.prototype.slice.call(arguments,1),t=this.list.length;t--;)this.list[t]&&this.list[t][n]&&this.list[t][n].apply(this.list[t],i)},removeAll:function(n){var t,i;for(void 0===n&&(n=!1),t=this.list.length;t--;)this.list[t]&&(i=this.remove(this.list[t]),n&&i.destroy());this.position=0;this.list=[]}},Object.defineProperty(n.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(n.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(n.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),n.ArraySet.prototype.constructor=n.ArraySet,n.ArrayUtils={getRandomItem:function(n,t,i){if(null===n)return null;void 0===t&&(t=0);void 0===i&&(i=n.length);var r=t+Math.floor(Math.random()*i);return void 0===n[r]?null:n[r]},removeRandomItem:function(n,t,i){var r,u;return null==n?null:(void 0===t&&(t=0),void 0===i&&(i=n.length),r=t+Math.floor(Math.random()*i),r<n.length)?(u=n.splice(r,1),void 0===u[0]?null:u[0]):null},remove:function(n,t,i){var f=n.length,u,r;if(!(t>=f||0===i)){for(null==i&&(i=1),u=f-i,r=t;r<u;++r)n[r]=n[r+i];n.length=u}},shuffle:function(n){for(var i,r,t=n.length-1;t>0;t--)i=Math.floor(Math.random()*(t+1)),r=n[t],n[t]=n[i],n[i]=r;return n},transposeMatrix:function(n){for(var i,u=n.length,f=n[0].length,r=new Array(f),t=0;t<f;t++)for(r[t]=new Array(u),i=u-1;i>-1;i--)r[t][i]=n[i][t];return r},rotateMatrix:function(t,i){if("string"!=typeof i&&(i=(i%360+360)%360),90===i||-270===i||"rotateLeft"===i)t=(t=n.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===i||270===i||"rotateRight"===i)t=t.reverse(),t=n.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(i)||"rotate180"===i){for(var r=0;r<t.length;r++)t[r].reverse();t=t.reverse()}return t},findClosest:function(n,t){var i,r,u;if(!t.length)return NaN;if(1===t.length||n<t[0])return t[0];for(i=1;t[i]<n;)i++;return r=t[i-1],u=i<t.length?t[i]:Number.POSITIVE_INFINITY,u-n<=n-r?u:r},rotateRight:function(n){var t=n.pop();return n.unshift(t),t},rotateLeft:function(n){var t=n.shift();return n.push(t),t},numberArray:function(n,t){void 0!==t&&null!==t||(t=n,n=0);for(var r=[],i=n;i<=t;i++)r.push(i);return r},numberArrayStep:function(t,i,r){void 0!==t&&null!==t||(t=0);void 0!==i&&null!==i||(i=t,t=0);void 0===r&&(r=1);for(var u=[],e=Math.max(n.Math.roundAwayFromZero((i-t)/(r||1)),0),f=0;f<e;f++)u.push(t),t+=r;return u}},n.LinkedList=function(){this.next=null;this.prev=null;this.first=null;this.last=null;this.total=0},n.LinkedList.prototype={add:function(n){return 0===this.total&&null===this.first&&null===this.last?(this.first=n,this.last=n,this.next=n,n.prev=this,this.total++,n):(this.last.next=n,n.prev=this.last,this.last=n,this.total++,n)},reset:function(){this.first=null;this.last=null;this.next=null;this.prev=null;this.total=0},remove:function(n){if(1===this.total)return this.reset(),void(n.next=n.prev=null);n===this.first?this.first=this.first.next:n===this.last&&(this.last=this.last.prev);n.prev&&(n.prev.next=n.next);n.next&&(n.next.prev=n.prev);n.next=n.prev=null;null===this.first&&(this.last=null);this.total--},callAll:function(n){if(this.first&&this.last){var t=this.first;do t&&t[n]&&t[n].call(t),t=t.next;while(t!==this.last.next)}}},n.LinkedList.prototype.constructor=n.LinkedList,n.Create=function(n){this.game=n;this.bmd=null;this.canvas=null;this.ctx=null;this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},n.Create.PALETTE_ARNE=0,n.Create.PALETTE_JMP=1,n.Create.PALETTE_CGA=2,n.Create.PALETTE_C64=3,n.Create.PALETTE_JAPANESE_MACHINE=4,n.Create.prototype={texture:function(n,t,i,r,u,f,e,o){var a,v,s,l,h,c;for(void 0===i&&(i=8),void 0===r&&(r=i),void 0===u&&(u=0),void 0===f&&(f=!0),a=t[0].length*i,v=t.length*r,null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(a,v),this.bmd.clear(),s=0;s<t.length;s++)for(l=t[s],h=0;h<l.length;h++)c=l[h],"."!==c&&" "!==c&&(this.ctx.fillStyle=this.palettes[u][c],this.ctx.fillRect(h*i,s*r,i,r));return f?this.bmd.generateTexture(n,e,o):this.copy()},grid:function(n,t,i,r,u,f,e,o,s){var h,c;for(void 0===e&&(e=!0),null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(t,i),this.ctx.fillStyle=f,h=0;h<i;h+=u)this.ctx.fillRect(0,h,t,1);for(c=0;c<t;c+=r)this.ctx.fillRect(c,0,1,i);return e?this.bmd.generateTexture(n,o,s):this.copy()},copy:function(n,t,i,r,u,f,e){return null==n&&(n=this.game.make.bitmapData()),n.resize(this.bmd.width,this.bmd.height),n.draw(this.bmd,t,i,r,u,f,e)}},n.Create.prototype.constructor=n.Create,n.FlexGrid=function(t,i,r){this.game=t.game;this.manager=t;this.width=i;this.height=r;this.boundsCustom=new n.Rectangle(0,0,i,r);this.boundsFluid=new n.Rectangle(0,0,i,r);this.boundsFull=new n.Rectangle(0,0,i,r);this.boundsNone=new n.Rectangle(0,0,i,r);this.positionCustom=new n.Point(0,0);this.positionFluid=new n.Point(0,0);this.positionFull=new n.Point(0,0);this.positionNone=new n.Point(0,0);this.scaleCustom=new n.Point(1,1);this.scaleFluid=new n.Point(1,1);this.scaleFluidInversed=new n.Point(1,1);this.scaleFull=new n.Point(1,1);this.scaleNone=new n.Point(1,1);this.customWidth=0;this.customHeight=0;this.customOffsetX=0;this.customOffsetY=0;this.ratioH=i/r;this.ratioV=r/i;this.multiplier=0;this.layers=[]},n.FlexGrid.prototype={setSize:function(t,i){this.width=t;this.height=i;this.ratioH=t/i;this.ratioV=i/t;this.scaleNone=new n.Point(1,1);this.boundsNone.width=this.width;this.boundsNone.height=this.height;this.refresh()},createCustomLayer:function(t,i,r,u){void 0===u&&(u=!0);this.customWidth=t;this.customHeight=i;this.boundsCustom.width=t;this.boundsCustom.height=i;var f=new n.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return u&&this.game.world.add(f),this.layers.push(f),r&&f.addMultiple(r),f},createFluidLayer:function(t,i){void 0===i&&(i=!0);var r=new n.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return i&&this.game.world.add(r),this.layers.push(r),t&&r.addMultiple(t),r},createFullLayer:function(t){var i=new n.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},createFixedLayer:function(t){var i=new n.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},reset:function(){for(var n=this.layers.length;n--;)this.layers[n].persist||(this.layers[n].position=null,this.layers[n].scale=null,this.layers.slice(n,1))},onResize:function(n,t){this.ratioH=n/t;this.ratioV=t/n;this.refresh(n,t)},refresh:function(){this.multiplier=Math.min(this.manager.height/this.height,this.manager.width/this.width);this.boundsFluid.width=Math.round(this.width*this.multiplier);this.boundsFluid.height=Math.round(this.height*this.multiplier);this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height);this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height);this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height);this.boundsFull.width=Math.round(this.manager.width*this.scaleFluidInversed.x);this.boundsFull.height=Math.round(this.manager.height*this.scaleFluidInversed.y);this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY);this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY);this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y);this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(n){this.manager.scaleSprite(n);n.x=this.manager.bounds.centerX;n.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16);this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},n.FlexGrid.prototype.constructor=n.FlexGrid,n.FlexLayer=function(t,i,r,u){n.Group.call(this,t.game,null,"__flexLayer"+t.game.rnd.uuid(),!1);this.manager=t.manager;this.grid=t;this.persist=!1;this.position=i;this.bounds=r;this.scale=u;this.topLeft=r.topLeft;this.topMiddle=new n.Point(r.halfWidth,0);this.topRight=r.topRight;this.bottomLeft=r.bottomLeft;this.bottomMiddle=new n.Point(r.halfWidth,r.bottom);this.bottomRight=r.bottomRight},n.FlexLayer.prototype=Object.create(n.Group.prototype),n.FlexLayer.prototype.constructor=n.FlexLayer,n.FlexLayer.prototype.resize=function(){},n.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16);this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1);this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9");this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9");this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},n.Color={RED:16711680,ORANGE:16750848,YELLOW:16776960,GREEN:65280,AQUA:65535,BLUE:255,VIOLET:16711935,WHITE:16777215,BLACK:0,GRAY:6710886,packPixel:function(t,i,r,u){return n.Device.LITTLE_ENDIAN?(u<<24|r<<16|i<<8|t)>>>0:(t<<24|i<<16|r<<8|u)>>>0},unpackPixel:function(t,i,r,u){return void 0!==i&&null!==i||(i=n.Color.createColor()),void 0!==r&&null!==r||(r=!1),void 0!==u&&null!==u||(u=!1),n.Device.LITTLE_ENDIAN?(i.a=(4278190080&t)>>>24,i.b=(16711680&t)>>>16,i.g=(65280&t)>>>8,i.r=255&t):(i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t),i.color=t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a/255+")",r&&n.Color.RGBtoHSL(i.r,i.g,i.b,i),u&&n.Color.RGBtoHSV(i.r,i.g,i.b,i),i},fromRGBA:function(t,i){return i||(i=n.Color.createColor()),i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a+")",i},toRGBA:function(n,t,i,r){return n<<24|t<<16|i<<8|r},toABGR:function(n,t,i,r){return(r<<24|i<<16|t<<8|n)>>>0},hexToRGBArray:function(n){return[(n>>16&255)/255,(n>>8&255)/255,(255&n)/255]},RGBArrayToHex:function(n){return(255*n[0]<<16)+(255*n[1]<<8)+255*n[2]},RGBtoHSL:function(t,i,r,u){var e,f,o;return u||(u=n.Color.createColor(t,i,r,1)),t/=255,i/=255,r/=255,e=Math.min(t,i,r),f=Math.max(t,i,r),(u.h=0,u.s=0,u.l=(f+e)/2,f!==e)&&(o=f-e,u.s=u.l>.5?o/(2-f-e):o/(f+e),f===t?u.h=(i-r)/o+(i<r?6:0):f===i?u.h=(r-t)/o+2:f===r&&(u.h=(t-i)/o+4),u.h/=6),u},HSLtoRGB:function(t,i,r,u){if(u?(u.r=r,u.g=r,u.b=r):u=n.Color.createColor(r,r,r),0!==i){var f=r<.5?r*(1+i):r+i-r*i,e=2*r-f;u.r=n.Color.hueToColor(e,f,t+1/3);u.g=n.Color.hueToColor(e,f,t);u.b=n.Color.hueToColor(e,f,t-1/3)}return u.r=Math.floor(255*u.r|0),u.g=Math.floor(255*u.g|0),u.b=Math.floor(255*u.b|0),n.Color.updateColor(u),u},RGBtoHSV:function(t,i,r,u){u||(u=n.Color.createColor(t,i,r,255));t/=255;i/=255;r/=255;var o=Math.min(t,i,r),f=Math.max(t,i,r),e=f-o;return u.h=0,u.s=0===f?0:e/f,u.v=f,f!==o&&(f===t?u.h=(i-r)/e+(i<r?6:0):f===i?u.h=(r-t)/e+2:f===r&&(u.h=(t-i)/e+4),u.h/=6),u},HSVtoRGB:function(t,i,r,u){void 0===u&&(u=n.Color.createColor(0,0,0,1,t,i,0,r));var f,e,o,l=Math.floor(6*t),a=6*t-l,s=r*(1-i),h=r*(1-a*i),c=r*(1-(1-a)*i);switch(l%6){case 0:f=r;e=c;o=s;break;case 1:f=h;e=r;o=s;break;case 2:f=s;e=r;o=c;break;case 3:f=s;e=h;o=r;break;case 4:f=c;e=s;o=r;break;case 5:f=r;e=s;o=h}return u.r=Math.floor(255*f),u.g=Math.floor(255*e),u.b=Math.floor(255*o),n.Color.updateColor(u),u},hueToColor:function(n,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?n+6*(t-n)*i:i<.5?t:i<2/3?n+(t-n)*(2/3-i)*6:n},createColor:function(t,i,r,u,f,e,o,s){var h={r:t||0,g:i||0,b:r||0,a:u||1,h:f||0,s:e||0,l:o||0,v:s||0,color:0,color32:0,rgba:""};return n.Color.updateColor(h)},updateColor:function(t){return t.rgba="rgba("+t.r.toFixed()+","+t.g.toFixed()+","+t.b.toFixed()+","+t.a.toString()+")",t.color=n.Color.getColor(t.r,t.g,t.b),t.color32=n.Color.getColor32(255*t.a,t.r,t.g,t.b),t},getColor32:function(n,t,i,r){return n<<24|t<<16|i<<8|r},getColor:function(n,t,i){return n<<16|t<<8|i},RGBtoString:function(t,i,r,u,f){return void 0===u&&(u=255),void 0===f&&(f="#"),"#"===f?"#"+(16777216+(t<<16)+(i<<8)+r).toString(16).slice(1):"0x"+n.Color.componentToHex(u)+n.Color.componentToHex(t)+n.Color.componentToHex(i)+n.Color.componentToHex(r)},hexToRGB:function(t){var i=n.Color.hexToColor(t);if(i)return n.Color.getColor32(i.a,i.r,i.g,i.b)},hexToColor:function(t,i){var r;if(t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(n,t,i,r){return t+t+i+i+r+r}),r=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),r){var u=parseInt(r[1],16),f=parseInt(r[2],16),e=parseInt(r[3],16);i?(i.r=u,i.g=f,i.b=e):i=n.Color.createColor(u,f,e)}return i},webToColor:function(t,i){i||(i=n.Color.createColor());var r=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return r&&(i.r=~~Number(r[1]),i.g=~~Number(r[2]),i.b=~~Number(r[3]),i.a=void 0!==r[4]?Number(r[4]):1,n.Color.updateColor(i)),i},valueToColor:function(t,i){if(i||(i=n.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?n.Color.webToColor(t,i):(i.a=1,n.Color.hexToColor(t,i));if("number"==typeof t){var r=n.Color.getRGB(t);return i.r=r.r,i.g=r.g,i.b=r.b,i.a=r.a/255,i}return i},componentToHex:function(n){var t=n.toString(16);return 1===t.length?"0"+t:t},HSVColorWheel:function(t,i){void 0===t&&(t=1);void 0===i&&(i=1);for(var u=[],r=0;r<=359;r++)u.push(n.Color.HSVtoRGB(r/359,t,i));return u},HSLColorWheel:function(t,i){void 0===t&&(t=.5);void 0===i&&(i=.5);for(var u=[],r=0;r<=359;r++)u.push(n.Color.HSLtoRGB(r/359,t,i));return u},interpolateColor:function(t,i,r,u,f,e){var s,c,b;if(void 0===f&&(f=255),void 0===e&&(e=0),s=n.Color.getRGB(t),c=n.Color.getRGB(i),0===e)var y=(c.red-s.red)*u/r+s.red,p=(c.green-s.green)*u/r+s.green,w=(c.blue-s.blue)*u/r+s.blue;if(1===e){var v,o=n.Color.RGBtoHSV(s.r,s.g,s.b),h=n.Color.RGBtoHSV(c.r,c.g,c.b),l=h.h-o.h;o.h>h.h&&(b=h.h,h.h=o.h,o.h=b,l=-l,u=r-u);l>.5&&(o.h=o.h+1,v=((h.h-o.h)*u/r+o.h)%1);l<=.5&&(v=(h.h-o.h)*u/r+o.h);var k=(h.s-o.s)*u/r+o.s,d=(h.v-o.v)*u/r+o.v,a=n.Color.HSVtoRGB(v,k,d,a),y=a.r,p=a.g,w=a.b}return n.Color.getColor32(f,y,p,w)},interpolateColorWithRGB:function(t,i,r,u,f,e){var o=n.Color.getRGB(t),s=(i-o.red)*e/f+o.red,h=(r-o.green)*e/f+o.green,c=(u-o.blue)*e/f+o.blue;return n.Color.getColor(s,h,c)},interpolateRGB:function(t,i,r,u,f,e,o,s){var h=(u-t)*s/o+t,c=(f-i)*s/o+i,l=(e-r)*s/o+r;return n.Color.getColor(h,c,l)},linear:function(n,t,i){return this.interpolateColor(n,t,1,i)},linearInterpolation:function(t,i){var r=n.Math.linear(0,t.length-1,i),u=t[Math.floor(r)],f=t[Math.ceil(r)];return this.linear(u,f,r%1)},getRandomColor:function(t,i,r){if(void 0===t&&(t=0),void 0===i&&(i=255),void 0===r&&(r=255),i>255||t>i)return n.Color.getColor(255,255,255);var u=t+Math.round(Math.random()*(i-t)),f=t+Math.round(Math.random()*(i-t)),e=t+Math.round(Math.random()*(i-t));return n.Color.getColor32(r,u,f,e)},getRGB:function(n){return n>16777215?{alpha:n>>>24,red:n>>16&255,green:n>>8&255,blue:255&n,a:n>>>24,r:n>>16&255,g:n>>8&255,b:255&n}:{alpha:255,red:n>>16&255,green:n>>8&255,blue:255&n,a:255,r:n>>16&255,g:n>>8&255,b:255&n}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var i=n.Color.getRGB(t);return"rgba("+i.r.toString()+","+i.g.toString()+","+i.b.toString()+","+(i.a/255).toString()+")"},getAlpha:function(n){return n>>>24},getAlphaFloat:function(n){return(n>>>24)/255},getRed:function(n){return n>>16&255},getGreen:function(n){return n>>8&255},getBlue:function(n){return 255&n},blendNormal:function(n){return n},blendLighten:function(n,t){return t>n?t:n},blendDarken:function(n,t){return t>n?n:t},blendMultiply:function(n,t){return n*t/255},blendAverage:function(n,t){return(n+t)/2},blendAdd:function(n,t){return Math.min(255,n+t)},blendSubtract:function(n,t){return Math.max(0,n+t-255)},blendDifference:function(n,t){return Math.abs(n-t)},blendNegation:function(n,t){return 255-Math.abs(255-n-t)},blendScreen:function(n,t){return 255-((255-n)*(255-t)>>8)},blendExclusion:function(n,t){return n+t-2*n*t/255},blendOverlay:function(n,t){return t<128?2*n*t/255:255-2*(255-n)*(255-t)/255},blendSoftLight:function(n,t){return t<128?2*(64+(n>>1))*(t/255):255-2*(255-(64+(n>>1)))*(255-t)/255},blendHardLight:function(t,i){return n.Color.blendOverlay(i,t)},blendColorDodge:function(n,t){return 255===t?t:Math.min(255,(n<<8)/(255-t))},blendColorBurn:function(n,t){return 0===t?t:Math.max(0,255-(255-n<<8)/t)},blendLinearDodge:function(t,i){return n.Color.blendAdd(t,i)},blendLinearBurn:function(t,i){return n.Color.blendSubtract(t,i)},blendLinearLight:function(t,i){return i<128?n.Color.blendLinearBurn(t,2*i):n.Color.blendLinearDodge(t,2*(i-128))},blendVividLight:function(t,i){return i<128?n.Color.blendColorBurn(t,2*i):n.Color.blendColorDodge(t,2*(i-128))},blendPinLight:function(t,i){return i<128?n.Color.blendDarken(t,2*i):n.Color.blendLighten(t,2*(i-128))},blendHardMix:function(t,i){return n.Color.blendVividLight(t,i)<128?0:255},blendReflect:function(n,t){return 255===t?t:Math.min(255,n*n/(255-t))},blendGlow:function(t,i){return n.Color.blendReflect(i,t)},blendPhoenix:function(n,t){return Math.min(n,t)-Math.max(n,t)+255}},n.Physics=function(n,t){t=t||{};this.game=n;this.config=t;this.arcade=null;this.p2=null;this.ninja=null;this.box2d=null;this.chipmunk=null;this.matter=null;this.parseConfig()},n.Physics.ARCADE=0,n.Physics.P2JS=1,n.Physics.NINJA=2,n.Physics.BOX2D=3,n.Physics.CHIPMUNK=4,n.Physics.MATTERJS=5,n.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!n.Physics.hasOwnProperty("Arcade")||(this.arcade=new n.Physics.Arcade(this.game));this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&n.Physics.hasOwnProperty("Ninja")&&(this.ninja=new n.Physics.Ninja(this.game));this.config.hasOwnProperty("p2")&&!0===this.config.p2&&n.Physics.hasOwnProperty("P2")&&(this.p2=new n.Physics.P2(this.game,this.config));this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&n.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new n.Physics.Box2D(this.game,this.config));this.config.hasOwnProperty("matter")&&!0===this.config.matter&&n.Physics.hasOwnProperty("Matter")&&(this.matter=new n.Physics.Matter(this.game,this.config))},startSystem:function(t){t===n.Physics.ARCADE?this.arcade=new n.Physics.Arcade(this.game):t===n.Physics.P2JS?null===this.p2?this.p2=new n.Physics.P2(this.game,this.config):this.p2.reset():t===n.Physics.NINJA?this.ninja=new n.Physics.Ninja(this.game):t===n.Physics.BOX2D?null===this.box2d?this.box2d=new n.Physics.Box2D(this.game,this.config):this.box2d.reset():t===n.Physics.MATTERJS&&(null===this.matter?this.matter=new n.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,i,r){void 0===i&&(i=n.Physics.ARCADE);void 0===r&&(r=!1);i===n.Physics.ARCADE?this.arcade.enable(t):i===n.Physics.P2JS&&this.p2?this.p2.enable(t,r):i===n.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):i===n.Physics.BOX2D&&this.box2d?this.box2d.enable(t):i===n.Physics.MATTERJS&&this.matter?this.matter.enable(t):console.warn(t.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate();this.box2d&&this.box2d.preUpdate();this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update();this.box2d&&this.box2d.update();this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld();this.ninja&&this.ninja.setBoundsToWorld();this.p2&&this.p2.setBoundsToWorld();this.box2d&&this.box2d.setBoundsToWorld();this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear();this.box2d&&this.box2d.clear();this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset();this.box2d&&this.box2d.reset();this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy();this.box2d&&this.box2d.destroy();this.matter&&this.matter.destroy();this.arcade=null;this.ninja=null;this.p2=null;this.box2d=null;this.matter=null}},n.Physics.prototype.constructor=n.Physics,n.Physics.Arcade=function(t){this.game=t;this.gravity=new n.Point;this.bounds=new n.Rectangle(0,0,t.world.width,t.world.height);this.checkCollision={up:!0,down:!0,left:!0,right:!0};this.maxObjects=10;this.maxLevels=4;this.OVERLAP_BIAS=4;this.forceX=!1;this.sortDirection=n.Physics.Arcade.LEFT_RIGHT;this.skipQuadTree=!0;this.isPaused=!1;this.quadTree=new n.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this._total=0;this.setBoundsToWorld()},n.Physics.Arcade.prototype.constructor=n.Physics.Arcade,n.Physics.Arcade.SORT_NONE=0,n.Physics.Arcade.LEFT_RIGHT=1,n.Physics.Arcade.RIGHT_LEFT=2,n.Physics.Arcade.TOP_BOTTOM=3,n.Physics.Arcade.BOTTOM_TOP=4,n.Physics.Arcade.prototype={setBounds:function(n,t,i,r){this.bounds.setTo(n,t,i,r)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,i){void 0===i&&(i=!0);var r=1;if(Array.isArray(t))for(r=t.length;r--;)t[r]instanceof n.Group?this.enable(t[r].children,i):(this.enableBody(t[r]),i&&t[r].hasOwnProperty("children")&&t[r].children.length>0&&this.enable(t[r],!0));else t instanceof n.Group?this.enable(t.children,i):(this.enableBody(t),i&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,!0))},enableBody:function(t){t.hasOwnProperty("body")&&null===t.body&&(t.body=new n.Physics.Arcade.Body(t),t.parent&&t.parent instanceof n.Group&&t.parent.addToHash(t))},updateMotion:function(n){if(n.allowRotation){var t=this.computeVelocity(0,n,n.angularVelocity,n.angularAcceleration,n.angularDrag,n.maxAngular)-n.angularVelocity;n.angularVelocity+=t;n.rotation+=n.angularVelocity*this.game.time.physicsElapsed}n.velocity.x=this.computeVelocity(1,n,n.velocity.x,n.acceleration.x,n.drag.x,n.maxVelocity.x);n.velocity.y=this.computeVelocity(2,n,n.velocity.y,n.acceleration.y,n.drag.y,n.maxVelocity.y)},computeVelocity:function(n,t,i,r,u,f){return void 0===f&&(f=1e4),1===n&&t.allowGravity?i+=(this.gravity.x+t.gravity.x)*this.game.time.physicsElapsed:2===n&&t.allowGravity&&(i+=(this.gravity.y+t.gravity.y)*this.game.time.physicsElapsed),r?i+=r*this.game.time.physicsElapsed:u&&t.allowDrag&&(i-(u*=this.game.time.physicsElapsed)>0?i-=u:i+u<0?i+=u:i=0),i>f?i=f:i<-f&&(i=-f),i},overlap:function(n,t,i,r,u){return i=i||null,r=r||null,u=u||i,this._total=0,this.collideObjects(n,t,i,r,u,!0),this._total>0},collide:function(n,t,i,r,u){return i=i||null,r=r||null,u=u||i,this._total=0,this.collideObjects(n,t,i,r,u,!1),this._total>0},sortLeftRight:function(n,t){return n.body&&t.body?n.body.x-t.body.x:0},sortRightLeft:function(n,t){return n.body&&t.body?t.body.x-n.body.x:0},sortTopBottom:function(n,t){return n.body&&t.body?n.body.y-t.body.y:0},sortBottomTop:function(n,t){return n.body&&t.body?t.body.y-n.body.y:0},sort:function(t,i){null!==t.physicsSortDirection?i=t.physicsSortDirection:void 0===i&&(i=this.sortDirection);i===n.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):i===n.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):i===n.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):i===n.Physics.Arcade.BOTTOM_TOP&&t.hash.sort(this.sortBottomTop)},collideObjects:function(n,t,i,r,u,f){var e,o;if(!Array.isArray(n)&&Array.isArray(t))for(e=0;e<t.length;e++)t[e]&&this.collideHandler(n,t[e],i,r,u,f);else if(Array.isArray(n)&&!Array.isArray(t))for(e=0;e<n.length;e++)n[e]&&this.collideHandler(n[e],t,i,r,u,f);else if(Array.isArray(n)&&Array.isArray(t)){for(e=0;e<n.length;e++)if(n[e])for(o=0;o<t.length;o++)t[o]&&this.collideHandler(n[e],t[o],i,r,u,f)}else this.collideHandler(n,t,i,r,u,f)},collideHandler:function(t,i,r,u,f,e){if(void 0===i&&t.physicsType===n.GROUP)return this.sort(t),void this.collideGroupVsSelf(t,r,u,f,e);t&&i&&t.exists&&i.exists&&(this.sortDirection!==n.Physics.Arcade.SORT_NONE&&(t.physicsType===n.GROUP&&this.sort(t),i.physicsType===n.GROUP&&this.sort(i)),t.physicsType===n.SPRITE?i.physicsType===n.SPRITE?this.collideSpriteVsSprite(t,i,r,u,f,e):i.physicsType===n.GROUP?this.collideSpriteVsGroup(t,i,r,u,f,e):i.physicsType===n.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(t,i,r,u,f,e):t.physicsType===n.GROUP?i.physicsType===n.SPRITE?this.collideSpriteVsGroup(i,t,r,u,f,e):i.physicsType===n.GROUP?this.collideGroupVsGroup(t,i,r,u,f,e):i.physicsType===n.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(t,i,r,u,f,e):t.physicsType===n.TILEMAPLAYER&&(i.physicsType===n.SPRITE?this.collideSpriteVsTilemapLayer(i,t,r,u,f,e):i.physicsType===n.GROUP&&this.collideGroupVsTilemapLayer(i,t,r,u,f,e)))},collideSpriteVsSprite:function(n,t,i,r,u,f){return!(!n.body||!t.body)&&(this.separate(n.body,t.body,r,u,f)&&(i&&i.call(u,n,t),this._total++),!0)},collideSpriteVsGroup:function(t,i,r,u,f,e){var o,h,c,s;if(0!==i.length&&t.body)if(this.skipQuadTree||t.body.skipQuadTree){for(o={},s=0;s<i.hash.length;s++)if(h=i.hash[s],h&&h.exists&&h.body){if(o=h.body.getBounds(o),this.sortDirection===n.Physics.Arcade.LEFT_RIGHT){if(t.body.right<o.x)break;if(o.right<t.body.x)continue}else if(this.sortDirection===n.Physics.Arcade.RIGHT_LEFT){if(t.body.x>o.right)break;if(o.x>t.body.right)continue}else if(this.sortDirection===n.Physics.Arcade.TOP_BOTTOM){if(t.body.bottom<o.y)break;if(o.bottom<t.body.y)continue}else if(this.sortDirection===n.Physics.Arcade.BOTTOM_TOP){if(t.body.y>o.bottom)break;if(o.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,h,r,u,f,e)}}else for(this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(i),c=this.quadTree.retrieve(t),s=0;s<c.length;s++)this.separate(t.body,c[s],u,f,e)&&(r&&r.call(f,t,c[s].sprite),this._total++)},collideGroupVsSelf:function(t,i,r,u,f){var c,o,s,l,e,h;if(0!==t.length)for(c=0;c<t.hash.length;c++)if(o={},s=t.hash[c],s&&s.exists&&s.body)for(o=s.body.getBounds(o),l=c+1;l<t.hash.length;l++)if(e={},h=t.hash[l],h&&h.exists&&h.body){if(e=h.body.getBounds(e),this.sortDirection===n.Physics.Arcade.LEFT_RIGHT){if(o.right<e.x)break;if(e.right<o.x)continue}else if(this.sortDirection===n.Physics.Arcade.RIGHT_LEFT){if(o.x>e.right)continue;if(e.x>o.right)break}else if(this.sortDirection===n.Physics.Arcade.TOP_BOTTOM){if(o.bottom<e.y)continue;if(e.bottom<o.y)break}else if(this.sortDirection===n.Physics.Arcade.BOTTOM_TOP){if(o.y>e.bottom)continue;if(e.y>s.body.bottom)break}this.collideSpriteVsSprite(s,h,i,r,u,f)}},collideGroupVsGroup:function(t,i,r,u,f,e){if(0!==t.length&&0!==i.length)for(var o=0;o<t.children.length;o++)t.children[o].exists&&(t.children[o].physicsType===n.GROUP?this.collideGroupVsGroup(t.children[o],i,r,u,f,e):this.collideSpriteVsGroup(t.children[o],i,r,u,f,e))},separate:function(n,t,i,r,u){var s,h,c;if(!n.enable||!t.enable||n.checkCollision.none||t.checkCollision.none||!this.intersects(n,t)||i&&!1===i.call(r,n.sprite,t.sprite))return!1;if(n.isCircle&&t.isCircle)return this.separateCircle(n,t,u);if(n.isCircle!==t.isCircle){var f=n.isCircle?t:n,l=n.isCircle?n:t,e={x:f.x,y:f.y,right:f.right,bottom:f.bottom},o=l.center;if((o.y<e.y||o.y>e.bottom)&&(o.x<e.x||o.x>e.right))return this.separateCircle(n,t,u)}return s=!1,h=!1,this.forceX||Math.abs(this.gravity.y+n.gravity.y)<Math.abs(this.gravity.x+n.gravity.x)?(s=this.separateX(n,t,u),this.intersects(n,t)&&(h=this.separateY(n,t,u))):(h=this.separateY(n,t,u),this.intersects(n,t)&&(s=this.separateX(n,t,u))),c=s||h,c&&(u?(n.onOverlap&&n.onOverlap.dispatch(n.sprite,t.sprite),t.onOverlap&&t.onOverlap.dispatch(t.sprite,n.sprite)):(n.onCollide&&n.onCollide.dispatch(n.sprite,t.sprite),t.onCollide&&t.onCollide.dispatch(t.sprite,n.sprite))),c},intersects:function(t,i){return t!==i&&(t.isCircle?i.isCircle?n.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y)<=t.halfWidth+i.halfWidth:this.circleBodyIntersects(t,i):i.isCircle?this.circleBodyIntersects(i,t):!(t.right<=i.position.x)&&!(t.bottom<=i.position.y)&&!(t.position.x>=i.right)&&!(t.position.y>=i.bottom))},circleBodyIntersects:function(t,i){var r=n.Math.clamp(t.center.x,i.left,i.right),u=n.Math.clamp(t.center.y,i.top,i.bottom);return(t.center.x-r)*(t.center.x-r)+(t.center.y-u)*(t.center.y-u)<=t.halfWidth*t.halfWidth},separateCircle:function(t,i,r){var e,f;this.getOverlapX(t,i);this.getOverlapY(t,i);var a=i.center.x-t.center.x,v=i.center.y-t.center.y,u=Math.atan2(v,a),o=0;if(t.isCircle!==i.isCircle?(e={x:i.isCircle?t.position.x:i.position.x,y:i.isCircle?t.position.y:i.position.y,right:i.isCircle?t.right:i.right,bottom:i.isCircle?t.bottom:i.bottom},f={x:t.isCircle?t.center.x:i.center.x,y:t.isCircle?t.center.y:i.center.y,radius:t.isCircle?t.halfWidth:i.halfWidth},f.y<e.y?f.x<e.x?o=n.Math.distance(f.x,f.y,e.x,e.y)-f.radius:f.x>e.right&&(o=n.Math.distance(f.x,f.y,e.right,e.y)-f.radius):f.y>e.bottom&&(f.x<e.x?o=n.Math.distance(f.x,f.y,e.x,e.bottom)-f.radius:f.x>e.right&&(o=n.Math.distance(f.x,f.y,e.right,e.bottom)-f.radius)),o*=-1):o=t.halfWidth+i.halfWidth-n.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y),r||0===o||t.immovable&&i.immovable||t.customSeparateX||i.customSeparateX)return 0!==o&&(t.onOverlap&&t.onOverlap.dispatch(t.sprite,i.sprite),i.onOverlap&&i.onOverlap.dispatch(i.sprite,t.sprite)),0!==o;var s={x:t.velocity.x*Math.cos(u)+t.velocity.y*Math.sin(u),y:-t.velocity.x*Math.sin(u)+t.velocity.y*Math.cos(u)},h={x:i.velocity.x*Math.cos(u)+i.velocity.y*Math.sin(u),y:-i.velocity.x*Math.sin(u)+i.velocity.y*Math.cos(u)},c=((t.mass-i.mass)*s.x+2*i.mass*h.x)/(t.mass+i.mass),l=(2*t.mass*s.x+(i.mass-t.mass)*h.x)/(t.mass+i.mass);return t.immovable||(t.velocity.x=(c*Math.cos(u)-s.y*Math.sin(u))*t.bounce.x,t.velocity.y=(s.y*Math.cos(u)+c*Math.sin(u))*t.bounce.y),i.immovable||(i.velocity.x=(l*Math.cos(u)-h.y*Math.sin(u))*i.bounce.x,i.velocity.y=(h.y*Math.cos(u)+l*Math.sin(u))*i.bounce.y),Math.abs(u)<Math.PI/2?t.velocity.x>0&&!t.immovable&&i.velocity.x>t.velocity.x?t.velocity.x*=-1:i.velocity.x<0&&!i.immovable&&t.velocity.x<i.velocity.x?i.velocity.x*=-1:t.velocity.y>0&&!t.immovable&&i.velocity.y>t.velocity.y?t.velocity.y*=-1:i.velocity.y<0&&!i.immovable&&t.velocity.y<i.velocity.y&&(i.velocity.y*=-1):Math.abs(u)>Math.PI/2&&(t.velocity.x<0&&!t.immovable&&i.velocity.x<t.velocity.x?t.velocity.x*=-1:i.velocity.x>0&&!i.immovable&&t.velocity.x>i.velocity.x?i.velocity.x*=-1:t.velocity.y<0&&!t.immovable&&i.velocity.y<t.velocity.y?t.velocity.y*=-1:i.velocity.y>0&&!i.immovable&&t.velocity.x>i.velocity.y&&(i.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed-o*Math.cos(u),t.y+=t.velocity.y*this.game.time.physicsElapsed-o*Math.sin(u)),i.immovable||(i.x+=i.velocity.x*this.game.time.physicsElapsed+o*Math.cos(u),i.y+=i.velocity.y*this.game.time.physicsElapsed+o*Math.sin(u)),t.onCollide&&t.onCollide.dispatch(t.sprite,i.sprite),i.onCollide&&i.onCollide.dispatch(i.sprite,t.sprite),!0},getOverlapX:function(n,t,i){var r=0,u=n.deltaAbsX()+t.deltaAbsX()+this.OVERLAP_BIAS;return 0===n.deltaX()&&0===t.deltaX()?(n.embedded=!0,t.embedded=!0):n.deltaX()>t.deltaX()?(r=n.right-t.x)>u&&!i||!1===n.checkCollision.right||!1===t.checkCollision.left?r=0:(n.touching.none=!1,n.touching.right=!0,t.touching.none=!1,t.touching.left=!0):n.deltaX()<t.deltaX()&&(-(r=n.x-t.width-t.x)>u&&!i||!1===n.checkCollision.left||!1===t.checkCollision.right?r=0:(n.touching.none=!1,n.touching.left=!0,t.touching.none=!1,t.touching.right=!0)),n.overlapX=r,t.overlapX=r,r},getOverlapY:function(n,t,i){var r=0,u=n.deltaAbsY()+t.deltaAbsY()+this.OVERLAP_BIAS;return 0===n.deltaY()&&0===t.deltaY()?(n.embedded=!0,t.embedded=!0):n.deltaY()>t.deltaY()?(r=n.bottom-t.y)>u&&!i||!1===n.checkCollision.down||!1===t.checkCollision.up?r=0:(n.touching.none=!1,n.touching.down=!0,t.touching.none=!1,t.touching.up=!0):n.deltaY()<t.deltaY()&&(-(r=n.y-t.bottom)>u&&!i||!1===n.checkCollision.up||!1===t.checkCollision.down?r=0:(n.touching.none=!1,n.touching.up=!0,t.touching.none=!1,t.touching.down=!0)),n.overlapY=r,t.overlapY=r,r},separateX:function(n,t,i){var r=this.getOverlapX(n,t,i),u,f;if(i||0===r||n.immovable&&t.immovable||n.customSeparateX||t.customSeparateX)return 0!==r||n.embedded&&t.embedded;if(u=n.velocity.x,f=t.velocity.x,n.immovable||t.immovable)n.immovable?(t.x+=r,t.velocity.x=u-f*t.bounce.x,n.moves&&(t.y+=(n.y-n.prev.y)*n.friction.y)):(n.x-=r,n.velocity.x=f-u*n.bounce.x,t.moves&&(n.y+=(t.y-t.prev.y)*t.friction.y));else{r*=.5;n.x-=r;t.x+=r;var o=Math.sqrt(f*f*t.mass/n.mass)*(f>0?1:-1),s=Math.sqrt(u*u*n.mass/t.mass)*(u>0?1:-1),e=.5*(o+s);o-=e;s-=e;n.velocity.x=e+o*n.bounce.x;t.velocity.x=e+s*t.bounce.x}return!0},separateY:function(n,t,i){var r=this.getOverlapY(n,t,i),u,f;if(i||0===r||n.immovable&&t.immovable||n.customSeparateY||t.customSeparateY)return 0!==r||n.embedded&&t.embedded;if(u=n.velocity.y,f=t.velocity.y,n.immovable||t.immovable)n.immovable?(t.y+=r,t.velocity.y=u-f*t.bounce.y,n.moves&&(t.x+=(n.x-n.prev.x)*n.friction.x)):(n.y-=r,n.velocity.y=f-u*n.bounce.y,t.moves&&(n.x+=(t.x-t.prev.x)*t.friction.x));else{r*=.5;n.y-=r;t.y+=r;var o=Math.sqrt(f*f*t.mass/n.mass)*(f>0?1:-1),s=Math.sqrt(u*u*n.mass/t.mass)*(u>0?1:-1),e=.5*(o+s);o-=e;s-=e;n.velocity.y=e+o*n.bounce.y;t.velocity.y=e+s*t.bounce.y}return!0},getObjectsUnderPointer:function(n,t,i,r){if(0!==t.length&&n.exists)return this.getObjectsAtLocation(n.x,n.y,t,i,r,n)},getObjectsAtLocation:function(t,i,r,u,f,e){this.quadTree.clear();this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this.quadTree.populate(r);for(var c=new n.Rectangle(t,i,1,1),h=[],s=this.quadTree.retrieve(c),o=0;o<s.length;o++)s[o].hitTest(t,i)&&(u&&u.call(f,e,s[o].sprite),h.push(s[o].sprite));return h},moveToObject:function(t,i,r,u){void 0===r&&(r=60);void 0===u&&(u=0);var f=n.Point.angle(i,t);return u>0&&(r=this.distanceBetween(t,i)/(u/1e3)),t.body.velocity.setToPolar(f,r),f},moveToPointer:function(n,t,i,r){void 0===t&&(t=60);i=i||this.game.input.activePointer;void 0===r&&(r=0);var u=this.angleToPointer(n,i);return r>0&&(t=this.distanceToPointer(n,i)/(r/1e3)),n.body.velocity.setToPolar(u,t),u},moveToXY:function(n,t,i,r,u){void 0===r&&(r=60);void 0===u&&(u=0);var f=Math.atan2(i-n.y,t-n.x);return u>0&&(r=this.distanceToXY(n,t,i)/(u/1e3)),n.body.velocity.setToPolar(f,r),f},velocityFromAngle:function(t,i,r){return void 0===i&&(i=60),(r=r||new n.Point).setToPolar(t,i,!0)},velocityFromRotation:function(t,i,r){return void 0===i&&(i=60),(r=r||new n.Point).setToPolar(t,i)},accelerationFromRotation:function(t,i,r){return void 0===i&&(i=60),(r=r||new n.Point).setToPolar(t,i)},accelerateToObject:function(n,t,i,r,u){void 0===i&&(i=60);void 0===r&&(r=1e3);void 0===u&&(u=1e3);var f=this.angleBetween(n,t);return n.body.acceleration.setToPolar(f,i),n.body.maxVelocity.setTo(r,u),f},accelerateToPointer:function(n,t,i,r,u){void 0===i&&(i=60);void 0===t&&(t=this.game.input.activePointer);void 0===r&&(r=1e3);void 0===u&&(u=1e3);var f=this.angleToPointer(n,t);return n.body.acceleration.setToPolar(f,i),n.body.maxVelocity.setTo(r,u),f},accelerateToXY:function(n,t,i,r,u,f){void 0===r&&(r=60);void 0===u&&(u=1e3);void 0===f&&(f=1e3);var e=this.angleToXY(n,t,i);return n.body.acceleration.setTo(e,r),n.body.maxVelocity.setTo(u,f),e},distanceBetween:function(n,t,i,r){void 0===i&&(i=!1);var u,f;return r?(u=n.centerX-t.centerX,f=n.centerY-t.centerY):i?(u=n.world.x-t.world.x,f=n.world.y-t.world.y):(u=n.x-t.x,f=n.y-t.y),Math.sqrt(u*u+f*f)},distanceToXY:function(n,t,i,r){void 0===r&&(r=!1);var u=r?n.world.x-t:n.x-t,f=r?n.world.y-i:n.y-i;return Math.sqrt(u*u+f*f)},distanceToPointer:function(n,t,i){void 0===t&&(t=this.game.input.activePointer);void 0===i&&(i=!1);var r=i?n.world.x-t.worldX:n.x-t.worldX,u=i?n.world.y-t.worldY:n.y-t.worldY;return Math.sqrt(r*r+u*u)},closest:function(n,t,i,r){for(var f,e,o=1/0,s=null,u=0,h=t.length;u<h;u++)f=t[u],e=this.distanceBetween(n,f,i,r),e<o&&(s=f,o=e);return s},farthest:function(n,t,i,r){for(var f,e,o=-1,s=null,u=0,h=t.length;u<h;u++)f=t[u],e=this.distanceBetween(n,f,i,r),e>o&&(s=f,o=e);return s},angleBetween:function(t,i,r){return void 0===r&&(r=!1),r?n.Point.angle(i.world,t.world):n.Point.angle(i,t)},angleBetweenCenters:function(n,t){var i=t.centerX-n.centerX,r=t.centerY-n.centerY;return Math.atan2(r,i)},angleToXY:function(n,t,i,r){return void 0===r&&(r=!1),r?Math.atan2(i-n.world.y,t-n.world.x):Math.atan2(i-n.y,t-n.x)},angleToPointer:function(n,t,i){return void 0===t&&(t=this.game.input.activePointer),void 0===i&&(i=!1),i?Math.atan2(t.worldY-n.world.y,t.worldX-n.world.x):Math.atan2(t.worldY-n.y,t.worldX-n.x)},worldAngleToPointer:function(n,t){return this.angleToPointer(n,t,!0)}},n.Physics.Arcade.Body=function(t){this.sprite=t;this.game=t.game;this.type=n.Physics.ARCADE;this.enable=!0;this.isCircle=!1;this.radius=0;this.offset=new n.Point;this.position=new n.Point(t.x,t.y);this.prev=new n.Point(this.position.x,this.position.y);this.allowRotation=!0;this.rotation=t.angle;this.preRotation=t.angle;this.width=t.width;this.height=t.height;this.sourceWidth=t.width;this.sourceHeight=t.height;t.texture&&(this.sourceWidth=t.texture.frame.width,this.sourceHeight=t.texture.frame.height);this.halfWidth=Math.abs(t.width/2);this.halfHeight=Math.abs(t.height/2);this.center=new n.Point(t.x+this.halfWidth,t.y+this.halfHeight);this.velocity=new n.Point;this.newVelocity=new n.Point;this.deltaMax=new n.Point;this.acceleration=new n.Point;this.allowDrag=!0;this.drag=new n.Point;this.allowGravity=!0;this.gravity=new n.Point;this.bounce=new n.Point;this.worldBounce=null;this.onWorldBounds=null;this.onCollide=null;this.onOverlap=null;this.maxVelocity=new n.Point(1e4,1e4);this.friction=new n.Point(1,0);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1e3;this.mass=1;this.angle=0;this.speed=0;this.facing=n.NONE;this.immovable=!1;this.moves=!0;this.customSeparateX=!1;this.customSeparateY=!1;this.overlapX=0;this.overlapY=0;this.overlapR=0;this.embedded=!1;this.collideWorldBounds=!1;this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0};this.touching={none:!0,up:!1,down:!1,left:!1,right:!1};this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1};this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1};this.tilePadding=new n.Point;this.dirty=!1;this.skipQuadTree=!1;this.syncBounds=!1;this.isMoving=!1;this.stopVelocityOnCollide=!0;this.moveTimer=0;this.moveDistance=0;this.moveDuration=0;this.moveTarget=null;this.moveEnd=null;this.onMoveComplete=new n.Signal;this.movementCallback=null;this.movementCallbackContext=null;this._reset=!0;this._sx=t.scale.x;this._sy=t.scale.y;this._dx=0;this._dy=0},n.Physics.Arcade.Body.prototype={updateBounds:function(){var n,t,i;this.syncBounds?(n=this.sprite.getBounds(),n.ceilAll(),n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._reset=!0)):(t=Math.abs(this.sprite.scale.x),i=Math.abs(this.sprite.scale.y),t===this._sx&&i===this._sy||(this.width=this.sourceWidth*t,this.height=this.sourceHeight*i,this._sx=t,this._sy=i,this._reset=!0));this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},preUpdate:function(){this.enable&&!this.game.physics.arcade.isPaused&&(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.updateCenter(),this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=this.velocity.atan()),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},updateMovement:function(){var n=0,i=0!==this.overlapX||0!==this.overlapY,t;return(this.moveDuration>0?(this.moveTimer+=this.game.time.elapsedMS,n=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),n=this.moveTarget.length/this.moveDistance),this.movementCallback)&&(t=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,n)),!(i||n>=1||void 0!==t&&!0!==t)||(this.stopMovement(n>=1||this.stopVelocityOnCollide&&i),!1)},stopMovement:function(n){this.isMoving&&(this.isMoving=!1,n&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,this.deltaX()<0?this.facing=n.LEFT:this.deltaX()>0&&(this.facing=n.RIGHT),this.deltaY()<0?this.facing=n.UP:this.deltaY()>0&&(this.facing=n.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,n=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,r=this.worldBounce?-this.worldBounce.x:-this.bounce.x,u=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.x<n.x&&i.left?(t.x=n.x,this.velocity.x*=r,this.blocked.left=!0,this.blocked.none=!1):this.right>n.right&&i.right&&(t.x=n.right-this.width,this.velocity.x*=r,this.blocked.right=!0,this.blocked.none=!1),t.y<n.y&&i.up?(t.y=n.y,this.velocity.y*=u,this.blocked.up=!0,this.blocked.none=!1):this.bottom>n.bottom&&i.down&&(t.y=n.bottom-this.height,this.velocity.y*=u,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(n,t,i){if(void 0===t&&(t=this.speed),0===t)return!1;var r;return void 0===i?(r=this.angle,i=this.game.math.radToDeg(r)):r=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=n,0===i||180===i?this.velocity.set(Math.cos(r)*t,0):90===i||270===i?this.velocity.set(0,Math.sin(r)*t):this.velocity.setToPolar(r,t),this.isMoving=!0,!0},moveTo:function(t,i,r){var f=i/(t/1e3),u;return 0===f?!1:(void 0===r?(u=this.angle,r=this.game.math.radToDeg(u)):u=this.game.math.degToRad(r),i=Math.abs(i),this.moveDuration=0,this.moveDistance=i,null===this.moveTarget&&(this.moveTarget=new n.Line,this.moveEnd=new n.Point),this.moveTarget.fromAngle(this.x,this.y,u,i),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===r||180===r?this.velocity.set(Math.cos(u)*f,0):90===r||270===r?this.velocity.set(0,Math.sin(u)*f):this.velocity.setToPolar(u,f),this.isMoving=!0,!0)},setSize:function(n,t,i,r){void 0===i&&(i=this.offset.x);void 0===r&&(r=this.offset.y);this.sourceWidth=n;this.sourceHeight=t;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(i,r);this.updateCenter();this.isCircle=!1;this.radius=0},setCircle:function(n,t,i){void 0===t&&(t=this.offset.x);void 0===i&&(i=this.offset.y);n>0?(this.isCircle=!0,this.radius=n,this.sourceWidth=2*n,this.sourceHeight=2*n,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(t,i),this.updateCenter()):this.isCircle=!1},reset:function(n,t){this.stop();this.position.x=n-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x;this.position.x-=this.sprite.scale.x<0?this.width:0;this.position.y=t-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y;this.position.y-=this.sprite.scale.y<0?this.height:0;this.prev.x=this.position.x;this.prev.y=this.position.y;this.rotation=this.sprite.angle;this.preRotation=this.rotation;this.updateBounds();this.updateCenter()},stop:function(){this.velocity.set(0);this.acceleration.set(0);this.speed=0;this.angularVelocity=0;this.angularAcceleration=0},getBounds:function(n){return n.x=this.x,n.y=this.y,n.right=this.right,n.bottom=this.bottom,n},hitTest:function(t,i){return this.isCircle?n.Circle.contains(this,t,i):n.Rectangle.contains(this,t,i)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof n.Group&&this.sprite.parent.removeFromHash(this.sprite);this.sprite.body=null;this.sprite=null}},Object.defineProperty(n.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(n.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(n.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(n.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(n.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(n){this.position.x=n}}),Object.defineProperty(n.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(n){this.position.y=n}}),n.Physics.Arcade.Body.render=function(n,t,i,r,u){void 0===r&&(r=!0);i=i||"rgba(0,255,0,0.4)";n.fillStyle=i;n.strokeStyle=i;n.lineWidth=u||1;t.isCircle?(n.beginPath(),n.arc(t.center.x-t.game.camera.x,t.center.y-t.game.camera.y,t.halfWidth,0,2*Math.PI),r?n.fill():n.stroke()):r?n.fillRect(t.position.x-t.game.camera.x,t.position.y-t.game.camera.y,t.width,t.height):n.strokeRect(t.position.x-t.game.camera.x,t.position.y-t.game.camera.y,t.width,t.height)},n.Physics.Arcade.Body.renderBodyInfo=function(n,t){n.line("x: "+t.x.toFixed(2),"y: "+t.y.toFixed(2),"width: "+t.width,"height: "+t.height);n.line("velocity x: "+t.velocity.x.toFixed(2),"y: "+t.velocity.y.toFixed(2),"deltaX: "+t._dx.toFixed(2),"deltaY: "+t._dy.toFixed(2));n.line("acceleration x: "+t.acceleration.x.toFixed(2),"y: "+t.acceleration.y.toFixed(2),"speed: "+t.speed.toFixed(2),"angle: "+t.angle.toFixed(2));n.line("gravity x: "+t.gravity.x,"y: "+t.gravity.y,"bounce x: "+t.bounce.x.toFixed(2),"y: "+t.bounce.y.toFixed(2));n.line("touching left: "+t.touching.left,"right: "+t.touching.right,"up: "+t.touching.up,"down: "+t.touching.down);n.line("blocked left: "+t.blocked.left,"right: "+t.blocked.right,"up: "+t.blocked.up,"down: "+t.blocked.down)},n.Physics.Arcade.Body.prototype.constructor=n.Physics.Arcade.Body,n.Physics.Arcade.TilemapCollision=function(){},n.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(n,t,i,r,u,f){var o,e;if(n.body&&(o=t.getTiles(n.body.position.x-n.body.tilePadding.x-t.getTileOffsetX(),n.body.position.y-n.body.tilePadding.y-t.getTileOffsetY(),n.body.width+n.body.tilePadding.x,n.body.height+n.body.tilePadding.y,!1,!1),0!==o.length))for(e=0;e<o.length;e++)r?r.call(u,n,o[e])&&this.separateTile(e,n.body,o[e],t,f)&&(this._total++,i&&i.call(u,n,o[e])):this.separateTile(e,n.body,o[e],t,f)&&(this._total++,i&&i.call(u,n,o[e]))},collideGroupVsTilemapLayer:function(n,t,i,r,u,f){if(0!==n.length)for(var e=0;e<n.children.length;e++)n.children[e].exists&&this.collideSpriteVsTilemapLayer(n.children[e],t,i,r,u,f)},separateTile:function(n,t,i,r,u){var f,e;if(!t.enable||(f=r.getTileOffsetX(),e=r.getTileOffsetY(),!i.intersects(t.position.x-f,t.position.y-e,t.right-f,t.bottom-e)))return!1;if(u)return!0;if(i.collisionCallback&&!i.collisionCallback.call(i.collisionCallbackContext,t.sprite,i)||void 0!==i.layer.callbacks&&i.layer.callbacks[i.index]&&!i.layer.callbacks[i.index].callback.call(i.layer.callbacks[i.index].callbackContext,t.sprite,i)||!(i.faceLeft||i.faceRight||i.faceTop||i.faceBottom))return!1;var o=0,s=0,h=0,c=1;if(t.deltaAbsX()>t.deltaAbsY()?h=-1:t.deltaAbsX()<t.deltaAbsY()&&(c=-1),0!==t.deltaX()&&0!==t.deltaY()&&(i.faceLeft||i.faceRight)&&(i.faceTop||i.faceBottom)&&(h=Math.min(Math.abs(t.position.x-f-i.right),Math.abs(t.right-f-i.left)),c=Math.min(Math.abs(t.position.y-e-i.bottom),Math.abs(t.bottom-e-i.top))),h<c){if((i.faceLeft||i.faceRight)&&0!==(o=this.tileCheckX(t,i,r))&&!i.intersects(t.position.x-f,t.position.y-e,t.right-f,t.bottom-e))return!0;(i.faceTop||i.faceBottom)&&(s=this.tileCheckY(t,i,r))}else{if((i.faceTop||i.faceBottom)&&0!==(s=this.tileCheckY(t,i,r))&&!i.intersects(t.position.x-f,t.position.y-e,t.right-f,t.bottom-e))return!0;(i.faceLeft||i.faceRight)&&(o=this.tileCheckX(t,i,r))}return 0!==o||0!==s},tileCheckX:function(n,t,i){var r=0,u=i.getTileOffsetX();return n.deltaX()<0&&!n.blocked.left&&t.collideRight&&n.checkCollision.left?t.faceRight&&n.x-u<t.right&&(r=n.x-u-t.right)<-this.TILE_BIAS&&(r=0):n.deltaX()>0&&!n.blocked.right&&t.collideLeft&&n.checkCollision.right&&t.faceLeft&&n.right-u>t.left&&(r=n.right-u-t.left)>this.TILE_BIAS&&(r=0),0!==r&&(n.customSeparateX?n.overlapX=r:this.processTileSeparationX(n,r)),r},tileCheckY:function(n,t,i){var r=0,u=i.getTileOffsetY();return n.deltaY()<0&&!n.blocked.up&&t.collideDown&&n.checkCollision.up?t.faceBottom&&n.y-u<t.bottom&&(r=n.y-u-t.bottom)<-this.TILE_BIAS&&(r=0):n.deltaY()>0&&!n.blocked.down&&t.collideUp&&n.checkCollision.down&&t.faceTop&&n.bottom-u>t.top&&(r=n.bottom-u-t.top)>this.TILE_BIAS&&(r=0),0!==r&&(n.customSeparateY?n.overlapY=r:this.processTileSeparationY(n,r)),r},processTileSeparationX:function(n,t){t<0?(n.blocked.left=!0,n.blocked.none=!1):t>0&&(n.blocked.right=!0,n.blocked.none=!1);n.position.x-=t;n.velocity.x=0===n.bounce.x?0:-n.velocity.x*n.bounce.x},processTileSeparationY:function(n,t){t<0?(n.blocked.up=!0,n.blocked.none=!1):t>0&&(n.blocked.down=!0,n.blocked.none=!1);n.position.y-=t;n.velocity.y=0===n.bounce.y?0:-n.velocity.y*n.bounce.y}},n.Utils.mixinPrototype(n.Physics.Arcade.prototype,n.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,n.Physics.P2=function(t,i){this.game=t;void 0===i?i={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(i.hasOwnProperty("gravity")||(i.gravity=[0,0]),i.hasOwnProperty("broadphase")||(i.broadphase=new p2.SAPBroadphase));this.config=i;this.world=new p2.World(this.config);this.frameRate=1/60;this.useElapsedTime=!1;this.paused=!1;this.materials=[];this.gravity=new n.Physics.P2.InversePointProxy(this,this.world.gravity);this.walls={left:null,right:null,top:null,bottom:null};this.onBodyAdded=new n.Signal;this.onBodyRemoved=new n.Signal;this.onSpringAdded=new n.Signal;this.onSpringRemoved=new n.Signal;this.onConstraintAdded=new n.Signal;this.onConstraintRemoved=new n.Signal;this.onContactMaterialAdded=new n.Signal;this.onContactMaterialRemoved=new n.Signal;this.postBroadphaseCallback=null;this.callbackContext=null;this.onBeginContact=new n.Signal;this.onEndContact=new n.Signal;i.hasOwnProperty("mpx")&&i.hasOwnProperty("pxm")&&i.hasOwnProperty("mpxi")&&i.hasOwnProperty("pxmi")&&(this.mpx=i.mpx,this.mpxi=i.mpxi,this.pxm=i.pxm,this.pxmi=i.pxmi);this.world.on("beginContact",this.beginContactHandler,this);this.world.on("endContact",this.endContactHandler,this);this.collisionGroups=[];this.nothingCollisionGroup=new n.Physics.P2.CollisionGroup(1);this.boundsCollisionGroup=new n.Physics.P2.CollisionGroup(2);this.everythingCollisionGroup=new n.Physics.P2.CollisionGroup(2147483648);this.boundsCollidesWith=[];this._toRemove=[];this._collisionGroupID=2;this._boundsLeft=!0;this._boundsRight=!0;this._boundsTop=!0;this._boundsBottom=!0;this._boundsOwnGroup=!1;this.setBoundsToWorld(!0,!0,!0,!0,!1)},n.Physics.P2.prototype={removeBodyNextStep:function(n){this._toRemove.push(n)},preUpdate:function(){for(var n=this._toRemove.length;n--;)this.removeBody(this._toRemove[n]);this._toRemove.length=0},enable:function(t,i,r){void 0===i&&(i=!1);void 0===r&&(r=!0);var u=1;if(Array.isArray(t))for(u=t.length;u--;)t[u]instanceof n.Group?this.enable(t[u].children,i,r):(this.enableBody(t[u],i),r&&t[u].hasOwnProperty("children")&&t[u].children.length>0&&this.enable(t[u],i,!0));else t instanceof n.Group?this.enable(t.children,i,r):(this.enableBody(t,i),r&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,i,!0))},enableBody:function(t,i){t.hasOwnProperty("body")&&null===t.body&&(t.body=new n.Physics.P2.Body(this.game,t,t.x,t.y,1),t.body.debug=i,void 0!==t.anchor&&t.anchor.set(.5))},setImpactEvents:function(n){n?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(n,t){this.postBroadphaseCallback=n;this.callbackContext=t;null!==n?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(n){if(this.postBroadphaseCallback&&0!==n.pairs.length)for(var t=n.pairs.length-2;t>=0;t-=2)n.pairs[t].parent&&n.pairs[t+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,n.pairs[t].parent,n.pairs[t+1].parent)&&n.pairs.splice(t,2)},impactHandler:function(n){if(n.bodyA.parent&&n.bodyB.parent){var t=n.bodyA.parent,i=n.bodyB.parent;t._bodyCallbacks[n.bodyB.id]&&t._bodyCallbacks[n.bodyB.id].call(t._bodyCallbackContext[n.bodyB.id],t,i,n.shapeA,n.shapeB);i._bodyCallbacks[n.bodyA.id]&&i._bodyCallbacks[n.bodyA.id].call(i._bodyCallbackContext[n.bodyA.id],i,t,n.shapeB,n.shapeA);t._groupCallbacks[n.shapeB.collisionGroup]&&t._groupCallbacks[n.shapeB.collisionGroup].call(t._groupCallbackContext[n.shapeB.collisionGroup],t,i,n.shapeA,n.shapeB);i._groupCallbacks[n.shapeA.collisionGroup]&&i._groupCallbacks[n.shapeA.collisionGroup].call(i._groupCallbackContext[n.shapeA.collisionGroup],i,t,n.shapeB,n.shapeA)}},beginContactHandler:function(n){n.bodyA&&n.bodyB&&(this.onBeginContact.dispatch(n.bodyA,n.bodyB,n.shapeA,n.shapeB,n.contactEquations),n.bodyA.parent&&n.bodyA.parent.onBeginContact.dispatch(n.bodyB.parent,n.bodyB,n.shapeA,n.shapeB,n.contactEquations),n.bodyB.parent&&n.bodyB.parent.onBeginContact.dispatch(n.bodyA.parent,n.bodyA,n.shapeB,n.shapeA,n.contactEquations))},endContactHandler:function(n){n.bodyA&&n.bodyB&&(this.onEndContact.dispatch(n.bodyA,n.bodyB,n.shapeA,n.shapeB),n.bodyA.parent&&n.bodyA.parent.onEndContact.dispatch(n.bodyB.parent,n.bodyB,n.shapeA,n.shapeB),n.bodyB.parent&&n.bodyB.parent.onEndContact.dispatch(n.bodyA.parent,n.bodyA,n.shapeB,n.shapeA))},setBoundsToWorld:function(n,t,i,r,u){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,n,t,i,r,u)},setWorldMaterial:function(n,t,i,r,u){void 0===t&&(t=!0);void 0===i&&(i=!0);void 0===r&&(r=!0);void 0===u&&(u=!0);t&&this.walls.left&&(this.walls.left.shapes[0].material=n);i&&this.walls.right&&(this.walls.right.shapes[0].material=n);r&&this.walls.top&&(this.walls.top.shapes[0].material=n);u&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=n)},updateBoundsCollisionGroup:function(n){void 0===n&&(n=!0);var t=n?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=t);this.walls.right&&(this.walls.right.shapes[0].collisionGroup=t);this.walls.top&&(this.walls.top.shapes[0].collisionGroup=t);this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=t);this._boundsOwnGroup=n},setBounds:function(n,t,i,r,u,f,e,o,s){void 0===u&&(u=this._boundsLeft);void 0===f&&(f=this._boundsRight);void 0===e&&(e=this._boundsTop);void 0===o&&(o=this._boundsBottom);void 0===s&&(s=this._boundsOwnGroup);this.setupWall(u,"left",n,t,1.5707963267948966,s);this.setupWall(f,"right",n+i,t,-1.5707963267948966,s);this.setupWall(e,"top",n,t,-3.1415926535897931,s);this.setupWall(o,"bottom",n,t+r,0,s);this._boundsLeft=u;this._boundsRight=f;this._boundsTop=e;this._boundsBottom=o;this._boundsOwnGroup=s},setupWall:function(n,t,i,r,u,f){n?(this.walls[t]?this.walls[t].position=[this.pxmi(i),this.pxmi(r)]:(this.walls[t]=new p2.Body({mass:0,position:[this.pxmi(i),this.pxmi(r)],angle:u}),this.walls[t].addShape(new p2.Plane),this.world.addBody(this.walls[t])),f&&(this.walls[t].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[t]&&(this.world.removeBody(this.walls[t]),this.walls[t]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this);this.world.on("endContact",this.endContactHandler,this);this.nothingCollisionGroup=new n.Physics.P2.CollisionGroup(1);this.boundsCollisionGroup=new n.Physics.P2.CollisionGroup(2);this.everythingCollisionGroup=new n.Physics.P2.CollisionGroup(2147483648);this._collisionGroupID=2;this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){var t,i,r,u,n;for(this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations(),t=this.world.constraints,n=t.length-1;n>=0;n--)this.world.removeConstraint(t[n]);for(i=this.world.bodies,n=i.length-1;n>=0;n--)this.world.removeBody(i[n]);for(r=this.world.springs,n=r.length-1;n>=0;n--)this.world.removeSpring(r[n]);for(u=this.world.contactMaterials,n=u.length-1;n>=0;n--)this.world.removeContactMaterial(u[n]);this.world.off("beginContact",this.beginContactHandler,this);this.world.off("endContact",this.endContactHandler,this);this.postBroadphaseCallback=null;this.callbackContext=null;this.impactCallback=null;this.collisionGroups=[];this._toRemove=[];this.boundsCollidesWith=[];this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear();this.game=null},addBody:function(n){return!n.data.world&&(this.world.addBody(n.data),this.onBodyAdded.dispatch(n),!0)},removeBody:function(n){return n.data.world===this.world&&(this.world.removeBody(n.data),this.onBodyRemoved.dispatch(n)),n},addSpring:function(t){return t instanceof n.Physics.P2.Spring||t instanceof n.Physics.P2.RotationalSpring?this.world.addSpring(t.data):this.world.addSpring(t),this.onSpringAdded.dispatch(t),t},removeSpring:function(t){return t instanceof n.Physics.P2.Spring||t instanceof n.Physics.P2.RotationalSpring?this.world.removeSpring(t.data):this.world.removeSpring(t),this.onSpringRemoved.dispatch(t),t},createDistanceConstraint:function(t,i,r,u,f,e){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new n.Physics.P2.DistanceConstraint(this,t,i,r,u,f,e));console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(t,i,r,u){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new n.Physics.P2.GearConstraint(this,t,i,r,u));console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(t,i,r,u,f,e){if(t=this.getBody(t),r=this.getBody(r),t&&r)return this.addConstraint(new n.Physics.P2.RevoluteConstraint(this,t,i,r,u,f,e));console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(t,i,r,u,f){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new n.Physics.P2.LockConstraint(this,t,i,r,u,f));console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(t,i,r,u,f,e,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new n.Physics.P2.PrismaticConstraint(this,t,i,r,u,f,e,o));console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(n){return this.world.addConstraint(n),this.onConstraintAdded.dispatch(n),n},removeConstraint:function(n){return this.world.removeConstraint(n),this.onConstraintRemoved.dispatch(n),n},addContactMaterial:function(n){return this.world.addContactMaterial(n),this.onContactMaterialAdded.dispatch(n),n},removeContactMaterial:function(n){return this.world.removeContactMaterial(n),this.onContactMaterialRemoved.dispatch(n),n},getContactMaterial:function(n,t){return this.world.getContactMaterial(n,t)},setMaterial:function(n,t){for(var i=t.length;i--;)t[i].setMaterial(n)},createMaterial:function(t,i){t=t||"";var r=new n.Physics.P2.Material(t);return this.materials.push(r),void 0!==i&&i.setMaterial(r),r},createContactMaterial:function(t,i,r){void 0===t&&(t=this.createMaterial());void 0===i&&(i=this.createMaterial());var u=new n.Physics.P2.ContactMaterial(t,i,r);return this.addContactMaterial(u)},getBodies:function(){for(var n=[],t=this.world.bodies.length;t--;)n.push(this.world.bodies[t].parent);return n},getBody:function(t){return t instanceof p2.Body?t:t instanceof n.Physics.P2.Body?t.data:t.body&&t.body.type===n.Physics.P2JS?t.body.data:null},getSprings:function(){for(var n=[],t=this.world.springs.length;t--;)n.push(this.world.springs[t].parent);return n},getConstraints:function(){for(var n=[],t=this.world.constraints.length;t--;)n.push(this.world.constraints[t]);return n},hitTest:function(t,i,r,u){void 0===i&&(i=this.world.bodies);void 0===r&&(r=5);void 0===u&&(u=!1);for(var o=[this.pxmi(t.x),this.pxmi(t.y)],e=[],f=i.length;f--;)i[f]instanceof n.Physics.P2.Body&&(!u||i[f].data.type!==p2.Body.STATIC)?e.push(i[f].data):i[f]instanceof p2.Body&&i[f].parent&&(!u||i[f].type!==p2.Body.STATIC)?e.push(i[f]):i[f]instanceof n.Sprite&&i[f].hasOwnProperty("body")&&(!u||i[f].body.data.type!==p2.Body.STATIC)&&e.push(i[f].body.data);return this.world.hitTest(o,e,r)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(t){var i=Math.pow(2,this._collisionGroupID),r;return this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|i),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|i),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|i),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|i),this._collisionGroupID++,r=new n.Physics.P2.CollisionGroup(i),this.collisionGroups.push(r),t&&this.setCollisionGroup(t,r),r},setCollisionGroup:function(t,i){if(t instanceof n.Group)for(var r=0;r<t.total;r++)t.children[r].body&&t.children[r].body.type===n.Physics.P2JS&&t.children[r].body.setCollisionGroup(i);else t.body.setCollisionGroup(i)},createSpring:function(t,i,r,u,f,e,o,s,h){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new n.Physics.P2.Spring(this,t,i,r,u,f,e,o,s,h));console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(t,i,r,u,f){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new n.Physics.P2.RotationalSpring(this,t,i,r,u,f));console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(t,i,r,u,f,e){void 0===u&&(u=!1);var o=new n.Physics.P2.Body(this.game,null,t,i,r);return!(e&&!o.addPolygon(f,e))&&(u&&this.world.addBody(o.data),o)},createParticle:function(t,i,r,u,f,e){void 0===u&&(u=!1);var o=new n.Physics.P2.Body(this.game,null,t,i,r);return!(e&&!o.addPolygon(f,e))&&(u&&this.world.addBody(o.data),o)},convertCollisionObjects:function(n,t,i){var r,e,u;void 0===i&&(i=!0);for(var o=[],f=0,s=n.collision[t].length;f<s;f++)r=n.collision[t][f],e=r.polyline||r.polygon,e?u=this.createBody(r.x,r.y,0,i,{},e):r.rectangle&&(u=this.createBody(r.x,r.y,0,i)).addRectangle(r.width,r.height,r.width/2,r.height/2),u&&o.push(u);return o},clearTilemapLayerBodies:function(n,t){t=n.getLayer(t);for(var i=n.layers[t].bodies.length;i--;)n.layers[t].bodies[i].destroy();n.layers[t].bodies.length=0},convertTilemap:function(n,t,i,r){var o,a,u,h,e;t=n.getLayer(t);void 0===i&&(i=!0);void 0===r&&(r=!0);this.clearTilemapLayerBodies(n,t);for(var f=0,c=0,l=0,s=0,v=n.layers[t].height;s<v;s++)for(f=0,o=0,a=n.layers[t].width;o<a;o++)u=n.layers[t].data[s][o],u&&u.index>-1&&u.collides&&(r?(h=n.getTileRight(t,o,s),0===f&&(c=u.x*u.width,l=u.y*u.height,f=u.width),h&&h.collides?f+=u.width:((e=this.createBody(c,l,0,!1)).addRectangle(f,u.height,f/2,u.height/2,0),i&&this.addBody(e),n.layers[t].bodies.push(e),f=0)):(e=this.createBody(u.x*u.width,u.y*u.height,0,!1),e.addRectangle(u.width,u.height,u.width/2,u.height/2,0),i&&this.addBody(e),n.layers[t].bodies.push(e)));return n.layers[t].bodies},mpx:function(n){return n*20},pxm:function(n){return.05*n},mpxi:function(n){return n*-20},pxmi:function(n){return-.05*n}},Object.defineProperty(n.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(n){this.world.defaultContactMaterial.friction=n}}),Object.defineProperty(n.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(n){this.world.defaultContactMaterial.restitution=n}}),Object.defineProperty(n.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(n){this.world.defaultContactMaterial=n}}),Object.defineProperty(n.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(n){this.world.applySpringForces=n}}),Object.defineProperty(n.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(n){this.world.applyDamping=n}}),Object.defineProperty(n.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(n){this.world.applyGravity=n}}),Object.defineProperty(n.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(n){this.world.solveConstraints=n}}),Object.defineProperty(n.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(n.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(n){this.world.emitImpactEvent=n}}),Object.defineProperty(n.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(n){this.world.sleepMode=n}}),Object.defineProperty(n.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),n.Physics.P2.FixtureList=function(n){Array.isArray(n)||(n=[n]);this.rawList=n;this.init();this.parse(this.rawList)},n.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={};this.groupedFixtures=[];this.allFixtures=[]},setCategory:function(n,t){this.getFixtures(t).forEach(function(t){t.collisionGroup=n})},setMask:function(n,t){this.getFixtures(t).forEach(function(t){t.collisionMask=n})},setSensor:function(n,t){this.getFixtures(t).forEach(function(t){t.sensor=n})},setMaterial:function(n,t){this.getFixtures(t).forEach(function(t){t.material=n})},getFixtures:function(n){var i=[],t;return n?(n instanceof Array||(n=[n]),t=this,n.forEach(function(n){t.namedFixtures[n]&&i.push(t.namedFixtures[n])}),this.flatten(i)):this.allFixtures},getFixtureByKey:function(n){return this.namedFixtures[n]},getGroup:function(n){return this.groupedFixtures[n]},parse:function(){var n,t,i,r;i=this.rawList;r=[];for(n in i)t=i[n],isNaN(+n)?this.namedFixtures[n]=this.flatten(t):(this.groupedFixtures[n]=this.groupedFixtures[n]||[],this.groupedFixtures[n]=this.groupedFixtures[n].concat(t)),r.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(n){var t,i;return t=[],i=arguments.callee,n.forEach(function(n){return Array.prototype.push.apply(t,Array.isArray(n)?i(n):[n])}),t}},n.Physics.P2.PointProxy=function(n,t){this.world=n;this.destination=t},n.Physics.P2.PointProxy.prototype.constructor=n.Physics.P2.PointProxy,Object.defineProperty(n.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(n){this.destination[0]=this.world.pxm(n)}}),Object.defineProperty(n.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(n){this.destination[1]=this.world.pxm(n)}}),Object.defineProperty(n.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(n){this.destination[0]=n}}),Object.defineProperty(n.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(n){this.destination[1]=n}}),n.Physics.P2.InversePointProxy=function(n,t){this.world=n;this.destination=t},n.Physics.P2.InversePointProxy.prototype.constructor=n.Physics.P2.InversePointProxy,Object.defineProperty(n.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(n){this.destination[0]=this.world.pxmi(n)}}),Object.defineProperty(n.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(n){this.destination[1]=this.world.pxmi(n)}}),Object.defineProperty(n.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(n){this.destination[0]=-n}}),Object.defineProperty(n.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(n){this.destination[1]=-n}}),n.Physics.P2.Body=function(t,i,r,u,f){i=i||null;r=r||0;u=u||0;void 0===f&&(f=1);this.game=t;this.world=t.physics.p2;this.sprite=i;this.type=n.Physics.P2JS;this.offset=new n.Point;this.data=new p2.Body({position:[this.world.pxmi(r),this.world.pxmi(u)],mass:f});this.data.parent=this;this.velocity=new n.Physics.P2.InversePointProxy(this.world,this.data.velocity);this.force=new n.Physics.P2.InversePointProxy(this.world,this.data.force);this.gravity=new n.Point;this.onBeginContact=new n.Signal;this.onEndContact=new n.Signal;this.collidesWith=[];this.removeNextStep=!1;this.debugBody=null;this.dirty=!1;this._collideWorldBounds=!0;this._bodyCallbacks={};this._bodyCallbackContext={};this._groupCallbacks={};this._groupCallbackContext={};this._reset=!1;i&&(this.setRectangleFromSprite(i),i.exists&&this.game.physics.p2.addBody(this))},n.Physics.P2.Body.prototype={createBodyCallback:function(n,t,i){var r=-1;n.id?r=n.id:n.body&&(r=n.body.id);r>-1&&(null===t?(delete this._bodyCallbacks[r],delete this._bodyCallbackContext[r]):(this._bodyCallbacks[r]=t,this._bodyCallbackContext[r]=i))},createGroupCallback:function(n,t,i){null===t?(delete this._groupCallbacks[n.mask],delete this._groupCallbackContext[n.mask]):(this._groupCallbacks[n.mask]=t,this._groupCallbackContext[n.mask]=i)},getCollisionMask:function(){var t=0,n;for(this._collideWorldBounds&&(t=this.game.physics.p2.boundsCollisionGroup.mask),n=0;n<this.collidesWith.length;n++)t|=this.collidesWith[n].mask;return t},updateCollisionMask:function(n){var i=this.getCollisionMask(),t;if(void 0===n)for(t=this.data.shapes.length-1;t>=0;t--)this.data.shapes[t].collisionMask=i;else n.collisionMask=i},setCollisionGroup:function(n,t){var r=this.getCollisionMask(),i;if(void 0===t)for(i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].collisionGroup=n.mask,this.data.shapes[i].collisionMask=r;else t.collisionGroup=n.mask,t.collisionMask=r},clearCollision:function(n,t,i){if(void 0===n&&(n=!0),void 0===t&&(t=!0),void 0===i)for(var r=this.data.shapes.length-1;r>=0;r--)n&&(this.data.shapes[r].collisionGroup=null),t&&(this.data.shapes[r].collisionMask=null);else n&&(i.collisionGroup=null),t&&(i.collisionMask=null);n&&(this.collidesWith.length=0)},removeCollisionGroup:function(n,t,i){var u,f,r;if(void 0===t&&(t=!0),Array.isArray(n))for(r=0;r<n.length;r++)(u=this.collidesWith.indexOf(n[r]))>-1&&(this.collidesWith.splice(u,1),t&&(delete this._groupCallbacks[n.mask],delete this._groupCallbackContext[n.mask]));else(u=this.collidesWith.indexOf(n))>-1&&(this.collidesWith.splice(u,1),t&&(delete this._groupCallbacks[n.mask],delete this._groupCallbackContext[n.mask]));if(f=this.getCollisionMask(),void 0===i)for(r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=f;else i.collisionMask=f},collides:function(n,t,i,r){var f,u;if(Array.isArray(n))for(u=0;u<n.length;u++)-1===this.collidesWith.indexOf(n[u])&&(this.collidesWith.push(n[u]),t&&this.createGroupCallback(n[u],t,i));else-1===this.collidesWith.indexOf(n)&&(this.collidesWith.push(n),t&&this.createGroupCallback(n,t,i));if(f=this.getCollisionMask(),void 0===r)for(u=this.data.shapes.length-1;u>=0;u--)this.data.shapes[u].collisionMask=f;else r.collisionMask=f},adjustCenterOfMass:function(){this.data.adjustCenterOfMass();this.shapeChanged()},getVelocityAtPoint:function(n,t){return this.data.getVelocityAtPoint(n,t)},applyDamping:function(n){this.data.applyDamping(n)},applyImpulse:function(n,t,i){this.data.applyImpulse(n,[this.world.pxmi(t),this.world.pxmi(i)])},applyImpulseLocal:function(n,t,i){this.data.applyImpulseLocal(n,[this.world.pxmi(t),this.world.pxmi(i)])},applyForce:function(n,t,i){this.data.applyForce(n,[this.world.pxmi(t),this.world.pxmi(i)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0;this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0;this.data.angularDamping=0},toLocalFrame:function(n,t){return this.data.toLocalFrame(n,t)},toWorldFrame:function(n,t){return this.data.toWorldFrame(n,t)},rotateLeft:function(n){this.data.angularVelocity=this.world.pxm(-n)},rotateRight:function(n){this.data.angularVelocity=this.world.pxm(n)},moveForward:function(n){var t=this.world.pxmi(-n),i=this.data.angle+Math.PI/2;this.data.velocity[0]=t*Math.cos(i);this.data.velocity[1]=t*Math.sin(i)},moveBackward:function(n){var t=this.world.pxmi(-n),i=this.data.angle+Math.PI/2;this.data.velocity[0]=-t*Math.cos(i);this.data.velocity[1]=-t*Math.sin(i)},thrust:function(n){var t=this.world.pxmi(-n),i=this.data.angle+Math.PI/2;this.data.force[0]+=t*Math.cos(i);this.data.force[1]+=t*Math.sin(i)},thrustLeft:function(n){var t=this.world.pxmi(-n),i=this.data.angle;this.data.force[0]+=t*Math.cos(i);this.data.force[1]+=t*Math.sin(i)},thrustRight:function(n){var t=this.world.pxmi(-n),i=this.data.angle;this.data.force[0]-=t*Math.cos(i);this.data.force[1]-=t*Math.sin(i)},reverse:function(n){var t=this.world.pxmi(-n),i=this.data.angle+Math.PI/2;this.data.force[0]-=t*Math.cos(i);this.data.force[1]-=t*Math.sin(i)},moveLeft:function(n){this.data.velocity[0]=this.world.pxmi(-n)},moveRight:function(n){this.data.velocity[0]=this.world.pxmi(n)},moveUp:function(n){this.data.velocity[1]=this.world.pxmi(-n)},moveDown:function(n){this.data.velocity[1]=this.world.pxmi(n)},preUpdate:function(){this.dirty=!0;this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x;this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y;this.fixedRotation||(this.sprite.rotation=this.data.angle);this.debugBody&&this.debugBody.updateSpriteTransform();this.dirty=!1},reset:function(n,t,i,r){void 0===i&&(i=!1);void 0===r&&(r=!1);this.setZeroForce();this.setZeroVelocity();this.setZeroRotation();i&&this.setZeroDamping();r&&(this.mass=1);this.x=n;this.y=t},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var n=0;n<this.game.physics.p2._toRemove.length;n++)this.game.physics.p2._toRemove[n]===this&&this.game.physics.p2._toRemove.splice(n,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld();this.clearShapes();this._bodyCallbacks={};this._bodyCallbackContext={};this._groupCallbacks={};this._groupCallbackContext={};this.debugBody&&this.debugBody.destroy(!0,!0);this.debugBody=null;this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var n=this.data.shapes.length;n--;)this.data.removeShape(this.data.shapes[n]);this.shapeChanged()},addShape:function(n,t,i,r){return void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.data.addShape(n,[this.world.pxmi(t),this.world.pxmi(i)],r),this.shapeChanged(),n},addCircle:function(n,t,i,r){var u=new p2.Circle({radius:this.world.pxm(n)});return this.addShape(u,t,i,r)},addRectangle:function(n,t,i,r,u){var f=new p2.Box({width:this.world.pxm(n),height:this.world.pxm(t)});return this.addShape(f,i,r,u)},addPlane:function(n,t,i){var r=new p2.Plane;return this.addShape(r,n,t,i)},addParticle:function(n,t,i){var r=new p2.Particle;return this.addShape(r,n,t,i)},addLine:function(n,t,i,r){var u=new p2.Line({length:this.world.pxm(n)});return this.addShape(u,t,i,r)},addCapsule:function(n,t,i,r,u){var f=new p2.Capsule({length:this.world.pxm(n),radius:this.world.pxm(t)});return this.addShape(f,i,r,u)},addPolygon:function(n,t){var i,u,e,f,r,o;if(n=n||{},Array.isArray(t)||(t=Array.prototype.slice.call(arguments,1)),i=[],1===t.length&&Array.isArray(t[0]))i=t[0].slice(0);else if(Array.isArray(t[0]))i=t.slice();else if("number"==typeof t[0])for(u=0,e=t.length;u<e;u+=2)i.push([t[u],t[u+1]]);for(f=i.length-1,i[f][0]===i[0][0]&&i[f][1]===i[0][1]&&i.pop(),r=0;r<i.length;r++)i[r][0]=this.world.pxmi(i[r][0]),i[r][1]=this.world.pxmi(i[r][1]);return o=this.data.fromPolygon(i,n),this.shapeChanged(),o},removeShape:function(n){var t=this.data.removeShape(n);return this.shapeChanged(),t},setCircle:function(n,t,i,r){return this.clearShapes(),this.addCircle(n,t,i,r)},setRectangle:function(n,t,i,r,u){return void 0===n&&(n=16),void 0===t&&(t=16),this.clearShapes(),this.addRectangle(n,t,i,r,u)},setRectangleFromSprite:function(n){return void 0===n&&(n=this.sprite),this.clearShapes(),this.addRectangle(n.width,n.height,0,0,n.rotation)},setMaterial:function(n,t){if(void 0===t)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].material=n;else t.material=n},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(n,t){for(var i,f,e=this.game.cache.getPhysicsData(n,t),r=[],u=0;u<e.length;u++)i=e[u],f=this.addFixture(i),r[i.filter.group]=r[i.filter.group]||[],r[i.filter.group]=r[i.filter.group].concat(f),i.fixtureKey&&(r[i.fixtureKey]=f);return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),r},addFixture:function(n){var e=[],i,t,f,h;if(n.circle)(t=new p2.Circle({radius:this.world.pxm(n.circle.radius)})).collisionGroup=n.filter.categoryBits,t.collisionMask=n.filter.maskBits,t.sensor=n.isSensor,i=p2.vec2.create(),i[0]=this.world.pxmi(n.circle.position[0]-this.sprite.width/2),i[1]=this.world.pxmi(n.circle.position[1]-this.sprite.height/2),this.data.addShape(t,i),e.push(t);else for(var c=n.polygons,r=p2.vec2.create(),o=0;o<c.length;o++){for(var s=c[o],l=[],u=0;u<s.length;u+=2)l.push([this.world.pxmi(s[u]),this.world.pxmi(s[u+1])]);for(t=new p2.Convex({vertices:l}),f=0;f!==t.vertices.length;f++)h=t.vertices[f],p2.vec2.sub(h,h,t.centerOfMass);p2.vec2.scale(r,t.centerOfMass,1);r[0]-=this.world.pxmi(this.sprite.width/2);r[1]-=this.world.pxmi(this.sprite.height/2);t.updateTriangles();t.updateCenterOfMass();t.updateBoundingRadius();t.collisionGroup=n.filter.categoryBits;t.collisionMask=n.filter.maskBits;t.sensor=n.isSensor;this.data.addShape(t,r);e.push(t)}return e},loadPolygon:function(n,t,i){var f,e,u,h,o,r,s,c;for(f=null===n?t:this.game.cache.getPhysicsData(n,t),"number"!=typeof i&&(i=1),e=p2.vec2.create(),u=0;u<f.length;u++){for(h=[],o=0;o<f[u].shape.length;o+=2)h.push([this.world.pxmi(f[u].shape[o]*i),this.world.pxmi(f[u].shape[o+1]*i)]);for(r=new p2.Convex({vertices:h}),s=0;s!==r.vertices.length;s++)c=r.vertices[s],p2.vec2.sub(c,c,r.centerOfMass);p2.vec2.scale(e,r.centerOfMass,1);e[0]-=this.world.pxmi(this.sprite.width/2);e[1]-=this.world.pxmi(this.sprite.height/2);r.updateTriangles();r.updateCenterOfMass();r.updateBoundingRadius();this.data.addShape(r,e)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},n.Physics.P2.Body.prototype.constructor=n.Physics.P2.Body,n.Physics.P2.Body.DYNAMIC=1,n.Physics.P2.Body.STATIC=2,n.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(n.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===n.Physics.P2.Body.STATIC},set:function(t){t&&this.data.type!==n.Physics.P2.Body.STATIC?(this.data.type=n.Physics.P2.Body.STATIC,this.mass=0):t||this.data.type!==n.Physics.P2.Body.STATIC||(this.data.type=n.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===n.Physics.P2.Body.DYNAMIC},set:function(t){t&&this.data.type!==n.Physics.P2.Body.DYNAMIC?(this.data.type=n.Physics.P2.Body.DYNAMIC,this.mass=1):t||this.data.type!==n.Physics.P2.Body.DYNAMIC||(this.data.type=n.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===n.Physics.P2.Body.KINEMATIC},set:function(t){t&&this.data.type!==n.Physics.P2.Body.KINEMATIC?(this.data.type=n.Physics.P2.Body.KINEMATIC,this.mass=4):t||this.data.type!==n.Physics.P2.Body.KINEMATIC||(this.data.type=n.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(n){n!==this.data.allowSleep&&(this.data.allowSleep=n)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"angle",{get:function(){return n.Math.wrapAngle(n.Math.radToDeg(this.data.angle))},set:function(t){this.data.angle=n.Math.degToRad(n.Math.wrapAngle(t))}}),Object.defineProperty(n.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(n){this.data.angularDamping=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(n){this.data.angularForce=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(n){this.data.angularVelocity=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(n){this.data.damping=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(n){n!==this.data.fixedRotation&&(this.data.fixedRotation=n)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(n){this.data.inertia=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(n){n!==this.data.mass&&(this.data.mass=n,this.data.updateMassProperties())}}),Object.defineProperty(n.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(n){n!==this.data.type&&(this.data.type=n)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(n){this.data.angle=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(n){this.data.sleepSpeedLimit=n}}),Object.defineProperty(n.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(n){this.data.position[0]=this.world.pxmi(n)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(n){this.data.position[1]=this.world.pxmi(n)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(n.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(t){t&&!this.debugBody?this.debugBody=new n.Physics.P2.BodyDebug(this.game,this.data):!t&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(n.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(n){n&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!n&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),n.Physics.P2.BodyDebug=function(t,i,r){n.Group.call(this,t);var u={pixelsPerLengthUnit:t.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=Object.assign(u,r);this.ppu=this.settings.pixelsPerLengthUnit;this.ppu=-1*this.ppu;this.body=i;this.canvas=new n.Graphics(t);this.canvas.alpha=this.settings.alpha;this.add(this.canvas);this.draw();this.updateSpriteTransform()},n.Physics.P2.BodyDebug.prototype=Object.create(n.Group.prototype),n.Physics.P2.BodyDebug.prototype.constructor=n.Physics.P2.BodyDebug,Object.assign(n.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu;this.position.y=this.body.position[1]*this.ppu;this.rotation=this.body.angle},draw:function(){var u,n,f,h,l,i,e,t,r,v,a,c,o,s,y;if(e=this.body,(r=this.canvas).clear(),f=parseInt(this.randomPastelHex(),16),i=this.lineWidth,e instanceof p2.Body&&e.shapes.length)for(y=e.shapes.length,h=0;h!==y;){if(n=e.shapes[h],t=n.position||0,u=n.angle||0,n instanceof p2.Circle)this.drawCircle(r,t[0]*this.ppu,t[1]*this.ppu,u,n.radius*this.ppu,f,i);else if(n instanceof p2.Capsule)this.drawCapsule(r,t[0]*this.ppu,t[1]*this.ppu,u,n.length*this.ppu,n.radius*this.ppu,16711680,f,i);else if(n instanceof p2.Plane)this.drawPlane(r,t[0]*this.ppu,-t[1]*this.ppu,f,16711680,5*i,10*i,10*i,100*this.ppu,u);else if(n instanceof p2.Line)this.drawLine(r,n.length*this.ppu,16711680,i);else if(n instanceof p2.Box)this.drawRectangle(r,t[0]*this.ppu,t[1]*this.ppu,u,n.width*this.ppu,n.height*this.ppu,16711680,f,i);else if(n instanceof p2.Convex){for(a=[],c=p2.vec2.create(),l=o=0,s=n.vertices.length;s>=0?o<s:o>s;l=s>=0?++o:--o)v=n.vertices[l],p2.vec2.rotate(c,v,u),a.push([(c[0]+t[0])*this.ppu,-(c[1]+t[1])*this.ppu]);this.drawConvex(r,a,n.triangles,16711680,f,i,this.settings.debugPolygons,[t[0]*this.ppu,-t[1]*this.ppu])}h++}},drawRectangle:function(n,t,i,r,u,f,e,o,s){void 0===s&&(s=1);void 0===e&&(e=0);n.lineStyle(s,e,1);n.beginFill(o);n.drawRect(t-u/2,i-f/2,u,f)},drawCircle:function(n,t,i,r,u,f,e){void 0===e&&(e=1);void 0===f&&(f=16777215);n.lineStyle(e,0,1);n.beginFill(f,1);n.drawCircle(t,i,2*-u);n.endFill();n.moveTo(t,i);n.lineTo(t+u*Math.cos(-r),i+u*Math.sin(-r))},drawLine:function(n,t,i,r){void 0===r&&(r=1);void 0===i&&(i=0);n.lineStyle(5*r,i,1);n.moveTo(-t/2,0);n.lineTo(t/2,0)},drawConvex:function(n,t,i,r,u,f,e,o){var h,s,w,c,l,a,v,b,y,p,k;if(void 0===f&&(f=1),void 0===r&&(r=0),e){for(h=[16711680,65280,255],s=0;s!==t.length+1;)c=t[s%t.length],l=t[(s+1)%t.length],v=c[0],p=c[1],b=l[0],k=l[1],n.lineStyle(f,h[s%h.length],1),n.moveTo(v,-p),n.lineTo(b,-k),n.drawCircle(v,-p,2*f),s++;return n.lineStyle(f,0,1),n.drawCircle(o[0],o[1],2*f)}for(n.lineStyle(f,r,1),n.beginFill(u),s=0;s!==t.length;)a=(w=t[s])[0],y=w[1],0===s?n.moveTo(a,-y):n.lineTo(a,-y),s++;if(n.endFill(),t.length>2)return n.moveTo(t[t.length-1][0],-t[t.length-1][1]),n.lineTo(t[0][0],-t[0][1])},drawPath:function(n,t,i,r,u){var f,s,h,c,l,a,v,y,p,e,o;for(void 0===u&&(u=1),void 0===i&&(i=0),n.lineStyle(u,i,1),"number"==typeof r&&n.beginFill(r),s=null,h=null,f=0;f<t.length;)e=(p=t[f])[0],o=p[1],e===s&&o===h||(0===f?n.moveTo(e,o):(c=s,l=h,a=e,v=o,y=t[(f+1)%t.length][0],0!=(a-c)*(t[(f+1)%t.length][1]-l)-(y-c)*(v-l)&&n.lineTo(e,o)),s=e,h=o),f++;"number"==typeof r&&n.endFill();t.length>2&&"number"==typeof r&&(n.moveTo(t[t.length-1][0],t[t.length-1][1]),n.lineTo(t[0][0],t[0][1]))},drawPlane:function(n,t,i,r,u,f,e,o,s,h){var c,l;void 0===f&&(f=1);void 0===r&&(r=16777215);n.lineStyle(f,u,11);n.beginFill(r);n.moveTo(t,-i);c=t+Math.cos(h)*this.game.width;l=i+Math.sin(h)*this.game.height;n.lineTo(c,-l);n.moveTo(t,-i);c=t+Math.cos(h)*-this.game.width;l=i+Math.sin(h)*-this.game.height;n.lineTo(c,-l)},drawCapsule:function(n,t,i,r,u,f,e,o,s){void 0===s&&(s=1);void 0===e&&(e=0);n.lineStyle(s,e,1);var h=Math.cos(r),c=Math.sin(r);n.beginFill(o,1);n.drawCircle(-u/2*h+t,-u/2*c+i,2*-f);n.drawCircle(u/2*h+t,u/2*c+i,2*-f);n.endFill();n.lineStyle(s,e,0);n.beginFill(o,1);n.moveTo(-u/2*h+f*c+t,-u/2*c+f*h+i);n.lineTo(u/2*h+f*c+t,u/2*c+f*h+i);n.lineTo(u/2*h-f*c+t,u/2*c-f*h+i);n.lineTo(-u/2*h-f*c+t,-u/2*c-f*h+i);n.endFill();n.lineStyle(s,e,1);n.moveTo(-u/2*h+f*c+t,-u/2*c+f*h+i);n.lineTo(u/2*h+f*c+t,u/2*c+f*h+i);n.moveTo(-u/2*h-f*c+t,-u/2*c-f*h+i);n.lineTo(u/2*h-f*c+t,u/2*c-f*h+i)},randomPastelHex:function(){var n,t,i,r;return i=[255,255,255],r=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),n=Math.floor(256*Math.random()),r=Math.floor((r+3*i[0])/4),t=Math.floor((t+3*i[1])/4),n=Math.floor((n+3*i[2])/4),this.rgbToHex(r,t,n)},rgbToHex:function(n,t,i){return this.componentToHex(n)+this.componentToHex(t)+this.componentToHex(i)},componentToHex:function(n){var t;return 2===(t=n.toString(16)).length?t:t+"0"}}),n.Physics.P2.Spring=function(n,t,i,r,u,f,e,o,s,h){this.game=n.game;this.world=n;void 0===r&&(r=1);void 0===u&&(u=100);void 0===f&&(f=1);var c={restLength:r=n.pxm(r),stiffness:u,damping:f};void 0!==e&&null!==e&&(c.worldAnchorA=[n.pxm(e[0]),n.pxm(e[1])]);void 0!==o&&null!==o&&(c.worldAnchorB=[n.pxm(o[0]),n.pxm(o[1])]);void 0!==s&&null!==s&&(c.localAnchorA=[n.pxm(s[0]),n.pxm(s[1])]);void 0!==h&&null!==h&&(c.localAnchorB=[n.pxm(h[0]),n.pxm(h[1])]);this.data=new p2.LinearSpring(t,i,c);this.data.parent=this},n.Physics.P2.Spring.prototype.constructor=n.Physics.P2.Spring,n.Physics.P2.RotationalSpring=function(n,t,i,r,u,f){this.game=n.game;this.world=n;void 0===r&&(r=null);void 0===u&&(u=100);void 0===f&&(f=1);r&&(r=n.pxm(r));var e={restAngle:r,stiffness:u,damping:f};this.data=new p2.RotationalSpring(t,i,e);this.data.parent=this},n.Physics.P2.Spring.prototype.constructor=n.Physics.P2.Spring,n.Physics.P2.Material=function(n){this.name=n;p2.Material.call(this)},n.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),n.Physics.P2.Material.prototype.constructor=n.Physics.P2.Material,n.Physics.P2.ContactMaterial=function(n,t,i){p2.ContactMaterial.call(this,n,t,i)},n.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),n.Physics.P2.ContactMaterial.prototype.constructor=n.Physics.P2.ContactMaterial,n.Physics.P2.CollisionGroup=function(n){this.mask=n},n.Physics.P2.DistanceConstraint=function(n,t,i,r,u,f,e){void 0===r&&(r=100);void 0===u&&(u=[0,0]);void 0===f&&(f=[0,0]);void 0===e&&(e=Number.MAX_VALUE);this.game=n.game;this.world=n;var o={distance:r=n.pxm(r),localAnchorA:u=[n.pxmi(u[0]),n.pxmi(u[1])],localAnchorB:f=[n.pxmi(f[0]),n.pxmi(f[1])],maxForce:e};p2.DistanceConstraint.call(this,t,i,o)},n.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),n.Physics.P2.DistanceConstraint.prototype.constructor=n.Physics.P2.DistanceConstraint,n.Physics.P2.GearConstraint=function(n,t,i,r,u){void 0===r&&(r=0);void 0===u&&(u=1);this.game=n.game;this.world=n;var f={angle:r,ratio:u};p2.GearConstraint.call(this,t,i,f)},n.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),n.Physics.P2.GearConstraint.prototype.constructor=n.Physics.P2.GearConstraint,n.Physics.P2.LockConstraint=function(n,t,i,r,u,f){void 0===r&&(r=[0,0]);void 0===u&&(u=0);void 0===f&&(f=Number.MAX_VALUE);this.game=n.game;this.world=n;var e={localOffsetB:r=[n.pxm(r[0]),n.pxm(r[1])],localAngleB:u,maxForce:f};p2.LockConstraint.call(this,t,i,e)},n.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),n.Physics.P2.LockConstraint.prototype.constructor=n.Physics.P2.LockConstraint,n.Physics.P2.PrismaticConstraint=function(n,t,i,r,u,f,e,o){void 0===r&&(r=!0);void 0===u&&(u=[0,0]);void 0===f&&(f=[0,0]);void 0===e&&(e=[0,0]);void 0===o&&(o=Number.MAX_VALUE);this.game=n.game;this.world=n;var s={localAnchorA:u=[n.pxmi(u[0]),n.pxmi(u[1])],localAnchorB:f=[n.pxmi(f[0]),n.pxmi(f[1])],localAxisA:e,maxForce:o,disableRotationalLock:!r};p2.PrismaticConstraint.call(this,t,i,s)},n.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),n.Physics.P2.PrismaticConstraint.prototype.constructor=n.Physics.P2.PrismaticConstraint,n.Physics.P2.RevoluteConstraint=function(n,t,i,r,u,f,e){void 0===f&&(f=Number.MAX_VALUE);void 0===e&&(e=null);this.game=n.game;this.world=n;i=[n.pxmi(i[0]),n.pxmi(i[1])];u=[n.pxmi(u[0]),n.pxmi(u[1])];e&&(e=[n.pxmi(e[0]),n.pxmi(e[1])]);var o={worldPivot:e,localPivotA:i,localPivotB:u,maxForce:f};p2.RevoluteConstraint.call(this,t,r,o)},n.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),n.Physics.P2.RevoluteConstraint.prototype.constructor=n.Physics.P2.RevoluteConstraint,n.ImageCollection=function(n,t,i,r,u,f,e){(void 0===i||i<=0)&&(i=32);(void 0===r||r<=0)&&(r=32);void 0===u&&(u=0);void 0===f&&(f=0);this.name=n;this.firstgid=0|t;this.imageWidth=0|i;this.imageHeight=0|r;this.imageMargin=0|u;this.imageSpacing=0|f;this.properties=e||{};this.images=[];this.total=0},n.ImageCollection.prototype={containsImageIndex:function(n){return n>=this.firstgid&&n<this.firstgid+this.total},addImage:function(n,t){this.images.push({gid:n,image:t});this.total++}},n.ImageCollection.prototype.constructor=n.ImageCollection,n.Tile=function(n,t,i,r,u,f){this.layer=n;this.index=t;this.x=i;this.y=r;this.rotation=0;this.flipped=!1;this.worldX=i*u;this.worldY=r*f;this.width=u;this.height=f;this.centerX=Math.abs(u/2);this.centerY=Math.abs(f/2);this.alpha=1;this.properties={};this.scanned=!1;this.faceTop=!1;this.faceBottom=!1;this.faceLeft=!1;this.faceRight=!1;this.collideLeft=!1;this.collideRight=!1;this.collideUp=!1;this.collideDown=!1;this.collisionCallback=null;this.collisionCallbackContext=this;this.debug=!1},n.Tile.prototype={containsPoint:function(n,t){return!(n<this.worldX||t<this.worldY||n>this.right||t>this.bottom)},intersects:function(n,t,i,r){return!(i<=this.worldX)&&!(r<=this.worldY)&&!(n>=this.worldX+this.width)&&!(t>=this.worldY+this.height)},setCollisionCallback:function(n,t){this.collisionCallback=n;this.collisionCallbackContext=t},destroy:function(){this.collisionCallback=null;this.collisionCallbackContext=null;this.properties=null},setCollision:function(n,t,i,r){this.collideLeft=n;this.collideRight=t;this.collideUp=i;this.collideDown=r;this.faceLeft=n;this.faceRight=t;this.faceTop=i;this.faceBottom=r},resetCollision:function(){this.collideLeft=!1;this.collideRight=!1;this.collideUp=!1;this.collideDown=!1;this.faceTop=!1;this.faceBottom=!1;this.faceLeft=!1;this.faceRight=!1},isInteresting:function(n,t){return n&&t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:n?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!t&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(n){this.index=n.index;this.alpha=n.alpha;this.properties=n.properties;this.collideUp=n.collideUp;this.collideDown=n.collideDown;this.collideLeft=n.collideLeft;this.collideRight=n.collideRight;this.collisionCallback=n.collisionCallback;this.collisionCallbackContext=n.collisionCallbackContext}},n.Tile.prototype.constructor=n.Tile,Object.defineProperty(n.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(n.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(n.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(n.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(n.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(n.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),n.Tilemap=function(t,i,r,u,f,e){this.game=t;this.key=i;var o=n.TilemapParser.parse(this.game,i,r,u,f,e);null!==o&&(this.width=o.width,this.height=o.height,this.tileWidth=o.tileWidth,this.tileHeight=o.tileHeight,this.orientation=o.orientation,this.format=o.format,this.version=o.version,this.properties=o.properties,this.widthInPixels=o.widthInPixels,this.heightInPixels=o.heightInPixels,this.layers=o.layers,this.tilesets=o.tilesets,this.imagecollections=o.imagecollections,this.tiles=o.tiles,this.objects=o.objects,this.collideIndexes=[],this.collision=o.collision,this.images=o.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},n.Tilemap.CSV=0,n.Tilemap.TILED_JSON=1,n.Tilemap.NORTH=0,n.Tilemap.EAST=1,n.Tilemap.SOUTH=2,n.Tilemap.WEST=3,n.Tilemap.prototype={create:function(n,t,i,r,u,f){return void 0===f&&(f=this.game.world),this.width=t,this.height=i,this.setTileSize(r,u),this.layers.length=0,this.createBlankLayer(n,t,i,r,u,f)},setTileSize:function(n,t){this.tileWidth=n;this.tileHeight=t;this.widthInPixels=this.width*n;this.heightInPixels=this.height*t},addTilesetImage:function(t,i,r,u,f,e,o){var h,c,s;if(void 0===t)return null;if(void 0===r&&(r=this.tileWidth),void 0===u&&(u=this.tileHeight),void 0===f&&(f=0),void 0===e&&(e=0),void 0===o&&(o=0),0===r&&(r=32),0===u&&(u=32),h=null,void 0!==i&&null!==i||(i=t),i instanceof n.BitmapData)h=i.canvas;else{if(!this.game.cache.checkImageKey(i))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+i+'"'),null;h=this.game.cache.getImage(i)}if(c=this.getTilesetIndex(t),null===c&&this.format===n.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+t+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[c])return this.tilesets[c].setImage(h),this.tilesets[c];s=new n.Tileset(t,o,r,u,f,e,{});s.setImage(h);this.tilesets.push(s);for(var p=this.tilesets.length-1,l=f,v=f,w=0,y=0,b=0,a=o;a<o+s.total&&(this.tiles[a]=[l,v,p],l+=r+e,++w!==s.total)&&(++y!==s.columns||(l=f,v+=u+e,y=0,++b!==s.rows));a++);return s},createFromObjects:function(t,i,r,u,f,e,o,s,h,c){var y,v,l,a,p;if(void 0===f&&(f=!0),void 0===e&&(e=!1),void 0===o&&(o=this.game.world),void 0===s&&(s=n.Sprite),void 0===h&&(h=!0),void 0===c&&(c=!0),!this.objects[t])return console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: "+t),void console.log("Objects: ",this.objects);for(y=0;y<this.objects[t].length;y++)if(v=!1,l=this.objects[t][y],void 0!==l.gid&&"number"==typeof i&&l.gid===i?v=!0:void 0!==l.id&&"number"==typeof i&&l.id===i?v=!0:void 0!==l.name&&"string"==typeof i&&l.name===i&&(v=!0),v){a=new s(this.game,parseFloat(l.x),parseFloat(l.y),r,u);a.name=l.name;a.autoCull=e;a.exists=f;a.visible=l.visible;c&&(l.width&&(a.width=l.width),l.height&&(a.height=l.height));l.rotation&&(a.angle=l.rotation);h&&(a.y-=a.height);o.add(a);for(p in l.properties)o.set(a,p,l.properties[p],!1,!1,0,!0)}},createFromTiles:function(t,i,r,u,f,e){var s,h,l;if("number"==typeof t&&(t=[t]),void 0===i||null===i?i=[]:"number"==typeof i&&(i=[i]),u=this.getLayer(u),void 0===f&&(f=this.game.world),void 0===e&&(e={}),void 0===e.customClass&&(e.customClass=n.Sprite),void 0===e.adjustY&&(e.adjustY=!0),s=this.layers[u].width,h=this.layers[u].height,this.copy(0,0,s,h,u),this._results.length<2)return 0;for(var c,a=0,o=1,v=this._results.length;o<v;o++)if(-1!==t.indexOf(this._results[o].index)){c=new e.customClass(this.game,this._results[o].worldX,this._results[o].worldY,r);for(l in e)c[l]=e[l];f.add(c);a++}if(1===i.length)for(o=0;o<t.length;o++)this.replace(t[o],i[0],0,0,s,h,u);else if(i.length>1)for(o=0;o<t.length;o++)this.replace(t[o],i[o],0,0,s,h,u);return a},createLayer:function(t,i,r,u){var f,e;return(void 0===i&&(i=this.game.width),void 0===r&&(r=this.game.height),void 0===u&&(u=this.game.world),f=t,"string"==typeof t&&(f=this.getLayerIndex(t)),null===f||f>this.layers.length)?(console.warn('Tilemap.createLayer: Invalid layer ID given: "'+t+'"'),void console.log("Layers: ",this.layers)):(void 0===i||i<=0?i=Math.min(this.game.width,this.layers[f].widthInPixels):i>this.game.width&&(i=this.game.width),void 0===r||r<=0?r=Math.min(this.game.height,this.layers[f].heightInPixels):r>this.game.height&&(r=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[f].name),console.log("Size:",i,"x",r),console.log("Tileset:",this.tilesets[0].name,"index:",f)),e=u.add(new n.TilemapLayer(this.game,this,f,i,r)),this.enableDebug&&console.groupEnd(),e)},createBlankLayer:function(t,i,r,u,f,e){var h,c,l;if(void 0===e&&(e=this.game.world),null===this.getLayerIndex(t)){for(var a,o={name:t,x:0,y:0,width:i,height:r,widthInPixels:i*u,heightInPixels:r*f,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},s=[],v=0;v<r;v++){for(a=[],h=0;h<i;h++)a.push(new n.Tile(o,-1,h,v,u,f));s.push(a)}return o.data=s,this.layers.push(o),this.currentLayer=this.layers.length-1,c=o.widthInPixels,l=o.heightInPixels,c>this.game.width&&(c=this.game.width),l>this.game.height&&(l=this.game.height),(s=new n.TilemapLayer(this.game,this,this.layers.length-1,c,l)).name=t,e.add(s)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)},getIndex:function(n,t){for(var i=0;i<n.length;i++)if(n[i].name===t)return i;return null},getLayerIndex:function(n){return this.getIndex(this.layers,n)},getTilesetIndex:function(n){return this.getIndex(this.tilesets,n)},getImageIndex:function(n){return this.getIndex(this.images,n)},setTileIndexCallback:function(n,t,i,r){if(r=this.getLayer(r),"number"==typeof n)null===t?delete this.layers[r].callbacks[n]:this.layers[r].callbacks[n]={callback:t,callbackContext:i};else for(var u=0,f=n.length;u<f;u++)null===t?delete this.layers[r].callbacks[n[u]]:this.layers[r].callbacks[n[u]]={callback:t,callbackContext:i}},setTileLocationCallback:function(n,t,i,r,u,f,e){if(e=this.getLayer(e),this.copy(n,t,i,r,e),!(this._results.length<2))for(var o=1;o<this._results.length;o++)this._results[o].setCollisionCallback(u,f)},setCollision:function(n,t,i,r){if(void 0===t&&(t=!0),void 0===r&&(r=!0),i=this.getLayer(i),"number"==typeof n)return this.setCollisionByIndex(n,t,i,!0);if(Array.isArray(n)){for(var u=0;u<n.length;u++)this.setCollisionByIndex(n[u],t,i,!1);r&&this.calculateFaces(i)}},setCollisionBetween:function(n,t,i,r,u){if(void 0===i&&(i=!0),void 0===u&&(u=!0),r=this.getLayer(r),!(n>t)){for(var f=n;f<=t;f++)this.setCollisionByIndex(f,i,r,!1);u&&this.calculateFaces(r)}},setCollisionByExclusion:function(n,t,i,r){void 0===t&&(t=!0);void 0===r&&(r=!0);i=this.getLayer(i);for(var u=0,f=this.tiles.length;u<f;u++)-1===n.indexOf(u)&&this.setCollisionByIndex(u,t,i,!1);r&&this.calculateFaces(i)},setCollisionByIndex:function(n,t,i,r){var o,f,e,u;for((void 0===t&&(t=!0),void 0===i&&(i=this.currentLayer),void 0===r&&(r=!0),t)?this.collideIndexes.push(n):(o=this.collideIndexes.indexOf(n),o>-1&&this.collideIndexes.splice(o,1)),f=0;f<this.layers[i].height;f++)for(e=0;e<this.layers[i].width;e++)u=this.layers[i].data[f][e],u&&u.index===n&&(t?u.setCollision(!0,!0,!0,!0):u.resetCollision(),u.faceTop=t,u.faceBottom=t,u.faceLeft=t,u.faceRight=t);return r&&this.calculateFaces(i),i},getLayer:function(t){if(void 0===t)t=this.currentLayer;else if("string"==typeof t){var i=t;null===(t=this.getLayerIndex(t))&&console.warn("No such layer name: "+i)}else t instanceof n.TilemapLayer&&(t=t.index);return t},setPreventRecalculate:function(n){if(!0===n&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===n&&!0===this.preventingRecalculate){this.preventingRecalculate=!1;for(var t in this.needToRecalculate)this.calculateFaces(t);this.needToRecalculate=!1}},calculateFaces:function(n){var i,s,t;if(this.preventingRecalculate)this.needToRecalculate[n]=!0;else for(var u=null,f=null,e=null,o=null,r=0,h=this.layers[n].height;r<h;r++)for(i=0,s=this.layers[n].width;i<s;i++)t=this.layers[n].data[r][i],t&&(u=this.getTileAbove(n,i,r),f=this.getTileBelow(n,i,r),e=this.getTileLeft(n,i,r),o=this.getTileRight(n,i,r),t.collides&&(t.faceTop=!0,t.faceBottom=!0,t.faceLeft=!0,t.faceRight=!0),u&&u.collides&&(t.faceTop=!1),f&&f.collides&&(t.faceBottom=!1),e&&e.collides&&(t.faceLeft=!1),o&&o.collides&&(t.faceRight=!1))},getTileAbove:function(n,t,i){return i>0?this.layers[n].data[i-1][t]:null},getTileBelow:function(n,t,i){return i<this.layers[n].height-1?this.layers[n].data[i+1][t]:null},getTileLeft:function(n,t,i){return t>0?this.layers[n].data[i][t-1]:null},getTileRight:function(n,t,i){return t<this.layers[n].width-1?this.layers[n].data[i][t+1]:null},setLayer:function(n){n=this.getLayer(n);this.layers[n]&&(this.currentLayer=n)},hasTile:function(n,t,i){return i=this.getLayer(i),void 0!==this.layers[i].data[t]&&void 0!==this.layers[i].data[t][n]&&this.layers[i].data[t][n].index>-1},removeTile:function(t,i,r){if(r=this.getLayer(r),t>=0&&t<this.layers[r].width&&i>=0&&i<this.layers[r].height&&this.hasTile(t,i,r)){var u=this.layers[r].data[i][t];return this.layers[r].data[i][t]=new n.Tile(this.layers[r],-1,t,i,this.tileWidth,this.tileHeight),this.layers[r].dirty=!0,this.calculateFaces(r),u}},removeTileWorldXY:function(n,t,i,r,u){return u=this.getLayer(u),n=this.game.math.snapToFloor(n,i)/i,t=this.game.math.snapToFloor(t,r)/r,this.removeTile(n,t,u)},putTile:function(t,i,r,u){if(null===t)return this.removeTile(i,r,u);if(u=this.getLayer(u),i>=0&&i<this.layers[u].width&&r>=0&&r<this.layers[u].height){var f;return t instanceof n.Tile?(f=t.index,this.hasTile(i,r,u)?this.layers[u].data[r][i].copy(t):this.layers[u].data[r][i]=new n.Tile(u,f,i,r,t.width,t.height)):(f=t,this.hasTile(i,r,u)?this.layers[u].data[r][i].index=f:this.layers[u].data[r][i]=new n.Tile(this.layers[u],f,i,r,this.tileWidth,this.tileHeight)),this.collideIndexes.indexOf(f)>-1?this.layers[u].data[r][i].setCollision(!0,!0,!0,!0):this.layers[u].data[r][i].resetCollision(),this.layers[u].dirty=!0,this.calculateFaces(u),this.layers[u].data[r][i]}return null},putTileWorldXY:function(n,t,i,r,u,f){return f=this.getLayer(f),t=this.game.math.snapToFloor(t,r)/r,i=this.game.math.snapToFloor(i,u)/u,this.putTile(n,t,i,f)},searchTileIndex:function(n,t,i,r){var e,u,f;if(void 0===t&&(t=0),void 0===i&&(i=!1),r=this.getLayer(r),e=0,i){for(u=this.layers[r].height-1;u>=0;u--)for(f=this.layers[r].width-1;f>=0;f--)if(this.layers[r].data[u][f].index===n){if(e===t)return this.layers[r].data[u][f];e++}}else for(u=0;u<this.layers[r].height;u++)for(f=0;f<this.layers[r].width;f++)if(this.layers[r].data[u][f].index===n){if(e===t)return this.layers[r].data[u][f];e++}return null},getTile:function(n,t,i,r){return void 0===r&&(r=!1),i=this.getLayer(i),n>=0&&n<this.layers[i].width&&t>=0&&t<this.layers[i].height?-1===this.layers[i].data[t][n].index?r?this.layers[i].data[t][n]:null:this.layers[i].data[t][n]:null},getTileWorldXY:function(n,t,i,r,u,f){return void 0===i&&(i=this.tileWidth),void 0===r&&(r=this.tileHeight),u=this.getLayer(u),n=this.game.math.snapToFloor(n,i)/i,t=this.game.math.snapToFloor(t,r)/r,this.getTile(n,t,u,f)},copy:function(n,t,i,r,u){var f,e;if(u=this.getLayer(u),this.layers[u]){for(void 0===n&&(n=0),void 0===t&&(t=0),void 0===i&&(i=this.layers[u].width),void 0===r&&(r=this.layers[u].height),n<0&&(n=0),t<0&&(t=0),i>this.layers[u].width&&(i=this.layers[u].width),r>this.layers[u].height&&(r=this.layers[u].height),this._results.length=0,this._results.push({x:n,y:t,width:i,height:r,layer:u}),f=t;f<t+r;f++)for(e=n;e<n+i;e++)this._results.push(this.layers[u].data[f][e]);return this._results}this._results.length=0},paste:function(n,t,i,r){if(void 0===n&&(n=0),void 0===t&&(t=0),r=this.getLayer(r),i&&!(i.length<2)){for(var f=n-i[1].x,e=t-i[1].y,u=1;u<i.length;u++)this.layers[r].data[e+i[u].y][f+i[u].x].copy(i[u]);this.layers[r].dirty=!0;this.calculateFaces(r)}},swap:function(n,t,i,r,u,f,e){e=this.getLayer(e);this.copy(i,r,u,f,e);this._results.length<2||(this._tempA=n,this._tempB=t,this._results.forEach(this.swapHandler,this),this.paste(i,r,this._results,e))},swapHandler:function(n){n.index===this._tempA?n.index=this._tempB:n.index===this._tempB&&(n.index=this._tempA)},forEach:function(n,t,i,r,u,f,e){e=this.getLayer(e);this.copy(i,r,u,f,e);this._results.length<2||(this._results.forEach(n,t),this.paste(i,r,this._results,e))},replace:function(n,t,i,r,u,f,e){if(e=this.getLayer(e),this.copy(i,r,u,f,e),!(this._results.length<2)){for(var o=1;o<this._results.length;o++)this._results[o].index===n&&(this._results[o].index=t);this.paste(i,r,this._results,e)}},random:function(n,t,i,r,u){var e,f,s,o;if(u=this.getLayer(u),this.copy(n,t,i,r,u),!(this._results.length<2)){for(e=[],f=1;f<this._results.length;f++)this._results[f].index&&(s=this._results[f].index,-1===e.indexOf(s)&&e.push(s));for(o=1;o<this._results.length;o++)this._results[o].index=this.game.rnd.pick(e);this.paste(n,t,this._results,u)}},shuffle:function(t,i,r,u,f){var s,e,o;if(f=this.getLayer(f),this.copy(t,i,r,u,f),!(this._results.length<2)){for(s=[],e=1;e<this._results.length;e++)this._results[e].index&&s.push(this._results[e].index);for(n.ArrayUtils.shuffle(s),o=1;o<this._results.length;o++)this._results[o].index=s[o-1];this.paste(t,i,this._results,f)}},fill:function(n,t,i,r,u,f){if(f=this.getLayer(f),this.copy(t,i,r,u,f),!(this._results.length<2)){for(var e=1;e<this._results.length;e++)this._results[e].index=n;this.paste(t,i,this._results,f)}},removeAllLayers:function(){this.layers.length=0;this.currentLayer=0},dump:function(){for(var n,r="",t=[""],i=0;i<this.layers[this.currentLayer].height;i++){for(n=0;n<this.layers[this.currentLayer].width;n++)r+="%c  ",this.layers[this.currentLayer].data[i][n]>1?this.debugMap[this.layers[this.currentLayer].data[i][n]]?t.push("background: "+this.debugMap[this.layers[this.currentLayer].data[i][n]]):t.push("background: #ffffff"):t.push("background: rgb(0, 0, 0)");r+="\n"}t[0]=r;console.log.apply(console,t)},destroy:function(){this.removeAllLayers();this.data=[];this.game=null}},n.Tilemap.prototype.constructor=n.Tilemap,Object.defineProperty(n.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(n){n!==this.currentLayer&&this.setLayer(n)}}),n.TilemapLayer=function(t,i,r,u,f){u|=0;f|=0;n.Sprite.call(this,t,0,0);this.map=i;this.index=r;this.layer=i.layers[r];this.canvas=n.CanvasPool.create(this,u,f);this.context=this.canvas.getContext("2d");this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution)));this.type=n.TILEMAPLAYER;this.physicsType=n.TILEMAPLAYER;this.renderSettings={enableScrollDelta:!0,overdrawRatio:.2,copyCanvas:null};this.debug=!1;this.exists=!0;this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"};this.scrollFactorX=1;this.scrollFactorY=1;this.dirty=!0;this.rayStepRate=4;this._wrap=!1;this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:i.tileWidth,tileHeight:i.tileHeight,cw:i.tileWidth,ch:i.tileHeight,tilesets:[]};this._scrollX=0;this._scrollY=0;this.tileOffset=new n.Point(this.layer.offsetX||0,this.layer.offsetY||0);this._results=[];t.device.canvasBitBltShift||(this.renderSettings.copyCanvas=n.TilemapLayer.ensureSharedCopyCanvas());this.fixedToCamera=!0},n.TilemapLayer.prototype=Object.create(n.Sprite.prototype),n.TilemapLayer.prototype.constructor=n.TilemapLayer,n.TilemapLayer.prototype.preUpdateCore=n.Component.Core.preUpdate,n.TilemapLayer.sharedCopyCanvas=null,n.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=n.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},n.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},n.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x;this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y},n.TilemapLayer.prototype._renderCanvas=function(n){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x;this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y;this.render();PIXI.Sprite.prototype._renderCanvas.call(this,n)},n.TilemapLayer.prototype._renderWebGL=function(n){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x;this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y;this.render();PIXI.Sprite.prototype._renderWebGL.call(this,n)},n.TilemapLayer.prototype.destroy=function(){n.CanvasPool.remove(this);n.Component.Destroy.prototype.destroy.call(this)},n.TilemapLayer.prototype.resize=function(n,t){this.canvas.width=n;this.canvas.height=t;this.texture.frame.resize(n,t);this.texture.width=n;this.texture.height=t;this.texture.crop.width=n;this.texture.crop.height=t;this.texture.baseTexture.width=n;this.texture.baseTexture.height=t;this.texture.baseTexture.dirty();this.texture.requiresUpdate=!0;this.texture._updateUvs();this.dirty=!0},n.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},n.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},n.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},n.TilemapLayer.prototype._fixX=function(n){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?n:0===this.scrollFactorX&&0!==this.position.x?n-this.position.x:this._scrollX+(n-this._scrollX/this.scrollFactorX)},n.TilemapLayer.prototype._unfixX=function(n){return 1===this.scrollFactorX?n:this._scrollX/this.scrollFactorX+(n-this._scrollX)},n.TilemapLayer.prototype._fixY=function(n){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?n:0===this.scrollFactorY&&0!==this.position.y?n-this.position.y:this._scrollY+(n-this._scrollY/this.scrollFactorY)},n.TilemapLayer.prototype._unfixY=function(n){return 1===this.scrollFactorY?n:this._scrollY/this.scrollFactorY+(n-this._scrollY)},n.TilemapLayer.prototype.getTileX=function(n){return Math.floor(this._fixX(n)/this._mc.tileWidth)},n.TilemapLayer.prototype.getTileY=function(n){return Math.floor(this._fixY(n)/this._mc.tileHeight)},n.TilemapLayer.prototype.getTileXY=function(n,t,i){return i.x=this.getTileX(n),i.y=this.getTileY(t),i},n.TilemapLayer.prototype.getRayCastTiles=function(n,t,i,r){var u,f,o,s;if(t||(t=this.rayStepRate),void 0===i&&(i=!1),void 0===r&&(r=!1),u=this.getTiles(n.x,n.y,n.width,n.height,i,r),0===u.length)return[];for(var h=n.coordinatesOnLine(t),c=[],e=0;e<u.length;e++)for(f=0;f<h.length;f++)if(o=u[e],s=h[f],o.containsPoint(s[0],s[1])){c.push(o);break}return c},n.TilemapLayer.prototype.getTiles=function(n,t,i,r,u,f){var l,s,e,o;void 0===u&&(u=!1);void 0===f&&(f=!1);l=!(u||f);n=this._fixX(n);t=this._fixY(t);for(var h=Math.floor(n/(this._mc.cw*this.scale.x)),c=Math.floor(t/(this._mc.ch*this.scale.y)),a=Math.ceil((n+i)/(this._mc.cw*this.scale.x))-h,v=Math.ceil((t+r)/(this._mc.ch*this.scale.y))-c;this._results.length;)this._results.pop();for(s=c;s<c+v;s++)for(e=h;e<h+a;e++)o=this.layer.data[s],o&&o[e]&&(l||o[e].isInteresting(u,f))&&this._results.push(o[e]);return this._results.slice()},n.TilemapLayer.prototype.resolveTileset=function(n){var i=this._mc.tilesets,r,t;if(n<2e3)for(;i.length<n;)i.push(void 0);return i[n]=(r=this.map.tiles[n]&&this.map.tiles[n][2],null!==r&&(t=this.map.tilesets[r],t&&t.containsTileIndex(n)))?t:null},n.TilemapLayer.prototype.resetTilesetCache=function(){for(var n=this._mc.tilesets;n.length;)n.pop()},n.TilemapLayer.prototype.setScale=function(n,t){var r,f,u,i;for(n=n||1,t=t||n,r=0;r<this.layer.data.length;r++)for(f=this.layer.data[r],u=0;u<f.length;u++)i=f[u],i.width=this.map.tileWidth*n,i.height=this.map.tileHeight*t,i.worldX=i.x*i.width,i.worldY=i.y*i.height;this.scale.setTo(n,t)},n.TilemapLayer.prototype.shiftCanvas=function(n,t,i){var e=n.canvas,r=e.width-Math.abs(t),u=e.height-Math.abs(i),h=0,c=0,o=t,s=i,f,l;t<0&&(h=-t,o=0);i<0&&(c=-i,s=0);f=this.renderSettings.copyCanvas;f?((f.width<r||f.height<u)&&(f.width=r,f.height=u),l=f.getContext("2d"),l.clearRect(0,0,r,u),l.drawImage(e,h,c,r,u,0,0,r,u),n.clearRect(o,s,r,u),n.drawImage(f,0,0,r,u,o,s,r,u)):(n.save(),n.globalCompositeOperation="copy",n.drawImage(e,h,c,r,u,o,s,r,u),n.restore())},n.TilemapLayer.prototype.renderRegion=function(n,t,i,r,u,f){var o=this.context,l=this.layer.width,a=this.layer.height,w=this._mc.tileWidth,b=this._mc.tileHeight,rt=this._mc.tilesets,g=NaN,s,h,v,y,k,d,nt,tt,it,e,p,c;for(this._wrap||(i<=u&&(i=Math.max(0,i),u=Math.min(l-1,u)),r<=f&&(r=Math.max(0,r),f=Math.min(a-1,f))),nt=i*w-n,tt=(i+1048576*l)%l,y=(r+1048576*a)%a,d=f-r,h=r*b-t;d>=0;y++,d--,h+=b)for(y>=a&&(y-=a),it=this.layer.data[y],v=tt,k=u-i,s=nt;k>=0;v++,k--,s+=w)v>=l&&(v-=l),e=it[v],!e||e.index<0||(p=e.index,c=rt[p],void 0===c&&(c=this.resolveTileset(p)),e.alpha===g||this.debug||(o.globalAlpha=e.alpha,g=e.alpha),c?e.rotation||e.flipped?(o.save(),o.translate(s+e.centerX,h+e.centerY),o.rotate(e.rotation),e.flipped&&o.scale(-1,1),c.draw(o,-e.centerX,-e.centerY,p),o.restore()):c.draw(o,s,h,p):this.debugSettings.missingImageFill&&(o.fillStyle=this.debugSettings.missingImageFill,o.fillRect(s,h,w,b)),e.debug&&this.debugSettings.debuggedTileOverfill&&(o.fillStyle=this.debugSettings.debuggedTileOverfill,o.fillRect(s,h,w,b)))},n.TilemapLayer.prototype.renderDeltaScroll=function(n,t){var i=this._mc.scrollX,r=this._mc.scrollY,c=this.canvas.width,l=this.canvas.height,u=this._mc.tileWidth,f=this._mc.tileHeight,e=0,o=-u,s=0,h=-f,a,v,y,p;(n<0?(e=c+n,o=c-1):n>0&&(o=n),t<0?(s=l+t,h=l-1):t>0&&(h=t),this.shiftCanvas(this.context,n,t),e=Math.floor((e+i)/u),o=Math.floor((o+i)/u),s=Math.floor((s+r)/f),h=Math.floor((h+r)/f),e<=o)&&(this.context.clearRect(e*u-i,0,(o-e+1)*u,l),a=Math.floor((0+r)/f),v=Math.floor((l-1+r)/f),this.renderRegion(i,r,e,a,o,v));s<=h&&(this.context.clearRect(0,s*f-r,c,(h-s+1)*f),y=Math.floor((0+i)/u),p=Math.floor((c-1+i)/u),this.renderRegion(i,r,y,s,p,h))},n.TilemapLayer.prototype.renderFull=function(){var n=this._mc.scrollX,t=this._mc.scrollY,i=this.canvas.width,r=this.canvas.height,u=this._mc.tileWidth,f=this._mc.tileHeight,e=Math.floor(n/u),o=Math.floor((i-1+n)/u),s=Math.floor(t/f),h=Math.floor((r-1+t)/f);this.context.clearRect(0,0,i,r);this.renderRegion(n,t,e,s,o,h)},n.TilemapLayer.prototype.render=function(){var t=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,t=!0);var i=this.canvas.width,r=this.canvas.height,e=0|this._scrollX,o=0|this._scrollY,n=this._mc,u=n.scrollX-e,f=n.scrollY-o;if(t||0!==u||0!==f||n.renderWidth!==i||n.renderHeight!==r)return this.context.save(),n.scrollX=e,n.scrollY=o,n.renderWidth===i&&n.renderHeight===r||(n.renderWidth=i,n.renderHeight=r),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(t=!0)),!t&&this.renderSettings.enableScrollDelta&&Math.abs(u)+Math.abs(f)<Math.min(i,r)?this.renderDeltaScroll(u,f):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},n.TilemapLayer.prototype.renderDebug=function(){var t,i,u,f,c,l,a=this._mc.scrollX,v=this._mc.scrollY,n=this.context,b=this.canvas.width,k=this.canvas.height,e=this.layer.width,o=this.layer.height,s=this._mc.tileWidth,h=this._mc.tileHeight,y=Math.floor(a/s),d=Math.floor((b-1+a)/s),p=Math.floor(v/h),g=Math.floor((k-1+v)/h),nt=y*s-a,tt=p*h-v,it=(y+1048576*e)%e,rt=(p+1048576*o)%o,w,r;for(n.strokeStyle=this.debugSettings.facingEdgeStroke,f=rt,l=g-p,i=tt;l>=0;f++,l--,i+=h)for(f>=o&&(f-=o),w=this.layer.data[f],u=it,c=d-y,t=nt;c>=0;u++,c--,t+=s)u>=e&&(u-=e),r=w[u],!r||r.index<0||!r.collides||(this.debugSettings.collidingTileOverfill&&(n.fillStyle=this.debugSettings.collidingTileOverfill,n.fillRect(t,i,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(n.beginPath(),r.faceTop&&(n.moveTo(t,i),n.lineTo(t+this._mc.cw,i)),r.faceBottom&&(n.moveTo(t,i+this._mc.ch),n.lineTo(t+this._mc.cw,i+this._mc.ch)),r.faceLeft&&(n.moveTo(t,i),n.lineTo(t,i+this._mc.ch)),r.faceRight&&(n.moveTo(t+this._mc.cw,i),n.lineTo(t+this._mc.cw,i+this._mc.ch)),n.closePath(),n.stroke()))},Object.defineProperty(n.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(n){this._wrap=n;this.dirty=!0}}),Object.defineProperty(n.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(n){this._scrollX=n}}),Object.defineProperty(n.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(n){this._scrollY=n}}),Object.defineProperty(n.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(n){this._mc.cw=0|n;this.dirty=!0}}),Object.defineProperty(n.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(n){this._mc.ch=0|n;this.dirty=!0}}),n.TilemapParser={INSERT_NULL:!1,parse:function(t,i,r,u,f,e){if(void 0===r&&(r=32),void 0===u&&(u=32),void 0===f&&(f=10),void 0===e&&(e=10),void 0===i)return this.getEmptyData();if(null===i)return this.getEmptyData(r,u,f,e);var o=t.cache.getTilemapData(i);if(o){if(o.format===n.Tilemap.CSV)return this.parseCSV(i,o.data,r,u);if(!o.format||o.format===n.Tilemap.TILED_JSON)return this.parseTiledJSON(o.data)}else console.warn('No map data found for key "%s"',i)},parseCSV:function(t,i,r,u){for(var h,o,f=this.getEmptyData(),c=[],l=(i=i.trim()).split("\n"),a=l.length,s=0,e=0;e<l.length;e++){for(c[e]=[],h=l[e].split(","),o=0;o<h.length;o++)c[e][o]=new n.Tile(f.layers[0],parseInt(h[o],10),o,e,r,u);0===s&&(s=h.length)}return f.format=n.Tilemap.CSV,f.name=t,f.width=s,f.height=a,f.tileWidth=r,f.tileHeight=u,f.widthInPixels=s*r,f.heightInPixels=a*u,f.layers[0].width=s,f.layers[0].height=a,f.layers[0].widthInPixels=f.widthInPixels,f.layers[0].heightInPixels=f.heightInPixels,f.layers[0].data=c,f},getEmptyData:function(n,t,i,r){return{width:void 0!==i&&null!==i?i:0,height:void 0!==r&&null!==r?r:0,tileWidth:void 0!==n&&null!==n?n:0,tileHeight:void 0!==t&&null!==t?t:0,orientation:"orthogonal",version:"1",properties:{},widthInPixels:0,heightInPixels:0,layers:[{name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]}],images:[],objects:{},collision:{},tilesets:[],tiles:[]}},_slice:function(n,t){var r={},u,i;for(u in t)i=t[u],void 0!==n[i]&&(r[i]=n[i]);return r},parseObjectGroup:function(n,t,i,r,u){var r=r||n.name,u=u||{x:0,y:0},h=this._slice,s,c,f,e,o;for(r||console.warn("No name found for objectGroup",n),void 0!==u.x&&void 0!==u.y||console.warn("Malformed xy properties in relativePosition",u),t[r]=t[r]||[],i[r]=i[r]||[],s=0,c=n.objects.length;s<c;s++)if(f=n.objects[s],f.gid)e={gid:f.gid,name:f.name,type:f.type||"",x:f.x+u.x,y:f.y+u.y,width:f.width,height:f.height,visible:f.visible,properties:f.properties},f.rotation&&(e.rotation=f.rotation),t[r].push(e);else if(f.polyline){for(e={name:f.name,type:f.type,x:f.x+u.x,y:f.y+u.y,width:f.width,height:f.height,visible:f.visible,properties:f.properties},f.rotation&&(e.rotation=f.rotation),e.polyline=[],o=0;o<f.polyline.length;o++)e.polyline.push([f.polyline[o].x,f.polyline[o].y]);i[r].push(e);t[r].push(e)}else if(f.polygon){for((e=h(f,["name","type","x","y","visible","rotation","properties"])).x+=u.x,e.y+=u.y,e.polygon=[],o=0;o<f.polygon.length;o++)e.polygon.push([f.polygon[o].x,f.polygon[o].y]);i[r].push(e);t[r].push(e)}else f.ellipse?((e=h(f,["name","type","ellipse","x","y","width","height","visible","rotation","properties"])).x+=u.x,e.y+=u.y,i[r].push(e),t[r].push(e)):((e=h(f,["name","type","x","y","width","height","visible","rotation","properties"])).x+=u.x,e.y+=u.y,e.rectangle=!0,i[r].push(e),t[r].push(e));return{objectsCollection:t,collisionCollection:i}},parseTiledJSON:function(t){var u,ut,c,it,st,k,o,d,y,l,e,wt,i,r,rt;if("orthogonal"!==t.orientation)return console.warn('Phaser CE supports only orthogonal maps. This map\'s orientation is "%s".',t.orientation),null;t.version>1.1&&console.warn('Some features in this Tiled JSON map (version %s) may not work in Phaser CE. Enable the json1 plugin and reexport the map in "Tiled 1.1" format. https://github.com/photonstorm/phaser-ce/issues/623',t.version);for(var f={width:t.width,height:t.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,orientation:t.orientation,format:n.Tilemap.TILED_JSON,version:t.version,properties:t.properties,widthInPixels:t.width*t.tilewidth,heightInPixels:t.height*t.tileheight},ct=[],r=0;r<t.layers.length;r++)if("tilelayer"===t.layers[r].type){if(u=t.layers[r],!u.compression&&u.encoding&&"base64"===u.encoding){for(var g=window.atob(u.data),nt=g.length,lt=new Array(nt),s=0;s<nt;s+=4)lt[s/4]=(g.charCodeAt(s)|g.charCodeAt(s+1)<<8|g.charCodeAt(s+2)<<16|g.charCodeAt(s+3)<<24)>>>0;u.data=lt;delete u.encoding}else if(u.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',u.name);continue}l={name:u.name,x:u.x,y:u.y,width:u.width,height:u.height,widthInPixels:u.width*t.tilewidth,heightInPixels:u.height*t.tileheight,alpha:u.opacity,offsetX:u.offsetx,offsetY:u.offsety,visible:u.visible,properties:{},indexes:[],callbacks:[],bodies:[]};u.properties&&(l.properties=u.properties);for(var h,b,p,a=0,v=[],tt=[],w=0,nt=u.data.length;w<nt;w++){if(h=0,b=!1,o=u.data[w],p=0,o>536870912)switch(o>2147483648&&(o-=2147483648,p+=4),o>1073741824&&(o-=1073741824,p+=2),o>536870912&&(o-=536870912,p+=1),p){case 5:h=Math.PI/2;break;case 6:h=Math.PI;break;case 3:h=3*Math.PI/2;break;case 4:h=0;b=!0;break;case 7:h=Math.PI/2;b=!0;break;case 2:h=Math.PI;b=!0;break;case 1:h=3*Math.PI/2;b=!0}o>0?((e=new n.Tile(l,o,a,tt.length,t.tilewidth,t.tileheight)).rotation=h,e.flipped=b,0!==p&&(e.flippedVal=p),v.push(e)):n.TilemapParser.INSERT_NULL?v.push(null):v.push(new n.Tile(l,-1,a,tt.length,t.tilewidth,t.tileheight));++a===u.width&&(tt.push(v),a=0,v=[])}l.data=tt;ct.push(l)}for(f.layers=ct,ut=[],r=0;r<t.layers.length;r++)"imagelayer"===t.layers[r].type&&(c=t.layers[r],k={name:c.name,image:c.image,x:c.x,y:c.y,alpha:c.opacity,visible:c.visible,properties:{}},c.properties&&(k.properties=c.properties),ut.push(k));f.images=ut;for(var ft=[],at={},et=[],ot=null,r=0;r<t.tilesets.length;r++){if((i=t.tilesets[r]).source)console.warn("Phaser CE can't load external tilesets (%s). Embed the tileset and then export the map again. https://github.com/photonstorm/phaser-ce/issues/273",i.source);else if(i.image)it=new n.Tileset(i.name,i.firstgid,i.tilewidth,i.tileheight,i.margin,i.spacing,i.properties),i.tileproperties&&(it.tileProperties=i.tileproperties),it.updateTileData(i.imagewidth,i.imageheight),ft.push(it);else{if(!i.tiles)throw new Error("Tileset "+i.name+" has no `image` or `tiles` property.");st=new n.ImageCollection(i.name,i.firstgid,i.tilewidth,i.tileheight,i.margin,i.spacing,i.properties);for(d in i.tiles)k=i.tiles[d].image,o=i.firstgid+parseInt(d,10),st.addImage(o,k);et.push(st)}for(d in i.tiles)(y=i.tiles[d].objectgroup)&&(at[parseInt(d,10)+i.firstgid]=y);ot&&(ot.lastgid=i.firstgid-1);ot=i}if(0===ft.length&&0===et.length)throw new Error("This tilemap has no tilesets.");f.tilesets=ft;f.imagecollections=et;for(var vt={},ht={},r=0;r<t.layers.length;r++)"objectgroup"===t.layers[r].type&&(y=t.layers[r],this.parseObjectGroup(y,vt,ht));for(f.objects=vt,f.collision=ht,f.tiles=[],r=0;r<f.tilesets.length;r++)for(var a=(i=f.tilesets[r]).tileMargin,yt=i.tileMargin,bt=0,pt=0,kt=0,w=i.firstgid;w<i.firstgid+i.total&&(f.tiles[w]=[a,yt,r],a+=i.tileWidth+i.tileSpacing,++bt!==i.total)&&(++pt!==i.columns||(a=i.tileMargin,yt+=i.tileHeight+i.tileSpacing,pt=0,++kt!==i.rows));w++);for(r=0;r<f.layers.length;r++)for(ht[(l=f.layers[r]).name]=[],i=null,s=0;s<l.data.length;s++)for(v=l.data[s],rt=0;rt<v.length;rt++)null===(e=v[rt])||e.index<0||(wt=f.tiles[e.index][2],(i=f.tilesets[wt]).tileProperties&&i.tileProperties[e.index-i.firstgid]&&(e.properties=n.Utils.mixin(i.tileProperties[e.index-i.firstgid],e.properties)),(y=at[e.index])&&this.parseObjectGroup(y,f.objects,f.collision,e.layer.name,{x:e.worldX+y.x,y:e.worldY+y.y}));return f}},n.Tileset=function(n,t,i,r,u,f,e){(void 0===i||i<=0)&&(i=32);(void 0===r||r<=0)&&(r=32);void 0===u&&(u=0);void 0===f&&(f=0);this.name=n;this.firstgid=0|t;this.tileWidth=0|i;this.tileHeight=0|r;this.tileMargin=0|u;this.tileSpacing=0|f;this.properties=e||{};this.image=null;this.rows=0;this.columns=0;this.total=0;this.drawCoords=[]},n.Tileset.prototype={draw:function(n,t,i,r){var u=r-this.firstgid<<1;u>=0&&u+1<this.drawCoords.length&&n.drawImage(this.image,this.drawCoords[u],this.drawCoords[u+1],this.tileWidth,this.tileHeight,t,i,this.tileWidth,this.tileHeight)},containsTileIndex:function(n){return n>=this.firstgid&&n<this.firstgid+this.total},setImage:function(n){this.image=n;this.updateTileData(n.width,n.height)},setSpacing:function(n,t){this.tileMargin=0|n;this.tileSpacing=0|t;this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(n,t){var i=(t-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),r=(n-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing),f;i%1==0&&r%1==0||console.warn("Phaser.Tileset - '%s' image tile area (%s x %s) is not a whole multiple of tile size (%s x %s + %s + %s)",this.name,n,t,this.tileWidth,this.tileHeight,this.tileMargin,this.tileSpacing);i=Math.floor(i);r=Math.floor(r);(this.rows&&this.rows!==i||this.columns&&this.columns!==r)&&console.warn("Phaser.Tileset - Tile layout from image '%s' (%s rows by %s columns) differs from tileset '%s' (%s rows by %s columns)",this.image.name,r,i,this.name,this.columns,this.rows);this.rows=i;this.columns=r;this.total=i*r;this.drawCoords.length=0;for(var u=this.tileMargin,e=this.tileMargin,o=0;o<this.rows;o++){for(f=0;f<this.columns;f++)this.drawCoords.push(u),this.drawCoords.push(e),u+=this.tileWidth+this.tileSpacing;u=this.tileMargin;e+=this.tileHeight+this.tileSpacing}}},n.Tileset.prototype.constructor=n.Tileset,n.Particle=function(t,i,r,u,f){n.Sprite.call(this,t,i,r,u,f);this.autoScale=!1;this.scaleData=null;this._s=0;this.autoAlpha=!1;this.alphaData=null;this._a=0},n.Particle.prototype=Object.create(n.Sprite.prototype),n.Particle.prototype.constructor=n.Particle,n.Particle.prototype.update=function(){this.autoScale&&(--this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1);this.autoAlpha&&(--this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},n.Particle.prototype.onEmit=function(){},n.Particle.prototype.setAlphaData=function(n){this.alphaData=n;this._a=n.length-1;this.alpha=this.alphaData[this._a].v;this.autoAlpha=!0},n.Particle.prototype.setScaleData=function(n){this.scaleData=n;this._s=n.length-1;this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y);this.autoScale=!0},n.Particle.prototype.reset=function(t,i,r){return n.Component.Reset.prototype.reset.call(this,t,i,r),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},n.Particles=function(n){this.game=n;this.emitters={};this.ID=0},n.Particles.prototype={add:function(n){return this.emitters[n.id]=n,n},remove:function(n){delete this.emitters[n.id]}},n.Particles.prototype.constructor=n.Particles,n.Particles.Arcade={},n.Particles.Arcade.Emitter=function(t,i,r,u){this.maxParticles=u||50;n.Group.call(this,t);this._id=this.game.particles.ID++;this.name="emitter"+this.id;this.type=n.EMITTER;this.physicsType=n.GROUP;this.area=new n.Rectangle(i,r,1,1);this.minAngle=null;this.maxAngle=null;this.minSpeed=0;this.maxSpeed=100;this.minParticleSpeed=new n.Point(-100,-100);this.maxParticleSpeed=new n.Point(100,100);this.minParticleScale=1;this.maxParticleScale=1;this.scaleData=null;this.minRotation=-360;this.maxRotation=360;this.minParticleAlpha=1;this.maxParticleAlpha=1;this.alphaData=null;this.particleClass=n.Particle;this.particleDrag=new n.Point;this.angularDrag=0;this.frequency=100;this.lifespan=2e3;this.bounce=new n.Point;this.on=!1;this.particleAnchor=new n.Point(.5,.5);this.blendMode=n.blendModes.NORMAL;this.emitX=i;this.emitY=r;this.autoScale=!1;this.autoAlpha=!1;this.particleBringToTop=!1;this.particleSendToBack=!1;this.counts={emitted:0,failed:0,totalEmitted:0,totalFailed:0};this._gravity=new n.Point(0,100);this._minParticleScale=new n.Point(1,1);this._maxParticleScale=new n.Point(1,1);this._total=0;this._timer=0;this._counter=0;this._flowQuantity=0;this._flowTotal=0;this._explode=!0;this._frames=null},n.Particles.Arcade.Emitter.prototype=Object.create(n.Group.prototype),n.Particles.Arcade.Emitter.prototype.constructor=n.Particles.Arcade.Emitter,n.Particles.Arcade.Emitter.prototype.update=function(){if(this.counts.emitted=0,this.counts.failed=0,this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(this._flowQuantity>0){for(n=0;n<this._flowQuantity;n++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,this._total>0&&this._counter>=this._total&&(this.on=!1));for(var n=this.children.length;n--;)this.children[n].exists&&this.children[n].update()},n.Particles.Arcade.Emitter.prototype.makeParticles=function(n,t,i,r,u,f){void 0===t&&(t=0);void 0===i&&(i=this.maxParticles);void 0===r&&(r=!1);void 0===u&&(u=!1);void 0===f&&(f=null);var e,o=0,s=n,h=t;for(this._frames=t,i>this.maxParticles&&(this.maxParticles=i);o<i;)Array.isArray(n)&&(s=this.game.rnd.pick(n)),Array.isArray(t)&&(h=this.game.rnd.pick(t)),e=new this.particleClass(this.game,0,0,s,h,f),this.game.physics.arcade.enable(e,!1),e.body.checkCollision.none=!r,e.body.collideWorldBounds=u,e.body.skipQuadTree=!0,e.exists=!1,e.visible=!1,e.anchor.copyFrom(this.particleAnchor),this.add(e),o++;return this},n.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},n.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},n.Particles.Arcade.Emitter.prototype.explode=function(n,t){return void 0===t&&(t=this.maxParticles),this._flowTotal=0,this.start(!0,n,0,t,!1),this},n.Particles.Arcade.Emitter.prototype.flow=function(n,t,i,r,u){return void 0!==t&&null!==t||(t=250),void 0!==i&&0!==i||(i=1),void 0===r&&(r=-1),void 0===u&&(u=!0),i>this.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=r,u?(this.start(!0,n,t,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+t*this.game.time.slowMotion):this.start(!1,n,t,i),this},n.Particles.Arcade.Emitter.prototype.start=function(n,t,i,r,u){if(void 0===n&&(n=!0),void 0===t&&(t=0),void 0!==i&&null!==i||(i=250),void 0===r&&(r=0),void 0===u&&(u=!1),r>this.maxParticles&&(r=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=t,this.frequency=i,n||u)for(var f=0;f<r;f++)this.emitParticle();else this.on=!0,this._total=r,this._counter=0,this._timer=this.game.time.time+i*this.game.time.slowMotion;return this},n.Particles.Arcade.Emitter.prototype.emitParticle=function(n,t,i,r){var u,f,e,o;return(void 0===n&&(n=null),void 0===t&&(t=null),u=this.getNextParticle(),null===u)?(this.counts.failed++,this.counts.totalFailed++,!1):(this.counts.emitted++,this.counts.totalEmitted++,f=this.game.rnd,void 0!==i&&void 0!==r?u.loadTexture(i,r):void 0!==i&&(u.loadTexture(i),u.frame=Array.isArray(this._frames)?f.pick(this._frames):this._frames),e=this.emitX,o=this.emitY,null!==n?e=n:this.width>1&&(e=f.between(this.left,this.right)),null!==t?o=t:this.height>1&&(o=f.between(this.top,this.bottom)),this.resetParticle(u,e,o),!0)},n.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var n,t=this.length;t--;)if(n=this.next(),!n.exists)return n;return null},n.Particles.Arcade.Emitter.prototype.resetParticle=function(n,t,i){var u=this.game.rnd,r;n.reset(t,i);n.angle=0;n.lifespan=this.lifespan;this.particleBringToTop?this.bringToTop(n):this.particleSendToBack&&this.sendToBack(n);this.autoScale?n.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?n.scale.set(u.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?n.scale.set(u.realInRange(this._minParticleScale.x,this._maxParticleScale.x),u.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):n.scale.set(this._minParticleScale.x,this._minParticleScale.y);this.autoAlpha?n.setAlphaData(this.alphaData):n.alpha=u.realInRange(this.minParticleAlpha,this.maxParticleAlpha);n.blendMode=this.blendMode;r=n.body;r.updateBounds();r.bounce.copyFrom(this.bounce);r.drag.copyFrom(this.particleDrag);null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:u.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:u.between(this.minSpeed,this.maxSpeed),r.velocity):(r.velocity.x=u.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),r.velocity.y=u.between(this.minParticleSpeed.y,this.maxParticleSpeed.y));r.angularVelocity=u.between(this.minRotation,this.maxRotation);r.gravity.copyFrom(this.gravity);r.angularDrag=this.angularDrag;n.onEmit()},n.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this);n.Group.prototype.destroy.call(this,!0,!1)},n.Particles.Arcade.Emitter.prototype.setSize=function(n,t){return this.area.width=n,this.area.height=t,this},n.Particles.Arcade.Emitter.prototype.setXSpeed=function(n,t){return n=n||0,t=t||0,this.minParticleSpeed.x=n,this.maxParticleSpeed.x=t,this},n.Particles.Arcade.Emitter.prototype.setYSpeed=function(n,t){return n=n||0,t=t||0,this.minParticleSpeed.y=n,this.maxParticleSpeed.y=t,this},n.Particles.Arcade.Emitter.prototype.setRotation=function(n,t){return n=n||0,t=t||0,this.minRotation=n,this.maxRotation=t,this},n.Particles.Arcade.Emitter.prototype.setAlpha=function(t,i,r,u,f){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),void 0===u&&(u=n.Easing.Linear.None),void 0===f&&(f=!1),this.minParticleAlpha=t,this.maxParticleAlpha=i,this.autoAlpha=!1,r>0&&t!==i){var o={v:t},e=this.game.make.tween(o).to({v:i},r,u);e.yoyo(f);this.alphaData=e.generateData(60);this.alphaData.reverse();this.autoAlpha=!0}return this},n.Particles.Arcade.Emitter.prototype.setScale=function(t,i,r,u,f,e,o){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===u&&(u=1),void 0===f&&(f=0),void 0===e&&(e=n.Easing.Linear.None),void 0===o&&(o=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(t,r),this._maxParticleScale.set(i,u),this.autoScale=!1,f>0&&(t!==i||r!==u)){var h={x:t,y:r},s=this.game.make.tween(h).to({x:i,y:u},f,e);s.yoyo(o);this.scaleData=s.generateData(60);this.scaleData.reverse();this.autoScale=!0}return this},n.Particles.Arcade.Emitter.prototype.setAngle=function(n,t,i,r){return this.minAngle=n,this.maxAngle=t,null!=i&&(this.minSpeed=i),null!=r&&(this.maxSpeed=r),this},n.Particles.Arcade.Emitter.prototype.at=function(n){return n.center?(this.emitX=n.center.x,this.emitY=n.center.y):(this.emitX=n.world.x+n.anchor.x*n.width,this.emitY=n.world.y+n.anchor.y*n.height),this},Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(n){"number"==typeof n?this._gravity.y=n:this._gravity=n}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(n){this.area.width=n}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(n){this.area.height=n}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(n){this.emitX=n}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(n){this.emitY=n}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?1/0:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(n.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),n.Weapon=function(t,i){n.Plugin.call(this,t,i);this.bullets=null;this.autoExpandBulletsGroup=!1;this.autofire=!1;this.shots=0;this.fireLimit=0;this.fireRate=100;this.fireRateVariance=0;this.fireFrom=new n.Rectangle(0,0,1,1);this.fireAngle=n.ANGLE_UP;this.bulletInheritSpriteSpeed=!1;this.bulletAnimation="";this.bulletFrameRandom=!1;this.bulletFrameCycle=!1;this.bulletWorldWrap=!1;this.bulletWorldWrapPadding=0;this.bulletAngleOffset=0;this.bulletAngleVariance=0;this.bulletSpeed=200;this.bulletSpeedVariance=0;this.bulletLifespan=0;this.bulletKillDistance=0;this.bulletGravity=new n.Point(0,0);this.bulletRotateToVelocity=!1;this.bulletKey="";this.bulletFrame="";this._bulletClass=n.Bullet;this._bulletCollideWorldBounds=!1;this._bulletKillType=n.Weapon.KILL_WORLD_BOUNDS;this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0};this.bounds=new n.Rectangle;this.bulletBounds=t.world.bounds;this.bulletFrames=[];this.bulletFrameIndex=0;this.anims={};this.onFire=new n.Signal;this.onKill=new n.Signal;this.onFireLimit=new n.Signal;this.trackedSprite=null;this.trackedPointer=null;this.multiFire=!1;this._hasFired=!1;this.trackRotation=!1;this.trackOffset=new n.Point;this._nextFire=0;this._tempNextFire=0;this._rotatedPoint=new n.Point},n.Weapon.prototype=Object.create(n.Plugin.prototype),n.Weapon.prototype.constructor=n.Weapon,n.Weapon.KILL_NEVER=0,n.Weapon.KILL_LIFESPAN=1,n.Weapon.KILL_DISTANCE=2,n.Weapon.KILL_WEAPON_BOUNDS=3,n.Weapon.KILL_CAMERA_BOUNDS=4,n.Weapon.KILL_WORLD_BOUNDS=5,n.Weapon.KILL_STATIC_BOUNDS=6,n.Weapon.prototype.createBullets=function(t,i,r,u){return void 0===t&&(t=1),void 0===u&&(u=this.game.world),this.bullets&&!this.bullets.game&&(this.bullets=null),this.bullets||(this.bullets=this.game.add.physicsGroup(n.Physics.ARCADE,u),this.bullets.classType=this._bulletClass),0!==t&&(-1===t&&(this.autoExpandBulletsGroup=!0,t=1),this.bullets.createMultiple(t,i,r),this.bullets.setAll("data.bulletManager",this),this.bulletKey=i,this.bulletFrame=r),this},n.Weapon.prototype.forEach=function(n,t){return this.bullets.forEachExists(n,t,arguments),this},n.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},n.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},n.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},n.Weapon.prototype.resetShots=function(n){return this.shots=0,void 0!==n&&(this.fireLimit=n),this},n.Weapon.prototype.destroy=function(){this.parent.remove(this,!1);this.bullets.destroy();this.game=null;this.parent=null;this.active=!1;this.visible=!1},n.Weapon.prototype.update=function(){this._bulletKillType===n.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY));this.autofire&&this.fire()},n.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},n.Weapon.prototype.trackSprite=function(n,t,i,r){return void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=!1),this.trackedPointer=null,this.trackedSprite=n,this.trackRotation=r,this.trackOffset.set(t,i),this},n.Weapon.prototype.trackPointer=function(n,t,i){return void 0===n&&(n=this.game.input.activePointer),void 0===t&&(t=0),void 0===i&&(i=0),this.trackedPointer=n,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(t,i),this},n.Weapon.prototype.fireMany=function(n,t){this.multiFire=!0;var i=[],r=this;return t||this.trackedSprite||this.trackedPointer?n.forEach(function(n){i.push(r.fire(t,null,null,n.x,n.y))}):n.forEach(function(n){i.push(r.fire(n))}),i},n.Weapon.prototype.fireOffset=function(n,t){return void 0===n&&(n=0),void 0===t&&(t=0),this.fire(null,null,null,n,t)},n.Weapon.prototype.fire=function(t,i,r,u,f){var s,v,y,e,h,c,p;if(void 0===i&&(i=null),void 0===r&&(r=null),this.game.time.now<this._nextFire||this.fireLimit>0&&this.shots===this.fireLimit)return null;s=this.bulletSpeed;0!==this.bulletSpeedVariance&&(s+=n.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance));t?this.fireFrom.width>1?this.fireFrom.centerOn(t.x,t.y):(this.fireFrom.x=t.x,this.fireFrom.y=t.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.worldRotation),this.fireFrom.width>1?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(s+=this.trackedSprite.body.speed)):this.trackedPointer&&(this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y));void 0!==u&&(this.fireFrom.x+=u);void 0!==f&&(this.fireFrom.y+=f);var l=this.fireFrom.width>1?this.fireFrom.randomX:this.fireFrom.x,a=this.fireFrom.height>1?this.fireFrom.randomY:this.fireFrom.y,o=this.trackRotation?this.trackedSprite.angle:this.fireAngle;return null!==i&&null!==r&&(o=this.game.math.radToDeg(Math.atan2(r-a,i-l))),0!==this.bulletAngleVariance&&(o+=n.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance)),v=0,y=0,0===o||180===o?v=Math.cos(this.game.math.degToRad(o))*s:90===o||270===o?y=Math.sin(this.game.math.degToRad(o))*s:(v=Math.cos(this.game.math.degToRad(o))*s,y=Math.sin(this.game.math.degToRad(o))*s),e=null,(this.autoExpandBulletsGroup?(e=this.bullets.getFirstExists(!1,!0,l,a,this.bulletKey,this.bulletFrame)).data.bulletManager=this:e=this.bullets.getFirstExists(!1),e)&&((e.reset(l,a),e.data.fromX=l,e.data.fromY=a,e.data.killType=this.bulletKillType,e.data.killDistance=this.bulletKillDistance,e.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===n.Weapon.KILL_LIFESPAN&&(e.lifespan=this.bulletLifespan),e.angle=o+this.bulletAngleOffset,""!==this.bulletAnimation)?(null===e.animations.getAnimation(this.bulletAnimation)&&(h=this.anims[this.bulletAnimation],e.animations.add(h.name,h.frames,h.frameRate,h.loop,h.useNumericIndex)),e.animations.play(this.bulletAnimation)):this.bulletFrameCycle?(e.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(e.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]),e.data.bodyDirty&&(this._data.customBody&&e.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),e.body.collideWorldBounds=this.bulletCollideWorldBounds,e.data.bodyDirty=!1),e.body.velocity.set(v,y),e.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y),c=0,0!==this.bulletSpeedVariance?(p=this.fireRate,(p+=n.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(p=0),c=this.game.time.now+p):c=this.game.time.now+this.fireRate,this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=c,this.shots++):(this._nextFire=c,this.shots++),this.onFire.dispatch(e,this,s),this.fireLimit>0&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)),e},n.Weapon.prototype.fireAtPointer=function(n){return void 0===n&&(n=this.game.input.activePointer),this.fire(null,n.worldX,n.worldY)},n.Weapon.prototype.fireAtSprite=function(n){return this.fire(null,n.world.x,n.world.y)},n.Weapon.prototype.fireAtXY=function(n,t){return this.fire(null,n,t)},n.Weapon.prototype.setBulletBodyOffset=function(n,t,i,r){return void 0===i&&(i=0),void 0===r&&(r=0),this._data.customBody=!0,this._data.width=n,this._data.height=t,this._data.offsetX=i,this._data.offsetY=r,this.bullets.callAll("body.setSize","body",n,t,i,r),this.bullets.setAll("data.bodyDirty",!1),this},n.Weapon.prototype.setBulletFrames=function(t,i,r,u){return void 0===r&&(r=!0),void 0===u&&(u=!1),this.bulletFrames=n.ArrayUtils.numberArray(t,i),this.bulletFrameIndex=0,this.bulletFrameCycle=r,this.bulletFrameRandom=u,this},n.Weapon.prototype.addBulletAnimation=function(n,t,i,r,u){return this.anims[n]={name:n,frames:t,frameRate:i,loop:r,useNumericIndex:u},this.bullets.callAll("animations.add","animations",n,t,i,r,u),this.bulletAnimation=n,this},n.Weapon.prototype.debug=function(n,t,i){void 0===n&&(n=16);void 0===t&&(t=32);void 0===i&&(i=!1);this.game.debug.text("Weapon Plugin",n,t);this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,n,t+24);i&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(n.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(n){this._bulletClass=n;this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(n.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(t){switch(t){case n.Weapon.KILL_STATIC_BOUNDS:case n.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case n.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case n.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=t}}),Object.defineProperty(n.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(n){this._bulletCollideWorldBounds=n;this.bullets.setAll("body.collideWorldBounds",n);this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(n.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(n){this.fireFrom.x=n}}),Object.defineProperty(n.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(n){this.fireFrom.y=n}}),n.Bullet=function(t,i,r,u,f){n.Sprite.call(this,t,i,r,u,f);this.anchor.set(.5);this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},n.Bullet.prototype=Object.create(n.Sprite.prototype),n.Bullet.prototype.constructor=n.Bullet,n.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},n.Bullet.prototype.update=function(){this.exists&&(this.data.killType>n.Weapon.KILL_LIFESPAN&&(this.data.killType===n.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=this.body.velocity.atan()),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},n.Video=function(t,i,r){if(void 0===i&&(i=null),void 0===r&&(r=null),this.game=t,this.key=i,this.width=0,this.height=0,this.type=n.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new n.Signal,this.onChangeSource=new n.Signal,this.onComplete=new n.Signal,this.onAccess=new n.Signal,this.onError=new n.Signal,this.onTimeout=new n.Signal,this.onTouchUnlock=new n.Signal,this.playWhenUnlocked=!0,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,i&&this.game.cache.checkVideoKey(i)){var u=this.game.cache.getVideo(i);u.isBlob?this.createVideoFromBlob(u.data):this.video=u.data;this.width=this.video.videoWidth;this.height=this.video.videoHeight}else r&&this.createVideoFromURL(r,!1);this.video&&!r?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(n.Cache.DEFAULT.baseTexture.source,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height));this.texture=new PIXI.Texture(this.baseTexture);this.textureFrame=new n.Frame(0,0,0,this.width,this.height,"video");this.texture.setFrame(this.textureFrame);this.texture.valid=!1;null!==i&&this.video&&(this.texture.valid=this.video.canplay);this.snapshot=null;n.BitmapData&&(this.snapshot=new n.BitmapData(this.game,"",this.width,this.height));this.game.device.needsTouchUnlock()?this.setTouchLock():u&&(u.locked=!1)},n.Video.prototype={connectToMediaStream:function(n,t){return n&&t&&(this.video=n,this.videoStream=t,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(n,t,i){if(void 0===n&&(n=!1),void 0===t&&(t=null),void 0===i&&(i=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop());this.removeVideoElement();this.video=document.createElement("video");this.video.setAttribute("autoplay","autoplay");this.video.setAttribute("playsinline","playsinline");null!==t&&(this.video.width=t);null!==i&&(this.video.height=i);this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:n,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(n){this.getUserMediaError(n)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID);this.onTimeout.dispatch(this)},getUserMediaError:function(n){clearTimeout(this._timeOutID);this.onError.dispatch(this,n)},getUserMediaSuccess:function(n){clearTimeout(this._timeOutID);this.videoStream=n;void 0!==this.video.mozSrcObject?this.video.mozSrcObject=n:void 0!==this.video.srcObject?this.video.srcObject=n:this.video.src=window.URL&&window.URL.createObjectURL(n)||n;var t=this;this.video.onloadeddata=function(){function n(){if(i>0)if(t.video.videoWidth>0){var r=t.video.videoWidth,u=t.video.videoHeight;isNaN(t.video.videoHeight)&&(u=r/(4/3));t.video.play();t.isStreaming=!0;t.baseTexture.source=t.video;t.updateTexture(null,r,u);t.onAccess.dispatch(t)}else window.setTimeout(n,500);else console.warn("Unable to connect to video stream. Webcam error?");i--}var i=10;n()}},createVideoFromBlob:function(n){var t=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.addEventListener("loadeddata",function(n){t.updateTexture(n)},!0),this.video.src=window.URL.createObjectURL(n),this.video.canplay=!0,this},createVideoFromURL:function(n,t){return void 0===t&&(t=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,t&&this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.src=n,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=n,this},updateTexture:function(n,t,i){var r=!1;void 0!==t&&null!==t||(t=this.video.videoWidth,r=!0);void 0!==i&&null!==i||(i=this.video.videoHeight);this.width=t;this.height=i;this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video);this.baseTexture.forceLoaded(t,i);this.texture.frame.resize(t,i);this.texture.width=t;this.texture.height=i;this.texture.valid=!0;this.snapshot&&this.snapshot.resize(t,i);r&&null!==this.key&&(this.onChangeSource.dispatch(this,t,i),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(n,t){return this._pendingChangeSource?this:(void 0===n&&(n=!1),void 0===t&&(t=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=n?"loop":"",this.video.playbackRate=t,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0))),this.video.play(),this.onPlay.dispatch(this,n,t)),this)},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0);this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):this.video.srcObject?(this.video.srcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(n){n.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(n){if(Array.isArray(n))for(var t=0;t<n.length;t++)n[t].loadTexture&&n[t].loadTexture(this);else n.loadTexture(this);return this},addToWorld:function(n,t,i,r,u,f){u=u||1;f=f||1;var e=this.game.add.image(n,t,this);return e.anchor.set(i,r),e.scale.set(u,f),e},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){this._muted&&!this._codeMuted&&(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,this.video.ended||this.video.play())},changeSource:function(n,t){return void 0===t&&(t=!0),this.texture.valid=!1,this.video.pause(),this._pendingChangeSource=!0,this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=n,this.video.load(),this._autoplay=t,t||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?(this._pendingChangeSource=!1,this.updateTexture()):--this.retry>0?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming)},setTouchLock:function(){this.game.input.addTouchLockCallback(this.unlock,this,!0);this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.playWhenUnlocked&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)),this.key){var n=this.game.cache.getVideo(this.key);n&&!n.isBlob&&(n.locked=!1)}return this.onTouchUnlock.dispatch(this),!0},grab:function(n,t,i){if(void 0===n&&(n=!1),void 0===t&&(t=1),void 0===i&&(i=null),null!==this.snapshot)return n&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,t,i),this.snapshot;console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable")},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay");this.video.removeAttribute("src");this.video=null}},destroy:function(){this.stop();this.removeVideoElement();this.touchLocked&&this.game.input.removeTouchLockCallback(this.unlock,this);this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(n.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(n){this.video.currentTime=n}}),Object.defineProperty(n.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(n.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(n.Video.prototype,"mute",{get:function(){return this._muted},set:function(n){if(n=n||null){if(this._muted)return;this._codeMuted=!0;this.setMute()}else{if(!this._muted)return;this._codeMuted=!1;this.unsetMute()}}}),Object.defineProperty(n.Video.prototype,"paused",{get:function(){return this._paused},set:function(n){if(n=n||null,!this.touchLocked)if(n){if(this._paused)return;this._codePaused=!0;this.setPause()}else{if(!this._paused)return;this._codePaused=!1;this.setResume()}}}),Object.defineProperty(n.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(n){n<0?n=0:n>1&&(n=1);this.video&&(this.video.volume=n)}}),Object.defineProperty(n.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(n){this.video&&(this.video.playbackRate=n)}}),Object.defineProperty(n.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(n){n&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(n.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),n.Video.prototype.constructor=n.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=n.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=n.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new n.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return n.Device.canUseMultiply},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports.Phaser=n):"undefined"!=typeof define&&define.amd?define("Phaser",u.Phaser=n):u.Phaser=n,n}.call(this);!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.StateTransition=t()}(this,function(){var n=function(n){this.game=n;this.onComplete=null;this._tweens=[]},i,r,u;n.prototype.start=function(n,t){var i,f,r=t.props,e=!!t.intro,u={_:{}};for(i in this.currentTarget=n,"function"==typeof r&&(r=r(this.game)),e&&this._prepareTargetForTweening(r),r)r.hasOwnProperty(i)&&("function"==typeof r[i]&&(r[i]=r[i](this.game)),"object"==typeof n[i]?u[i]=r[i]:u._[i]=r[i]);for(i in u)u.hasOwnProperty(i)&&(this._tweens.push(this.game.add.tween("_"===i?n:n[i])[e?"from":"to"](u[i],t.duration,t.ease,!0,t.delay)),(f=this._tweens[this._tweens.length-1]).onComplete.addOnce(this._checkForComplete,this),f.onLoop.addOnce(function(){console.log("progress",this)},this))};n.prototype._checkForComplete=function(n,t){for(var i=0,r=this._tweens.length,u=0;i<r;i++)!1===this._tweens[i].isRunning&&(u++,this.game.tweens.remove(t));u===r&&(this.onComplete&&this.onComplete(),this.currentTarget.destroy())};n.prototype._prepareTargetForTweening=function(n){n.hasOwnProperty("alpha")&&(this.currentTarget.alpha=0)};n.prototype.destroy=function(n){n.destroy()};n.prototype.stop=function(){this._active=!1;this.update()};var e=function(){return parseInt(Phaser.VERSION.replace(/\./g,""),10)>248},f=function(n){function t(t,i,r,u){var o=new Phaser.RenderTexture(t,t.width,t.height),f;(n.call(this,t,i||0,r||0,o),u)||(f=new Phaser.Graphics(t,0,0),f.beginFill(t.stage.backgroundColor),f.drawRect(0,0,t.width,t.height),f.endFill(),t.stage.addChildAt(f,0),o.renderXY(f,0,0),t.stage.removeChild(f));e()?o.renderXY(t.world,-1*t.camera.position.x,-1*t.camera.position.y):o.renderXY(t.world,t.width/2-t.camera.position.x,t.height/2-t.camera.position.y);this.inputEnabled=!0}return n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t,t}(Phaser.Image),t=function(t,i){this.game=t;this._contentSnapshot=new f(t,0,0,i);this._transition=new n(t)};return t.prototype.go=function(n){this.game.stage.addChildAt(this._contentSnapshot,this.game.stage.children.length);this._transition.start(this._contentSnapshot,n)},i=function(n){for(var t=0,i=n.length;t<i;t+=1)n[t]&&n[t]instanceof f&&n[t].destroy()},r=Phaser.StateManager.prototype.start,Phaser.StateManager.prototype.start=function(n,u,f){for(var o=[],e=arguments.length-3;e-->0;)o[e]=arguments[e+3];(function(n,r,u){var o,e,f=this,s=f.states[n],h=s.create;f.game.stage&&i(f.game.stage.children);f.game.isBooted&&r&&(o=new t(f.game,r.noStage),function(n,r,u){n.create=function(){h.call(this);u&&(e=new t(f.game,u.noStage),f._created=!1,e.go(u),e._transition.onComplete=function(){f._created=!0;i(f.game.stage.children)});o.go(r);n.create=h}}(s,r,u))}).call(this,n,u,f);r.call.apply(r,[this,n].concat(o))},u=function(n){function t(){n.apply(this,arguments)}return n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t,t}(Phaser.Plugin),u.createTransition=function(n){return{ease:n.ease||Phaser.Easing.Exponential.InOut,duration:n.duration||500,intro:n.intro||!1,props:n.props||{}}},u});var GameType={Block:1,Draw:2,Pyramid:3,Muggins:4,AllFives:5,FiveUp:6,AllThrees:7,Sebastopol:8,Bergen:9,Chickenfoot:10,MexicanTrain:11,Concentration:12,FivesAndThrees:13,MalteseCross:14,BlockOneSpinner:15,BlockAllSpinners:16,DrawOneSpinner:17,DrawAllSpinners:18,ArabDraw:19,DiceDominoMatch:20,Dominosa:21,Slosh:22,Partnership:23,SevenPis:24,FairLucy:25,Luzon:26,Stack:27,Gaple:28,Hungarian:29,Freecell:30,Jubilee:31,Sniff:32,Canton:33,SevenUp:34,AllSevensNoSpinner:35,AllSevensOneSpinner:36,SevenRocks:37,SevenToedPete:38,HorseRace:39,Sevens:40,Patience:41,CrissCross:42,FlowerScorpion:43,Buccaneer:44,PaiGow:45,PassPass:46,DominoMatch:47,French:48,TienGow:49,ThreeDozen:50,PassAndOut:51,Cuban:52,Austrian:53,BlindHughie:54,Abacus:55,AllPrimesNoSpinner:56,AllPrimesOneSpinner:57,HonestJohn:58,Domino99:100},GameMode={Classic:1,Relaxed:2},PlayOptions={NoSpinner:1,OneSpinner:2,AllSpinners:3},dominoGames=[{id:GameType.Block,name:"Block Dominoes",multiplayer:!0,titleClass:"block",url:"/block-dominoes",state:"Draw",selection:!0},{id:GameType.Draw,name:"Draw Dominoes",multiplayer:!0,titleClass:"draw",url:"/draw-dominoes",state:"Draw",selection:!0},{id:GameType.BlockOneSpinner,name:"Block Dominoes (One Spinner)",multiplayer:!0,titleClass:"blockonespinner",url:"/block-dominoes-one-spinner",state:"DrawSpinner",selection:!0},{id:GameType.BlockAllSpinners,name:"Block Dominoes (All Spinners)",multiplayer:!0,titleClass:"blockmultispinners",url:"/block-dominoes-multiple-spinners",state:"DrawSpinner",selection:!0},{id:GameType.DrawOneSpinner,name:"Draw Dominoes (One Spinner)",multiplayer:!0,titleClass:"drawonespinner",url:"/draw-dominoes-one-spinner",state:"DrawSpinner",selection:!0},{id:GameType.DrawAllSpinners,name:"Draw Dominoes (All Spinners)",multiplayer:!0,titleClass:"drawmultispinners",url:"/draw-dominoes-multiple-spinners",state:"DrawSpinner",selection:!0},{id:GameType.Muggins,name:"Muggins",multiplayer:!0,titleClass:"muggins",url:"/muggins-dominoes",state:"Muggins",selection:!0},{id:GameType.AllFives,name:"All Fives",multiplayer:!0,titleClass:"allfives",url:"/allfives-dominoes",state:"Fives",selection:!0},{id:GameType.FiveUp,name:"Five Up",multiplayer:!0,titleClass:"fiveup",url:"/fiveup-dominoes",state:"Fives",selection:!0},{id:GameType.AllThrees,name:"All Threes",multiplayer:!0,titleClass:"allthrees",url:"/allthrees-dominoes",state:"Fives",selection:!0},{id:GameType.Bergen,name:"Bergen Dominoes",multiplayer:!0,titleClass:"bergen",url:"/bergen-dominoes",state:"Bergen",selection:!0},{id:GameType.Chickenfoot,name:"Chickenfoot Dominoes",multiplayer:!0,titleClass:"chickenfoot",url:"/chickenfoot-dominoes",state:"Chickenfoot",selection:!0},{id:GameType.MexicanTrain,name:"Mexican Train",multiplayer:!0,titleClass:"mexicantrain",url:"/mexicantrain-dominoes",state:"Train",selection:!0},{id:GameType.FivesAndThrees,name:"Fives and Threes",multiplayer:!0,titleClass:"fivesandthrees",url:"/fives-and-threes",state:"Muggins",selection:!0},{id:GameType.MalteseCross,name:"Maltese Cross",multiplayer:!0,titleClass:"maltesecross",url:"/maltese-cross-dominoes",state:"MalteseCross",selection:!0},{id:GameType.ArabDraw,name:"Arab Draw Dominoes",multiplayer:!0,titleClass:"arabdraw",url:"/arab-draw-dominoes",state:"ArabDraw",selection:!0},{id:GameType.Pyramid,name:"Pyramid Dominoes",multiplayer:!1,titleClass:"pyramid",url:"/pyramid-dominoes",state:"Pyramid",dual:!0},{id:GameType.Sebastopol,name:"Sebastopol",multiplayer:!1,titleClass:"sebastopol",url:"/sebastopol-dominoes",state:"Sebastopol",dual:!1},{id:GameType.Slosh,name:"Slosh Dominoes",multiplayer:!1,titleClass:"slosh",url:"/slosh-dominoes",state:"Slosh",dual:!1,selection:!1},{id:GameType.Partnership,name:"Partnership Dominoes",multiplayer:!1,titleClass:"partner",url:"/partnership-dominoes",state:"Partnership",dual:!1,selection:!1},{id:GameType.Concentration,name:"Concentration",multiplayer:!1,titleClass:"concentration",url:"/concentration-dominoes",state:"Concentration",dual:!1,selection:!1},{id:GameType.DiceDominoMatch,name:"Dice Domino Match",multiplayer:!1,titleClass:"dicedominomatch",url:"/dice-domino-match",state:"DiceDominoMatch",dual:!1},{id:GameType.SevenPis,name:"Seven Pis",multiplayer:!1,titleClass:"sevenpis",url:"/seven-pis-dominoes",state:"SevenPis",dual:!1},{id:GameType.FairLucy,name:"Fair Lucy",multiplayer:!1,titleClass:"fairlucy",url:"/fair-lucy-dominoes",state:"FairLucy",dual:!1,selection:!1},{id:GameType.Luzon,name:"Luzon Dominoes",multiplayer:!1,titleClass:"luzon",url:"/luzon-dominoes",state:"Luzon",dual:!1,selection:!1},{id:GameType.Stack,name:"Stack Dominoes",multiplayer:!1,titleClass:"stack",url:"/stack-dominoes",state:"Stack",dual:!1,selection:!1},{id:GameType.Gaple,name:"Gaple Dominoes",multiplayer:!1,titleClass:"gaple",url:"/gaple-dominoes",state:"Gaple",dual:!1,selection:!1},{id:GameType.Dominosa,name:"Dominosa",titleClass:"dominosa",url:"/dominosa",selection:!1},{id:GameType.Hungarian,name:"Hungarian Dominoes",multiplayer:!0,titleClass:"hungarian",url:"/hungarian-dominoes",state:"Hungarian",selection:!0},{id:GameType.Freecell,name:"Freecell Dominoes",multiplayer:!1,titleClass:"freecell",url:"/freecell-dominoes",state:"Freecell",dual:!1,selection:!1},{id:GameType.Jubilee,name:"Jubilee Dominoes",multiplayer:!1,titleClass:"jubilee",url:"/jubilee-dominoes",state:"Jubilee",dual:!1,selection:!1},{id:GameType.Sniff,name:"Sniff Dominoes",multiplayer:!0,titleClass:"sniff",url:"/sniff-dominoes",state:"Fives",selection:!0},{id:GameType.Canton,name:"Canton Dominoes",multiplayer:!0,titleClass:"canton",url:"/canton-dominoes",state:"Canton",selection:!0},{id:GameType.AllSevensNoSpinner,name:"All Sevens (No Spinner)",multiplayer:!0,titleClass:"allsevens0",url:"/allsevens-dominoes",state:"Sevens",selection:!0},{id:GameType.AllSevensOneSpinner,name:"All Seven (One Spinner)",multiplayer:!0,titleClass:"allsevens1",url:"/allsevens-dominoes-one-spinner",state:"Sevens",selection:!0},{id:GameType.SevenUp,name:"Seven Up",multiplayer:!0,titleClass:"sevenup",url:"/sevenup-dominoes",state:"Sevens",selection:!0},{id:GameType.SevenRocks,name:"Seven Rocks",multiplayer:!1,titleClass:"sevenrocks",url:"/sevenrocks-dominoes",state:"SevenRocks",dual:!1,selection:!1},{id:GameType.SevenToedPete,name:"Seven Toed Pete",multiplayer:!1,titleClass:"seventoedpete",url:"/seventoedpete-dominoes",state:"SevenToedPete",dual:!1,selection:!1},{id:GameType.HorseRace,name:"Horse Race",multiplayer:!0,titleClass:"horserace",url:"/horserace-dominoes",state:"SevenToedPete",selection:!0},{id:GameType.Sevens,name:"Sevens Dominoes",multiplayer:!0,titleClass:"sevens",url:"/sevens-dominoes",state:"SevensGame",selection:!0},{id:GameType.Patience,name:"Patience Dominoes",multiplayer:!1,titleClass:"patience",url:"/patience-dominoes",state:"Patience",dual:!1,selection:!1},{id:GameType.CrissCross,name:"CrissCross Dominoes",multiplayer:!1,titleClass:"crisscross",url:"/crisscross-dominoes",state:"CrissCross",dual:!1,selection:!1},{id:GameType.FlowerScorpion,name:"Flower Scorpion",multiplayer:!0,titleClass:"flowerscorpion",url:"/flower-and-scorpion-dominoes",state:"FlowerScorpion",selection:!0},{id:GameType.Buccaneer,name:"Buccaneer",multiplayer:!1,titleClass:"buccaneer",url:"/buccaneer-dominoes",state:"Buccaneer",dual:!1,selection:!1},{id:GameType.PassPass,name:"Pass-Pass Dominoes",multiplayer:!1,titleClass:"passpass",url:"/pass-pass-dominoes",state:"PassPass",dual:!1,selection:!1},{id:GameType.DominoMatch,name:"Domino Match",multiplayer:!1,titleClass:"dominomatch",url:"/domino-match",state:"DominoMatch",dual:!1,selection:!1},{id:GameType.French,name:"French Dominoes",multiplayer:!1,titleClass:"french",url:"/french-dominoes",state:"French",dual:!1,selection:!1},{id:GameType.PaiGow,name:"Pai Gow",multiplayer:!1,titleClass:"paigow",url:"/pai-gow",state:"PaiGow",dual:!1,selection:!1},{id:GameType.TienGow,name:"Tien Gow",multiplayer:!1,titleClass:"tiengow",url:"/tien-gow",state:"TienGow",dual:!1,selection:!1},{id:GameType.ThreeDozen,name:"Three Dozen",multiplayer:!0,titleClass:"threedozen",url:"/three-dozen",state:"ThreeDozen",selection:!0},{id:GameType.PassAndOut,name:"Pass and Out",multiplayer:!0,titleClass:"passandout",url:"/pass-and-out-dominoes",state:"PassAndOut",selection:!0},{id:GameType.Cuban,name:"Cuban Dominoes",multiplayer:!1,titleClass:"cuban",url:"/cuban-dominoes",state:"Cuban",dual:!1,selection:!1},{id:GameType.Austrian,name:"Austrian Dominoes",multiplayer:!1,titleClass:"austrian",url:"/austrian-dominoes",state:"Austrian",dual:!1,selection:!1},{id:GameType.BlindHughie,name:"Blind Hughie",multiplayer:!0,titleClass:"blindhughie",url:"/blind-hughie",state:"BlindHughie",selection:!0},{id:GameType.Abacus,name:"Abacus Dominoes",multiplayer:!1,titleClass:"abacus",url:"/abacus-dominoes",state:"Abacus",dual:!1,selection:!1},{id:GameType.AllPrimesNoSpinner,name:"All Primes (No Spinner)",multiplayer:!0,titleClass:"allprimes0",url:"/allprimes-dominoes",state:"Muggins",selection:!0},{id:GameType.AllPrimesOneSpinner,name:"All Primes (One Spinner)",multiplayer:!0,titleClass:"allprimes1",url:"/allprimes-dominoes-one-spinner",state:"Fives",selection:!0},{id:GameType.HonestJohn,name:"Honest John",multiplayer:!1,titleClass:"honestjohn",url:"/honest-john",state:"HonestJohn",dual:!1,selection:!1},],row1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,28,31,32,33,34,35,38,39,42,49,50,53,55,56],row2=[17,18,19,36,37,44,20,21,22,23,24,25,26,30,29,40,41,43,27,45,46,47,48,51,52,54],imageClasses={2:"two",3:"three",4:"four"},globalOptions={showEmbedAds:!0,showMobilePreloadAds:!1},dominoGameState=null,isEmbed=!1,str1='<div class="col-6 col-sm-4 col-md-3"><div class="overlay-container"><img alt="" src="/Resources/images/board.png" class="img-responsive" width="300" height="300"/><div class="overlay-top"><img class="',str2=' title" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABaAQMAAADHOIuVAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABlJREFUeNrtwTEBAAAAwqD1T+1vBqAAAHgDCSQAAT2geaMAAAAASUVORK5CYII=" /><\/div>',str3='<div class="overlay-middle"><img src="/Resources/images/down.png" width="100" height="100" class="middle" onclick="javascript:decCount(',str4=');"/><img class="four middle" id="cnt',str5='" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABRJREFUeNpjYBgFo2AUjIJRQE8AAAV4AAHYKaK4AAAAAElFTkSuQmCC" /><img src="/Resources/images/up.png" width="100" height="100" class="middle" onclick="javascript:incCount(',str6=');"/><\/div>',str7='<div class="overlay-bottom"><img src="/Resources/images/play.png" width="200" height="90" class="play img-responsive" onclick="javascript:playGame(',str8=');"/><\/div><\/div><\/div>',str9='<div class="overlay-middle"><img src="/Resources/images/classic.png" width="200" height="90" class="play m10 img-responsive" onclick="javascript:playGame(',str10=');"/><\/div>',str11='<div class="overlay-bottom"><img src="/Resources/images/relaxed.png"width="200" height="90" class="play img-responsive" onclick="javascript:playGame(',str12=');"/><\/div><\/div><\/div>',str13='<div class="col-6 col-sm-4 col-md-3"><div class="overlay-container"><img alt="" src="/Resources/images/board_1.png" class="img-responsive" width="300" height="300"/><div class="overlay-upper"><img class="',str14=' title" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABaAQMAAADHOIuVAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABlJREFUeNrtwTEBAAAAwqD1T+1vBqAAAHgDCSQAAT2geaMAAAAASUVORK5CYII=" /><\/div>',str15='<div class="overlay-lower"><img src="/Resources/images/play.png" width="200" height="90" class="play img-responsive" onclick="javascript:playGame(',str16=');"/><\/div><\/div><\/div>';cookieConsent=function(){window.cookieconsent&&window.cookieconsent.initialise({palette:{popup:{background:"#270909"},button:{background:"#FFF267",text:"#000000"}},theme:"classic",position:"bottom-left",content:{message:"On this website our advertising partners (Google and others) use cookies to personalize your ads. By using our site you agree to our privacy policy.",dismiss:"Accept",href:"http://www.onlinedominogames.com/policy"}})};document.readyState!=="complete"&&(document.readyState==="loading"||document.documentElement.doScroll)?document.addEventListener("DOMContentLoaded",cookieConsent):cookieConsent();window.fakeStorage={_data:{},setItem:function(n,t){return this._data[n]=String(t)},getItem:function(n){return this._data.hasOwnProperty(n)?this._data[n]:undefined},removeItem:function(n){return delete this._data[n]},clear:function(){return this._data={}}};LocalStorageManager.prototype={localStorageSupported:function(){var t="test",n;try{return n=window.localStorage,n.setItem(t,"1"),n.removeItem(t),!0}catch(i){return!1}},saveItem:function(n,t){this.storage.setItem(n,JSON.stringify(t))},getItem:function(n){var t=this.storage.getItem(n);return t?JSON.parse(t):null},removeItem:function(n){this.storage.removeItem(n)},getGameConfig:function(){var n=this.storage.getItem(this.gameConfigKey);return n?JSON.parse(n):{playSounds:!0}},setGameConfig:function(n){this.storage.setItem(this.gameConfigKey,JSON.stringify(n))},clearGameConfig:function(){this.storage.removeItem(this.gameConfigKey)},getGameData:function(){var n=this.storage.getItem(this.gameDataKey);return n?JSON.parse(n):{cardBacks:{}}},setGameData:function(n){this.storage.setItem(this.gameDataKey,JSON.stringify(n))},clearGameData:function(){this.storage.removeItem(this.gameDataKey)},getGame:function(n){var t=this.storage.getItem(this.gamesKey);return t?JSON.parse(t)[n]:null},setGame:function(n,t){var i=this.storage.getItem(this.gamesKey),r=i?JSON.parse(i):{};r[t]=n;this.storage.setItem(this.gamesKey,JSON.stringify(r))},clearGame:function(n){var t=this.storage.getItem(this.gamesKey),i=t?JSON.parse(t):{};i[n]=null;this.storage.setItem(this.gamesKey,JSON.stringify(i))},clearGames:function(){this.storage.removeItem(this.gamesKey)},getStats:function(n){var i=this.storage.getItem(this.gameStatsKey),t;return i&&(t=JSON.parse(i)[n],t)?t:{Played:0,Won:0,BestTime:0,BestScore:0,AverageTime:0,AverageScore:0}},setStats:function(n,t){var i=this.storage.getItem(this.gameStatsKey),r=i?JSON.parse(i):{};r[t]=n;this.storage.setItem(this.gameStatsKey,JSON.stringify(r))},clearStats:function(n){var t=this.storage.getItem(this.gameStatsKey),i=t?JSON.parse(t):{};i[n]=null;this.storage.setItem(this.gameStatsKey,JSON.stringify(i))},clearStats:function(){this.storage.removeItem(this.gameStatsKey)}};window.cookieStorage={setItem:function(n,t){this.writeCookie(n,t)},getItem:function(n){return this.readCookie(n)},removeItem:function(n){this.writeCookie(n,"",-1)},readCookie:function(n){for(var r=n+"=",u=document.cookie.split(";"),t,i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1,t.length);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return null},writeCookie:function(n,t,i){var r=function(){if(i){var n=new Date;return n.setTime(n.getTime()+i*864e5),"; expires="+n.toGMTString()}return""}();document.cookie=n+"="+t+r+"; path=/"}};LocalSessionManager.prototype={localSessionSupported:function(){try{return typeof window.sessionStorage!="undefined"}catch(n){return!1}},saveItem:function(n,t){this.storage.setItem(n,JSON.stringify(t))},getItem:function(n){var t=this.storage.getItem(n);return t?JSON.parse(t):null},removeItem:function(n){this.storage.removeItem(n)}};var sessionManager=new LocalSessionManager,storageManager=new LocalStorageManager,gameConfig=storageManager.getGameConfig();Queue.prototype.size=function(){return this._newestIndex-this._oldestIndex};Queue.prototype.enqueue=function(n){this._storage[this._newestIndex]=n;this._newestIndex++};Queue.prototype.dequeue=function(){var n=this._oldestIndex,i=this._newestIndex,t;if(n!==i)return t=this._storage[n],delete this._storage[n],this._oldestIndex++,t};Tree.prototype.setRoot=function(n){this._root.data=n};Tree.prototype.traverseDF=function(n){(function t(i){for(var r=0,u=i.children.length;r<u;r++)t(i.children[r]);n(i)})(this._root)};Tree.prototype.traverseBF=function(n){var t=new Queue,i,r;for(t.enqueue(this._root),currentTree=t.dequeue();currentTree;){for(i=0,r=currentTree.children.length;i<r;i++)t.enqueue(currentTree.children[i]);n(currentTree);currentTree=t.dequeue()}};Tree.prototype.contains=function(n,t){t.call(this,n)};Tree.prototype.add=function(n,t,i){var u=new Node(n),r=null,f=function(n){n.data===t&&(r=n)};if(this.contains(f,i),r)r.children.push(u),u.parent=r;else throw new Error("Cannot add node to a non-existent parent.");};Tree.prototype.remove=function(n,t,i){var o=this,r=null,f=null,u,e=function(n){n.data===t&&(r=n)};if(this.contains(e,i),r)if(u=findIndex(r.children,n),u===undefined)throw new Error("Node to remove does not exist.");else f=r.children.splice(u,1);else throw new Error("Parent does not exist.");return f};SinglyLinkedList.prototype.add=function(n){var t=new SLNode(n);this.head?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t);this.numberOfValues++};SinglyLinkedList.prototype.remove=function(n){for(var i=this.head,t=this.head;t;)t.data===n?(t===this.head&&(this.head=this.head.next),t===this.tail&&(this.tail=i),i.next=t.next,this.numberOfValues--):i=t,t=t.next};SinglyLinkedList.prototype.insertAfter=function(n,t){for(var i=this.head,r;i;)i.data===t&&(r=new SLNode(n),i===this.tail?(this.tail.next=r,this.tail=r):(r.next=i.next,i.next=r),this.numberOfValues++),i=i.next};SinglyLinkedList.prototype.traverse=function(n){for(var t=this.head;t;)n&&n(t),t=t.next};SinglyLinkedList.prototype.length=function(){return this.numberOfValues};SinglyLinkedList.prototype.print=function(){for(var t="",n=this.head;n;)t+=n.data+" ",n=n.next;console.log(t.trim())};SinglyLinkedList.prototype.addList=function(n){for(var t=0,i=n.length;t<i;t++)this.add(n[t])};SinglyLinkedList.prototype.addLinkedList=function(n){for(var t=n.head;t;)this.add(t.data),t=t.next};_0x58ea=["InOut","Exponential","Easing","width","id","name","-","rank1","rank2","frame","angle","moveByAngle","direction","counter","enabled","visible","getPipScore","prototype","isDual","isEqualTo","canPlay","indexOf","hasRank","getOtherRank","dominoes","game","dominoSpacerX","dominoSpacerY","maxDominoesSpace","left","top","noOfDecks","isDoubleClick","scale","properties","anchor","x","y","initDominoes","initExtDominoes","push","setPosition","resetLastDomino","length","addDomino","removeDomino","splice","getDomino","getDominoIndex","getTopDomino","getLastDomino","shuffle","enableAllDominoes","makeAllDominoesVisible","draw","pop","drawInSequence","drawDomino","drawRandomDomino","random","floor","drawDominoAt","drawCacheDomino","drawDominoFor","resetDomino","setAngle","reset","countDominoes","getPositionX","dominoesToDisplay","getPositionY","_frame","height","getSpriteScale","devicePixelRatio","max","audio","add","playSounds","","play","click","playAudio","frameName","audioon.png","audiooff.png","setGameConfig","dominoesMap","spriteCache","sprite","backFrame","domino","setTo","inputEnabled","atlas","temp.png","alpha","createTempSprite","self","isFullScreen","stopFullScreen","fullscreen.png","startFullScreen","exitfullscreen.png","initSpriteCache","calculateMargin","getDominoControlAt","applyScale","setControlPosition","calculateMarginY","calculateMarginX","removeAll","getDominoControl","Quadratic","tween","deck","isMoveComplete","to","group","bringToTop","display","addOnce","onStart","onComplete","Linear","addTweenForMove","bold 18px Arial","#fff","text","align","center","rgba(0, 0, 0, 0.5)","setShadow","canvas","createLinearGradient","context","#FFFFFF","addColorStop","#C0C0C0","fill","modalback.png","priorityID","input","message","centerX","world","confirm","settings","decline","set","min","scaleSprite","bold 36px Arial","middle","message3.png","GameoverImg",": ","\n","msg","image","homeButton","button","callbackButton","winnerLabel","resizeSolitaireGameoverModal","scaleText","next","start","Block","BlockOneSpinner","BlockAllSpinners","Draw","DrawOneSpinner","DrawAllSpinners","AllThrees","AllFives","AllPrimesNoSpinner","AllPrimesOneSpinner","Sniff","Canton","FivesAndThrees","MalteseCross","Muggins","FiveUp","MexicanTrain","Chickenfoot","Sebastopol","ArabDraw","SevenToedPete","Sevens","French","PassPass","Gaple","DiceDominoMatch","Bergen","FlowerScorpion","Hungarian","SevenUp","AllSevensNoSpinner","AllSevensOneSpinner","HorseRace","Abacus","PassAndOut","Austrian","BlindHughie","HonestJohn","Slosh","Partnership","SevenRocks","rank","No domino in the train","data","parent","children","getOpenRank","traverseBF","tree","Stack","Cuban","rotate","R","U","D","L","widthAvailable","heightAvailable","getOrientation","leftPadding","topPadding","marginLeft","marginTop","forEach","tileWidth","tileHeight","setDominoPositionsXY","startDomino","endDomino","calculateWidthFor","setDominoPositions","getOrientationCenterSpinner","RU","RD","LU","LD","setDominoPositionsCenterSpinner","centerY","setDominoPositionsSingleSpinner","dice","call","Sprite","anim","blurX","BlurX","filter","blurY","BlurY","frameIndex","rnd","pick","roll","animations","rollComplete","existing","create","constructor","updateFrameIndex","updateRotate","filters","update","isPlaying","isAnimationRunning","value","map","object","substring","search","location","&","split","=","console","log"];const SlideLeftIn={ease:Phaser[_0x58ea[2]][_0x58ea[1]][_0x58ea[0]],duration:900,intro:!0,props:{x:function(n){return n[_0x58ea[3]]}}},SlideLeftOut={ease:Phaser[_0x58ea[2]][_0x58ea[1]][_0x58ea[0]],duration:900,intro:!1,props:{x:function(n){return-n[_0x58ea[3]]}}};Domino[_0x58ea[17]][_0x58ea[16]]=function(){return this[_0x58ea[7]]+this[_0x58ea[8]]};Domino[_0x58ea[17]][_0x58ea[18]]=function(){return this[_0x58ea[7]]===this[_0x58ea[8]]};Domino[_0x58ea[17]][_0x58ea[19]]=function(n,t){return this[_0x58ea[7]]===n&&this[_0x58ea[8]]===t?!0:this[_0x58ea[7]]===t&&this[_0x58ea[8]]===n?!0:!1};Domino[_0x58ea[17]][_0x58ea[20]]=function(n){return n[_0x58ea[21]](this[_0x58ea[7]])>=0?this[_0x58ea[7]]:n[_0x58ea[21]](this[_0x58ea[8]])>=0?this[_0x58ea[8]]:-1};Domino[_0x58ea[17]][_0x58ea[22]]=function(n){return this[_0x58ea[7]]===n||this[_0x58ea[8]]===n};Domino[_0x58ea[17]][_0x58ea[23]]=function(n){return n===this[_0x58ea[7]]?this[_0x58ea[8]]:this[_0x58ea[7]]};Deck[_0x58ea[17]][_0x58ea[39]]=function(n){this[_0x58ea[24]]=n};Deck[_0x58ea[17]][_0x58ea[38]]=function(n){for(var r=0,e=this[_0x58ea[24]],t,i,u=0,f=this[_0x58ea[31]];u<f;u++)for(t=0;t<=n;t++)for(i=t;i<=n;i++)r++,e[_0x58ea[40]](new Domino(t,i,r,r))};Deck[_0x58ea[17]][_0x58ea[41]]=function(n,t){this[_0x58ea[29]]=n;this[_0x58ea[30]]=t};Deck[_0x58ea[17]][_0x58ea[42]]=function(n,t){var i=this[_0x58ea[24]][_0x58ea[43]]-1;i>=0&&(this[_0x58ea[24]][i][_0x58ea[15]]=n,this[_0x58ea[24]][i][_0x58ea[14]]=t)};Deck[_0x58ea[17]][_0x58ea[44]]=function(n){this[_0x58ea[24]][_0x58ea[40]](n)};Deck[_0x58ea[17]][_0x58ea[45]]=function(n){for(var t=0;t<this[_0x58ea[24]][_0x58ea[43]];t++)if(n[_0x58ea[13]]===this[_0x58ea[24]][t][_0x58ea[13]]){this[_0x58ea[24]][_0x58ea[46]](t,1);break}};Deck[_0x58ea[17]][_0x58ea[47]]=function(n,t){for(var r,i=0,u=this[_0x58ea[24]][_0x58ea[43]];i<u;i++)if(r=this[_0x58ea[24]][i],r[_0x58ea[7]]===n&&r[_0x58ea[8]]===t)return r;return null};Deck[_0x58ea[17]][_0x58ea[48]]=function(n,t){for(var r,i=0,u=this[_0x58ea[24]][_0x58ea[43]];i<u;i++)if(r=this[_0x58ea[24]][i],r[_0x58ea[7]]===n&&r[_0x58ea[8]]===t)return i;return-1};Deck[_0x58ea[17]][_0x58ea[49]]=function(){return this[_0x58ea[24]][_0x58ea[43]]>0?this[_0x58ea[24]][this[_0x58ea[24]][_0x58ea[43]]-1]:null};Deck[_0x58ea[17]][_0x58ea[50]]=function(){var n=this[_0x58ea[24]][_0x58ea[43]];return n>0?this[_0x58ea[24]][n-1]:null};Deck[_0x58ea[17]][_0x58ea[51]]=function(n){for(var t=0;t<n;t++)shuffle(this[_0x58ea[24]])};Deck[_0x58ea[17]][_0x58ea[52]]=function(n){for(var t=0,i=this[_0x58ea[24]][_0x58ea[43]];t<i;t++)this[_0x58ea[24]][t][_0x58ea[14]]=n};Deck[_0x58ea[17]][_0x58ea[53]]=function(n){for(var t=0,i=this[_0x58ea[24]][_0x58ea[43]];t<i;t++)this[_0x58ea[24]][t][_0x58ea[15]]=n};Deck[_0x58ea[17]][_0x58ea[54]]=function(n,t){for(var r,i=0;i<t;i++)r=this[_0x58ea[24]][_0x58ea[55]](),n[_0x58ea[44]](r)};Deck[_0x58ea[17]][_0x58ea[56]]=function(n,t){let i=[];for(let n=0;n<t;n++){let n=this[_0x58ea[24]][_0x58ea[55]]();i[_0x58ea[40]](n)}for(let r=t-1;r>=0;r--){let t=i[_0x58ea[55]]();n[_0x58ea[44]](t)}};Deck[_0x58ea[17]][_0x58ea[57]]=function(n,t){for(var r=this[_0x58ea[24]],f,i=0,u=r[_0x58ea[43]];i<u;i++)if(t[_0x58ea[13]]===r[i][_0x58ea[13]]){f=r[i];splice1(r,i);n[_0x58ea[44]](f);break}};Deck[_0x58ea[17]][_0x58ea[58]]=function(n){var t=this[_0x58ea[24]],r=t[_0x58ea[43]],i=Math[_0x58ea[60]](Math[_0x58ea[59]]()*r),u=t[i];splice1(t,i);n[_0x58ea[44]](u)};Deck[_0x58ea[17]][_0x58ea[61]]=function(n,t,i){for(var u,r=0;r<this[_0x58ea[24]][_0x58ea[43]];r++)t[_0x58ea[13]]===this[_0x58ea[24]][r][_0x58ea[13]]&&(u=this[_0x58ea[24]][_0x58ea[46]](r,1),n[_0x58ea[24]][_0x58ea[46]](i,0,u[0]))};Deck[_0x58ea[17]][_0x58ea[62]]=function(n,t){for(var r,i=0;i<this[_0x58ea[24]][_0x58ea[43]];i++)if(t[_0x58ea[13]]===this[_0x58ea[24]][i][_0x58ea[13]]){r=this[_0x58ea[24]][_0x58ea[46]](i,1);r[0][_0x58ea[14]]=t[_0x58ea[14]];r[0][_0x58ea[15]]=t[_0x58ea[15]];n[_0x58ea[44]](r[0]);break}};Deck[_0x58ea[17]][_0x58ea[63]]=function(n,t,i){for(var u=this[_0x58ea[24]],e,r=0,f=u[_0x58ea[43]];r<f;r++)if(t===u[r][_0x58ea[7]]&&i===u[r][_0x58ea[8]]){e=u[r];splice1(u,r);n[_0x58ea[44]](e);break}};Deck[_0x58ea[17]][_0x58ea[64]]=function(n,t,i){for(var u,r=0,f=this[_0x58ea[24]][_0x58ea[43]];r<f;r++)if(u=this[_0x58ea[24]][r],u[_0x58ea[13]]===n[_0x58ea[13]]){u[_0x58ea[15]]=t;u[_0x58ea[14]]=i;break}};Deck[_0x58ea[17]][_0x58ea[65]]=function(n){for(var i=this[_0x58ea[24]][_0x58ea[43]],t=0;t<i;t++)this[_0x58ea[24]][t][_0x58ea[10]]=n,this[_0x58ea[24]][t][_0x58ea[11]]=n};Deck[_0x58ea[17]][_0x58ea[66]]=function(){for(var t=this[_0x58ea[24]][_0x58ea[43]],n=0;n<t;n++)this[_0x58ea[24]][n][_0x58ea[10]]=0,this[_0x58ea[24]][n][_0x58ea[11]]=0,this[_0x58ea[24]][n][_0x58ea[15]]=!1,this[_0x58ea[24]][n][_0x58ea[14]]=!1,this[_0x58ea[24]][n][_0x58ea[12]]=null,delete this[_0x58ea[24]][n][_0x58ea[29]],delete this[_0x58ea[24]][n][_0x58ea[30]]};Deck[_0x58ea[17]][_0x58ea[67]]=function(n){for(var i=0,t=0,r=this[_0x58ea[24]][_0x58ea[43]];t<r;t++)(this[_0x58ea[24]][t][_0x58ea[7]]===n||this[_0x58ea[24]][t][_0x58ea[8]]===n)&&i++;return i};Deck[_0x58ea[17]][_0x58ea[68]]=function(n,t){var i=this[_0x58ea[26]],u=t&&this[_0x58ea[26]]>0?t:0,r=n;return this[_0x58ea[28]]>0&&this[_0x58ea[24]][_0x58ea[43]]>this[_0x58ea[28]]&&(i=this[_0x58ea[26]]*this[_0x58ea[28]]/this[_0x58ea[24]][_0x58ea[43]]),this[_0x58ea[69]]>0&&this[_0x58ea[24]][_0x58ea[43]]>this[_0x58ea[69]]&&(r=n>=this[_0x58ea[24]][_0x58ea[43]]-this[_0x58ea[69]]?n-(this[_0x58ea[24]][_0x58ea[43]]-this[_0x58ea[69]]):0,this[_0x58ea[28]]>0&&this[_0x58ea[28]]>this[_0x58ea[69]]&&(i=0)),this[_0x58ea[29]]+r*i-u+i/2};Deck[_0x58ea[17]][_0x58ea[70]]=function(n,t){var i=this[_0x58ea[27]],u=t&&this[_0x58ea[27]]>0?t:0,r=n;return this[_0x58ea[28]]>0&&this[_0x58ea[24]][_0x58ea[43]]>this[_0x58ea[28]]&&(i=this[_0x58ea[27]]*this[_0x58ea[28]]/this[_0x58ea[24]][_0x58ea[43]]),this[_0x58ea[69]]>0&&this[_0x58ea[24]][_0x58ea[43]]>this[_0x58ea[69]]&&(r=n>=this[_0x58ea[24]][_0x58ea[43]]-this[_0x58ea[69]]?n-(this[_0x58ea[24]][_0x58ea[43]]-this[_0x58ea[69]]):0,this[_0x58ea[28]]>0&&this[_0x58ea[28]]>this[_0x58ea[69]]&&(i=0)),this[_0x58ea[30]]+r*i-u+i/2};LocalScaleManager[_0x58ea[17]]={applyScale:function(n,t){n[_0x58ea[33]][_0x58ea[36]]=t;n[_0x58ea[33]][_0x58ea[37]]=t},scaleSprite:function(n,t,i,r,u,f){var e=this[_0x58ea[73]](n[_0x58ea[71]][_0x58ea[3]],n[_0x58ea[71]][_0x58ea[72]],t,i,r,f);return n[_0x58ea[33]][_0x58ea[36]]=e*u,n[_0x58ea[33]][_0x58ea[37]]=e*u,e},scaleSpriteTo:function(n,t){n[_0x58ea[33]][_0x58ea[36]]=t;n[_0x58ea[33]][_0x58ea[37]]=t},scaleText:function(n,t,i,r,u,f){var o=n[_0x58ea[3]]/n[_0x58ea[33]][_0x58ea[36]],s=n[_0x58ea[72]]/n[_0x58ea[33]][_0x58ea[37]],e=this[_0x58ea[73]](o,s,t,i,r,f);return n[_0x58ea[33]][_0x58ea[36]]=e*u,n[_0x58ea[33]][_0x58ea[37]]=e*u,e},getSpriteScale:function(n,t,i,r,u,f){var e=1,o=window[_0x58ea[74]],s=(n*o+2*u)/i,h=(t*o+2*u)/r;return s>1||h>1?e=1/Math[_0x58ea[75]](s,h):f&&(e=1/Math[_0x58ea[75]](s,h)),e*o}};scaleManager=new LocalScaleManager;LocalAudioManager[_0x58ea[17]]={initAudio:function(n){for(var t=0,i=n[_0x58ea[43]];t<i;t++)this[_0x58ea[76]][n[t]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[76]](n[t])},playAudio:function(n,t){if(gameConfig[_0x58ea[78]]){var i=this[_0x58ea[76]][n];i&&i[_0x58ea[80]](_0x58ea[79],0,1,t)}},toggleSound:function(n){this[_0x58ea[82]](_0x58ea[81],!1);n[_0x58ea[83]]===_0x58ea[84]?(n[_0x58ea[83]]=_0x58ea[85],gameConfig[_0x58ea[78]]=!1):(n[_0x58ea[83]]=_0x58ea[84],gameConfig[_0x58ea[78]]=!0);storageManager[_0x58ea[86]](gameConfig)}};GameManager[_0x58ea[17]]={initDominoControls:function(n,t){for(var u=n[_0x58ea[24]],f=u[_0x58ea[43]],i,r=0;r<f;r++)i=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[89]](n[_0x58ea[68]](r,0),n[_0x58ea[70]](r),_0x58ea[24]),i[_0x58ea[9]]=globalParams[_0x58ea[90]],i[_0x58ea[91]]=u[r],n[_0x58ea[35]]&&i[_0x58ea[35]][_0x58ea[92]](n[_0x58ea[35]][_0x58ea[36]],n[_0x58ea[35]][_0x58ea[37]]),i[_0x58ea[33]][_0x58ea[92]](n[_0x58ea[33]]),i[_0x58ea[93]]=!0,t[_0x58ea[77]](i),this[_0x58ea[87]][u[r][_0x58ea[13]]]=i},createTempSprite:function(n){var t=mygame[_0x58ea[77]][_0x58ea[89]](-2e3,-2e3,_0x58ea[94]);return t[_0x58ea[83]]=_0x58ea[95],t[_0x58ea[35]][_0x58ea[92]](.5,.5),t[_0x58ea[96]]=.6,t[_0x58ea[93]]=!0,n[_0x58ea[77]](t),t},initSpriteCache:function(n){for(var i,t=0;t<4;t++)i=this[_0x58ea[97]](n),this[_0x58ea[88]][_0x58ea[40]](i)},isLandscape:function(n,t){return n/t>1.2?!0:!1},fullScreen:function(n,t,i){window[_0x58ea[98]]===window[_0x58ea[30]]&&(this[_0x58ea[25]][_0x58ea[33]][_0x58ea[99]]?(this[_0x58ea[25]][_0x58ea[33]][_0x58ea[100]](),n[_0x58ea[83]]=_0x58ea[101],i&&(t[_0x58ea[15]]=!0)):(mygame[_0x58ea[33]][_0x58ea[102]](!1),n[_0x58ea[83]]=_0x58ea[103],i&&(t[_0x58ea[15]]=!1)))},getTempSprite:function(n){return this[_0x58ea[88]][_0x58ea[43]]===0&&this[_0x58ea[104]](n),this[_0x58ea[88]][_0x58ea[55]]()},resetDeckControls:function(n,t){for(var u=n[_0x58ea[24]][_0x58ea[43]],f=this[_0x58ea[105]](n,u),r=0;r<u;r++){var i=this[_0x58ea[106]](n,r),e=n[_0x58ea[68]](r,f),o=n[_0x58ea[70]](r);i[_0x58ea[36]]=e;i[_0x58ea[37]]=o;i[_0x58ea[10]]=n[_0x58ea[10]]+i[_0x58ea[91]][_0x58ea[10]]+i[_0x58ea[91]][_0x58ea[11]];i[_0x58ea[33]][_0x58ea[92]](n[_0x58ea[33]]);t&&t[_0x58ea[77]](i)}},positionDeckDominoes:function(n,t,i,r){for(var f,u=0,e=n[_0x58ea[24]][_0x58ea[43]];u<e;u++)f=this[_0x58ea[106]](n,u),t[_0x58ea[107]](f,i),this[_0x58ea[108]](f,n,u,r)},setControlPosition:function(n,t,i,r){var u=t[_0x58ea[68]](i,r),f=t[_0x58ea[70]](i,r);n[_0x58ea[36]]=u;n[_0x58ea[37]]=f},calculateMargin:function(n,t){return n[_0x58ea[10]]===90?this[_0x58ea[109]](n,t):this[_0x58ea[110]](n,t)},calculateMarginX:function(n,t){return t>n[_0x58ea[28]]?n[_0x58ea[26]]*n[_0x58ea[28]]/2:n[_0x58ea[26]]*t/2},calculateMarginY:function(n,t){return t>n[_0x58ea[28]]?n[_0x58ea[27]]*n[_0x58ea[28]]/2:n[_0x58ea[27]]*t/2},getDominoControlAt:function(n,t){return this[_0x58ea[87]][n[_0x58ea[24]][t][_0x58ea[13]]]},getDominoControl:function(n){return this[_0x58ea[87]][n[_0x58ea[13]]]},resetGroup:function(n,t){var i,r,u;for(t[_0x58ea[111]](),i=0,r=n[_0x58ea[24]][_0x58ea[43]];i<r;i++)u=this[_0x58ea[112]](n[_0x58ea[24]][i]),t[_0x58ea[77]](u)},resetDeckXY:function(n){var i,r,t;if(n[_0x58ea[24]][_0x58ea[43]]!==0)for(i=0,r=n[_0x58ea[24]][_0x58ea[43]];i<r;i++)t=this[_0x58ea[106]](n,i),t[_0x58ea[36]]=t[_0x58ea[91]][_0x58ea[29]],t[_0x58ea[37]]=t[_0x58ea[91]][_0x58ea[30]],t[_0x58ea[10]]=n[_0x58ea[10]]+t[_0x58ea[91]][_0x58ea[10]]+t[_0x58ea[91]][_0x58ea[11]],t[_0x58ea[9]]=t[_0x58ea[91]][_0x58ea[9]]},addTweenForMove:function(n,t,i,r,u,f,e){var c=t[_0x58ea[68]](i,f),l=t[_0x58ea[70]](i,f),s=300,h,o;return u&&(s=u),h=e?e:Phaser[_0x58ea[2]][_0x58ea[113]][_0x58ea[0]],o=mygame[_0x58ea[77]][_0x58ea[114]](n),o[_0x58ea[115]]=t,o[_0x58ea[116]]=!1,o[_0x58ea[117]]({x:c,y:l},s,h,!1,r),o[_0x58ea[122]][_0x58ea[121]](function(n,t){n[_0x58ea[119]](mygame[_0x58ea[118]]);n[_0x58ea[9]]=t[_0x58ea[115]][_0x58ea[120]]?n[_0x58ea[91]][_0x58ea[9]]:globalParams[_0x58ea[90]]},this),o[_0x58ea[123]][_0x58ea[121]](function(n,t){t[_0x58ea[115]][_0x58ea[10]]!==0&&(n[_0x58ea[10]]+=t[_0x58ea[115]][_0x58ea[10]]);n[_0x58ea[33]][_0x58ea[92]](t[_0x58ea[115]][_0x58ea[33]]);t[_0x58ea[116]]=!0},this),o},addTweenForMoveToPosition:function(n,t,i,r,u,f,e){var c=i[_0x58ea[36]],l=i[_0x58ea[37]],s=300,h,o;return u&&(s=u),h=e?e:Phaser[_0x58ea[2]][_0x58ea[113]][_0x58ea[0]],o=mygame[_0x58ea[77]][_0x58ea[114]](n),o[_0x58ea[115]]=t,o[_0x58ea[116]]=!1,o[_0x58ea[117]]({x:c,y:l},s,h,!1,r),o[_0x58ea[122]][_0x58ea[121]](function(n,t){n[_0x58ea[119]](mygame[_0x58ea[118]]);n[_0x58ea[9]]=t[_0x58ea[115]][_0x58ea[120]]?n[_0x58ea[91]][_0x58ea[9]]:globalParams[_0x58ea[90]]},this),o[_0x58ea[123]][_0x58ea[121]](function(n,t){t[_0x58ea[115]][_0x58ea[10]]!==0&&(n[_0x58ea[10]]+=t[_0x58ea[115]][_0x58ea[10]]);n[_0x58ea[33]][_0x58ea[92]](t[_0x58ea[115]][_0x58ea[33]]);t[_0x58ea[116]]=!0},this),o},addTweenForMoveXY:function(n,t,i,r){var f=300,u,e;return r&&(f=r),u=mygame[_0x58ea[77]][_0x58ea[114]](t),u[_0x58ea[115]]=n,u[_0x58ea[117]]({x:t[_0x58ea[91]][_0x58ea[29]],y:t[_0x58ea[91]][_0x58ea[30]]},f,Phaser[_0x58ea[2]][_0x58ea[124]].None,!1,i),u[_0x58ea[122]][_0x58ea[121]](function(){},this),e=t[_0x58ea[91]],u[_0x58ea[10]]=n[_0x58ea[10]]+t[_0x58ea[91]][_0x58ea[10]]+t[_0x58ea[91]][_0x58ea[11]],u[_0x58ea[123]][_0x58ea[121]](function(n,t){n[_0x58ea[9]]=n[_0x58ea[91]][_0x58ea[9]];n[_0x58ea[10]]=t[_0x58ea[10]];n[_0x58ea[33]][_0x58ea[92]](t[_0x58ea[115]][_0x58ea[33]])},this),u},addTweenForLastControlMove:function(n,t,i,r,u){var f=n[_0x58ea[24]][_0x58ea[43]]-1,e=this[_0x58ea[106]](n,f);return this[_0x58ea[125]](e,n,f,t,i,r,u)},addLabelText:function(n,t){var i=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[128]](-200,-200,n,t?t:{font:_0x58ea[126],fill:_0x58ea[127]}),r;return i[_0x58ea[35]][_0x58ea[92]](.5,0),i[_0x58ea[129]]=_0x58ea[130],i[_0x58ea[132]](4,4,_0x58ea[131],4),r=i[_0x58ea[135]][_0x58ea[134]](0,0,0,i[_0x58ea[133]][_0x58ea[72]]),r[_0x58ea[137]](0,_0x58ea[136]),r[_0x58ea[137]](1,_0x58ea[138]),i[_0x58ea[139]]=r,i[_0x58ea[15]]=!0,i},createConfirmationModal:function(n){var r=this[_0x58ea[25]][_0x58ea[3]],i=this[_0x58ea[25]][_0x58ea[72]],t=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[89]](0,0,_0x58ea[94],_0x58ea[140]);return t[_0x58ea[93]]=!0,t[_0x58ea[142]][_0x58ea[141]]=1,t[_0x58ea[72]]=i,t[_0x58ea[3]]=r,t[_0x58ea[143]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[89]](this[_0x58ea[25]][_0x58ea[145]][_0x58ea[144]],i*.3,_0x58ea[94],_0x58ea[140]),t[_0x58ea[143]][_0x58ea[35]][_0x58ea[92]](.5),t[_0x58ea[146]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[89]](r*.25,i*.6,_0x58ea[147]),t[_0x58ea[146]][_0x58ea[9]]=11,t[_0x58ea[146]][_0x58ea[35]][_0x58ea[92]](.5),t[_0x58ea[146]][_0x58ea[93]]=!0,t[_0x58ea[146]][_0x58ea[142]][_0x58ea[141]]=2,t[_0x58ea[148]]=mygame[_0x58ea[77]][_0x58ea[89]](r*.75,i*.6,_0x58ea[147]),t[_0x58ea[148]][_0x58ea[9]]=12,t[_0x58ea[148]][_0x58ea[35]][_0x58ea[92]](.5),t[_0x58ea[148]][_0x58ea[93]]=!0,t[_0x58ea[148]][_0x58ea[142]][_0x58ea[141]]=2,n[_0x58ea[77]](t),n[_0x58ea[77]](t[_0x58ea[143]]),n[_0x58ea[77]](t[_0x58ea[146]]),n[_0x58ea[77]](t[_0x58ea[148]]),t},resizeConfirmationModal:function(n){var i,t,r;n&&(i=this[_0x58ea[25]][_0x58ea[3]],t=this[_0x58ea[25]][_0x58ea[72]],n[_0x58ea[72]]=t,n[_0x58ea[3]]=i,r=scaleManager[_0x58ea[73]](750,120,i*.9,t*.3,0,!1),n[_0x58ea[143]][_0x58ea[33]][_0x58ea[149]](r),n[_0x58ea[143]][_0x58ea[36]]=this[_0x58ea[25]][_0x58ea[145]][_0x58ea[144]],n[_0x58ea[143]][_0x58ea[37]]=t*.3,scaleManager[_0x58ea[151]](n[_0x58ea[146]],i/4,t/4,Math[_0x58ea[150]](i/4,t/4)*.1,1,!0),n[_0x58ea[146]][_0x58ea[36]]=i*.25,n[_0x58ea[146]][_0x58ea[37]]=t*.6,scaleManager[_0x58ea[151]](n[_0x58ea[148]],i/4,t/4,Math[_0x58ea[150]](i/4,t/4)*.1,1,!0),n[_0x58ea[148]][_0x58ea[36]]=i*.75,n[_0x58ea[148]][_0x58ea[37]]=t*.6)},createSolitaireGameoverModal:function(n,t,i,r){var h=this[_0x58ea[25]][_0x58ea[3]],c=this[_0x58ea[25]][_0x58ea[72]],l={font:_0x58ea[152],fill:_0x58ea[127],boundsAlignH:_0x58ea[130],boundsAlignV:_0x58ea[153],align:_0x58ea[130]},u=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[89]](0,0,_0x58ea[94],_0x58ea[140]),o,s,e,f;if(u[_0x58ea[93]]=!0,u[_0x58ea[142]][_0x58ea[141]]=1,u[_0x58ea[72]]=c,u[_0x58ea[3]]=h,o=_0x58ea[154],s=_0x58ea[79],t[_0x58ea[43]]>0)for(e=0;e<t[_0x58ea[43]];e++)f=t[e],f[0]===_0x58ea[155]?o=f[1]:s+=f[0]+_0x58ea[156]+f[1]+_0x58ea[157];return u[_0x58ea[158]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[159]](-900,-900,_0x58ea[94],o),u[_0x58ea[158]][_0x58ea[35]][_0x58ea[92]](.5,.5),u[_0x58ea[160]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[161]](-900,-900,_0x58ea[147],function(){isEmbed?initGameState():goToHome()},this),u[_0x58ea[160]][_0x58ea[9]]=13,u[_0x58ea[160]][_0x58ea[35]][_0x58ea[92]](.5),u[_0x58ea[160]][_0x58ea[93]]=!0,u[_0x58ea[160]][_0x58ea[142]][_0x58ea[141]]=2,i&&(u[_0x58ea[162]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[161]](-900,-900,_0x58ea[147],i,r),u[_0x58ea[162]][_0x58ea[9]]=1,u[_0x58ea[162]][_0x58ea[35]][_0x58ea[92]](.5),u[_0x58ea[162]][_0x58ea[93]]=!0,u[_0x58ea[162]][_0x58ea[142]][_0x58ea[141]]=2),u[_0x58ea[163]]=this[_0x58ea[25]][_0x58ea[77]][_0x58ea[128]](-900,-900,s,l),u[_0x58ea[163]][_0x58ea[35]][_0x58ea[92]](.5,.5),n[_0x58ea[77]](u),n[_0x58ea[77]](u[_0x58ea[158]]),n[_0x58ea[77]](u[_0x58ea[163]]),n[_0x58ea[77]](u[_0x58ea[160]]),i&&n[_0x58ea[77]](u[_0x58ea[162]]),this[_0x58ea[25]][_0x58ea[145]][_0x58ea[119]](n),this[_0x58ea[164]](u,i?!0:!1),u},resizeSolitaireGameoverModal:function(n,t){var f;if(n){var r=this[_0x58ea[25]][_0x58ea[3]],i=this[_0x58ea[25]][_0x58ea[72]],u=r*.5;n[_0x58ea[72]]=i;n[_0x58ea[3]]=r;f=scaleManager[_0x58ea[151]](n[_0x58ea[158]],r*.8,i*.3,Math[_0x58ea[150]](r*.8,i*.3)*.1,1);n[_0x58ea[158]][_0x58ea[36]]=u;n[_0x58ea[158]][_0x58ea[37]]=i*.45;t?(scaleManager[_0x58ea[151]](n[_0x58ea[160]],r,i*.1,Math[_0x58ea[150]](r,i*.1)*.1,1),n[_0x58ea[160]][_0x58ea[36]]=u-n[_0x58ea[160]][_0x58ea[3]],n[_0x58ea[160]][_0x58ea[37]]=i*.85,scaleManager[_0x58ea[151]](n[_0x58ea[162]],r,i*.1,Math[_0x58ea[150]](r,i*.1)*.1,1),n[_0x58ea[162]][_0x58ea[36]]=u+n[_0x58ea[162]][_0x58ea[3]],n[_0x58ea[162]][_0x58ea[37]]=i*.85):(scaleManager[_0x58ea[151]](n[_0x58ea[160]],r,i*.1,Math[_0x58ea[150]](r,i*.1)*.1,1),n[_0x58ea[160]][_0x58ea[36]]=u,n[_0x58ea[160]][_0x58ea[37]]=i*.85);scaleManager[_0x58ea[165]](n[_0x58ea[163]],r*.9,i*.2,Math[_0x58ea[150]](r*.9,i*.1)*.05,1,!1);n[_0x58ea[163]][_0x58ea[36]]=u;n[_0x58ea[163]][_0x58ea[37]]=i*.7}},initPlayers:function(n,t){for(var r=[],i=0;i<n;i++)r[_0x58ea[40]](new Player(i+1,t[i]));for(i=0;i<n-1;i++)r[i][_0x58ea[166]]=r[i+1];return r[n-1][_0x58ea[166]]=r[0],r},runTweens:function(n){for(var t=0,i=n[_0x58ea[43]];t<i;t++)n[t][_0x58ea[167]]()},getInitialDominoesCount:function(n,t){switch(n){case GameType[_0x58ea[168]]:case GameType[_0x58ea[169]]:case GameType[_0x58ea[170]]:return t===2?7:t===3?5:5;case GameType[_0x58ea[171]]:case GameType[_0x58ea[172]]:case GameType[_0x58ea[173]]:return t===2?7:t===3?7:6;case GameType[_0x58ea[174]]:case GameType[_0x58ea[175]]:case GameType[_0x58ea[176]]:case GameType[_0x58ea[177]]:return t===2?9:t===3?7:5;case GameType[_0x58ea[178]]:case GameType[_0x58ea[179]]:return t===2?7:t===3?6:5;case GameType[_0x58ea[180]]:case GameType[_0x58ea[181]]:case GameType[_0x58ea[182]]:return t===2?7:t===3?5:5;case GameType[_0x58ea[183]]:case GameType[_0x58ea[184]]:case GameType[_0x58ea[185]]:return 5;case GameType[_0x58ea[186]]:case GameType[_0x58ea[187]]:case GameType[_0x58ea[188]]:case GameType[_0x58ea[189]]:case GameType[_0x58ea[190]]:return 7;case GameType[_0x58ea[191]]:case GameType[_0x58ea[192]]:return 6;case GameType[_0x58ea[193]]:return 10;case GameType[_0x58ea[194]]:case GameType[_0x58ea[195]]:return t===2?6:t===3?6:5;case GameType[_0x58ea[196]]:return t===2?12:t===3?8:6;case GameType[_0x58ea[197]]:case GameType[_0x58ea[198]]:case GameType[_0x58ea[199]]:case GameType[_0x58ea[200]]:return t===2?7:t===3?6:5;case GameType[_0x58ea[201]]:case GameType[_0x58ea[202]]:return 7;case GameType[_0x58ea[203]]:return t===2?9:t===3?7:7;case GameType[_0x58ea[204]]:return t===2?7:t===3?5:5;case GameType[_0x58ea[205]]:return 11}},roundScore:function(n,t){switch(n){case GameType[_0x58ea[168]]:case GameType[_0x58ea[169]]:case GameType[_0x58ea[170]]:case GameType[_0x58ea[171]]:case GameType[_0x58ea[172]]:case GameType[_0x58ea[173]]:case GameType[_0x58ea[186]]:case GameType[_0x58ea[181]]:case GameType[_0x58ea[190]]:case GameType[_0x58ea[187]]:case GameType[_0x58ea[206]]:case GameType[_0x58ea[207]]:case GameType[_0x58ea[202]]:return t;case GameType[_0x58ea[194]]:return 1;case GameType[_0x58ea[182]]:case GameType[_0x58ea[175]]:case GameType[_0x58ea[183]]:return t%5>=3?Math[_0x58ea[60]](t/5)+1:Math[_0x58ea[60]](t/5);case GameType[_0x58ea[178]]:return t%5>=3?-(Math[_0x58ea[60]](t/5)+1)*5:-Math[_0x58ea[60]](t/5)*5;case GameType[_0x58ea[174]]:return t%3>=2?Math[_0x58ea[60]](t/3)+1:Math[_0x58ea[60]](t/3);case GameType[_0x58ea[180]]:return 1;case GameType[_0x58ea[208]]:return t%5>=3?(Math[_0x58ea[60]](t/5)+1)*5:Math[_0x58ea[60]](t/5)*5;case GameType[_0x58ea[188]]:case GameType[_0x58ea[200]]:return t%5>=3?Math[_0x58ea[60]](t/5)+1:Math[_0x58ea[60]](t/5);default:return t}},turnScore:function(n,t){switch(n){case GameType[_0x58ea[168]]:case GameType[_0x58ea[169]]:case GameType[_0x58ea[170]]:case GameType[_0x58ea[171]]:case GameType[_0x58ea[172]]:case GameType[_0x58ea[173]]:case GameType[_0x58ea[186]]:case GameType[_0x58ea[181]]:case GameType[_0x58ea[190]]:case GameType[_0x58ea[187]]:case GameType[_0x58ea[207]]:case GameType[_0x58ea[197]]:case GameType[_0x58ea[198]]:case GameType[_0x58ea[199]]:case GameType[_0x58ea[202]]:case GameType[_0x58ea[203]]:return 0;case GameType[_0x58ea[182]]:case GameType[_0x58ea[175]]:case GameType[_0x58ea[178]]:case GameType[_0x58ea[208]]:return t%5==0?t:0;case GameType[_0x58ea[183]]:case GameType[_0x58ea[188]]:case GameType[_0x58ea[200]]:return t%5==0?t/5:0;case GameType[_0x58ea[174]]:return t%3==0?t:0;case GameType[_0x58ea[180]]:return t===15?8:t%5==0?t/5:t%3==0?t/3:0;case GameType[_0x58ea[191]]:return t===10||t===5||t===7?t:0;case GameType[_0x58ea[176]]:case GameType[_0x58ea[177]]:return isPrime(t)?t:0}},isBlockGame:function(n){switch(n){case GameType[_0x58ea[168]]:case GameType[_0x58ea[169]]:case GameType[_0x58ea[170]]:case GameType[_0x58ea[186]]:case GameType[_0x58ea[181]]:case GameType[_0x58ea[180]]:case GameType[_0x58ea[207]]:case GameType[_0x58ea[196]]:case GameType[_0x58ea[202]]:return!0;default:return!1}},getHighestDomino:function(n){for(var r=-1,u,i,t=0,f=n[_0x58ea[43]];t<f;t++)i=n[t][_0x58ea[16]](),i>r&&(r=i,u=n[t]);return u},getHighestDominoForPipEnd:function(n,t){for(var r=-1,u,i=0,f=n[_0x58ea[43]];i<f;i++)n[i][_0x58ea[20]]([t])>=0&&n[i][_0x58ea[7]]+n[i][_0x58ea[8]]>r&&(r=n[i][_0x58ea[7]]+n[i][_0x58ea[8]],u=n[i]);return u},getHighestDouble:function(n){for(var r=-1,u,i,t=0,f=n[_0x58ea[43]];t<f;t++)i=n[t][_0x58ea[16]](),n[t][_0x58ea[18]]()&&i>r&&(r=i,u=n[t]);return u},getLowestDouble:function(n){for(var r=1e4,u,i,t=0,f=n[_0x58ea[43]];t<f;t++)i=n[t][_0x58ea[16]](),n[t][_0x58ea[18]]()&&i<r&&(r=i,u=n[t]);return u},getLowestDomino:function(n){for(var r=1e4,u,i,t=0,f=n[_0x58ea[43]];t<f;t++)i=n[t][_0x58ea[16]](),i<r&&(r=i,u=n[t]);return u},getHighestDominoForTotal:function(n,t){for(var u=0,f,r,i=0,e=n[_0x58ea[43]];i<e;i++)r=n[i][_0x58ea[16]](),r%t==0&&r>u&&(u=r,f=n[i]);return f},getDominoesForTotal:function(n,t){for(var r=[],f,i=0,u=n[_0x58ea[43]];i<u;i++)f=n[i][_0x58ea[16]](),f===t&&r[_0x58ea[40]](n[i]);return r},getDominoForDouble:function(n,t){for(var r,i=0,u=n[_0x58ea[43]];i<u;i++)if(r=n[i],r[_0x58ea[18]]()&&r[_0x58ea[7]]===t)return r;return null},getHighestPrimeDomino:function(n){for(var t=null,r,u,i=0,f=n[_0x58ea[43]];i<f;i++)r=n[i],u=r[_0x58ea[16]](),isPrime(u)&&(!t||u>t[_0x58ea[16]]())&&(t=r);return t},ifAnyMatchingDomino:function(n,t,i){for(var f,r=0,u=n[_0x58ea[43]];r<u;r++)if((f=n[r],f!==t)&&n[r][_0x58ea[20]](i)>=0)return!0;return!1},getPlayableDominoes:function(n,t){for(var u=[],r,i=0,f=n[_0x58ea[24]][_0x58ea[43]];i<f;i++)r=n[_0x58ea[24]][i],r[_0x58ea[20]](t)>=0&&u[_0x58ea[40]](r);return u},hasPlayableDominoes:function(n,t){for(var u,i=0,r=n[_0x58ea[24]][_0x58ea[43]];i<r;i++)if(u=n[_0x58ea[24]][i],u[_0x58ea[20]](t)>=0)return!0;return!1},hasPlayableDominoFor:function(n,t){for(var u,i=0,r=n[_0x58ea[24]][_0x58ea[43]];i<r;i++)if(u=n[_0x58ea[24]][i],u[_0x58ea[20]]([t])>=0)return!0;return!1},drawTestDominoes:function(n,t,i){for(var u,r=0,f=i[_0x58ea[43]];r<f;r++)u=i[r],n[_0x58ea[63]](t,u[0],u[1])},countPips:function(n){for(var i=0,t=0,r=n[_0x58ea[24]][_0x58ea[43]];t<r;t++)i+=n[_0x58ea[24]][t][_0x58ea[7]]+n[_0x58ea[24]][t][_0x58ea[8]];return i},getOpenRank:function(n,t){if(n[_0x58ea[18]]())return n[_0x58ea[7]];var i=t[_0x58ea[20]]([n[_0x58ea[7]]]);return i<0?n[_0x58ea[7]]:n[_0x58ea[8]]},getOpenRanks:function(n){for(var i=[],t=0,r=n[_0x58ea[43]];t<r;t++)i[_0x58ea[40]](n[t][_0x58ea[209]]);return i},calculateScore:function(n,t,i){switch(t){case 0:throw _0x58ea[210];case 1:return n[_0x58ea[24]][0][_0x58ea[16]]();default:var f=this,r=0,u=null;return n[_0x58ea[216]][_0x58ea[215]](function(t){var e=t[_0x58ea[211]],s,c,h,o;if(e)if(e[_0x58ea[18]]())switch(i){case GameType[_0x58ea[178]]:if(!u)for(s=0,c=n[_0x58ea[24]][_0x58ea[43]];s<c;s++)if(h=n[_0x58ea[24]][s],h[_0x58ea[18]]()){u=h;break}e===u?(t[_0x58ea[212]]||(t[_0x58ea[213]][_0x58ea[43]]<=2&&(r+=e[_0x58ea[16]]()),t[_0x58ea[213]][_0x58ea[43]]===3&&(r+=e[_0x58ea[16]]()/2)),t[_0x58ea[212]]&&(t[_0x58ea[213]][_0x58ea[43]]<=1&&(r+=e[_0x58ea[16]]()),t[_0x58ea[213]][_0x58ea[43]]===2&&(r+=e[_0x58ea[16]]()/2))):t[_0x58ea[213]][_0x58ea[43]]===0&&(r+=e[_0x58ea[16]]());break;default:!t[_0x58ea[212]]&&t[_0x58ea[213]][_0x58ea[43]]<=1&&(r+=e[_0x58ea[16]]());t[_0x58ea[212]]&&t[_0x58ea[213]][_0x58ea[43]]===0&&(r+=e[_0x58ea[16]]())}else t[_0x58ea[212]]?t[_0x58ea[213]][_0x58ea[43]]===0&&(o=f[_0x58ea[214]](e,t[_0x58ea[212]][_0x58ea[211]]),r+=o):t[_0x58ea[213]][_0x58ea[43]]===0?r+=e[_0x58ea[16]]():t[_0x58ea[213]][_0x58ea[43]]===1&&(o=f[_0x58ea[214]](e,t[_0x58ea[213]][0][_0x58ea[211]]),r+=o)}),r}},calculateOpenRanks:function(n,t){var r;switch(n[_0x58ea[24]][_0x58ea[43]]){case 0:throw _0x58ea[210];case 1:return r=n[_0x58ea[24]][0],r[_0x58ea[18]]()?[{domino:r,rank:r[_0x58ea[7]]}]:[{domino:r,rank:r[_0x58ea[7]]},{domino:r,rank:r[_0x58ea[8]]}];default:var i=[],f=this,u=!1,e=null;return n[_0x58ea[216]][_0x58ea[215]](function(r){var o=r[_0x58ea[211]],c,a,h,l,y,v,s;if(o){if(!u)switch(t){case GameType[_0x58ea[186]]:case GameType[_0x58ea[190]]:r[_0x58ea[212]]||(r[_0x58ea[213]][_0x58ea[43]]===4?u=!0:i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]}));break;case GameType[_0x58ea[181]]:if(!r[_0x58ea[212]])if(r[_0x58ea[213]][_0x58ea[43]]===4){for(c=r[_0x58ea[213]],a=0,h=0;h<c[_0x58ea[43]];h++)c[h][_0x58ea[213]][_0x58ea[43]]===0?(s=f[_0x58ea[214]](c[h][_0x58ea[211]],c[h][_0x58ea[212]][_0x58ea[211]]),i[_0x58ea[40]]({domino:c[h][_0x58ea[211]],rank:s})):a++;a===4&&(u=!0)}else i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]});break;default:u=!0}if(u)if(o[_0x58ea[18]]())switch(t){case GameType[_0x58ea[174]]:case GameType[_0x58ea[175]]:case GameType[_0x58ea[178]]:case GameType[_0x58ea[186]]:case GameType[_0x58ea[181]]:case GameType[_0x58ea[190]]:case GameType[_0x58ea[172]]:case GameType[_0x58ea[169]]:case GameType[_0x58ea[208]]:case GameType[_0x58ea[188]]:case GameType[_0x58ea[177]]:if(!e)for(l=0,y=n[_0x58ea[24]][_0x58ea[43]];l<y;l++)if(v=n[_0x58ea[24]][l],v[_0x58ea[18]]()){e=v;break}o===e?(!r[_0x58ea[212]]&&r[_0x58ea[213]][_0x58ea[43]]<4||r[_0x58ea[213]][_0x58ea[43]]<3)&&i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]}):r[_0x58ea[213]][_0x58ea[43]]===0&&i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]});break;case GameType[_0x58ea[183]]:case GameType[_0x58ea[173]]:case GameType[_0x58ea[170]]:case GameType[_0x58ea[200]]:(!r[_0x58ea[212]]&&r[_0x58ea[213]][_0x58ea[43]]<4||r[_0x58ea[213]][_0x58ea[43]]<3)&&i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]});break;case GameType[_0x58ea[171]]:case GameType[_0x58ea[168]]:case GameType[_0x58ea[182]]:case GameType[_0x58ea[180]]:case GameType[_0x58ea[194]]:case GameType[_0x58ea[187]]:case GameType[_0x58ea[207]]:case GameType[_0x58ea[217]]:case GameType[_0x58ea[192]]:case GameType[_0x58ea[196]]:case GameType[_0x58ea[195]]:case GameType[_0x58ea[191]]:case GameType[_0x58ea[202]]:case GameType[_0x58ea[218]]:case GameType[_0x58ea[203]]:case GameType[_0x58ea[204]]:case GameType[_0x58ea[201]]:case GameType[_0x58ea[176]]:(!r[_0x58ea[212]]&&r[_0x58ea[213]][_0x58ea[43]]<2||r[_0x58ea[213]][_0x58ea[43]]===0)&&i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]})}else r[_0x58ea[212]]?r[_0x58ea[213]][_0x58ea[43]]===0&&(s=f[_0x58ea[214]](o,r[_0x58ea[212]][_0x58ea[211]]),i[_0x58ea[40]]({domino:o,rank:s})):r[_0x58ea[213]][_0x58ea[43]]===0?(i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[7]]}),i[_0x58ea[40]]({domino:o,rank:o[_0x58ea[8]]})):r[_0x58ea[213]][_0x58ea[43]]===1&&(s=f[_0x58ea[214]](o,r[_0x58ea[213]][0][_0x58ea[211]]),i[_0x58ea[40]]({domino:o,rank:s}))}}),i}},getOrientation:function(n,t,i,r,u){var e=n[_0x58ea[211]],f=t[_0x58ea[211]],h=n[_0x58ea[219]],s,o;if(f[_0x58ea[18]]())if(i){if(s=i[_0x58ea[211]],o=t[_0x58ea[213]][_0x58ea[21]](n),s[_0x58ea[10]]===90&&s[_0x58ea[7]]===f[_0x58ea[7]]||s[_0x58ea[10]]===-90&&s[_0x58ea[8]]===f[_0x58ea[7]]){if(o===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(o===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(o===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}}if(s[_0x58ea[10]]===90&&s[_0x58ea[8]]===f[_0x58ea[7]]||s[_0x58ea[10]]===-90&&s[_0x58ea[7]]===f[_0x58ea[7]]){if(o===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}if(o===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(o===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}}if(s[_0x58ea[10]]===0&&s[_0x58ea[8]]===f[_0x58ea[7]]||s[_0x58ea[10]]===180&&s[_0x58ea[7]]===f[_0x58ea[7]]){if(o===0)if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}else if(t[_0x58ea[219]]){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}if(o===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(o===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}}if(s[_0x58ea[10]]===0&&s[_0x58ea[7]]===f[_0x58ea[7]]||s[_0x58ea[10]]===180&&s[_0x58ea[8]]===f[_0x58ea[7]]){if(o===0)if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}else if(t[_0x58ea[219]]){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(o===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(o===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}}}else{if(o=t[_0x58ea[213]][_0x58ea[21]](n),o===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(o===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}if(o===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(o===3){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}}else if(e[_0x58ea[18]]())switch(f[_0x58ea[10]]){case 90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case-90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};break;case 0:if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[221],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[222],leftPadding:u/2,topPadding:r/2}}break;case 180:if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[222],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[221],leftPadding:u/2,topPadding:r/2}}}else switch(f[_0x58ea[10]]){case 90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case-90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};break;case 0:if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}break;case 180:if(h){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}else{if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}}},setDominoPositionsXY:function(n,t,i,r,u,f){var o,w,s,h,c,l,a,v,e;if(n[_0x58ea[24]][_0x58ea[43]]!==0){var y=i[_0x58ea[224]],p=i[_0x58ea[225]],a=0,v=0;if(n[_0x58ea[24]][_0x58ea[43]]===1?(o=n[_0x58ea[24]][0],n[_0x58ea[24]][0][_0x58ea[10]]=n[_0x58ea[24]][0][_0x58ea[18]]()?0:90,n[_0x58ea[24]][0][_0x58ea[11]]=0,n[_0x58ea[24]][0][_0x58ea[29]]=n[_0x58ea[29]],n[_0x58ea[24]][0][_0x58ea[30]]=n[_0x58ea[30]],o[_0x58ea[18]]()?(s=o[_0x58ea[29]]-r/2,h=o[_0x58ea[29]]+r/2,c=o[_0x58ea[30]]-u/2,l=o[_0x58ea[30]]+u/2):(s=o[_0x58ea[29]]-u/2,h=o[_0x58ea[29]]+u/2,c=o[_0x58ea[30]]-r/2,l=o[_0x58ea[30]]+r/2)):(w=this,n[_0x58ea[216]][_0x58ea[215]](function(t){var i=t[_0x58ea[211]],f,e;if(i)if(t[_0x58ea[212]]){if(f=t[_0x58ea[212]][_0x58ea[211]],e=w[_0x58ea[226]](t,t[_0x58ea[212]],t[_0x58ea[212]][_0x58ea[212]],r,u),i[_0x58ea[10]]=e[_0x58ea[10]],i[_0x58ea[11]]=0,i[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[220]:i[_0x58ea[29]]=f[_0x58ea[29]]+r/2+u/2;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[223]:i[_0x58ea[29]]=f[_0x58ea[29]]-r/2-u/2;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]+u/2+r/2}else if(f[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[220]:i[_0x58ea[29]]=f[_0x58ea[10]]===0?f[_0x58ea[29]]+r/2+u/2:f[_0x58ea[29]]+u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[223]:i[_0x58ea[29]]=f[_0x58ea[10]]===0?f[_0x58ea[29]]-r/2-u/2:f[_0x58ea[29]]-u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[10]]===0?f[_0x58ea[30]]-u:f[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[10]]===0?f[_0x58ea[30]]+u:f[_0x58ea[30]]+u/2+r/2}else switch(e[_0x58ea[12]]){case _0x58ea[220]:i[_0x58ea[29]]=f[_0x58ea[29]]+u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[223]:i[_0x58ea[29]]=f[_0x58ea[29]]-u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]-u;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]+u}i[_0x58ea[29]]<s&&(s=i[_0x58ea[29]]-e[_0x58ea[227]]);i[_0x58ea[29]]>h&&(h=i[_0x58ea[29]]+e[_0x58ea[227]]);i[_0x58ea[30]]<c&&(c=i[_0x58ea[30]]-e[_0x58ea[228]]);i[_0x58ea[30]]>l&&(l=i[_0x58ea[30]]+e[_0x58ea[228]])}else i[_0x58ea[10]]=i[_0x58ea[18]]()?0:90,i[_0x58ea[11]]=0,i[_0x58ea[29]]=n[_0x58ea[29]],i[_0x58ea[30]]=n[_0x58ea[30]],i[_0x58ea[18]]()?(s=i[_0x58ea[29]]-r/2,h=i[_0x58ea[29]]+r/2,c=i[_0x58ea[30]]-u/2,l=i[_0x58ea[30]]+u/2):(s=i[_0x58ea[29]]-u/2,h=i[_0x58ea[29]]+u/2,c=i[_0x58ea[30]]-r/2,l=i[_0x58ea[30]]+r/2)}),a=h-s,v=l-c),y>=a&&p>=v)n[_0x58ea[216]][_0x58ea[215]](function(n){var t=n[_0x58ea[211]];t[_0x58ea[29]]=t[_0x58ea[29]]+y/2-(s+h)/2+i[_0x58ea[229]];t[_0x58ea[30]]=t[_0x58ea[30]]+p/2-(c+l)/2+i[_0x58ea[230]]});else{if(y<a&&p<v)var b=y/a,k=p/v,e=f*Math[_0x58ea[150]](b,k);else y<a?e=f*y/a:p<v&&(e=f*p/v);e=e*.98;n[_0x58ea[33]]=e;t[_0x58ea[231]](function(n){n[_0x58ea[33]][_0x58ea[92]](e)});this[_0x58ea[234]](n,t,i,globalParams[_0x58ea[232]]*e,globalParams[_0x58ea[233]]*e,e)}}},calculateWidthFor:function(n,t,i,r,u){for(var o=i-t+1,e=0,f=t;f<=i;f++)n[f][_0x58ea[18]]()||e++;return e*u+(o-e)*r},setDominoPositions:function(n,t,i,r,u){var l,o,nt,g,tt,s,h,b,k,f,y;if(n[_0x58ea[24]][_0x58ea[43]]!==0){if(l=r,n[_0x58ea[24]][_0x58ea[43]]===1)o=n[_0x58ea[24]][0],o[_0x58ea[10]]=o[_0x58ea[18]]()?0:90,o[_0x58ea[11]]=0,o[_0x58ea[29]]=n[_0x58ea[29]],o[_0x58ea[30]]=n[_0x58ea[30]],l={startDomino:o,endDomino:o};else{nt=this;n[_0x58ea[216]][_0x58ea[215]](function(n){var r=n[_0x58ea[211]],u;r&&(n[_0x58ea[212]]?(u=nt[_0x58ea[226]](n,n[_0x58ea[212]],n[_0x58ea[212]][_0x58ea[212]],t,i),r[_0x58ea[10]]=u[_0x58ea[10]],r[_0x58ea[11]]=0):(r[_0x58ea[10]]=r[_0x58ea[18]]()?0:90,r[_0x58ea[11]]=0))});var v=u?this[_0x58ea[25]][_0x58ea[3]]*u:this[_0x58ea[25]][_0x58ea[3]]*.9,d=0,w=n[_0x58ea[24]][_0x58ea[43]];for(f=0;f<w;f++)n[_0x58ea[24]][f][_0x58ea[11]]=0,n[_0x58ea[24]][f][_0x58ea[18]]()||d++;if(g=d*i+(w-d)*t,tt=n[_0x58ea[24]][0][_0x58ea[18]]()?t/2:i/2,g<=v){for(s=n[_0x58ea[29]]-g/2+tt,h=n[_0x58ea[30]],f=0,y=w;f<y;f++)f===0?(n[_0x58ea[24]][f][_0x58ea[29]]=s,n[_0x58ea[24]][f][_0x58ea[30]]=h):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=s+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=h):(n[_0x58ea[24]][f][_0x58ea[29]]=s+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=h),n[_0x58ea[24]][f][_0x58ea[18]]()?(s+=f===0?t/2:t,h+=0):(s+=f===0?i/2:i,h+=0);l={startDomino:n[_0x58ea[24]][0],endDomino:n[_0x58ea[24]][n[_0x58ea[24]][_0x58ea[43]]-1]}}else{for(b=0,k=0,f=0;f<w;f++)n[_0x58ea[24]][f][_0x58ea[13]]===l[_0x58ea[235]][_0x58ea[13]]&&(b=f),n[_0x58ea[24]][f][_0x58ea[13]]===l[_0x58ea[236]][_0x58ea[13]]&&(k=f);var e=0,c=v,p=0,a=!1;if(b-1>=0)for(f=b-1;f>=0;f--)p=n[_0x58ea[24]][f][_0x58ea[18]]()?t:i,n[_0x58ea[24]][f][_0x58ea[11]]=0,c+p<v?(a?(e%2==1?n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2-t/2,n[_0x58ea[24]][f][_0x58ea[11]]=180):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+t,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2-t/2,n[_0x58ea[24]][f][_0x58ea[11]]=180):e%2==0&&(n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2-t/2):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-t,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i/2-t/2)),a=!1):e%2==1?n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]],n[_0x58ea[24]][f][_0x58ea[11]]=180):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+i,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]],n[_0x58ea[24]][f][_0x58ea[11]]=180):e%2==0&&(n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-i,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]])),c+=n[_0x58ea[24]][f][_0x58ea[18]]()?t:i):(c=0,e++,a=!0,e%2==1?n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]],n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i,n[_0x58ea[24]][f][_0x58ea[11]]=90):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]-i/4,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[7]]!==n[_0x58ea[24]][f][_0x58ea[8]]&&(n[_0x58ea[24]][f][_0x58ea[11]]=90)):e%2==0&&(n[_0x58ea[24]][f+1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]],n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-i,n[_0x58ea[24]][f][_0x58ea[11]]=90):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f+1][_0x58ea[29]]+i/4,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f+1][_0x58ea[30]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[7]]!==n[_0x58ea[24]][f][_0x58ea[8]]&&(n[_0x58ea[24]][f][_0x58ea[11]]=90))));if(e=0,c=v,p=0,k+1<=n[_0x58ea[24]][_0x58ea[43]]-1)for(f=k+1,y=n[_0x58ea[24]][_0x58ea[43]];f<y;f++)p=n[_0x58ea[24]][f][_0x58ea[18]]()?t:i,n[_0x58ea[24]][f][_0x58ea[11]]=0,c+p<v?(a?(f===0?(n[_0x58ea[24]][f][_0x58ea[29]]=s,n[_0x58ea[24]][f][_0x58ea[30]]=h):e%2==0?n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2+t/2):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+t,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2+t/2):e%2==1&&(n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2+t/2,n[_0x58ea[24]][f][_0x58ea[11]]=180):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-t,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-t/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i/2+t/2,n[_0x58ea[24]][f][_0x58ea[11]]=180)),a=!1):f===0?(n[_0x58ea[24]][f][_0x58ea[29]]=s,n[_0x58ea[24]][f][_0x58ea[30]]=h):e%2==0?n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+i,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]):e%2==1&&(n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]],n[_0x58ea[24]][f][_0x58ea[11]]=180):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-t/2-i/2,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-i,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]],n[_0x58ea[24]][f][_0x58ea[11]]=180)),c+=n[_0x58ea[24]][f][_0x58ea[18]]()?t:i):(c=0,e++,a=!0,e%2==1?n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]],n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i,n[_0x58ea[24]][f][_0x58ea[11]]=90):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]+i/4,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[7]]!==n[_0x58ea[24]][f][_0x58ea[8]]&&(n[_0x58ea[24]][f][_0x58ea[11]]=90)):e%2==0&&(n[_0x58ea[24]][f-1][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]],n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+i,n[_0x58ea[24]][f][_0x58ea[11]]=90):(n[_0x58ea[24]][f][_0x58ea[29]]=n[_0x58ea[24]][f-1][_0x58ea[29]]-i/4,n[_0x58ea[24]][f][_0x58ea[30]]=n[_0x58ea[24]][f-1][_0x58ea[30]]+t/2+i/2,n[_0x58ea[24]][f][_0x58ea[7]]!==n[_0x58ea[24]][f][_0x58ea[8]]&&(n[_0x58ea[24]][f][_0x58ea[11]]=90))))}}return l}},resetDominoPositions:function(n,t,i,r,u){var l,c,g,w,o,s,nt,f,y;if(n[_0x58ea[24]][_0x58ea[43]]!==0){if(l=null,n[_0x58ea[24]][_0x58ea[43]]===1)c=n[_0x58ea[24]][0],c[_0x58ea[10]]=c[_0x58ea[18]]()?0:90,c[_0x58ea[11]]=0,c[_0x58ea[29]]=n[_0x58ea[29]],c[_0x58ea[30]]=n[_0x58ea[30]],l={startDomino:c,endDomino:c};else{g=this;n[_0x58ea[216]][_0x58ea[215]](function(n){var r=n[_0x58ea[211]],u;r&&(n[_0x58ea[212]]?(u=g[_0x58ea[226]](n,n[_0x58ea[212]],n[_0x58ea[212]][_0x58ea[212]],t,i),r[_0x58ea[10]]=u[_0x58ea[10]],r[_0x58ea[11]]=0):(r[_0x58ea[10]]=r[_0x58ea[18]]()?0:90,r[_0x58ea[11]]=0))});var b=u?this[_0x58ea[25]][_0x58ea[3]]*u:this[_0x58ea[25]][_0x58ea[3]]*.9,k=0,v=n[_0x58ea[24]][_0x58ea[43]],d=0;for(f=0;f<v;f++)n[_0x58ea[24]][f][_0x58ea[7]]!==n[_0x58ea[24]][f][_0x58ea[8]]&&(n[_0x58ea[24]][f][_0x58ea[11]]=0,k++);if(d=k*i+(v-k)*t,w=n[_0x58ea[24]][0][_0x58ea[18]]()?t/2:i/2,d<=b){for(o=n[_0x58ea[29]]-d/2+w,s=n[_0x58ea[30]],f=0,y=n[_0x58ea[24]][_0x58ea[43]];f<y;f++)f===0?(n[_0x58ea[24]][f][_0x58ea[29]]=o,n[_0x58ea[24]][f][_0x58ea[30]]=s):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=o+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=s):(n[_0x58ea[24]][f][_0x58ea[29]]=o+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=s),n[_0x58ea[24]][f][_0x58ea[18]]()?(o+=f===0?t/2:t,s+=0):(o+=f===0?i/2:i,s+=0);l={startDomino:n[_0x58ea[24]][0],endDomino:n[_0x58ea[24]][n[_0x58ea[24]][_0x58ea[43]]-1]}}else{if(nt=!1,!l){for(var tt=Math[_0x58ea[60]](v/2),e=tt-1,h=tt+1,p=0,a=!0;p<=b;)p=this[_0x58ea[237]](n[_0x58ea[24]],e,h,t,i),p<=b&&(a?(h+1<v?h++:e-1>=0&&e--,a=!a):(e-1>=0?e--:h+1<v&&h++,a=!a));a?e++:h--;p=this[_0x58ea[237]](n[_0x58ea[24]],e,h,t,i);l={startDomino:n[_0x58ea[24]][e],endDomino:n[_0x58ea[24]][h]};nt=!0;var w=n[_0x58ea[24]][e][_0x58ea[18]]()?t/2:i/2,o=n[_0x58ea[29]]-p/2+w,s=n[_0x58ea[30]];for(f=e,y=h+1;f<y;f++)f===e?(n[_0x58ea[24]][f][_0x58ea[29]]=o,n[_0x58ea[24]][f][_0x58ea[30]]=s):n[_0x58ea[24]][f][_0x58ea[18]]()?(n[_0x58ea[24]][f][_0x58ea[29]]=o+t/2,n[_0x58ea[24]][f][_0x58ea[30]]=s):(n[_0x58ea[24]][f][_0x58ea[29]]=o+i/2,n[_0x58ea[24]][f][_0x58ea[30]]=s),n[_0x58ea[24]][f][_0x58ea[18]]()?(o+=f===e?t/2:t,s+=0):(o+=f===e?i/2:i,s+=0)}this[_0x58ea[238]](n,t,i,l,u)}}return l}},setDominoPositionsCenterSpinner:function(n,t,i,r,u,f){var o,w,s,h,c,l,a,v,e;if(n[_0x58ea[24]][_0x58ea[43]]!==0){var y=i[_0x58ea[224]],p=i[_0x58ea[225]],a=0,v=0;if(n[_0x58ea[24]][_0x58ea[43]]===1?(o=n[_0x58ea[24]][0],n[_0x58ea[24]][0][_0x58ea[10]]=n[_0x58ea[24]][0][_0x58ea[18]]()?0:90,n[_0x58ea[24]][0][_0x58ea[11]]=0,n[_0x58ea[24]][0][_0x58ea[29]]=n[_0x58ea[29]],n[_0x58ea[24]][0][_0x58ea[30]]=n[_0x58ea[30]],o[_0x58ea[18]]()?(s=o[_0x58ea[29]]-r/2,h=o[_0x58ea[29]]+r/2,c=o[_0x58ea[30]]-u/2,l=o[_0x58ea[30]]+u/2):(s=o[_0x58ea[29]]-u/2,h=o[_0x58ea[29]]+u/2,c=o[_0x58ea[30]]-r/2,l=o[_0x58ea[30]]+r/2)):(w=this,n[_0x58ea[216]][_0x58ea[215]](function(t){var f=t[_0x58ea[211]],i,e;if(f)if(t[_0x58ea[212]]){if(i=t[_0x58ea[212]][_0x58ea[211]],e=w[_0x58ea[239]](t,t[_0x58ea[212]],t[_0x58ea[212]][_0x58ea[212]],r,u),f[_0x58ea[10]]=e[_0x58ea[10]],f[_0x58ea[11]]=0,f[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[220]:f[_0x58ea[29]]=i[_0x58ea[29]]+r/2+u/2;f[_0x58ea[30]]=i[_0x58ea[10]]===45||i[_0x58ea[10]]===-135?i[_0x58ea[30]]-u*.25:i[_0x58ea[10]]===-45||i[_0x58ea[10]]===135?i[_0x58ea[30]]+u*.25:i[_0x58ea[30]];break;case _0x58ea[223]:f[_0x58ea[29]]=i[_0x58ea[29]]-r/2-u/2;f[_0x58ea[30]]=i[_0x58ea[10]]===-45||i[_0x58ea[10]]===135?i[_0x58ea[30]]-u*.25:i[_0x58ea[10]]===45||i[_0x58ea[10]]===-135?i[_0x58ea[30]]+u*.25:i[_0x58ea[30]];break;case _0x58ea[221]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[30]]+u/2+r/2}else if(i[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[240]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]+r/2+u/2:i[_0x58ea[29]]+u;f[_0x58ea[30]]=i[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[241]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]+r/2+u/2:i[_0x58ea[29]]+u;f[_0x58ea[30]]=i[_0x58ea[30]]+u/2+r/2;break;case _0x58ea[242]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]-r/2-u/2:i[_0x58ea[29]]-u;f[_0x58ea[30]]=i[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[243]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]-r/2-u/2:i[_0x58ea[29]]-u;f[_0x58ea[30]]=i[_0x58ea[30]]+u/2+r/2;break;case _0x58ea[220]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]+r/2+u/2:i[_0x58ea[29]]+u;f[_0x58ea[30]]=i[_0x58ea[30]];break;case _0x58ea[223]:f[_0x58ea[29]]=i[_0x58ea[10]]===0?i[_0x58ea[29]]-r/2-u/2:i[_0x58ea[29]]-u;f[_0x58ea[30]]=i[_0x58ea[30]];break;case _0x58ea[221]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[10]]===0?i[_0x58ea[30]]-u:i[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[10]]===0?i[_0x58ea[30]]+u:i[_0x58ea[30]]+u/2+r/2}else switch(e[_0x58ea[12]]){case _0x58ea[220]:f[_0x58ea[29]]=i[_0x58ea[29]]+u;f[_0x58ea[30]]=i[_0x58ea[10]]===45||i[_0x58ea[10]]===-135?i[_0x58ea[30]]-r:i[_0x58ea[10]]===-45||i[_0x58ea[10]]===135?i[_0x58ea[30]]+r:i[_0x58ea[30]];break;case _0x58ea[223]:f[_0x58ea[29]]=i[_0x58ea[29]]-u;f[_0x58ea[30]]=i[_0x58ea[10]]===45||i[_0x58ea[10]]===-135?i[_0x58ea[30]]+r:i[_0x58ea[10]]===-45||i[_0x58ea[10]]===135?i[_0x58ea[30]]-r:i[_0x58ea[30]];break;case _0x58ea[221]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[30]]-u;break;case _0x58ea[222]:f[_0x58ea[29]]=i[_0x58ea[29]];f[_0x58ea[30]]=i[_0x58ea[30]]+u}f[_0x58ea[29]]<s&&(s=f[_0x58ea[29]]-e[_0x58ea[227]]);f[_0x58ea[29]]>h&&(h=f[_0x58ea[29]]+e[_0x58ea[227]]);f[_0x58ea[30]]<c&&(c=f[_0x58ea[30]]-e[_0x58ea[228]]);f[_0x58ea[30]]>l&&(l=f[_0x58ea[30]]+e[_0x58ea[228]])}else f[_0x58ea[10]]=f[_0x58ea[18]]()?0:90,f[_0x58ea[11]]=0,f[_0x58ea[29]]=n[_0x58ea[29]],f[_0x58ea[30]]=n[_0x58ea[30]],f[_0x58ea[18]]()?(s=f[_0x58ea[29]]-r/2,h=f[_0x58ea[29]]+r/2,c=f[_0x58ea[30]]-u/2,l=f[_0x58ea[30]]+u/2):(s=f[_0x58ea[29]]-u/2,h=f[_0x58ea[29]]+u/2,c=f[_0x58ea[30]]-r/2,l=f[_0x58ea[30]]+r/2)}),a=h-s,v=l-c),y>=a&&p>=v)n[_0x58ea[216]][_0x58ea[215]](function(n){var t=n[_0x58ea[211]];t[_0x58ea[29]]=t[_0x58ea[29]]+y/2-(s+h)/2+i[_0x58ea[229]];t[_0x58ea[30]]=t[_0x58ea[30]]+p/2-(c+l)/2+i[_0x58ea[230]]});else{if(y<a&&p<v)var b=y/a,k=p/v,e=f*Math[_0x58ea[150]](b,k);else y<a?e=f*y/a:p<v&&(e=f*p/v);e=e*.9;n[_0x58ea[33]]=e;t[_0x58ea[231]](function(n){n[_0x58ea[33]][_0x58ea[92]](e)});this[_0x58ea[244]](n,t,i,globalParams[_0x58ea[232]]*e,globalParams[_0x58ea[233]]*e,e)}}},getOrientationCenterSpinner:function(n,t,i,r,u){var e=n[_0x58ea[211]],f=t[_0x58ea[211]],o,s;if(f[_0x58ea[18]]())if(i){if(o=i[_0x58ea[211]],s=t[_0x58ea[213]][_0x58ea[21]](n),o[_0x58ea[10]]===90&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-90&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-135&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===45&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-45&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===135&&o[_0x58ea[7]]===f[_0x58ea[7]]){if(s===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(s===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(s===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}}if(o[_0x58ea[10]]===90&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-90&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===135&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-45&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===-135&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===45&&o[_0x58ea[8]]===f[_0x58ea[7]]){if(s===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}if(s===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(s===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}}if(o[_0x58ea[10]]===0&&o[_0x58ea[8]]===f[_0x58ea[7]]||o[_0x58ea[10]]===180&&o[_0x58ea[7]]===f[_0x58ea[7]]){if(s===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2}}if(s===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(s===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}}if(o[_0x58ea[10]]===0&&o[_0x58ea[7]]===f[_0x58ea[7]]||o[_0x58ea[10]]===180&&o[_0x58ea[8]]===f[_0x58ea[7]]){if(s===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}if(s===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2}}if(s===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2}}}}else{if(s=t[_0x58ea[213]][_0x58ea[21]](n),s===0){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-135,direction:_0x58ea[240],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:45,direction:_0x58ea[240],leftPadding:u/2,topPadding:r/2}}if(s===1){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-45,direction:_0x58ea[241],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:135,direction:_0x58ea[241],leftPadding:u/2,topPadding:r/2}}if(s===2){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:135,direction:_0x58ea[242],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-45,direction:_0x58ea[242],leftPadding:r/2,topPadding:u/2}}if(s===3){if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:45,direction:_0x58ea[243],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-135,direction:_0x58ea[243],leftPadding:r/2,topPadding:u/2}}}else if(e[_0x58ea[18]]())switch(f[_0x58ea[10]]){case-135:if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case 135:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case 45:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case-45:if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case 90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};break;case-90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[223],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[220],leftPadding:r/2,topPadding:u/2};break;case 0:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[221],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[222],leftPadding:u/2,topPadding:r/2};break;case 180:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[222],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[221],leftPadding:u/2,topPadding:r/2}}else switch(f[_0x58ea[10]]){case-135:if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case 135:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case 45:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case-45:if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case 90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};break;case-90:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:-90,direction:_0x58ea[223],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:-90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:90,direction:_0x58ea[220],leftPadding:u/2,topPadding:r/2};break;case 0:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};break;case 180:if(e[_0x58ea[7]]===f[_0x58ea[7]])return{angle:0,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[7]])return{angle:180,direction:_0x58ea[222],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[7]]===f[_0x58ea[8]])return{angle:180,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2};if(e[_0x58ea[8]]===f[_0x58ea[8]])return{angle:0,direction:_0x58ea[221],leftPadding:r/2,topPadding:u/2}}},setDominoPositionsSingleSpinner:function(n,t,i,r,u,f){var w,d,b,e,o,h,g,s;if(n[_0x58ea[24]][_0x58ea[43]]!==0){var c=i[_0x58ea[224]],l=i[_0x58ea[225]],a=0,v=0,p,y,k=!1;for(w=0,d=n[_0x58ea[24]][_0x58ea[43]];w<d;w++)if(b=n[_0x58ea[24]][w],b[_0x58ea[18]]()){p=b;break}if(n[_0x58ea[216]][_0x58ea[215]](function(n){var t=n[_0x58ea[211]];n[_0x58ea[212]]||t!==p||(k=!0);t===p&&(y=n);delete n[_0x58ea[219]]}),p)if(e=y,k){for(o=0,e=y[_0x58ea[213]][2];e;)o++,o===3&&(e[_0x58ea[219]]={direction:_0x58ea[220]}),e=e[_0x58ea[213]][0];for(o=0,e=y[_0x58ea[213]][3];e;)o++,o===3&&(e[_0x58ea[219]]={direction:_0x58ea[223]}),e=e[_0x58ea[213]][0]}else{for(o=0,e=y[_0x58ea[213]][1];e;)o++,o===3&&(e[_0x58ea[219]]={direction:_0x58ea[220]}),e=e[_0x58ea[213]][0];for(o=0,e=y[_0x58ea[213]][2];e;)o++,o===3&&(e[_0x58ea[219]]={direction:_0x58ea[223]}),e=e[_0x58ea[213]][0]}if(n[_0x58ea[24]][_0x58ea[43]]===1?(h=n[_0x58ea[24]][0],n[_0x58ea[24]][0][_0x58ea[10]]=n[_0x58ea[24]][0][_0x58ea[18]]()?0:90,n[_0x58ea[24]][0][_0x58ea[11]]=0,n[_0x58ea[24]][0][_0x58ea[29]]=i[_0x58ea[144]],n[_0x58ea[24]][0][_0x58ea[30]]=i[_0x58ea[245]],h[_0x58ea[18]]()?(xMin=h[_0x58ea[29]]-r/2,xMax=h[_0x58ea[29]]+r/2,yMin=h[_0x58ea[30]]-u/2,yMax=h[_0x58ea[30]]+u/2):(xMin=h[_0x58ea[29]]-u/2,xMax=h[_0x58ea[29]]+u/2,yMin=h[_0x58ea[30]]-r/2,yMax=h[_0x58ea[30]]+r/2)):(g=this,n[_0x58ea[216]][_0x58ea[215]](function(t){var i=t[_0x58ea[211]],f,e;if(i)if(t[_0x58ea[212]]){if(f=t[_0x58ea[212]][_0x58ea[211]],e=g[_0x58ea[226]](t,t[_0x58ea[212]],t[_0x58ea[212]][_0x58ea[212]],r,u),i[_0x58ea[10]]=e[_0x58ea[10]],i[_0x58ea[11]]=0,i[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[220]:t[_0x58ea[219]]?(i[_0x58ea[29]]=f[_0x58ea[29]]+r,i[_0x58ea[30]]=f[_0x58ea[30]]-u/2):(i[_0x58ea[29]]=f[_0x58ea[29]]+r/2+u/2,i[_0x58ea[30]]=f[_0x58ea[30]]);break;case _0x58ea[223]:t[_0x58ea[219]]?(i[_0x58ea[29]]=f[_0x58ea[29]]-r,i[_0x58ea[30]]=f[_0x58ea[30]]+u/2):(i[_0x58ea[29]]=f[_0x58ea[29]]-r/2-u/2,i[_0x58ea[30]]=f[_0x58ea[30]]);break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]+u/2+r/2}else if(f[_0x58ea[18]]())switch(e[_0x58ea[12]]){case _0x58ea[220]:i[_0x58ea[29]]=t[_0x58ea[219]]?f[_0x58ea[29]]+u:f[_0x58ea[10]]===0?f[_0x58ea[29]]+r/2+u/2:f[_0x58ea[29]]+u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[223]:i[_0x58ea[29]]=t[_0x58ea[219]]?f[_0x58ea[29]]-u:f[_0x58ea[10]]===0?f[_0x58ea[29]]-r/2-u/2:f[_0x58ea[29]]-u;i[_0x58ea[30]]=f[_0x58ea[30]];break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[10]]===0?f[_0x58ea[30]]-u:f[_0x58ea[30]]-u/2-r/2;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[10]]===0?f[_0x58ea[30]]+u:f[_0x58ea[30]]+u/2+r/2}else switch(e[_0x58ea[12]]){case _0x58ea[220]:t[_0x58ea[219]]?(i[_0x58ea[29]]=f[_0x58ea[29]]+u/2+r/2,i[_0x58ea[30]]=f[_0x58ea[30]]-r/2):(i[_0x58ea[29]]=f[_0x58ea[29]]+u,i[_0x58ea[30]]=f[_0x58ea[30]]);break;case _0x58ea[223]:t[_0x58ea[219]]?(i[_0x58ea[29]]=f[_0x58ea[29]]-u/2-r/2,i[_0x58ea[30]]=f[_0x58ea[30]]+r/2):(i[_0x58ea[29]]=f[_0x58ea[29]]-u,i[_0x58ea[30]]=f[_0x58ea[30]]);break;case _0x58ea[221]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]-u;break;case _0x58ea[222]:i[_0x58ea[29]]=f[_0x58ea[29]];i[_0x58ea[30]]=f[_0x58ea[30]]+u}i[_0x58ea[29]]<xMin&&(xMin=i[_0x58ea[29]]-e[_0x58ea[227]]);i[_0x58ea[29]]>xMax&&(xMax=i[_0x58ea[29]]+e[_0x58ea[227]]);i[_0x58ea[30]]<yMin&&(yMin=i[_0x58ea[30]]-e[_0x58ea[228]]);i[_0x58ea[30]]>yMax&&(yMax=i[_0x58ea[30]]+e[_0x58ea[228]])}else i[_0x58ea[10]]=i[_0x58ea[18]]()?0:90,i[_0x58ea[11]]=0,i[_0x58ea[29]]=n[_0x58ea[29]],i[_0x58ea[30]]=n[_0x58ea[30]],i[_0x58ea[18]]()?(xMin=i[_0x58ea[29]]-r/2,xMax=i[_0x58ea[29]]+r/2,yMin=i[_0x58ea[30]]-u/2,yMax=i[_0x58ea[30]]+u/2):(xMin=i[_0x58ea[29]]-u/2,xMax=i[_0x58ea[29]]+u/2,yMin=i[_0x58ea[30]]-r/2,yMax=i[_0x58ea[30]]+r/2)}),a=xMax-xMin,v=yMax-yMin),c>=a&&l>=v)n[_0x58ea[216]][_0x58ea[215]](function(n){var t=n[_0x58ea[211]];t[_0x58ea[29]]=t[_0x58ea[29]]+c/2-(xMin+xMax)/2+i[_0x58ea[229]];t[_0x58ea[30]]=t[_0x58ea[30]]+l/2-(yMin+yMax)/2+i[_0x58ea[230]]});else{if(c<a&&l<v)var nt=c/a,tt=l/v,s=f*Math[_0x58ea[150]](nt,tt);else c<a?s=f*c/a:l<v&&(s=f*l/v);s=s*.9;n[_0x58ea[33]]=s;t[_0x58ea[231]](function(n){n[_0x58ea[33]][_0x58ea[92]](s)});this[_0x58ea[246]](n,t,i,globalParams[_0x58ea[232]]*s,globalParams[_0x58ea[233]]*s,s)}}}};Dice=function(n,t){Phaser[_0x58ea[249]][_0x58ea[248]](this,mygame,n,t,_0x58ea[247]);this[_0x58ea[114]];this[_0x58ea[250]];this[_0x58ea[251]]=mygame[_0x58ea[77]][_0x58ea[253]](_0x58ea[252]);this[_0x58ea[254]]=mygame[_0x58ea[77]][_0x58ea[253]](_0x58ea[255]);this[_0x58ea[256]]=0;this[_0x58ea[219]]=!0;this[_0x58ea[35]][_0x58ea[92]](.5,.5);this[_0x58ea[10]]=mygame[_0x58ea[257]][_0x58ea[10]]();for(var r=[],i=0;i<15;i++)r[i]=this[_0x58ea[256]]+mygame[_0x58ea[257]][_0x58ea[258]]([0,1,2,3,4,5]);this[_0x58ea[250]]=this[_0x58ea[260]][_0x58ea[77]](_0x58ea[259],r);this[_0x58ea[250]][_0x58ea[123]][_0x58ea[77]](this[_0x58ea[261]],this);this[_0x58ea[9]]=1;mygame[_0x58ea[77]][_0x58ea[262]](this)};Dice[_0x58ea[17]]=Object[_0x58ea[263]](Phaser[_0x58ea[249]][_0x58ea[17]]);Dice[_0x58ea[17]][_0x58ea[264]]=Dice;Dice[_0x58ea[17]][_0x58ea[265]]=function(n){this[_0x58ea[256]]=n;this[_0x58ea[9]]+=n};Dice[_0x58ea[17]][_0x58ea[266]]=function(n){this[_0x58ea[219]]=n;n||(this[_0x58ea[10]]=0)};Dice[_0x58ea[17]][_0x58ea[259]]=function(){this[_0x58ea[267]]=[this[_0x58ea[251]],this[_0x58ea[254]]];this[_0x58ea[260]][_0x58ea[80]](_0x58ea[259],20)};Dice[_0x58ea[17]][_0x58ea[261]]=function(){this[_0x58ea[267]]=null;this[_0x58ea[9]]=this[_0x58ea[256]]+mygame[_0x58ea[257]][_0x58ea[258]]([0,1,2,3,4,5])};Dice[_0x58ea[17]][_0x58ea[268]]=function(){this[_0x58ea[250]][_0x58ea[269]]&&this[_0x58ea[219]]&&(this[_0x58ea[10]]=mygame[_0x58ea[257]][_0x58ea[10]]())};Dice[_0x58ea[17]][_0x58ea[270]]=function(){return this[_0x58ea[250]][_0x58ea[269]]};Dice[_0x58ea[17]][_0x58ea[271]]=function(){switch(this[_0x58ea[9]]-this[_0x58ea[256]]){case 0:return 1;case 1:return 2;case 2:return 3;case 3:return 4;case 4:return 5;case 5:return 6;default:return null}};globalParams={backFrame:0,blankFrame:1,tileWidth:50,tileHeight:100,doubleFrames:[1,8,14,19,23,26,28]};log[_0x58ea[14]]=!1;var _0x5f5d=["scaleMode","scale","RESIZE","ScaleManager","fullScreenScaleMode","backgroundColor","stage","loading","/Resources/images/loading.png","image","load","Loading","start","state","centerX","world","centerY","sprite","add","setTo","anchor","setPreloadSprite","dominoes","/Resources/images/dominoes.png","spritesheet","settings","/Resources/images/settings_1.png","background","/Resources/images/background.jpg","atlas","/Resources/images/atlas_web_11.png","/Resources/images/atlas_web_11.json","Loader","click","/Resources/sounds/click.mp3","/Resources/sounds/click.ogg","audio","move","/Resources/sounds/move.mp3","/Resources/sounds/move.ogg","select","/Resources/sounds/select.mp3","/Resources/sounds/select.ogg","next","/Resources/sounds/next.mp3","/Resources/sounds/next.ogg","pass","/Resources/sounds/pass.mp3","/Resources/sounds/pass.ogg","msg","/Resources/sounds/msg.mp3","/Resources/sounds/msg.ogg","gameover","/Resources/sounds/gameover.mp3","/Resources/sounds/gameover.ogg","diceroll","/Resources/sounds/diceroll.mp3","/Resources/sounds/diceroll.ogg","play_preroll","/Resources/images/play_preroll.png","initAudio","multiplayer","selection","Game_","getItem","p","","removeItem","playersCount","initState","selectionState","SelectOpponents","dual","m","mode","SelectMode","showEmbedAds","showMobilePreloadAds","PlayAd","prototype","width","game","height","title","selectmode.png","classicButton","playTheGame","button","type","Classic","frameName","classic.png","relaxedButton","Relaxed","relaxed.png","closeButton","close","frame","visible","resize","clicked","playAudio","min","scaleSprite","x","y","selectplayers.png","playTwoButton","selecttwo.png","playThereButton","selectthree.png","playFourButton","selectfour.png","playerOptions","playOptions","NoSpinner","OneSpinner","AllSpinners","alignVertical","length","selectedOpponents","selectedOption","players","selectplayers","indexOf","selectPlayer","push","highlightPlayer","options","selectmode","selectPlayOption","option","off.png",".png","highlightOption","playButton","play.png","cancel.png","tint","on.png","You","Tom","Amy","Dan","score","winnerText","You, Ric","style1","bold 36px Arial","#fff","center","middle","style2","#FFFF00","gametitle.png","name","text","#000","setShadow","board","boneyard.png","homeButton","home","moreGamesButton","more","nameLabel","scoreLabel","winnerLabel","Winner: ","positionControls","scaleText","props","Time","00:00:05","Score","clockSeconds","message3.png","GameoverImg",": ","\n","playAd","titleLabel","helpModal","getElementById","getElementsByClassName","onclick","display","style","none","help","visibility","id","block"],mygame,audioManager,Boot={init:function(){mygame[_0x5f5d[1]][_0x5f5d[0]]=Phaser[_0x5f5d[3]][_0x5f5d[2]];mygame[_0x5f5d[1]][_0x5f5d[4]]=Phaser[_0x5f5d[3]][_0x5f5d[2]]},preload:function(){mygame[_0x5f5d[6]][_0x5f5d[5]]=4138514;mygame[_0x5f5d[10]][_0x5f5d[9]](_0x5f5d[7],_0x5f5d[8])},create:function(){mygame[_0x5f5d[13]][_0x5f5d[12]](_0x5f5d[11])}},Loading={init:function(){},preload:function(){var n=mygame[_0x5f5d[18]][_0x5f5d[17]](this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[15]][_0x5f5d[16]],_0x5f5d[7]);n[_0x5f5d[20]][_0x5f5d[19]](.5);mygame[_0x5f5d[10]][_0x5f5d[21]](n);mygame[_0x5f5d[6]][_0x5f5d[5]]=4138514;mygame[_0x5f5d[10]][_0x5f5d[24]](_0x5f5d[22],_0x5f5d[23],50,100);mygame[_0x5f5d[10]][_0x5f5d[24]](_0x5f5d[25],_0x5f5d[26],180,180);mygame[_0x5f5d[10]][_0x5f5d[9]](_0x5f5d[27],_0x5f5d[28]);mygame[_0x5f5d[10]][_0x5f5d[29]](_0x5f5d[29],_0x5f5d[30],_0x5f5d[31],Phaser[_0x5f5d[32]].TEXTURE_ATLAS_JSON_HASH);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[33],[_0x5f5d[34],_0x5f5d[35]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[37],[_0x5f5d[38],_0x5f5d[39]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[40],[_0x5f5d[41],_0x5f5d[42]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[43],[_0x5f5d[44],_0x5f5d[45]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[46],[_0x5f5d[47],_0x5f5d[48]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[49],[_0x5f5d[50],_0x5f5d[51]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[52],[_0x5f5d[53],_0x5f5d[54]]);mygame[_0x5f5d[10]][_0x5f5d[36]](_0x5f5d[55],[_0x5f5d[56],_0x5f5d[57]]);isMobileView&&mygame[_0x5f5d[10]][_0x5f5d[9]](_0x5f5d[58],_0x5f5d[59])},create:function(){var i,u,n,r,t;audioManager=new LocalAudioManager(mygame);audioManager[_0x5f5d[60]]([_0x5f5d[33],_0x5f5d[37],_0x5f5d[40],_0x5f5d[43],_0x5f5d[46],_0x5f5d[52],_0x5f5d[49],_0x5f5d[55]]);isMobileView||showHelp();i=getGameConfig(dominoGameType);u=i[_0x5f5d[13]];i[_0x5f5d[61]]?i[_0x5f5d[62]]?(r=sessionManager[_0x5f5d[64]](_0x5f5d[63]+dominoGameType),n=r?r[_0x5f5d[65]]:null,n&&n!=_0x5f5d[66]&&(n=parseInt(n)),n&&n<=4&&n>=2?(sessionManager[_0x5f5d[67]](_0x5f5d[63]+dominoGameType),mygame[_0x5f5d[68]]=n,this[_0x5f5d[69]](u)):i[_0x5f5d[70]]?this[_0x5f5d[69]](i[_0x5f5d[70]]):this[_0x5f5d[69]](_0x5f5d[71])):this[_0x5f5d[69]](u):i[_0x5f5d[72]]?(r=sessionManager[_0x5f5d[64]](_0x5f5d[63]+dominoGameType),t=r?r[_0x5f5d[73]]:null,t&&t!=_0x5f5d[66]&&(t=parseInt(t)),t&&(t===1||t===2)?(sessionManager[_0x5f5d[67]](_0x5f5d[63]+dominoGameType),mygame[_0x5f5d[74]]=t,this[_0x5f5d[69]](u)):this[_0x5f5d[69]](_0x5f5d[75])):this[_0x5f5d[69]](u)},initState:function(n){dominoGameState=n;globalOptions[_0x5f5d[76]]&&isEmbed||(globalOptions[_0x5f5d[77]]&&isMobileView?(mygame[_0x5f5d[13]][_0x5f5d[18]](_0x5f5d[78],PlayAd),mygame[_0x5f5d[13]][_0x5f5d[12]](_0x5f5d[78])):initGameState())}};SelectMode=function(){};SelectMode[_0x5f5d[79]]={create:function(){var n=this[_0x5f5d[81]][_0x5f5d[80]],t=this[_0x5f5d[81]][_0x5f5d[82]];this[_0x5f5d[27]]=this[_0x5f5d[18]][_0x5f5d[9]](0,0,_0x5f5d[27]);this[_0x5f5d[83]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[84]);this[_0x5f5d[83]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[85]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[85]][_0x5f5d[88]]=GameMode[_0x5f5d[89]];this[_0x5f5d[85]][_0x5f5d[90]]=_0x5f5d[91];this[_0x5f5d[85]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[92]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[92]][_0x5f5d[88]]=GameMode[_0x5f5d[93]];this[_0x5f5d[92]][_0x5f5d[90]]=_0x5f5d[94];this[_0x5f5d[92]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[95]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[96]],this);this[_0x5f5d[95]][_0x5f5d[97]]=6;this[_0x5f5d[95]][_0x5f5d[20]][_0x5f5d[19]](.5);isEmbed&&(this[_0x5f5d[95]][_0x5f5d[98]]=!1);this[_0x5f5d[99]](n,t)},close:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),goToHome())},resize:function(n,t){this[_0x5f5d[27]][_0x5f5d[82]]=t;this[_0x5f5d[27]][_0x5f5d[80]]=n;scaleManager[_0x5f5d[103]](this[_0x5f5d[83]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[83]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[83]][_0x5f5d[105]]=t*.1;scaleManager[_0x5f5d[103]](this[_0x5f5d[85]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.05,1);this[_0x5f5d[85]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[85]][_0x5f5d[105]]=t*.35;scaleManager[_0x5f5d[103]](this[_0x5f5d[92]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.05,1);this[_0x5f5d[92]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[92]][_0x5f5d[105]]=t*.6;scaleManager[_0x5f5d[103]](this[_0x5f5d[95]],n,t*.15,Math[_0x5f5d[102]](n,t*.1)*.1,1);this[_0x5f5d[95]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[95]][_0x5f5d[105]]=t-this[_0x5f5d[95]][_0x5f5d[82]]*1.5/2},playTheGame:function(n){if(!n[_0x5f5d[100]]){n[_0x5f5d[100]]=!0;audioManager[_0x5f5d[101]](_0x5f5d[33]);var t=getGameConfig(dominoGameType)[_0x5f5d[13]];this[_0x5f5d[13]][_0x5f5d[12]](t,SlideLeftOut,SlideLeftIn,!0,!1,n[_0x5f5d[88]])}}};SelectOpponents=function(){};SelectOpponents[_0x5f5d[79]]={create:function(){var n=this[_0x5f5d[81]][_0x5f5d[80]],t=this[_0x5f5d[81]][_0x5f5d[82]];this[_0x5f5d[27]]=this[_0x5f5d[18]][_0x5f5d[9]](0,0,_0x5f5d[27]);this[_0x5f5d[83]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[106]);this[_0x5f5d[83]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[107]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[107]][_0x5f5d[88]]=2;this[_0x5f5d[107]][_0x5f5d[90]]=_0x5f5d[108];this[_0x5f5d[107]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[109]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[109]][_0x5f5d[88]]=3;this[_0x5f5d[109]][_0x5f5d[90]]=_0x5f5d[110];this[_0x5f5d[109]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[111]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[111]][_0x5f5d[88]]=4;this[_0x5f5d[111]][_0x5f5d[90]]=_0x5f5d[112];this[_0x5f5d[111]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[95]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[96]],this);this[_0x5f5d[95]][_0x5f5d[97]]=6;this[_0x5f5d[95]][_0x5f5d[20]][_0x5f5d[19]](.5);isEmbed&&(this[_0x5f5d[95]][_0x5f5d[98]]=!1);this[_0x5f5d[99]](n,t)},close:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),goToHome())},resize:function(n,t){this[_0x5f5d[27]][_0x5f5d[82]]=t;this[_0x5f5d[27]][_0x5f5d[80]]=n;scaleManager[_0x5f5d[103]](this[_0x5f5d[83]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[83]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[83]][_0x5f5d[105]]=t*.1;scaleManager[_0x5f5d[103]](this[_0x5f5d[107]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[107]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[107]][_0x5f5d[105]]=t*.3;scaleManager[_0x5f5d[103]](this[_0x5f5d[109]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[109]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[109]][_0x5f5d[105]]=t*.5;scaleManager[_0x5f5d[103]](this[_0x5f5d[111]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[111]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[111]][_0x5f5d[105]]=t*.7;scaleManager[_0x5f5d[103]](this[_0x5f5d[95]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1);this[_0x5f5d[95]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[95]][_0x5f5d[105]]=t-this[_0x5f5d[95]][_0x5f5d[82]]*1.2/2},playTheGame:function(n){if(!n[_0x5f5d[100]]){n[_0x5f5d[100]]=!0;audioManager[_0x5f5d[101]](_0x5f5d[33]);var t=getGameConfig(dominoGameType)[_0x5f5d[13]];this[_0x5f5d[13]][_0x5f5d[12]](t,SlideLeftOut,SlideLeftIn,!0,!1,n[_0x5f5d[88]])}}};SelectOptions=function(){};SelectOptions[_0x5f5d[79]]={create:function(){var e=this[_0x5f5d[81]][_0x5f5d[80]],o=this[_0x5f5d[81]][_0x5f5d[82]],i,r,u;this[_0x5f5d[27]]=this[_0x5f5d[18]][_0x5f5d[9]](0,0,_0x5f5d[27]);var f=getGameConfig(dominoGameType),t=f[_0x5f5d[113]]?f[_0x5f5d[113]]:[2,3,4],n=f[_0x5f5d[114]]?f[_0x5f5d[114]]:[PlayOptions[_0x5f5d[115]],PlayOptions[_0x5f5d[116]],PlayOptions[_0x5f5d[117]]];if(this[_0x5f5d[118]]=!0,t[_0x5f5d[119]]>0&&n[_0x5f5d[119]]>0&&(this[_0x5f5d[118]]=!1),this[_0x5f5d[120]]=-1,this[_0x5f5d[121]]=-1,this[_0x5f5d[122]]=[],t&&t[_0x5f5d[119]]>0&&(this[_0x5f5d[123]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[106]),this[_0x5f5d[123]][_0x5f5d[20]][_0x5f5d[19]](.5),t[_0x5f5d[124]](2)>=0&&(this[_0x5f5d[107]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[125]],this),this[_0x5f5d[107]][_0x5f5d[88]]=2,this[_0x5f5d[107]][_0x5f5d[90]]=_0x5f5d[108],this[_0x5f5d[107]][_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[122]][_0x5f5d[126]](this[_0x5f5d[107]])),t[_0x5f5d[124]](3)>=0&&(this[_0x5f5d[109]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[125]],this),this[_0x5f5d[109]][_0x5f5d[88]]=3,this[_0x5f5d[109]][_0x5f5d[90]]=_0x5f5d[110],this[_0x5f5d[109]][_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[122]][_0x5f5d[126]](this[_0x5f5d[109]])),t[_0x5f5d[124]](4)>=0&&(this[_0x5f5d[111]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[125]],this),this[_0x5f5d[111]][_0x5f5d[88]]=4,this[_0x5f5d[111]][_0x5f5d[90]]=_0x5f5d[112],this[_0x5f5d[111]][_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[122]][_0x5f5d[126]](this[_0x5f5d[111]])),this[_0x5f5d[120]]=this[_0x5f5d[122]][this[_0x5f5d[122]][_0x5f5d[119]]-1][_0x5f5d[88]],this[_0x5f5d[127]](this[_0x5f5d[120]])),this[_0x5f5d[128]]=[],n&&n[_0x5f5d[119]]>0){for(this[_0x5f5d[129]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[84]),this[_0x5f5d[129]][_0x5f5d[20]][_0x5f5d[19]](.5),i=0;i<n[_0x5f5d[119]];i++)r=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[130]],this),r[_0x5f5d[131]]=n[i],r[_0x5f5d[90]]=_0x5f5d[132],r[_0x5f5d[20]][_0x5f5d[19]](.5),u=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[130]],this),u[_0x5f5d[131]]=n[i],u[_0x5f5d[90]]=_0x5f5d[74]+n[i]+_0x5f5d[133],u[_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[128]][_0x5f5d[126]]([r,u]);this[_0x5f5d[121]]=n[0];this[_0x5f5d[134]](this[_0x5f5d[121]])}this[_0x5f5d[135]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[86]],this);this[_0x5f5d[135]][_0x5f5d[90]]=_0x5f5d[136];this[_0x5f5d[135]][_0x5f5d[20]][_0x5f5d[19]](.5);this[_0x5f5d[95]]=this[_0x5f5d[81]][_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[29],this[_0x5f5d[96]],this);this[_0x5f5d[95]][_0x5f5d[90]]=_0x5f5d[137];this[_0x5f5d[95]][_0x5f5d[20]][_0x5f5d[19]](.5);isEmbed&&(this[_0x5f5d[95]][_0x5f5d[98]]=!1);this[_0x5f5d[99]](e,o)},highlightPlayer:function(n){for(var i,t=0;t<this[_0x5f5d[122]][_0x5f5d[119]];t++)i=this[_0x5f5d[122]][t],i[_0x5f5d[138]]=i[_0x5f5d[88]]!==n?8421504:16777215},highlightOption:function(n){for(var i,t=0;t<this[_0x5f5d[128]][_0x5f5d[119]];t++)i=this[_0x5f5d[128]][t],i[0][_0x5f5d[90]]=i[0][_0x5f5d[131]]!==n?_0x5f5d[132]:_0x5f5d[139]},selectPlayer:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),this[_0x5f5d[127]](n[_0x5f5d[88]]),this[_0x5f5d[120]]=n[_0x5f5d[88]],n[_0x5f5d[100]]=!1)},selectPlayOption:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),this[_0x5f5d[134]](n[_0x5f5d[131]]),this[_0x5f5d[121]]=n[_0x5f5d[131]],n[_0x5f5d[100]]=!1)},close:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),goToHome())},resize:function(n,t){var e,f,o,r,i,u;if(this[_0x5f5d[27]][_0x5f5d[82]]=t,this[_0x5f5d[27]][_0x5f5d[80]]=n,this[_0x5f5d[118]]){if(e=this[_0x5f5d[122]][_0x5f5d[119]],e>0)for(scaleManager[_0x5f5d[103]](this[_0x5f5d[123]],n,t*.15,Math[_0x5f5d[102]](n,t*.2)*.2,1),this[_0x5f5d[123]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[123]][_0x5f5d[105]]=t*.1,r=.6/e,i=0;i<e;i++)f=this[_0x5f5d[122]][i],scaleManager[_0x5f5d[103]](f,n,t*r,Math[_0x5f5d[102]](n,t*r)*.1,1),f[_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],f[_0x5f5d[105]]=t*.2+(i+.5)*t*r;if(o=this[_0x5f5d[128]][_0x5f5d[119]],o>0)for(scaleManager[_0x5f5d[103]](this[_0x5f5d[129]],n,t*.15,Math[_0x5f5d[102]](n,t*.2)*.2,1),this[_0x5f5d[129]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[129]][_0x5f5d[105]]=t*.1,r=.6/o,i=0;i<o;i++)u=this[_0x5f5d[128]][i],scaleManager[_0x5f5d[103]](u[0],n*.2,t*r,Math[_0x5f5d[102]](n*.2,t*r)*.1,1),u[0][_0x5f5d[104]]=u[0][_0x5f5d[80]]/2,u[0][_0x5f5d[105]]=t*.2+(i+.5)*t*r,scaleManager[_0x5f5d[103]](u[1],n*.8,t*r,Math[_0x5f5d[102]](n*.8,t*r)*.1,1),u[1][_0x5f5d[104]]=u[0][_0x5f5d[80]]+u[1][_0x5f5d[80]]/2,u[1][_0x5f5d[105]]=t*.2+(i+.5)*t*r}else{for(e=this[_0x5f5d[122]][_0x5f5d[119]],scaleManager[_0x5f5d[103]](this[_0x5f5d[123]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1),this[_0x5f5d[123]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[123]][_0x5f5d[105]]=t*.05,r=1/e,i=0;i<e;i++)f=this[_0x5f5d[122]][i],scaleManager[_0x5f5d[103]](f,n*.3,t*.2,Math[_0x5f5d[102]](n*.3,t*.2)*.1,1),f[_0x5f5d[104]]=(i+.5)*n*r,f[_0x5f5d[105]]=t*.2;for(o=this[_0x5f5d[128]][_0x5f5d[119]],scaleManager[_0x5f5d[103]](this[_0x5f5d[129]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1),this[_0x5f5d[129]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[129]][_0x5f5d[105]]=t*.38,r=.4/o,i=0;i<o;i++)u=this[_0x5f5d[128]][i],scaleManager[_0x5f5d[103]](u[0],n*.2,t*r,Math[_0x5f5d[102]](n*.2,t*r)*.1,1),u[0][_0x5f5d[104]]=u[0][_0x5f5d[80]]/2,u[0][_0x5f5d[105]]=t*.4+(i+.5)*t*r,scaleManager[_0x5f5d[103]](u[1],n*.8,t*r,Math[_0x5f5d[102]](n*.8,t*r)*.1,1),u[1][_0x5f5d[104]]=u[0][_0x5f5d[80]]+u[1][_0x5f5d[80]]/2,u[1][_0x5f5d[105]]=u[0][_0x5f5d[105]]}scaleManager[_0x5f5d[103]](this[_0x5f5d[135]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1);this[_0x5f5d[135]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]-this[_0x5f5d[135]][_0x5f5d[80]]*1.2/2;this[_0x5f5d[135]][_0x5f5d[105]]=t*.9;scaleManager[_0x5f5d[103]](this[_0x5f5d[95]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1);this[_0x5f5d[95]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]+this[_0x5f5d[95]][_0x5f5d[80]]*1.2/2;this[_0x5f5d[95]][_0x5f5d[105]]=t*.9},playTheGame:function(n){var t,i;n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),t=getGameConfig(dominoGameType),dominoGameType=t[_0x5f5d[128]][t[_0x5f5d[114]][_0x5f5d[124]](this[_0x5f5d[121]])],i=t[_0x5f5d[13]],this[_0x5f5d[13]][_0x5f5d[12]](i,SlideLeftOut,SlideLeftIn,!0,!1,this[_0x5f5d[120]]))}};var MultiplayerGameOver={init:function(n){n?this[_0x5f5d[122]]=n:(this[_0x5f5d[122]]=[new Player(1,_0x5f5d[140]),new Player(2,_0x5f5d[141]),new Player(3,_0x5f5d[142]),new Player(4,_0x5f5d[143])],this[_0x5f5d[122]][0][_0x5f5d[144]]=105,this[_0x5f5d[122]][1][_0x5f5d[144]]=5,this[_0x5f5d[122]][2][_0x5f5d[144]]=45,this[_0x5f5d[122]][3][_0x5f5d[144]]=23,this[_0x5f5d[122]][_0x5f5d[145]]=_0x5f5d[146])},create:function(){var r=this[_0x5f5d[81]][_0x5f5d[80]],u=this[_0x5f5d[81]][_0x5f5d[82]],t,i,n;for(this[_0x5f5d[27]]=this[_0x5f5d[18]][_0x5f5d[9]](0,0,_0x5f5d[27]),this[_0x5f5d[147]]={font:_0x5f5d[148],fill:_0x5f5d[149],boundsAlignH:_0x5f5d[150],boundsAlignV:_0x5f5d[151],align:_0x5f5d[150]},this[_0x5f5d[152]]={font:_0x5f5d[148],fill:_0x5f5d[153],boundsAlignH:_0x5f5d[150],boundsAlignV:_0x5f5d[151],align:_0x5f5d[150]},this[_0x5f5d[83]]=mygame[_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[154]),this[_0x5f5d[83]][_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[155]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,getGameName(dominoGameType),this[_0x5f5d[147]]),this[_0x5f5d[155]][_0x5f5d[20]][_0x5f5d[19]](.5,.5),this[_0x5f5d[155]][_0x5f5d[158]](2,2,_0x5f5d[157],2),this[_0x5f5d[159]]=mygame[_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[160]),this[_0x5f5d[159]][_0x5f5d[20]][_0x5f5d[19]](.5,.5),this[_0x5f5d[161]]=mygame[_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[162]],this),this[_0x5f5d[161]][_0x5f5d[97]]=13,this[_0x5f5d[161]][_0x5f5d[20]][_0x5f5d[19]](.5),isEmbed&&(this[_0x5f5d[163]]=mygame[_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[164]],this),this[_0x5f5d[163]][_0x5f5d[97]]=14,this[_0x5f5d[163]][_0x5f5d[20]][_0x5f5d[19]](.5)),t=0,i=this[_0x5f5d[122]][_0x5f5d[119]];t<i;t++)n=this[_0x5f5d[122]][t],n[_0x5f5d[165]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,n[_0x5f5d[155]],this[_0x5f5d[147]]),n[_0x5f5d[165]][_0x5f5d[20]][_0x5f5d[19]](.5,.5),n[_0x5f5d[165]][_0x5f5d[158]](2,2,_0x5f5d[157],2),n[_0x5f5d[166]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,n[_0x5f5d[144]],this[_0x5f5d[152]]),n[_0x5f5d[166]][_0x5f5d[20]][_0x5f5d[19]](.5,.5),n[_0x5f5d[166]][_0x5f5d[158]](2,2,_0x5f5d[157],2);this[_0x5f5d[167]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,_0x5f5d[168]+this[_0x5f5d[122]][_0x5f5d[145]],this[_0x5f5d[147]]);this[_0x5f5d[167]][_0x5f5d[20]][_0x5f5d[19]](.5,.5);this[_0x5f5d[169]](r,u)},resize:function(n,t){this[_0x5f5d[169]](n,t)},positionControls:function(n,t){var o,f,i;this[_0x5f5d[27]][_0x5f5d[82]]=t;this[_0x5f5d[27]][_0x5f5d[80]]=n;scaleManager[_0x5f5d[103]](this[_0x5f5d[83]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[83]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[83]][_0x5f5d[105]]=t*.1;scaleManager[_0x5f5d[170]](this[_0x5f5d[155]],n*.9,t*.1,Math[_0x5f5d[102]](n*.9,t*.1)*.1,1,!1);this[_0x5f5d[155]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[155]][_0x5f5d[105]]=t*.25;o=scaleManager[_0x5f5d[103]](this[_0x5f5d[159]],n,t*.4,Math[_0x5f5d[102]](n,t*.4)*.1,1);this[_0x5f5d[159]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[159]][_0x5f5d[105]]=t*.5;isEmbed?(scaleManager[_0x5f5d[103]](this[_0x5f5d[161]],n*.3,t*.1,Math[_0x5f5d[102]](n*.3,t*.1)*.1,1),this[_0x5f5d[161]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]-this[_0x5f5d[161]][_0x5f5d[80]],this[_0x5f5d[161]][_0x5f5d[105]]=t*.9,scaleManager[_0x5f5d[103]](this[_0x5f5d[163]],n*.3,t*.1,Math[_0x5f5d[102]](n*.3,t*.1)*.1,1),this[_0x5f5d[163]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]+this[_0x5f5d[163]][_0x5f5d[80]],this[_0x5f5d[163]][_0x5f5d[105]]=t*.9):(scaleManager[_0x5f5d[103]](this[_0x5f5d[161]],n,t*.1,Math[_0x5f5d[102]](n,t*.1)*.1,1),this[_0x5f5d[161]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[161]][_0x5f5d[105]]=t*.9);scaleManager[_0x5f5d[170]](this[_0x5f5d[167]],n*.9,t*.1,Math[_0x5f5d[102]](n*.9,t*.1)*.1,1,!1);this[_0x5f5d[167]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[167]][_0x5f5d[105]]=t*.75;var r=300*o,u=200*o,s=this[_0x5f5d[122]][_0x5f5d[119]],e=1/s,h={2:[-.25,.25],3:[-.33,0,.33],4:[-.375,-.125,.125,.375]}[s];for(f=0;f<s;f++)i=this[_0x5f5d[122]][f],scaleManager[_0x5f5d[170]](i[_0x5f5d[165]],r/2,u*e,Math[_0x5f5d[102]](r/2,u*e)*.1,1,!1),i[_0x5f5d[165]][_0x5f5d[104]]=this[_0x5f5d[159]][_0x5f5d[104]]-r*.25,i[_0x5f5d[165]][_0x5f5d[105]]=this[_0x5f5d[159]][_0x5f5d[105]]+u*h[f],scaleManager[_0x5f5d[170]](i[_0x5f5d[166]],r/2,u*e,Math[_0x5f5d[102]](r/2,u*e)*.1,1,!1),i[_0x5f5d[166]][_0x5f5d[104]]=this[_0x5f5d[159]][_0x5f5d[104]]+r*.25,i[_0x5f5d[166]][_0x5f5d[105]]=this[_0x5f5d[159]][_0x5f5d[105]]+u*h[f]},home:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),isEmbed?initGameState():goToHome())},more:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,goToHome(),n[_0x5f5d[100]]=!1)}},SolitaireGameOver={init:function(n){n?this[_0x5f5d[171]]=n:(this[_0x5f5d[171]]=[[_0x5f5d[172],_0x5f5d[173]],[_0x5f5d[174],104]],this[_0x5f5d[171]][_0x5f5d[144]]=105,this[_0x5f5d[171]][_0x5f5d[175]]=5)},create:function(){var u=this[_0x5f5d[81]][_0x5f5d[80]],f=this[_0x5f5d[81]][_0x5f5d[82]],i,r,t,n;if(this[_0x5f5d[27]]=this[_0x5f5d[18]][_0x5f5d[9]](0,0,_0x5f5d[27]),this[_0x5f5d[147]]={font:_0x5f5d[148],fill:_0x5f5d[149],boundsAlignH:_0x5f5d[150],boundsAlignV:_0x5f5d[151],align:_0x5f5d[150]},this[_0x5f5d[152]]={font:_0x5f5d[148],fill:_0x5f5d[153],boundsAlignH:_0x5f5d[150],boundsAlignV:_0x5f5d[151],align:_0x5f5d[150]},this[_0x5f5d[83]]=mygame[_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],_0x5f5d[154]),this[_0x5f5d[83]][_0x5f5d[20]][_0x5f5d[19]](.5),this[_0x5f5d[155]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,getGameName(dominoGameType),this[_0x5f5d[147]]),this[_0x5f5d[155]][_0x5f5d[20]][_0x5f5d[19]](.5,.5),this[_0x5f5d[155]][_0x5f5d[158]](2,2,_0x5f5d[157],2),i=_0x5f5d[176],r=_0x5f5d[66],this[_0x5f5d[171]][_0x5f5d[119]]>0)for(t=0;t<this[_0x5f5d[171]][_0x5f5d[119]];t++)n=this[_0x5f5d[171]][t],n[0]===_0x5f5d[177]?i=n[1]:r+=n[0]+_0x5f5d[178]+n[1]+_0x5f5d[179];this[_0x5f5d[159]]=mygame[_0x5f5d[18]][_0x5f5d[9]](-900,-900,_0x5f5d[29],i);this[_0x5f5d[159]][_0x5f5d[20]][_0x5f5d[19]](.5,.5);this[_0x5f5d[161]]=mygame[_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[162]],this);this[_0x5f5d[161]][_0x5f5d[97]]=13;this[_0x5f5d[161]][_0x5f5d[20]][_0x5f5d[19]](.5);isEmbed&&(this[_0x5f5d[163]]=mygame[_0x5f5d[18]][_0x5f5d[87]](-900,-900,_0x5f5d[25],this[_0x5f5d[164]],this),this[_0x5f5d[163]][_0x5f5d[97]]=14,this[_0x5f5d[163]][_0x5f5d[20]][_0x5f5d[19]](.5));this[_0x5f5d[167]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,r,this[_0x5f5d[147]]);this[_0x5f5d[167]][_0x5f5d[20]][_0x5f5d[19]](.5,.5);this[_0x5f5d[169]](u,f)},resize:function(n,t){this[_0x5f5d[169]](n,t)},positionControls:function(n,t){this[_0x5f5d[27]][_0x5f5d[82]]=t;this[_0x5f5d[27]][_0x5f5d[80]]=n;scaleManager[_0x5f5d[103]](this[_0x5f5d[83]],n,t*.2,Math[_0x5f5d[102]](n,t*.2)*.1,1);this[_0x5f5d[83]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[83]][_0x5f5d[105]]=t*.1;scaleManager[_0x5f5d[170]](this[_0x5f5d[155]],n*.9,t*.1,Math[_0x5f5d[102]](n*.9,t*.1)*.1,1,!1);this[_0x5f5d[155]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[155]][_0x5f5d[105]]=t*.25;var i=scaleManager[_0x5f5d[103]](this[_0x5f5d[159]],n,t*.3,Math[_0x5f5d[102]](n,t*.3)*.1,1);this[_0x5f5d[159]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[159]][_0x5f5d[105]]=t*.45;isEmbed?(scaleManager[_0x5f5d[103]](this[_0x5f5d[161]],n*.3,t*.1,Math[_0x5f5d[102]](n*.3,t*.1)*.1,1),this[_0x5f5d[161]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]-this[_0x5f5d[161]][_0x5f5d[80]],this[_0x5f5d[161]][_0x5f5d[105]]=t*.9,scaleManager[_0x5f5d[103]](this[_0x5f5d[163]],n*.3,t*.1,Math[_0x5f5d[102]](n*.3,t*.1)*.1,1),this[_0x5f5d[163]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]]+this[_0x5f5d[163]][_0x5f5d[80]],this[_0x5f5d[163]][_0x5f5d[105]]=t*.9):(scaleManager[_0x5f5d[103]](this[_0x5f5d[161]],n*.3,t*.1,Math[_0x5f5d[102]](n*.3,t*.1)*.1,1),this[_0x5f5d[161]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]],this[_0x5f5d[161]][_0x5f5d[105]]=t*.9);scaleManager[_0x5f5d[170]](this[_0x5f5d[167]],n*.9,t*.2,Math[_0x5f5d[102]](n*.9,t*.1)*.1,1,!1);this[_0x5f5d[167]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[167]][_0x5f5d[105]]=t*.7},home:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,audioManager[_0x5f5d[101]](_0x5f5d[33]),isEmbed?initGameState():goToHome())},more:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,goToHome(),n[_0x5f5d[100]]=!1)}},PlayAd={init:function(){},create:function(){var n=this[_0x5f5d[81]][_0x5f5d[80]],t=this[_0x5f5d[81]][_0x5f5d[82]];this[_0x5f5d[147]]={font:_0x5f5d[148],fill:_0x5f5d[149],boundsAlignH:_0x5f5d[150],boundsAlignV:_0x5f5d[151],align:_0x5f5d[150]};this[_0x5f5d[135]]=mygame[_0x5f5d[18]][_0x5f5d[87]](-200,-200,_0x5f5d[58],this[_0x5f5d[180]],this);this[_0x5f5d[135]][_0x5f5d[20]][_0x5f5d[19]](.5,.5);this[_0x5f5d[181]]=mygame[_0x5f5d[18]][_0x5f5d[156]](-900,-900,getGameName(dominoGameType),this[_0x5f5d[147]]);this[_0x5f5d[181]][_0x5f5d[20]][_0x5f5d[19]](.5,.5);this[_0x5f5d[169]](n,t)},resize:function(n,t){this[_0x5f5d[169]](n,t)},positionControls:function(n,t){scaleManager[_0x5f5d[103]](this[_0x5f5d[135]],n*.9,t*.8,0,1);this[_0x5f5d[135]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[135]][_0x5f5d[105]]=t*.4;scaleManager[_0x5f5d[170]](this[_0x5f5d[181]],n*.9,t*.2,Math[_0x5f5d[102]](n*.9,t*.2)*.1,1,!1);this[_0x5f5d[181]][_0x5f5d[104]]=this[_0x5f5d[15]][_0x5f5d[14]];this[_0x5f5d[181]][_0x5f5d[105]]=t*.9},playAd:function(n){n[_0x5f5d[100]]||(n[_0x5f5d[100]]=!0,loadVliPreRoll(),n[_0x5f5d[100]]=!1)}}