/* Phaser v2.16.1 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */

(function(){var t=this,e=e||{VERSION:"2.16.1",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};if("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(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=function(){var t=Array.prototype.slice;return function(e){function i(){var o=n.concat(t.call(arguments));s.apply(this instanceof i?this:e,o)}var s=this,n=t.call(arguments,1);if("function"!=typeof s)throw new TypeError;return i.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(s.prototype),i}}()),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=arguments.length>=2?arguments[1]:void 0,n=0;n<i;n++)n in e&&t.call(s,e[n],n,e)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(e=0;e<this.length;e++)this[e]=0}else{Array.call(this,t.length),this.length=t.length;for(var e=0;e<this.length;e++)this[e]=t[e]}},window[t].prototype=e,window[t].constructor=window[t]};i("Float32Array"),i("Uint32Array"),i("Uint16Array"),i("Int16Array"),i("ArrayBuffer")}window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),Object.assign||(Object.assign=function(t,e){"use strict";if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),s=Object.prototype.hasOwnProperty,n=1;n<arguments.length;n++){var o=arguments[n];if(null!=o)for(var r in o)s.call(o,r)&&(i[r]=o[r])}return i}),e.Utils={defaults:function(t,e){for(var i=Object.keys(e),s=0,n=i.length;s<n;s++){var o=i[s];void 0===t[o]&&(t[o]=e[o])}return t},reverseString:function(t){return t.split("").reverse().join("")},getProperty:function(t,e){var i=e.split(".");switch(i.length){case 1:return t[e];case 2:return t[i[0]][i[1]];case 3:return t[i[0]][i[1]][i[2]];case 4:return t[i[0]][i[1]][i[2]][i[3]];default:return this._getProperty(t,e)}},setProperties:function(t,e){for(var i in e)this.setProperty(t,i,e[i]);return t},setProperty:function(t,e,i){var s=e.split(".");switch(s.length){case 1:t[e]=i;break;case 2:t[s[0]][s[1]]=i;break;case 3:t[s[0]][s[1]][s[2]]=i;break;case 4:t[s[0]][s[1]][s[2]][s[3]]=i;break;default:this._setProperty(t,e,i)}},_getProperty:function(t,e){for(var i=e.split("."),s=i.length,n=0,o=t;n<s;){var r=i[n];if(null==o)return;o=o[r],n++}return o},_setProperty:function(t,e,i){var s=e.split("."),n=s.length,o=0,r=t,a=s[0];if(1===n)t[e]=i;else{for(;o<n-1;)r=r[a],a=s[++o];r[a]=i}return t},chanceRoll:function(t){return void 0===t&&(t=50),t>0&&100*Math.random()<=t},randomChoice:function(t,e){return Math.random()<.5?t:e},parseDimension:function(t,e){var i=0,s=0;return"string"==typeof t?"%"===t.substr(-1)?(i=parseInt(t,10)/100,s=0===e?window.innerWidth*i:window.innerHeight*i):s=parseInt(t,10):s=t,s},pad:function(t,e,i,s){if(void 0===e)var e=0;if(void 0===i)var i=" ";if(void 0===s)var s=3;var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var o=Math.ceil((n=e-t.length)/2),r=n-o;t=new Array(r+1).join(i)+t+new Array(o+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,i,s,n,o,r,a=arguments[0]||{},h=1,l=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},h=2),l===h&&(a=this,--h);h<l;h++)if(null!=(t=arguments[h]))for(i in t)s=a[i],a!==(n=t[i])&&(c&&n&&(e.Utils.isPlainObject(n)||(o=Array.isArray(n)))?(o?(o=!1,r=s&&Array.isArray(s)?s:[]):r=s&&e.Utils.isPlainObject(s)?s:{},a[i]=e.Utils.extend(c,r,n)):void 0!==n&&(a[i]=n));return a},mixinPrototype:function(t,e,i){void 0===i&&(i=!1);for(var s=Object.keys(e),n=0;n<s.length;n++){var o=s[n],r=e[o];!i&&o in t||(!r||"function"!=typeof r.get&&"function"!=typeof r.set?t[o]=r:"function"==typeof r.clone?t[o]=r.clone():Object.defineProperty(t,o,r))}},mixin:function(t,i){if(!t||"object"!=typeof t)return i;for(var s in t){var n=t[s];if(!n.childNodes&&!n.cloneNode){var o=typeof t[s];t[s]&&"object"===o?typeof i[s]===o?i[s]=e.Utils.mixin(t[s],i[s]):i[s]=e.Utils.mixin(t[s],new n.constructor):i[s]=t[s]}}return i}},e.Circle=function(t,i,s){t=t||0,i=i||0,s=s||0,this.x=t,this.y=i,this._diameter=s,this._radius=0,s>0&&(this._radius=.5*s),this.type=e.CIRCLE},e.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new e.Point);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),n=s>1?2-s:s,o=n*Math.cos(i),r=n*Math.sin(i);return t.x=this.x+o*this.radius,t.y=this.y+r*this.radius,t},getBounds:function(){return new e.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,i){var s=e.Math.distance(this.x,this.y,t.x,t.y);return i?Math.round(s):s},clone:function(t){return void 0===t||null===t?t=new e.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,i){return e.Circle.contains(this,t,i)},circumferencePoint:function(t,i,s){return e.Circle.circumferencePoint(this,t,i,s)},sample:function(t,i,s,n,o){t||(t=60),null==i&&(i=0),null==s&&(s=e.Math.PI2),o||(o=[]);for(var r=0;r<t;)this.circumferencePoint(e.Math.linear(i,s,r/t),n,o[r]||(o[r]=new e.Point)),r+=1;return o},offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},e.Circle.prototype.constructor=e.Circle,Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(t){t>0&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){t>0&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}}),Object.defineProperty(e.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}}),Object.defineProperty(e.Circle.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),e.Circle.contains=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},e.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},e.Circle.intersects=function(t,i){return e.Math.distance(t.x,t.y,i.x,i.y)<=t.radius+i.radius},e.Circle.circumferencePoint=function(t,i,s,n){return void 0===s&&(s=!1),void 0===n&&(n=new e.Point),!0===s&&(i=e.Math.degToRad(i)),n.x=t.x+t.radius*Math.cos(i),n.y=t.y+t.radius*Math.sin(i),n},e.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(i>e.halfWidth+t.radius)return!1;var s=Math.abs(t.y-e.y-e.halfHeight);if(s>e.halfHeight+t.radius)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;var n=i-e.halfWidth,o=s-e.halfHeight;return n*n+o*o<=t.radius*t.radius},e.Circle.intersectsLine=function(t,i,s){var n=t.x,o=t.y,r=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-r*i.end.x,h=t.radius,l=t.radius,c=a+r*n,u=(n*(l*l)-r*(h*h)*(a-o)+h*l*Math.sqrt(h*h*(r*r)+l*l-c*c-o*o+2*c*o))/(h*h*(r*r)+l*l),d=(n*(l*l)-r*(h*h)*(a-o)-h*l*Math.sqrt(h*h*(r*r)+l*l-c*c-o*o+2*c*o))/(h*h*(r*r)+l*l),p=r*u+a,f=r*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Circle=e.Circle,e.Ellipse=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.ELLIPSE},e.Ellipse.prototype={setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},getBounds:function(){return new e.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},clone:function(t){return void 0===t||null===t?t=new e.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 e.Ellipse.contains(this,t,i)},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return t.x=this.centerX+.5*s*Math.cos(i)*this.width,t.y=this.centerY+.5*s*Math.sin(i)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},e.Ellipse.prototype.constructor=e.Ellipse,Object.defineProperty(e.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(e.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Ellipse.prototype,"top",{get:function(){return this.y},set:function(t){this.y=t}}),Object.defineProperty(e.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Ellipse.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Ellipse.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),Object.defineProperty(e.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Ellipse.contains=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return s*=s,n*=n,s+n<.25},e.Ellipse.intersectsLine=function(t,i,s){var n=t.x,o=t.y,r=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-r*i.end.x,h=t.width/2,l=t.height/2,c=a+r*n,u=(n*(l*l)-r*(h*h)*(a-o)+h*l*Math.sqrt(h*h*(r*r)+l*l-c*c-o*o+2*c*o))/(h*h*(r*r)+l*l),d=(n*(l*l)-r*(h*h)*(a-o)-h*l*Math.sqrt(h*h*(r*r)+l*l-c*c-o*o+2*c*o))/(h*h*(r*r)+l*l),p=r*u+a,f=r*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Ellipse=e.Ellipse,e.Line=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.start=new e.Point(t,i),this.end=new e.Point(s,n),this.type=e.LINE},e.Line.prototype={setTo:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this},fromPoints:function(t,e){return this.setTo(t.x,t.y,e.x,e.y),this},fromSprite:function(t,e,i){return void 0===i&&(i=!1),i?this.setTo(t.centerX,t.centerY,e.centerX,e.centerY):this.fromPoints(t,e)},fromAngle:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this},rotate:function(t,e){var i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this},rotateAround:function(t,e,i,s){return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this},intersects:function(t,i,s){return e.Line.intersectsPoints(this.start,this.end,t.start,t.end,i,s)},reflect:function(t){return e.Line.reflect(this,t)},midPoint:function(t){return void 0===t&&(t=new e.Point),t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t},centerOn:function(t,e){var i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)},pointOnLine:function(t,i,s){return e.Math.fuzzyEqual((t-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(i-this.start.y),s||0)},pointOnSegment:function(t,e,i){var s=Math.min(this.start.x,this.end.x),n=Math.max(this.start.x,this.end.x),o=Math.min(this.start.y,this.end.y),r=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e,i)&&t>=s&&t<=n&&e>=o&&e<=r},random:function(t){void 0===t&&(t=new e.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(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),o=Math.round(this.end.y),r=Math.abs(n-i),a=Math.abs(o-s),h=i<n?1:-1,l=s<o?1:-1,c=r-a;e.push([i,s]);for(var u=1;i!==n||s!==o;){var d=c<<1;d>-a&&(c-=a,i+=h),d<r&&(c+=r,s+=l),u%t==0&&e.push([i,s]),u++}return e},clone:function(t){return void 0===t||null===t?t=new e.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(e.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(e.Line.prototype,"angle",{get:function(){return e.Point.angle(this.end,this.start)}}),Object.defineProperty(e.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(e.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}}),Object.defineProperty(e.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(e.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(e.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalAngle",{get:function(){return e.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),e.Line.intersectsPoints=function(t,i,s,n,o,r){void 0===o&&(o=!0),void 0===r&&(r=new e.Point);var a=i.y-t.y,h=n.y-s.y,l=t.x-i.x,c=s.x-n.x,u=i.x*t.y-t.x*i.y,d=n.x*s.y-s.x*n.y,p=a*c-h*l;if(0===p)return null;if(r.x=(l*d-c*u)/p,r.y=(h*u-a*d)/p,o){var f=(n.y-s.y)*(i.x-t.x)-(n.x-s.x)*(i.y-t.y),g=((n.x-s.x)*(t.y-s.y)-(n.y-s.y)*(t.x-s.x))/f,m=((i.x-t.x)*(t.y-s.y)-(i.y-t.y)*(t.x-s.x))/f;return g>=0&&g<=1&&m>=0&&m<=1?r:null}return r},e.Line.intersects=function(t,i,s,n){return e.Line.intersectsPoints(t.start,t.end,i.start,i.end,s,n)},e.Line.intersectsRectangle=function(t,e){if(0===t.length||e.empty)return!1;var i=t.start.x,s=t.start.y,n=t.end.x,o=t.end.y,r=e.x,a=e.y,h=e.right,l=e.bottom,c=0;if(i>=r&&i<=h&&s>=a&&s<=l||n>=r&&n<=h&&o>=a&&o<=l)return!0;if(i<r&&n>=r){if((c=s+(o-s)*(r-i)/(n-i))>a&&c<=l)return!0}else if(i>h&&n<=h&&(c=s+(o-s)*(h-i)/(n-i))>=a&&c<=l)return!0;if(s<a&&o>=a){if((c=i+(n-i)*(a-s)/(o-s))>=r&&c<=h)return!0}else if(s>l&&o<=l&&(c=i+(n-i)*(l-s)/(o-s))>=r&&c<=h)return!0;return!1},e.Line.intersectionWithRectangle=function(t,i,s){var n=e.Line.intersectionWithRectangle;s||(s=new e.Point),n.edges||(n.edges=[new e.Line,new e.Line,new e.Line,new e.Line]),n.edgeIntersection||(n.edgeIntersection=new e.Point);var o=n.edges,r=n.edgeIntersection.set(0),a=i.x,h=i.y,l=i.right,c=i.bottom,u=1/0;o[0].setTo(a,h,l,h),o[1].setTo(a,c,l,c),o[2].setTo(a,h,a,c),o[3].setTo(l,h,l,c);for(var d,p=0;d=o[p];p++)if(t.intersects(d,!0,r)){var f=t.start.distance(r);f<u&&(u=f,s.copyFrom(r))}return null!=f?s:null},e.Line.reflect=function(t,e){return 2*e.normalAngle-3.141592653589793-t.angle},e.Matrix=function(t,i,s,n,o,r){void 0!==t&&null!==t||(t=1),void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),void 0!==n&&null!==n||(n=1),void 0!==o&&null!==o||(o=0),void 0!==r&&null!==r||(r=0),this.a=t,this.b=i,this.c=s,this.d=n,this.tx=o,this.ty=r,this.type=e.MATRIX},e.Matrix.prototype={fromArray:function(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])},setTo:function(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this},clone:function(t){return void 0===t||null===t?t=new e.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(t){return t.copyFrom(this),t},copyFrom:function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},toArray:function(t,e){return void 0===e&&(e=new Float32Array(9)),t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},apply:function(t,i){return void 0===i&&(i=new e.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 e.Point);var s=1/(this.a*this.d+this.c*-this.b),n=t.x,o=t.y;return i.x=this.d*s*n+-this.c*s*o+(this.ty*this.c-this.tx*this.d)*s,i.y=this.a*s*o+-this.b*s*n+(-this.ty*this.a+this.tx*this.b)*s,i},translate:function(t,e){return this.tx+=t,this.ty+=e,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this},append:function(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},e.identityMatrix=new e.Matrix,e.Point=function(t,i){t=t||0,i=i||0,this.x=t,this.y=i,this.type=e.POINT},e.Point.prototype={copyFrom:function(t){return this.setTo(t.x,t.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,i){return e.Point.set(this,t,i)},set:function(t,i){return e.Point.set(this,t,i)},setToPolar:function(t,i,s){return null==i&&(i=1),s&&(t=e.Math.degToRad(t)),this.setTo(Math.cos(t)*i,Math.sin(t)*i)},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},multiply:function(t,e){return this.x*=t,this.y*=e,this},divide:function(t,e){return this.x/=t,this.y/=e,this},clampX:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this},clampY:function(t,i){return this.y=e.Math.clamp(this.y,t,i),this},clamp:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this.y=e.Math.clamp(this.y,t,i),this},clip:function(t){var e=t.left,i=t.top,s=t.right,n=t.bottom;return this.x<e?this.x=e:this.x>s&&(this.x=s),this.y<i?this.y=i:this.y>n&&(this.y=n),this},clone:function(t){return void 0===t||null===t?t=new e.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,i){return e.Point.distance(this,t,i)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,i){return e.Point.fuzzyEquals(this,t,i)},fuzzyEqualsXY:function(t,i,s){return e.Point.fuzzyEqualsXY(this,t,i,s)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,i,s){var n=Math.atan2(i-this.y,t-this.x);return s?e.Math.radToDeg(n):n},atan:function(t){var i=Math.atan2(this.y,this.x);return t?e.Math.radToDeg(i):i},rotate:function(t,i,s,n,o){return e.Point.rotate(this,t,i,s,n,o)},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(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()<t*t&&this.setMagnitude(t),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.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+")}]"}},e.Point.prototype.constructor=e.Point,e.Point.add=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x+i.x,s.y=t.y+i.y,s},e.Point.subtract=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x-i.x,s.y=t.y-i.y,s},e.Point.multiply=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x*i.x,s.y=t.y*i.y,s},e.Point.divide=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x/i.x,s.y=t.y/i.y,s},e.Point.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.Point.equalsXY=function(t,e,i){return t.x===e&&t.y===i},e.Point.fuzzyEquals=function(t,i,s){return e.Math.fuzzyEqual(t.x,i.x,s)&&e.Math.fuzzyEqual(t.y,i.y,s)},e.Point.fuzzyEqualsXY=function(t,i,s,n){return e.Math.fuzzyEqual(t.x,i,n)&&e.Math.fuzzyEqual(t.y,s,n)},e.Point.angle=function(t,e){return Math.atan2(t.y-e.y,t.x-e.x)},e.Point.negative=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.x,-t.y)},e.Point.multiplyAdd=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+i.x*s,t.y+i.y*s)},e.Point.interpolate=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+(i.x-t.x)*s,t.y+(i.y-t.y)*s)},e.Point.perp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.y,t.x)},e.Point.rperp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(t.y,-t.x)},e.Point.distance=function(t,i,s){var n=e.Math.distance(t.x,t.y,i.x,i.y);return s?Math.round(n):n},e.Point.project=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i)/i.getMagnitudeSq();return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.projectUnit=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i);return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.normalRightHand=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-1*t.y,t.x)},e.Point.normalize=function(t,i){void 0===i&&(i=new e.Point);var s=t.getMagnitude();return 0!==s&&i.setTo(t.x/s,t.y/s),i},e.Point.rotate=function(t,i,s,n,o,r){if(o&&(n=e.Math.degToRad(n)),void 0===r){t.subtract(i,s);var a=Math.sin(n),h=Math.cos(n),l=h*t.x-a*t.y,c=a*t.x+h*t.y;t.x=l+i,t.y=c+s}else{var u=n+Math.atan2(t.y-s,t.x-i);t.x=i+r*Math.cos(u),t.y=s+r*Math.sin(u)}return t},e.Point.centroid=function(t,i){if(void 0===i&&(i=new e.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");var s=t.length;if(s<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===s)return i.copyFrom(t[0]),i;for(var n=0;n<s;n++)e.Point.add(i,t[n],i);return i.divide(s,s),i},e.Point.parse=function(t,i,s){i=i||"x",s=s||"y";var n=new e.Point;return t[i]&&(n.x=parseFloat(t[i])),t[s]&&(n.y=parseFloat(t[s])),n},e.Point.trunc=function(t){return t.x=e.Math.trunc(t.x),t.y=e.Math.trunc(t.y),t},e.Point.isPoint=function(t){return null!=t&&"number"==typeof t.x&&"number"==typeof t.y},e.Point.set=function(t,e,i){return t.x=e||0,t.y=i||(0!==i?t.x:0),t},e.Point.sortClockwise=function(t,e){e||(e=this.centroid(t));var i=e.x,s=e.y;return t.sort(function(t,e){if(t.x-i>=0&&e.x-i<0)return-1;if(t.x-i<0&&e.x-i>=0)return 1;if(t.x-i==0&&e.x-i==0)return t.y-s>=0||e.y-s>=0?t.y>e.y?1:-1:e.y>t.y?1:-1;var n=(t.x-i)*-(e.y-s)-(e.x-i)*-(t.y-s);return n<0?-1:n>0?1:(t.x-i)*(t.x-i)+(t.y-s)*(t.y-s)>(e.x-i)*(e.x-i)+(e.y-s)*(e.y-s)?-1:1})},PIXI.Point=e.Point,e.Polygon=function(){this.area=0,this._points=[],arguments.length>0&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=e.POLYGON},e.Polygon.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e<this._points.length;e++)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e++):(t.push(this._points[e].x),t.push(this._points[e].y));return t},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 e.Polygon(i):t.setTo(i),t},contains:function(t,e){var i=!1;if(this.flattened)for(var s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){var o=this._points[s],r=this._points[s+1],a=this._points[n],h=this._points[n+1];(r<=e&&e<h||h<=e&&e<r)&&t<(a-o)*(e-r)/(h-r)+o&&(i=!i)}else for(var s=-1,n=this._points.length-1;++s<this._points.length;n=s){var o=this._points[s].x,r=this._points[s].y,a=this._points[n].x,h=this._points[n].y;(r<=e&&e<h||h<=e&&e<r)&&t<(a-o)*(e-r)/(h-r)+o&&(i=!i)}return i},setTo:function(t){if(this.area=0,this._points=[],arguments.length>0){Array.isArray(t)||(t=Array.prototype.slice.call(arguments));for(var e=Number.MAX_VALUE,i=0,s=t.length;i<s;i++){if("number"==typeof t[i]){n=new PIXI.Point(t[i],t[i+1]);i++}else if(Array.isArray(t[i]))n=new PIXI.Point(t[i][0],t[i][1]);else var n=new PIXI.Point(t[i].x,t[i].y);this._points.push(n),n.y<e&&(e=n.y)}this.calculateArea(e)}return this},calculateArea:function(t){for(var e,i,s,n,o=0,r=this._points.length;o<r;o++)e=this._points[o],i=o===r-1?this._points[0]:this._points[o+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}},e.Polygon.prototype.constructor=e.Polygon,Object.defineProperty(e.Polygon.prototype,"points",{get:function(){return this._points}}),PIXI.Polygon=e.Polygon,e.Rectangle=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.RECTANGLE},e.Rectangle.prototype={offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},scale:function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},centerOn:function(t,e){return this.centerX=t,this.centerY=e,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(t){return this.setTo(t.x,t.y,t.width,t.height)},copyFromBounds:function(t){return this.setTo(t.left,t.top,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},inflate:function(t,i){return e.Rectangle.inflate(this,t,i)},size:function(t){return e.Rectangle.size(this,t)},resize:function(t,e){return this.width=t,this.height=e,this},clone:function(t){return e.Rectangle.clone(this,t)},contains:function(t,i){return e.Rectangle.contains(this,t,i)},containsRect:function(t){return e.Rectangle.containsRect(t,this)},equals:function(t){return e.Rectangle.equals(this,t)},intersection:function(t,i){return e.Rectangle.intersection(this,t,i)},intersects:function(t){return e.Rectangle.intersects(this,t)},intersectsRaw:function(t,i,s,n,o){return e.Rectangle.intersectsRaw(this,t,i,s,n,o)},union:function(t,i){return e.Rectangle.union(this,t,i)},random:function(t){return void 0===t&&(t=new e.Point),t.x=this.randomX,t.y=this.randomY,t},getPoint:function(t,i){switch(void 0===i&&(i=new e.Point),t){default:case e.TOP_LEFT:return i.set(this.x,this.y);case e.TOP_CENTER:return i.set(this.centerX,this.y);case e.TOP_RIGHT:return i.set(this.right,this.y);case e.LEFT_CENTER:return i.set(this.x,this.centerY);case e.CENTER:return i.set(this.centerX,this.centerY);case e.RIGHT_CENTER:return i.set(this.right,this.centerY);case e.BOTTOM_LEFT:return i.set(this.x,this.bottom);case e.BOTTOM_CENTER:return i.set(this.centerX,this.bottom);case e.BOTTOM_RIGHT:return i.set(this.right,this.bottom)}},sides:function(t,i,s,n){arguments.length||(t=new e.Line,i=new e.Line,s=new e.Line,n=new e.Line);var o=this.x,r=this.y,a=this.right,h=this.bottom;return t.setTo(o,r,a,r),i.setTo(a,r,a,h),s.setTo(o,h,a,h),n.setTo(o,r,o,h),arguments.length?null:[t,i,s,n]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomLeft",{get:function(){return new e.Point(this.x,this.bottom)},set:function(t){this.x=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(t){this.right=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(e.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"topRight",{get:function(){return new e.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Rectangle.prototype.constructor=e.Rectangle,e.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},e.Rectangle.inflatePoint=function(t,i){return e.Rectangle.inflate(t,i.x,i.y)},e.Rectangle.size=function(t,i){return void 0===i||null===i?i=new e.Point(t.width,t.height):i.setTo(t.width,t.height),i},e.Rectangle.clone=function(t,i){return void 0===i||null===i?i=new e.Rectangle(t.x,t.y,t.width,t.height):i.setTo(t.x,t.y,t.width,t.height),i},e.Rectangle.createFromBounds=function(t,i){return void 0!==i&&null!==i||(i=new e.Rectangle(t.x,t.y,t.width,t.height)),i.copyFromBounds(t)},e.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom)},e.Rectangle.containsRaw=function(t,e,i,s,n,o){return n>=t&&n<t+i&&o>=e&&o<e+s},e.Rectangle.containsPoint=function(t,i){return e.Rectangle.contains(t,i.x,i.y)},e.Rectangle.containsRect=function(t,e){return!(t.volume>e.volume)&&(t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom)},e.Rectangle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},e.Rectangle.sameDimensions=function(t,e){return t.width===e.width&&t.height===e.height},e.Rectangle.intersection=function(t,i,s){return void 0===s&&(s=new e.Rectangle),e.Rectangle.intersects(t,i)&&(s.x=Math.max(t.x,i.x),s.y=Math.max(t.y,i.y),s.width=Math.min(t.right,i.right)-s.x,s.height=Math.min(t.bottom,i.bottom)-s.y),s},e.Rectangle.intersects=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)},e.Rectangle.intersectsRaw=function(t,e,i,s,n,o){return void 0===o&&(o=0),!(e>t.right+o||i<t.left-o||s>t.bottom+o||n<t.top-o)},e.Rectangle.union=function(t,i,s){return void 0===s&&(s=new e.Rectangle),s.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))},e.Rectangle.aabb=function(t,i){void 0===i&&(i=new e.Rectangle);var s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return t.forEach(function(t){t.x>s&&(s=t.x),t.x<n&&(n=t.x),t.y>o&&(o=t.y),t.y<r&&(r=t.y)}),i.setTo(n,r,s-n,o-r),i},PIXI.Rectangle=e.Rectangle,e.EmptyRectangle=new e.Rectangle(0,0,0,0),e.RoundedRectangle=function(t,i,s,n,o){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===o&&(o=20),this.x=t,this.y=i,this.width=s,this.height=n,this.radius=o||20,this.type=e.ROUNDEDRECTANGLE},e.RoundedRectangle.prototype={clone:function(){return new e.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var s=this.y;if(e>=s&&e<=s+this.height)return!0}return!1}},e.RoundedRectangle.prototype.constructor=e.RoundedRectangle,PIXI.RoundedRectangle=e.RoundedRectangle,e.Camera=function(t,i,s,n,o,r){this.game=t,this.world=t.world,this.id=0,this.view=new e.Rectangle(s,n,o,r),this.bounds=new e.Rectangle(s,n,o,r),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 e.Point(1,1),this.onShakeComplete=new e.Signal,this.onFlashComplete=new e.Signal,this.onFadeComplete=new e.Signal,this.fx=null,this._targetPosition=new e.Point,this._edge=0,this._position=new e.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 e.Rectangle},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.SHAKE_BOTH=4,e.Camera.SHAKE_HORIZONTAL=5,e.Camera.SHAKE_VERTICAL=6,e.Camera.ENABLE_FX=!0,e.Camera.FLASH=0,e.Camera.FADE_OUT=1,e.Camera.FADE_IN=2,e.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,e.Graphics&&e.Camera.ENABLE_FX&&(this.fx=new e.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,i,s,n){void 0===i&&(i=e.Camera.FOLLOW_LOCKON),void 0===s&&(s=1),void 0===n&&(n=1),this.target=t,this.lerp.set(s,n);var o;switch(i){case e.Camera.FOLLOW_PLATFORMER:var r=this.width/8,a=this.height/3;this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-a)/2-.25*a,r,a);break;case e.Camera.FOLLOW_TOPDOWN:o=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-o)/2,(this.height-o)/2,o,o);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:o=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-o)/2,(this.height-o)/2,o,o);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,i,s,n,o){return void 0===t&&(t=.05),void 0===i&&(i=500),void 0===s&&(s=!0),void 0===n&&(n=e.Camera.SHAKE_BOTH),void 0===o&&(o=!0),!(!s&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=i,this._shake.shakeBounds=o,this._shake.x=0,this._shake.y=0,this._shake.horizontal=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_HORIZONTAL,this._shake.vertical=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_VERTICAL,!0)},flash:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=e,this._fxType=0,!0)},fade:function(t,i,s,n){return this.fadeEffect(t,i,s,n,e.Camera.FADE_OUT)},fadeIn:function(t,i,s,n){return this.fadeEffect(t,i,s,n,e.Camera.FADE_IN)},fadeEffect:function(t,i,s,n,o){if(void 0===t&&(t=0),void 0===i&&(i=500),void 0===s&&(s=!1),void 0===n&&(n=1),!this.fx||!s&&this._fxDuration>0)return!1;if(this.fx.clear(),this.fx.beginFill(t,n),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),o<1||o>2)throw new Error("Wrong `type` argument");return this.fx.alpha=o===e.Camera.FADE_IN?1:0,this._fxDuration=i,this._fxType=o,!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(){this._fxType===e.Camera.FLASH?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):this._fxType===e.Camera.FADE_IN?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFadeComplete.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 t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=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)):e>=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)):s>=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(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},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}},e.Camera.prototype.constructor=e.Camera,Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(e.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(e.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(e.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),e.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},e.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(){}},e.State.prototype.constructor=e.State,e.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 e.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},e.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,s){void 0===s&&(s=!1);var n;return i instanceof e.State?n=i:"object"==typeof i?(n=i).game=this.game:"function"==typeof i&&(n=new i(this.game)),this.states[t]=n,s&&(this.game.isBooted?this.start(t):this._pendingState=t),n},remove:function(t){this.current===t&&(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[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1),this._pendingState=this.current,this._clearWorld=t,this._clearCache=e,arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){if(this.clearCurrentState(),this.setCurrentState(this._pendingState),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(t){var e=this.states[t];return e?!!(e.preload||e.create||e.update||e.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: "+t),!1)},link:function(t){var e=this.states[t];e.game=this.game,e.add=this.game.add,e.make=this.game.make,e.camera=this.game.camera,e.cache=this.game.cache,e.input=this.game.input,e.load=this.game.load,e.math=this.game.math,e.sound=this.game.sound,e.scale=this.game.scale,e.state=this,e.stage=this.game.stage,e.time=this.game.time,e.tweens=this.game.tweens,e.world=this.game.world,e.particles=this.game.particles,e.rnd=this.game.rnd,e.physics=this.game.physics,e.key=t},unlink:function(t){var e=this.states[t];e&&(e.game=null,e.add=null,e.make=null,e.camera=null,e.cache=null,e.input=null,e.load=null,e.math=null,e.sound=null,e.scale=null,e.state=null,e.stage=null,e.time=null,e.tweens=null,e.world=null,e.particles=null,e.rnd=null,e.physics=null)},setCurrentState:function(t){var e=this.current,i=this.states[t];this.callbackContext=i,this.link(t),this.onInitCallback=i.init||this.dummy,this.onPreloadCallback=i.preload||null,this.onLoadRenderCallback=i.loadRender||null,this.onLoadUpdateCallback=i.loadUpdate||null,this.onCreateCallback=i.create||null,this.onUpdateCallback=i.update||null,this.onPostUpdateCallback=i.postUpdate||null,this.onPreRenderCallback=i.preRender||null,this.onRenderCallback=i.render||null,this.onResizeCallback=i.resize||null,this.onPausedCallback=i.paused||null,this.onResumedCallback=i.resumed||null,this.onPauseUpdateCallback=i.pauseUpdate||null,this.onShutDownCallback=i.shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=t,this._created=!1,this.onStateChange.dispatch(this.current,e),this.onInitCallback.apply(this.callbackContext,this._args),t===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(t){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,t)},resize:function(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===e.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=""}},e.StateManager.prototype.constructor=e.StateManager,Object.defineProperty(e.StateManager.prototype,"created",{get:function(){return this._created}}),e.Signal=function(){},e.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(t,e){if("function"!=typeof t)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))},_registerListener:function(t,i,s,n,o){var r,a=this._indexOfListener(t,s);if(-1!==a){if((r=this._bindings[a]).isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else r=new e.SignalBinding(this,t,i,s,n,o),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r},_addBinding:function(t){this._bindings||(this._bindings=[]);var e=this._bindings.length;do{e--}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){if(!this._bindings)return-1;void 0===e&&(e=null);for(var i,s=this._bindings.length;s--;)if((i=this._bindings[s])._listener===t&&i.context===e)return s;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){this.validateListener(t,"add");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!1,e,i,s)},addOnce:function(t,e,i){this.validateListener(t,"addOnce");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!0,e,i,s)},remove:function(t,e){this.validateListener(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(t){if(void 0===t&&(t=null),this._bindings){for(var e=this._bindings.length;e--;)t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&(this._bindings||this.memorize)){var t=Array.prototype.slice.call(arguments);this.memorize&&(this._prevParams=t);var e=this._bindings?this._bindings.length:0;if(e){var i=this._bindings.slice();this._shouldPropagate=!0;do{e--}while(i[e]&&this._shouldPropagate&&!1!==i[e].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(e.Signal.prototype,"boundDispatch",{get:function(){var t=this;return this._boundDispatch||(this._boundDispatch=function(){return t.dispatch.apply(t,arguments)})}}),e.Signal.prototype.constructor=e.Signal,e.SignalBinding=function(t,e,i,s,n,o){this._listener=e,i&&(this._isOnce=!0),null!=s&&(this.context=s),this._signal=t,n&&(this._priority=n),o&&o.length&&(this._args=o)},e.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,this._args&&(i=i.concat(this._args)),e=this._listener.apply(this.context,i),this.callCount++,this._isOnce&&this.detach()),e},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+"]"}},e.SignalBinding.prototype.constructor=e.SignalBinding,e.Filter=function(t,i,s){this.game=t,this.type=e.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new e.Point;var n=new Date;if(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:[n.getFullYear(),n.getMonth(),n.getDate(),60*n.getHours()*60+60*n.getMinutes()+n.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(var o in i)this.uniforms[o]=i[o];"string"==typeof s&&(s=s.split("\n")),this.fragmentSrc=s||[]},e.Filter.prototype={init:function(){},setResolution:function(t,e){this.uniforms.resolution.value.x=t,this.uniforms.resolution.value.y=e},update:function(t){if(t){var e=t.x/this.game.width,i=1-t.y/this.game.height;e===this.prevPoint.x&&i===this.prevPoint.y||(this.uniforms.mouse.value.x=e.toFixed(2),this.uniforms.mouse.value.y=i.toFixed(2),this.prevPoint.set(e,i))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(t,i,s,n,o,r){void 0===o&&(o=0),void 0===r&&(r=0),void 0!==s&&null!==s?this.width=s:s=this.width,void 0!==n&&null!==n?this.height=n:n=this.height;var a=this.game.add.image(t,i,e.Cache.DEFAULT);return a.width=s,a.height=n,a.anchor.set(o,r),a.filters=[this],a},syncUniforms:function(){for(var t=0;t<this.shaders.length;t++)this.shaders[t].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}},e.Filter.prototype.constructor=e.Filter,Object.defineProperty(e.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(t){this.uniforms.resolution.value.x=t}}),Object.defineProperty(e.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(t){this.uniforms.resolution.value.y=t}}),e.Plugin=function(t,e){void 0===e&&(e=null),this.game=t,this.parent=e,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.Plugin.prototype.constructor=e.Plugin,e.PluginManager=function(t){this.game=t,this.plugins=[],this._len=0,this._i=0},e.PluginManager.prototype={add:function(t){var e=Array.prototype.slice.call(arguments,1),i=!1;return"function"==typeof t?t=new t(this.game,this):(t.game=this.game,t.parent=this),"function"==typeof t.preUpdate&&(t.hasPreUpdate=!0,i=!0),"function"==typeof t.update&&(t.hasUpdate=!0,i=!0),"function"==typeof t.postUpdate&&(t.hasPostUpdate=!0,i=!0),"function"==typeof t.render&&(t.hasRender=!0,i=!0),"function"==typeof t.postRender&&(t.hasPostRender=!0,i=!0),i?((t.hasPreUpdate||t.hasUpdate||t.hasPostUpdate)&&(t.active=!0),(t.hasRender||t.hasPostRender)&&(t.visible=!0),this._len=this.plugins.push(t),"function"==typeof t.init&&t.init.apply(t,e),t):null},remove:function(t,e){for(void 0===e&&(e=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===t)return e&&t.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}},e.PluginManager.prototype.constructor=e.PluginManager,e.Stage=function(t){this.game=t,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new e.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)},e.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Stage.prototype.constructor=e.Stage,e.Stage.prototype.parseConfig=function(t){t.disableVisibilityChange&&(this.disableVisibilityChange=t.disableVisibilityChange),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor)},e.Stage.prototype.boot=function(){e.DOM.getOffset(this.game.canvas,this.offset),e.Canvas.setUserSelect(this.game.canvas,"none"),e.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},e.Stage.prototype.preUpdate=function(){this.currentRenderOrderID=0;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},e.Stage.prototype.update=function(){for(var t=this.children.length;t--;)this.children[t].update()},e.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 t=0;t<this.children.length;t++)this.children[t].postUpdate();this.updateTransform()},e.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0;t<this.children.length;t++)this.children[t].updateTransform()},e.Stage.prototype.checkVisibility=function(){void 0!==document.hidden?this._hiddenVar="visibilitychange":void 0!==document.webkitHidden?this._hiddenVar="webkitvisibilitychange":void 0!==document.mozHidden?this._hiddenVar="mozvisibilitychange":void 0!==document.msHidden?this._hiddenVar="msvisibilitychange":this._hiddenVar=null;var t=this;this._onChange=function(e){return t.visibilityChange(e)},this._onChangePause=function(){return t._onChange({type:"pause"})},this._onChangeResume=function(){return t._onChange({type:"resume"})},this._onClick=function(e){void 0===document.hasFocus||document.hasFocus()||t.visibilityChange(e)},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)))},e.Stage.prototype.visibilityChange=function(t){switch(t.type){case"blur":case"pagehide":return void this.game.focusLoss(t);case"click":case"focus":case"pageshow":return void this.game.focusGain(t)}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===t.type?this.game.gamePaused(t):this.game.gameResumed(t))},e.Stage.prototype.setBackgroundColor=function(t){this.game.transparent||(e.Color.valueToColor(t,this._bgColor),e.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},e.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)},e.Stage.prototype.add=function(t,e,i){return t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?this.addChild(t):this.addChildAt(t,i),t)},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(t){this.setBackgroundColor(t)}}),Object.defineProperty(e.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(t){PIXI.scaleModes.DEFAULT=t?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}}),e.Group=function(t,i,s,n,o,r){void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===r&&(r=e.Physics.ARCADE),this.game=t,void 0===i&&(i=t.world),this.name=s||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),n?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):i&&(i.addChild(this),this.z=i.children.length),this.type=e.GROUP,this.physicsType=e.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=e.Sprite,this.cursor=null,this.inputEnableChildren=!1,this.updateOnlyExistingChildren=!1,this.onChildInputDown=new e.Signal,this.onChildInputUp=new e.Signal,this.onChildInputOver=new e.Signal,this.onChildInputOut=new e.Signal,this.enableBody=o,this.enableBodyDebug=!1,this.physicsBodyType=r,this.physicsSortDirection=null,this.onDestroy=new e.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.hash=[],this._sortProperty="z"},e.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Group.prototype.constructor=e.Group,e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.RETURN_ALL=3,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype.add=function(t,e,i){return void 0===e&&(e=!1),t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?(t.z=this.children.length,this.addChild(t)):(this.addChildAt(t,i),this.updateZ()),this.enableBody&&t.hasOwnProperty("body")&&null===t.body?this.game.physics.enable(t,this.physicsBodyType):t.body&&this.addToHash(t),!this.inputEnableChildren||t.input&&!t.inputEnabled||(t.inputEnabled=!0),!e&&t.events&&t.events.onAddedToGroup$dispatch(t,this),null===this.cursor&&(this.cursor=t),t)},e.Group.prototype.addAt=function(t,e,i){return this.add(t,i,e)},e.Group.prototype.addToHash=function(t){return t.parent===this&&-1===this.hash.indexOf(t)&&(this.hash.push(t),!0)},e.Group.prototype.removeFromHash=function(t){if(t){var e=this.hash.indexOf(t);if(-1!==e)return this.hash.splice(e,1),!0}return!1},e.Group.prototype.addMultiple=function(t,i){if(t instanceof e.Group)t.moveAll(this,i);else if(Array.isArray(t))for(var s=0;s<t.length;s++)this.add(t[s],i);return t},e.Group.prototype.getAt=function(t){return t<0||t>=this.children.length?-1:this.getChildAt(t)},e.Group.prototype.create=function(t,e,i,s,n,o){void 0===n&&(n=!0);var r=new this.classType(this.game,t,e,i,s);return r.exists=n,r.visible=n,r.alive=n,this.add(r,!1,o)},e.Group.prototype.createMultiple=function(t,e,i,s,n,o){void 0===i&&(i=0),void 0===s&&(s=!1),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);var r=this,a=[];return e.forEach(function(e){i.forEach(function(i){for(var h=0;h<t;h++){var l=r.create(0,0,e,i,s);n&&n.call(o||l,l,h),a.push(l)}})}),a},e.Group.prototype.updateZ=function(){for(var t=this.children.length;t--;)this.children[t].z=t},e.Group.prototype.align=function(t,i,s,n,o,r){if(void 0===o&&(o=e.TOP_LEFT),void 0===r&&(r=0),0===this.children.length||r>this.children.length||-1===t&&-1===i)return!1;for(var a=new e.Rectangle(0,0,s,n),h=t*s,l=i*n,c=r;c<this.children.length;c++){var u=this.children[c];if(u.alignIn)if(u.alignIn(a,o),-1===t)a.y+=n,a.y===l&&(a.x+=s,a.y=0);else if(-1===i)a.x+=s,a.x===h&&(a.x=0,a.y+=n);else if(a.x+=s,a.x===h&&(a.x=0,a.y+=n,a.y===l))return!0}return!0},e.Group.prototype.resetCursor=function(t){if(void 0===t&&(t=0),t>this.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},e.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},e.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},e.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},e.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)<this.children.length&&(this.remove(t,!1,!0),this.add(t,!0)),t},e.Group.prototype.bringChildToTop=e.Group.prototype.bringToTop,e.Group.prototype.sendToBack=function(t){return t.parent===this&&this.getIndex(t)>0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t},e.Group.prototype.sendChildToBack=e.Group.prototype.sendToBack,e.Group.prototype.moveUp=function(t){if(t.parent===this&&this.getIndex(t)<this.children.length-1){var e=this.getIndex(t),i=this.getAt(e+1);i&&this.swap(t,i)}return t},e.Group.prototype.moveDown=function(t){if(t.parent===this&&this.getIndex(t)>0){var e=this.getIndex(t),i=this.getAt(e-1);i&&this.swap(t,i)}return t},e.Group.prototype.xy=function(t,e,i){if(t<0||t>this.children.length)return-1;this.getChildAt(t).x=e,this.getChildAt(t).y=i},e.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},e.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},e.Group.prototype.getByName=function(t){return this.getFirst("name",t)},e.Group.prototype.replace=function(t,i){var s=this.getIndex(t);if(-1!==s)return i.parent&&(i.parent instanceof e.Group?i.parent.remove(i):i.parent.removeChild(i)),this.remove(t),this.addAt(i,s),t},e.Group.prototype.hasProperty=function(t,e){var i=e.length;return 1===i&&e[0]in t||(2===i&&e[0]in t&&e[1]in t[e[0]]||(3===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]||4===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]&&e[3]in t[e[0]][e[1]][e[2]]))},e.Group.prototype.setProperty=function(t,e,i,s,n){if(void 0===n&&(n=!1),s=s||0,!this.hasProperty(t,e)&&(!n||s>0))return!1;var o=e.length;return 1===o?0===s?t[e[0]]=i:1===s?t[e[0]]+=i:2===s?t[e[0]]-=i:3===s?t[e[0]]*=i:4===s&&(t[e[0]]/=i):2===o?0===s?t[e[0]][e[1]]=i:1===s?t[e[0]][e[1]]+=i:2===s?t[e[0]][e[1]]-=i:3===s?t[e[0]][e[1]]*=i:4===s&&(t[e[0]][e[1]]/=i):3===o?0===s?t[e[0]][e[1]][e[2]]=i:1===s?t[e[0]][e[1]][e[2]]+=i:2===s?t[e[0]][e[1]][e[2]]-=i:3===s?t[e[0]][e[1]][e[2]]*=i:4===s&&(t[e[0]][e[1]][e[2]]/=i):4===o&&(0===s?t[e[0]][e[1]][e[2]][e[3]]=i:1===s?t[e[0]][e[1]][e[2]][e[3]]+=i:2===s?t[e[0]][e[1]][e[2]][e[3]]-=i:3===s?t[e[0]][e[1]][e[2]][e[3]]*=i:4===s&&(t[e[0]][e[1]][e[2]][e[3]]/=i)),!0},e.Group.prototype.checkProperty=function(t,i,s,n){if(void 0===n&&(n=!1),this!==t.parent)return!1;var o=e.Utils.getProperty(t,i);return!(void 0===o&&n||o!==s)},e.Group.prototype.set=function(t,e,i,s,n,o,r){if(void 0===r&&(r=!1),e=e.split("."),void 0===s&&(s=!1),void 0===n&&(n=!1),(!1===s||s&&t.alive)&&(!1===n||n&&t.visible))return this.setProperty(t,e,i,o,r)},e.Group.prototype.setAll=function(t,e,i,s,n,o){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===o&&(o=!1),t=t.split("."),n=n||0;for(var r=this.children.length,a=0;a<r;a++){var h=this.children[a];i&&!h.alive||s&&!h.visible||this.setProperty(h,t,e,n,o)}},e.Group.prototype.setAllChildren=function(t,i,s,n,o,r){void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===r&&(r=!1),o=o||0;for(var a=this.children.length,h=0;h<a;h++){var l=this.children[h];s&&!l.alive||n&&!l.visible||(l instanceof e.Group?l.setAllChildren(t,i,s,n,o,r):this.setProperty(l,t.split("."),i,o,r))}},e.Group.prototype.checkAll=function(t,e,i,s,n){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=!1);for(var o=0;o<this.children.length;o++){var r=this.children[o];if((!i||r.alive)&&(!s||r.visible)&&!this.checkProperty(r,t,e,n))return!1}return!0},e.Group.prototype.checkAny=function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);for(var n=0;n<this.children.length;n++){var o=this.children[n];if((!i||o.alive)&&(!s||o.visible)&&this.checkProperty(o,t,e))return!0}return!1},e.Group.prototype.addAll=function(t,e,i,s){this.setAll(t,e,i,s,1)},e.Group.prototype.subAll=function(t,e,i,s){this.setAll(t,e,i,s,2)},e.Group.prototype.multiplyAll=function(t,e,i,s){this.setAll(t,e,i,s,3)},e.Group.prototype.divideAll=function(t,e,i,s){this.setAll(t,e,i,s,4)},e.Group.prototype.kill=function(){this.alive=!1,this.exists=!1,this.visible=!1},e.Group.prototype.killAll=function(){this.callAllExists("kill",!0)},e.Group.prototype.revive=function(){this.alive=!0,this.exists=!0,this.visible=!0},e.Group.prototype.reviveAll=function(){this.callAllExists("revive",!1)},e.Group.prototype.resetAll=function(t,e,i,s,n){this.forEach(this.resetChild,this,n,t,e,i,s)},e.Group.prototype.callAllExists=function(t,e){var i;if(arguments.length>2){i=[];for(s=2;s<arguments.length;s++)i.push(arguments[s])}for(var s=0;s<this.children.length;s++){var n=this.children[s];n.exists===e&&n[t]&&n[t].apply(n,i)}},e.Group.prototype.callbackFromArray=function(t,e,i){if(1===i){if(t[e[0]])return t[e[0]]}else if(2===i){if(t[e[0]][e[1]])return t[e[0]][e[1]]}else if(3===i){if(t[e[0]][e[1]][e[2]])return t[e[0]][e[1]][e[2]]}else if(4===i){if(t[e[0]][e[1]][e[2]][e[3]])return t[e[0]][e[1]][e[2]][e[3]]}else if(t[e])return t[e];return!1},e.Group.prototype.callAll=function(t,e){if(void 0!==t){var i=(t=t.split(".")).length;if(void 0===e||null===e||""===e)e=null;else if("string"==typeof e)var s=(e=e.split(".")).length;var n;if(arguments.length>2){n=[];for(a=2;a<arguments.length;a++)n.push(arguments[a])}for(var o=null,r=null,a=0;a<this.children.length;a++){var h=this.children[a];o=this.callbackFromArray(h,t,i),e&&o?(r=this.callbackFromArray(h,e,s),o.apply(r,n)):o&&o.apply(h,n)}}},e.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}return!0},e.Group.prototype.update=function(){for(var t=this.children.length;t--;){var e=this.children.length;t>=e&&(t=e-1);var i=this.children[t];this.updateOnlyExistingChildren&&!i.exists||i.update()}},e.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 t=0;t<this.children.length;t++)this.children[t].postUpdate()},e.Group.prototype.filter=function(t,i){for(var s=-1,n=this.children.length,o=[];++s<n;){var r=this.children[s];(!i||i&&r.exists)&&t(r,s,this.children)&&o.push(r)}return new e.ArraySet(o)},e.Group.prototype.forEach=function(t,e,i){if(void 0===i&&(i=!1),arguments.length<=3)for(n=0;n<this.children.length;n++){o=this.children[n];i&&!o.exists||t.call(e,o)}else{for(var s=[null],n=3;n<arguments.length;n++)s.push(arguments[n]);for(n=0;n<this.children.length;n++){var o=this.children[n];i&&!o.exists||(s[0]=o,t.apply(e,s))}}},e.Group.prototype.forEachExists=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("exists",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachAlive=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachDead=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!1,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.sort=function(t,i){this.children.length<2||(void 0===t&&(t="z"),void 0===i&&(i=e.Group.SORT_ASCENDING),this._sortProperty=t,i===e.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},e.Group.prototype.customSort=function(t,e){this.children.length<2||(this.children.sort(t.bind(e)),this.updateZ())},e.Group.prototype.ascendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?-1:t[this._sortProperty]>e[this._sortProperty]?1:t.z<e.z?-1:1},e.Group.prototype.descendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?1:t[this._sortProperty]>e[this._sortProperty]?-1:0},e.Group.prototype.iterate=function(t,i,s,n,o,r){if(0===this.children.length){if(s===e.Group.RETURN_TOTAL)return 0;if(s===e.Group.RETURN_ALL)return[]}var a=0;if(s===e.Group.RETURN_ALL)var h=[];for(var l=0;l<this.children.length;l++)if(this.children[l][t]===i){if(a++,n&&(r?(r[0]=this.children[l],n.apply(o,r)):n.call(o,this.children[l])),s===e.Group.RETURN_CHILD)return this.children[l];s===e.Group.RETURN_ALL&&h.push(this.children[l])}return s===e.Group.RETURN_TOTAL?a:s===e.Group.RETURN_ALL?h:null},e.Group.prototype.getFirst=function(t,i){return this.iterate(t,i,e.Group.RETURN_CHILD)},e.Group.prototype.getFirstExists=function(t,e,i,s,n,o){void 0===e&&(e=!1),"boolean"!=typeof t&&(t=!0);var r=this.getFirst("exists",t);return null===r&&e?this.create(i,s,n,o):this.resetChild(r,i,s,n,o)},e.Group.prototype.getFirstAlive=function(t,e,i,s,n){void 0===t&&(t=!1);var o=this.getFirst("alive",!0);return null===o&&t?this.create(e,i,s,n):this.resetChild(o,e,i,s,n)},e.Group.prototype.getFirstDead=function(t,e,i,s,n){void 0===t&&(t=!1);var o=this.getFirst("alive",!1);return null===o&&t?this.create(e,i,s,n):this.resetChild(o,e,i,s,n)},e.Group.prototype.resetChild=function(t,e,i,s,n){return null===t?null:(void 0===e&&(e=null),void 0===i&&(i=null),null!==e&&null!==i&&t.reset(e,i),void 0!==s&&t.loadTexture(s,n),t)},e.Group.prototype.getTop=function(){if(this.children.length>0)return this.children[this.children.length-1]},e.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]},e.Group.prototype.getClosestTo=function(t,i,s){for(var n=Number.MAX_VALUE,o=0,r=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(o=Math.abs(e.Point.distance(t,h)))<n&&(!i||i.call(s,h,o))&&(n=o,r=h)}return r},e.Group.prototype.getFurthestFrom=function(t,i,s){for(var n=0,o=0,r=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(o=Math.abs(e.Point.distance(t,h)))>n&&(!i||i.call(s,h,o))&&(n=o,r=h)}return r},e.Group.prototype.count=function(t,i){return this.iterate(t,i,e.Group.RETURN_TOTAL)},e.Group.prototype.countLiving=function(){return this.count("alive",!0)},e.Group.prototype.countDead=function(){return this.count("alive",!1)},e.Group.prototype.getRandom=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=this.children.length),0===i?null:e.ArrayUtils.getRandomItem(this.children,t,i)},e.Group.prototype.getRandomExists=function(t,e){var i=this.getAll("exists",!0,t,e);return this.game.rnd.pick(i)},e.Group.prototype.getAll=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=this.children.length);for(var n=[],o=i;o<s;o++){var r=this.children[o];t?r[t]===e&&n.push(r):n.push(r)}return n},e.Group.prototype.remove=function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=!1),0===this.children.length||-1===this.children.indexOf(t))return!1;i||!t.events||t.destroyPhase||t.events.onRemovedFromGroup$dispatch(t,this);var s=this.removeChild(t);return this.removeFromHash(t),this.updateZ(),this.cursor===t&&this.next(),e&&s&&s.destroy(!0),!0},e.Group.prototype.moveAll=function(t,i){if(void 0===i&&(i=!1),this.children.length>0&&t instanceof e.Group){do{t.add(this.children[0],i)}while(this.children.length>0);this.hash=[],this.cursor=null}return t},e.Group.prototype.removeAll=function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var s=this.removeChild(this.children[0]);this.removeFromHash(s),t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.hash=[],this.cursor=null}},e.Group.prototype.removeBetween=function(t,e,i,s){if(void 0===e&&(e=this.children.length-1),void 0===i&&(i=!1),void 0===s&&(s=!1),0!==this.children.length){if(t>e||t<0||e>this.children.length)return!1;for(var n=e;n>=t;){!s&&this.children[n].events&&this.children[n].events.onRemovedFromGroup$dispatch(this.children[n],this);var o=this.removeChild(this.children[n]);this.removeFromHash(o),i&&o&&o.destroy(!0),this.cursor===this.children[n]&&(this.cursor=null),n--}this.updateZ()}},e.Group.prototype.scatter=function(t,e){null==t&&(t=this.game.world.bounds),this.forEach(function(e){e.position.set(t.randomX,t.randomY)},null,e)},e.Group.prototype.shuffle=function(){e.ArrayUtils.shuffle(this.children),this.updateZ()},e.Group.prototype.destroy=function(t,e){null===this.game||this.ignoreDestroy||(void 0===t&&(t=!0),void 0===e&&(e=!1),this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(t){this.rotation=e.Math.degToRad(t)}}),Object.defineProperty(e.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.halfWidth}}),Object.defineProperty(e.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.halfHeight}}),Object.defineProperty(e.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i}}),Object.defineProperty(e.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.width}}),Object.defineProperty(e.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i}}),Object.defineProperty(e.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.height}}),e.World=function(t){e.Group.call(this,t,null,"__world",!1),this.bounds=new e.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)},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},e.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},e.World.prototype.setBounds=function(t,e,i,s){this._definedSize=!0,this._width=i,this._height=s,this.bounds.setTo(t,e,i,s),this.x=t,this.y=e,this.camera.bounds&&this.camera.bounds.setTo(t,e,Math.max(i,this.game.width),Math.max(s,this.game.height)),this.game.physics.setBoundsToWorld()},e.World.prototype.resize=function(t,e){this._definedSize&&(t<this._width&&(t=this._width),e<this._height&&(e=this._height)),this.bounds.width=t,this.bounds.height=e,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},e.World.prototype.shutdown=function(){this.destroy(!0,!0)},e.World.prototype.wrap=function(t,e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=!1),void 0===s&&(s=!0),void 0===n&&(n=!0),i?(t.getBounds(),s&&(t.x+t._currentBounds.width<this.bounds.x?t.x=this.bounds.right:t.x>this.bounds.right&&(t.x=this.bounds.left)),n&&(t.y+t._currentBounds.height<this.bounds.top?t.y=this.bounds.bottom:t.y>this.bounds.bottom&&(t.y=this.bounds.top))):(s&&t.x+e<this.bounds.x?t.x=this.bounds.right+e:s&&t.x-e>this.bounds.right&&(t.x=this.bounds.left-e),n&&t.y+e<this.bounds.top?t.y=this.bounds.bottom+e:n&&t.y-e>this.bounds.bottom&&(t.y=this.bounds.top-e))},e.World.prototype.wrapAll=function(t,e,i,s,n,o){t.forEach(this.wrap,this,e,i,s,n,o)},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(t){t<this.game.width&&(t=this.game.width),this.bounds.width=t,this._width=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(t){t<this.game.height&&(t=this.game.height),this.bounds.height=t,this._height=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}}),Object.defineProperty(e.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(e.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)}}),e.Game=function(t,i,s,n,o,r,a,h){return this.id=e.GAMES.push(this)-1,this.config=null,this.physicsConfig=h,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=e.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=e.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 e.Signal,this.forceSingleUpdate=!0,this.forceSingleRender=!0,this.dropFrames=!1,this.maxUpdates=3,this.powerPreference="default",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!==s&&(this.renderType=s),void 0!==n&&(this.parent=n),void 0!==r&&(this.transparent=r),void 0!==a&&(this.antialias=a),this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new e.StateManager(this,o)),this.device.whenReady(this.boot,this),this},e.Game.prototype={parseConfig:function(t){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),void 0!==t.powerPreference&&(this.powerPreference=t.powerPreference),t.physicsConfig&&(this.physicsConfig=t.physicsConfig);var i=[(Date.now()*Math.random()).toString()];t.seed&&(i=t.seed),this.rnd=new e.RandomDataGenerator(i);var s=null;t.state&&(s=t.state),this.state=new e.StateManager(this,s)},boot:function(){if(!this.isBooted){if(this.onPause=new e.Signal,this.onResume=new e.Signal,this.onBlur=new e.Signal,this.onFocus=new e.Signal,this.isBooted=!0,PIXI.game=this,this.math=e.Math,this.scale=new e.ScaleManager(this,this._width,this._height),this.stage=new e.Stage(this),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.make=new e.GameObjectCreator(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics(this,this.physicsConfig),this.particles=new e.Particles(this),this.create=new e.Create(this),this.plugins=new e.PluginManager(this),this.net=new e.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 e.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.config&&this.config.forceSetTimeOut?this.raf=new e.RequestAnimationFrame(this,this.config.forceSetTimeOut):this.raf=new e.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(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var t=e.VERSION,i="Canvas",s="HTML Audio",n=1;if(this.renderType===e.WEBGL?(i="WebGL",n++):this.renderType===e.HEADLESS&&(i="Headless"),this.device.webAudio&&(s="WebAudio",n++),this.device.ie)window.console&&console.log("Phaser v"+t+" | Pixi.js | "+i+" | "+s+" | http://phaser.io");else{for(var o=["%c %c %c Phaser CE v"+t+" | Pixi.js | "+i+" | "+s+"  %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<n?o.push("color: #ff2424; background: #fff"):o.push("color: #959595; background: #fff");console.log.apply(console,o)}}},setUpRenderer:function(){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas 2d context, aborting.");if(this.config.canvas?this.canvas=this.config.canvas:this.canvas=e.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&&e.Canvas.setImageRenderingCrisp(this.canvas),this.renderType===e.WEBGL||this.renderType===e.WEBGL_MULTI||this.renderType===e.AUTO&&this.device.webGL){(this.multiTexture||this.renderType===e.WEBGL_MULTI)&&(PIXI.enableMultiTexture(),this.multiTexture=!0);try{this.renderer=new PIXI.WebGLRenderer(this,this.config),this.renderType=e.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===e.WEBGL)throw t}}this.renderer||(this.renderer=new PIXI.CanvasRenderer(this,this.config),this.context=this.renderer.context,this.renderType===e.AUTO&&(this.renderType=e.CANVAS)),this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===e.CANVAS),this.renderType!==e.HEADLESS&&(this.stage.smoothed=this.antialias,e.Canvas.addToDOM(this.canvas,this.parent,!1),e.Canvas.setTouchAction(this.canvas))},contextLost:function(t){t.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(t){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{var i=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(i*this.maxUpdates,this.time.elapsed),0);var s=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/i),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame)),this.forceSingleRender?this.rendersThisFrame=1:this.rendersThisFrame=Math.min(1,this.updatesThisFrame);this._deltaTime>=i&&(this._deltaTime-=i,this.currentUpdateID=s,this.updateLogic(this.time.desiredFpsMult),s++,!this.forceSingleUpdate||1!==s);)this.time.refresh();s>this._lastCount?this._spiraling++:s<this._lastCount&&(this._spiraling=0),this._lastCount=s,this.rendersThisFrame>0&&this.updateRender(this._deltaTime/i)}this.renderer.type===e.WEBGL&&this.renderer.gl.flush()}},updateLogic:function(t){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(t),this.debug.preUpdate(),this.input.pauseUpdate()):(this.stepping&&(this.pendingStep=!0),this.time.preUpdate(),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(t),this.plugins.preUpdate(t),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===e.HEADLESS||(this.time.preRender(),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),e.Canvas.removeFromDOM(this.canvas),PIXI.game===this&&(PIXI.game=null),PIXI.defaultRenderer=null,e.GAMES[this.id]=null},gamePaused:function(t){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.gamePaused(),this.onPause.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(t){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.gameResumed(),this.onResume.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(t){this.onBlur.dispatch(t),this.stage.disableVisibilityChange||this.gamePaused(t)},focusGain:function(t){this.focusWindow(),this.onFocus.dispatch(t),this.stage.disableVisibilityChange||this.gameResumed(t)},focusWindow:function(){window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus()}},e.Game.prototype.constructor=e.Game,Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(t){!0===t?(!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)}}),e.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=e.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 e.ArraySet,this._localPoint=new e.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.MAX_POINTERS=10,e.Input.prototype={boot:function(t){"maxPointers"in t&&(this.maxPointers=t.maxPointers),this.mousePointer=new e.Pointer(this.game,0,e.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new e.Mouse(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.mouseWheel=new e.MouseWheel(this.game),this.pointerLock=new e.PointerLock(this.game),e.Keyboard&&(this.keyboard=new e.Keyboard(this.game)),e.Gamepad&&(this.gamepad=new e.Gamepad(this.game)),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,45),this.activePointer=this.mousePointer,this.hitCanvas=e.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,!0===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(t){i.onClickTrampoline(t)},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=[],e.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e},addMoveCallback:function(t,e){this.moveCallbacks.push({callback:t,context:e})},addTouchLockCallback:function(t,e,i){void 0===i&&(i=!1),this.touchLockCallbacks.push({callback:t,context:e,onEnd:i})},removeTouchLockCallback:function(t,e){for(var i=this.touchLockCallbacks.length;i--;)if(this.touchLockCallbacks[i].callback===t&&this.touchLockCallbacks[i].context===e)return this.touchLockCallbacks.splice(i,1),!0;return!1},executeTouchLockCallbacks:function(t,e){for(var i=this.touchLockCallbacks.length;i--;){var s=this.touchLockCallbacks[i];s.onEnd===t&&s.callback.call(s.context,this,e)&&this.touchLockCallbacks.splice(i,1)}},deleteMoveCallback:function(t,e){for(var i=this.moveCallbacks.length;i--;)if(this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)},addPointer:function(){if(this.pointers.length>=e.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+e.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,i=new e.Pointer(this.game,t,e.PointerMode.CONTACT);return this.pointers.push(i),this["pointer"+t]=i,i},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 t=0;t<this.pointers.length;t++)this.pointers[t].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 e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(t,e){this._oldPosition.setTo(t,e),this.speed.setTo(0,0)},startPointer:function(t){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(!i.active)return i.start(t)}return null},updatePointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.move(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.move(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.move(t)}return null},stopPointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.stop(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.stop(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.stop(t)}return null},countActivePointers:function(t){void 0===t&&(t=this.pointers.length);for(var e=t,i=0;i<this.pointers.length&&e>0;i++)this.pointers[i].active&&e--;return t-e},getPointer:function(t){void 0===t&&(t=!1);for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active===t)return i}return null},getPointerFromIdentifier:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.identifier===t)return i}return null},getPointerFromId:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.pointerId===t)return i}return null},getLocalPosition:function(t,i,s){void 0===s&&(s=new e.Point);var n=t.worldTransform,o=1/(n.a*n.d+n.c*-n.b);return s.setTo(n.d*o*i.x+-n.c*o*i.y+(n.ty*n.c-n.tx*n.d)*o,n.a*o*i.y+-n.b*o*i.x+(-n.ty*n.a+n.tx*n.b)*o)},hitTest:function(t,i,s){if(!t.worldVisible)return!1;if(this.getLocalPosition(t,i,this._localPoint),s.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(e.Creature&&t instanceof e.Creature){var n=Math.abs(t.width),o=Math.abs(t.height),r=t.x-n*t.anchorX;if(this.game.camera.x+i.x>=r&&this.game.camera.x+i.x<r+n){a=t.y-o*t.anchorY;if(this.game.camera.y+i.y>=a&&this.game.camera.y+i.y<a+o)return!0}}else if(t instanceof e.TileSprite){var n=t.width,o=t.height,r=-n*t.anchor.x;if(this._localPoint.x>=r&&this._localPoint.x<r+n){a=-o*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+o)return!0}}else if(t instanceof PIXI.Sprite){var n=t.texture.frame.width/t.texture.baseTexture.resolution,o=t.texture.frame.height/t.texture.baseTexture.resolution,r=-n*t.anchor.x;if(this._localPoint.x>=r&&this._localPoint.x<r+n){var a=-o*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+o)return!0}}else if(t instanceof e.Graphics)for(l=0;l<t.graphicsData.length;l++){var h=t.graphicsData[l];if(h.fill&&(h.shape&&h.shape.contains(this._localPoint.x,this._localPoint.y)))return!0}for(var l=0;l<t.children.length;l++)if(this.hitTest(t.children[l],i,s))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()},callAll:function(t,e){for(var i=this.interactiveItems.list,s=i.length;s--;){var n=i[s];n&&n.enabled&&n[t](e)}}},e.Input.prototype.constructor=e.Input,Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(t){this._x=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(t){this._y=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter<this.pollRate}}),Object.defineProperty(e.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Mouse=function(t){this.game=t,this.input=t.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},e.Mouse.NO_BUTTON=-1,e.Mouse.LEFT_BUTTON=0,e.Mouse.MIDDLE_BUTTON=1,e.Mouse.RIGHT_BUTTON=2,e.Mouse.BACK_BUTTON=3,e.Mouse.FORWARD_BUTTON=4,e.Mouse.prototype={start:function(){var t=this.game.device;if(t.isAndroidStockBrowser()&&this.input.touch.active)return!1;if(null!==this._onMouseDown)return!1;var e=this;this._onMouseDown=function(t){return e.onMouseDown(t)},this._onMouseMove=function(t){return e.onMouseMove(t)},this._onMouseUp=function(t){return e.onMouseUp(t)},this._onMouseUpGlobal=function(t){return e.onMouseUpGlobal(t)},this._onMouseOutGlobal=function(t){return e.onMouseOutGlobal(t)},this._onMouseOut=function(t){return e.onMouseOut(t)},this._onMouseOver=function(t){return e.onMouseOver(t)};var i=this.game.canvas;return i.addEventListener("mousedown",this._onMouseDown,!0),i.addEventListener("mousemove",this._onMouseMove,!0),i.addEventListener("mouseup",this._onMouseUp,!0),t.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),i.addEventListener("mouseover",this._onMouseOver,!0),i.addEventListener("mouseout",this._onMouseOut,!0)),this.active=!0,!0},onMouseDown:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.start(t))},onMouseMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.move(t))},onMouseUp:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.stop(t))},onMouseUpGlobal:function(t){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),t.identifier=0,this.input.mousePointer.stop(t))},onMouseOutGlobal:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(t),this.input.mousePointer.resetButtons())},onMouseOut:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(this.input.mousePointer.updateButtons(t),this.stopOnGameOut&&(t.identifier=0,this.input.mousePointer.stop(t),this.input.callAll("_pointerOutHandler",this.input.mousePointer)))},onMouseOver:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.input.mousePointer.updateButtons(t)},stop:function(){var t=this.game.canvas;t.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("mousemove",this._onMouseMove,!0),t.removeEventListener("mouseup",this._onMouseUp,!0),t.removeEventListener("mouseover",this._onMouseOver,!0),t.removeEventListener("mouseout",this._onMouseOut,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0),this.active=!1}},e.Mouse.prototype.constructor=e.Mouse,e.MouseWheel=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.preventDefault=!0,this.active=!1,this.callback=null,this.callbackContext=t,this.delta=0,this.wheelEventName=t.device.wheelEvent,this.boundOnWheelHandler=this.onWheelHandler.bind(this),this.eventProxy=null},e.MouseWheel.UP=1,e.MouseWheel.DOWN=-1,e.MouseWheel.prototype.start=function(){return!(!this.wheelEventName||this.active)&&(this.element.addEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),"mousewheel"===this.wheelEventName?this.eventProxy=new e.WheelEventProxy(-.025,1):"DOMMouseScroll"===this.wheelEventName&&(this.eventProxy=new e.WheelEventProxy(1,1)),this.active=!0,!0)},e.MouseWheel.prototype.stop=function(){this.active&&(this.element.removeEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),this.active=!1)},e.MouseWheel.prototype.onWheelHandler=function(t){this.eventProxy&&(t=this.eventProxy.bindEvent(t)),this.preventDefault&&t.preventDefault(),this.delta=e.Math.clamp(-t.deltaY,-1,1),this.callback&&this.callback.call(this.callbackContext,t)},e.MSPointer=function(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.pointerOutCallback=null,this.pointerOverCallback=null,this.pointerCancelCallback=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},e.MSPointer.prototype={start:function(){if(!this.game.device.mspointer)return!1;if(null!==this._onMSPointerDown)return!1;var t=this;this._onMSPointerDown=function(e){return t.onPointerDown(e)},this._onMSPointerMove=function(e){return t.onPointerMove(e)},this._onMSPointerUp=function(e){return t.onPointerUp(e)},this._onMSPointerUpGlobal=function(e){return t.onPointerUpGlobal(e)},this._onMSPointerOut=function(e){return t.onPointerOut(e)},this._onMSPointerOver=function(e){return t.onPointerOver(e)},this._onMSPointerCancel=function(e){return t.onPointerCancel(e)};var e=this.game.canvas;return e.addEventListener("MSPointerDown",this._onMSPointerDown,!1),e.addEventListener("MSPointerMove",this._onMSPointerMove,!1),e.addEventListener("MSPointerUp",this._onMSPointerUp,!1),e.addEventListener("MSPointerCancel",this._onMSPointerCancel,!1),e.addEventListener("pointerdown",this._onMSPointerDown,!1),e.addEventListener("pointermove",this._onMSPointerMove,!1),e.addEventListener("pointerup",this._onMSPointerUp,!1),e.addEventListener("pointercancel",this._onMSPointerCancel,!1),e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.addEventListener("MSPointerOver",this._onMSPointerOver,!0),e.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.addEventListener("pointerover",this._onMSPointerOver,!0),e.addEventListener("pointerout",this._onMSPointerOut,!0)),this.active=!0,!0},onPointerDown:function(t){this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.capture&&t.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,this.isMousePointerEvent(t)?this.input.mousePointer.start(t):this.input.startPointer(t))},onPointerMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,this.isMousePointerEvent(t)?this.input.mousePointer.move(t):this.input.updatePointer(t))},onPointerUp:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.capture&&t.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,this.isMousePointerEvent(t)?this.input.mousePointer.stop(t):this.input.stopPointer(t))},onPointerUpGlobal:function(t){if(t.identifier=t.pointerId,this.isMousePointerEvent(t)&&!this.input.mousePointer.withinGame)this.onPointerUp(t);else{var e=this.input.getPointerFromIdentifier(t.identifier);e&&e.withinGame&&this.onPointerUp(t)}},onPointerOut:function(t){this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId;var e=this.getPointerFromEvent(t);e&&(e.withinGame=!1),this.pointerOutCallback&&this.pointerOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(t.identifier=0,e||(e=this.input.mousePointer),e.stop(t),this.input.callAll("_pointerOutHandler",e))},onPointerOver:function(t){this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId;var e=this.getPointerFromEvent(t);e&&(e.withinGame=!0),this.pointerOverCallback&&this.pointerOverCallback.call(this.callbackContext,t)},onPointerCancel:function(t){this.event=t,this.pointerCancelCallback&&this.pointerCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&(t.identifier=t.pointerId,this.isMousePointerEvent(t)?this.input.mousePointer.stop(t):this.input.stopPointer(t))},stop:function(){var t=this.game.canvas;t.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),t.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),t.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),t.removeEventListener("pointerdown",this._onMSPointerDown,!1),t.removeEventListener("pointermove",this._onMSPointerMove,!1),t.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),t.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.removeEventListener("pointerover",this._onMSPointerOver,!0),t.removeEventListener("pointerout",this._onMSPointerOut,!0),this.active=!1},isMousePointerEvent:function(t){return"mouse"===t.pointerType||4===t.pointerType},getPointerFromEvent:function(t){return this.isMousePointerEvent(t)?this.input.mousePointer:this.input.getPointerFromIdentifier(t.identifier)}},e.MSPointer.prototype.constructor=e.MSPointer,e.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 e.Signal,this.onUp=new e.Signal,this.onFloat=new e.Signal},e.DeviceButton.prototype={start:function(t,e){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onDown.dispatch(this,e))},stop:function(t,e){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onUp.dispatch(this,e))},startStop:function(t,e,i){t?this.start(e,i):this.stop(e,i)},padFloat:function(t){this.isDown=!1,this.isUp=!1,this.value=t,this.onFloat.dispatch(this,t)},justPressed:function(t){return t=t||250,this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||250,this.isUp&&this.timeUp+t>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}},e.DeviceButton.prototype.constructor=e.DeviceButton,Object.defineProperty(e.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),e.Pointer=function(t,i,s){this.game=t,this.id=i,this.type=e.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=s||e.PointerMode.CURSOR|e.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new e.DeviceButton(this,e.Pointer.LEFT_BUTTON),this.middleButton=new e.DeviceButton(this,e.Pointer.MIDDLE_BUTTON),this.rightButton=new e.DeviceButton(this,e.Pointer.RIGHT_BUTTON),this.backButton=new e.DeviceButton(this,e.Pointer.BACK_BUTTON),this.forwardButton=new e.DeviceButton(this,e.Pointer.FORWARD_BUTTON),this.eraserButton=new e.DeviceButton(this,e.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 e.Point,this.positionDown=new e.Point,this.positionUp=new e.Point,this.circle=new e.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},e.Pointer.NO_BUTTON=0,e.Pointer.LEFT_BUTTON=1,e.Pointer.RIGHT_BUTTON=2,e.Pointer.MIDDLE_BUTTON=4,e.Pointer.BACK_BUTTON=8,e.Pointer.FORWARD_BUTTON=16,e.Pointer.ERASER_BUTTON=32,e.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 e.Mouse.LEFT_BUTTON:this.leftButton.start(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.start(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.start(i);break;case e.Mouse.BACK_BUTTON:this.backButton.start(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.start(i)}},processButtonsUp:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.stop(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.stop(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.stop(i);break;case e.Mouse.BACK_BUTTON:this.backButton.stop(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.stop(i)}},processButtonsUpDown:function(t,i){var s=i.type.toLowerCase().substr(-4),n="down"===s,o="move"===s;void 0!==t?(n&&1===t&&i.ctrlKey&&(t=2),this.leftButton.startStop(e.Pointer.LEFT_BUTTON&t,i),this.rightButton.startStop(e.Pointer.RIGHT_BUTTON&t,i),this.middleButton.startStop(e.Pointer.MIDDLE_BUTTON&t,i),this.backButton.startStop(e.Pointer.BACK_BUTTON&t,i),this.forwardButton.startStop(e.Pointer.FORWARD_BUTTON&t,i),this.eraserButton.startStop(e.Pointer.ERASER_BUTTON&t,i)):void 0!==i.button?n&&i.ctrlKey&&0===i.button?this.rightButton.start(i):n?this.processButtonsDown(i.button,i):o||this.processButtonsUp(i.button,i):n?i.ctrlKey?this.rightButton.start(i):this.leftButton.start(i):(this.leftButton.stop(i),this.rightButton.stop(i))},updateButtons:function(t){this.button=t.button,this.processButtonsUpDown(t.buttons,t),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===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.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===e.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===e.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 s=this.game.input;if(!s.pollLocked){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&&s.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)*s.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*s.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(s.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||s.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||s.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===s.totalActivePointers)&&(s.activePointer=this,s.x=this.x,s.y=this.y,s.position.setTo(s.x,s.y),s.circle.x=s.x,s.circle.y=s.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var n=s.moveCallbacks.length;n--;)s.moveCallbacks[n].callback.call(s.moveCallbacks[n].context,this,this.x,this.y,i,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?s.interactiveItems.total>0&&this.processInteractiveObjects(i):!1===this.targetObject.update(this)&&(this.targetObject=null),this}},processInteractiveObjects:function(t){var e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,!n.validForInput(i,e,!1)||this.game.paused&&!n.sprite.noPause||(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject},swapTarget:function(t,e){void 0===e&&(e=!1),null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))},leave:function(t){this.withinGame=!1,this.move(t,!1)},stop:function(t){var i=this.game.input;{if(!this._stateReset||!this.withinGame){if(this.timeUp=this.game.time.time,(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.onUp.dispatch(this,t),this.duration>=0&&this.duration<=i.tapRate)){var s=this.timeUp-this.previousTapTime<i.doubleTapRate;i.onTap.dispatch(this,s,t),this.previousTapTime=this.timeUp}return 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(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time},addClickTrampoline:function(t,e,i,s){if(this.isDown){for(var n=this._clickTrampolines=this._clickTrampolines||[],o=0;o<n.length;o++)if(n[o].name===t){n.splice(o,1);break}n.push({name:t,targetObject:this.targetObject,callback:e,callbackContext:i,callbackArgs:s})}},processClickTrampolines:function(){var t=this._clickTrampolines;if(t){for(var e=0;e<t.length;e++){var i=t[e];i.targetObject===this._trampolineTargetObject&&i.callback.apply(i.callbackContext,i.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}},e.Pointer.prototype.constructor=e.Pointer,Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.PointerMode={CURSOR:1,CONTACT:2},e.PointerModes={},e.PointerModes[e.PointerMode.CURSOR]="CURSOR",e.PointerModes[e.PointerMode.CONTACT]="CONTACT",e.Touch=function(t){this.game=t,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},e.Touch.prototype={start:function(){if(!this.game.device.touch)return!1;if(null!==this._onTouchStart)return!1;var t=this;return this._onTouchStart=function(e){return t.onTouchStart(e)},this._onTouchMove=function(e){return t.onTouchMove(e)},this._onTouchEnd=function(e){return t.onTouchEnd(e)},this._onTouchEnter=function(e){return t.onTouchEnter(e)},this._onTouchLeave=function(e){return t.onTouchLeave(e)},this._onTouchCancel=function(e){return t.onTouchCancel(e)},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(t){t.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(t){if(this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.startPointer(t.changedTouches[e])}},onTouchCancel:function(t){if(this.event=t,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled){this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])}},onTouchEnter:function(t){this.event=t,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&this.preventDefault&&t.preventDefault()},onTouchLeave:function(t){this.event=t,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault()},onTouchMove:function(t){this.event=t,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.updatePointer(t.changedTouches[e])},onTouchEnd:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])},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)}},e.Touch.prototype.constructor=e.Touch,e.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 e.Point,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new e.Point,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new e.Point,this.snapPoint=new e.Point,this._dragPoint=new e.Point,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new e.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})},e.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 s=0;s<10;s++)this._pointerData[s]={id:s,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 e.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 t=0;t<10;t++)this._pointerData[t]={id:t,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(t,e,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>t||this.priorityID===t&&this.sprite.renderOrderID>e))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(t){return t=t||0,this._pointerData[t].x},pointerY:function(t){return t=t||0,this._pointerData[t].y},pointerDown:function(t){return t=t||0,this._pointerData[t].isDown},pointerUp:function(t){return t=t||0,this._pointerData[t].isUp},pointerTimeDown:function(t){return t=t||0,this._pointerData[t].timeDown},pointerTimeUp:function(t){return t=t||0,this._pointerData[t].timeUp},pointerOver:function(t){if(!this.enabled)return!1;if(void 0===t){for(var e=0;e<10;e++)if(this._pointerData[e].isOver)return!0;return!1}return this._pointerData[t].isOver},pointerOut:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOut;for(var e=0;e<10;e++)if(this._pointerData[e].isOut)return!0},pointerTimeOver:function(t){return t=t||0,this._pointerData[t].timeOver},pointerTimeOut:function(t){return t=t||0,this._pointerData[t].timeOut},pointerDragged:function(t){return t=t||0,this._pointerData[t].isDragged},checkPointerDown:function(t,e){return!!(t.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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(t,e){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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);var t=this._tempPoint.x,e=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,t<this.sprite.texture.crop.x||t>this.sprite.texture.crop.right||e<this.sprite.texture.crop.y||e>this.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,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=e.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(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){var s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.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),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}},_touchedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)},_releasedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;var i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}},updateDrag:function(t,e){var i=this.game.camera,s=this.dragOffset,n=this._dragPoint,o=this._pointerData[t.id],r=this.snapPoint,a=this.sprite;if(void 0===e&&(e=!1),t.isUp)return this.stopDrag(t),!1;var h=this.globalToLocal(t);if(a.fixedToCamera)var l=i.scale.x*h.x+n.x+s.x,c=i.scale.y*h.y+n.y+s.y;else var l=h.x+n.x+s.x,c=h.y+n.y+s.y;if(a.fixedToCamera){var u=a.cameraOffset,d=u.x,p=u.y;this.allowHorizontalDrag&&(u.x=l-i.x),this.allowVerticalDrag&&(u.y=c-i.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(u.x=Math.round((u.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,u.y=Math.round((u.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,r.set(u.x,u.y));var f=u.x-d,g=u.y-p}else{var m=i.x-o.camX,y=i.y-o.camY,d=a.x,p=a.y;this.allowHorizontalDrag&&(a.x=l+m),this.allowVerticalDrag&&(a.y=c+y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(a.x=Math.round((a.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,a.y=Math.round((a.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,r.set(a.x,a.y));var f=a.x-d,g=a.y-p}return this.sprite.events.onDragUpdate.dispatch(a,t,l,c,r,e,f,g),!0},justOver:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOver&&this.overDuration(t)<e},justOut:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOut&&this.game.time.time-this._pointerData[t].timeOut<e},justPressed:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isDown&&this.downDuration(t)<e},justReleased:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isUp&&this.game.time.time-this._pointerData[t].timeUp<e},overDuration:function(t){return t=t||0,this._pointerData[t].isOver?this.game.time.time-this._pointerData[t].timeOver:-1},downDuration:function(t){return t=t||0,this._pointerData[t].isDown?this.game.time.time-this._pointerData[t].timeDown:-1},enableDrag:function(t,i,s,n,o,r){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=255),void 0===o&&(o=null),void 0===r&&(r=null),this._dragPoint=new e.Point,this.draggable=!0,this.bringToTop=i,this.dragOffset=new e.Point,this.dragFromCenter=t,this.pixelPerfectClick=s,this.pixelPerfectAlpha=n,o&&(this.boundsRect=o),r&&(this.boundsSprite=r)},disableDrag:function(){if(this._pointerData)for(var t=0;t<10;t++)this._pointerData[t].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1},startDrag:function(t){var i=this.sprite.x,s=this.sprite.y,n=this.globalToLocal(t);if(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){if(this.dragFromCenter){var o=this.sprite.getBounds(),r=this.globalToLocal(new e.Point(o.centerX,o.centerY));this.sprite.cameraOffset.x=n.x+(this.sprite.cameraOffset.x-r.x),this.sprite.cameraOffset.y=n.y+(this.sprite.cameraOffset.y-r.y)}this._dragPoint.setTo(this.sprite.cameraOffset.x-t.x,this.sprite.cameraOffset.y-t.y)}else{if(this.dragFromCenter){var o=this.sprite.getBounds(),r=this.globalToLocal(new e.Point(o.centerX,o.centerY));this.sprite.x=n.x+(this.sprite.x-r.x),this.sprite.y=n.y+(this.sprite.y-r.y)}this._dragPoint.setTo(this.sprite.x-n.x,this.sprite.y-n.y)}this.updateDrag(t,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(i,s),this.sprite.events.onDragStart$dispatch(this.sprite,t,i,s),this._pendingDrag=!1},globalToLocalX:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.x,t*=this.game.scale.grid.scaleFluidInversed.x),t},globalToLocalY:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.y,t*=this.game.scale.grid.scaleFluidInversed.y),t},globalToLocal:function(t){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:t.x,y:t.y}):t},stopDrag:function(t){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[t.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,t),!1===this.checkPointerOver(t)&&this._pointerOutHandler(t)},setDragLock:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.allowHorizontalDrag=t,this.allowVerticalDrag=e},enableSnap:function(t,e,i,s,n,o){void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===n&&(n=0),void 0===o&&(o=0),this.snapX=t,this.snapY=e,this.snapOffsetX=n,this.snapOffsetY=o,this.snapOnDrag=i,this.snapOnRelease=s},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)))}},e.InputHandler.prototype.constructor=e.InputHandler,e.PointerLock=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.active=!1,this.locked=!1,this.onChange=new e.Signal,this.onError=new e.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},e.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)},e.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)},e.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()},e.PointerLock.prototype.exit=function(){document.exitPointerLock()},e.PointerLock.prototype.onChangeHandler=function(t){this.locked=document[this.pointerLockElement]===this.element,this.onChange.dispatch(this.locked,t)},e.PointerLock.prototype.onErrorHandler=function(t){this.onError.dispatch(t)},e.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 e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this)]},e.Gamepad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},start:function(){if(!this._active){this._active=!0;var t=this;this._onGamepadConnected=function(e){return t.onGamepadConnected(e)},this._onGamepadDisconnected=function(e){return t.onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(t){var e=t.gamepad;this._rawPads.push(e),this._gamepads[e.index].connect(e)},onGamepadDisconnected:function(t){var e=t.gamepad;for(var i in this._rawPads)this._rawPads[i].index===e.index&&this._rawPads.splice(i,1);this._gamepads[e.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)t=navigator.getGamepads();else if(navigator.webkitGetGamepads)t=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var t=navigator.webkitGamepads();if(t){this._rawPads=[];for(var e=!1,i=0;i<t.length&&(typeof t[i]!==this._prevRawGamepadTypes[i]&&(e=!0,this._prevRawGamepadTypes[i]=typeof t[i]),t[i]&&this._rawPads.push(t[i]),3!==i);i++);for(var s=0;s<this._gamepads.length;s++)this._gamepads[s]._rawPad=this._rawPads[s];if(e){for(var n,o={rawIndices:{},padIndices:{}},r=0;r<this._gamepads.length;r++)if((n=this._gamepads[r]).connected)for(var a=0;a<this._rawPads.length;a++)this._rawPads[a].index===n.index&&(o.rawIndices[n.index]=!0,o.padIndices[r]=!0);for(var h=0;h<this._gamepads.length;h++)if(n=this._gamepads[h],!o.padIndices[h]){this._rawPads.length<1&&n.disconnect();for(var l=0;l<this._rawPads.length&&!o.padIndices[h];l++){var c=this._rawPads[l];if(c){if(o.rawIndices[c.index]){n.disconnect();continue}n.connect(c),o.rawIndices[c.index]=!0,o.padIndices[h]=!0}else n.disconnect()}}}}}},setDeadZones:function(t){for(var e=0;e<this._gamepads.length;e++)this._gamepads[e].deadZone=t},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].reset()},justPressed:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justPressed(t,e))return!0;return!1},justReleased:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justReleased(t,e))return!0;return!1},isDown:function(t){for(var e=0;e<this._gamepads.length;e++)if(!0===this._gamepads[e].isDown(t))return!0;return!1},destroy:function(){this.stop();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].destroy()}},e.Gamepad.prototype.constructor=e.Gamepad,Object.defineProperty(e.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(e.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(e.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(e.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(e.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(e.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(e.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),e.Gamepad.BUTTON_0=0,e.Gamepad.BUTTON_1=1,e.Gamepad.BUTTON_2=2,e.Gamepad.BUTTON_3=3,e.Gamepad.BUTTON_4=4,e.Gamepad.BUTTON_5=5,e.Gamepad.BUTTON_6=6,e.Gamepad.BUTTON_7=7,e.Gamepad.BUTTON_8=8,e.Gamepad.BUTTON_9=9,e.Gamepad.BUTTON_10=10,e.Gamepad.BUTTON_11=11,e.Gamepad.BUTTON_12=12,e.Gamepad.BUTTON_13=13,e.Gamepad.BUTTON_14=14,e.Gamepad.BUTTON_15=15,e.Gamepad.AXIS_0=0,e.Gamepad.AXIS_1=1,e.Gamepad.AXIS_2=2,e.Gamepad.AXIS_3=3,e.Gamepad.AXIS_4=4,e.Gamepad.AXIS_5=5,e.Gamepad.AXIS_6=6,e.Gamepad.AXIS_7=7,e.Gamepad.AXIS_8=8,e.Gamepad.AXIS_9=9,e.Gamepad.XBOX360_A=0,e.Gamepad.XBOX360_B=1,e.Gamepad.XBOX360_X=2,e.Gamepad.XBOX360_Y=3,e.Gamepad.XBOX360_LEFT_BUMPER=4,e.Gamepad.XBOX360_RIGHT_BUMPER=5,e.Gamepad.XBOX360_LEFT_TRIGGER=6,e.Gamepad.XBOX360_RIGHT_TRIGGER=7,e.Gamepad.XBOX360_BACK=8,e.Gamepad.XBOX360_START=9,e.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,e.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,e.Gamepad.XBOX360_DPAD_LEFT=14,e.Gamepad.XBOX360_DPAD_RIGHT=15,e.Gamepad.XBOX360_DPAD_UP=12,e.Gamepad.XBOX360_DPAD_DOWN=13,e.Gamepad.XBOX360_STICK_LEFT_X=0,e.Gamepad.XBOX360_STICK_LEFT_Y=1,e.Gamepad.XBOX360_STICK_RIGHT_X=2,e.Gamepad.XBOX360_STICK_RIGHT_Y=3,e.Gamepad.PS3XC_X=0,e.Gamepad.PS3XC_CIRCLE=1,e.Gamepad.PS3XC_SQUARE=2,e.Gamepad.PS3XC_TRIANGLE=3,e.Gamepad.PS3XC_L1=4,e.Gamepad.PS3XC_R1=5,e.Gamepad.PS3XC_L2=6,e.Gamepad.PS3XC_R2=7,e.Gamepad.PS3XC_SELECT=8,e.Gamepad.PS3XC_START=9,e.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,e.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,e.Gamepad.PS3XC_DPAD_UP=12,e.Gamepad.PS3XC_DPAD_DOWN=13,e.Gamepad.PS3XC_DPAD_LEFT=14,e.Gamepad.PS3XC_DPAD_RIGHT=15,e.Gamepad.PS3XC_STICK_LEFT_X=0,e.Gamepad.PS3XC_STICK_LEFT_Y=1,e.Gamepad.PS3XC_STICK_RIGHT_X=2,e.Gamepad.PS3XC_STICK_RIGHT_Y=3,e.SinglePad=function(t,e){this.game=t,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=e,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},e.SinglePad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},getButton:function(t){return this._buttons[t]?this._buttons[t]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&this._rawPad&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var t=0;t<this._buttonsLen;t++){var e=isNaN(this._rawPad.buttons[t])?this._rawPad.buttons[t].value:this._rawPad.buttons[t];e!==this._buttons[t].value&&(1===e?this.processButtonDown(t,e):0===e?this.processButtonUp(t,e):this.processButtonFloat(t,e))}for(var i=0;i<this._axesLen;i++){var s=this._rawPad.axes[i];s>0&&s>this.deadZone||s<0&&s<-this.deadZone?this.processAxisChange(i,s):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var i=!this.connected;this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length;for(var s=0;s<this._axesLen;s++)this._axes[s]=t.axes[s];for(var n in t.buttons)n=parseInt(n,10),this._buttons[n]=new e.DeviceButton(this,n);i&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),i&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var t=this.connected,e=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var i=0;i<this._buttonsLen;i++)this._buttons[i].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,t&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,e),t&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var t=0;t<this._buttonsLen;t++)this._buttons[t].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(t,e){this._axes[t]!==e&&(this._axes[t]=e,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,t,e),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,t,e))},processButtonDown:function(t,e){this._buttons[t]&&this._buttons[t].start(null,e),this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,t,e,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t,e)},processButtonUp:function(t,e){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,t,e,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].stop(null,e)},processButtonFloat:function(t,e){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,t,e,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].padFloat(e)},axis:function(t){return!!this._axes[t]&&this._axes[t]},isDown:function(t){return!!this._buttons[t]&&this._buttons[t].isDown},isUp:function(t){return!!this._buttons[t]&&this._buttons[t].isUp},justReleased:function(t,e){if(this._buttons[t])return this._buttons[t].justReleased(e)},justPressed:function(t,e){if(this._buttons[t])return this._buttons[t].justPressed(e)},buttonValue:function(t){return this._buttons[t]?this._buttons[t].value:null},reset:function(){for(var t=0;t<this._axes.length;t++)this._axes[t]=0}},e.SinglePad.prototype.constructor=e.SinglePad,e.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 e.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new e.Signal,this._justDown=!1,this._justUp=!1},e.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(t){this._enabled&&(this.event=t,this.isDown||(this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.shiftKey=t.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(t){this._enabled&&(this.event=t,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(t){void 0===t&&(t=!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,t&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(t){return void 0===t&&(t=50),this.isDown&&this.duration<t},upDuration:function(t){return void 0===t&&(t=50),!this.isDown&&this.game.time.time-this.timeUp<t},justPressed:function(){return this.isDown&&0===this.duration},justReleased:function(){return!this.isDown&&0===this.durationUp}},Object.defineProperty(e.Key.prototype,"justDown",{get:function(){var t=this._justDown;return this._justDown=!1,t}}),Object.defineProperty(e.Key.prototype,"justUp",{get:function(){var t=this._justUp;return this._justUp=!1,t}}),Object.defineProperty(e.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(t){(t=!!t)!==this._enabled&&(t||this.reset(!1),this._enabled=t)}}),e.Key.prototype.constructor=e.Key,e.Keyboard=function(t){this.game=t,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},e.Keyboard.prototype={addCallbacks:function(t,e,i,s){this.callbackContext=t,void 0!==e&&null!==e&&(this.onDownCallback=e),void 0!==i&&null!==i&&(this.onUpCallback=i),void 0!==s&&null!==s&&(this.onPressCallback=s)},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 e.Key(this.game,t),this.addKeyCapture(t)),this._keys[t]},addKeys:function(t){var e={};for(var i in t)e[i]=this.addKey(t[i]);return e},removeKey:function(t){this._keys[t]&&(this._keys[t]=null,this.removeKeyCapture(t))},createCursorKeys:function(){return this.addKeys({up:e.KeyCode.UP,down:e.KeyCode.DOWN,left:e.KeyCode.LEFT,right:e.KeyCode.RIGHT})},start:function(){if(this.game.device.cocoonJS)return!1;if(this.active)return!1;var t=this;return this._onKeyDown=function(e){return t.processKeyDown(e)},this._onKeyUp=function(e){return t.processKeyUp(e)},this._onKeyPress=function(e){return t.processKeyPress(e)},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(t){if("object"==typeof t)for(var e in t)this._capture[t[e]]=!0;else this._capture[t]=!0},removeKeyCapture:function(t){delete this._capture[t]},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 e.Key(this.game,i)),this._keys[i].processKeyDown(t),this._k=i,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t)}},processKeyPress:function(t){this.pressEvent=t,this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(t.charCode),t)},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 e.Key(this.game,i)),this._keys[i].processKeyUp(t),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t)}},reset:function(t){void 0===t&&(t=!0),this.event=null;for(var e=this._keys.length;e--;)this._keys[e]&&this._keys[e].reset(t)},downDuration:function(t,e){return this._keys[t]?this._keys[t].downDuration(e):null},upDuration:function(t,e){return this._keys[t]?this._keys[t].upDuration(e):null},justPressed:function(t){return this._keys[t]?this._keys[t].justPressed():null},justReleased:function(t){return this._keys[t]?this._keys[t].justReleased():null},isDown:function(t){return this._keys[t]?this._keys[t].isDown:null}},Object.defineProperty(e.Keyboard.prototype,"lastChar",{get:function(){return this.event&&32===this.event.charCode?"":this.pressEvent?String.fromCharCode(this.pressEvent.charCode):null}}),Object.defineProperty(e.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),e.Keyboard.prototype.constructor=e.Keyboard,e.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(var s in e.KeyCode)e.KeyCode.hasOwnProperty(s)&&!s.match(/[a-z]/)&&(e.Keyboard[s]=e.KeyCode[s]);e.Component=function(){},e.Component.Angle=function(){},e.Component.Angle.prototype={angle:{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(t){this.rotation=e.Math.degToRad(e.Math.wrapAngle(t))}}},e.Component.Animation=function(){},e.Component.Animation.prototype={play:function(t,e,i,s){if(this.animations)return this.animations.play(t,e,i,s)}},e.Component.AutoCull=function(){},e.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)}}},e.Component.Bounds=function(){},e.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(t){this.x=t+this.offsetX-.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+.5*this.height},set:function(t){this.y=t+this.offsetY-.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(t){this.x=t+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(t){this.x=t-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(t){this.y=t+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(t){this.y=t-this.height+this.offsetY}},alignIn:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.top=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.top=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.top=t.top-n;break;case e.LEFT_CENTER:this.left=t.left-s,this.centerY=t.centerY+n;break;case e.CENTER:this.centerX=t.centerX+s,this.centerY=t.centerY+n;break;case e.RIGHT_CENTER:this.right=t.right+s,this.centerY=t.centerY+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.bottom=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.bottom=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.bottom=t.bottom+n}return this},alignTo:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.bottom=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.bottom=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.bottom=t.top-n;break;case e.LEFT_TOP:this.right=t.left-s,this.top=t.top-n;break;case e.LEFT_CENTER:this.right=t.left-s,this.centerY=t.centerY+n;break;case e.LEFT_BOTTOM:this.right=t.left-s,this.bottom=t.bottom+n;break;case e.RIGHT_TOP:this.left=t.right+s,this.top=t.top-n;break;case e.RIGHT_CENTER:this.left=t.right+s,this.centerY=t.centerY+n;break;case e.RIGHT_BOTTOM:this.left=t.right+s,this.bottom=t.bottom+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.top=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.top=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.top=t.bottom+n}return this}},e.Group.prototype.alignIn=e.Component.Bounds.prototype.alignIn,e.Group.prototype.alignTo=e.Component.Bounds.prototype.alignTo,e.Component.BringToTop=function(){},e.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringChildToTop&&this.parent.bringChildToTop(this),this},e.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendChildToBack&&this.parent.sendChildToBack(this),this},e.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},e.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},e.Component.Core=function(){},e.Component.Core.install=function(t){e.Utils.mixinPrototype(this,e.Component.Core.prototype),this.components={};for(var i=0;i<t.length;i++){var s=t[i],n=!1;"Destroy"===s&&(n=!0),e.Utils.mixinPrototype(this,e.Component[s].prototype,n),this.components[s]=!0}},e.Component.Core.init=function(t,i,s,n,o){this.game=t,this.key=n,this.data={},this.position.set(i,s),this.world=new e.Point(i,s),this.previousPosition=new e.Point(i,s),this.events=new e.Events(this),this._bounds=new e.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new e.AnimationManager(this)),this.components.LoadTexture&&null!==n&&this.loadTexture(n,o),this.components.FixedToCamera&&(this.cameraOffset=new e.Point(i,s))},e.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))},e.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===e.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===e.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},preUpdateChildren:function(){for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&e.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&e.Component.FixedToCamera.postUpdate.call(this);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()}},e.Component.Crop=function(){},e.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):i&&null===this.cropRect?this.cropRect=new e.Rectangle(t.x,t.y,t.width,t.height):this.cropRect=t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var t=this.texture.crop.x,i=this.texture.crop.y,s=this.texture.crop.width,n=this.texture.crop.height;this._crop=e.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var o=Math.max(this._frame.x,this._crop.x),r=Math.max(this._frame.y,this._crop.y),a=Math.min(this._frame.right,this._crop.right)-o,h=Math.min(this._frame.bottom,this._crop.bottom)-r;this.texture.crop.x=o,this.texture.crop.y=r,this.texture.crop.width=a,this.texture.crop.height=h,this.texture.frame.width=Math.min(a,this.cropRect.width),this.texture.frame.height=Math.min(h,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||t===o&&i===r&&s===a&&n===h||(this.texture.requiresReTint=!0)}}},e.Component.Delta=function(){},e.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}}},e.Component.Destroy=function(){},e.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 e.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 s=this.children.length;if(t)for(;s--;)this.children[s].destroy(t);else for(;s--;)this.removeChild(this.children[s]);this._crop&&(this._crop=null,this.cropRect=null),this._frame&&(this._frame=null),e.Video&&this.key instanceof e.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),e.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(),this._destroyTintedTexture(),i&&this.texture.destroy(!0),this.destroyPhase=!1,this.pendingDestroy=!1}}},e.Events=function(t){this.parent=t},e.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},e.Events.prototype.constructor=e.Events;for(var n in e.Events.prototype)e.Events.prototype.hasOwnProperty(n)&&0===n.indexOf("on")&&null===e.Events.prototype[n]&&function(t,i){"use strict";Object.defineProperty(e.Events.prototype,t,{get:function(){return this[i]||(this[i]=new e.Signal)}}),e.Events.prototype[t+"$dispatch"]=function(){return this[i]?this[i].dispatch.apply(this[i],arguments):null}}(n,"_"+n);e.Component.FixedToCamera=function(){},e.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)},e.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(t){t?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new e.Point},e.Component.Health=function(){},e.Component.Health.prototype={health:1,maxHealth:100,damage:function(t){return this.alive&&(this.health-=t,this.health<=0&&this.kill()),this},setHealth:function(t){return this.health=t,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(t){return this.alive&&(this.health+=t,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},e.Component.InCamera=function(){},e.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},e.Component.InputEnabled=function(){},e.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new e.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},e.Component.InWorld=function(){},e.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},e.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},e.Component.LifeSpan=function(){},e.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)},e.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(t){return void 0===t&&(t=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(t),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}},e.Component.LoadTexture=function(){},e.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,i,s){t===e.PENDING_ATLAS?(t=i,i=0):i=i||0,(s||void 0===s)&&this.animations&&this.animations.stop(),this.key=t,this.customRender=!1;var n=this.game.cache,o=!0,r=this.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;if(e.RenderTexture&&t instanceof e.RenderTexture)this.key=t.key,this.setTexture(t);else if(e.BitmapData&&t instanceof e.BitmapData)this.customRender=!0,this.setTexture(t.texture),o=n.hasFrameData(t.key,e.Cache.BITMAPDATA)?!this.animations.loadFrameData(n.getFrameData(t.key,e.Cache.BITMAPDATA),i):!this.animations.loadFrameData(t.frameData,0);else if(e.Video&&t instanceof e.Video){this.customRender=!0;var a=t.texture.valid;this.setTexture(t.texture),this.setFrame(t.texture.frame.clone()),t.onChangeSource.add(this.resizeFrame,this),this.texture.valid=a}else if(e.Tilemap&&t instanceof e.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(t.canvas));else if(t instanceof PIXI.Texture)r=t.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,this.setTexture(t);else{var h=n.getImage(t,!0);this.key=h.key,this.setTexture(new PIXI.Texture(h.base)),this.texture.baseTexture.skipRender="__default"===t,o=!this.animations.loadFrameData(h.frameData,i)}o&&(this._frame=e.Rectangle.clone(this.texture.frame)),r||(this.texture.baseTexture.scaleMode=1)},setFrame:function(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),t.rotated&&(this.texture.rotated=!0),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(t){this.animations.frame=t}},frameName:{get:function(){return this.animations.frameName},set:function(t){this.animations.frameName=t}}},e.Component.Overlap=function(){},e.Component.Overlap.prototype={overlap:function(t){return e.Rectangle.intersects(this.getBounds(),t.getBounds())}},e.Component.PhysicsBody=function(){},e.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))},e.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},e.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(t){this.position.x=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},e.Component.Reset=function(){},e.Component.Reset.prototype.reset=function(t,e,i){return void 0===i&&(i=1),this.world.set(t,e),this.position.set(t,e),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(t,e,!1,!1),this},e.Component.ScaleMinMax=function(){},e.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(t){this.scaleMin&&(t.a<this.scaleMin.x&&(t.a=this.scaleMin.x),t.d<this.scaleMin.y&&(t.d=this.scaleMin.y)),this.scaleMax&&(t.a>this.scaleMax.x&&(t.a=this.scaleMax.x),t.d>this.scaleMax.y&&(t.d=this.scaleMax.y))},setScaleMinMax:function(t,i,s,n){void 0===i?i=s=n=t:void 0===s&&(s=n=i,i=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,i):this.scaleMin=new e.Point(t,i),null===s?this.scaleMax=null:this.scaleMax?this.scaleMax.set(s,n):this.scaleMax=new e.Point(s,n),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},e.Component.Smoothed=function(){},e.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?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())}}},e.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,i,s,n,o){var r=this.game.plugins.add(e.Weapon);return o&&(r.bulletClass=o),r.createBullets(t,i,s,n),r},image:function(t,i,s,n,o){return void 0===o&&(o=this.world),o.add(new e.Image(this.game,t,i,s,n))},sprite:function(t,i,s,n,o){return void 0===o&&(o=this.world),o.add(new e.Sprite(this.game,t,i,s,n))},creature:function(t,i,s,n,o,r,a){void 0===o&&(o=this.world);var h=new e.Creature(this.game,t,i,s,n,r,a);return o.add(h),h},tween:function(t){return this.game.tweens.create(t)},group:function(t,i,s,n,o){return new e.Group(this.game,t,i,s,n,o)},physicsGroup:function(t,i,s,n){return new e.Group(this.game,i,s,n,!0,t)},spriteBatch:function(t,i,s){return void 0===t&&(t=null),void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},tileSprite:function(t,i,s,n,o,r,a){return void 0===a&&(a=this.world),a.add(new e.TileSprite(this.game,t,i,s,n,o,r))},rope:function(t,i,s,n,o,r){return void 0===r&&(r=this.world),r.add(new e.Rope(this.game,t,i,s,n,o))},text:function(t,i,s,n,o){return void 0===o&&(o=this.world),o.add(new e.Text(this.game,t,i,s,n))},button:function(t,i,s,n,o,r,a,h,l,c){return void 0===c&&(c=this.world),c.add(new e.Button(this.game,t,i,s,n,o,r,a,h,l))},graphics:function(t,i,s){return void 0===s&&(s=this.world),s.add(new e.Graphics(this.game,t,i))},emitter:function(t,i,s){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,t,i,s))},retroFont:function(t,i,s,n,o,r,a,h,l){return new e.RetroFont(this.game,t,i,s,n,o,r,a,h,l)},bitmapText:function(t,i,s,n,o,r){return void 0===r&&(r=this.world),r.add(new e.BitmapText(this.game,t,i,s,n,o))},tilemap:function(t,i,s,n,o){return new e.Tilemap(this.game,t,i,s,n,o)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var o=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,o),o},video:function(t,i){return new e.Video(this.game,t,i)},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var o=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,o),o},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},e.GameObjectFactory.prototype.constructor=e.GameObjectFactory,e.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},e.GameObjectCreator.prototype={image:function(t,i,s,n){return new e.Image(this.game,t,i,s,n)},sprite:function(t,i,s,n){return new e.Sprite(this.game,t,i,s,n)},tween:function(t){return new e.Tween(t,this.game,this.game.tweens)},group:function(t,i,s,n,o){return new e.Group(this.game,t||null,i,s,n,o)},spriteBatch:function(t,i,s){return void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},tileSprite:function(t,i,s,n,o,r){return new e.TileSprite(this.game,t,i,s,n,o,r)},rope:function(t,i,s,n,o){return new e.Rope(this.game,t,i,s,n,o)},text:function(t,i,s,n){return new e.Text(this.game,t,i,s,n)},button:function(t,i,s,n,o,r,a,h,l){return new e.Button(this.game,t,i,s,n,o,r,a,h,l)},graphics:function(t,i){return new e.Graphics(this.game,t,i)},emitter:function(t,i,s){return new e.Particles.Arcade.Emitter(this.game,t,i,s)},retroFont:function(t,i,s,n,o,r,a,h,l){return new e.RetroFont(this.game,t,i,s,n,o,r,a,h,l)},bitmapText:function(t,i,s,n,o,r){return new e.BitmapText(this.game,t,i,s,n,o,r)},tilemap:function(t,i,s,n,o){return new e.Tilemap(this.game,t,i,s,n,o)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var o=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,o),o},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var o=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,o),o},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t}},e.GameObjectCreator.prototype.constructor=e.GameObjectCreator,e.Sprite=function(t,i,s,n,o){i=i||0,s=s||0,n=n||null,o=o||null,this.type=e.SPRITE,this.physicsType=e.SPRITE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,o)},e.Sprite.prototype=Object.create(PIXI.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Component.Core.install.call(e.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Sprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Sprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Sprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Sprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Image=function(t,i,s,n,o){i=i||0,s=s||0,n=n||null,o=o||null,this.type=e.IMAGE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,o)},e.Image.prototype=Object.create(PIXI.Sprite.prototype),e.Image.prototype.constructor=e.Image,e.Component.Core.install.call(e.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),e.Image.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Image.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Image.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},e.Button=function(t,i,s,n,o,r,a,h,l,c){i=i||0,s=s||0,n=n||null,o=o||null,r=r||this,e.Image.call(this,t,i,s,n,h),this.type=e.BUTTON,this.physicsType=e.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 e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=e.PointerMode.CONTACT,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,h,l,c),null!==o&&this.onInputUp.add(o,r),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)},e.Button.prototype=Object.create(e.Image.prototype),e.Button.prototype.constructor=e.Button;return e.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},e.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},e.Button.prototype.changeStateFrame=function(t){if(this.freezeFrames)return!1;var e=this["_on"+t+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)},e.Button.prototype.setFrames=function(t,e,i,s){this.setStateFrame("Over",t,this.input.pointerOver()),this.setStateFrame("Out",e,!this.input.pointerOver()),this.setStateFrame("Down",i,this.input.pointerDown()),this.setStateFrame("Up",s,this.input.pointerUp())},e.Button.prototype.setStateSound=function(t,i,s){var n="on"+t+"Sound",o="on"+t+"SoundMarker";i instanceof e.Sound||i instanceof e.AudioSprite?(this[n]=i,this[o]="string"==typeof s?s:""):(this[n]=null,this[o]="")},e.Button.prototype.playStateSound=function(t){var e=this["on"+t+"Sound"];if(e){var i=this["on"+t+"SoundMarker"];return e.play(i),!0}return!1},e.Button.prototype.setSounds=function(t,e,i,s,n,o,r,a){this.setStateSound("Over",t,e),this.setStateSound("Out",n,o),this.setStateSound("Down",i,s),this.setStateSound("Up",r,a)},e.Button.prototype.setOverSound=function(t,e){this.setStateSound("Over",t,e)},e.Button.prototype.setOutSound=function(t,e){this.setStateSound("Out",t,e)},e.Button.prototype.setDownSound=function(t,e){this.setStateSound("Down",t,e)},e.Button.prototype.setUpSound=function(t,e){this.setStateSound("Up",t,e)},e.Button.prototype.onInputOverHandler=function(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame("Over"),this.onOverMouseOnly&&!e.isMouse||(this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,e)))},e.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame("Out"),this.playStateSound("Out"),this.onInputOut&&this.onInputOut.dispatch(this,e)},e.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame("Down"),this.playStateSound("Down"),this.onInputDown&&this.onInputDown.dispatch(this,e)},e.Button.prototype.onInputUpHandler=function(t,e,i){this.playStateSound("Up"),this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(i?this.changeStateFrame("Over"):this.changeStateFrame("Out")))},e.SpriteBatch=function(t,i,s,n){void 0!==i&&null!==i||(i=t.world),e.Group.call(this,t,i,s,n),this.type=e.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},e.SpriteBatch.prototype=Object.create(e.Group.prototype),e.SpriteBatch.prototype.constructor=e.SpriteBatch,e.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(t.gl),this.ready=!0),this.fastSpriteBatch.gl!==t.gl&&this.fastSpriteBatch.setContext(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},e.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,s=!0,n=0;n<this.children.length;n++){var o=this.children[n];if(o.visible){var r=o.texture,a=r.frame;if(e.globalAlpha=this.worldAlpha*o.alpha,o.rotation%(2*Math.PI)==0)s&&(e.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),s=!1),e.drawImage(r.baseTexture.source,a.x,a.y,a.width,a.height,o.anchor.x*(-a.width*o.scale.x)+o.position.x+.5+t.shakeX|0,o.anchor.y*(-a.height*o.scale.y)+o.position.y+.5+t.shakeY|0,a.width*o.scale.x,a.height*o.scale.y);else{s||(s=!0),o.displayObjectUpdateTransform();var h=o.worldTransform,l=h.tx*t.resolution+t.shakeX,c=h.ty*t.resolution+t.shakeY;t.roundPixels?e.setTransform(h.a,h.b,h.c,h.d,0|l,0|c):e.setTransform(h.a,h.b,h.c,h.d,l,c),e.drawImage(r.baseTexture.source,a.x,a.y,a.width,a.height,o.anchor.x*-a.width+.5|0,o.anchor.y*-a.height+.5|0,a.width,a.height)}}}}},e.BitmapData=function(t,i,s,n,o){void 0!==s&&0!==s||(s=256),void 0!==n&&0!==n||(n=256),void 0===o&&(o=!1),this.game=t,this.key=i,this.width=s,this.height=n,this.canvas=e.Canvas.create(this,s,n,null,o),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=t.renderType===e.CANVAS?t.renderer.renderSession.smoothProperty:e.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,s,n),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 e.FrameData,this.textureFrame=this.frameData.addFrame(new e.Frame(0,0,0,s,n,"bitmapData")),this.texture.frame=this.textureFrame,this.type=e.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new e.Point,this._size=new e.Point,this._scale=new e.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new e.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new e.Circle,this._swapCanvas=void 0},e.BitmapData.prototype={move:function(t,e,i){return 0!==t&&this.moveH(t,i),0!==e&&this.moveV(e,i),this},moveH:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.height,o=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);r=this.width-t;i&&s.drawImage(o,0,0,t,n,r,0,t,n),s.drawImage(o,t,0,r,n,0,0,r,n)}else{var r=this.width-t;i&&s.drawImage(o,r,0,t,n,0,0,t,n),s.drawImage(o,0,0,r,n,t,0,r,n)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.width,o=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);r=this.height-t;i&&s.drawImage(o,0,0,n,t,0,r,n,t),s.drawImage(o,0,t,n,r,0,0,n,r)}else{var r=this.height-t;i&&s.drawImage(o,0,r,n,t,0,0,n,t),s.drawImage(o,0,0,n,r,0,t,n,r)}return this.clear(),this.copy(this._swapCanvas)},add:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},load:function(t){if("string"==typeof t&&(t=this.game.cache.getImage(t)),t)return this.resize(t.width,t.height),this.cls(),this.draw(t),this.update(),this},clear:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=this.height),this.context.clearRect(t,e,i,s),this.dirty=!0,this},fill:function(t,e,i,s){return void 0===s&&(s=1),this.context.fillStyle="rgba("+t+","+e+","+i+","+s+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},getBase64:function(t,e){return this.canvas.toDataURL(t,e)},getImage:function(t,e,i,s){var n=new Image;return i&&(n.onload=i),s&&(n.onerror=s),n.src=this.getBase64(t,e),n},generateTexture:function(t,e,i){var s=this.game.cache,n=new Image;if(e&&(n.onload=function(){var o=s.addImage(t,"",n),r=new PIXI.Texture(o.base);e.call(i||null,r),n.onload=null}),n.src=this.getBase64(),!e){var o=s.addImage(t,"",n);return new PIXI.Texture(o.base)}return null},resize:function(t,e){return t===this.width&&e===this.height||(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e,void 0!==this._swapCanvas&&(this._swapCanvas.width=t,this._swapCanvas.height=e),this.baseTexture.width=t,this.baseTexture.height=e,this.textureFrame.width=t,this.textureFrame.height=e,this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.update(),this.dirty=!0),this},update:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=Math.max(1,this.width)),void 0===s&&(s=Math.max(1,this.height)),this.imageData=this.context.getImageData(t,e,i,s),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,s,n,o,r){void 0===s&&(s=0),void 0===n&&(n=0),void 0===o&&(o=this.width),void 0===r&&(r=this.height);for(var a=s+o,h=n+r,l=e.Color.createColor(),c={r:0,g:0,b:0,a:0},u=!1,d=n;d<h;d++)for(var p=s;p<a;p++)e.Color.unpackPixel(this.getPixel32(p,d),l),!1!==(c=t.call(i,l,p,d))&&null!==c&&void 0!==c&&(this.setPixel32(p,d,c.r,c.g,c.b,c.a,!1),u=!0);return u&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(t,e,i,s,n,o){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===o&&(o=this.height);for(var r=i+n,a=s+o,h=0,l=0,c=!1,u=s;u<a;u++)for(var d=i;d<r;d++)h=this.getPixel32(d,u),(l=t.call(e,h,d,u))!==h&&(this.pixels[u*this.width+d]=l,c=!0);return c&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(t,i,s,n,o,r,a,h,l){var c=0,u=0,d=this.width,p=this.height,f=e.Color.packPixel(t,i,s,n);void 0!==l&&l instanceof e.Rectangle&&(c=l.x,u=l.y,d=l.width,p=l.height);for(var g=0;g<p;g++)for(var m=0;m<d;m++)this.getPixel32(c+m,u+g)===f&&this.setPixel32(c+m,u+g,o,r,a,h,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(t,i,s,n){var o=t||0===t,r=i||0===i,a=s||0===s;if(o||r||a){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var h=e.Color.createColor(),l=n.y;l<n.bottom;l++)for(var c=n.x;c<n.right;c++)e.Color.unpackPixel(this.getPixel32(c,l),h,!0),o&&(h.h=t),r&&(h.s=i),a&&(h.l=s),e.Color.HSLtoRGB(h.h,h.s,h.l,h),this.setPixel32(c,l,h.r,h.g,h.b,h.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(t,i,s,n){if(void 0!==t&&null!==t||(t=!1),void 0!==i&&null!==i||(i=!1),void 0!==s&&null!==s||(s=!1),t||i||s){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var o=e.Color.createColor(),r=n.y;r<n.bottom;r++)for(var a=n.x;a<n.right;a++)e.Color.unpackPixel(this.getPixel32(a,r),o,!0),t&&(o.h=this.game.math.wrap(o.h+t,0,1)),i&&(o.s=this.game.math.clamp(o.s+i,0,1)),s&&(o.l=this.game.math.clamp(o.l+s,0,1)),e.Color.HSLtoRGB(o.h,o.s,o.l,o),this.setPixel32(a,r,o.r,o.g,o.b,o.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(t,i,s,n,o,r,a){return void 0===a&&(a=!0),t>=0&&t<=this.width&&i>=0&&i<=this.height&&(e.Device.LITTLE_ENDIAN?this.pixels[i*this.width+t]=r<<24|o<<16|n<<8|s:this.pixels[i*this.width+t]=s<<24|n<<16|o<<8|r,a&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(t,e,i,s,n,o){return this.setPixel32(t,e,i,s,n,255,o)},getPixel:function(t,i,s){s||(s=e.Color.createColor());var n=~~(t+i*this.width);return n*=4,s.r=this.data[n],s.g=this.data[++n],s.b=this.data[++n],s.a=this.data[++n],s},getPixel32:function(t,e){if(t>=0&&t<=this.width&&e>=0&&e<=this.height)return this.pixels[e*this.width+t]},getPixelRGB:function(t,i,s,n,o){return e.Color.unpackPixel(this.getPixel32(t,i),s,n,o)},getPixels:function(t){return this.context.getImageData(t.x,t.y,t.width,t.height)},getFirstPixel:function(t){void 0===t&&(t=0);var i=e.Color.createColor(),s=0,n=0,o=1,r=!1;1===t?(o=-1,n=this.height):3===t&&(o=-1,s=this.width);do{e.Color.unpackPixel(this.getPixel32(s,n),i),0===t||1===t?++s===this.width&&(s=0,((n+=o)>=this.height||n<=0)&&(r=!0)):2!==t&&3!==t||++n===this.height&&(n=0,((s+=o)>=this.width||s<=0)&&(r=!0))}while(0===i.a&&!r);return i.x=s,i.y=n,i},getBounds:function(t){return void 0===t&&(t=new e.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(t,e,i,s,n,o){n=n||1,o=o||1;var r=this.game.add.image(t,e,this);return r.anchor.set(i,s),r.scale.set(n,o),r},copy:function(t,i,s,n,o,r,a,h,l,c,u,d,p,f,g,m,y){if(void 0!==t&&null!==t||(t=this),t instanceof e.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof e.Sprite||t instanceof e.Image||t instanceof e.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,t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source,void 0!==r&&null!==r||(r=t.x),void 0!==a&&null!==a||(a=t.y),t.texture.trim&&(r+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,a+=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 e.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!==s&&null!==s||(s=0),n&&(this._size.x=n),o&&(this._size.y=o),void 0!==r&&null!==r||(r=i),void 0!==a&&null!==a||(a=s),void 0!==h&&null!==h||(h=this._size.x),void 0!==l&&null!==l||(l=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof u&&(this._anchor.x=u),"number"==typeof d&&(this._anchor.y=d),"number"==typeof p&&(this._scale.x=p),"number"==typeof f&&(this._scale.y=f),"number"==typeof g&&(this._alpha.current=g),void 0===m&&(m=null),void 0===y&&(y=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var v=this.context;return this._alpha.prev=v.globalAlpha,v.save(),v.globalAlpha=this._alpha.current,m&&(this.op=m),y&&(r|=0,a|=0),v.translate(r,a),v.scale(this._scale.x,this._scale.y),v.rotate(this._rotate),v.drawImage(this._image,this._pos.x+i,this._pos.y+s,this._size.x,this._size.y,-h*this._anchor.x,-l*this._anchor.y,h,l),v.restore(),v.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)return this;var n=t.worldTransform;if(this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===n.a||0===n.d||0===this._size.x||0===this._size.y)return this;t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source;var o=n.tx,r=n.ty;t.texture.trim&&(o+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,r+=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)),s&&(o|=0,r|=0);var a=this.context;return this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,i&&(this.op=i),a[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,a.setTransform(n.a,n.b,n.c,n.d,o,r),a.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),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(t,e,i,s,n,o,r){return this.copy(t,e.x,e.y,e.width,e.height,i,s,e.width,e.height,0,0,0,1,1,n,o,r)},draw:function(t,e,i,s,n,o,r){return this.copy(t,null,null,null,null,e,i,s,n,null,null,null,null,null,null,o,r)},drawGroup:function(t,e,i){return t.total>0&&t.forEachExists(this.drawGroupProxy,this,e,i),this},drawGroupProxy:function(t,i,s){if(t.hasOwnProperty("texture")&&this.copyTransform(t,i,s),t.type===e.GROUP&&t.exists)this.drawGroup(t,i,s);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var n=0;n<t.children.length;n++)t.children[n].exists&&this.copyTransform(t.children[n],i,s)},drawFull:function(t,i,s){if(!1===t.worldVisible||0===t.worldAlpha||t.hasOwnProperty("exists")&&!1===t.exists)return this;if(t.type!==e.GROUP&&t.type!==e.EMITTER&&t.type!==e.BITMAPTEXT)if(t.type===e.GRAPHICS){var n=t.getBounds();this.ctx.save(),this.ctx.translate(n.x,n.y),PIXI.CanvasGraphics.renderGraphics(t,this.ctx),this.ctx.restore()}else 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,s);if(t.children)for(var o=0;o<t.children.length;o++)this.drawFull(t.children[o],i,s);return this},shadow:function(t,e,i,s){var n=this.context;return void 0===t||null===t?n.shadowColor="rgba(0,0,0,0)":(n.shadowColor=t,n.shadowBlur=0===e?0:e||5,n.shadowOffsetX=0===i?0:i||10,n.shadowOffsetY=0===s?0:s||10),this},alphaMask:function(t,e,i,s){return void 0===s||null===s?this.draw(e).blendSourceAtop():this.draw(e,s.x,s.y,s.width,s.height).blendSourceAtop(),void 0===i||null===i?this.draw(t).blendReset():this.draw(t,i.x,i.y,i.width,i.height).blendReset(),this},extract:function(t,e,i,s,n,o,r,a,h){return void 0===n&&(n=255),void 0===o&&(o=!1),void 0===r&&(r=e),void 0===a&&(a=i),void 0===h&&(h=s),o&&t.resize(this.width,this.height),this.processPixelRGB(function(o,l,c){return o.r===e&&o.g===i&&o.b===s&&t.setPixel32(l,c,r,a,h,n,!1),!1},this),t.context.putImageData(t.imageData,0,0),t.dirty=!0,t},rect:function(t,e,i,s,n){return void 0!==n&&(this.context.fillStyle=n),this.context.fillRect(t,e,i,s),this},text:function(t,e,i,s,n,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="14px Courier"),void 0===n&&(n="rgb(255,255,255)"),void 0===o&&(o=!0);var r=this.context,a=r.font;return r.font=s,o&&(r.fillStyle="rgb(0,0,0)",r.fillText(t,e+1,i+1)),r.fillStyle=n,r.fillText(t,e,i),r.font=a,this},circle:function(t,e,i,s){var n=this.context;return void 0!==s&&(n.fillStyle=s),n.beginPath(),n.arc(t,e,i,0,2*Math.PI,!1),n.closePath(),n.fill(),this},line:function(t,e,i,s,n,o){void 0===n&&(n="#fff"),void 0===o&&(o=1);var r=this.context;return r.beginPath(),r.moveTo(t,e),r.lineTo(i,s),r.lineWidth=o,r.strokeStyle=n,r.stroke(),r.closePath(),this},polygon:function(t,e,i,s){void 0===s&&(s="#fff"),void 0===i&&(i=0);var n=this.context;e&&(n.fillStyle=e),i&&(n.lineWidth=i,n.strokeStyle=s),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(var o=1,r=t.length;o<r;o++){var a=t[o];n.lineTo(a.x,a.y)}return n.closePath(),e&&n.fill(),i&&n.stroke(),this},textureLine:function(t,i,s){if(void 0===s&&(s="repeat-x"),"string"!=typeof i||(i=this.game.cache.getImage(i))){var n=t.length;"no-repeat"===s&&n>i.width&&(n=i.width);var o=this.context;return o.fillStyle=o.createPattern(i,s),this._circle=new e.Circle(t.start.x,t.start.y,i.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),o.save(),o.translate(this._pos.x,this._pos.y),o.rotate(t.angle),o.fillRect(0,0,n,i.height),o.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),e.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(t,e,i){t.update();for(var s,n=0;n<t.height;n++){s=(i+n)*this.width+e;for(var o=0;o<t.width;o++)this.pixels[s+o]=t.pixels[n*t.width+o]}return this}},Object.defineProperty(e.BitmapData.prototype,"smoothed",{get:function(){return e.Canvas.getSmoothingEnabled(this.context)},set:function(t){e.Canvas.setSmoothingEnabled(this.context,t)}}),Object.defineProperty(e.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(t){this.context.globalCompositeOperation=t}}),e.BitmapData.getTransform=function(t,e,i,s,n,o){return"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),"number"!=typeof i&&(i=1),"number"!=typeof s&&(s=1),"number"!=typeof n&&(n=0),"number"!=typeof o&&(o=0),{sx:i,sy:s,scaleX:i,scaleY:s,skewX:n,skewY:o,translateX:t,translateY:e,tx:t,ty:e}},e.BitmapData.prototype.constructor=e.BitmapData,e.EarCut={},e.EarCut.Triangulate=function(t,i,s){s=s||2;var n=i&&i.length,o=n?i[0]*s:t.length,r=e.EarCut.linkedList(t,0,o,s,!0),a=[];if(!r)return a;var h,l,c,u,d,p,f;if(n&&(r=e.EarCut.eliminateHoles(t,i,r,s)),t.length>80*s){h=c=t[0],l=u=t[1];for(var g=s;g<o;g+=s)d=t[g],p=t[g+1],d<h&&(h=d),p<l&&(l=p),d>c&&(c=d),p>u&&(u=p);f=Math.max(c-h,u-l)}return e.EarCut.earcutLinked(r,a,s,h,l,f),a},e.EarCut.linkedList=function(t,i,s,n,o){var r,a,h,l=0;for(r=i,a=s-n;r<s;r+=n)l+=(t[a]-t[r])*(t[r+1]+t[a+1]),a=r;if(o===l>0)for(r=i;r<s;r+=n)h=e.EarCut.insertNode(r,t[r],t[r+1],h);else for(r=s-n;r>=i;r-=n)h=e.EarCut.insertNode(r,t[r],t[r+1],h);return h},e.EarCut.filterPoints=function(t,i){if(!t)return t;i||(i=t);var s,n=t;do{if(s=!1,n.steiner||!e.EarCut.equals(n,n.next)&&0!==e.EarCut.area(n.prev,n,n.next))n=n.next;else{if(e.EarCut.removeNode(n),(n=i=n.prev)===n.next)return null;s=!0}}while(s||n!==i);return i},e.EarCut.earcutLinked=function(t,i,s,n,o,r,a){if(t){!a&&r&&e.EarCut.indexCurve(t,n,o,r);for(var h,l,c=t;t.prev!==t.next;)if(h=t.prev,l=t.next,r?e.EarCut.isEarHashed(t,n,o,r):e.EarCut.isEar(t))i.push(h.i/s),i.push(t.i/s),i.push(l.i/s),e.EarCut.removeNode(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?(t=e.EarCut.cureLocalIntersections(t,i,s),e.EarCut.earcutLinked(t,i,s,n,o,r,2)):2===a&&e.EarCut.splitEarcut(t,i,s,n,o,r):e.EarCut.earcutLinked(e.EarCut.filterPoints(t),i,s,n,o,r,1);break}}},e.EarCut.isEar=function(t){var i=t.prev,s=t,n=t.next;if(e.EarCut.area(i,s,n)>=0)return!1;for(var o=t.next.next;o!==t.prev;){if(e.EarCut.pointInTriangle(i.x,i.y,s.x,s.y,n.x,n.y,o.x,o.y)&&e.EarCut.area(o.prev,o,o.next)>=0)return!1;o=o.next}return!0},e.EarCut.isEarHashed=function(t,i,s,n){var o=t.prev,r=t,a=t.next;if(e.EarCut.area(o,r,a)>=0)return!1;for(var h=o.x<r.x?o.x<a.x?o.x:a.x:r.x<a.x?r.x:a.x,l=o.y<r.y?o.y<a.y?o.y:a.y:r.y<a.y?r.y:a.y,c=o.x>r.x?o.x>a.x?o.x:a.x:r.x>a.x?r.x:a.x,u=o.y>r.y?o.y>a.y?o.y:a.y:r.y>a.y?r.y:a.y,d=e.EarCut.zOrder(h,l,i,s,n),p=e.EarCut.zOrder(c,u,i,s,n),f=t.nextZ;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=d;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},e.EarCut.cureLocalIntersections=function(t,i,s){var n=t;do{var o=n.prev,r=n.next.next;e.EarCut.intersects(o,n,n.next,r)&&e.EarCut.locallyInside(o,r)&&e.EarCut.locallyInside(r,o)&&(i.push(o.i/s),i.push(n.i/s),i.push(r.i/s),e.EarCut.removeNode(n),e.EarCut.removeNode(n.next),n=t=r),n=n.next}while(n!==t);return n},e.EarCut.splitEarcut=function(t,i,s,n,o,r){var a=t;do{for(var h=a.next.next;h!==a.prev;){if(a.i!==h.i&&e.EarCut.isValidDiagonal(a,h)){var l=e.EarCut.splitPolygon(a,h);return a=e.EarCut.filterPoints(a,a.next),l=e.EarCut.filterPoints(l,l.next),e.EarCut.earcutLinked(a,i,s,n,o,r),void e.EarCut.earcutLinked(l,i,s,n,o,r)}h=h.next}a=a.next}while(a!==t)},e.EarCut.eliminateHoles=function(t,i,s,n){var o,r,a,h,l,c=[];for(o=0,r=i.length;o<r;o++)a=i[o]*n,h=o<r-1?i[o+1]*n:t.length,(l=e.EarCut.linkedList(t,a,h,n,!1))===l.next&&(l.steiner=!0),c.push(e.EarCut.getLeftmost(l));for(c.sort(e.EarCut.compareX),o=0;o<c.length;o++)e.EarCut.eliminateHole(c[o],s),s=e.EarCut.filterPoints(s,s.next);return s},e.EarCut.compareX=function(t,e){return t.x-e.x},e.EarCut.eliminateHole=function(t,i){if(i=e.EarCut.findHoleBridge(t,i)){var s=e.EarCut.splitPolygon(i,t);e.EarCut.filterPoints(s,s.next)}},e.EarCut.findHoleBridge=function(t,i){var s,n=i,o=t.x,r=t.y,a=-1/0;do{if(r<=n.y&&r>=n.next.y){var h=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);h<=o&&h>a&&(a=h,s=n.x<n.next.x?n:n.next)}n=n.next}while(n!==i);if(!s)return null;if(t.x===s.x)return s.prev;var l,c=s,u=1/0;for(n=s.next;n!==c;)o>=n.x&&n.x>=s.x&&e.EarCut.pointInTriangle(r<s.y?o:a,r,s.x,s.y,r<s.y?a:o,r,n.x,n.y)&&((l=Math.abs(r-n.y)/(o-n.x))<u||l===u&&n.x>s.x)&&e.EarCut.locallyInside(n,t)&&(s=n,u=l),n=n.next;return s},e.EarCut.indexCurve=function(t,i,s,n){var o=t;do{null===o.z&&(o.z=e.EarCut.zOrder(o.x,o.y,i,s,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,e.EarCut.sortLinked(o)},e.EarCut.sortLinked=function(t){var e,i,s,n,o,r,a,h,l=1;do{for(i=t,t=null,o=null,r=0;i;){for(r++,s=i,a=0,e=0;e<l&&(a++,s=s.nextZ);e++);for(h=l;a>0||h>0&&s;)0===a?(n=s,s=s.nextZ,h--):0!==h&&s?i.z<=s.z?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=s}o.nextZ=null,l*=2}while(r>1);return t},e.EarCut.zOrder=function(t,e,i,s,n){return t=32767*(t-i)/n,e=32767*(e-s)/n,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},e.EarCut.getLeftmost=function(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i},e.EarCut.pointInTriangle=function(t,e,i,s,n,o,r,a){return(n-r)*(e-a)-(t-r)*(o-a)>=0&&(t-r)*(s-a)-(i-r)*(e-a)>=0&&(i-r)*(o-a)-(n-r)*(s-a)>=0},e.EarCut.isValidDiagonal=function(t,i){return e.EarCut.equals(t,i)||t.next.i!==i.i&&t.prev.i!==i.i&&!e.EarCut.intersectsPolygon(t,i)&&e.EarCut.locallyInside(t,i)&&e.EarCut.locallyInside(i,t)&&e.EarCut.middleInside(t,i)},e.EarCut.area=function(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)},e.EarCut.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.EarCut.intersects=function(t,i,s,n){return e.EarCut.area(t,i,s)>0!=e.EarCut.area(t,i,n)>0&&e.EarCut.area(s,n,t)>0!=e.EarCut.area(s,n,i)>0},e.EarCut.intersectsPolygon=function(t,i){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==i.i&&s.next.i!==i.i&&e.EarCut.intersects(s,s.next,t,i))return!0;s=s.next}while(s!==t);return!1},e.EarCut.locallyInside=function(t,i){return e.EarCut.area(t.prev,t,t.next)<0?e.EarCut.area(t,i,t.next)>=0&&e.EarCut.area(t,t.prev,i)>=0:e.EarCut.area(t,i,t.prev)<0||e.EarCut.area(t,t.next,i)<0},e.EarCut.middleInside=function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s},e.EarCut.splitPolygon=function(t,i){var s=new e.EarCut.Node(t.i,t.x,t.y),n=new e.EarCut.Node(i.i,i.x,i.y),o=t.next,r=i.prev;return t.next=i,i.prev=t,s.next=o,o.prev=s,n.next=s,s.prev=n,r.next=n,n.prev=r,n},e.EarCut.insertNode=function(t,i,s,n){var o=new e.EarCut.Node(t,i,s);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o},e.EarCut.removeNode=function(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)},e.EarCut.Node=function(t,e,i){this.i=t,this.x=e,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 s,n=i.gl,o=i.projection,r=i.offset,a=i.shaderManager.primitiveShader;t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,n);var h=t._webGL[n.id];if(h)for(var l=0;l<h.data.length;l++)1===h.data[l].mode?(s=h.data[l],i.stencilManager.pushStencil(t,s,i),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(s.indices.length-4)),i.stencilManager.popStencil(t,s,i)):(s=h.data[l],i.shaderManager.setShader(a),a=i.shaderManager.primitiveShader,n.uniformMatrix3fv(a.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(a.flipY,1),n.uniform2f(a.projectionVector,o.x,-o.y),n.uniform2f(a.offsetVector,-r.x,-r.y),n.uniform3fv(a.tintColor,e.Color.hexToRGBArray(t.tint)),n.uniform1f(a.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,s.buffer),n.vertexAttribPointer(a.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(a.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,s.indexBuffer),n.drawElements(n.TRIANGLE_STRIP,s.indices.length,n.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(t,i){var s=t._webGL[i.id];s||(s=t._webGL[i.id]={lastIndex:0,data:[],gl:i}),t.dirty=!1;var n;if(t.clearDirty){for(t.clearDirty=!1,n=0;n<s.data.length;n++){var o=s.data[n];o.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(o)}s.data=[],s.lastIndex=0}var r;for(n=s.lastIndex;n<t.graphicsData.length;n++){var a=t.graphicsData[n];a.type===e.POLYGON?(a.points=a.shape.points.slice(),a.shape.closed&&(a.points[0]===a.points[a.points.length-2]&&a.points[1]===a.points[a.points.length-1]||a.points.push(a.points[0],a.points[1])),a.fill&&a.points.length>=PIXI.WebGLGraphics.stencilBufferLimit&&(a.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(r=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildPoly(a,r)||(r=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,r))):(r=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,r))),a.lineWidth>0&&(r=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildLine(a,r))):(r=PIXI.WebGLGraphics.switchMode(s,0),a.type===e.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(a,r):a.type===e.CIRCLE||a.type===e.ELLIPSE?PIXI.WebGLGraphics.buildCircle(a,r):a.type===e.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(a,r)),s.lastIndex++}for(n=0;n<s.data.length;n++)(r=s.data[n]).dirty&&r.upload()},PIXI.WebGLGraphics.switchMode=function(t,e){var i;return t.data.length?(i=t.data[t.data.length-1]).mode===e&&1!==e||((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)):((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)),i.dirty=!0,i},PIXI.WebGLGraphics.buildRectangle=function(t,i){var s=t.shape,n=s.x,o=s.y,r=s.width,a=s.height;if(t.fill){var h=e.Color.hexToRGBArray(t.fillColor),l=t.fillAlpha,c=h[0]*l,u=h[1]*l,d=h[2]*l,p=i.points,f=i.indices,g=p.length/6;p.push(n,o),p.push(c,u,d,l),p.push(n+r,o),p.push(c,u,d,l),p.push(n,o+a),p.push(c,u,d,l),p.push(n+r,o+a),p.push(c,u,d,l),f.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var m=t.points;t.points=[n,o,n+r,o,n+r,o+a,n,o+a,n,o],PIXI.WebGLGraphics.buildLine(t,i),t.points=m}},PIXI.WebGLGraphics.buildRoundedRectangle=function(t,i){var s=t.shape,n=s.x,o=s.y,r=s.width,a=s.height,h=s.radius,l=[];if(l.push(n,o+h),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n,o+a-h,n,o+a,n+h,o+a)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+r-h,o+a,n+r,o+a,n+r,o+a-h)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+r,o+h,n+r,o,n+r-h,o)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+h,o,n,o,n,o+h)),t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6,v=e.EarCut.Triangulate(l,null,2),x=0;for(x=0;x<v.length;x+=3)m.push(v[x]+y),m.push(v[x]+y),m.push(v[x+1]+y),m.push(v[x+2]+y),m.push(v[x+2]+y);for(x=0;x<l.length;x++)g.push(l[x],l[++x],d,p,f,u)}if(t.lineWidth){var b=t.points;t.points=l,PIXI.WebGLGraphics.buildLine(t,i),t.points=b}},PIXI.WebGLGraphics.quadraticBezierCurve=function(t,e,i,s,n,o){function r(t,e,i){return t+(e-t)*i}for(var a,h,l,c,u,d,p=[],f=0,g=0;g<=20;g++)a=r(t,i,f=g/20),h=r(e,s,f),l=r(i,n,f),c=r(s,o,f),u=r(a,l,f),d=r(h,c,f),p.push(u,d);return p},PIXI.WebGLGraphics.buildCircle=function(t,i){var s,n,o=t.shape,r=o.x,a=o.y;t.type===e.CIRCLE?(s=o.radius,n=o.radius):(s=o.width,n=o.height);var h=2*Math.PI/40,l=0;if(t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6;for(m.push(y),l=0;l<41;l++)g.push(r,a,d,p,f,u),g.push(r+Math.sin(h*l)*s,a+Math.cos(h*l)*n,d,p,f,u),m.push(y++,y++);m.push(y-1)}if(t.lineWidth){var v=t.points;for(t.points=[],l=0;l<41;l++)t.points.push(r+Math.sin(h*l)*s,a+Math.cos(h*l)*n);PIXI.WebGLGraphics.buildLine(t,i),t.points=v}},PIXI.WebGLGraphics.buildLine=function(t,i){var s=0,n=t.points;if(0!==n.length){if(t.lineWidth%2)for(s=0;s<n.length;s++)n[s]+=.5;var o=new PIXI.Point(n[0],n[1]),r=new PIXI.Point(n[n.length-2],n[n.length-1]);if(o.x===r.x&&o.y===r.y){(n=n.slice()).pop(),n.pop();var a=(r=new PIXI.Point(n[n.length-2],n[n.length-1])).x+.5*(o.x-r.x),h=r.y+.5*(o.y-r.y);n.unshift(a,h),n.push(a,h)}var l,c,u,d,p,f,g,m,y,v,x,b,_,w,T,P,C,S,k,A,M,O,I=i.points,E=i.indices,L=n.length/2,R=n.length,D=I.length/6,B=t.lineWidth/2,F=e.Color.hexToRGBArray(t.lineColor),U=t.lineAlpha,G=F[0]*U,N=F[1]*U,X=F[2]*U;for(u=n[0],d=n[1],p=n[2],y=-(d-(f=n[3])),v=u-p,y/=O=Math.sqrt(y*y+v*v),v/=O,y*=B,v*=B,I.push(u-y,d-v,G,N,X,U),I.push(u+y,d+v,G,N,X,U),s=1;s<L-1;s++)u=n[2*(s-1)],d=n[2*(s-1)+1],p=n[2*s],f=n[2*s+1],g=n[2*(s+1)],m=n[2*(s+1)+1],y=-(d-f),v=u-p,y/=O=Math.sqrt(y*y+v*v),v/=O,y*=B,v*=B,x=-(f-m),b=p-g,x/=O=Math.sqrt(x*x+b*b),b/=O,C=(-y+u)*(-v+f)-(-y+p)*(-v+d),A=(-(x*=B)+g)*(-(b*=B)+f)-(-x+p)*(-b+m),M=(T=-v+d-(-v+f))*(k=-x+p-(-x+g))-(S=-b+m-(-b+f))*(P=-y+p-(-y+u)),Math.abs(M)<.1?(M+=10.1,I.push(p-y,f-v,G,N,X,U),I.push(p+y,f+v,G,N,X,U)):((l=(P*A-k*C)/M)-p)*(l-p)+((c=(S*C-T*A)/M)-f)+(c-f)>19600?(_=y-x,w=v-b,_/=O=Math.sqrt(_*_+w*w),w/=O,_*=B,w*=B,I.push(p-_,f-w),I.push(G,N,X,U),I.push(p+_,f+w),I.push(G,N,X,U),I.push(p-_,f-w),I.push(G,N,X,U),R++):(I.push(l,c),I.push(G,N,X,U),I.push(p-(l-p),f-(c-f)),I.push(G,N,X,U));for(u=n[2*(L-2)],d=n[2*(L-2)+1],p=n[2*(L-1)],y=-(d-(f=n[2*(L-1)+1])),v=u-p,y/=O=Math.sqrt(y*y+v*v),v/=O,y*=B,v*=B,I.push(p-y,f-v),I.push(G,N,X,U),I.push(p+y,f+v),I.push(G,N,X,U),E.push(D),s=0;s<R;s++)E.push(D++);E.push(D-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(t,i){var s=t.points.slice();if(!(s.length<6)){var n=i.indices;i.points=s,i.alpha=t.fillAlpha,i.color=e.Color.hexToRGBArray(t.fillColor);for(var o,r,a=1/0,h=-1/0,l=1/0,c=-1/0,u=0;u<s.length;u+=2)o=s[u],r=s[u+1],a=o<a?o:a,h=o>h?o:h,l=r<l?r:l,c=r>c?r:c;s.push(a,l,h,l,h,c,a,c);var d=s.length/2;for(u=0;u<d;u++)n.push(u)}},PIXI.WebGLGraphics.buildPoly=function(t,i){var s=t.points;if(!(s.length<6)){var n=i.points,o=i.indices,r=s.length/2,a=e.Color.hexToRGBArray(t.fillColor),h=t.fillAlpha,l=a[0]*h,c=a[1]*h,u=a[2]*h,d=e.EarCut.Triangulate(s,null,2);if(!d)return!1;var p=n.length/6,f=0;for(f=0;f<d.length;f+=3)o.push(d[f]+p),o.push(d[f]+p),o.push(d[f+1]+p),o.push(d[f+2]+p),o.push(d[f+2]+p);for(f=0;f<r;f++)n.push(s[2*f],s[2*f+1],l,c,u,h);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.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 t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(t,i){var s=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var n=0;n<t.graphicsData.length;n++){var o=t.graphicsData[n],r=o.shape,a=o._fillTint,h=o._lineTint;if(i.lineWidth=o.lineWidth,o.type===e.POLYGON){i.beginPath();var l=r.points;i.moveTo(l[0],l[1]);for(var c=1;c<l.length/2;c++)i.lineTo(l[2*c],l[2*c+1]);r.closed&&i.lineTo(l[0],l[1]),l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&i.closePath(),o.fill&&(i.globalAlpha=o.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),o.lineWidth&&(i.globalAlpha=o.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(o.type===e.RECTANGLE)(o.fillColor||0===o.fillColor)&&(i.globalAlpha=o.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fillRect(r.x,r.y,r.width,r.height)),o.lineWidth&&(i.globalAlpha=o.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.strokeRect(r.x,r.y,r.width,r.height));else if(o.type===e.CIRCLE)i.beginPath(),i.arc(r.x,r.y,r.radius,0,2*Math.PI),i.closePath(),o.fill&&(i.globalAlpha=o.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),o.lineWidth&&(i.globalAlpha=o.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke());else if(o.type===e.ELLIPSE){var u=2*r.width,d=2*r.height,p=r.x-u/2,f=r.y-d/2;i.beginPath();var g=u/2*.5522848,m=d/2*.5522848,y=p+u,v=f+d,x=p+u/2,b=f+d/2;i.moveTo(p,b),i.bezierCurveTo(p,b-m,x-g,f,x,f),i.bezierCurveTo(x+g,f,y,b-m,y,b),i.bezierCurveTo(y,b+m,x+g,v,x,v),i.bezierCurveTo(x-g,v,p,b+m,p,b),i.closePath(),o.fill&&(i.globalAlpha=o.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),o.lineWidth&&(i.globalAlpha=o.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(o.type===e.ROUNDEDRECTANGLE){var _=r.x,w=r.y,T=r.width,P=r.height,C=r.radius,S=Math.min(T,P)/2|0;C=C>S?S:C,i.beginPath(),i.moveTo(_,w+C),i.lineTo(_,w+P-C),i.quadraticCurveTo(_,w+P,_+C,w+P),i.lineTo(_+T-C,w+P),i.quadraticCurveTo(_+T,w+P,_+T,w+P-C),i.lineTo(_+T,w+C),i.quadraticCurveTo(_+T,w,_+T-C,w),i.lineTo(_+C,w),i.quadraticCurveTo(_,w,_,w+C),i.closePath(),(o.fillColor||0===o.fillColor)&&(i.globalAlpha=o.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),o.lineWidth&&(i.globalAlpha=o.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,i){var s=t.graphicsData.length;if(0!==s){i.beginPath();for(var n=0;n<s;n++){var o=t.graphicsData[n],r=o.shape;if(o.type===e.POLYGON){var a=r.points;i.moveTo(a[0],a[1]);for(var h=1;h<a.length/2;h++)i.lineTo(a[2*h],a[2*h+1]);a[0]===a[a.length-2]&&a[1]===a[a.length-1]&&i.closePath()}else if(o.type===e.RECTANGLE)i.rect(r.x,r.y,r.width,r.height),i.closePath();else if(o.type===e.CIRCLE)i.arc(r.x,r.y,r.radius,0,2*Math.PI),i.closePath();else if(o.type===e.ELLIPSE){var l=2*r.width,c=2*r.height,u=r.x-l/2,d=r.y-c/2,p=l/2*.5522848,f=c/2*.5522848,g=u+l,m=d+c,y=u+l/2,v=d+c/2;i.moveTo(u,v),i.bezierCurveTo(u,v-f,y-p,d,y,d),i.bezierCurveTo(y+p,d,g,v-f,g,v),i.bezierCurveTo(g,v+f,y+p,m,y,m),i.bezierCurveTo(y-p,m,u,v+f,u,v),i.closePath()}else if(o.type===e.ROUNDEDRECTANGLE){var x=r.x,b=r.y,_=r.width,w=r.height,T=r.radius,P=Math.min(_,w)/2|0;T=T>P?P:T,i.moveTo(x,b+T),i.lineTo(x,b+w-T),i.quadraticCurveTo(x,b+w,x+T,b+w),i.lineTo(x+_-T,b+w),i.quadraticCurveTo(x+_,b+w,x+_,b+w-T),i.lineTo(x+_,b+T),i.quadraticCurveTo(x+_,b,x+_-T,b),i.lineTo(x+T,b),i.quadraticCurveTo(x,b,x,b+T),i.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(t){if(16777215!==t.tint)for(var e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255,n=0;n<t.graphicsData.length;n++){var o=t.graphicsData[n],r=0|o.fillColor,a=0|o.lineColor;o._fillTint=((r>>16&255)/255*e*255<<16)+((r>>8&255)/255*i*255<<8)+(255&r)/255*s*255,o._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*s*255}},e.GraphicsData=function(t,e,i,s,n,o,r){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=o,this.shape=r,this.type=r.type},e.GraphicsData.prototype.constructor=e.GraphicsData,e.GraphicsData.prototype.clone=function(){return new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.Graphics=function(t,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.type=e.GRAPHICS,this.physicsType=e.SPRITE,this.anchor=new e.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 e.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Component.Core.install.call(e.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.Graphics.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Graphics.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Graphics.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Graphics.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Graphics.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.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()},e.Graphics.prototype.destroy=function(t){this.clear(),e.Component.Destroy.prototype.destroy.call(this,t)},e.Graphics.prototype.drawTriangle=function(t,i){void 0===i&&(i=!1);var s=new e.Polygon(t);if(i){var n=new e.Point(this.game.camera.x-t[0].x,this.game.camera.y-t[0].y),o=new e.Point(t[1].x-t[0].x,t[1].y-t[0].y),r=new e.Point(t[1].x-t[2].x,t[1].y-t[2].y).cross(o);n.dot(r)>0&&this.drawPolygon(s)}else this.drawPolygon(s)},e.Graphics.prototype.drawTriangles=function(t,i,s){void 0===s&&(s=!1);var n,o=new e.Point,r=new e.Point,a=new e.Point,h=[];if(i)if(t[0]instanceof e.Point)for(n=0;n<i.length/3;n++)h.push(t[i[3*n]]),h.push(t[i[3*n+1]]),h.push(t[i[3*n+2]]),3===h.length&&(this.drawTriangle(h,s),h=[]);else for(n=0;n<i.length;n++)o.x=t[2*i[n]],o.y=t[2*i[n]+1],h.push(o.copyTo({})),3===h.length&&(this.drawTriangle(h,s),h=[]);else if(t[0]instanceof e.Point)for(n=0;n<t.length/3;n++)this.drawTriangle([t[3*n],t[3*n+1],t[3*n+2]],s);else for(n=0;n<t.length/6;n++)o.x=t[6*n+0],o.y=t[6*n+1],r.x=t[6*n+2],r.y=t[6*n+3],a.x=t[6*n+4],a.y=t[6*n+5],this.drawTriangle([o,r,a],s)},e.Graphics.prototype.lineStyle=function(t,i,s){return this.lineWidth=t||0,this.lineColor=i||0,this.lineAlpha=void 0===s?1:s,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new e.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},e.Graphics.prototype.moveTo=function(t,i){return this.drawShape(new e.Polygon([t,i])),this},e.Graphics.prototype.lineTo=function(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.quadraticCurveTo=function(t,e,i,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var n,o,r=this.currentPath.shape.points;0===r.length&&this.moveTo(0,0);for(var a=r[r.length-2],h=r[r.length-1],l=0,c=1;c<=20;++c)n=a+(t-a)*(l=c/20),o=h+(e-h)*l,r.push(n+(t+(i-t)*l-n)*l,o+(e+(s-e)*l-o)*l);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.bezierCurveTo=function(t,e,i,s,n,o){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var r,a,h,l,c,u=this.currentPath.shape.points,d=u[u.length-2],p=u[u.length-1],f=0,g=1;g<=20;++g)h=(a=(r=1-(f=g/20))*r)*r,c=(l=f*f)*f,u.push(h*d+3*a*f*t+3*r*l*i+c*n,h*p+3*a*f*e+3*r*l*s+c*o);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arcTo=function(t,e,i,s,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var o=this.currentPath.shape.points,r=o[o.length-2],a=o[o.length-1]-e,h=r-t,l=s-e,c=i-t,u=Math.abs(a*c-h*l);if(u<1e-8||0===n)o[o.length-2]===t&&o[o.length-1]===e||o.push(t,e);else{var d=a*a+h*h,p=l*l+c*c,f=a*l+h*c,g=n*Math.sqrt(d)/u,m=n*Math.sqrt(p)/u,y=g*f/d,v=m*f/p,x=g*c+m*h,b=g*l+m*a,_=h*(m+y),w=a*(m+y),T=c*(g+v),P=l*(g+v),C=Math.atan2(w-b,_-x),S=Math.atan2(P-b,T-x);this.arc(x+t,b+e,n,C,S,h*l>c*a)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arc=function(t,e,i,s,n,o,r){if(s===n)return this;void 0===o&&(o=!1),void 0===r&&(r=40),!o&&n<=s?n+=2*Math.PI:o&&s<=n&&(s+=2*Math.PI);var a=o?-1*(s-n):n-s,h=Math.ceil(Math.abs(a)/(2*Math.PI))*r;if(0===a)return this;var l=t+Math.cos(s)*i,c=e+Math.sin(s)*i;o&&this.filling?this.moveTo(t,e):this.moveTo(l,c);for(var u=this.currentPath.shape.points,d=a/(2*h),p=2*d,f=Math.cos(d),g=Math.sin(d),m=h-1,y=m%1/m,v=0;v<=m;v++){var x=d+s+p*(v+y*v),b=Math.cos(x),_=-Math.sin(x);u.push((f*b+g*_)*i+t,(f*-_+g*b)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},e.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},e.Graphics.prototype.drawRect=function(t,i,s,n){return this.drawShape(new e.Rectangle(t,i,s,n)),this},e.Graphics.prototype.drawRoundedRect=function(t,i,s,n,o){return this.drawShape(new e.RoundedRectangle(t,i,s,n,o)),this},e.Graphics.prototype.drawCircle=function(t,i,s){return this.drawShape(new e.Circle(t,i,s)),this},e.Graphics.prototype.drawEllipse=function(t,i,s,n){return this.drawShape({x:t,y:i,width:s,height:n,type:e.ELLIPSE}),this},e.Graphics.prototype.drawPolygon=function(t){t instanceof e.Polygon&&(t=t.points);var i=t;if(!Array.isArray(i)){i=new Array(arguments.length);for(var s=0;s<i.length;++s)i[s]=arguments[s]}return this.drawShape(new e.Polygon(i)),this},e.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},e.Graphics.prototype.generateTexture=function(t,e,i){void 0===t&&(t=1),void 0===e&&(e=PIXI.scaleModes.DEFAULT),void 0===i&&(i=0);var s=this.getBounds();s.width+=i,s.height+=i;var n=new PIXI.CanvasBuffer(s.width*t,s.height*t),o=PIXI.Texture.fromCanvas(n.canvas,e);return o.baseTexture.resolution=t,n.context.scale(t,t),n.context.translate(-s.x,-s.y),PIXI.CanvasGraphics.renderGraphics(this,n.context),o},e.Graphics.prototype._renderWebGL=function(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,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=PIXI.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0;i<this.children.length;i++)this.children[i]._renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},e.Graphics.prototype._renderCanvas=function(t){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,t);var e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);var s=t.resolution,n=i.tx*t.resolution+t.shakeX,o=i.ty*t.resolution+t.shakeY;e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,o),PIXI.CanvasGraphics.renderGraphics(this,e);for(var r=0;r<this.children.length;r++)this.children[r]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},e.Graphics.prototype.getBounds=function(t){if(this._currentBounds)return this._currentBounds;if(this.isMask)return e.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var i=this._localBounds,s=i.x,n=i.width+i.x,o=i.y,r=i.height+i.y,a=t||this.worldTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,f=h*n+c*r+d,g=u*r+l*n+p,m=h*s+c*r+d,y=u*r+l*s+p,v=h*s+c*o+d,x=u*o+l*s+p,b=h*n+c*o+d,_=u*o+l*n+p,w=f,T=g,P=f,C=g;return P=m<P?m:P,P=v<P?v:P,P=b<P?b:P,C=y<C?y:C,C=x<C?x:C,C=_<C?_:C,w=m>w?m:w,w=v>w?v:w,w=b>w?b:w,T=y>T?y:T,T=x>T?x:T,T=_>T?_:T,this._bounds.x=P,this._bounds.width=w-P,this._bounds.y=C,this._bounds.height=T-C,this._currentBounds=this._bounds,this._currentBounds},e.Graphics.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=e.identityMatrix;for(var i=0;i<this.children.length;i++)this.children[i].updateTransform();var s=this.getBounds();for(this.worldTransform=t,i=0;i<this.children.length;i++)this.children[i].updateTransform();return s},e.Graphics.prototype.containsPoint=function(t,i){void 0===i&&(i=new e.Point),this.worldTransform.applyInverse(t,i);for(var s=this.graphicsData,n=0;n<s.length;n++){var o=s[n];if(o.fill&&(o.shape&&o.shape.contains(i.x,i.y)))return!0}return!1},e.Graphics.prototype.getVisualBounds=function(t){return this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1),this._localBounds.clone(t)},e.Graphics.prototype.updateLocalBounds=function(){var t=1/0,i=-1/0,s=1/0,n=-1/0;if(this.graphicsData.length)for(var o,r,a,h,l,c,u=0;u<this.graphicsData.length;u++){var d=this.graphicsData[u],p=d.type,f=d.lineWidth;if(o=d.shape,p===e.RECTANGLE||p===e.ROUNDEDRECTANGLE)a=o.x-f/2,h=o.y-f/2,l=o.width+f,c=o.height+f,t=a<t?a:t,i=a+l>i?a+l:i,s=h<s?h:s,n=h+c>n?h+c:n;else if(p===e.CIRCLE)a=o.x,h=o.y,l=o.radius+f/2,c=o.radius+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else if(p===e.ELLIPSE)a=o.x,h=o.y,l=o.width+f/2,c=o.height+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else{r=o.points;for(var g=0;g<r.length;g++)r[g]instanceof e.Point?(a=r[g].x,h=r[g].y):(a=r[g],h=r[g+1],g<r.length-1&&g++),t=a-f<t?a-f:t,i=a+f>i?a+f:i,s=h-f<s?h-f:s,n=h+f>n?h+f:n}}else t=0,i=0,s=0,n=0;var m=this.boundsPadding;this._localBounds.x=t-m,this._localBounds.width=i-t+2*m,this._localBounds.y=s-m,this._localBounds.height=n-s+2*m},e.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new PIXI.CanvasBuffer(t.width,t.height),i=PIXI.Texture.fromCanvas(e.canvas);this._cachedSprite=new PIXI.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},e.Graphics.prototype.updateCachedSpriteTexture=function(){var t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=e.frame.width=i.width,e.crop.height=e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()},e.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},e.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof e.Polygon&&(t=t.clone()).flatten();var i=new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(i),i.type===e.POLYGON&&(i.shape.closed=this.filling,this.currentPath=i),this.dirty=!0,this._boundsDirty=!0,i},Object.defineProperty(e.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),e.RenderTexture=function(t,i,s,n,o,r,a,h){if(void 0===i&&(i=100),void 0===s&&(s=100),void 0===n&&(n=""),void 0===o&&(o=e.scaleModes.DEFAULT),void 0===r&&(r=1),void 0===a&&(a=PIXI.defaultRenderer),void 0===h&&(h=0),this.game=t,this.key=n,this.type=e.RENDERTEXTURE,this._tempMatrix=new e.Matrix,this.width=i,this.height=s,this.resolution=r,this.frame=new e.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=o,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=a,this.renderer.type===e.WEBGL){var l=this.renderer.gl;this.baseTexture.textureIndex=h,this.baseTexture._dirty[l.id]=!1,this.textureBuffer=new PIXI.FilterTexture(l,this.width,this.height,this.baseTexture.scaleMode,h),this.baseTexture._glTextures[l.id]=this.textureBuffer.texture,this.projection=new e.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 e.Matrix,this._updateUvs()},e.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.RenderTexture.prototype.renderXY=function(t,i,s,n){t.updateTransform(),this._tempMatrix.copyFrom(t.worldTransform),this._tempMatrix.tx=i,this._tempMatrix.ty=s,this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.renderRawXY=function(t,i,s,n){this._tempMatrix.identity().translate(i,s),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.render=function(t,i,s){void 0===i||null===i?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(i),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,s):this._renderCanvas(t,this._tempMatrix,s)},e.RenderTexture.prototype.resize=function(t,i,s){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,s&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===e.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},e.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===e.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},e.RenderTexture.prototype._renderWebGL=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),s.translate(0,2*this.projection.y),e&&s.append(e),s.scale(1,-1);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();var o=this.renderer.gl;o.viewport(0,0,this.width*this.resolution,this.height*this.resolution),o.bindFramebuffer(o.FRAMEBUFFER,this.textureBuffer.frameBuffer),i&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(t,this.projection,this.textureBuffer.frameBuffer,e),this.renderer.spriteBatch.dirty=!0,o.bindFramebuffer(o.FRAMEBUFFER,null)}},e.RenderTexture.prototype._renderCanvas=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),e&&s.append(e);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();i&&this.textureBuffer.clear();var o=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(t,this.textureBuffer.context,e),this.renderer.resolution=o}},e.RenderTexture.prototype.getImage=function(t,e,i,s){var n=new Image;return n.src=this.getBase64(t,e),i&&(n.onload=i),s&&(n.onerror=s),n},e.RenderTexture.prototype.getBase64=function(t,e){return this.getCanvas().toDataURL(t,e)},e.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===e.WEBGL){var t=this.renderer.gl,i=this.textureBuffer.width,s=this.textureBuffer.height,n=new Uint8Array(4*i*s);t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,i,s,t.RGBA,t.UNSIGNED_BYTE,n),t.bindFramebuffer(t.FRAMEBUFFER,null);var o=new PIXI.CanvasBuffer(i,s),r=o.context.getImageData(0,0,i,s);return r.data.set(n),o.context.putImageData(r,0,0),o.canvas}return this.textureBuffer.canvas},e.Text=function(t,i,s,n,o){i=i||0,s=s||0,n=void 0===n||null===n?"":n.toString(),this.canvas=e.CanvasPool.create(this),e.Sprite.call(this,t,i,s,PIXI.Texture.fromCanvas(this.canvas)),this.type=e.TEXT,this.physicsType=e.SPRITE,this.padding=new e.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=n,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,this.style={},this.setStyle(o||{}),""!==n&&this.updateText()},e.Text.prototype=Object.create(e.Sprite.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Text.prototype.update=function(){},e.Text.prototype.destroy=function(t){this.texture.destroy(!0),e.Component.Destroy.prototype.destroy.call(this,t)},e.Text.prototype.setShadow=function(t,e,i,s,n,o){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="rgba(0, 0, 0, 1)"),void 0===s&&(s=0),void 0===n&&(n=!0),void 0===o&&(o=!0),this.style.shadowOffsetX=t,this.style.shadowOffsetY=e,this.style.shadowColor=i,this.style.shadowBlur=s,this.style.shadowStroke=n,this.style.shadowFill=o,this.dirty=!0,this},e.Text.prototype.setStyle=function(t,e){void 0===e&&(e=!1);var i=Object.assign({},t);i.font=t.font||"bold 20pt Arial",i.backgroundColor=t.backgroundColor||null,i.fill=t.fill||"black",i.align=(t.align||"left").toLowerCase(),i.boundsAlignH=(t.boundsAlignH||"left").toLowerCase(),i.boundsAlignV=(t.boundsAlignV||"top").toLowerCase(),i.stroke=t.stroke||"black",i.strokeThickness=Number(t.strokeThickness)||0,i.wordWrap=t.wordWrap||!1,i.wordWrapWidth=t.wordWrapWidth||100,i.maxLines=t.maxLines||0,i.shadowOffsetX=t.shadowOffsetX||0,i.shadowOffsetY=t.shadowOffsetY||0,i.shadowColor=t.shadowColor||"rgba(0,0,0,0)",i.shadowBlur=t.shadowBlur||0,i.tabs=t.tabs||0;var s=this.fontToComponents(i.font);return i.fontStyle&&(s.fontStyle=i.fontStyle),i.fontVariant&&(s.fontVariant=i.fontVariant),i.fontWeight&&(s.fontWeight=i.fontWeight),i.fontSize&&("number"==typeof i.fontSize&&(i.fontSize=i.fontSize+"px"),s.fontSize=i.fontSize),this._fontComponents=s,i.font=this.componentsToFont(this._fontComponents),this.style=i,this.dirty=!0,e&&this.updateText(),this},e.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var t=this.text;this.characterLimitSize>-1&&this.characterLimitSize<t.length&&(t=this.text.substring(0,this.characterLimitSize)+this.characterLimitSuffix),this.style.wordWrap&&(t=this.runWordWrap(this.text));var e=t.split(this.splitRegExp),i=this.style.tabs,s=[],n=0,o=this.determineFontProperties(this.style.font),r=e.length;this.style.maxLines>0&&this.style.maxLines<e.length&&(r=this.style.maxLines),this._charCount=0;for(var a=0;a<r;a++){if(0===i){l=this.style.strokeThickness+this.padding.x;this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(e[a]):l+=this.context.measureText(e[a]).width,this.style.wordWrap&&(l-=this.context.measureText(" ").width)}else{var h=e[a].split(/(?:\t)/),l=this.padding.x+this.style.strokeThickness;if(Array.isArray(i))for(var c=0,u=0;u<h.length;u++){var d=0;d=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(h[u]):Math.ceil(this.context.measureText(h[u]).width),u>0&&(c+=i[u-1]),l=c+d}else for(u=0;u<h.length;u++)this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(h[u]):l+=Math.ceil(this.context.measureText(h[u]).width),l+=this.game.math.snapToCeil(l,i)-l}s[a]=Math.ceil(l),n=Math.max(n,s[a])}this.canvas.width=n*this._res;var p=o.fontSize+this.style.strokeThickness+this.padding.y,f=p*r,g=this._lineSpacing;g<0&&Math.abs(g)>p&&(g=-p),0!==g&&(f+=g>0?g*e.length:g*(e.length-1)),this.canvas.height=f*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";var m,y;for(this._charCount=0,a=0;a<r;a++)m=this.style.strokeThickness/2,y=this.style.strokeThickness/2+a*p+o.ascent,a>0&&(y+=g*a),"right"===this.style.align?m+=n-s[a]:"center"===this.style.align&&(m+=(n-s[a])/2),this.autoRound&&(m=Math.round(m),y=Math.round(y)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[a],m,y):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[a],m,y):this.renderTabLine(e[a],m,y,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[a],m,y):this.renderTabLine(e[a],m,y,!0)));this.updateTexture(),this.dirty=!1},e.Text.prototype.renderTabLine=function(t,e,i,s){var n=t.split(/(?:\t)/),o=this.style.tabs,r=0;if(Array.isArray(o))for(var a=0,h=0;h<n.length;h++)h>0&&(a+=o[h-1]),r=e+a,s?this.context.fillText(n[h],r,i):this.context.strokeText(n[h],r,i);else for(h=0;h<n.length;h++){var l=Math.ceil(this.context.measureText(n[h]).width);r=this.game.math.snapToCeil(e,o),s?this.context.fillText(n[h],r,i):this.context.strokeText(n[h],r,i),e=r+l}},e.Text.prototype.updateShadow=function(t){t?(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)},e.Text.prototype.measureLine=function(t){for(var e=0,i=0;i<t.length;i++){var s=t[i];if(this.fontWeights.length>0||this.fontStyles.length>0){var n=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(n.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(n.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(n)}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)),e+=this.context.measureText(s).width,this._charCount++}return Math.ceil(e)},e.Text.prototype.updateLine=function(t,e,i){for(var s=0;s<t.length;s++){var n=t[s];if(this.fontWeights.length>0||this.fontStyles.length>0){var o=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(o.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(o.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(o)}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(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount++}},e.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},e.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},e.Text.prototype.addColor=function(t,e){return this.colors[e]=t,this.dirty=!0,this},e.Text.prototype.addStrokeColor=function(t,e){return this.strokeColors[e]=t,this.dirty=!0,this},e.Text.prototype.addFontStyle=function(t,e){return this.fontStyles[e]=t,this.dirty=!0,this},e.Text.prototype.addFontWeight=function(t,e){return this.fontWeights[e]=t,this.dirty=!0,this},e.Text.prototype.precalculateWordWrap=function(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)},e.Text.prototype.runWordWrap=function(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)},e.Text.prototype.advancedWordWrap=function(t){for(var e=this.context,i=this.style.wordWrapWidth,s="",n=t.replace(/ +/gi," ").split(/\r?\n/gi),o=n.length,r=0;r<o;r++){var a=n[r],h="";if(a=a.replace(/^ *|\s*$/gi,""),e.measureText(a).width<i)s+=a+"\n";else{for(var l=i,c=a.split(" "),u=0;u<c.length;u++){var d=c[u],p=d+" ",f=e.measureText(p).width;if(f>l){if(0===u){for(var g=p;g.length&&(g=g.slice(0,-1),!((f=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var m=d.substr(g.length);c[u]=m,h+=g}var y=c[u].length?u:u+1,v=c.slice(y).join(" ").replace(/[ \n]*$/gi,"");n[r+1]=v+" "+(n[r+1]||""),o=n.length;break}h+=p,l-=f}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},e.Text.prototype.basicWordWrap=function(t){for(var e="",i=t.split("\n"),s=0;s<i.length;s++){for(var n=this.style.wordWrapWidth,o=i[s].split(" "),r=0;r<o.length;r++){var a=this.context.measureText(o[r]).width,h=a+this.context.measureText(" ").width;h>n?(r>0&&(e+="\n"),e+=o[r]+" ",n=this.style.wordWrapWidth-a):(n-=h,e+=o[r]+" ")}s<i.length-1&&(e+="\n")}return e},e.Text.prototype.updateFont=function(t){var e=this.componentsToFont(t);this.style.font!==e&&(this.style.font=e,this.dirty=!0,this.parent&&this.updateTransform())},e.Text.prototype.fontToComponents=function(t){var e=t.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*$/);if(e){var i=e[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:t,fontStyle:e[1]||"normal",fontVariant:e[2]||"normal",fontWeight:e[3]||"normal",fontSize:e[4]||"medium",fontFamily:i}}return console.warn("Phaser.Text - unparsable CSS font: "+t),{font:t}},e.Text.prototype.componentsToFont=function(t){var e,i=[];return(e=t.fontStyle)&&"normal"!==e&&i.push(e),(e=t.fontVariant)&&"normal"!==e&&i.push(e),(e=t.fontWeight)&&"normal"!==e&&i.push(e),(e=t.fontSize)&&"medium"!==e&&i.push(e),(e=t.fontFamily)&&i.push(e),i.length||i.push(t.font),i.join(" ")},e.Text.prototype.setText=function(t,e){return void 0===e&&(e=!1),(t=t.toString()||"")===this._text?this:(this.text=t,e?this.updateText():this.dirty=!0,this)},e.Text.prototype.parseList=function(t){if(!Array.isArray(t))return this;for(var e="",i=0;i<t.length;i++)Array.isArray(t[i])?(e+=t[i].join("\t"),i<t.length-1&&(e+="\n")):(e+=t[i],i<t.length-1&&(e+="\t"));return this.text=e,this.dirty=!0,this},e.Text.prototype.setTextBounds=function(t,i,s,n){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,i,s,n):this.textBounds=new e.Rectangle(t,i,s,n),this.style.wordWrapWidth>s&&(this.style.wordWrapWidth=s)),this.updateTexture(),this},e.Text.prototype.updateTexture=function(){var t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){var o=this.textBounds.x,r=this.textBounds.y;"right"===this.style.boundsAlignH?o+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(o+=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=-o,this.pivot.y=-r}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},e.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.Text.prototype.determineFontProperties=function(t){var i=e.Text.fontPropertiesCache[t],s=this.testString||"|MÉq";if(!i){i={};var n=e.Text.fontPropertiesCanvas,o=e.Text.fontPropertiesContext;o.font=t;var r=Math.ceil(o.measureText(s).width),a=Math.ceil(o.measureText(s).width),h=2*a;if(a=1.4*a|0,n.width=r,n.height=h,o.fillStyle="#f00",o.fillRect(0,0,r,h),o.font=t,o.textBaseline="alphabetic",o.fillStyle="#000",o.fillText(s,0,a),!o.getImageData(0,0,r,h))return i.ascent=a,i.descent=a+6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i,i;var l,c,u=o.getImageData(0,0,r,h).data,d=u.length,p=4*r,f=0,g=!1;for(l=0;l<a;l++){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f+=p}for(i.ascent=a-l,f=d-p,g=!1,l=h;l>a;l--){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f-=p}i.descent=l-a,i.descent+=6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i}return i},e.Text.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,t)},e.Text.prototype.setCharacterLimit=function(t,e){this.characterLimitSuffix=void 0===e?"":e,this.characterLimitSize=t,this.updateText()},Object.defineProperty(e.Text.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(t){t=t||"bold 20pt Arial",this._fontComponents=this.fontToComponents(t),this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(t){t=(t=t||"Arial").trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t)||/['",]/.exec(t)||(t="'"+t+"'"),this._fontComponents.fontFamily=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontSize",{get:function(){var t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t},set:function(t){"number"==typeof(t=t||"0")&&(t+="px"),this._fontComponents.fontSize=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontWeight=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontStyle=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontVariant=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"align",{get:function(){return this.style.align},set:function(t){(t=t.toLowerCase())!==this.style.align&&(this.style.align=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"resolution",{get:function(){return this._res},set:function(t){t!==this._res&&(this._res=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=Number(t),this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(e.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),Object.defineProperty(e.Text.prototype,"testString",{get:function(){return this._testString},set:function(t){this._testString=t,this.updateText()}}),e.Text.fontPropertiesCache={},e.Text.fontPropertiesCanvas=document.createElement("canvas"),e.Text.fontPropertiesContext=e.Text.fontPropertiesCanvas.getContext("2d"),e.BitmapText=function(t,i,s,n,o,r,a){i=i||0,s=s||0,n=n||"",o=o||"",r=r||32,a=a||"left",PIXI.DisplayObjectContainer.call(this),this.type=e.BITMAPTEXT,this.physicsType=e.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new e.Point,this._prevAnchor=new e.Point,this._glyphs=[],this._maxWidth=0,this._text=o.toString()||"",this._data=t.cache.getBitmapFont(n),this._font=n,this._fontSize=r,this._align=a,this._letterSpacing=0,this._tint=16777215,this.updateText(),this.dirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.Component.Core.install.call(e.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.BitmapText.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.BitmapText.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.BitmapText.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.BitmapText.prototype.preUpdateCore=e.Component.Core.preUpdate,e.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.BitmapText.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===e.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},e.BitmapText.prototype.setText=function(t){this.text=t},e.BitmapText.prototype.scanLine=function(t,e,i){for(var s=0,n=0,o=-1,r=0,a=null,h=this._maxWidth>0?this._maxWidth:null,l=[],c=0;c<i.length;c++){var u=c===i.length-1;if(/(?:\r\n|\r|\n)/.test(i.charAt(c)))return{width:n,text:i.substr(0,c),end:u,chars:l};var d=i.charCodeAt(c),p=t.chars[d],f=0;void 0===p&&(d=32,p=t.chars[d]);var g=a&&p.kerning[a]?p.kerning[a]:0;if(/(\s)/.test(i.charAt(c))&&(o=c,r=n),f=(g+p.texture.width+p.xOffset)*e,h&&n+f>=h&&o>-1)return{width:r||n,text:i.substr(0,c-(c-o)),end:!1,chars:l};n+=(p.xAdvance+g+this.letterSpacing)*e,l.push(s+(p.xOffset+g+this.letterSpacing)*e),s+=(p.xAdvance+g+this.letterSpacing)*e,a=d}return{width:n,text:i,end:u,chars:l}},e.BitmapText.prototype.cleanText=function(t,e){void 0===e&&(e="");var i=this._data.font;if(!i)return"";for(var s=/\r\n|\n\r|\n|\r/g,n=t.replace(s,"\n").split("\n"),o=0;o<n.length;o++){for(var r="",a=n[o],h=0;h<a.length;h++)r=i.chars[a.charCodeAt(h)]?r.concat(a[h]):r.concat(e);n[o]=r}return n.join("\n")},e.BitmapText.prototype.updateText=function(){var t=this._data.font;if(t){var e=this.text,i=this._fontSize/t.size,s=[],n=0;this.textWidth=0;do{(c=this.scanLine(t,i,e)).y=n,s.push(c),c.width>this.textWidth&&(this.textWidth=c.width),n+=t.lineHeight*i,e=e.substr(c.text.length+1)}while(!1===c.end);this.textHeight=n;for(var o=0,r=0,a=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l<s.length;l++){var c=s[l];"right"===this._align?r=this.textWidth-c.width:"center"===this._align&&(r=(this.textWidth-c.width)/2);for(var u=0;u<c.text.length;u++){var d=c.text.charCodeAt(u),p=t.chars[d];void 0===p&&(d=32,p=t.chars[d]);var f=this._glyphs[o];f?f.texture=p.texture:((f=new PIXI.Sprite(p.texture)).name=c.text[u],this._glyphs.push(f)),f.position.x=c.chars[u]+r-a,f.position.y=c.y+p.yOffset*i-h,f.scale.set(i),f.tint=this.tint,f.texture.requiresReTint=!0,f.cachedTint=16777215,f.parent||this.addChild(f),o++}}for(l=o;l<this._glyphs.length;l++)this.removeChild(this._glyphs[l])}},e.BitmapText.prototype.purgeGlyphs=function(){for(var t=this._glyphs.length,e=[],i=0;i<this._glyphs.length;i++)this._glyphs[i].parent!==this?this._glyphs[i].destroy():e.push(this._glyphs[i]);return this._glyphs=[],this._glyphs=e,this.updateText(),t-e.length},e.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(e.BitmapText.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(t){"number"==typeof t&&(this._letterSpacing=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"align",{get:function(){return this._align},set:function(t){t===this._align||"left"!==t&&"center"!==t&&"right"!==t||(this._align=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(t){t!==this._tint&&(this._tint=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"font",{get:function(){return this._font},set:function(t){t!==this._font&&(this._font=t.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(t){(t=parseInt(t,10))!==this._fontSize&&t>0&&(this._fontSize=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(t){this._data.base.scaleMode=t?0:1,this._data.base.dirty()}}),e.RetroFont=function(t,i,s,n,o,r,a,h,l,c){if(!t.cache.checkImageKey(i))return!1;void 0!==r&&null!==r||(r=t.cache.getImage(i).width/s),this.characterWidth=s,this.characterHeight=n,this.characterSpacingX=a||0,this.characterSpacingY=h||0,this.characterPerRow=r,this.offsetX=l||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 e.FrameData;for(var u=this.offsetX,d=this.offsetY,p=0,f=0;f<o.length;f++){var g=this.frameData.addFrame(new e.Frame(f,u,d,this.characterWidth,this.characterHeight));this.grabData[o.charCodeAt(f)]=g.index,++p===this.characterPerRow?(p=0,u=this.offsetX,d+=this.characterHeight+this.characterSpacingY):u+=this.characterWidth+this.characterSpacingX}t.cache.updateFrameData(i,this.frameData),this.stamp=new e.Image(t,0,0,i,0),e.RenderTexture.call(this,t,100,100,"",e.scaleModes.NEAREST),this.type=e.RETROFONT},e.RetroFont.prototype=Object.create(e.RenderTexture.prototype),e.RetroFont.prototype.constructor=e.RetroFont,e.RetroFont.ALIGN_LEFT="left",e.RetroFont.ALIGN_RIGHT="right",e.RetroFont.ALIGN_CENTER="center",e.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",e.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",e.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",e.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",e.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",e.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",e.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",e.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",e.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},e.RetroFont.prototype.setText=function(t,e,i,s,n,o){this.multiLine=e||!1,this.customSpacingX=i||0,this.customSpacingY=s||0,this.align=n||"left",this.autoUpperCase=!o,t.length>0&&(this.text=t)},e.RetroFont.prototype.buildRetroFontText=function(){var t=0,i=0;if(this.clear(),this.multiLine){var s=this._text.split("\n");this.fixedWidth>0?this.resize(this.fixedWidth,s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var n=0;n<s.length;n++)t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-s[n].length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-s[n].length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(s[n],t,i,this.customSpacingX),i+=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===e.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===e.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},e.RetroFont.prototype.pasteLine=function(t,e,i,s){for(var n=0;n<t.length;n++)if(" "===t.charAt(n))e+=this.characterWidth+s;else if(this.grabData[t.charCodeAt(n)]>=0&&(this.stamp.frame=this.grabData[t.charCodeAt(n)],this.renderXY(this.stamp,e,i,!1),(e+=this.characterWidth+s)>this.width))break},e.RetroFont.prototype.getLongestLine=function(){var t=0;if(this._text.length>0)for(var e=this._text.split("\n"),i=0;i<e.length;i++)e[i].length>t&&(t=e[i].length);return t},e.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i<this._text.length;i++){var s=this._text[i],n=s.charCodeAt(0);(this.grabData[n]>=0||!t&&"\n"===s)&&(e=e.concat(s))}return e},e.RetroFont.prototype.updateOffset=function(t,e){if(this.offsetX!==t||this.offsetY!==e){for(var i=t-this.offsetX,s=e-this.offsetY,n=this.game.cache.getFrameData(this.stamp.key).getFrames(),o=n.length;o--;)n[o].x+=i,n[o].y+=s;this.buildRetroFontText()}},Object.defineProperty(e.RetroFont.prototype,"text",{get:function(){return this._text},set:function(t){var e;(e=this.autoUpperCase?t.toUpperCase():t)!==this._text&&(this._text=e,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(e.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(t){this.stamp.smoothed=t,this.buildRetroFontText()}}),e.Rope=function(t,i,s,n,o,r){this.points=r||[],this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,i=i||0,s=s||0,n=n||null,o=o||null,this.type=e.ROPE,PIXI.DisplayObjectContainer.call(this),this.texture=e.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]),r&&(this.vertices=new Float32Array(4*r.length),this.uvs=new Float32Array(4*r.length),this.colors=new Float32Array(2*r.length),this.indices=new Uint16Array(2*r.length)),this.dirty=!0,this.canvasPadding=0,this.drawMode=e.Rope.TRIANGLE_STRIP,e.Component.Core.init.call(this,t,i,s,n,o),this.refresh()},e.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Rope.prototype.constructor=e.Rope,e.Component.Core.install.call(e.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Rope.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Rope.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Rope.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Rope.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Rope.TRIANGLE_STRIP=0,e.Rope.TRIANGLES=1,e.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},e.Rope.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this},e.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=this.indices,s=this.colors;this.count-=.2;for(var n=t.length,o=0,r=0,a=0;a<n;a++)r=a/(n-1),e[o=4*a]=r,e[o+1]=0,e[o+2]=r,e[o+3]=1,s[o=2*a]=1,s[o+1]=1,i[o=2*a]=o,i[o+1]=o+1}},e.Rope.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){var e,i=t[0],s={x:0,y:0};this.count-=.2;for(var n,o,r,a,h=this.vertices,l=t.length,c=this.texture.height/2,u=0;u<l;u++)n=t[u],o=4*u,e=u<l-1?t[u+1]:n,s.y=-(e.x-i.x),s.x=e.y-i.y,r=Math.sqrt(s.x*s.x+s.y*s.y),a=c,s.x/=r,s.y/=r,s.x*=a,s.y*=a,h[o]=n.x+s.x,h[o+1]=n.y+s.y,h[o+2]=n.x-s.x,h[o+3]=n.y-s.y,i=n;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},e.Rope.prototype.setTexture=function(t){this.texture=t},e.Rope.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},e.Rope.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},e.Rope.prototype._renderStrip=function(t){var i=t.gl,s=t.projection,n=t.offset,o=t.shaderManager.stripShader,r=this.drawMode===e.Rope.TRIANGLE_STRIP?i.TRIANGLE_STRIP:i.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),i.uniformMatrix3fv(o.translationMatrix,!1,this.worldTransform.toArray(!0)),i.uniform2f(o.projectionVector,s.x,-s.y),i.uniform2f(o.offsetVector,-n.x,-n.y),i.uniform1f(o.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(o.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(o.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(o.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.vertexAttribPointer(o.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(r,this.indices.length,i.UNSIGNED_SHORT,0)},e.Rope.prototype._renderCanvas=function(t){var i=t.context,s=this.worldTransform,n=s.tx*t.resolution+t.shakeX,o=s.ty*t.resolution+t.shakeY;t.roundPixels?i.setTransform(s.a,s.b,s.c,s.d,0|n,0|o):i.setTransform(s.a,s.b,s.c,s.d,n,o),this.drawMode===e.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(i):this._renderCanvasTriangles(i)},e.Rope.prototype._renderCanvasTriangleStrip=function(t){var e=this.vertices,i=this.uvs,s=e.length/2;this.count++;for(var n=0;n<s-2;n++){var o=2*n;this._renderCanvasDrawTriangle(t,e,i,o,o+2,o+4)}},e.Rope.prototype._renderCanvasTriangles=function(t){var e=this.vertices,i=this.uvs,s=this.indices,n=s.length;this.count++;for(var o=0;o<n;o+=3){var r=2*s[o],a=2*s[o+1],h=2*s[o+2];this._renderCanvasDrawTriangle(t,e,i,r,a,h)}},e.Rope.prototype._renderCanvasDrawTriangle=function(t,e,i,s,n,o){var r=this.texture.baseTexture.source,a=this.texture.width,h=this.texture.height,l=e[s],c=e[n],u=e[o],d=e[s+1],p=e[n+1],f=e[o+1],g=i[s]*a,m=i[n]*a,y=i[o]*a,v=i[s+1]*h,x=i[n+1]*h,b=i[o+1]*h;if(this.canvasPadding>0){var _=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,T=(l+c+u)/3,P=(d+p+f)/3,C=l-T,S=d-P,k=Math.sqrt(C*C+S*S);l=T+C/k*(k+_),d=P+S/k*(k+w),S=p-P,c=T+(C=c-T)/(k=Math.sqrt(C*C+S*S))*(k+_),p=P+S/k*(k+w),S=f-P,u=T+(C=u-T)/(k=Math.sqrt(C*C+S*S))*(k+_),f=P+S/k*(k+w)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(c,p),t.lineTo(u,f),t.closePath(),t.clip();var A=g*x+v*y+m*b-x*y-v*m-g*b,M=l*x+v*u+c*b-x*u-v*c-l*b,O=g*c+l*y+m*u-c*y-l*m-g*u,I=g*x*u+v*c*y+l*m*b-l*x*y-v*m*u-g*c*b,E=d*x+v*f+p*b-x*f-v*p-d*b,L=g*p+d*y+m*f-p*y-d*m-g*f,R=g*x*f+v*p*y+d*m*b-d*x*y-v*m*f-g*p*b;t.transform(M/A,E/A,O/A,L/A,I/A,R/A),t.drawImage(r,0,0),t.restore()},e.Rope.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,s=i.length/2;this.count++,e.beginPath();for(var n=1;n<s-2;n++){var o=2*n,r=i[o],a=i[o+2],h=i[o+4],l=i[o+1],c=i[o+3],u=i[o+5];e.moveTo(r,l),e.lineTo(a,c),e.lineTo(h,u)}e.fillStyle="#FF0000",e.fill(),e.closePath()},e.Rope.prototype.getBounds=function(t){for(var i=t||this.worldTransform,s=i.a,n=i.b,o=i.c,r=i.d,a=i.tx,h=i.ty,l=-1/0,c=-1/0,u=1/0,d=1/0,p=this.vertices,f=0;f<p.length;f+=2){var g=p[f],m=p[f+1],y=s*g+o*m+a,v=r*m+n*g+h;u=y<u?y:u,d=v<d?v:d,l=y>l?y:l,c=v>c?v:c}if(u===-1/0||c===1/0)return e.EmptyRectangle;var x=this._bounds;return x.x=u,x.width=l-u,x.y=d,x.height=c-d,this._currentBounds=x,x},Object.defineProperty(e.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(t){t&&"function"==typeof t?(this._hasUpdateAnimation=!0,this._updateAnimation=t):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(e.Rope.prototype,"segments",{get:function(){for(var t,i,s,n,o,r,a,h,l=[],c=0;c<this.points.length;c++)t=4*c,i=this.vertices[t]*this.scale.x,s=this.vertices[t+1]*this.scale.y,n=this.vertices[t+4]*this.scale.x,o=this.vertices[t+3]*this.scale.y,r=e.Math.difference(i,n),a=e.Math.difference(s,o),i+=this.world.x,s+=this.world.y,h=new e.Rectangle(i,s,r,a),l.push(h);return l}}),e.TileSprite=function(t,i,s,n,o,r,a){i=i||0,s=s||0,n=n||256,o=o||256,r=r||null,a=a||null,PIXI.Sprite.call(this,new PIXI.Texture(e.Cache.DEFAULT.baseTexture),n,o),this.type=e.TILESPRITE,this.physicsType=e.SPRITE,this._scroll=new e.Point,this.tileScale=new e.Point(1,1),this.tileScaleOffset=new e.Point(1,1),this.tilePosition=new e.Point,this.textureDebug=!1,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0,this._width=n,this._height=o,e.Component.Core.init.call(this,t,i,s,r,a)},e.TileSprite.prototype=Object.create(PIXI.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Component.Core.install.call(e.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),e.TileSprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.TileSprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.TileSprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.TileSprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.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()},e.TileSprite.prototype.autoScroll=function(t,e){return this._scroll.set(t,e),this},e.TileSprite.prototype.stopScroll=function(){return this._scroll.set(0,0),this},e.TileSprite.prototype.destroy=function(t){e.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)},e.TileSprite.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this.tilePosition.x=0,this.tilePosition.y=0,this},e.TileSprite.prototype.setTexture=function(t){return this.texture!==t&&(this.texture=t,this.refreshTexture=!0,this.cachedTint=16777215),this},e.TileSprite.prototype._renderWebGL=function(t){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,t),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,t.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}t.spriteBatch.renderTilingSprite(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t);var i=!1;this._filters&&(i=!0,t.spriteBatch.stop(),t.filterManager.popFilter()),this._mask&&(i||t.spriteBatch.stop(),t.maskManager.popMask(this._mask,t)),i&&t.spriteBatch.start()}},e.TileSprite.prototype._renderCanvas=function(t){if(this.visible&&this.renderable&&0!==this.alpha){var e=t.context;this._mask&&t.maskManager.pushMask(this._mask,t),e.globalAlpha=this.worldAlpha;var i=this.worldTransform,s=t.resolution,n=i.tx*s+t.shakeX,o=i.ty*s+t.shakeY;if(e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,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,t),!this.tilingTexture)return;this.tilePattern=e.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var r=t.currentBlendMode;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]);var a=this.tilePosition,h=this.tileScale;a.x%=this.tilingTexture.baseTexture.width,a.y%=this.tilingTexture.baseTexture.height,e.scale(h.x,h.y),e.translate(a.x+this.anchor.x*-this._width,a.y+this.anchor.y*-this._height),e.fillStyle=this.tilePattern,n=-a.x,o=-a.y;var l=this._width/h.x,c=this._height/h.y;t.roundPixels&&(n|=0,o|=0,l|=0,c|=0),e.fillRect(n,o,l,c),e.scale(1/h.x,1/h.y),e.translate(-a.x+this.anchor.x*this._width,-a.y+this.anchor.y*this._height),this._mask&&t.maskManager.popMask(t);for(var u=0;u<this.children.length;u++)this.children[u]._renderCanvas(t);r!==this.blendMode&&(t.currentBlendMode=r,e.globalCompositeOperation=PIXI.blendModesCanvas[r])}},e.TileSprite.prototype.onTextureUpdate=function(){},e.TileSprite.prototype.generateTilingTexture=function(t){if(this.texture.baseTexture.hasLoaded){var i=this.texture,s=i.frame,n=this._frame.sourceSizeW||this._frame.width,o=this._frame.sourceSizeH||this._frame.height,r=0,a=0;this._frame.trimmed&&(r=this._frame.spriteSourceSizeX,a=this._frame.spriteSourceSizeY),t&&(n=e.Math.getNextPowerOfTwo(n),o=e.Math.getNextPowerOfTwo(o)),this.canvasBuffer?(this.canvasBuffer.resize(n,o),this.tilingTexture.baseTexture.width=n,this.tilingTexture.baseTexture.height=o,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new PIXI.CanvasBuffer(n,o),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,n,o));var h=i.crop.width,l=i.crop.height;h===n&&l===o||(h=n,l=o);var c=this.tintedTexture?this.tintedTexture:i.baseTexture.source;this.canvasBuffer.context.drawImage(c,i.crop.x,i.crop.y,i.crop.width,i.crop.height,r,a,h,l),this.tileScaleOffset.x=s.width/n,this.tileScaleOffset.y=s.height/o,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},e.TileSprite.prototype.getBounds=function(){var t=this._width,e=this._height,i=t*(1-this.anchor.x),s=t*-this.anchor.x,n=e*(1-this.anchor.y),o=e*-this.anchor.y,r=this.worldTransform,a=r.a,h=r.b,l=r.c,c=r.d,u=r.tx,d=r.ty,p=a*s+l*o+u,f=c*o+h*s+d,g=a*i+l*o+u,m=c*o+h*i+d,y=a*i+l*n+u,v=c*n+h*i+d,x=a*s+l*n+u,b=c*n+h*s+d,_=-1/0,w=-1/0,T=1/0,P=1/0;T=x<(T=y<(T=g<(T=p<T?p:T)?g:T)?y:T)?x:T,P=b<(P=v<(P=m<(P=f<P?f:P)?m:P)?v:P)?b:P,_=x>(_=y>(_=g>(_=p>_?p:_)?g:_)?y:_)?x:_,w=b>(w=v>(w=m>(w=f>w?f:w)?m:w)?v:w)?b:w;var C=this._bounds;return C.x=T,C.width=_-T,C.y=P,C.height=w-P,this._currentBounds=C,C},Object.defineProperty(e.TileSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(e.TileSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),e.CanvasPool={create:function(t,i,s){var n,o=e.CanvasPool.getFirst();if(-1===o){var r={parent:t,canvas:document.createElement("canvas")};e.CanvasPool.pool.push(r),n=r.canvas}else e.CanvasPool.pool[o].parent=t,n=e.CanvasPool.pool[o].canvas;return void 0!==i&&(n.width=i,n.height=s),n},getFirst:function(){for(var t=e.CanvasPool.pool,i=0;i<t.length;i++)if(!t[i].parent)return i;return-1},remove:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].parent===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},removeByCanvas:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].canvas===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},getTotal:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent&&i++;return i},getFree:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent||i++;return i},log:function(){console.log("CanvasPool: %s used, %s free, %s total",e.CanvasPool.getTotal(),e.CanvasPool.getFree(),e.CanvasPool.pool.length)}},e.CanvasPool.pool=[],Object.defineProperty(e.CanvasPool,"length",{get:function(){return this.pool.length}}),e.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},e.Device=new e.Device,e.Device.onInitialized=new e.Signal,e.Device.whenReady=function(t,e,i){var s=this._readyCheck;if(this.deviceReadyAt||!s)t.call(e,this);else if(s._monitor||i)s._queue=s._queue||[],s._queue.push([t,e]);else{s._monitor=s.bind(this),s._queue=s._queue||[],s._queue.push([t,e]);var n=void 0!==window.cordova,o=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(s._monitor,0):n&&!o?document.addEventListener("deviceready",s._monitor,!1):(document.addEventListener("DOMContentLoaded",s._monitor,!1),window.addEventListener("load",s._monitor,!1))}},e.Device._readyCheck=function(){var t=this._readyCheck;if(document.body){if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",t._monitor),document.removeEventListener("DOMContentLoaded",t._monitor),window.removeEventListener("load",t._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var e;e=t._queue.shift();){var i=e[0],s=e[1];i.call(s,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}}else window.setTimeout(t._monitor,20)},e.Device._initialize=function(){function t(){var t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t);return e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null}function i(){if(void 0===Uint8ClampedArray)return!1;var t=e.CanvasPool.create(this,1,1).getContext("2d");if(!t)return!1;var i=t.createImageData(1,1);return e.CanvasPool.remove(this),i.data instanceof Uint8ClampedArray}var s=this;!function(){var t=navigator.userAgent;/Playstation Vita/.test(t)?s.vita=!0:/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?s.kindle=!0:/Android/.test(t)?s.android=!0:/CrOS/.test(t)?s.chromeOS=!0:/iP[ao]d|iPhone/i.test(t)?(s.iOS=!0,navigator.appVersion.match(/OS (\d+)/),s.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(t)?s.linux=!0:/Mac OS/.test(t)?s.macOS=!0:/Windows/.test(t)&&(s.windows=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(s.android=!1,s.iOS=!1,s.macOS=!1,s.windows=!0,s.windowsPhone=!0);var e=/Silk/.test(t);(s.windows||s.macOS||s.linux&&!e||s.chromeOS)&&(s.desktop=!0),(s.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(s.desktop=!1)}(),function(){var t=navigator.userAgent;if(/Arora/.test(t)?s.arora=!0:/Edge\/\d+/.test(t)?s.edge=!0:/Chrome\/(\d+)/.test(t)&&!s.windowsPhone?(s.chrome=!0,s.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(t)?s.epiphany=!0:/Firefox\D+(\d+)/.test(t)?(s.firefox=!0,s.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(t)&&s.iOS?s.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(t)?(s.ie=!0,s.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(t)?s.midori=!0:/Opera/.test(t)?s.opera=!0:/Safari\/(\d+)/.test(t)&&!s.windowsPhone?(s.safari=!0,/Version\/(\d+)\./.test(t)&&(s.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(t)&&(s.ie=!0,s.trident=!0,s.tridentVersion=parseInt(RegExp.$1,10),s.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(t)&&(s.silk=!0),navigator.standalone&&(s.webApp=!0),void 0!==window.cordova&&(s.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(s.node=!0),s.node&&"object"==typeof process.versions&&(s.nodeWebkit=!!process.versions["node-webkit"],s.electron=!!process.versions.electron),navigator.isCocoonJS&&(s.cocoonJS=!0),s.cocoonJS)try{s.cocoonJSApp="undefined"!=typeof CocoonJS}catch(t){s.cocoonJSApp=!1}void 0!==window.ejecta&&(s.ejecta=!0),/Crosswalk/.test(t)&&(s.crosswalk=!0)}(),function(){s.audioData=!!window.Audio,s.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio");try{if(t.canPlayType&&(t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(s.ogg=!0),(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||t.canPlayType("audio/opus;").replace(/^no$/,""))&&(s.opus=!0),t.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(s.mp3=!0),t.canPlayType("audio/wav").replace(/^no$/,"")&&(s.wav=!0),(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/aac;").replace(/^no$/,""))&&(s.m4a=!0),t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(s.webm=!0),""!==t.canPlayType('audio/mp4;codecs="ec-3"')))if(s.edge)s.dolby=!0;else if(s.safari&&s.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var e=parseInt(RegExp.$1,10),i=parseInt(RegExp.$2,10);(10===e&&i>=11||e>10)&&(s.dolby=!0)}}catch(t){}}(),function(){var t=document.createElement("video");try{t.canPlayType&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(s.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.h264Video=!0,s.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(s.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(s.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.hlsVideo=!0))}catch(t){}}(),function(){var t,e=document.createElement("p"),i={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(e,null);for(var n in i)void 0!==e.style[n]&&(e.style[n]="translate3d(1px,1px,1px)",t=window.getComputedStyle(e).getPropertyValue(i[n]));document.body.removeChild(e),s.css3D=void 0!==t&&t.length>0&&"none"!==t}(),s.pixelRatio=window.devicePixelRatio||1,s.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),s.iPhone4=2===s.pixelRatio&&s.iPhone,s.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?s.typedArray=!0:s.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(s.littleEndian=t(),s.LITTLE_ENDIAN=s.littleEndian),s.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==s.littleEndian&&i(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(s.vibration=!0),function(){s.canvas=!!window.CanvasRenderingContext2D||s.cocoonJS;try{s.localStorage=!!localStorage.getItem}catch(t){s.localStorage=!1}s.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),s.fileSystem=!!window.requestFileSystem,s.webGL=!!window.WebGLRenderingContext,s.worker=!!window.Worker,s.pointerLockElement="pointerLockElement"in document&&"pointerLockElement"||"mozPointerLockElement"in document&&"mozPointerLockElement"||"webkitPointerLockElement"in document&&"webkitPointerLockElement",s.pointerlockchange="onpointerlockchange"in document&&"pointerlockchange"||"onmozpointerlockchange"in document&&"mozpointerlockchange"||"onwebkitpointerlockchange"in document&&"webkitpointerlockchange",s.pointerlockerror="onpointerlockerror"in document&&"pointerlockerror"||"onmozpointerlockerror"in document&&"mozpointerlockerror"||"onwebkitpointerlockerror"in document&&"webkitpointerlockerror",s.pointerLock=!!s.pointerLockElement,s.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,s.getUserMedia=s.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(s.getUserMedia=!1),!s.iOS&&(s.ie||s.firefox||s.chrome)&&(s.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(s.canvasBitBltShift=!1)}(),function(){var t=e.CanvasPool.create(this,6,1),i=t.getContext("2d");i.fillStyle="rgba(10, 20, 30, 0.5)",i.fillRect(0,0,1,1);var n=i.getImageData(0,0,1,1);if(n){i.putImageData(n,1,0);var o=i.getImageData(1,0,1,1);s.canHandleAlpha=o.data[0]===n.data[0]&&o.data[1]===n.data[1]&&o.data[2]===n.data[2]&&o.data[3]===n.data[3]}i.globalCompositeOperation="multiply",s.canUseMultiply="multiply"===i.globalCompositeOperation,e.CanvasPool.removeByCanvas(t),PIXI.CanvasTinter.tintMethod=s.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var t=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],e=document.createElement("div"),i=0;i<t.length;i++)if(e[t[i]]){s.fullscreen=!0,s.requestFullscreen=t[i];break}var n=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(s.fullscreen)for(i=0;i<n.length;i++)if(document[n[i]]){s.cancelFullscreen=n[i];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(s.fullscreenKeyboard=!0)}(),("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(s.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(s.mspointer=!0),s.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?s.wheelEvent="wheel":"onmousewheel"in window?s.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(s.wheelEvent="DOMMouseScroll"))},e.Device.canPlayAudio=function(t){return!("mp3"!==t||!this.mp3)||(!("ogg"!==t||!this.ogg&&!this.opus)||(!("m4a"!==t||!this.m4a)||(!("opus"!==t||!this.opus)||(!("wav"!==t||!this.wav)||(!("webm"!==t||!this.webm)||!("mp4"!==t||!this.dolby))))))},e.Device.canPlayVideo=function(t){return!("webm"!==t||!this.webmVideo&&!this.vp9Video)||(!("mp4"!==t||!this.mp4Video&&!this.h264Video)||(!("ogg"!==t&&"ogv"!==t||!this.oggVideo)||!("mpeg"!==t||!this.hlsVideo)))},e.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},e.Device.isAndroidStockBrowser=function(){var t=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return t&&t[1]<537},e.Canvas={create:function(t,i,s,n,o){i=i||256,s=s||256;var r=o?document.createElement("canvas"):e.CanvasPool.create(t,i,s);return"string"==typeof n&&""!==n&&(r.id=n),r.width=i,r.height=s,r.style.display="block",r},setBackgroundColor:function(t,e){return e=e||"rgb(0,0,0)",t.style.backgroundColor=e,t},setTouchAction:function(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t},setUserSelect:function(t,e){return e=e||"none",t.style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t},addToDOM:function(t,e,i){var s;return void 0===i&&(i=!0),e&&("string"==typeof e?s=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(s=e)),s||(s=document.body),i&&s.style&&(s.style.overflow="hidden"),s.appendChild(t),t},removeFromDOM:function(t){t.parentNode&&t.parentNode.removeChild(t)},setTransform:function(t,e,i,s,n,o,r){return t.setTransform(s,o,r,n,e,i),t},setSmoothingEnabled:function(t,i){var s=e.Canvas.getSmoothingPrefix(t);return s&&(t[s]=i),t},getSmoothingPrefix:function(t){var e=["i","webkitI","msI","mozI","oI"];for(var i in e){var s=e[i]+"mageSmoothingEnabled";if(s in t)return s}return null},getSmoothingEnabled:function(t){var i=e.Canvas.getSmoothingPrefix(t);if(i)return t[i]},setImageRenderingCrisp:function(t){for(var e=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges","pixelated"],i=0;i<e.length;i++)t.style["image-rendering"]=e[i];return t.style.msInterpolationMode="nearest-neighbor",t},setImageRenderingBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}},e.RequestAnimationFrame=function(t,e){void 0===e&&(e=!1),this.game=t,this.isRunning=!1,this.forceSetTimeOut=e;for(var i=["ms","moz","webkit","o"],s=0;s<i.length&&!window.requestAnimationFrame;s++)window.requestAnimationFrame=window[i[s]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[s]+"CancelAnimationFrame"]||window[i[s]+"CancelRequestAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},e.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var t=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return t.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(e){return t.updateRAF(e)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(t){this.isRunning&&(this.game.update(Math.floor(t)),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}},e.RequestAnimationFrame.prototype.constructor=e.RequestAnimationFrame,e.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*e.Math.DEG_TO_RAD},radToDeg:function(t){return t*e.Math.RAD_TO_DEG},getNextPowerOfTwo:function(t){if(t>0&&0==(t&t-1))return t;for(var e=1;e<t;)e<<=1;return e},isPowerOfTwo:function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)},random:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return Math.random()*(e-t)+t},between:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},fuzzyEqual:function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)<i},fuzzyLessThan:function(t,e,i){return void 0===i&&(i=1e-4),t<e+i},fuzzyGreaterThan:function(t,e,i){return void 0===i&&(i=1e-4),t>e-i},fuzzyCeil:function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)},fuzzyFloor:function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)},average:function(){for(var t=0,e=arguments.length,i=0;i<e;i++)t+=+arguments[i];return t/e},shear:function(t){return t%1},snapTo:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.round(t/e),i+t)},snapToFloor:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.floor(t/e),i+t)},snapToCeil:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),i+t)},roundTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.round(t*s)/s},floorTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.floor(t*s)/s},ceilTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.ceil(t*s)/s},trunc:function(t){return isFinite(t)?t-t%1||(t<0?-0:0===t?t:0):t},rotateToAngle:function(t,i,s){return void 0===s&&(s=.05),t===i?t:(Math.abs(i-t)<=s||Math.abs(i-t)>=e.Math.PI2-s?t=i:(Math.abs(i-t)>Math.PI&&(i<t?i+=e.Math.PI2:i-=e.Math.PI2),i>t?t+=s:i<t&&(t-=s)),t)},getShortestAngle:function(t,e){var i=e-t;return 0===i?0:i-360*Math.floor((i- -180)/360)},angleBetween:function(t,e,i,s){return Math.atan2(s-e,i-t)},angleBetweenY:function(t,e,i,s){return Math.atan2(i-t,s-e)},angleBetweenPoints:function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},angleBetweenPointsY:function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)},reverseAngle:function(t){return this.normalizeAngle(t+Math.PI,!0)},normalizeAngle:function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI},maxAdd:function(t,e,i){return Math.min(t+e,i)},minSub:function(t,e,i){return Math.max(t-e,i)},wrap:function(t,e,i){var s=i-e;if(s<=0)return 0;var n=(t-e)%s;return n<0&&(n+=s),n+e},wrapValue:function(t,e,i){return t=Math.abs(t),e=Math.abs(e),i=Math.abs(i),(t+e)%i},isOdd:function(t){return!!(1&t)},isEven:function(t){return!(1&t)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]<t[i]&&(i=e);return t[i]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]>t[i]&&(i=e);return t[i]},minProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]<e[s][t]&&(s=i);return e[s][t]},maxProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]>e[s][t]&&(s=i);return e[s][t]},wrapAngle:function(t,e){return e?this.wrap(t,-Math.PI,Math.PI):this.wrap(t,-180,180)},linearInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return e<0?this.linear(t[0],t[1],s):e>1?this.linear(t[i],t[i-1],i-s):this.linear(t[n],t[n+1>i?i:n+1],s-n)},bezierInterpolation:function(t,e){for(var i=0,s=t.length-1,n=0;n<=s;n++)i+=Math.pow(1-e,s-n)*Math.pow(e,n)*t[n]*this.bernstein(s,n);return i},catmullRomInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return t[0]===t[i]?(e<0&&(n=Math.floor(s=i*(1+e))),this.catmullRom(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],s-n)):e<0?t[0]-(this.catmullRom(t[0],t[0],t[1],t[1],-s)-t[0]):e>1?t[i]-(this.catmullRom(t[i],t[i],t[i-1],t[i-1],s-i)-t[i]):this.catmullRom(t[n?n-1:0],t[n],t[i<n+1?i:n+1],t[i<n+2?i:n+2],s-n)},linear:function(t,e,i){return(e-t)*i+t},bernstein:function(t,e){return this.factorial(t)/this.factorial(e)/this.factorial(t-e)},factorial:function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e},catmullRom:function(t,e,i,s,n){var o=.5*(i-t),r=.5*(s-e),a=n*n;return(2*e-2*i+o+r)*(n*a)+(-3*e+3*i-2*o-r)*a+o*n+e},difference:function(t,e){return Math.abs(t-e)},roundAwayFromZero:function(t){return t>0?Math.ceil(t):Math.floor(t)},sinCosGenerator:function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1);for(var n=e,o=i,r=s*Math.PI/t,a=[],h=[],l=0;l<t;l++)n+=(o-=n*r)*r,a[l]=o,h[l]=n;return{sin:h,cos:a,length:t}},hypot:function(t,e){return Math.sqrt(t*t+e*e)},distance:function(t,e,i,s){var n=t-i,o=e-s;return Math.sqrt(n*n+o*o)},distanceSq:function(t,e,i,s){var n=t-i,o=e-s;return n*n+o*o},distancePow:function(t,e,i,s,n){return void 0===n&&(n=2),Math.sqrt(Math.pow(i-t,n)+Math.pow(s-e,n))},clamp:function(t,e,i){return t<e?e:i<t?i:t},clampBottom:function(t,e){return t<e?e:t},within:function(t,e,i){return Math.abs(t-e)<=i},mapLinear:function(t,e,i,s,n){return s+(t-e)*(n-s)/(i-e)},smoothstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*(3-2*t)},smootherstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)},sign:function(t){return t<0?-1:t>0?1:0},percent:function(t,e,i){return void 0===i&&(i=0),t>e||i>e?1:t<i||i>t?0:(t-i)/e}},e.RandomDataGenerator=function(t){void 0===t&&(t=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof t?this.state(t):this.sow(t)},e.RandomDataGenerator.prototype={rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},sow:function(t){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,t)for(var e=0;e<t.length&&null!=t[e];e++){var i=t[e];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(t){var e,i,s;for(s=4022871197,t=t.toString(),i=0;i<t.length;i++)e=.02519603282416938*(s+=t.charCodeAt(i)),e-=s=e>>>0,s=(e*=s)>>>0,s+=4294967296*(e-=s);return 2.3283064365386963e-10*(s>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(t,e){return Math.floor(this.realInRange(0,e-t+1)+t)},between:function(t,e){return this.integerInRange(t,e)},realInRange:function(t,e){return this.frac()*(e-t)+t},normal:function(){return 1-2*this.frac()},uuid:function(){var t="",e="";for(e=t="";t++<36;e+=~t%5|3*t&4?(15^t?8^this.frac()*(20^t?16:4):4).toString(16):"-");return e},pick:function(t){return t[this.integerInRange(0,t.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(t){return t[~~(Math.pow(this.frac(),2)*(t.length-1)+.5)]},timestamp:function(t,e){return this.realInRange(t||9466848e5,e||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(t){return"string"==typeof t&&t.match(/^!rnd/)&&(t=t.split(","),this.c=parseFloat(t[1]),this.s0=parseFloat(t[2]),this.s1=parseFloat(t[3]),this.s2=parseFloat(t[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},e.RandomDataGenerator.prototype.constructor=e.RandomDataGenerator,e.QuadTree=function(t,e,i,s,n,o,r){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(t,e,i,s,n,o,r)},e.QuadTree.prototype={reset:function(t,e,i,s,n,o,r){this.maxObjects=n||10,this.maxLevels=o||4,this.level=r||0,this.bounds={x:Math.round(t),y:Math.round(e),width:i,height:s,subWidth:Math.floor(i/2),subHeight:Math.floor(s/2),right:Math.round(t)+Math.floor(i/2),bottom:Math.round(e)+Math.floor(s/2)},this.objects.length=0,this.nodes.length=0},populate:function(t){t.forEach(this.populateHandler,this,!0)},populateHandler:function(t){t.body&&t.exists&&this.insert(t.body)},split:function(){this.nodes[0]=new e.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new e.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new e.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new e.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(t){var e,i=0;if(null==this.nodes[0]||-1===(e=this.getIndex(t))){if(this.objects.push(t),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();i<this.objects.length;)-1!==(e=this.getIndex(this.objects[i]))?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}else this.nodes[e].insert(t)},getIndex:function(t){var e=-1;return t.x<this.bounds.right&&t.right<this.bounds.right?t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=1:t.y>this.bounds.bottom&&(e=2):t.x>this.bounds.right&&(t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=0:t.y>this.bounds.bottom&&(e=3)),e},retrieve:function(t){if(t instanceof e.Rectangle)var i=this.objects,s=this.getIndex(t);else{if(!t.body)return this._empty;var i=this.objects,s=this.getIndex(t.body)}return this.nodes[0]&&(i=-1!==s?i.concat(this.nodes[s].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 t=this.nodes.length;t--;)this.nodes[t].clear(),this.nodes.splice(t,1);this.nodes.length=0}},e.QuadTree.prototype.constructor=e.QuadTree,e.Net=function(t){this.game=t},e.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(t){return-1!==window.location.hostname.indexOf(t)},updateQueryString:function(t,e,i,s){void 0===i&&(i=!1),void 0!==s&&""!==s||(s=window.location.href);var n="",o=new RegExp("([?|&])"+t+"=.*?(&|#|$)(.*)","gi");if(o.test(s))n=void 0!==e&&null!==e?s.replace(o,"$1"+t+"="+e+"$2$3"):s.replace(o,"$1$3").replace(/(&|\?)$/,"");else if(void 0!==e&&null!==e){var r=-1!==s.indexOf("?")?"&":"?",a=s.split("#");s=a[0]+r+t+"="+e,a[1]&&(s+="#"+a[1]),n=s}else n=s;if(!i)return n;window.location.href=n},getQueryString:function(t){void 0===t&&(t="");var e={},i=location.search.substring(1).split("&");for(var s in i){var n=i[s].split("=");if(n.length>1){if(t&&t===this.decodeURI(n[0]))return this.decodeURI(n[1]);e[this.decodeURI(n[0])]=this.decodeURI(n[1])}}return e},decodeURI:function(t){return decodeURIComponent(t.replace(/\+/g," "))}},e.Net.prototype.constructor=e.Net,e.TweenManager=function(t){this.game=t,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:e.Easing.Power0,Power1:e.Easing.Power1,Power2:e.Easing.Power2,Power3:e.Easing.Power3,Power4:e.Easing.Power4,Linear:e.Easing.Linear.None,Quad:e.Easing.Quadratic.Out,Cubic:e.Easing.Cubic.Out,Quart:e.Easing.Quartic.Out,Quint:e.Easing.Quintic.Out,Sine:e.Easing.Sinusoidal.Out,Expo:e.Easing.Exponential.Out,Circ:e.Easing.Circular.Out,Elastic:e.Easing.Elastic.Out,Back:e.Easing.Back.Out,Bounce:e.Easing.Bounce.Out,"Quad.easeIn":e.Easing.Quadratic.In,"Cubic.easeIn":e.Easing.Cubic.In,"Quart.easeIn":e.Easing.Quartic.In,"Quint.easeIn":e.Easing.Quintic.In,"Sine.easeIn":e.Easing.Sinusoidal.In,"Expo.easeIn":e.Easing.Exponential.In,"Circ.easeIn":e.Easing.Circular.In,"Elastic.easeIn":e.Easing.Elastic.In,"Back.easeIn":e.Easing.Back.In,"Bounce.easeIn":e.Easing.Bounce.In,"Quad.easeOut":e.Easing.Quadratic.Out,"Cubic.easeOut":e.Easing.Cubic.Out,"Quart.easeOut":e.Easing.Quartic.Out,"Quint.easeOut":e.Easing.Quintic.Out,"Sine.easeOut":e.Easing.Sinusoidal.Out,"Expo.easeOut":e.Easing.Exponential.Out,"Circ.easeOut":e.Easing.Circular.Out,"Elastic.easeOut":e.Easing.Elastic.Out,"Back.easeOut":e.Easing.Back.Out,"Bounce.easeOut":e.Easing.Bounce.Out,"Quad.easeInOut":e.Easing.Quadratic.InOut,"Cubic.easeInOut":e.Easing.Cubic.InOut,"Quart.easeInOut":e.Easing.Quartic.InOut,"Quint.easeInOut":e.Easing.Quintic.InOut,"Sine.easeInOut":e.Easing.Sinusoidal.InOut,"Expo.easeInOut":e.Easing.Exponential.InOut,"Circ.easeInOut":e.Easing.Circular.InOut,"Elastic.easeInOut":e.Easing.Elastic.InOut,"Back.easeInOut":e.Easing.Back.InOut,"Bounce.easeInOut":e.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},e.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var t=0;t<this._tweens.length;t++)this._tweens[t].pendingDelete=!0;this._add=[]},removeFrom:function(t,i){void 0===i&&(i=!0);if(Array.isArray(t))for(s=0,n=t.length;s<n;s++)this.removeFrom(t[s]);else if(t.type===e.GROUP&&i)for(var s=0,n=t.children.length;s<n;s++)this.removeFrom(t.children[s]);else{for(s=0,n=this._tweens.length;s<n;s++)t===this._tweens[s].target&&this.remove(this._tweens[s]);for(s=0,n=this._add.length;s<n;s++)t===this._add[s].target&&this.remove(this._add[s])}},add:function(t){t._manager=this,this._add.push(t)},create:function(t){return new e.Tween(t,this.game,this)},remove:function(t){var e=this._tweens.indexOf(t);-1!==e?this._tweens[e].pendingDelete=!0:-1!==(e=this._add.indexOf(t))&&(this._add[e].pendingDelete=!0)},update:function(){var t=this._add.length,e=this._tweens.length;if(0===e&&0===t)return!1;for(var i=0;i<e;)this._tweens[i].update(this.game.time.time)?i++:(this._tweens.splice(i,1),e--);return t>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(t,e){return e||(e=!1),this._tweens.some(function(i){return i.target===t&&(!e||i.isRunning&&!i.pendingDelete)})},_pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._pause()},_resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._resume()},pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].pause()},resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].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}},e.TweenManager.prototype.constructor=e.TweenManager,e.Tween=function(t,i,s){this.game=i,this.target=t,this.manager=s,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new e.Signal,this.onLoop=new e.Signal,this.onRepeat=new e.Signal,this.onChildComplete=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=s.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},e.Tween.updateColor=function(t){e.Color.updateColor(t.target)},e.Tween.prototype={to:function(t,i,s,n,o,r,a){return(void 0===i||i<=0)&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).to(t,i,s,o,r,a)),n&&this.start(),this)},from:function(t,i,s,n,o,r,a){return void 0===i&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).from(t,i,s,o,r,a)),n&&this.start(),this)},start:function(t){if(void 0===t&&(t=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(i=0;i<this.timeline.length;i++)for(var e in this.timeline[i].vEnd)this.properties[e]=this.target[e]||0,Array.isArray(this.properties[e])||(this.properties[e]*=1);for(var i=0;i<this.timeline.length;i++)this.timeline[i].loadValues();return this.manager.add(this),this.isRunning=!0,(t<0||t>this.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this},stop:function(t){return void 0===t&&(t=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(t,e,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var s=0;s<this.timeline.length;s++)this.timeline[s][t]=e;else this.timeline[i][t]=e;return this},delay:function(t,e){return this.updateTweenData("delay",t,e)},repeat:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("repeatCounter",t,i),this.updateTweenData("repeatTotal",t,i),this.updateTweenData("repeatDelay",e,i)},repeatDelay:function(t,e){return this.updateTweenData("repeatDelay",t,e)},yoyo:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("yoyo",t,i),this.updateTweenData("yoyoDelay",e,i)},yoyoDelay:function(t,e){return this.updateTweenData("yoyoDelay",t,e)},easing:function(t,e){return"string"==typeof t&&this.manager.easeMap[t]&&(t=this.manager.easeMap[t]),this.updateTweenData("easingFunction",t,e)},interpolation:function(t,i,s){return void 0===i&&(i=e.Math),this.updateTweenData("interpolationFunction",t,s),this.updateTweenData("interpolationContext",i,s)},repeatAll:function(t){return void 0===t&&(t=0),this.repeatCounter=t,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1].chainedTween=arguments[t]:this.chainedTween=arguments[t];return this},loop:function(t){return void 0===t&&(t=!0),this.repeatCounter=t?-1:0,this},onUpdateCallback:function(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,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 t=0;t<this.timeline.length;t++)this.timeline[t].isRunning||(this.timeline[t].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(t){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;var i=this.timeline[this.current].update(t);if(i===e.TweenData.PENDING)return!0;if(i===e.TweenData.RUNNING)return 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;if(i===e.TweenData.LOOPED)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(i===e.TweenData.COMPLETE){var s=!1;return this.reverse?--this.current<0&&(this.current=this.timeline.length-1,s=!0):++this.current===this.timeline.length&&(this.current=0,s=!0),s?-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)}},generateData:function(t,e){if(null===this.game||null===this.target)return null;void 0===t&&(t=60),void 0===e&&(e=[]);for(s=0;s<this.timeline.length;s++)for(var i in this.timeline[s].vEnd)this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1);for(s=0;s<this.timeline.length;s++)this.timeline[s].loadValues();for(var s=0;s<this.timeline.length;s++)e=e.concat(this.timeline[s].generateData(t));return e}},Object.defineProperty(e.Tween.prototype,"totalDuration",{get:function(){for(var t=0,e=0;e<this.timeline.length;e++)t+=this.timeline[e].duration;return t}}),e.Tween.prototype.constructor=e.Tween,e.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=e.Easing.Default,this.interpolationFunction=e.Math.linearInterpolation,this.interpolationContext=e.Math,this.isRunning=!1,this.isFrom=!1},e.TweenData.PENDING=0,e.TweenData.RUNNING=1,e.TweenData.LOOPED=2,e.TweenData.COMPLETE=3,e.TweenData.prototype={to:function(t,e,i,s,n,o){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=o,this.isFrom=!1,this},from:function(t,e,i,s,n,o){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=o,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t],this.parent.target[t]=this.vStart[t];return this.value=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var t in this.parent.properties){if(this.vStart[t]=this.parent.properties[t],Array.isArray(this.vEnd[t])){if(0===this.vEnd[t].length)continue;0===this.percent&&(this.vEnd[t]=[this.vStart[t]].concat(this.vEnd[t]))}void 0!==this.vEnd[t]?("string"==typeof this.vEnd[t]&&(this.vEnd[t]=this.vStart[t]+parseFloat(this.vEnd[t])),this.parent.properties[t]=this.vEnd[t]):this.vEnd[t]=this.vStart[t],this.vStartCache[t]=this.vStart[t],this.vEndCache[t]=this.vEnd[t]}return this},update:function(t){if(this.isRunning){if(t<this.startTime)return e.TweenData.RUNNING}else{if(!(t>=this.startTime))return e.TweenData.PENDING;this.isRunning=!0}var i=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=i*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=i*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);for(var s in this.vEnd){var n=this.vStart[s],o=this.vEnd[s];Array.isArray(o)?this.parent.target[s]=this.interpolationFunction.call(this.interpolationContext,o,this.value):this.parent.target[s]=n+(o-n)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():e.TweenData.RUNNING},generateData:function(t){this.parent.reverse?this.dt=this.duration:this.dt=0;var e=[],i=!1,s=1/t*1e3;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);var n={};for(var o in this.vEnd){var r=this.vStart[o],a=this.vEnd[o];Array.isArray(a)?n[o]=this.interpolationFunction.call(this.interpolationContext,a,this.value):n[o]=r+(a-r)*this.value}e.push(n),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=e.slice();h.reverse(),e=e.concat(h)}return e},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,e.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return e.TweenData.COMPLETE;if(this.inReverse)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(var 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.parent.reverse?this.dt=this.duration:this.dt=0,e.TweenData.LOOPED}},e.TweenData.prototype.constructor=e.TweenData,e.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)},Out:function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)},InOut:function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:(.1,-1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4))},Out:function(t){return 0===t?0:1===t?1:(.1,1*Math.pow(2,-10*t)*Math.sin((t-.1)*(2*Math.PI)/.4)+1)},InOut:function(t){return 0===t?0:1===t?1:(.1,(t*=2)<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-e.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*e.Easing.Bounce.In(2*t):.5*e.Easing.Bounce.Out(2*t-1)+.5}}},e.Easing.Default=e.Easing.Linear.None,e.Easing.Power0=e.Easing.Linear.None,e.Easing.Power1=e.Easing.Quadratic.Out,e.Easing.Power2=e.Easing.Cubic.Out,e.Easing.Power3=e.Easing.Quartic.Out,e.Easing.Power4=e.Easing.Quintic.Out,e.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 e.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},e.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(t){return this._timers.push(t),t},create:function(t){void 0===t&&(t=!0);var i=new e.Timer(this.game,t);return this._timers.push(i),i},removeAll:function(){for(var t=0;t<this._timers.length;t++)this._timers[t].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t},update:function(t){var e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e,this.prevTime=this.now,this.now=t,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-t))),this.timeExpected=t+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var t=0,e=this._timers.length;t<e;)this._timers[t].update(this.time)?t++:(this._timers.splice(t,1),e--)},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 t=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/t),this.ups=Math.round(1e3*this.updates/t),this.rps=Math.round(1e3*this.renders/t),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}},preUpdate:function(){this.advancedTiming&&this.updates++},preRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var t=this._timers.length;t--;)this._timers[t]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var t=this._timers.length;t--;)this._timers[t]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(t){return this.time-t},elapsedSecondsSince:function(t){return.001*(this.time-t)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(e.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(t){this._desiredFps=t,this.physicsElapsed=1/t,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/t}}),e.Time.prototype.constructor=e.Time,e.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 e.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},e.Timer.MINUTE=6e4,e.Timer.SECOND=1e3,e.Timer.HALF=500,e.Timer.QUARTER=250,e.Timer.prototype={create:function(t,i,s,n,o,r){var a=t=Math.round(t);0===this._now?a+=this.game.time.time:a+=this._now;var h=new e.TimerEvent(this,t,a,s,i,n,o,r);return this.events.push(h),this.order(),this.expired=!1,h},add:function(t,e,i){return this.create(t,!1,0,e,i,Array.prototype.slice.call(arguments,3))},repeat:function(t,e,i,s){return this.create(t,!1,e,i,s,Array.prototype.slice.call(arguments,4))},loop:function(t,e,i){return this.create(t,!0,0,e,i,Array.prototype.slice.call(arguments,3))},start:function(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(var e=0;e<this.events.length;e++)this.events[e].tick=this.events[e].delay+this._started}},stop:function(t){this.running=!1,void 0===t&&(t=!0),t&&(this.events.length=0)},remove:function(t){for(var e=0;e<this.events.length;e++)if(this.events[e]===t)return this.events[e].pendingDelete=!0,!0;return!1},order:function(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(t,e){return t.tick<e.tick?-1:t.tick>e.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(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running;){var e=this.events[this._i];if(!(this._now>=e.tick)||e.pendingDelete)break;this._newTick=this._now+e.delay-(this._now-e.tick),this._newTick<0&&(this._newTick=this._now+e.delay),!0===e.loop?(e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):e.repeatCount>0?(e.repeatCount--,e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):(this._marked++,e.pendingDelete=!0,e.callback.apply(e.callbackContext,e.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(t){for(var e=0;e<this.events.length;e++)if(!this.events[e].pendingDelete){var i=this.events[e].tick-t;i<0&&(i=0),this.events[e].tick=this._now+i}var s=this.nextTick-t;this.nextTick=s<0?this._now:this._now+s},resume:function(){if(this.paused){var t=this.game.time.time;this._pauseTotal+=t-this._now,this._now=t,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(e.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(e.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(e.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(e.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(e.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),e.Timer.prototype.constructor=e.Timer,e.TimerEvent=function(t,e,i,s,n,o,r,a){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=o,this.callbackContext=r,this.args=a,this.pendingDelete=!1},e.TimerEvent.prototype.constructor=e.TimerEvent,e.AnimationManager=function(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(t,e){if(void 0===t)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(t);return this._frameData=t,void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},copyFrameData:function(t,e){if(this._frameData=t.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},add:function(t,i,s,n,o){return i=i||[],s=s||60,void 0===n&&(n=!1),void 0===o&&(o=!(!i||"number"!=typeof i[0])),this._outputFrames=[],this._frameData.getFrameIndexes(i,o,this._outputFrames),this._anims[t]=new e.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,s,n),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(t,e){void 0===e&&(e=!0);for(var i=0;i<t.length;i++)if(!0===e){if(t[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0},play:function(t,e,i,s){if(this._anims[t])return this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s))},stop:function(t,e){void 0===e&&(e=!1),!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)},previous:function(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(t){return"string"==typeof t&&this._anims[t]?this._anims[t]:null},refreshFrame:function(){},destroy:function(){t=null;for(var t in this._anims)this._anims.hasOwnProperty(t)&&this._anims[t].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},e.AnimationManager.prototype.constructor=e.AnimationManager,Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(e.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(t){var e;"number"==typeof t&&this._frameData&&(e=this._frameData.getFrame(t))&&(this.currentFrame=e,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(t){var e;"string"==typeof t&&this._frameData&&(e=this._frameData.getFrameByName(t))?(this.currentFrame=e,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+t)}}),e.Animation=function(t,i,s,n,o,r,a){void 0===a&&(a=!1),this.game=t,this._parent=i,this._frameData=n,this.name=s,this._frames=[],this._frames=this._frames.concat(o),this.delay=1e3/r,this.loop=a,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 e.Signal,this.onUpdate=null,this.onComplete=new e.Signal,this.onLoop=new e.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},e.Animation.prototype={play:function(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),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(t,e){var i;if(void 0===e&&(e=!1),"string"==typeof t)for(s=0;s<this._frames.length;s++)this._frameData.getFrame(this._frames[s]).name===t&&(i=s);else if("number"==typeof t)if(e)i=t;else for(var s=0;s<this._frames.length;s++)this._frames[s]===t&&(i=s);if(i){var n=this.isReversed?-1:1;this._frameIndex=i-n,this._timeNextFrame=this.game.time.time,this.update()}},stop:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,t&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),e&&(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 t=this.game.time.time,e=t-this._timeNextFrame;return!!(this.isPlaying&&e>=0)&&(this._frameSkip=1,this._frameDiff=e,this._timeLastFrame=t,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=t+(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(t,e){if(void 0===e&&(e=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(t){void 0===t&&(t=1);var e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},previous:function(t){void 0===t&&(t=1);var e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e++),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},updateFrameData:function(t){this._frameData=t,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()}},e.Animation.prototype.constructor=e.Animation,Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(e.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(e.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){t>0&&(this.delay=1e3/t)}}),Object.defineProperty(e.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new e.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),e.Animation.generateFrameNames=function(t,i,s,n,o){void 0===n&&(n="");var r=[],a="";if(i<s)for(h=i;h<=s;h++)a=t+(a="number"==typeof o?e.Utils.pad(h.toString(),o,"0",1):h.toString())+n,r.push(a);else for(var h=i;h>=s;h--)a=t+(a="number"==typeof o?e.Utils.pad(h.toString(),o,"0",1):h.toString())+n,r.push(a);return r},e.Frame=function(t,i,s,n,o,r){this.index=t,this.x=i,this.y=s,this.width=n,this.height=o,0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+r+'" has a width or height of zero'),this.name=r,this.centerX=Math.floor(n/2),this.centerY=Math.floor(o/2),this.distance=e.Math.distance(0,0,n,o),this.rotated=!1,this.trimmed=!1,this.sourceSizeW=n,this.sourceSizeH=o,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},e.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=e.Math.distance(0,0,t,i),this.sourceSizeW=t,this.sourceSizeH=i,this.right=this.x+t,this.bottom=this.y+i},setTrim:function(t,e,i,s,n,o,r){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=o,this.spriteSourceSizeH=r)},clone:function(){var t=new e.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var i in this)this.hasOwnProperty(i)&&(t[i]=this[i]);return t},getRect:function(t){return void 0===t?t=new e.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},e.Frame.prototype.constructor=e.Frame,e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t},getFrame:function(t){return t>=this._frames.length&&(t=0),this._frames[t]},getFrameByName:function(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null},checkFrameName:function(t){return null!=this._frameNames[t]},clone:function(){for(var t=new e.FrameData,i=0;i<this._frames.length;i++)t._frames.push(this._frames[i].clone());for(var s in this._frameNames)this._frameNames.hasOwnProperty(s)&&(t._frameNames[s]=this._frameNames[s]);return t},getFrameRange:function(t,e,i){void 0===i&&(i=[]);for(var s=t;s<=e;s++)i.push(this._frames[s]);return i},getFrames:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s]);else for(var s=0;s<t.length;s++)e?i.push(this.getFrame(t[s])):i.push(this.getFrameByName(t[s]));return i},getFrameIndexes:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s].index);else for(var s=0;s<t.length;s++)e&&this._frames[t[s]]?i.push(this._frames[t[s]].index):this.getFrameByName(t[s])&&i.push(this.getFrameByName(t[s]).index);return i},destroy:function(){this._frames=null,this._frameNames=null}},e.FrameData.prototype.constructor=e.FrameData,Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(t,i,s,n,o,r,a,h){void 0===o&&(o=-1),void 0===r&&(r=0),void 0===a&&(a=0),void 0===h&&(h=0);var l=i;if("string"==typeof i?l=t.cache.getImage(i):i=l.name,null===l)return null;if(s<=0||n<=0)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' frameWidth (%s) or frameHeight (%s) must be positive",i,s,n),null;var c=l.width,u=l.height;if(0===c||0===u)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is zero",i,c,u),null;if(c<s||u<n)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is less than the given frameWidth (%s) or frameHeight (%s)",i,c,u,s,n),null;var d=Math.floor((c-r)/(s+a)),p=Math.floor((u-r)/(n+a)),f=d*p,g=f,m=f-1,y=0,v=m;if(h>f||h<-f)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",i,h,f),null;if(o>-1&&(v=(f=o)-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,s+r+a,s,r,a),p<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,u,n+r+a,n,r,a),0===g)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' zero frames were produced",i),null;if(h>0?v=(y=h)+(f=Math.min(f,g-h))-1:h<0&&(y=(v=m+h)-(f=Math.min(f,g+h))+1),y<0)return console.warn("First frame index %s is outside of range [0, %d]",y,m),null;if(v>m)return console.warn("Last frame index %s is outside of range [0, %d]",v,m),null;for(var x=new e.FrameData,b=r,_=r,w=0,T=0;T<g&&!(T>v);T++)T>=y&&x.addFrame(new e.Frame(w++,b,_,s,n,"")),(b+=s+a)+s>c&&(b=r,_+=n+a);return x},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 s,n=new e.FrameData,o=i.frames,r=0;r<o.length;r++)s=n.addFrame(new e.Frame(r,o[r].frame.x,o[r].frame.y,o[r].frame.w,o[r].frame.h,o[r].filename)),o[r].trimmed&&s.setTrim(o[r].trimmed,o[r].sourceSize.w,o[r].sourceSize.h,o[r].spriteSourceSize.x,o[r].spriteSourceSize.y,o[r].spriteSourceSize.w,o[r].spriteSourceSize.h),o[r].rotated&&(s.rotated=!0);return n},JSONDataPyxel:function(t,i){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(t){if(!i[t])return console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "'+t+'" 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 s=new e.FrameData,n=i.tileheight,o=i.tilewidth,r=i.layers[0].tiles,a=0;a<r.length;a++)s.addFrame(new e.Frame(a,r[a].x,r[a].y,o,n,"frame_"+a)).setTrim(!1);return s},JSONDataHash:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(i);var s,n=new e.FrameData,o=i.frames,r=0;for(var a in o)s=n.addFrame(new e.Frame(r,o[a].frame.x,o[a].frame.y,o[a].frame.w,o[a].frame.h,a)),o[a].trimmed&&s.setTrim(o[a].trimmed,o[a].sourceSize.w,o[a].sourceSize.h,o[a].spriteSourceSize.x,o[a].spriteSourceSize.y,o[a].spriteSourceSize.w,o[a].spriteSourceSize.h),o[a].rotated&&(s.rotated=!0),r++;return n},XMLData:function(t,i){if(i.getElementsByTagName("TextureAtlas")){for(var s,n,o,r,a,h,l,c,u,d,p,f=new e.FrameData,g=i.getElementsByTagName("SubTexture"),m=0;m<g.length;m++)n=(o=g[m].attributes).name.value,r=parseInt(o.x.value,10),a=parseInt(o.y.value,10),h=parseInt(o.width.value,10),l=parseInt(o.height.value,10),c=null,u=null,o.frameX&&(c=Math.abs(parseInt(o.frameX.value,10)),u=Math.abs(parseInt(o.frameY.value,10)),d=parseInt(o.frameWidth.value,10),p=parseInt(o.frameHeight.value,10)),s=f.addFrame(new e.Frame(m,r,a,h,l,n)),null===c&&null===u||s.setTrim(!0,h,l,c,u,d,p);return f}console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag")}},e.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:{},data:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new e.Signal,this._cacheMap=[],this._cacheMap[e.Cache.CANVAS]=this._cache.canvas,this._cacheMap[e.Cache.IMAGE]=this._cache.image,this._cacheMap[e.Cache.TEXTURE]=this._cache.texture,this._cacheMap[e.Cache.SOUND]=this._cache.sound,this._cacheMap[e.Cache.TEXT]=this._cache.text,this._cacheMap[e.Cache.PHYSICS]=this._cache.physics,this._cacheMap[e.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[e.Cache.BINARY]=this._cache.binary,this._cacheMap[e.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[e.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[e.Cache.JSON]=this._cache.json,this._cacheMap[e.Cache.XML]=this._cache.xml,this._cacheMap[e.Cache.VIDEO]=this._cache.video,this._cacheMap[e.Cache.SHADER]=this._cache.shader,this._cacheMap[e.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._cacheMap[e.Cache.DATA]=this._cache.data,this._pendingCount=0,this.onReady=new e.Signal,this._addImages()},e.Cache.CANVAS=1,e.Cache.IMAGE=2,e.Cache.TEXTURE=3,e.Cache.SOUND=4,e.Cache.TEXT=5,e.Cache.PHYSICS=6,e.Cache.TILEMAP=7,e.Cache.BINARY=8,e.Cache.BITMAPDATA=9,e.Cache.BITMAPFONT=10,e.Cache.JSON=11,e.Cache.XML=12,e.Cache.VIDEO=13,e.Cache.SHADER=14,e.Cache.RENDER_TEXTURE=15,e.Cache.DATA=16,e.Cache.DEFAULT=null,e.Cache.DEFAULT_KEY="__default",e.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",e.Cache.MISSING=null,e.Cache.MISSING_KEY="__missing",e.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",e.Cache.READY_TIMEOUT=1e3,e.Cache.prototype={addCompressedTextureMetaData:function(t,i,s,n){this.checkImageKey(t)&&this.removeImage(t);var o=s in e.LoaderParser?e.LoaderParser[s](n):n,r={key:t,url:i,data:o,base:new PIXI.BaseTexture(o,null,this.game.resolution),frame:new e.Frame(0,0,0,o.width,o.height,t),frameData:new e.FrameData,fileFormat:s};return r.frameData.addFrame(new e.Frame(0,0,0,o.width,o.height,i)),this._cache.image[t]=r,this._resolveURL(i,r),r},addCanvas:function(t,e,i){void 0===i&&(i=e.getContext("2d")),this._cache.canvas[t]={canvas:e,context:i}},addImage:function(t,i,s){this.checkImageKey(t)&&this.removeImage(t),!1===s.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var n={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution),frame:new e.Frame(0,0,0,s.width,s.height,t),frameData:new e.FrameData};return n.frameData.addFrame(new e.Frame(0,0,0,s.width,s.height,i)),this._cache.image[t]=n,this._resolveURL(i,n),"__default"===t?e.Cache.DEFAULT=new PIXI.Texture(n.base):"__missing"===t&&(e.Cache.MISSING=new PIXI.Texture(n.base)),n},addImageAsync:function(t,e,i){var s=this,n=new Image;n.onload=function(){i.call(this,s.addImage(t,null,n)),s._removePending(),n.onload=null},this._addPending(),n.src=e},addDefaultImage:function(){this.addImageAsync(e.Cache.DEFAULT_KEY,e.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,e.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(e.Cache.MISSING_KEY,e.Cache.MISSING_SRC,function(t){e.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(t,e,i,s,n){void 0===s&&(s=!0,n=!1),void 0===n&&(s=!1,n=!0);var o=!1;n&&(o=!0),this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:o,webAudio:s,audioTag:n,locked:this.game.sound.touchLocked},this._resolveURL(e,this._cache.sound[t])},addText:function(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])},addPhysicsData:function(t,e,i,s){this._cache.physics[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.physics[t])},addTilemap:function(t,e,i,s){this._cache.tilemap[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.tilemap[t])},addBinary:function(t,e){this._cache.binary[t]=e},addBitmapData:function(t,i,s){return i.key=t,void 0===s&&(s=new e.FrameData).addFrame(i.textureFrame),this._cache.bitmapData[t]={data:i,frameData:s},i},addBitmapFont:function(t,i,s,n,o,r,a){var h={url:i,data:s,font:null,base:new PIXI.BaseTexture(s,null,this.game.resolution)};void 0===r&&(r=0),void 0===a&&(a=0),h.font="json"===o?e.LoaderParser.jsonBitmapFont(n,h.base,r,a,!1,this.game.resolution):e.LoaderParser.xmlBitmapFont(n,h.base,r,a,!1,this.game.resolution),this._cache.bitmapFont[t]=h,this._resolveURL(i,h)},addBitmapFontFromAtlas:function(t,i,s,n,o,r,a){var h=this.getFrameByName(i,s);if(h){var l={font:null,base:this.getBaseTexture(i),frame:h};void 0===r&&(r=0),void 0===a&&(a=0);var c;"json"===o?(c=this.getJSON(n),l.font=e.LoaderParser.jsonBitmapFont(c,l.base,r,a,h,this.game.resolution)):(c=this.getXML(n),l.font=e.LoaderParser.xmlBitmapFont(c,l.base,r,a,h,this.game.resolution)),this._cache.bitmapFont[t]=l}},addJSON:function(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])},addXML:function(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])},addVideo:function(t,e,i,s){this._cache.video[t]={url:e,data:i,isBlob:s,locked:!0},this._resolveURL(e,this._cache.video[t])},addShader:function(t,e,i){this._cache.shader[t]={url:e,data:i},this._resolveURL(e,this._cache.shader[t])},addRenderTexture:function(t,i){this._cache.renderTexture[t]={texture:i,frame:new e.Frame(0,0,0,i.width,i.height,"","")}},addSpriteSheet:function(t,i,s,n,o,r,a,h,l){void 0===r&&(r=-1),void 0===a&&(a=0),void 0===h&&(h=0);var c={key:t,url:i,data:s,frameWidth:n,frameHeight:o,margin:a,spacing:h,base:new PIXI.BaseTexture(s,null,this.game.resolution),frameData:e.AnimationParser.spriteSheet(this.game,s,n,o,r,a,h,l)};this._cache.image[t]=c,this._resolveURL(i,c)},addTextureAtlas:function(t,i,s,n,o){var r={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution)};o===e.Loader.TEXTURE_ATLAS_XML_STARLING?r.frameData=e.AnimationParser.XMLData(this.game,n,t):o===e.Loader.TEXTURE_ATLAS_JSON_PYXEL?r.frameData=e.AnimationParser.JSONDataPyxel(this.game,n,t):Array.isArray(n.frames)?r.frameData=e.AnimationParser.JSONData(this.game,n,t):r.frameData=e.AnimationParser.JSONDataHash(this.game,n,t),this._cache.image[t]=r,this._resolveURL(i,r)},addData:function(t,e){this._cache.data[t]=e},reloadSound:function(t){var e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",function(){return e.reloadSoundComplete(t)},!1),i.data.load())},reloadSoundComplete:function(t){var e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))},updateSound:function(t,e,i){var s=this.getSound(t);s&&(s[e]=i)},decodedSound:function(t,e){var i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1},isSoundDecoded:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded},isSoundReady:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded&&!this.game.sound.touchLocked},checkKey:function(t,e){return!!this._cacheMap[t][e]},checkURL:function(t){return!!this._urlMap[this._resolveURL(t)]},checkCanvasKey:function(t){return this.checkKey(e.Cache.CANVAS,t)},checkDataKey:function(t){return this.checkKey(e.Cache.DATA,t)},checkImageKey:function(t){return this.checkKey(e.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(e.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(e.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(e.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(e.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(e.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(e.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(e.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(e.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(e.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(e.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(e.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(e.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(e.Cache.RENDER_TEXTURE,t)},getItem:function(t,e,i,s){return this.checkKey(e,t)?void 0===s?this._cacheMap[e][t]:this._cacheMap[e][t][s]:(i&&console.warn("Phaser.Cache."+i+': Key "'+t+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,e.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,i){void 0!==t&&null!==t||(t="__default"),void 0===i&&(i=!1);var s=this.getItem(t,e.Cache.IMAGE,"getImage");return null===s&&(s=this.getItem("__missing",e.Cache.IMAGE,"getImage")),i?s:s.data},getTextureFrame:function(t){return this.getItem(t,e.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,e.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,e.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,e.Cache.TEXT,"getText","data")},getPhysicsData:function(t,i,s){var n=this.getItem(t,e.Cache.PHYSICS,"getPhysicsData","data");if(null===n||void 0===i||null===i)return n;if(n[i]){var o=n[i];if(!o||!s)return o;for(var r in o)if((r=o[r]).fixtureKey===s)return r;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+s+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+i+'"');return null},getTilemapData:function(t){return this.getItem(t,e.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,e.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,e.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,e.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,i){var s=this.getItem(t,e.Cache.JSON,"getJSON","data");return s?i?e.Utils.extend(!0,Array.isArray(s)?[]:{},s):s:null},getXML:function(t){return this.getItem(t,e.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,e.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,e.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,e.Cache.RENDER_TEXTURE,"getRenderTexture")},getData:function(t){return this.getItem(t,e.Cache.DATA,"getData")},getBaseTexture:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getBaseTexture","base")},getFrame:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrame","frame")},getFrameCount:function(t,e){var i=this.getFrameData(t,e);return i?i.total:0},getFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrameData","frameData")},hasFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),null!==this.getItem(t,i,"","frameData")},updateFrameData:function(t,i,s){void 0===s&&(s=e.Cache.IMAGE),this._cacheMap[s][t]&&(this._cacheMap[s][t].frameData=i)},getFrameByIndex:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrame(e):null},getFrameByName:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrameByName(e):null},getURL:function(t){return(t=this._resolveURL(t))?this._urlMap[t]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+t+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){void 0===t&&(t=e.Cache.IMAGE);var i=[];if(this._cacheMap[t])for(var s in this._cacheMap[t])"__default"!==s&&"__missing"!==s&&i.push(s);return i},removeCanvas:function(t){delete this._cache.canvas[t]},removeImage:function(t,e){void 0===e&&(e=!0);var i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]},removeSound:function(t){delete this._cache.sound[t]},removeText:function(t){delete this._cache.text[t]},removePhysics:function(t){delete this._cache.physics[t]},removeTilemap:function(t){delete this._cache.tilemap[t]},removeBinary:function(t){delete this._cache.binary[t]},removeBitmapData:function(t){delete this._cache.bitmapData[t]},removeBitmapFont:function(t){delete this._cache.bitmapFont[t]},removeJSON:function(t){delete this._cache.json[t]},removeXML:function(t){delete this._cache.xml[t]},removeVideo:function(t){delete this._cache.video[t]},removeShader:function(t){delete this._cache.shader[t]},removeRenderTexture:function(t){delete this._cache.renderTexture[t]},removeSpriteSheet:function(t){delete this._cache.spriteSheet[t]},removeTextureAtlas:function(t){delete this._cache.image[t]},removeData:function(t){delete this._cache.data[t]},clearGLTextures:function(){for(var t in this._cache.image)this._cache.image[t].base._glTextures=[]},_resolveURL:function(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null},destroy:function(){for(var t=0;t<this._cacheMap.length;t++){var e=this._cacheMap[t];for(var i in e)"__default"!==i&&"__missing"!==i&&(this.destroyItem(e[i]),delete e[i])}this._urlMap=null,this._urlResolver=null,this._urlTemp=null},destroyItem:function(t){t.destroy?t.destroy():(t.base&&t.base.destroy&&t.base.destroy(),t.data&&t.data.destroy&&t.data.destroy(),t.frameData&&t.frameData.destroy&&t.frameData.destroy(),t.texture&&t.texture.destroy&&t.texture.destroy(!0))},_addImages:function(){this._pendingCount=0,this.addDefaultImage(),this.addMissingImage();var t=this,i=e.Cache.READY_TIMEOUT;e.Cache.READY_TIMEOUT>0?setTimeout(function(){t.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",i),t._ready())},e.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)}},e.Cache.prototype.constructor=e.Cache,Object.defineProperty(e.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),e.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 e.Signal,this.onBeforeLoadComplete=new e.Signal,this.onLoadComplete=new e.Signal,this.onPackComplete=new e.Signal,this.onFileStart=new e.Signal,this.onFileComplete=new e.Signal,this.onFileError=new e.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},e.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,e.Loader.TEXTURE_ATLAS_JSON_HASH=1,e.Loader.TEXTURE_ATLAS_XML_STARLING=2,e.Loader.PHYSICS_LIME_CORONA_JSON=3,e.Loader.PHYSICS_PHASER_JSON=4,e.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,e.Loader.mediaTypes={avif:"image/avif",bmp:"image/bmp",cur:"image/x-icon",gif:"image/gif",ico:"image/x-icon",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp"},e.Loader.getMediaType=function(t){var i=t.match(/\.(\w+)$/);return i?e.Loader.mediaTypes[i[1]]||null:null},e.Loader._getSource=function(t){return"string"==typeof t?{url:t,type:e.Loader.getMediaType(t)}:t},e.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 e.Rectangle(0,0,1,t.height):new e.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(t,e){return this.getAssetIndex(t,e)>-1},getAssetIndex:function(t,e){for(var i=-1,s=0;s<this._fileList.length;s++){var n=this._fileList[s];if(n.type===t&&n.key===e&&(i=s,!n.loaded&&!n.loading))break}return i},getAsset:function(t,e){var i=this.getAssetIndex(t,e);return i>-1&&{index:i,file:this._fileList[i]}},reset:function(t,e){void 0===e&&(e=!1),this.resetLocked||(t&&(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,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(t,e,i,s,n,o){if(void 0===n&&(n=!1),void 0===e||""===e)return console.warn("Phaser.Loader: Invalid or no key given of type "+t),this;if(void 0===i||null===i){if(!o)return console.warn("Phaser.Loader: No URL given for file type: "+t+" key: "+e),this;i=e+o}var r={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s)for(var a in s)r[a]=s[a];var h=this.getAssetIndex(t,e);if(n&&h>-1){var l=this._fileList[h];l.loading||l.loaded?(this._fileList.push(r),this._totalFileCount++):this._fileList[h]=r}else-1===h&&(this._fileList.push(r),this._totalFileCount++);return this},replaceInFileList:function(t,e,i,s){return this.addToFileList(t,e,i,s,!0)},pack:function(t,e,i,s){if(void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=null),!e&&!i)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(var o=0;o<this._fileList.length+1;o++){var r=this._fileList[o];if(!r||!r.loaded&&!r.loading&&"packfile"!==r.type){this._fileList.splice(o,0,n),this._totalPackCount++;break}}return this},image:function(t,e,i){return Array.isArray(e)?this.imageset(t,e,i):"object"==typeof e?this.texture(t,e,i):this.addToFileList("image",t,e,void 0,i,".png")},imageset:function(t,e,i){var s=e[e.length-1],n="string"==typeof s?s:s.url;return this.addToFileList("imageset",t,n,{sources:e},i)},imageFromBitmapData:function(t,e,i){return this.image(t,e.canvas.toDataURL("image/png"),i)},imageFromGrid:function(t,e,i,s,n,o){return this.imageFromBitmapData(t,this.game.create.grid(t,e,i,s,n,o,!1))},imageFromTexture:function(t,e,i,s,n){return this.imageFromBitmapData(t,this.game.create.texture(t,e,i,s,n,!1))},texture:function(t,i,s){if(this.game.renderType===e.WEBGL){var n,o=this.game.renderer.extensions.compression;for(n in i)if(n.toUpperCase()in o)return this.addToFileList("texture",t,i[n],void 0,s,".pvr")}return i.truecolor&&this.addToFileList("image",t,i.truecolor,void 0,s,".png"),this},images:function(t,e){if(Array.isArray(e))for(i=0;i<t.length;i++)this.image(t[i],e[i]);else for(var i=0;i<t.length;i++)this.image(t[i]);return this},text:function(t,e,i){return this.addToFileList("text",t,e,void 0,i,".txt")},json:function(t,e,i){return this.addToFileList("json",t,e,void 0,i,".json")},shader:function(t,e,i){return this.addToFileList("shader",t,e,void 0,i,".frag")},xml:function(t,e,i){return this.addToFileList("xml",t,e,void 0,i,".xml")},script:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=this),this.addToFileList("script",t,e,{syncPoint:!0,callback:i,callbackContext:s},!1,".js")},binary:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=i),this.addToFileList("binary",t,e,{callback:i,callbackContext:s},!1,".bin")},spritesheet:function(t,e,i,s,n,o,r,a){return void 0===n&&(n=-1),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),this.addToFileList("spritesheet",t,e,{frameWidth:i,frameHeight:s,frameMax:n,margin:o,spacing:r,skipFrames:a},!1,".png")},audio:function(t,e,i){return this.game.sound.noAudio?this:(void 0===i&&(i=!0),"string"==typeof e&&(e=[e]),this.addToFileList("audio",t,e,{buffer:null,autoDecode:i}))},audioSprite:function(t,e,i,s,n){return this.game.sound.noAudio?this:(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=!0),this.audio(t,e,n),i?this.json(t+"-audioatlas",i):s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addJSON(t+"-audioatlas","",s)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},audiosprite:function(t,e,i,s,n){return this.audioSprite(t,e,i,s,n)},video:function(t,e,i,s){return void 0===i&&(i=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===s&&(s=!1),"string"==typeof e&&(e=[e]),this.addToFileList("video",t,e,{buffer:null,asBlob:s,loadEvent:i})},tilemap:function(t,i,s,n){if(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Tilemap.CSV),i||s||(i=n===e.Tilemap.CSV?t+".csv":t+".json"),s){switch(n){case e.Tilemap.CSV:break;case e.Tilemap.TILED_JSON:"string"==typeof s&&(s=JSON.parse(s))}this.cache.addTilemap(t,null,s,n)}else this.addToFileList("tilemap",t,i,{format:n});return this},tilemapCSV:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.CSV)},tilemapTiledJSON:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.TILED_JSON)},physics:function(t,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Physics.LIME_CORONA_JSON),i||s||(i=t+".json"),s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addPhysicsData(t,null,s,n)):this.addToFileList("physics",t,i,{format:n}),this},bitmapFont:function(t,e,i,s,n,o){if(void 0!==e&&null!==e||(e=t+".png"),void 0===i&&(i=null),void 0===s&&(s=null),null===i&&null===s&&(i=t+".xml"),void 0===n&&(n=0),void 0===o&&(o=0),i)this.addToFileList("bitmapfont",t,e,{atlasURL:i,xSpacing:n,ySpacing:o});else if("string"==typeof s){var r,a;try{r=JSON.parse(s)}catch(t){a=this.parseXml(s)}if(!a&&!r)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",t,e,{atlasURL:null,atlasData:r||a,atlasType:r?"json":"xml",xSpacing:n,ySpacing:o})}return this},atlasJSONArray:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(t,i,s,n){return void 0===s&&(s=null),void 0===n&&(n=null),s||n||(s=t+".xml"),this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(t,i,s,n,o){if(void 0!==i&&null!==i||(i=t+".png"),void 0===s&&(s=null),void 0===n&&(n=null),void 0===o&&(o=e.Loader.TEXTURE_ATLAS_JSON_ARRAY),s||n||(s=o===e.Loader.TEXTURE_ATLAS_XML_STARLING?t+".xml":t+".json"),s)this.addToFileList("textureatlas",t,i,{atlasURL:s,format:o});else{switch(o){case e.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof n&&(n=JSON.parse(n));break;case e.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof n){var r=this.parseXml(n);if(!r)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");n=r}}this.addToFileList("textureatlas",t,i,{atlasURL:null,atlasData:n,format:o})}return this},withSyncPoint:function(t,e){this._withSyncPointDepth++;try{t.call(e||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(t,e){var i=this.getAsset(t,e);return i&&(i.file.syncPoint=!0),this},removeFile:function(t,e){var i=this.getAsset(t,e);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(){if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(i=0;i<this._flightQueue.length;i++)((s=this._flightQueue[i]).loaded||s.error)&&(this._flightQueue.splice(i,1),i--,s.loading=!1,s.requestUrl=null,s.requestObject=null,s.error&&this.onFileError.dispatch(s.key,s),"packfile"!==s.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,s.key,!s.error,this._loadedFileCount,this._totalFileCount)):"packfile"===s.type&&s.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)));for(var t=!1,e=this.enableParallel?Math.max(1,this.maxParallelDownloads):1,i=this._processingHead;i<this._fileList.length;i++){var s=this._fileList[i];if("packfile"===s.type&&!s.error&&s.loaded&&i===this._processingHead&&(this.processPack(s),this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)),s.loaded||s.error?i===this._processingHead&&(this._processingHead=i+1):!s.loading&&this._flightQueue.length<e&&("packfile"!==s.type||s.data?t||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(s),s.loading=!0,this.onFileStart.dispatch(this.progress,s.key,s.url),this.loadFile(s)):(this._flightQueue.push(s),s.loading=!0,this.loadFile(s))),!s.loaded&&s.syncPoint&&(t=!0),this._flightQueue.length>=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var n=this;setTimeout(function(){n.finishedLoading(!0)},2e3)}},finishedLoading:function(t){!this.hasLoaded&&this.game.state&&(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state.loadComplete())},asyncComplete:function(t,e){void 0===e&&(e=""),t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn("Phaser.Loader - "+t.type+"["+t.key+"]: "+e)),this.processLoadQueue()},processPack:function(t){var i=t.data[t.key];if(i)for(var s=0;s<i.length;s++){var n=i[s];switch(n.type){case"image":this.image(n.key,n.url,n.overwrite);break;case"text":this.text(n.key,n.url,n.overwrite);break;case"json":this.json(n.key,n.url,n.overwrite);break;case"xml":this.xml(n.key,n.url,n.overwrite);break;case"script":this.script(n.key,n.url,n.callback,t.callbackContext||this);break;case"binary":this.binary(n.key,n.url,n.callback,t.callbackContext||this);break;case"spritesheet":this.spritesheet(n.key,n.url,n.frameWidth,n.frameHeight,n.frameMax,n.margin,n.spacing,n.skipFrames);break;case"video":this.video(n.key,n.urls);break;case"audio":this.audio(n.key,n.urls,n.autoDecode);break;case"audiosprite":this.audiosprite(n.key,n.urls,n.jsonURL,n.jsonData,n.autoDecode);break;case"tilemap":this.tilemap(n.key,n.url,n.data,e.Tilemap[n.format]);break;case"physics":this.physics(n.key,n.url,n.data,e.Loader[n.format]);break;case"bitmapFont":this.bitmapFont(n.key,n.textureURL,n.atlasURL,n.atlasData,n.xSpacing,n.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasXML":this.atlasXML(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlas":this.atlas(n.key,n.textureURL,n.atlasURL,n.atlasData,e.Loader[n.format]);break;case"shader":this.shader(n.key,n.url,n.overwrite)}}else console.warn("Phaser.Loader - "+t.key+": pack has data, but not for pack key")},transformUrl:function(t,e){return!!t&&(t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t:this.baseURL+e.path+t)},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"imageset":this.loadPictureTag(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===e.Tilemap.TILED_JSON?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete):t.format===e.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(t){var e=this;t.data=new Image,t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileComplete(t))},t.data.onerror=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileError(t))},t.data.src=this.transformUrl(t.url,t),t.data.complete&&t.data.width&&t.data.height&&(t.data.onload=null,t.data.onerror=null,this.fileComplete(t))},loadPictureTag:function(t){for(var i=this,s=document.createElement("picture"),n=t.sources,o=e.Loader._getSource(n.pop()),r=0,a=n.length;r<a;r++){var h=e.Loader._getSource(n[r]);h.type&&h.url||console.warn('Skipping an invalid source for image "%s" (url: "%s", type: "%s")',t.key,h.url,h.type);var l=document.createElement("source");l.setAttribute("type",h.type),l.setAttribute("srcset",this.transformUrl(h.url,t)),s.appendChild(l)}t.data=document.createElement("img"),t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,t.url=t.data.currentSrc,i.fileComplete(t))},t.data.onerror=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,t.url=t.data.currentSrc,i.fileError(t))},s.appendChild(t.data),t.data.src=this.transformUrl(o.url,t),t.data.complete&&t.data.width&&t.data.height&&(t.data.onload=null,t.data.onerror=null,this.fileComplete(t))},loadVideoTag:function(t){var i=this;t.data=document.createElement("video"),t.data.name=t.key,t.data.controls=!1,t.data.autoplay=!1,t.data.playsInline=!0;var s=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!0,e.GAMES[i.game.id].load.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!1,i.fileError(t)},t.data.addEventListener(t.loadEvent,s,!1),t.data.src=this.transformUrl(t.url,t),t.data.load()},loadAudioTag:function(t){var e=this;if(this.game.sound.touchLocked)t.data=new Audio,t.data.name=t.key,t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),this.fileComplete(t);else{t.data=new Audio,t.data.name=t.key;var i=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileError(t)},t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),t.data.addEventListener("canplaythrough",i,!1),t.data.load()}},xhrLoad:function(t,e,i,s,n){var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=i,!1!==this.headers.requestedWith&&o.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&o.setRequestHeader("Accept",this.headers[t.type]),n=n||this.fileError;var r=this;o.onload=function(){try{return 4===o.readyState&&o.status>=400&&o.status<=599?n.call(r,t,o):s.call(r,t,o)}catch(e){r.hasLoaded?console.error(e):r.asyncComplete(t,e.message||"Exception")}},o.onerror=function(){try{return n.call(r,t,o)}catch(e){r.hasLoaded?console.error(e):r.asyncComplete(t,e.message||"Exception")}},t.requestObject=o,t.requestUrl=e,o.send()},getVideoURL:function(t){for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayVideo(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(i))return t[e]}}return null},getAudioURL:function(t){if(this.game.sound.noAudio)return null;for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayAudio(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(i))return t[e]}}return null},fileError:function(t,e,i){var s="error loading asset from URL "+(t.requestUrl||this.transformUrl(t.url,t));!i&&e&&(i=e.status),i&&(s=s+" ("+i+")"),this.asyncComplete(t,s)},fileComplete:function(t,i){var s=!0;switch(t.type){case"packfile":o=JSON.parse(i.responseText);t.data=o||{};break;case"texture":var n=/\.([^.]+)$/.exec(t.url.split("?",1)[0])[1].toLowerCase();null!==t.data?this.cache.addCompressedTextureMetaData(t.key,t.url,n,t.data):this.cache.addCompressedTextureMetaData(t.key,t.url,n,i.response);break;case"image":case"imageset":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(s=!1,t.format===e.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===e.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===e.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==e.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?(s=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",function(t,e){var i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))})):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(e){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":var o=JSON.parse(i.responseText);this.cache.addPhysicsData(t.key,t.url,o,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.callback?t.data=t.callback.call(t.callbackContext,t.key,i.response):t.data=i.response,this.cache.addBinary(t.key,t.data)}s&&this.asyncComplete(t)},jsonLoadComplete:function(t,e){var i=JSON.parse(e.responseText);"tilemap"===t.type?this.cache.addTilemap(t.key,t.url,i,t.format):"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)},csvLoadComplete:function(t,e){var i=e.responseText;this.cache.addTilemap(t.key,t.url,i,t.format),this.asyncComplete(t)},xmlLoadComplete:function(t,e){var i=e.responseText,s=this.parseXml(i);if(!s){var n=e.responseType||e.contentType;return console.warn("Phaser.Loader - "+t.key+": invalid XML ("+n+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)},parseXml:function(t){var e;try{if(window.DOMParser){var i=new DOMParser;e=i.parseFromString(t,"text/xml")}else(e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e: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(e.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return e.Math.clamp(t||0,0,100)}}),Object.defineProperty(e.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),e.Loader.prototype.constructor=e.Loader,e.LoaderParser={bitmapFont:function(t,e,i,s,n,o){return this.xmlBitmapFont(t,e,i,s,n,o)},xmlBitmapFont:function(t,e,i,s,n,o){null==o&&(o=1);var r={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];r.font=a.getAttribute("face"),r.size=parseInt(a.getAttribute("size"),10),r.lineHeight=parseInt(h.getAttribute("lineHeight"),10)+s,r.chars={};for(var l=t.getElementsByTagName("char"),c=n?n.x:0,u=n?n.y:0,d=0;d<l.length;d++){var p=parseInt(l[d].getAttribute("id"),10),f=r.chars[p]={x:parseInt(l[d].getAttribute("x"),10),y:parseInt(l[d].getAttribute("y"),10),width:parseInt(l[d].getAttribute("width"),10),height:parseInt(l[d].getAttribute("height"),10),xOffset:parseInt(l[d].getAttribute("xoffset"),10)/o,yOffset:parseInt(l[d].getAttribute("yoffset"),10)/o,xAdvance:(parseInt(l[d].getAttribute("xadvance"),10)+i)/o,kerning:{}};if(n&&n.trimmed){if(f.x+f.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(f.width-=f.x+f.width-n.spriteSourceSizeX-n.spriteSourceSizeW),f.y+f.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(f.height-=f.y+f.height-n.spriteSourceSizeY-n.spriteSourceSizeH),f.x<n.spriteSourceSizeX){g=n.spriteSourceSizeX-f.x;f.x=0,f.width-=g,f.xOffset+=g}if(f.y<n.spriteSourceSizeY){var g=n.spriteSourceSizeY-f.y;f.y=0,f.height-=g,f.yOffset+=g}}f.x+=c,f.y+=u}var m=t.getElementsByTagName("kerning");for(d=0;d<m.length;d++){var y=parseInt(m[d].getAttribute("first"),10),v=parseInt(m[d].getAttribute("second"),10),x=parseInt(m[d].getAttribute("amount"),10)/o;r.chars[v]&&(r.chars[v].kerning[y]=x)}return this.finalizeBitmapFont(e,r)},jsonBitmapFont:function(t,e,i,s,n,o){null==o&&(o=1);var r={font:t.font.info._face,size:parseInt(t.font.info._size,10),lineHeight:parseInt(t.font.common._lineHeight,10)+s,chars:{}},a=n?n.x:0,h=n?n.y:0;return t.font.chars.char.forEach(function(t){var e=parseInt(t._id,10),s=r.chars[e]={x:parseInt(t._x,10),y:parseInt(t._y,10),width:parseInt(t._width,10),height:parseInt(t._height,10),xOffset:parseInt(t._xoffset,10)/o,yOffset:parseInt(t._yoffset,10)/o,xAdvance:(parseInt(t._xadvance,10)+i)/o,kerning:{}};if(n&&n.trimmed){if(s.x+s.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(s.width-=s.x+s.width-n.spriteSourceSizeX-n.spriteSourceSizeW),s.y+s.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(s.height-=s.y+s.height-n.spriteSourceSizeY-n.spriteSourceSizeH),s.x<n.spriteSourceSizeX){l=n.spriteSourceSizeX-s.x;s.x=0,s.width-=l,s.xOffset+=l}if(s.y<n.spriteSourceSizeY){var l=n.spriteSourceSizeY-s.y;s.y=0,s.height-=l,s.yOffset+=l}}s.x+=a,s.y+=h}),t.font.kernings&&t.font.kernings.kerning&&t.font.kernings.kerning.forEach(function(t){r.chars[t._second]&&(r.chars[t._second].kerning[t._first]=parseInt(t._amount,10)/o)}),this.finalizeBitmapFont(e,r)},finalizeBitmapFont:function(t,i){return Object.keys(i.chars).forEach(function(s){var n=i.chars[s];n.texture=new PIXI.Texture(t,new e.Rectangle(n.x,n.y,n.width,n.height))}),i},pvr:function(t){var e,i=new Uint32Array(t.slice(0,52)),s=new Uint8Array(t),n=null,o=i[3]<<32|i[2],r=0;if(55727696===i[0]&&[0,1,2,3,6,7,9,11].indexOf(o)>=0){switch(o>=0&&o<=3?e="PVRTC":o>=7&&o<=11?e="S3TC":6===o&&(e="ETC1"),o){case 0:r=35841;break;case 1:r=35843;break;case 2:r=35840;break;case 3:r=35842;break;case 6:r=36196;break;case 7:r=33777;break;case 9:r=33778;break;case 11:r=33779;break;default:r=-1}n={complete:!0,fileFormat:"PVR",compressionAlgorithm:e,flags:i[1],pixelFormat:o,colorSpace:i[4],channelType:i[5],height:i[6],width:i[7],depth:i[8],numberOfSurfaces:i[9],numberOfFaces:i[10],numberOfMipmaps:i[11],metaDataSize:i[12],textureData:s.subarray(52+i[12],s.byteLength),glExtensionFormat:r}}return n},dds:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null;return 68===e[0]&&68===e[1]&&83===e[2]&&32===e[3]&&("DX10"===(s={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:i[1],flags:i[2],height:i[3],width:i[4],pitch:i[5],depth:i[6],mipmapCount:i[7],formatSize:i[19],formatFlag:i[19],formatFourCC:[String.fromCharCode(e[84]),String.fromCharCode(e[85]),String.fromCharCode(e[86]),String.fromCharCode(e[87])].join(""),formatBitCount:i[21],formatRBitMask:i[22],formatGBitMask:i[23],formatBBitMask:i[24],formatABitMask:i[25],caps1:i[26],caps2:i[27],caps3:i[28],caps4:i[29],reserved2:i[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:e.subarray(i[1]+4,e.byteLength)}).formatFourCC?(s.DXGIFormat=i[31],s.resourceDimension=i[32],s.miscFlag=i[33],s.arraySize=i[34],s.miscFlag=i[35]):"DXT5"===s.formatFourCC?s.glExtensionFormat=33779:"DXT3"===s.formatFourCC&&(s.glExtensionFormat=33778)),s},ktx:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null,n=16+i[15]/4|0,o=i[n],r=i[7],a=0;if(171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&49===e[5]&&49===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]&&[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(r)>=0){switch(r){case 36196:a="ETC1";break;case 35840:case 35841:case 35842:case 35843:a="PVRTC";break;case 33776:case 33777:case 33778:case 33779:a="S3TC"}s={complete:!0,fileFormat:"KTX",compressionAlgorithm:a,endianness:i[3],glType:i[4],glTypeSize:i[5],glFormat:i[6],glInternalFormat:i[7],glBaseInternalFormat:i[8],width:i[9],height:i[10],pixelDepth:i[11],numberOfArrayElements:i[12],numberOfFaces:i[13],numberOfMipmapLevels:i[14],bytesOfKeyValueData:i[15],keyAndValueByteSize:i[16],imageSize:o,textureData:e.subarray(4*(n+1),o+100)}}return s},pkm:function(t){var e=new Uint8Array(t),i=null;return 80===e[0]&&75===e[1]&&77===e[2]&&32===e[3]&&(i={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(e[6]<<8|e[7]),width:65535&(e[8]<<8|e[9]),height:65535&(e[10]<<8|e[11]),originalWidth:65535&(e[12]<<8|e[13]),originalHeight:65535&(e[14]<<8|e[15]),textureData:e.subarray(16,e.length)}),i}},e.AudioSprite=function(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(var i in this.config.spritemap){var s=this.config.spritemap[i],n=this.game.add.sound(this.key);n.addMarker(i,s.start,s.end-s.start,null,s.loop),this.sounds[i]=n}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},e.AudioSprite.prototype={play:function(t,e){return void 0===e&&(e=1),this.sounds[t].play(t,null,e)},stop:function(t){if(t)this.sounds[t].stop();else for(var e in this.sounds)this.sounds[e].stop()},get:function(t){return this.sounds[t]}},e.AudioSprite.prototype.constructor=e.AudioSprite,e.Sound=function(t,i,s,n,o){void 0===s&&(s=1),void 0===n&&(n=!1),void 0===o&&(o=t.sound.connectToMaster),this.game=t,this.name=i,this.key=i,this.loop=n,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,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=s,o&&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 e.Signal,this.onPlay=new e.Signal,this.onPause=new e.Signal,this.onResume=new e.Signal,this.onLoop=new e.Signal,this.onStop=new e.Signal,this.onMute=new e.Signal,this.onMarkerComplete=new e.Signal,this.onFadeComplete=new e.Signal,this._volume=s,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},e.Sound.prototype={soundHasUnlocked:function(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(t,e,i,s,n){void 0!==i&&null!==i||(i=1),void 0!==s&&null!==s||(s=1),void 0===n&&(n=!1),this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}},removeMarker:function(t){delete this.markers[t]},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(){if(this.game.cache.checkSoundKey(this.key)){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));var t=this.game.time.time;if(this.isPlaying){if(this._pendingStart){var e=this._sound.currentTime;if(!(e>((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1,this.startTime=t-1e3*e,this.stopTime=this.startTime+this.durationMS}this.currentTime=t-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=t,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0,!1))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=t),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0,!1)):this.stop())}}else this.destroy()},loopFull:function(t){return this.play(null,0,t,!0)},play:function(t,e,i,s,n,o){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),void 0===o&&(o=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Phaser.Sound.play: audio marker "+t+" doesn't exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._createSourceAndConnect(),this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||this._addOnEndedHandler(),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),this.loop&&""===t?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,o&&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._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume*this._globalVolume,this._pendingStart=!this.currentMarker,this.isPlaying=!0,this.paused=!1,this._tempPause=0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,o&&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(t,e,i,s){t=t||"",e=e||0,i=i||1,void 0===s&&(s=!1),this.play(t,e,i,s,!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(){if(this.paused){if(this.usingWebAudio){var t=Math.max(0,this.position+this.pausedPosition/1e3);this._createSourceAndConnect(),""===this.currentMarker&&(this.loop?this._sound.loop=!0:this._addOnEndedHandler());var e=this.duration-this.pausedPosition/1e3;this.loop&&""===this.currentMarker?this._startSource(0,t):this._startSource(0,t,e)}else this._pendingStart=!this.currentMarker,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 t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}},fadeIn:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=this.currentMarker),this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))},fadeOut:function(t){this.fadeTo(t,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,e.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(t){this.usingAudioTag&&this._sound&&(this._globalVolume=t,this._sound.volume=this._globalVolume*this._volume)},destroy:function(t){void 0===t&&(t=!0),this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?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(t,e,i){void 0===i?this._sound.start(t||0,e||0):this._sound.start(t||0,e||0,i)},_stopSourceAndDisconnect:function(){this._removeOnEndedHandler();try{this._sound.stop(0)}catch(t){}this._disconnectSource(),this._sound=null},_addOnEndedHandler:function(){this._sound.onended=this.onEndedHandler.bind(this)},_removeOnEndedHandler:function(){this._sound.onended=null}},e.Sound.prototype.constructor=e.Sound,Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(t){(t=t||!1)!==this._muted&&(t?(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(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(t){this.usingAudioTag&&(t=this.game.math.clamp(t,0,1)),this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.usingWebAudio?this.gainNode.gain.value=t:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*t))}}),Object.defineProperty(e.Sound.prototype,"sourceId",{get:function(){return this._sound?this._sourceId:null}}),e.SoundManager=function(t){this.game=t,this.onSoundDecode=new e.Signal,this.onVolumeChange=new e.Signal,this.onMute=new e.Signal,this.onUnMute=new e.Signal,this.onTouchUnlock=new e.Signal,this.onStateChange=new e.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 e.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null,this._onClick=this._onClick.bind(this),this._onStateChange=this._onStateChange.bind(this)},e.SoundManager.prototype={boot:function(){var t=this.game.device,e=window.PhaserGlobal;if(t.iOS&&!1===t.webAudio&&(this.channels=1),e){if(!0===e.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===e.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(e&&e.audioContext)this.context=e.audioContext;else{var i=window.AudioContext||window.webkitAudioContext;if(i)try{this.context=new i}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1,console.warn(t)}}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),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),this.context.onstatechange=this._onStateChange,"suspended"===this.context.state&&this.game.canvas.addEventListener("click",this._onClick);this.noAudio||t.needsTouchUnlock()&&this.setTouchLock(),this.usingWebAudio&&t.chrome&&t.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)return this.context.resume()},resumeWebAudioIfSuspended:function(){if(this.usingWebAudio&&"suspended"===this.context.state)return this.context.resume()},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.setTouchUnlock();else if(this.usingWebAudio){var t=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination);var e=this;this._unlockSource.onended=function(){e.setTouchUnlock(),e.resumeWebAudioIfSuspended()},void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),this.resumeWebAudioIfSuspended()}return!0},stopAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].stop()},pauseAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].pause()},resumeAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].resume()},decode:function(t,e){e=e||null;var i=this.game.cache.getSoundData(t);if(i&&!1===this.game.cache.isSoundDecoded(t)){this.game.cache.updateSound(t,"isDecoding",!0);var s=this;try{this.context.decodeAudioData(i,function(i){i&&(s.game.cache.decodedSound(t,i),s.onSoundDecode.dispatch(t,e))})}catch(t){}}},setDecodedCallback:function(t,i,s){"string"==typeof t&&(t=[t]),this._watchList.reset();for(var n=0;n<t.length;n++)t[n]instanceof e.Sound?this.game.cache.isSoundDecoded(t[n].key)||this._watchList.add(t[n].key):this.game.cache.isSoundDecoded(t[n])||this._watchList.add(t[n]);0===this._watchList.total?(this._watching=!1,i.call(s)):(this._watching=!0,this._watchCallback=i,this._watchContext=s)},update:function(){if(!this.noAudio){for(var t=0;t<this._sounds.length;t++)this._sounds[t].update();if(this._watching){for(var e=this._watchList.first;e;)this.game.cache.isSoundDecoded(e)&&this._watchList.remove(e),e=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(t,i,s,n){void 0===i&&(i=1),void 0===s&&(s=!1),void 0===n&&(n=this.connectToMaster);var o=new e.Sound(this.game,t,i,s,n);return this._sounds.push(o),o},addSprite:function(t){return new e.AudioSprite(this.game,t)},remove:function(t){for(var e=this._sounds.length;e--;)if(this._sounds[e]===t)return this._sounds[e].destroy(!1),this._sounds.splice(e,1),!0;return!1},removeAll:function(){this.stopAll();for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].destroy();this._sounds.length=0},removeByKey:function(t){for(var e=this._sounds.length,i=0;e--;)this._sounds[e].key===t&&(this._sounds[e].destroy(!1),this._sounds.splice(e,1),i++);return i},play:function(t,e,i){if(!this.noAudio){var s=this.add(t,e,i);return s.play(),s}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].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 t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].mute=!1);this.onUnMute.dispatch()}},gamePaused:function(){this.muteOnPause&&this.setMute()},gameResumed:function(){this.resumeWebAudio(),this.muteOnPause&&this.unsetMute()},destroy:function(){this.removeAll(),this.onMute.dispose(),this.onSoundDecode.dispose(),this.onStateChange.dispose(),this.onTouchUnlock.dispose(),this.onUnMute.dispose(),this.onVolumeChange.dispose(),this.game.canvas.removeEventListener("click",this._onClick),this.context&&(this.context.onstatechange=null,window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close(),this.context=null)},_onStateChange:function(){this.onStateChange.dispatch(this.context.state)},_onClick:function(){this.resumeWebAudioIfSuspended(),this.game.canvas.removeEventListener("click",this._onClick)}},e.SoundManager.prototype.constructor=e.SoundManager,Object.defineProperty(e.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||!1){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(t){if(t<0?t=0:t>1&&(t=1),this._volume!==t){if(this._volume=t,this.usingWebAudio)this.masterGain.gain.value=t;else for(var e=0;e<this._sounds.length;e++)this._sounds[e].usingAudioTag&&this._sounds[e].updateGlobalVolume(t);this.onVolumeChange.dispatch(t)}}}),e.ScaleManager=function(t,i,s){this.game=t,this.dom=e.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 e.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new e.Signal,this.enterIncorrectOrientation=new e.Signal,this.leaveIncorrectOrientation=new e.Signal,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new e.Signal,this.onFullScreenChange=new e.Signal,this.onFullScreenError=new e.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new e.Point(1,1),this.scaleFactorInversed=new e.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new e.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=e.ScaleManager.NO_SCALE,this._fullScreenScaleMode=e.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new e.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new e.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new e.Rectangle,this._userScaleFactor=new e.Point(1,1),this._userScaleTrim=new e.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new e.Rectangle,this._tempBounds=new e.Rectangle,this._lastReportedCanvasSize=new e.Rectangle,this._lastReportedGameSize=new e.Rectangle,this._booted=!1,t.config&&this.parseConfig(t.config),this.setupScale(i,s)},e.ScaleManager.EXACT_FIT=0,e.ScaleManager.NO_SCALE=1,e.ScaleManager.SHOW_ALL=2,e.ScaleManager.RESIZE=3,e.ScaleManager.USER_SCALE=4,e.ScaleManager.MODES=["EXACT_FIT","NO_SCALE","SHOW_ALL","RESIZE","USER_SCALE"],e.ScaleManager.prototype={boot:function(){var t=this.compatibility;t.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?t.scrollTo=new e.Point(0,1):t.scrollTo=new e.Point(0,0)),this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");var i=this;this._orientationChange=function(t){return i.orientationChange(t)},this._windowResize=function(t){return i.windowResize(t)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(t){return i.fullScreenChange(t)},this._fullScreenError=function(t){return i.fullScreenError(t)},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),e.FlexGrid&&(this.grid=new e.FlexGrid(this,this.width,this.height)),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(t){void 0!==t.scaleMode&&(this._booted?this.scaleMode=t.scaleMode:this._pendingScaleMode=t.scaleMode),void 0!==t.fullScreenScaleMode&&(this.fullScreenScaleMode=t.fullScreenScaleMode),t.fullScreenTarget&&(this.fullScreenTarget=t.fullScreenTarget),this.pageAlignHorizontally=t.alignH||!1,this.pageAlignVertically=t.alignV||!1,t.scaleH&&t.scaleV&&this.setUserScale(t.scaleH,t.scaleV,t.trimH,t.trimV)},setupScale:function(t,i){var s,n=new e.Rectangle;""!==this.game.parent&&("string"==typeof this.game.parent?s=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(s=this.game.parent)),s?(this.parentNode=s,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds,this.parentNode),n.width=this._parentBounds.width,n.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,n.width=this.dom.visualBounds.width,n.height=this.dom.visualBounds.height,this.offset.set(0,0));var o=0,r=0;"number"==typeof t?o=t:(this.parentScaleFactor.x=parseInt(t,10)/100,o=n.width*this.parentScaleFactor.x),"number"==typeof i?r=i:(this.parentScaleFactor.y=parseInt(i,10)/100,r=n.height*this.parentScaleFactor.y),o=Math.floor(o),r=Math.floor(r),this._gameSize.setTo(0,0,o,r),this.updateDimensions(o,r,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(t,i){this._gameSize.setTo(0,0,t,i),this.currentScaleMode!==e.ScaleManager.RESIZE&&this.updateDimensions(t,i,!0),this.queueUpdate(!0)},setUserScale:function(t,e,i,s,n,o){this._userScaleFactor.setTo(t,e),this._userScaleTrim.setTo(0|i,0|s),void 0===n&&(n=!0),void 0===o&&(o=!0),n&&this.queueUpdate(o)},setResizeCallback:function(t,e){this.onResize=t,this.onResizeContext=e},signalSizeChange:function(){if(!e.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!e.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===e.ScaleManager.RESIZE&&(this.game.state.resize(t,i),this.game.load.resize(t,i))}},setMinMax:function(t,e,i,s){this.minWidth=t,this.minHeight=e,void 0!==i&&(this.maxWidth=i),void 0!==s&&(this.maxHeight=s)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);var i=this._parentBounds.width,s=this._parentBounds.height,n=this.getParentBounds(this._parentBounds),o=n.width!==i||n.height!==s,r=this.updateOrientationState();(o||r)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,n),this.updateLayout(),this.signalSizeChange());var a=2*this._updateThrottle;this._updateThrottle<t&&(a=Math.min(t,this._updateThrottleReset)),this._updateThrottle=e.Math.clamp(a,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(t,e,i){this.width=t*this.parentScaleFactor.x,this.height=e*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(t,e){void 0===e&&(e=!1),!0!==t||!0!==e?(this.forceLandscape=t,this.forcePortrait=e,this.queueUpdate(!0)):console.warn("Phaser.ScaleManager: forceLandscape and forcePortrait cannot both be true.")},classifyOrientation:function(t){return"portrait-primary"===t||"portrait-secondary"===t?"portrait":"landscape-primary"===t||"landscape-secondary"===t?"landscape":null},updateOrientationState:function(){var t=this.screenOrientation,e=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var i=t!==this.screenOrientation,s=e!==this.incorrectOrientation;return s&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(i||s)&&this.onOrientationChange.dispatch(this,t,e),i||s},orientationChange:function(t){this.event=t,this.queueUpdate(!0)},windowResize:function(t){this.event=t,this.queueUpdate(!0)},scrollTop:function(){var t=this.compatibility.scrollTo;t&&window.scrollTo(t.x,t.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var t=this.currentScaleMode;if(t!==e.ScaleManager.RESIZE){if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():t===e.ScaleManager.EXACT_FIT?this.setExactFit():t===e.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===e.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):t===e.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===e.ScaleManager.SHOW_ALL||t===e.ScaleManager.USER_SCALE)){var 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()}else this.reflowGame()},getParentBounds:function(t,i){var s=t||new e.Rectangle,n=i||this.boundingParent,o=this.dom.visualBounds,r=this.dom.layoutBounds;if(n){var a=n.getBoundingClientRect(),h=n.offsetParent?n.offsetParent.getBoundingClientRect():n.getBoundingClientRect();s.setTo(a.left-h.left,a.top-h.top,a.width,a.height);var l=this.windowConstraints;if(l.right){c="layout"===l.right?r:o;s.right=Math.min(s.right,c.width)}if(l.bottom){var c="layout"===l.bottom?r:o;s.bottom=Math.min(s.bottom,c.height)}}else s.setTo(0,0,o.width,o.height);return s.setTo(Math.round(s.x),Math.round(s.y),Math.round(s.width),Math.round(s.height)),s},align:function(t,e){null!=t&&(this.pageAlignHorizontally=t),null!=e&&(this.pageAlignVertically=e)},alignCanvas:function(t,e){var i=this.getParentBounds(this._tempBounds),s=this.game.canvas,n=this.margin;if(t){n.left=n.right=0;h=s.getBoundingClientRect();if(this.width<i.width&&!this.incorrectOrientation){var o=h.left-i.x,r=i.width/2-this.width/2,a=(r=Math.max(r,0))-o;n.left=Math.round(a)}s.style.marginLeft=n.left+"px",0!==n.left&&(n.right=-(i.width-h.width-n.left),s.style.marginRight=n.right+"px")}if(e){n.top=n.bottom=0;var h=s.getBoundingClientRect();if(this.height<i.height&&!this.incorrectOrientation){var o=h.top-i.y,r=i.height/2-this.height/2,a=(r=Math.max(r,0))-o;n.top=Math.round(a)}s.style.marginTop=n.top+"px",0!==n.top&&(n.bottom=-(i.height-h.height-n.top),s.style.marginBottom=n.bottom+"px")}n.x=n.left,n.y=n.top},reflowGame:function(){this.resetCanvas("","");var t=this.getParentBounds(this._tempBounds);this.updateDimensions(t.width,t.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=e.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=e.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(t,e){void 0===t&&(t=this.width+"px"),void 0===e&&(e=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=t,i.style.height=e},queueUpdate:function(t){t&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(t){t&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(t){var e,i=this.getParentBounds(this._tempBounds),s=i.width,n=i.height;e=t?Math.max(n/this.game.height,s/this.game.width):Math.min(n/this.game.height,s/this.game.width),this.width=Math.round(this.game.width*e),this.height=Math.round(this.game.height*e)},setExactFit:function(){var t=this.getParentBounds(this._tempBounds);this.width=t.width,this.height=t.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 t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t.style.background="#000",t},startFullScreen:function(t,i,s){if(this.isFullScreen)return!1;{if(this.compatibility.supportsFullScreen){if("when-not-mouse"===this.compatibility.clickTrampoline){var n=this.game.input;if(n.activePointer&&n.activePointer!==n.mousePointer&&(i||!1!==i))return void n.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1])}void 0!==t&&this.game.renderType===e.CANVAS&&(this.game.stage.smoothed=t);var o=this.fullScreenTarget;o||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),o=this._createdFullScreenTarget);var r={targetElement:o};if(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,r),this._createdFullScreenTarget){var a=this.game.canvas;a.parentNode.insertBefore(o,a),o.appendChild(a)}return void 0===s&&(s={navigationUI:"hide"}),this.game.device.fullscreenKeyboard?o[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):o[this.game.device.requestFullscreen](s),!0}var h=this;setTimeout(function(){h.fullScreenError()},10)}},stopFullScreen:function(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen)&&(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),!0)},cleanupCreatedTarget:function(){var t=this._createdFullScreenTarget;if(t&&t.parentNode){var e=t.parentNode;e.insertBefore(this.game.canvas,t),e.removeChild(t)}this._createdFullScreenTarget=null},prepScreenMode:function(t){var i=!!this._createdFullScreenTarget,s=this._createdFullScreenTarget||this.fullScreenTarget;t?(i||this.fullScreenScaleMode===e.ScaleManager.EXACT_FIT)&&s!==this.game.canvas&&(this._fullScreenRestore={targetWidth:s.style.width,targetHeight:s.style.height},s.style.width="100%",s.style.height="100%"):(this._fullScreenRestore&&(s.style.width=this._fullScreenRestore.targetWidth,s.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(t){this.event=t,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(t){this.event=t,this.cleanupCreatedTarget(),console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"),this.onFullScreenError.dispatch(this)},scaleSprite:function(t,e,i,s){if(void 0===e&&(e=this.width),void 0===i&&(i=this.height),void 0===s&&(s=!1),!t||!t.scale)return t;if(t.scale.x=1,t.scale.y=1,t.width<=0||t.height<=0||e<=0||i<=0)return t;var n=e,o=t.height*e/t.width,r=t.width*i/t.height,a=i,h=r>e;return(h=h?s:!s)?(t.width=Math.floor(n),t.height=Math.floor(o)):(t.width=Math.floor(r),t.height=Math.floor(a)),t},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))}},e.ScaleManager.prototype.constructor=e.ScaleManager,Object.defineProperty(e.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(e.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(t){return t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t),this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(t){return t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t),this._fullScreenScaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(t){t!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(t){t!==this._pageAlignVertically&&(this._pageAlignVertically=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(e.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(e.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),e.Utils.Debug=function(t){this.game=t,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},e.Utils.Debug.GEOM_AUTO=0,e.Utils.Debug.GEOM_RECTANGLE=1,e.Utils.Debug.GEOM_CIRCLE=2,e.Utils.Debug.GEOM_POINT=3,e.Utils.Debug.GEOM_LINE=4,e.Utils.Debug.GEOM_ELLIPSE=5,e.Utils.Debug.prototype={boot:function(){this.game.renderType===e.CANVAS?this.context=this.game.context:(this.bmd=new e.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=e.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new e.Line,this._rect=new e.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(t,e,i,s){"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),i=i||"rgb(255,255,255)",void 0===s&&(s=0),this.currentX=t,this.currentY=e,this.currentColor=i,this.columnWidth=s,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,e=0;e<arguments.length;e++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[e],t+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[e],t,this.currentY),t+=this.columnWidth;this.currentY+=this.lineHeight},gameInfo:function(t,e,i){var s=this.game;this.start(t,e,i),this.line("Game ID "+s.id),this.line({1:"Canvas",2:"WebGL",3:"Headless",4:"WebGL Multitexture"}[s.renderType]+" ("+s.width+" x "+s.height+")"),this.line("Paused: "+s.paused),this.line("Stepping: "+s.stepping+" ("+s.stepCount+")"),this.stop()},state:function(t,e,i){var s=this.game.state,n=Object.keys(s.states);this.start(t,e,i);for(var o=0;o<n.length;o++){var r=n[o];r===s.current?this.line((s._created?"* ":"> ")+r):r===s._pendingState?this.line("+ "+r):this.line("  "+r)}this.stop()},sound:function(t,e,i){var s=this.game.sound;this.start(t,e,i),s.noAudio?this.line("Audio is disabled"):(this.line("Volume: "+s.volume.toFixed(2)+(s.mute?" (Mute)":"")),this.line("Mute on pause: "+s.muteOnPause),this.line("Using: "+(s.usingWebAudio?"Web Audio - "+s.context.state:"Audio Tag")),this.line("Touch locked: "+s.touchLocked),this.line("Sounds: "+s._sounds.length)),this.stop()},soundInfo:function(t,e,i,s){if(this.start(e,i,s),this.line("Sound: "+t.key+"  Touch locked: "+t.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(t.key)+"  Pending Playback: "+t.pendingPlayback),this.line("Decoded: "+t.isDecoded+"  Decoding: "+t.isDecoding),this.line("Playing: "+t.isPlaying+"  Loop: "+t.loop),this.line("Time: "+(t.currentTime/1e3).toFixed(3)+"s  Total: "+t.totalDuration.toFixed(3)+"s"),this.line("Volume: "+t.volume.toFixed(2)+(t.mute?" (Mute)":"")),this.line("Using: "+(t.usingWebAudio?"Web Audio":"Audio Tag")),t.usingWebAudio&&this.line("  Source: "+(t.sourceId||"none")),t.usingAudioTag&&t._sound){var n=t._sound;this.line("  currentSrc: "+n.currentSrc),this.line("  currentTime: "+n.currentTime),this.line("  duration: "+n.duration),this.line("  ended: "+n.ended),this.line("  loop: "+n.loop),this.line("  muted: "+n.muted),this.line("  paused: "+n.paused)}""!==t.currentMarker&&(this.line("Marker: "+t.currentMarker+"  Duration: "+t.duration.toFixed(3)+"s ("+t.durationMS+"ms)"),this.line("Start: "+t.markers[t.currentMarker].start.toFixed(3)+"  Stop: "+t.markers[t.currentMarker].stop.toFixed(3)),this.line("Position: "+t.position.toFixed(3))),this.stop()},camera:function(t,e,i){var s=t.deadzone,n=t.target,o=t.view;s&&(this._rect.setTo(o.x+s.x,o.y+s.y,s.width,s.height),this.rectangle(this._rect,e,i)),n&&(this._line.setTo(o.centerX,o.centerY,n.x,n.y),this.geom(this._line,e,i),this.geom(n,e,!1,3))},cameraInfo:function(t,e,i,s){var n=t.bounds,o=t.deadzone,r=t.target,a=t.view;this.start(e,i,s),this.line("Camera ("+t.width+" x "+t.height+")"),this.line("x: "+t.x+" y: "+t.y),this.line("Bounds: "+(n?"x: "+n.x+" y: "+n.y+" w: "+n.width+" h: "+n.height:"none")),this.line("View: x: "+a.x+" y: "+a.y+" w: "+a.width+" h: "+a.height),this.line("Center: x: "+t.centerX+" y: "+t.centerY),this.line("Deadzone: "+(o?"x: "+o.x+" y: "+o.y+" w: "+o.width+" h: "+o.height:o)),this.line("Total in view: "+t.totalInView),this.line("At limit: x: "+t.atLimit.x+" y: "+t.atLimit.y),this.line("Target: "+(r?r.name||r:"none")),this.stop()},timer:function(t,e,i,s){this.start(e,i,s),this.line("Timer (running: "+t.running+" expired: "+t.expired+")"),this.line("Next Tick: "+t.next+" Duration: "+t.duration),this.line("Paused: "+t.paused+" Length: "+t.length),this.stop()},pointer:function(t,e,i,s,n,o){if(null!=t&&(void 0===e&&(e=!1),i=i||"rgba(0,255,0,0.5)",s=s||"rgba(255,255,0,0.5)",o=o||"rgba(255,0,0,0.5)",!0!==e||!0!==t.isUp)){this.start(t.x,t.y-150,n),this.context.beginPath(),this.context.arc(t.x,t.y,t.circle.radius,0,2*Math.PI),t.active?this.context.fillStyle=t.isDown?i:s:this.context.fillStyle=o,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(t.positionDown.x,t.positionDown.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath();var r=t.movementX,a=t.movementY;(r||a)&&(this.context.beginPath(),this.context.moveTo(r+t.position.x,a+t.position.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath()),this.line("ID: "+t.id+" Active: "+t.active),this.line("World X: "+t.worldX.toFixed(1)+" World Y: "+t.worldY.toFixed(1)),this.line("Screen X: "+t.x.toFixed(1)+" Screen Y: "+t.y.toFixed(1)+" In: "+t.withinGame),this.line("Movement: X: "+r+" Y: "+a),this.line("Duration: "+t.duration+" ms"),this.line("is Down: "+t.isDown+" is Up: "+t.isUp),this.line("Identifier: "+t.identifier+" Pointer ID: "+t.pointerId),t.isMouse&&this.line("Buttons: "+this._pointerButtonIcon(t.leftButton)+" "+this._pointerButtonIcon(t.middleButton)+" "+this._pointerButtonIcon(t.rightButton)),this.stop()}},_pointerButtonIcon:function(t){return t.isDown?"x":t.isUp?"o":"-"},spriteInputInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite Input: ("+t.width+" x "+t.height+")"),this.line("x: "+t.input.pointerX().toFixed(1)+" y: "+t.input.pointerY().toFixed(1)),this.line("over: "+t.input.pointerOver()+" duration: "+t.input.overDuration().toFixed(0)),this.line("down: "+t.input.pointerDown()+" duration: "+t.input.downDuration().toFixed(0)),this.line("just over: "+t.input.justOver()+" just out: "+t.input.justOut()),this.stop()},key:function(t,e,i,s){this.start(e,i,s,150),this.line("Key:",t.keyCode,"isDown:",t.isDown),this.line("justDown:",t.justDown,"justUp:",t.justUp),this.line("Time Down:",t.timeDown.toFixed(0),"duration:",t.duration.toFixed(0)),this.stop()},inputInfo:function(t,i,s,n){var o=this.game.input;if(void 0===n&&(n=!0),this.start(t,i,s),this.line("Input"),this.line("X: "+o.x+" Y: "+o.y),this.line("World X: "+o.worldX+" World Y: "+o.worldY),this.line("Scale X: "+o.scale.x.toFixed(2)+" Scale Y: "+o.scale.x.toFixed(2)),this.line("Screen X: "+o.activePointer.screenX.toFixed(1)+" Screen Y: "+o.activePointer.screenY.toFixed(1)),n){this.line("Sources:"),this.line("  "+this._inputHandler(o.mouse,"mouse")),this.line("  "+this._inputHandler(o.mspointer,"mspointer")),this.line("  "+this._inputHandler(o.touch,"touch"));var r=o.pointers,a=o.mousePointer,h=e.PointerModes,l=0,c=0;this.line("Pointers:"),this.line("  "+(a.isDown?"x":"o")+" "+h[a.pointerMode]+" "+a.identifier);for(var u=0;u<r.length;u++){var d=r[u];this.line("  "+(d.active?"+":"-")+" "+h[d.pointerMode]+" "+d.identifier),d.active?l+=1:c+=1}this.line("  Active: "+l+" Free: "+c+" Max: "+o.maxPointers),this.stop()}else this.stop()},inputHandler:function(t,e,i,s,n){this.start(i,s,n),this.line(e||"?"),this.line("active: "+t.active),t.active?(this.line("enabled: "+t.enabled),"capture"in t&&this.line("capture: "+t.capture),"preventDefault"in t&&this.line("preventDefault: "+t.preventDefault),"event"in t&&this.line("event: "+(t.event?t.event.type:t.event)),this.stop()):this.stop()},_inputHandler:function(t,e){return this._inputHandlerStatusIcon(t)+" "+e+" "+this._inputHandlerCaptureIcon(t)},_inputHandlerStatusIcon:function(t){return t.active?t.enabled?"+":"-":" "},_inputHandlerCaptureIcon:function(t){return t.active&&(t.capture||t.preventDefault)?"*":" "},spriteBounds:function(t,e,i){var s=t.getBounds();s.x+=this.game.camera.x,s.y+=this.game.camera.y,this.rectangle(s,e,i)},ropeSegments:function(t,e,i){var s=this;t.segments.forEach(function(t){s.rectangle(t,e,i)},this)},spriteInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite: "+(t.name||"")+" ("+t.width+" x "+t.height+") anchor: "+t.anchor.x+" x "+t.anchor.y),this.line("x: "+t.x.toFixed(1)+" y: "+t.y.toFixed(1)),this.line("angle: "+t.angle.toFixed(1)+" rotation: "+t.rotation.toFixed(1)),this.line("visible: "+t.visible+" in camera: "+t.inCamera),this.line("bounds x: "+t._bounds.x.toFixed(1)+" y: "+t._bounds.y.toFixed(1)+" w: "+t._bounds.width.toFixed(1)+" h: "+t._bounds.height.toFixed(1)),this.line("parent: "+(t.parent?t.parent.name||"(DisplayObject)":"(none)")),this.stop()},spriteCoords:function(t,e,i,s){this.start(e,i,s,100),t.name&&this.line(t.name),this.line("x:",t.x.toFixed(2),"y:",t.y.toFixed(2)),this.line("pos x:",t.position.x.toFixed(2),"pos y:",t.position.y.toFixed(2)),this.line("world x:",t.world.x.toFixed(2),"world y:",t.world.y.toFixed(2)),this.stop()},lineInfo:function(t,e,i,s){this.start(e,i,s,80),this.line("start.x:",t.start.x.toFixed(2),"start.y:",t.start.y.toFixed(2)),this.line("end.x:",t.end.x.toFixed(2),"end.y:",t.end.y.toFixed(2)),this.line("length:",t.length.toFixed(2),"angle:",t.angle),this.stop()},pixel:function(t,e,i,s){s=s||2,this.start(),this.context.fillStyle=i,this.context.fillRect(t,e,s,s),this.stop()},geom:function(t,i,s,n){void 0===s&&(s=!0),void 0===n&&(n=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 o=e.Utils.Debug;n===o.GEOM_RECTANGLE||t instanceof e.Rectangle?s?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):n===o.GEOM_CIRCLE||t instanceof e.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(),s?this.context.fill():this.context.stroke()):n===o.GEOM_POINT||t instanceof e.Point?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,4,4):n===o.GEOM_LINE||t instanceof e.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()):(n===o.GEOM_ELLIPSE||t instanceof e.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(),s?this.context.fill():this.context.stroke()),this.stop()},rectangle:function(t,e,i){void 0===i&&(i=!0),e=e||"rgba(0, 255, 0, 0.4)",this.start(),i?(this.context.fillStyle=e,this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)):(this.context.lineWidth=this.lineWidth,this.context.strokeStyle=e,this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)),this.stop()},text:function(t,e,i,s,n){s=s||"rgb(255,255,255)",n=n||this.font,this.start(),this.context.font=n,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(t,e+1,i+1)),this.context.fillStyle=s,this.context.fillText(t,e,i),this.stop()},quadTree:function(t,e){e=e||"rgba(255,0,0,0.3)",this.start();var i=t.bounds;if(0===t.nodes.length){this.context.strokeStyle=e,this.context.strokeRect(i.x,i.y,i.width,i.height),this.text("size: "+t.objects.length,i.x+4,i.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(s=0;s<t.objects.length;s++)this.context.strokeRect(t.objects[s].x,t.objects[s].y,t.objects[s].width,t.objects[s].height)}else for(var s=0;s<t.nodes.length;s++)this.quadTree(t.nodes[s]);this.stop()},body:function(t,i,s){t.body&&(this.start(),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.render(this.context,t.body,i,s,this.lineWidth):t.body.type===e.Physics.NINJA?e.Physics.Ninja.Body.render(this.context,t.body,i,s):t.body.type===e.Physics.BOX2D&&e.Physics.Box2D.renderBody(this.context,t.body,i),this.stop())},bodyInfo:function(t,i,s,n){t.body&&(this.start(i,s,n,210),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.renderBodyInfo(this,t.body):t.body.type===e.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(),e.Physics.Box2D.renderBody(this.context,t,i),this.stop()},displayList:function(t){if(void 0===t&&(t=this.game.world),t.hasOwnProperty("renderOrderID")?console.log("["+t.renderOrderID+"]",t):console.log("[]",t),t.children&&t.children.length>0)for(var e=0;e<t.children.length;e++)this.game.debug.displayList(t.children[e])},renderer:function(t,e,i){var s=this.game.renderer,n=s.renderSession;if(this.start(t,e,i),this.line((s.gl?"WebGL":"Canvas")+" Renderer ("+s.width+" x "+s.height+")"),this.line("autoResize: "+s.autoResize),this.line("clearBeforeRender: "+s.clearBeforeRender),this.line("resolution: "+s.resolution),this.line("transparent: "+s.transparent),this.line("renderSession:"),s.gl){this.line("  currentBatchedTextures: ("+s.currentBatchedTextures.length+")");for(var o=0;o<s.currentBatchedTextures.length;o++)this.line("    "+s.currentBatchedTextures[o]);this.line("  drawCount: "+n.drawCount),this.line("  maxTextures: "+s.maxTextures),this.line("  maxTextureSize: "+s.maxTextureSize),this.line("  maxTextureAvailableSpace: "+n.maxTextureAvailableSpace),this.line("  roundPixels: "+n.roundPixels)}else this.line("  roundPixels: "+n.roundPixels),this.line("  scaleMode: "+(0===n.scaleMode?"LINEAR":1===n.scaleMode?"NEAREST":n.scaleMode));this.stop()},canvasPool:function(t,i,s,n){var o=e.CanvasPool;this.start(t,i,s,n||100),this.line("Canvas Pool"),this.line("Used:",o.getTotal()),this.line("Free:",o.getFree()),this.line("Total:",o.length),this.stop()},physicsGroup:function(t,e,i,s){t.forEach(this.body,this,s,e,i)},phaser:function(t,i,s){this.text("Phaser v"+e.VERSION+" "+(this.game.renderType===e.WEBGL?"WebGL":"Canvas")+" "+(this.game.device.webAudio?"WebAudio":"HTML Audio"),t,i,s,this.font)},scale:function(t,i,s){this.start(t,i,s);var n=this.game.scale,o=n.scaleFactorInversed,r=n._parentBounds,t=" x ";this.line("Game: "+this.game.width+t+this.game.height),this.line("Canvas: "+n.width+t+n.height+" ("+o.x.toFixed(2)+t+o.y.toFixed(2)+") ["+n.aspectRatio.toFixed(2)+"]"),this.line("Mode: "+e.ScaleManager.MODES[n.currentScaleMode]+(n.currentScaleMode===e.ScaleManager.USER_SCALE?" ("+n._userScaleFactor.x+t+n._userScaleFactor.y+")":"")),this.line("Parent: "+(n.parentIsWindow?"window":n.parentNode)+(r.empty?"":" ("+r.width+t+r.height+")")),this.line("Screen: "+n.classifyOrientation(n.screenOrientation)+(n.incorrectOrientation?" (incorrect)":"")),this.stop()},loader:function(t,i,s,n){var o=e.Utils.pad;this.start(i,s,n),t.hasLoaded?this.line("Complete"+(t.resetLocked?" [locked]":"")):t.isLoading?this.line("Loading"):this.line("Not started"),t.hasLoaded&&!t.resetLocked||(this.line("Progress: "+o(t.progress,3)+"%"),this.line("Files: "+t._loadedFileCount+" of "+t._totalFileCount),this.line("Packs: "+t._loadedPackCount+" of "+t._loadedPackCount)),this.stop()},device:function(t,e,i){var s=this.game.device;this.start(t,e,i),this.line("Device"),this.line("Pointer Events: "+s.mspointer),this.line("Touch: "+s.touch),this.line("Web Audio: "+s.webAudio),this.line("WebGL: "+s.webGL),this.stop()},destroy:function(){e.CanvasPool.remove(this)}},e.Utils.Debug.prototype.constructor=e.Utils.Debug,e.DOM={getOffset:function(t,i){i=i||new e.Point;var s=t.getBoundingClientRect(),n=e.DOM.scrollY,o=e.DOM.scrollX,r=document.documentElement.clientTop,a=document.documentElement.clientLeft;return i.x=s.left+o-a,i.y=s.top+n-r,i},getBounds:function(t,e){return void 0===e&&(e=0),!(!(t=t&&!t.nodeType?t[0]:t)||1!==t.nodeType)&&this.calibrate(t.getBoundingClientRect(),e)},calibrate:function(t,e){e=+e||0;var i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=t.right+e)-(i.left=t.left-e),i.height=(i.bottom=t.bottom+e)-(i.top=t.top-e),i},getAspectRatio:function(t){var e=(t=null==t?this.visualBounds:1===t.nodeType?this.getBounds(t):t).width,i=t.height;return"function"==typeof e&&(e=e.call(t)),"function"==typeof i&&(i=i.call(t)),e/i},inLayoutViewport:function(t,e){var i=this.getBounds(t,e);return!!i&&i.bottom>=0&&i.right>=0&&i.top<=this.layoutBounds.width&&i.left<=this.layoutBounds.height},getScreenOrientation:function(t){var e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;var s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n},visualBounds:new e.Rectangle,layoutBounds:new e.Rectangle,documentBounds:new e.Rectangle},e.Device.whenReady(function(t){var i=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},s=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(e.DOM,"scrollX",{get:i}),Object.defineProperty(e.DOM,"scrollY",{get:s}),Object.defineProperty(e.DOM.visualBounds,"x",{get:i}),Object.defineProperty(e.DOM.visualBounds,"y",{get:s}),Object.defineProperty(e.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(e.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var n=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},o=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(e.DOM.visualBounds,"width",{get:n}),Object.defineProperty(e.DOM.visualBounds,"height",{get:o}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:n}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:o})}else Object.defineProperty(e.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(e.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:function(){var t=document.documentElement.clientWidth,e=window.innerWidth;return t<e?e:t}}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:function(){var t=document.documentElement.clientHeight,e=window.innerHeight;return t<e?e:t}});Object.defineProperty(e.DOM.documentBounds,"x",{value:0}),Object.defineProperty(e.DOM.documentBounds,"y",{value:0}),Object.defineProperty(e.DOM.documentBounds,"width",{get:function(){var t=document.documentElement;return Math.max(t.clientWidth,t.offsetWidth,t.scrollWidth)}}),Object.defineProperty(e.DOM.documentBounds,"height",{get:function(){var t=document.documentElement;return Math.max(t.clientHeight,t.offsetHeight,t.scrollHeight)}})},null,!0),e.ArraySet=function(t){this.position=0,this.list=t||[]},e.ArraySet.prototype={add:function(t){return this.exists(t)||this.list.push(t),t},getIndex:function(t){return this.list.indexOf(t)},getByKey:function(t,e){for(var i=this.list.length;i--;)if(this.list[i][t]===e)return this.list[i];return null},exists:function(t){return this.list.indexOf(t)>-1},reset:function(){this.list.length=0},remove:function(t){var e=this.list.indexOf(t);if(e>-1)return this.list.splice(e,1),t},setAll:function(t,e){for(var i=this.list.length;i--;)this.list[i]&&(this.list[i][t]=e)},callAll:function(t){for(var e=Array.prototype.slice.call(arguments,1),i=this.list.length;i--;)this.list[i]&&this.list[i][t]&&this.list[i][t].apply(this.list[i],e)},removeAll:function(t){void 0===t&&(t=!1);for(var e=this.list.length;e--;)if(this.list[e]){var i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}},Object.defineProperty(e.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(e.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(e.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),e.ArraySet.prototype.constructor=e.ArraySet,e.ArrayUtils={getRandomItem:function(t,e,i){if(null===t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return void 0===t[s]?null:t[s]},removeRandomItem:function(t,e,i){if(null==t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);if(s<t.length){var n=t.splice(s,1);return void 0===n[0]?null:n[0]}return null},remove:function(t,e,i){var s=t.length;if(!(e>=s||0===i)){null==i&&(i=1);for(var n=s-i,o=e;o<n;++o)t[o]=t[o+i];t.length=n}},shuffle:function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t},transposeMatrix:function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n<i;n++){s[n]=new Array(e);for(var o=e-1;o>-1;o--)s[n][o]=t[o][n]}return s},rotateMatrix:function(t,i){if("string"!=typeof i&&(i=(i%360+360)%360),90===i||-270===i||"rotateLeft"===i)t=(t=e.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===i||270===i||"rotateRight"===i)t=t.reverse(),t=e.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(i)||"rotate180"===i){for(var s=0;s<t.length;s++)t[s].reverse();t=t.reverse()}return t},findClosest:function(t,e){if(!e.length)return NaN;if(1===e.length||t<e[0])return e[0];for(var i=1;e[i]<t;)i++;var s=e[i-1],n=i<e.length?e[i]:Number.POSITIVE_INFINITY;return n-t<=t-s?n:s},rotateRight:function(t){var e=t.pop();return t.unshift(e),e},rotateLeft:function(t){var e=t.shift();return t.push(e),e},numberArray:function(t,e){void 0!==e&&null!==e||(e=t,t=0);for(var i=[],s=t;s<=e;s++)i.push(s);return i},numberArrayStep:function(t,i,s){void 0!==t&&null!==t||(t=0),void 0!==i&&null!==i||(i=t,t=0),void 0===s&&(s=1);for(var n=[],o=Math.max(e.Math.roundAwayFromZero((i-t)/(s||1)),0),r=0;r<o;r++)n.push(t),t+=s;return n}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(t){return 0===this.total&&null===this.first&&null===this.last?(this.first=t,this.last=t,this.next=t,t.prev=this,this.total++,t):(this.last.next=t,t.prev=this.last,this.last=t,this.total++,t)},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(t){if(1===this.total)return this.reset(),void(t.next=t.prev=null);t===this.first?this.first=this.first.next:t===this.last&&(this.last=this.last.prev),t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.next=t.prev=null,null===this.first&&(this.last=null),this.total--},callAll:function(t){if(this.first&&this.last){var e=this.first;do{e&&e[t]&&e[t].call(e),e=e.next}while(e!==this.last.next)}}},e.LinkedList.prototype.constructor=e.LinkedList,e.Create=function(t){this.game=t,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"}]},e.Create.PALETTE_ARNE=0,e.Create.PALETTE_JMP=1,e.Create.PALETTE_CGA=2,e.Create.PALETTE_C64=3,e.Create.PALETTE_JAPANESE_MACHINE=4,e.Create.prototype={texture:function(t,e,i,s,n,o,r,a){void 0===i&&(i=8),void 0===s&&(s=i),void 0===n&&(n=0),void 0===o&&(o=!0);var h=e[0].length*i,l=e.length*s;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(h,l),this.bmd.clear();for(var c=0;c<e.length;c++)for(var u=e[c],d=0;d<u.length;d++){var p=u[d];"."!==p&&" "!==p&&(this.ctx.fillStyle=this.palettes[n][p],this.ctx.fillRect(d*i,c*s,i,s))}return o?this.bmd.generateTexture(t,r,a):this.copy()},grid:function(t,e,i,s,n,o,r,a,h){void 0===r&&(r=!0),null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(e,i),this.ctx.fillStyle=o;for(var l=0;l<i;l+=n)this.ctx.fillRect(0,l,e,1);for(var c=0;c<e;c+=s)this.ctx.fillRect(c,0,1,i);return r?this.bmd.generateTexture(t,a,h):this.copy()},copy:function(t,e,i,s,n,o,r){return null==t&&(t=this.game.make.bitmapData()),t.resize(this.bmd.width,this.bmd.height),t.draw(this.bmd,e,i,s,n,o,r)}},e.Create.prototype.constructor=e.Create,e.FlexGrid=function(t,i,s){this.game=t.game,this.manager=t,this.width=i,this.height=s,this.boundsCustom=new e.Rectangle(0,0,i,s),this.boundsFluid=new e.Rectangle(0,0,i,s),this.boundsFull=new e.Rectangle(0,0,i,s),this.boundsNone=new e.Rectangle(0,0,i,s),this.positionCustom=new e.Point(0,0),this.positionFluid=new e.Point(0,0),this.positionFull=new e.Point(0,0),this.positionNone=new e.Point(0,0),this.scaleCustom=new e.Point(1,1),this.scaleFluid=new e.Point(1,1),this.scaleFluidInversed=new e.Point(1,1),this.scaleFull=new e.Point(1,1),this.scaleNone=new e.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=i/s,this.ratioV=s/i,this.multiplier=0,this.layers=[]},e.FlexGrid.prototype={setSize:function(t,i){this.width=t,this.height=i,this.ratioH=t/i,this.ratioV=i/t,this.scaleNone=new e.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(t,i,s,n){void 0===n&&(n=!0),this.customWidth=t,this.customHeight=i,this.boundsCustom.width=t,this.boundsCustom.height=i;var o=new e.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return n&&this.game.world.add(o),this.layers.push(o),s&&o.addMultiple(s),o},createFluidLayer:function(t,i){void 0===i&&(i=!0);var s=new e.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return i&&this.game.world.add(s),this.layers.push(s),t&&s.addMultiple(t),s},createFullLayer:function(t){var i=new e.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 e.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 t=this.layers.length;t--;)this.layers[t].persist||(this.layers[t].position=null,this.layers[t].scale=null,this.layers.slice(t,1))},onResize:function(t,e){this.ratioH=t/e,this.ratioV=e/t,this.refresh(t,e)},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(t){this.manager.scaleSprite(t),t.x=this.manager.bounds.centerX,t.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)}},e.FlexGrid.prototype.constructor=e.FlexGrid,e.FlexLayer=function(t,i,s,n){e.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=s,this.scale=n,this.topLeft=s.topLeft,this.topMiddle=new e.Point(s.halfWidth,0),this.topRight=s.topRight,this.bottomLeft=s.bottomLeft,this.bottomMiddle=new e.Point(s.halfWidth,s.bottom),this.bottomRight=s.bottomRight},e.FlexLayer.prototype=Object.create(e.Group.prototype),e.FlexLayer.prototype.constructor=e.FlexLayer,e.FlexLayer.prototype.resize=function(){},e.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")},e.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,s,n){return e.Device.LITTLE_ENDIAN?(n<<24|s<<16|i<<8|t)>>>0:(t<<24|i<<16|s<<8|n)>>>0},unpackPixel:function(t,i,s,n){return void 0!==i&&null!==i||(i=e.Color.createColor()),void 0!==s&&null!==s||(s=!1),void 0!==n&&null!==n||(n=!1),e.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+")",s&&e.Color.RGBtoHSL(i.r,i.g,i.b,i),n&&e.Color.RGBtoHSV(i.r,i.g,i.b,i),i},fromRGBA:function(t,i){return i||(i=e.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(t,e,i,s){return t<<24|e<<16|i<<8|s},toABGR:function(t,e,i,s){return(s<<24|i<<16|e<<8|t)>>>0},hexToRGBArray:function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},RGBArrayToHex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},RGBtoHSL:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,1)),t/=255,i/=255,s/=255;var o=Math.min(t,i,s),r=Math.max(t,i,s);if(n.h=0,n.s=0,n.l=(r+o)/2,r!==o){var a=r-o;n.s=n.l>.5?a/(2-r-o):a/(r+o),r===t?n.h=(i-s)/a+(i<s?6:0):r===i?n.h=(s-t)/a+2:r===s&&(n.h=(t-i)/a+4),n.h/=6}return n},HSLtoRGB:function(t,i,s,n){if(n?(n.r=s,n.g=s,n.b=s):n=e.Color.createColor(s,s,s),0!==i){var o=s<.5?s*(1+i):s+i-s*i,r=2*s-o;n.r=e.Color.hueToColor(r,o,t+1/3),n.g=e.Color.hueToColor(r,o,t),n.b=e.Color.hueToColor(r,o,t-1/3)}return n.r=Math.floor(255*n.r|0),n.g=Math.floor(255*n.g|0),n.b=Math.floor(255*n.b|0),e.Color.updateColor(n),n},RGBtoHSV:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,255)),t/=255,i/=255,s/=255;var o=Math.min(t,i,s),r=Math.max(t,i,s),a=r-o;return n.h=0,n.s=0===r?0:a/r,n.v=r,r!==o&&(r===t?n.h=(i-s)/a+(i<s?6:0):r===i?n.h=(s-t)/a+2:r===s&&(n.h=(t-i)/a+4),n.h/=6),n},HSVtoRGB:function(t,i,s,n){void 0===n&&(n=e.Color.createColor(0,0,0,1,t,i,0,s));var o,r,a,h=Math.floor(6*t),l=6*t-h,c=s*(1-i),u=s*(1-l*i),d=s*(1-(1-l)*i);switch(h%6){case 0:o=s,r=d,a=c;break;case 1:o=u,r=s,a=c;break;case 2:o=c,r=s,a=d;break;case 3:o=c,r=u,a=s;break;case 4:o=d,r=c,a=s;break;case 5:o=s,r=c,a=u}return n.r=Math.floor(255*o),n.g=Math.floor(255*r),n.b=Math.floor(255*a),e.Color.updateColor(n),n},hueToColor:function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},createColor:function(t,i,s,n,o,r,a,h){var l={r:t||0,g:i||0,b:s||0,a:n||1,h:o||0,s:r||0,l:a||0,v:h||0,color:0,color32:0,rgba:""};return e.Color.updateColor(l)},updateColor:function(t){return t.rgba="rgba("+t.r.toFixed()+","+t.g.toFixed()+","+t.b.toFixed()+","+t.a.toString()+")",t.color=e.Color.getColor(t.r,t.g,t.b),t.color32=e.Color.getColor32(255*t.a,t.r,t.g,t.b),t},getColor32:function(t,e,i,s){return t<<24|e<<16|i<<8|s},getColor:function(t,e,i){return t<<16|e<<8|i},RGBtoString:function(t,i,s,n,o){return void 0===n&&(n=255),void 0===o&&(o="#"),"#"===o?"#"+((1<<24)+(t<<16)+(i<<8)+s).toString(16).slice(1):"0x"+e.Color.componentToHex(n)+e.Color.componentToHex(t)+e.Color.componentToHex(i)+e.Color.componentToHex(s)},hexToRGB:function(t){var i=e.Color.hexToColor(t);if(i)return e.Color.getColor32(i.a,i.r,i.g,i.b)},hexToColor:function(t,i){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var s=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(s){var n=parseInt(s[1],16),o=parseInt(s[2],16),r=parseInt(s[3],16);i?(i.r=n,i.g=o,i.b=r):i=e.Color.createColor(n,o,r)}return i},webToColor:function(t,i){i||(i=e.Color.createColor());var s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return s&&(i.r=~~Number(s[1]),i.g=~~Number(s[2]),i.b=~~Number(s[3]),i.a=void 0!==s[4]?Number(s[4]):1,e.Color.updateColor(i)),i},valueToColor:function(t,i){if(i||(i=e.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?e.Color.webToColor(t,i):(i.a=1,e.Color.hexToColor(t,i));if("number"==typeof t){var s=e.Color.getRGB(t);return i.r=s.r,i.g=s.g,i.b=s.b,i.a=s.a/255,i}return i},componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},HSVColorWheel:function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSVtoRGB(n/359,t,i));return s},HSLColorWheel:function(t,i){void 0===t&&(t=.5),void 0===i&&(i=.5);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSLtoRGB(n/359,t,i));return s},interpolateColor:function(t,i,s,n,o,r){void 0===o&&(o=255),void 0===r&&(r=0);var a=e.Color.getRGB(t),h=e.Color.getRGB(i);if(0===r)var l=(h.red-a.red)*n/s+a.red,c=(h.green-a.green)*n/s+a.green,u=(h.blue-a.blue)*n/s+a.blue;if(1===r){var d,p=e.Color.RGBtoHSV(a.r,a.g,a.b),f=e.Color.RGBtoHSV(h.r,h.g,h.b),g=f.h-p.h;if(p.h>f.h){var m=f.h;f.h=p.h,p.h=m,g=-g,n=s-n}g>.5&&(p.h=p.h+1,d=((f.h-p.h)*n/s+p.h)%1),g<=.5&&(d=(f.h-p.h)*n/s+p.h);var y=(f.s-p.s)*n/s+p.s,v=(f.v-p.v)*n/s+p.v,x=e.Color.HSVtoRGB(d,y,v,x),l=x.r,c=x.g,u=x.b}return e.Color.getColor32(o,l,c,u)},interpolateColorWithRGB:function(t,i,s,n,o,r){var a=e.Color.getRGB(t),h=(i-a.red)*r/o+a.red,l=(s-a.green)*r/o+a.green,c=(n-a.blue)*r/o+a.blue;return e.Color.getColor(h,l,c)},interpolateRGB:function(t,i,s,n,o,r,a,h){var l=(n-t)*h/a+t,c=(o-i)*h/a+i,u=(r-s)*h/a+s;return e.Color.getColor(l,c,u)},linear:function(t,e,i){return this.interpolateColor(t,e,1,i)},linearInterpolation:function(t,i){var s=e.Math.linear(0,t.length-1,i),n=t[Math.floor(s)],o=t[Math.ceil(s)];return this.linear(n,o,s%1)},getRandomColor:function(t,i,s){if(void 0===t&&(t=0),void 0===i&&(i=255),void 0===s&&(s=255),i>255||t>i)return e.Color.getColor(255,255,255);var n=t+Math.round(Math.random()*(i-t)),o=t+Math.round(Math.random()*(i-t)),r=t+Math.round(Math.random()*(i-t));return e.Color.getColor32(s,n,o,r)},getRGB:function(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var i=e.Color.getRGB(t);return"rgba("+i.r.toString()+","+i.g.toString()+","+i.b.toString()+","+(i.a/255).toString()+")"},getAlpha:function(t){return t>>>24},getAlphaFloat:function(t){return(t>>>24)/255},getRed:function(t){return t>>16&255},getGreen:function(t){return t>>8&255},getBlue:function(t){return 255&t},blendNormal:function(t){return t},blendLighten:function(t,e){return e>t?e:t},blendDarken:function(t,e){return e>t?t:e},blendMultiply:function(t,e){return t*e/255},blendAverage:function(t,e){return(t+e)/2},blendAdd:function(t,e){return Math.min(255,t+e)},blendSubtract:function(t,e){return Math.max(0,t+e-255)},blendDifference:function(t,e){return Math.abs(t-e)},blendNegation:function(t,e){return 255-Math.abs(255-t-e)},blendScreen:function(t,e){return 255-((255-t)*(255-e)>>8)},blendExclusion:function(t,e){return t+e-2*t*e/255},blendOverlay:function(t,e){return e<128?2*t*e/255:255-2*(255-t)*(255-e)/255},blendSoftLight:function(t,e){return e<128?2*(64+(t>>1))*(e/255):255-2*(255-(64+(t>>1)))*(255-e)/255},blendHardLight:function(t,i){return e.Color.blendOverlay(i,t)},blendColorDodge:function(t,e){return 255===e?e:Math.min(255,(t<<8)/(255-e))},blendColorBurn:function(t,e){return 0===e?e:Math.max(0,255-(255-t<<8)/e)},blendLinearDodge:function(t,i){return e.Color.blendAdd(t,i)},blendLinearBurn:function(t,i){return e.Color.blendSubtract(t,i)},blendLinearLight:function(t,i){return i<128?e.Color.blendLinearBurn(t,2*i):e.Color.blendLinearDodge(t,2*(i-128))},blendVividLight:function(t,i){return i<128?e.Color.blendColorBurn(t,2*i):e.Color.blendColorDodge(t,2*(i-128))},blendPinLight:function(t,i){return i<128?e.Color.blendDarken(t,2*i):e.Color.blendLighten(t,2*(i-128))},blendHardMix:function(t,i){return e.Color.blendVividLight(t,i)<128?0:255},blendReflect:function(t,e){return 255===e?e:Math.min(255,t*t/(255-e))},blendGlow:function(t,i){return e.Color.blendReflect(i,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},e.Physics=function(t,e){e=e||{},this.game=t,this.config=e,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},e.Physics.ARCADE=0,e.Physics.P2JS=1,e.Physics.NINJA=2,e.Physics.BOX2D=3,e.Physics.CHIPMUNK=4,e.Physics.MATTERJS=5,e.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!e.Physics.hasOwnProperty("Arcade")||(this.arcade=new e.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&e.Physics.hasOwnProperty("Ninja")&&(this.ninja=new e.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&e.Physics.hasOwnProperty("P2")&&(this.p2=new e.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&e.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new e.Physics.Box2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&e.Physics.hasOwnProperty("Matter")&&(this.matter=new e.Physics.Matter(this.game,this.config))},startSystem:function(t){t===e.Physics.ARCADE?this.arcade=new e.Physics.Arcade(this.game):t===e.Physics.P2JS?null===this.p2?this.p2=new e.Physics.P2(this.game,this.config):this.p2.reset():t===e.Physics.NINJA?this.ninja=new e.Physics.Ninja(this.game):t===e.Physics.BOX2D?null===this.box2d?this.box2d=new e.Physics.Box2D(this.game,this.config):this.box2d.reset():t===e.Physics.MATTERJS&&(null===this.matter?this.matter=new e.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,i,s){void 0===i&&(i=e.Physics.ARCADE),void 0===s&&(s=!1),i===e.Physics.ARCADE?this.arcade.enable(t):i===e.Physics.P2JS&&this.p2?this.p2.enable(t,s):i===e.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):i===e.Physics.BOX2D&&this.box2d?this.box2d.enable(t):i===e.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}},e.Physics.prototype.constructor=e.Physics,e.Physics.Arcade=function(t){this.game=t,this.gravity=new e.Point,this.bounds=new e.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=e.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new e.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()},e.Physics.Arcade.prototype.constructor=e.Physics.Arcade,e.Physics.Arcade.SORT_NONE=0,e.Physics.Arcade.LEFT_RIGHT=1,e.Physics.Arcade.RIGHT_LEFT=2,e.Physics.Arcade.TOP_BOTTOM=3,e.Physics.Arcade.BOTTOM_TOP=4,e.Physics.Arcade.prototype={setBounds:function(t,e,i,s){this.bounds.setTo(t,e,i,s)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,i){void 0===i&&(i=!0);var s=1;if(Array.isArray(t))for(s=t.length;s--;)t[s]instanceof e.Group?this.enable(t[s].children,i):(this.enableBody(t[s]),i&&t[s].hasOwnProperty("children")&&t[s].children.length>0&&this.enable(t[s],!0));else t instanceof e.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 e.Physics.Arcade.Body(t),t.parent&&t.parent instanceof e.Group&&t.parent.addToHash(t))},updateMotion:function(t){if(t.allowRotation){var e=this.computeVelocity(0,t,t.angularVelocity,t.angularAcceleration,t.angularDrag,t.maxAngular)-t.angularVelocity;t.angularVelocity+=e,t.rotation+=t.angularVelocity*this.game.time.physicsElapsed}t.velocity.x=this.computeVelocity(1,t,t.velocity.x,t.acceleration.x,t.drag.x,t.maxVelocity.x),t.velocity.y=this.computeVelocity(2,t,t.velocity.y,t.acceleration.y,t.drag.y,t.maxVelocity.y)},computeVelocity:function(t,e,i,s,n,o){return void 0===o&&(o=1e4),1===t&&e.allowGravity?i+=(this.gravity.x+e.gravity.x)*this.game.time.physicsElapsed:2===t&&e.allowGravity&&(i+=(this.gravity.y+e.gravity.y)*this.game.time.physicsElapsed),s?i+=s*this.game.time.physicsElapsed:n&&e.allowDrag&&(i-(n*=this.game.time.physicsElapsed)>0?i-=n:i+n<0?i+=n:i=0),i>o?i=o:i<-o&&(i=-o),i},overlap:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!0),this._total>0},collide:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!1),this._total>0},sortLeftRight:function(t,e){return t.body&&e.body?t.body.x-e.body.x:0},sortRightLeft:function(t,e){return t.body&&e.body?e.body.x-t.body.x:0},sortTopBottom:function(t,e){return t.body&&e.body?t.body.y-e.body.y:0},sortBottomTop:function(t,e){return t.body&&e.body?e.body.y-t.body.y:0},sort:function(t,i){null!==t.physicsSortDirection?i=t.physicsSortDirection:void 0===i&&(i=this.sortDirection),i===e.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):i===e.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):i===e.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):i===e.Physics.Arcade.BOTTOM_TOP&&t.hash.sort(this.sortBottomTop)},collideObjects:function(t,e,i,s,n,o){if(!Array.isArray(t)&&Array.isArray(e))for(r=0;r<e.length;r++)e[r]&&this.collideHandler(t,e[r],i,s,n,o);else if(Array.isArray(t)&&!Array.isArray(e))for(r=0;r<t.length;r++)t[r]&&this.collideHandler(t[r],e,i,s,n,o);else if(Array.isArray(t)&&Array.isArray(e)){for(var r=0;r<t.length;r++)if(t[r])for(var a=0;a<e.length;a++)e[a]&&this.collideHandler(t[r],e[a],i,s,n,o)}else this.collideHandler(t,e,i,s,n,o)},collideHandler:function(t,i,s,n,o,r){if(void 0===i&&t.physicsType===e.GROUP)return this.sort(t),void this.collideGroupVsSelf(t,s,n,o,r);t&&i&&t.exists&&i.exists&&(this.sortDirection!==e.Physics.Arcade.SORT_NONE&&(t.physicsType===e.GROUP&&this.sort(t),i.physicsType===e.GROUP&&this.sort(i)),t.physicsType===e.SPRITE?i.physicsType===e.SPRITE?this.collideSpriteVsSprite(t,i,s,n,o,r):i.physicsType===e.GROUP?this.collideSpriteVsGroup(t,i,s,n,o,r):i.physicsType===e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(t,i,s,n,o,r):t.physicsType===e.GROUP?i.physicsType===e.SPRITE?this.collideSpriteVsGroup(i,t,s,n,o,r):i.physicsType===e.GROUP?this.collideGroupVsGroup(t,i,s,n,o,r):i.physicsType===e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(t,i,s,n,o,r):t.physicsType===e.TILEMAPLAYER&&(i.physicsType===e.SPRITE?this.collideSpriteVsTilemapLayer(i,t,s,n,o,r):i.physicsType===e.GROUP&&this.collideGroupVsTilemapLayer(i,t,s,n,o,r)))},collideSpriteVsSprite:function(t,e,i,s,n,o){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,s,n,o)&&(i&&i.call(n,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,i,s,n,o,r){if(0!==i.length&&t.body)if(this.skipQuadTree||t.body.skipQuadTree)for(var a={},h=0;h<i.hash.length;h++){var l=i.hash[h];if(l&&l.exists&&l.body){if(a=l.body.getBounds(a),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(t.body.right<a.x)break;if(a.right<t.body.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(t.body.x>a.right)break;if(a.x>t.body.right)continue}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(t.body.bottom<a.y)break;if(a.bottom<t.body.y)continue}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(t.body.y>a.bottom)break;if(a.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,l,s,n,o,r)}}else{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);for(var c=this.quadTree.retrieve(t),h=0;h<c.length;h++)this.separate(t.body,c[h],n,o,r)&&(s&&s.call(o,t,c[h].sprite),this._total++)}},collideGroupVsSelf:function(t,i,s,n,o){if(0!==t.length)for(var r=0;r<t.hash.length;r++){var a={},h=t.hash[r];if(h&&h.exists&&h.body){a=h.body.getBounds(a);for(var l=r+1;l<t.hash.length;l++){var c={},u=t.hash[l];if(u&&u.exists&&u.body){if(c=u.body.getBounds(c),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(a.right<c.x)break;if(c.right<a.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(a.x>c.right)continue;if(c.x>a.right)break}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(a.bottom<c.y)continue;if(c.bottom<a.y)break}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(a.y>c.bottom)continue;if(c.y>h.body.bottom)break}this.collideSpriteVsSprite(h,u,i,s,n,o)}}}}},collideGroupVsGroup:function(t,i,s,n,o,r){if(0!==t.length&&0!==i.length)for(var a=0;a<t.children.length;a++)t.children[a].exists&&(t.children[a].physicsType===e.GROUP?this.collideGroupVsGroup(t.children[a],i,s,n,o,r):this.collideSpriteVsGroup(t.children[a],i,s,n,o,r))},separate:function(t,e,i,s,n){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(s,t.sprite,e.sprite))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,n);if(t.isCircle!==e.isCircle){var o=t.isCircle?e:t,r=t.isCircle?t:e,a={x:o.x,y:o.y,right:o.right,bottom:o.bottom},h=r.center;if((h.y<a.y||h.y>a.bottom)&&(h.x<a.x||h.x>a.right))return this.separateCircle(t,e,n)}var l=!1,c=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)<Math.abs(this.gravity.x+t.gravity.x)?(l=this.separateX(t,e,n),this.intersects(t,e)&&(c=this.separateY(t,e,n))):(c=this.separateY(t,e,n),this.intersects(t,e)&&(l=this.separateX(t,e,n)));var u=l||c;return u&&(n?(t.onOverlap&&t.onOverlap.dispatch(t.sprite,e.sprite),e.onOverlap&&e.onOverlap.dispatch(e.sprite,t.sprite)):(t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite))),u},intersects:function(t,i){return t!==i&&(t.isCircle?i.isCircle?e.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 s=e.Math.clamp(t.center.x,i.left,i.right),n=e.Math.clamp(t.center.y,i.top,i.bottom);return(t.center.x-s)*(t.center.x-s)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},separateCircle:function(t,i,s){this.getOverlapX(t,i),this.getOverlapY(t,i);var n=i.center.x-t.center.x,o=i.center.y-t.center.y,r=Math.atan2(o,n),a=0;if(t.isCircle!==i.isCircle){var h={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},l={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};l.y<h.y?l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.y)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.y)-l.radius):l.y>h.bottom&&(l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.bottom)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.bottom)-l.radius)),a*=-1}else a=t.halfWidth+i.halfWidth-e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y);if(s||0===a||t.immovable&&i.immovable||t.customSeparateX||i.customSeparateX)return 0!==a&&(t.onOverlap&&t.onOverlap.dispatch(t.sprite,i.sprite),i.onOverlap&&i.onOverlap.dispatch(i.sprite,t.sprite)),0!==a;var c={x:t.velocity.x*Math.cos(r)+t.velocity.y*Math.sin(r),y:-t.velocity.x*Math.sin(r)+t.velocity.y*Math.cos(r)},u={x:i.velocity.x*Math.cos(r)+i.velocity.y*Math.sin(r),y:-i.velocity.x*Math.sin(r)+i.velocity.y*Math.cos(r)},d=((t.mass-i.mass)*c.x+2*i.mass*u.x)/(t.mass+i.mass),p=(2*t.mass*c.x+(i.mass-t.mass)*u.x)/(t.mass+i.mass);return t.immovable||(t.velocity.x=(d*Math.cos(r)-c.y*Math.sin(r))*t.bounce.x,t.velocity.y=(c.y*Math.cos(r)+d*Math.sin(r))*t.bounce.y),i.immovable||(i.velocity.x=(p*Math.cos(r)-u.y*Math.sin(r))*i.bounce.x,i.velocity.y=(u.y*Math.cos(r)+p*Math.sin(r))*i.bounce.y),Math.abs(r)<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(r)>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-a*Math.cos(r),t.y+=t.velocity.y*this.game.time.physicsElapsed-a*Math.sin(r)),i.immovable||(i.x+=i.velocity.x*this.game.time.physicsElapsed+a*Math.cos(r),i.y+=i.velocity.y*this.game.time.physicsElapsed+a*Math.sin(r)),t.onCollide&&t.onCollide.dispatch(t.sprite,i.sprite),i.onCollide&&i.onCollide.dispatch(i.sprite,t.sprite),!0},getOverlapX:function(t,e,i){var s=0,n=t.deltaAbsX()+e.deltaAbsX()+this.OVERLAP_BIAS;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>n&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()<e.deltaX()&&(-(s=t.x-e.width-e.x)>n&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s},getOverlapY:function(t,e,i){var s=0,n=t.deltaAbsY()+e.deltaAbsY()+this.OVERLAP_BIAS;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>n&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()<e.deltaY()&&(-(s=t.y-e.bottom)>n&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s},separateX:function(t,e,i){var s=this.getOverlapX(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.x,o=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=s,e.velocity.x=n-o*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=s,t.velocity.x=o-n*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{s*=.5,t.x-=s,e.x+=s;var r=Math.sqrt(o*o*e.mass/t.mass)*(o>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(r+a);r-=h,a-=h,t.velocity.x=h+r*t.bounce.x,e.velocity.x=h+a*e.bounce.x}return!0},separateY:function(t,e,i){var s=this.getOverlapY(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.y,o=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=s,e.velocity.y=n-o*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=s,t.velocity.y=o-n*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{s*=.5,t.y-=s,e.y+=s;var r=Math.sqrt(o*o*e.mass/t.mass)*(o>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(r+a);r-=h,a-=h,t.velocity.y=h+r*t.bounce.y,e.velocity.y=h+a*e.bounce.y}return!0},getObjectsUnderPointer:function(t,e,i,s){if(0!==e.length&&t.exists)return this.getObjectsAtLocation(t.x,t.y,e,i,s,t)},getObjectsAtLocation:function(t,i,s,n,o,r){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(s);for(var a=new e.Rectangle(t,i,1,1),h=[],l=this.quadTree.retrieve(a),c=0;c<l.length;c++)l[c].hitTest(t,i)&&(n&&n.call(o,r,l[c].sprite),h.push(l[c].sprite));return h},moveToObject:function(t,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var o=e.Point.angle(i,t);return n>0&&(s=this.distanceBetween(t,i)/(n/1e3)),t.body.velocity.setToPolar(o,s),o},moveToPointer:function(t,e,i,s){void 0===e&&(e=60),i=i||this.game.input.activePointer,void 0===s&&(s=0);var n=this.angleToPointer(t,i);return s>0&&(e=this.distanceToPointer(t,i)/(s/1e3)),t.body.velocity.setToPolar(n,e),n},moveToXY:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var o=Math.atan2(i-t.y,e-t.x);return n>0&&(s=this.distanceToXY(t,e,i)/(n/1e3)),t.body.velocity.setToPolar(o,s),o},velocityFromAngle:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i,!0)},velocityFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerationFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerateToObject:function(t,e,i,s,n){void 0===i&&(i=60),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var o=this.angleBetween(t,e);return t.body.acceleration.setToPolar(o,i),t.body.maxVelocity.setTo(s,n),o},accelerateToPointer:function(t,e,i,s,n){void 0===i&&(i=60),void 0===e&&(e=this.game.input.activePointer),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var o=this.angleToPointer(t,e);return t.body.acceleration.setToPolar(o,i),t.body.maxVelocity.setTo(s,n),o},accelerateToXY:function(t,e,i,s,n,o){void 0===s&&(s=60),void 0===n&&(n=1e3),void 0===o&&(o=1e3);var r=this.angleToXY(t,e,i);return t.body.acceleration.setTo(r,s),t.body.maxVelocity.setTo(n,o),r},distanceBetween:function(t,e,i,s){void 0===i&&(i=!1);var n,o;return s?(n=t.centerX-e.centerX,o=t.centerY-e.centerY):i?(n=t.world.x-e.world.x,o=t.world.y-e.world.y):(n=t.x-e.x,o=t.y-e.y),Math.sqrt(n*n+o*o)},distanceToXY:function(t,e,i,s){void 0===s&&(s=!1);var n=s?t.world.x-e:t.x-e,o=s?t.world.y-i:t.y-i;return Math.sqrt(n*n+o*o)},distanceToPointer:function(t,e,i){void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1);var s=i?t.world.x-e.worldX:t.x-e.worldX,n=i?t.world.y-e.worldY:t.y-e.worldY;return Math.sqrt(s*s+n*n)},closest:function(t,e,i,s){for(var n=1/0,o=null,r=0,a=e.length;r<a;r++){var h=e[r],l=this.distanceBetween(t,h,i,s);l<n&&(o=h,n=l)}return o},farthest:function(t,e,i,s){for(var n=-1,o=null,r=0,a=e.length;r<a;r++){var h=e[r],l=this.distanceBetween(t,h,i,s);l>n&&(o=h,n=l)}return o},angleBetween:function(t,i,s){return void 0===s&&(s=!1),s?e.Point.angle(i.world,t.world):e.Point.angle(i,t)},angleBetweenCenters:function(t,e){var i=e.centerX-t.centerX,s=e.centerY-t.centerY;return Math.atan2(s,i)},angleToXY:function(t,e,i,s){return void 0===s&&(s=!1),s?Math.atan2(i-t.world.y,e-t.world.x):Math.atan2(i-t.y,e-t.x)},angleToPointer:function(t,e,i){return void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1),i?Math.atan2(e.worldY-t.world.y,e.worldX-t.world.x):Math.atan2(e.worldY-t.y,e.worldX-t.x)},worldAngleToPointer:function(t,e){return this.angleToPointer(t,e,!0)}},e.Physics.Arcade.Body=function(t){this.sprite=t,this.game=t.game,this.type=e.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new e.Point,this.position=new e.Point(t.x,t.y),this.prev=new e.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 e.Point(t.x+this.halfWidth,t.y+this.halfHeight),this.velocity=new e.Point,this.newVelocity=new e.Point,this.deltaMax=new e.Point,this.acceleration=new e.Point,this.allowDrag=!0,this.drag=new e.Point,this.allowGravity=!0,this.gravity=new e.Point,this.bounce=new e.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new e.Point(1e4,1e4),this.friction=new e.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=e.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 e.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 e.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},e.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var t=this.sprite.getBounds();t.ceilAll(),t.width===this.width&&t.height===this.height||(this.width=t.width,this.height=t.height,this._reset=!0)}else{var e=Math.abs(this.sprite.scale.x),i=Math.abs(this.sprite.scale.y);e===this._sx&&i===this._sy||(this.width=this.sourceWidth*e,this.height=this.sourceHeight*i,this._sx=e,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 t=0,e=0!==this.overlapX||0!==this.overlapY;if(this.moveDuration>0?(this.moveTimer+=this.game.time.elapsedMS,t=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),t=this.moveTarget.length/this.moveDistance),this.movementCallback)var i=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,t);return!(e||t>=1||void 0!==i&&!0!==i)||(this.stopMovement(t>=1||this.stopVelocityOnCollide&&e),!1)},stopMovement:function(t){this.isMoving&&(this.isMoving=!1,t&&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=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.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,e=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.x<e.x&&i.left?(t.x=e.x,this.velocity.x*=s,this.blocked.left=!0,this.blocked.none=!1):this.right>e.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,this.blocked.none=!1),t.y<e.y&&i.up?(t.y=e.y,this.velocity.y*=n,this.blocked.up=!0,this.blocked.none=!1):this.bottom>e.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(t,e,i){if(void 0===e&&(e=this.speed),0===e)return!1;var s;return void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=t,0===i||180===i?this.velocity.set(Math.cos(s)*e,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*e):this.velocity.setToPolar(s,e),this.isMoving=!0,!0},moveTo:function(t,i,s){var n=i/(t/1e3);if(0===n)return!1;var o;return void 0===s?(o=this.angle,s=this.game.math.radToDeg(o)):o=this.game.math.degToRad(s),i=Math.abs(i),this.moveDuration=0,this.moveDistance=i,null===this.moveTarget&&(this.moveTarget=new e.Line,this.moveEnd=new e.Point),this.moveTarget.fromAngle(this.x,this.y,o,i),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===s||180===s?this.velocity.set(Math.cos(o)*n,0):90===s||270===s?this.velocity.set(0,Math.sin(o)*n):this.velocity.setToPolar(o,n),this.isMoving=!0,!0},setSize:function(t,e,i,s){void 0===i&&(i=this.offset.x),void 0===s&&(s=this.offset.y),this.sourceWidth=t,this.sourceHeight=e,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,s),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(t,e,i){void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*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(e,i),this.updateCenter()):this.isCircle=!1},reset:function(t,e){this.stop(),this.position.x=t-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=e-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(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,i){return this.isCircle?e.Circle.contains(this,t,i):e.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 e.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),e.Physics.Arcade.Body.render=function(t,e,i,s,n){void 0===s&&(s=!0),i=i||"rgba(0,255,0,0.4)",t.fillStyle=i,t.strokeStyle=i,t.lineWidth=n||1,e.isCircle?(t.beginPath(),t.arc(e.center.x-e.game.camera.x,e.center.y-e.game.camera.y,e.halfWidth,0,2*Math.PI),s?t.fill():t.stroke()):s?t.fillRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height):t.strokeRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height)},e.Physics.Arcade.Body.renderBodyInfo=function(t,e){t.line("x: "+e.x.toFixed(2),"y: "+e.y.toFixed(2),"width: "+e.width,"height: "+e.height),t.line("velocity x: "+e.velocity.x.toFixed(2),"y: "+e.velocity.y.toFixed(2),"deltaX: "+e._dx.toFixed(2),"deltaY: "+e._dy.toFixed(2)),t.line("acceleration x: "+e.acceleration.x.toFixed(2),"y: "+e.acceleration.y.toFixed(2),"speed: "+e.speed.toFixed(2),"angle: "+e.angle.toFixed(2)),t.line("gravity x: "+e.gravity.x,"y: "+e.gravity.y,"bounce x: "+e.bounce.x.toFixed(2),"y: "+e.bounce.y.toFixed(2)),t.line("touching left: "+e.touching.left,"right: "+e.touching.right,"up: "+e.touching.up,"down: "+e.touching.down),t.line("blocked left: "+e.blocked.left,"right: "+e.blocked.right,"up: "+e.blocked.up,"down: "+e.blocked.down)},e.Physics.Arcade.Body.prototype.constructor=e.Physics.Arcade.Body,e.Physics.Arcade.TilemapCollision=function(){},e.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(t,e,i,s,n,o){if(t.body){var r=e.getTiles(t.body.position.x-t.body.tilePadding.x-e.getTileOffsetX(),t.body.position.y-t.body.tilePadding.y-e.getTileOffsetY(),t.body.width+t.body.tilePadding.x,t.body.height+t.body.tilePadding.y,!1,!1);if(0!==r.length)for(var a=0;a<r.length;a++)s?s.call(n,t,r[a])&&this.separateTile(a,t.body,r[a],e,o)&&(this._total++,i&&i.call(n,t,r[a])):this.separateTile(a,t.body,r[a],e,o)&&(this._total++,i&&i.call(n,t,r[a]))}},collideGroupVsTilemapLayer:function(t,e,i,s,n,o){if(0!==t.length)for(var r=0;r<t.children.length;r++)t.children[r].exists&&this.collideSpriteVsTilemapLayer(t.children[r],e,i,s,n,o)},separateTile:function(t,e,i,s,n){if(!e.enable)return!1;var o=s.getTileOffsetX(),r=s.getTileOffsetY();if(!i.intersects(e.position.x-o,e.position.y-r,e.right-o,e.bottom-r))return!1;if(n)return!0;if(i.collisionCallback&&!i.collisionCallback.call(i.collisionCallbackContext,e.sprite,i))return!1;if(void 0!==i.layer.callbacks&&i.layer.callbacks[i.index]&&!i.layer.callbacks[i.index].callback.call(i.layer.callbacks[i.index].callbackContext,e.sprite,i))return!1;if(!(i.faceLeft||i.faceRight||i.faceTop||i.faceBottom))return!1;var a=0,h=0,l=0,c=1;if(e.deltaAbsX()>e.deltaAbsY()?l=-1:e.deltaAbsX()<e.deltaAbsY()&&(c=-1),0!==e.deltaX()&&0!==e.deltaY()&&(i.faceLeft||i.faceRight)&&(i.faceTop||i.faceBottom)&&(l=Math.min(Math.abs(e.position.x-o-i.right),Math.abs(e.right-o-i.left)),c=Math.min(Math.abs(e.position.y-r-i.bottom),Math.abs(e.bottom-r-i.top))),l<c){if((i.faceLeft||i.faceRight)&&0!==(a=this.tileCheckX(e,i,s))&&!i.intersects(e.position.x-o,e.position.y-r,e.right-o,e.bottom-r))return!0;(i.faceTop||i.faceBottom)&&(h=this.tileCheckY(e,i,s))}else{if((i.faceTop||i.faceBottom)&&0!==(h=this.tileCheckY(e,i,s))&&!i.intersects(e.position.x-o,e.position.y-r,e.right-o,e.bottom-r))return!0;(i.faceLeft||i.faceRight)&&(a=this.tileCheckX(e,i,s))}return 0!==a||0!==h},tileCheckX:function(t,e,i){var s=0,n=i.getTileOffsetX();return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x-n<e.right&&(s=t.x-n-e.right)<-this.TILE_BIAS&&(s=0):t.deltaX()>0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right-n>e.left&&(s=t.right-n-e.left)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateX?t.overlapX=s:this.processTileSeparationX(t,s)),s},tileCheckY:function(t,e,i){var s=0,n=i.getTileOffsetY();return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y-n<e.bottom&&(s=t.y-n-e.bottom)<-this.TILE_BIAS&&(s=0):t.deltaY()>0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom-n>e.top&&(s=t.bottom-n-e.top)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateY?t.overlapY=s:this.processTileSeparationY(t,s)),s},processTileSeparationX:function(t,e){e<0?(t.blocked.left=!0,t.blocked.none=!1):e>0&&(t.blocked.right=!0,t.blocked.none=!1),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x},processTileSeparationY:function(t,e){e<0?(t.blocked.up=!0,t.blocked.none=!1):e>0&&(t.blocked.down=!0,t.blocked.none=!1),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},e.Utils.mixinPrototype(e.Physics.Arcade.prototype,e.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,e.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 e.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new e.Signal,this.onBodyRemoved=new e.Signal,this.onSpringAdded=new e.Signal,this.onSpringRemoved=new e.Signal,this.onConstraintAdded=new e.Signal,this.onConstraintRemoved=new e.Signal,this.onContactMaterialAdded=new e.Signal,this.onContactMaterialRemoved=new e.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new e.Signal,this.onEndContact=new e.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 e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.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)},e.Physics.P2.prototype={removeBodyNextStep:function(t){this._toRemove.push(t)},preUpdate:function(){for(var t=this._toRemove.length;t--;)this.removeBody(this._toRemove[t]);this._toRemove.length=0},enable:function(t,i,s){void 0===i&&(i=!1),void 0===s&&(s=!0);var n=1;if(Array.isArray(t))for(n=t.length;n--;)t[n]instanceof e.Group?this.enable(t[n].children,i,s):(this.enableBody(t[n],i),s&&t[n].hasOwnProperty("children")&&t[n].children.length>0&&this.enable(t[n],i,!0));else t instanceof e.Group?this.enable(t.children,i,s):(this.enableBody(t,i),s&&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 e.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(t){t?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(t,e){this.postBroadphaseCallback=t,this.callbackContext=e,null!==t?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(t){if(this.postBroadphaseCallback&&0!==t.pairs.length)for(var e=t.pairs.length-2;e>=0;e-=2)t.pairs[e].parent&&t.pairs[e+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,t.pairs[e].parent,t.pairs[e+1].parent)&&t.pairs.splice(e,2)},impactHandler:function(t){if(t.bodyA.parent&&t.bodyB.parent){var e=t.bodyA.parent,i=t.bodyB.parent;e._bodyCallbacks[t.bodyB.id]&&e._bodyCallbacks[t.bodyB.id].call(e._bodyCallbackContext[t.bodyB.id],e,i,t.shapeA,t.shapeB),i._bodyCallbacks[t.bodyA.id]&&i._bodyCallbacks[t.bodyA.id].call(i._bodyCallbackContext[t.bodyA.id],i,e,t.shapeB,t.shapeA),e._groupCallbacks[t.shapeB.collisionGroup]&&e._groupCallbacks[t.shapeB.collisionGroup].call(e._groupCallbackContext[t.shapeB.collisionGroup],e,i,t.shapeA,t.shapeB),i._groupCallbacks[t.shapeA.collisionGroup]&&i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.collisionGroup],i,e,t.shapeB,t.shapeA)}},beginContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onBeginContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyA.parent&&t.bodyA.parent.onBeginContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyB.parent&&t.bodyB.parent.onBeginContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA,t.contactEquations))},endContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onEndContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB),t.bodyA.parent&&t.bodyA.parent.onEndContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB),t.bodyB.parent&&t.bodyB.parent.onEndContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA))},setBoundsToWorld:function(t,e,i,s,n){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,t,e,i,s,n)},setWorldMaterial:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===s&&(s=!0),void 0===n&&(n=!0),e&&this.walls.left&&(this.walls.left.shapes[0].material=t),i&&this.walls.right&&(this.walls.right.shapes[0].material=t),s&&this.walls.top&&(this.walls.top.shapes[0].material=t),n&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=t)},updateBoundsCollisionGroup:function(t){void 0===t&&(t=!0);var e=t?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=e),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=e),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=e),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=e),this._boundsOwnGroup=t},setBounds:function(t,e,i,s,n,o,r,a,h){void 0===n&&(n=this._boundsLeft),void 0===o&&(o=this._boundsRight),void 0===r&&(r=this._boundsTop),void 0===a&&(a=this._boundsBottom),void 0===h&&(h=this._boundsOwnGroup),this.setupWall(n,"left",t,e,1.5707963267948966,h),this.setupWall(o,"right",t+i,e,-1.5707963267948966,h),this.setupWall(r,"top",t,e,-3.141592653589793,h),this.setupWall(a,"bottom",t,e+s,0,h),this._boundsLeft=n,this._boundsRight=o,this._boundsTop=r,this._boundsBottom=a,this._boundsOwnGroup=h},setupWall:function(t,e,i,s,n,o){t?(this.walls[e]?this.walls[e].position=[this.pxmi(i),this.pxmi(s)]:(this.walls[e]=new p2.Body({mass:0,position:[this.pxmi(i),this.pxmi(s)],angle:n}),this.walls[e].addShape(new p2.Plane),this.world.addBody(this.walls[e])),o&&(this.walls[e].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[e]&&(this.world.removeBody(this.walls[e]),this.walls[e]=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 e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var t=this.world.constraints,e=t.length-1;e>=0;e--)this.world.removeConstraint(t[e]);for(var i=this.world.bodies,e=i.length-1;e>=0;e--)this.world.removeBody(i[e]);for(var s=this.world.springs,e=s.length-1;e>=0;e--)this.world.removeSpring(s[e]);for(var n=this.world.contactMaterials,e=n.length-1;e>=0;e--)this.world.removeContactMaterial(n[e]);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(t){return!t.data.world&&(this.world.addBody(t.data),this.onBodyAdded.dispatch(t),!0)},removeBody:function(t){return t.data.world===this.world&&(this.world.removeBody(t.data),this.onBodyRemoved.dispatch(t)),t},addSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.addSpring(t.data):this.world.addSpring(t),this.onSpringAdded.dispatch(t),t},removeSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.removeSpring(t.data):this.world.removeSpring(t),this.onSpringRemoved.dispatch(t),t},createDistanceConstraint:function(t,i,s,n,o,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.DistanceConstraint(this,t,i,s,n,o,r));console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(t,i,s,n){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.GearConstraint(this,t,i,s,n));console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(t,i,s,n,o,r){if(t=this.getBody(t),s=this.getBody(s),t&&s)return this.addConstraint(new e.Physics.P2.RevoluteConstraint(this,t,i,s,n,o,r));console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(t,i,s,n,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.LockConstraint(this,t,i,s,n,o));console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(t,i,s,n,o,r,a){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.PrismaticConstraint(this,t,i,s,n,o,r,a));console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(t){return this.world.addConstraint(t),this.onConstraintAdded.dispatch(t),t},removeConstraint:function(t){return this.world.removeConstraint(t),this.onConstraintRemoved.dispatch(t),t},addContactMaterial:function(t){return this.world.addContactMaterial(t),this.onContactMaterialAdded.dispatch(t),t},removeContactMaterial:function(t){return this.world.removeContactMaterial(t),this.onContactMaterialRemoved.dispatch(t),t},getContactMaterial:function(t,e){return this.world.getContactMaterial(t,e)},setMaterial:function(t,e){for(var i=e.length;i--;)e[i].setMaterial(t)},createMaterial:function(t,i){t=t||"";var s=new e.Physics.P2.Material(t);return this.materials.push(s),void 0!==i&&i.setMaterial(s),s},createContactMaterial:function(t,i,s){void 0===t&&(t=this.createMaterial()),void 0===i&&(i=this.createMaterial());var n=new e.Physics.P2.ContactMaterial(t,i,s);return this.addContactMaterial(n)},getBodies:function(){for(var t=[],e=this.world.bodies.length;e--;)t.push(this.world.bodies[e].parent);return t},getBody:function(t){return t instanceof p2.Body?t:t instanceof e.Physics.P2.Body?t.data:t.body&&t.body.type===e.Physics.P2JS?t.body.data:null},getSprings:function(){for(var t=[],e=this.world.springs.length;e--;)t.push(this.world.springs[e].parent);return t},getConstraints:function(){for(var t=[],e=this.world.constraints.length;e--;)t.push(this.world.constraints[e]);return t},hitTest:function(t,i,s,n){void 0===i&&(i=this.world.bodies),void 0===s&&(s=5),void 0===n&&(n=!1);for(var o=[this.pxmi(t.x),this.pxmi(t.y)],r=[],a=i.length;a--;)i[a]instanceof e.Physics.P2.Body&&(!n||i[a].data.type!==p2.Body.STATIC)?r.push(i[a].data):i[a]instanceof p2.Body&&i[a].parent&&(!n||i[a].type!==p2.Body.STATIC)?r.push(i[a]):i[a]instanceof e.Sprite&&i[a].hasOwnProperty("body")&&(!n||i[a].body.data.type!==p2.Body.STATIC)&&r.push(i[a].body.data);return this.world.hitTest(o,r,s)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(t){var i=Math.pow(2,this._collisionGroupID);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++;var s=new e.Physics.P2.CollisionGroup(i);return this.collisionGroups.push(s),t&&this.setCollisionGroup(t,s),s},setCollisionGroup:function(t,i){if(t instanceof e.Group)for(var s=0;s<t.total;s++)t.children[s].body&&t.children[s].body.type===e.Physics.P2JS&&t.children[s].body.setCollisionGroup(i);else t.body.setCollisionGroup(i)},createSpring:function(t,i,s,n,o,r,a,h,l){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.Spring(this,t,i,s,n,o,r,a,h,l));console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(t,i,s,n,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.RotationalSpring(this,t,i,s,n,o));console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(t,i,s,n,o,r){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(r&&!a.addPolygon(o,r))&&(n&&this.world.addBody(a.data),a)},createParticle:function(t,i,s,n,o,r){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(r&&!a.addPolygon(o,r))&&(n&&this.world.addBody(a.data),a)},convertCollisionObjects:function(t,e,i){void 0===i&&(i=!0);for(var s=[],n=0,o=t.collision[e].length;n<o;n++){var r=t.collision[e][n],a=r.polyline||r.polygon;if(a)var h=this.createBody(r.x,r.y,0,i,{},a);else r.rectangle&&(h=this.createBody(r.x,r.y,0,i)).addRectangle(r.width,r.height,r.width/2,r.height/2);h&&s.push(h)}return s},clearTilemapLayerBodies:function(t,e){e=t.getLayer(e);for(var i=t.layers[e].bodies.length;i--;)t.layers[e].bodies[i].destroy();t.layers[e].bodies.length=0},convertTilemap:function(t,e,i,s){e=t.getLayer(e),void 0===i&&(i=!0),void 0===s&&(s=!0),this.clearTilemapLayerBodies(t,e);for(var n=0,o=0,r=0,a=0,h=t.layers[e].height;a<h;a++){n=0;for(var l=0,c=t.layers[e].width;l<c;l++){var u=t.layers[e].data[a][l];if(u&&u.index>-1&&u.collides)if(s){var d=t.getTileRight(e,l,a);0===n&&(o=u.x*u.width,r=u.y*u.height,n=u.width),d&&d.collides?n+=u.width:((p=this.createBody(o,r,0,!1)).addRectangle(n,u.height,n/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p),n=0)}else{var p=this.createBody(u.x*u.width,u.y*u.height,0,!1);p.addRectangle(u.width,u.height,u.width/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p)}}}return t.layers[e].bodies},mpx:function(t){return t*=20},pxm:function(t){return.05*t},mpxi:function(t){return t*=-20},pxmi:function(t){return-.05*t}},Object.defineProperty(e.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(t){this.world.defaultContactMaterial.friction=t}}),Object.defineProperty(e.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(t){this.world.defaultContactMaterial.restitution=t}}),Object.defineProperty(e.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(t){this.world.defaultContactMaterial=t}}),Object.defineProperty(e.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(t){this.world.applySpringForces=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(t){this.world.applyDamping=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(t){this.world.applyGravity=t}}),Object.defineProperty(e.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(t){this.world.solveConstraints=t}}),Object.defineProperty(e.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(e.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(t){this.world.emitImpactEvent=t}}),Object.defineProperty(e.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(t){this.world.sleepMode=t}}),Object.defineProperty(e.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),e.Physics.P2.FixtureList=function(t){Array.isArray(t)||(t=[t]),this.rawList=t,this.init(),this.parse(this.rawList)},e.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionGroup=t})},setMask:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionMask=t})},setSensor:function(t,e){this.getFixtures(e).forEach(function(e){e.sensor=t})},setMaterial:function(t,e){this.getFixtures(e).forEach(function(e){e.material=t})},getFixtures:function(t){var e=[];if(t){t instanceof Array||(t=[t]);var i=this;return t.forEach(function(t){i.namedFixtures[t]&&e.push(i.namedFixtures[t])}),this.flatten(e)}return this.allFixtures},getFixtureByKey:function(t){return this.namedFixtures[t]},getGroup:function(t){return this.groupedFixtures[t]},parse:function(){var t,e,i,s;i=this.rawList,s=[];for(t in i)e=i[t],isNaN(t-0)?this.namedFixtures[t]=this.flatten(e):(this.groupedFixtures[t]=this.groupedFixtures[t]||[],this.groupedFixtures[t]=this.groupedFixtures[t].concat(e)),s.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(t){var e,i;return e=[],i=arguments.callee,t.forEach(function(t){return Array.prototype.push.apply(e,Array.isArray(t)?i(t):[t])}),e}},e.Physics.P2.PointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.PointProxy.prototype.constructor=e.Physics.P2.PointProxy,Object.defineProperty(e.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(t){this.destination[0]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(t){this.destination[1]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=t}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=t}}),e.Physics.P2.InversePointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.InversePointProxy.prototype.constructor=e.Physics.P2.InversePointProxy,Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(t){this.destination[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(t){this.destination[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=-t}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=-t}}),e.Physics.P2.Body=function(t,i,s,n,o){i=i||null,s=s||0,n=n||0,void 0===o&&(o=1),this.game=t,this.world=t.physics.p2,this.sprite=i,this.type=e.Physics.P2JS,this.offset=new e.Point,this.data=new p2.Body({position:[this.world.pxmi(s),this.world.pxmi(n)],mass:o}),this.data.parent=this,this.velocity=new e.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new e.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new e.Point,this.onBeginContact=new e.Signal,this.onEndContact=new e.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))},e.Physics.P2.Body.prototype={createBodyCallback:function(t,e,i){var s=-1;t.id?s=t.id:t.body&&(s=t.body.id),s>-1&&(null===e?(delete this._bodyCallbacks[s],delete this._bodyCallbackContext[s]):(this._bodyCallbacks[s]=e,this._bodyCallbackContext[s]=i))},createGroupCallback:function(t,e,i){null===e?(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]):(this._groupCallbacks[t.mask]=e,this._groupCallbackContext[t.mask]=i)},getCollisionMask:function(){var t=0;this._collideWorldBounds&&(t=this.game.physics.p2.boundsCollisionGroup.mask);for(var e=0;e<this.collidesWith.length;e++)t|=this.collidesWith[e].mask;return t},updateCollisionMask:function(t){var e=this.getCollisionMask();if(void 0===t)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].collisionMask=e;else t.collisionMask=e},setCollisionGroup:function(t,e){var i=this.getCollisionMask();if(void 0===e)for(var s=this.data.shapes.length-1;s>=0;s--)this.data.shapes[s].collisionGroup=t.mask,this.data.shapes[s].collisionMask=i;else e.collisionGroup=t.mask,e.collisionMask=i},clearCollision:function(t,e,i){if(void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i)for(var s=this.data.shapes.length-1;s>=0;s--)t&&(this.data.shapes[s].collisionGroup=null),e&&(this.data.shapes[s].collisionMask=null);else t&&(i.collisionGroup=null),e&&(i.collisionMask=null);t&&(this.collidesWith.length=0)},removeCollisionGroup:function(t,e,i){void 0===e&&(e=!0);var s;if(Array.isArray(t))for(o=0;o<t.length;o++)(s=this.collidesWith.indexOf(t[o]))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));else(s=this.collidesWith.indexOf(t))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));var n=this.getCollisionMask();if(void 0===i)for(var o=this.data.shapes.length-1;o>=0;o--)this.data.shapes[o].collisionMask=n;else i.collisionMask=n},collides:function(t,e,i,s){if(Array.isArray(t))for(o=0;o<t.length;o++)-1===this.collidesWith.indexOf(t[o])&&(this.collidesWith.push(t[o]),e&&this.createGroupCallback(t[o],e,i));else-1===this.collidesWith.indexOf(t)&&(this.collidesWith.push(t),e&&this.createGroupCallback(t,e,i));var n=this.getCollisionMask();if(void 0===s)for(var o=this.data.shapes.length-1;o>=0;o--)this.data.shapes[o].collisionMask=n;else s.collisionMask=n},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(t,e){return this.data.getVelocityAtPoint(t,e)},applyDamping:function(t){this.data.applyDamping(t)},applyImpulse:function(t,e,i){this.data.applyImpulse(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyImpulseLocal:function(t,e,i){this.data.applyImpulseLocal(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyForce:function(t,e,i){this.data.applyForce(t,[this.world.pxmi(e),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(t,e){return this.data.toLocalFrame(t,e)},toWorldFrame:function(t,e){return this.data.toWorldFrame(t,e)},rotateLeft:function(t){this.data.angularVelocity=this.world.pxm(-t)},rotateRight:function(t){this.data.angularVelocity=this.world.pxm(t)},moveForward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=e*Math.cos(i),this.data.velocity[1]=e*Math.sin(i)},moveBackward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=-e*Math.cos(i),this.data.velocity[1]=-e*Math.sin(i)},thrust:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustLeft:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustRight:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},reverse:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},moveLeft:function(t){this.data.velocity[0]=this.world.pxmi(-t)},moveRight:function(t){this.data.velocity[0]=this.world.pxmi(t)},moveUp:function(t){this.data.velocity[1]=this.world.pxmi(-t)},moveDown:function(t){this.data.velocity[1]=this.world.pxmi(t)},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(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),i&&this.setZeroDamping(),s&&(this.mass=1),this.x=t,this.y=e},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var t=0;t<this.game.physics.p2._toRemove.length;t++)this.game.physics.p2._toRemove[t]===this&&this.game.physics.p2._toRemove.splice(t,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 t=this.data.shapes.length;t--;)this.data.removeShape(this.data.shapes[t]);this.shapeChanged()},addShape:function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.data.addShape(t,[this.world.pxmi(e),this.world.pxmi(i)],s),this.shapeChanged(),t},addCircle:function(t,e,i,s){var n=new p2.Circle({radius:this.world.pxm(t)});return this.addShape(n,e,i,s)},addRectangle:function(t,e,i,s,n){var o=new p2.Box({width:this.world.pxm(t),height:this.world.pxm(e)});return this.addShape(o,i,s,n)},addPlane:function(t,e,i){var s=new p2.Plane;return this.addShape(s,t,e,i)},addParticle:function(t,e,i){var s=new p2.Particle;return this.addShape(s,t,e,i)},addLine:function(t,e,i,s){var n=new p2.Line({length:this.world.pxm(t)});return this.addShape(n,e,i,s)},addCapsule:function(t,e,i,s,n){var o=new p2.Capsule({length:this.world.pxm(t),radius:this.world.pxm(e)});return this.addShape(o,i,s,n)},addPolygon:function(t,e){t=t||{},Array.isArray(e)||(e=Array.prototype.slice.call(arguments,1));var i=[];if(1===e.length&&Array.isArray(e[0]))i=e[0].slice(0);else if(Array.isArray(e[0]))i=e.slice();else if("number"==typeof e[0])for(var s=0,n=e.length;s<n;s+=2)i.push([e[s],e[s+1]]);var o=i.length-1;i[o][0]===i[0][0]&&i[o][1]===i[0][1]&&i.pop();for(var r=0;r<i.length;r++)i[r][0]=this.world.pxmi(i[r][0]),i[r][1]=this.world.pxmi(i[r][1]);var a=this.data.fromPolygon(i,t);return this.shapeChanged(),a},removeShape:function(t){var e=this.data.removeShape(t);return this.shapeChanged(),e},setCircle:function(t,e,i,s){return this.clearShapes(),this.addCircle(t,e,i,s)},setRectangle:function(t,e,i,s,n){return void 0===t&&(t=16),void 0===e&&(e=16),this.clearShapes(),this.addRectangle(t,e,i,s,n)},setRectangleFromSprite:function(t){return void 0===t&&(t=this.sprite),this.clearShapes(),this.addRectangle(t.width,t.height,0,0,t.rotation)},setMaterial:function(t,e){if(void 0===e)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].material=t;else e.material=t},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(t,e){for(var i=this.game.cache.getPhysicsData(t,e),s=[],n=0;n<i.length;n++){var o=i[n],r=this.addFixture(o);s[o.filter.group]=s[o.filter.group]||[],s[o.filter.group]=s[o.filter.group].concat(r),o.fixtureKey&&(s[o.fixtureKey]=r)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),s},addFixture:function(t){var e=[];if(t.circle){(l=new p2.Circle({radius:this.world.pxm(t.circle.radius)})).collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor;var i=p2.vec2.create();i[0]=this.world.pxmi(t.circle.position[0]-this.sprite.width/2),i[1]=this.world.pxmi(t.circle.position[1]-this.sprite.height/2),this.data.addShape(l,i),e.push(l)}else for(var s=t.polygons,n=p2.vec2.create(),o=0;o<s.length;o++){for(var r=s[o],a=[],h=0;h<r.length;h+=2)a.push([this.world.pxmi(r[h]),this.world.pxmi(r[h+1])]);for(var l=new p2.Convex({vertices:a}),c=0;c!==l.vertices.length;c++){var u=l.vertices[c];p2.vec2.sub(u,u,l.centerOfMass)}p2.vec2.scale(n,l.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),l.updateTriangles(),l.updateCenterOfMass(),l.updateBoundingRadius(),l.collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor,this.data.addShape(l,n),e.push(l)}return e},loadPolygon:function(t,e,i){if(null===t)s=e;else var s=this.game.cache.getPhysicsData(t,e);"number"!=typeof i&&(i=1);for(var n=p2.vec2.create(),o=0;o<s.length;o++){for(var r=[],a=0;a<s[o].shape.length;a+=2)r.push([this.world.pxmi(s[o].shape[a]*i),this.world.pxmi(s[o].shape[a+1]*i)]);for(var h=new p2.Convex({vertices:r}),l=0;l!==h.vertices.length;l++){var c=h.vertices[l];p2.vec2.sub(c,c,h.centerOfMass)}p2.vec2.scale(n,h.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),h.updateTriangles(),h.updateCenterOfMass(),h.updateBoundingRadius(),this.data.addShape(h,n)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},e.Physics.P2.Body.prototype.constructor=e.Physics.P2.Body,e.Physics.P2.Body.DYNAMIC=1,e.Physics.P2.Body.STATIC=2,e.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(e.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===e.Physics.P2.Body.STATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.STATIC?(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0):t||this.data.type!==e.Physics.P2.Body.STATIC||(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===e.Physics.P2.Body.DYNAMIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.DYNAMIC?(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1):t||this.data.type!==e.Physics.P2.Body.DYNAMIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===e.Physics.P2.Body.KINEMATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.KINEMATIC?(this.data.type=e.Physics.P2.Body.KINEMATIC,this.mass=4):t||this.data.type!==e.Physics.P2.Body.KINEMATIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(t){t!==this.data.allowSleep&&(this.data.allowSleep=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.data.angle))},set:function(t){this.data.angle=e.Math.degToRad(e.Math.wrapAngle(t))}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(t){this.data.angularDamping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(t){this.data.angularForce=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(t){this.data.angularVelocity=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(t){this.data.damping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(t){t!==this.data.fixedRotation&&(this.data.fixedRotation=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(t){this.data.inertia=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(t){t!==this.data.mass&&(this.data.mass=t,this.data.updateMassProperties())}}),Object.defineProperty(e.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(t){t!==this.data.type&&(this.data.type=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(t){this.data.angle=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(t){this.data.sleepSpeedLimit=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(t){this.data.position[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(t){this.data.position[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(e.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(t){t&&!this.debugBody?this.debugBody=new e.Physics.P2.BodyDebug(this.game,this.data):!t&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(t){t&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!t&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),e.Physics.P2.BodyDebug=function(t,i,s){e.Group.call(this,t);var n={pixelsPerLengthUnit:t.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=Object.assign(n,s),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=i,this.canvas=new e.Graphics(t),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},e.Physics.P2.BodyDebug.prototype=Object.create(e.Group.prototype),e.Physics.P2.BodyDebug.prototype.constructor=e.Physics.P2.BodyDebug,Object.assign(e.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 t,e,i,s,n,o,r,a,h,l,c,u,d,p;if(r=this.body,(h=this.canvas).clear(),i=parseInt(this.randomPastelHex(),16),16711680,o=this.lineWidth,r instanceof p2.Body&&r.shapes.length){var f=r.shapes.length;for(s=0;s!==f;){if(e=r.shapes[s],a=e.position||0,t=e.angle||0,e instanceof p2.Circle)this.drawCircle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.radius*this.ppu,i,o);else if(e instanceof p2.Capsule)this.drawCapsule(h,a[0]*this.ppu,a[1]*this.ppu,t,e.length*this.ppu,e.radius*this.ppu,16711680,i,o);else if(e instanceof p2.Plane)this.drawPlane(h,a[0]*this.ppu,-a[1]*this.ppu,i,16711680,5*o,10*o,10*o,100*this.ppu,t);else if(e instanceof p2.Line)this.drawLine(h,e.length*this.ppu,16711680,o);else if(e instanceof p2.Box)this.drawRectangle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.width*this.ppu,e.height*this.ppu,16711680,i,o);else if(e instanceof p2.Convex){for(c=[],u=p2.vec2.create(),n=d=0,p=e.vertices.length;p>=0?d<p:d>p;n=p>=0?++d:--d)l=e.vertices[n],p2.vec2.rotate(u,l,t),c.push([(u[0]+a[0])*this.ppu,-(u[1]+a[1])*this.ppu]);this.drawConvex(h,c,e.triangles,16711680,i,o,this.settings.debugPolygons,[a[0]*this.ppu,-a[1]*this.ppu])}s++}}},drawRectangle:function(t,e,i,s,n,o,r,a,h){void 0===h&&(h=1),void 0===r&&(r=0),t.lineStyle(h,r,1),t.beginFill(a),t.drawRect(e-n/2,i-o/2,n,o)},drawCircle:function(t,e,i,s,n,o,r){void 0===r&&(r=1),void 0===o&&(o=16777215),t.lineStyle(r,0,1),t.beginFill(o,1),t.drawCircle(e,i,2*-n),t.endFill(),t.moveTo(e,i),t.lineTo(e+n*Math.cos(-s),i+n*Math.sin(-s))},drawLine:function(t,e,i,s){void 0===s&&(s=1),void 0===i&&(i=0),t.lineStyle(5*s,i,1),t.moveTo(-e/2,0),t.lineTo(e/2,0)},drawConvex:function(t,e,i,s,n,o,r,a){var h,l,c,u,d,p,f,g,m,y,v;if(void 0===o&&(o=1),void 0===s&&(s=0),r){for(h=[16711680,65280,255],l=0;l!==e.length+1;)u=e[l%e.length],d=e[(l+1)%e.length],f=u[0],y=u[1],g=d[0],v=d[1],t.lineStyle(o,h[l%h.length],1),t.moveTo(f,-y),t.lineTo(g,-v),t.drawCircle(f,-y,2*o),l++;return t.lineStyle(o,0,1),t.drawCircle(a[0],a[1],2*o)}for(t.lineStyle(o,s,1),t.beginFill(n),l=0;l!==e.length;)p=(c=e[l])[0],m=c[1],0===l?t.moveTo(p,-m):t.lineTo(p,-m),l++;if(t.endFill(),e.length>2)return t.moveTo(e[e.length-1][0],-e[e.length-1][1]),t.lineTo(e[0][0],-e[0][1])},drawPath:function(t,e,i,s,n){var o,r,a,h,l,c,u,d,p,f,g;for(void 0===n&&(n=1),void 0===i&&(i=0),t.lineStyle(n,i,1),"number"==typeof s&&t.beginFill(s),r=null,a=null,o=0;o<e.length;)f=(p=e[o])[0],g=p[1],f===r&&g===a||(0===o?t.moveTo(f,g):(h=r,l=a,c=f,u=g,d=e[(o+1)%e.length][0],0!==(c-h)*(e[(o+1)%e.length][1]-l)-(d-h)*(u-l)&&t.lineTo(f,g)),r=f,a=g),o++;"number"==typeof s&&t.endFill(),e.length>2&&"number"==typeof s&&(t.moveTo(e[e.length-1][0],e[e.length-1][1]),t.lineTo(e[0][0],e[0][1]))},drawPlane:function(t,e,i,s,n,o,r,a,h,l){var c,u;void 0===o&&(o=1),void 0===s&&(s=16777215),t.lineStyle(o,n,11),t.beginFill(s),t.moveTo(e,-i),c=e+Math.cos(l)*this.game.width,u=i+Math.sin(l)*this.game.height,t.lineTo(c,-u),t.moveTo(e,-i),c=e+Math.cos(l)*-this.game.width,u=i+Math.sin(l)*-this.game.height,t.lineTo(c,-u)},drawCapsule:function(t,e,i,s,n,o,r,a,h){void 0===h&&(h=1),void 0===r&&(r=0),t.lineStyle(h,r,1);var l=Math.cos(s),c=Math.sin(s);t.beginFill(a,1),t.drawCircle(-n/2*l+e,-n/2*c+i,2*-o),t.drawCircle(n/2*l+e,n/2*c+i,2*-o),t.endFill(),t.lineStyle(h,r,0),t.beginFill(a,1),t.moveTo(-n/2*l+o*c+e,-n/2*c+o*l+i),t.lineTo(n/2*l+o*c+e,n/2*c+o*l+i),t.lineTo(n/2*l-o*c+e,n/2*c-o*l+i),t.lineTo(-n/2*l-o*c+e,-n/2*c-o*l+i),t.endFill(),t.lineStyle(h,r,1),t.moveTo(-n/2*l+o*c+e,-n/2*c+o*l+i),t.lineTo(n/2*l+o*c+e,n/2*c+o*l+i),t.moveTo(-n/2*l-o*c+e,-n/2*c-o*l+i),t.lineTo(n/2*l-o*c+e,n/2*c-o*l+i)},randomPastelHex:function(){var t,e,i,s;return i=[255,255,255],s=Math.floor(256*Math.random()),e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),s=Math.floor((s+3*i[0])/4),e=Math.floor((e+3*i[1])/4),t=Math.floor((t+3*i[2])/4),this.rgbToHex(s,e,t)},rgbToHex:function(t,e,i){return this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},componentToHex:function(t){var e;return 2===(e=t.toString(16)).length?e:e+"0"}}),e.Physics.P2.Spring=function(t,e,i,s,n,o,r,a,h,l){this.game=t.game,this.world=t,void 0===s&&(s=1),void 0===n&&(n=100),void 0===o&&(o=1);var c={restLength:s=t.pxm(s),stiffness:n,damping:o};void 0!==r&&null!==r&&(c.worldAnchorA=[t.pxm(r[0]),t.pxm(r[1])]),void 0!==a&&null!==a&&(c.worldAnchorB=[t.pxm(a[0]),t.pxm(a[1])]),void 0!==h&&null!==h&&(c.localAnchorA=[t.pxm(h[0]),t.pxm(h[1])]),void 0!==l&&null!==l&&(c.localAnchorB=[t.pxm(l[0]),t.pxm(l[1])]),this.data=new p2.LinearSpring(e,i,c),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.RotationalSpring=function(t,e,i,s,n,o){this.game=t.game,this.world=t,void 0===s&&(s=null),void 0===n&&(n=100),void 0===o&&(o=1),s&&(s=t.pxm(s));var r={restAngle:s,stiffness:n,damping:o};this.data=new p2.RotationalSpring(e,i,r),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.Material=function(t){this.name=t,p2.Material.call(this)},e.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),e.Physics.P2.Material.prototype.constructor=e.Physics.P2.Material,e.Physics.P2.ContactMaterial=function(t,e,i){p2.ContactMaterial.call(this,t,e,i)},e.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),e.Physics.P2.ContactMaterial.prototype.constructor=e.Physics.P2.ContactMaterial,e.Physics.P2.CollisionGroup=function(t){this.mask=t},e.Physics.P2.DistanceConstraint=function(t,e,i,s,n,o,r){void 0===s&&(s=100),void 0===n&&(n=[0,0]),void 0===o&&(o=[0,0]),void 0===r&&(r=Number.MAX_VALUE),this.game=t.game,this.world=t;var a={distance:s=t.pxm(s),localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:o=[t.pxmi(o[0]),t.pxmi(o[1])],maxForce:r};p2.DistanceConstraint.call(this,e,i,a)},e.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),e.Physics.P2.DistanceConstraint.prototype.constructor=e.Physics.P2.DistanceConstraint,e.Physics.P2.GearConstraint=function(t,e,i,s,n){void 0===s&&(s=0),void 0===n&&(n=1),this.game=t.game,this.world=t;var o={angle:s,ratio:n};p2.GearConstraint.call(this,e,i,o)},e.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),e.Physics.P2.GearConstraint.prototype.constructor=e.Physics.P2.GearConstraint,e.Physics.P2.LockConstraint=function(t,e,i,s,n,o){void 0===s&&(s=[0,0]),void 0===n&&(n=0),void 0===o&&(o=Number.MAX_VALUE),this.game=t.game,this.world=t;var r={localOffsetB:s=[t.pxm(s[0]),t.pxm(s[1])],localAngleB:n,maxForce:o};p2.LockConstraint.call(this,e,i,r)},e.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),e.Physics.P2.LockConstraint.prototype.constructor=e.Physics.P2.LockConstraint,e.Physics.P2.PrismaticConstraint=function(t,e,i,s,n,o,r,a){void 0===s&&(s=!0),void 0===n&&(n=[0,0]),void 0===o&&(o=[0,0]),void 0===r&&(r=[0,0]),void 0===a&&(a=Number.MAX_VALUE),this.game=t.game,this.world=t;var h={localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:o=[t.pxmi(o[0]),t.pxmi(o[1])],localAxisA:r,maxForce:a,disableRotationalLock:!s};p2.PrismaticConstraint.call(this,e,i,h)},e.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),e.Physics.P2.PrismaticConstraint.prototype.constructor=e.Physics.P2.PrismaticConstraint,e.Physics.P2.RevoluteConstraint=function(t,e,i,s,n,o,r){void 0===o&&(o=Number.MAX_VALUE),void 0===r&&(r=null),this.game=t.game,this.world=t,i=[t.pxmi(i[0]),t.pxmi(i[1])],n=[t.pxmi(n[0]),t.pxmi(n[1])],r&&(r=[t.pxmi(r[0]),t.pxmi(r[1])]);var a={worldPivot:r,localPivotA:i,localPivotB:n,maxForce:o};p2.RevoluteConstraint.call(this,e,s,a)},e.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),e.Physics.P2.RevoluteConstraint.prototype.constructor=e.Physics.P2.RevoluteConstraint,e.ImageCollection=function(t,e,i,s,n,o,r){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===o&&(o=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|o,this.properties=r||{},this.images=[],this.total=0},e.ImageCollection.prototype={containsImageIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},addImage:function(t,e){this.images.push({gid:t,image:e}),this.total++}},e.ImageCollection.prototype.constructor=e.ImageCollection,e.Tile=function(t,e,i,s,n,o){this.layer=t,this.index=e,this.x=i,this.y=s,this.rotation=0,this.flipped=!1,this.worldX=i*n,this.worldY=s*o,this.width=n,this.height=o,this.centerX=Math.abs(n/2),this.centerY=Math.abs(o/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},e.Tile.prototype={containsPoint:function(t,e){return!(t<this.worldX||e<this.worldY||t>this.right||e>this.bottom)},intersects:function(t,e,i,s){return!(i<=this.worldX)&&(!(s<=this.worldY)&&(!(t>=this.worldX+this.width)&&!(e>=this.worldY+this.height)))},setCollisionCallback:function(t,e){this.collisionCallback=t,this.collisionCallbackContext=e},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(t,e,i,s){this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s},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(t,e){return t&&e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!e&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(t){this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext}},e.Tile.prototype.constructor=e.Tile,Object.defineProperty(e.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(e.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(e.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(e.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),e.Tilemap=function(t,i,s,n,o,r){this.game=t,this.key=i;var a=e.TilemapParser.parse(this.game,i,s,n,o,r);null!==a&&(this.width=a.width,this.height=a.height,this.tileWidth=a.tileWidth,this.tileHeight=a.tileHeight,this.orientation=a.orientation,this.format=a.format,this.version=a.version,this.properties=a.properties,this.widthInPixels=a.widthInPixels,this.heightInPixels=a.heightInPixels,this.layers=a.layers,this.tilesets=a.tilesets,this.imagecollections=a.imagecollections,this.tiles=a.tiles,this.objects=a.objects,this.collideIndexes=[],this.collision=a.collision,this.images=a.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.NORTH=0,e.Tilemap.EAST=1,e.Tilemap.SOUTH=2,e.Tilemap.WEST=3,e.Tilemap.prototype={create:function(t,e,i,s,n,o){return void 0===o&&(o=this.game.world),this.width=e,this.height=i,this.setTileSize(s,n),this.layers.length=0,this.createBlankLayer(t,e,i,s,n,o)},setTileSize:function(t,e){this.tileWidth=t,this.tileHeight=e,this.widthInPixels=this.width*t,this.heightInPixels=this.height*e},addTilesetImage:function(t,i,s,n,o,r,a){if(void 0===t)return null;void 0===s&&(s=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),0===s&&(s=32),0===n&&(n=32);var h=null;if(void 0!==i&&null!==i||(i=t),i instanceof e.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)}var l=this.getTilesetIndex(t);if(null===l&&this.format===e.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[l])return this.tilesets[l].setImage(h),this.tilesets[l];var c=new e.Tileset(t,a,s,n,o,r,{});c.setImage(h),this.tilesets.push(c);for(var u=this.tilesets.length-1,d=o,p=o,f=0,g=0,m=0,y=a;y<a+c.total&&(this.tiles[y]=[d,p,u],d+=s+r,++f!==c.total)&&(++g!==c.columns||(d=o,p+=n+r,g=0,++m!==c.rows));y++);return c},createFromObjects:function(t,i,s,n,o,r,a,h,l,c){if(void 0===o&&(o=!0),void 0===r&&(r=!1),void 0===a&&(a=this.game.world),void 0===h&&(h=e.Sprite),void 0===l&&(l=!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(var u=0;u<this.objects[t].length;u++){var d=!1,p=this.objects[t][u];if(void 0!==p.gid&&"number"==typeof i&&p.gid===i?d=!0:void 0!==p.id&&"number"==typeof i&&p.id===i?d=!0:void 0!==p.name&&"string"==typeof i&&p.name===i&&(d=!0),d){var f=new h(this.game,parseFloat(p.x),parseFloat(p.y),s,n);f.name=p.name,f.autoCull=r,f.exists=o,f.visible=p.visible,c&&(p.width&&(f.width=p.width),p.height&&(f.height=p.height)),p.rotation&&(f.angle=p.rotation),l&&(f.y-=f.height),a.add(f);for(var g in p.properties)a.set(f,g,p.properties[g],!1,!1,0,!0)}}},createFromTiles:function(t,i,s,n,o,r){"number"==typeof t&&(t=[t]),void 0===i||null===i?i=[]:"number"==typeof i&&(i=[i]),n=this.getLayer(n),void 0===o&&(o=this.game.world),void 0===r&&(r={}),void 0===r.customClass&&(r.customClass=e.Sprite),void 0===r.adjustY&&(r.adjustY=!0);var a=this.layers[n].width,h=this.layers[n].height;if(this.copy(0,0,a,h,n),this._results.length<2)return 0;for(var l,c=0,u=1,d=this._results.length;u<d;u++)if(-1!==t.indexOf(this._results[u].index)){l=new r.customClass(this.game,this._results[u].worldX,this._results[u].worldY,s);for(var p in r)l[p]=r[p];o.add(l),c++}if(1===i.length)for(u=0;u<t.length;u++)this.replace(t[u],i[0],0,0,a,h,n);else if(i.length>1)for(u=0;u<t.length;u++)this.replace(t[u],i[u],0,0,a,h,n);return c},createLayer:function(t,i,s,n){void 0===i&&(i=this.game.width),void 0===s&&(s=this.game.height),void 0===n&&(n=this.game.world);var o=t;if("string"==typeof t&&(o=this.getLayerIndex(t)),null===o||o>this.layers.length)return 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[o].widthInPixels):i>this.game.width&&(i=this.game.width),void 0===s||s<=0?s=Math.min(this.game.height,this.layers[o].heightInPixels):s>this.game.height&&(s=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[o].name),console.log("Size:",i,"x",s),console.log("Tileset:",this.tilesets[0].name,"index:",o));var r=n.add(new e.TilemapLayer(this.game,this,o,i,s));return this.enableDebug&&console.groupEnd(),r},createBlankLayer:function(t,i,s,n,o,r){void 0===r&&(r=this.game.world);{if(null===this.getLayerIndex(t)){for(var a,h={name:t,x:0,y:0,width:i,height:s,widthInPixels:i*n,heightInPixels:s*o,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},l=[],c=0;c<s;c++){a=[];for(var u=0;u<i;u++)a.push(new e.Tile(h,-1,u,c,n,o));l.push(a)}h.data=l,this.layers.push(h),this.currentLayer=this.layers.length-1;var d=h.widthInPixels,p=h.heightInPixels;return d>this.game.width&&(d=this.game.width),p>this.game.height&&(p=this.game.height),(l=new e.TilemapLayer(this.game,this,this.layers.length-1,d,p)).name=t,r.add(l)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)}},getIndex:function(t,e){for(var i=0;i<t.length;i++)if(t[i].name===e)return i;return null},getLayerIndex:function(t){return this.getIndex(this.layers,t)},getTilesetIndex:function(t){return this.getIndex(this.tilesets,t)},getImageIndex:function(t){return this.getIndex(this.images,t)},setTileIndexCallback:function(t,e,i,s){if(s=this.getLayer(s),"number"==typeof t)null===e?delete this.layers[s].callbacks[t]:this.layers[s].callbacks[t]={callback:e,callbackContext:i};else for(var n=0,o=t.length;n<o;n++)null===e?delete this.layers[s].callbacks[t[n]]:this.layers[s].callbacks[t[n]]={callback:e,callbackContext:i}},setTileLocationCallback:function(t,e,i,s,n,o,r){if(r=this.getLayer(r),this.copy(t,e,i,s,r),!(this._results.length<2))for(var a=1;a<this._results.length;a++)this._results[a].setCollisionCallback(n,o)},setCollision:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i),"number"==typeof t)return this.setCollisionByIndex(t,e,i,!0);if(Array.isArray(t)){for(var n=0;n<t.length;n++)this.setCollisionByIndex(t[n],e,i,!1);s&&this.calculateFaces(i)}},setCollisionBetween:function(t,e,i,s,n){if(void 0===i&&(i=!0),void 0===n&&(n=!0),s=this.getLayer(s),!(t>e)){for(var o=t;o<=e;o++)this.setCollisionByIndex(o,i,s,!1);n&&this.calculateFaces(s)}},setCollisionByExclusion:function(t,e,i,s){void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i);for(var n=0,o=this.tiles.length;n<o;n++)-1===t.indexOf(n)&&this.setCollisionByIndex(n,e,i,!1);s&&this.calculateFaces(i)},setCollisionByIndex:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===i&&(i=this.currentLayer),void 0===s&&(s=!0),e)this.collideIndexes.push(t);else{var n=this.collideIndexes.indexOf(t);n>-1&&this.collideIndexes.splice(n,1)}for(var o=0;o<this.layers[i].height;o++)for(var r=0;r<this.layers[i].width;r++){var a=this.layers[i].data[o][r];a&&a.index===t&&(e?a.setCollision(!0,!0,!0,!0):a.resetCollision(),a.faceTop=e,a.faceBottom=e,a.faceLeft=e,a.faceRight=e)}return s&&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 e.TilemapLayer&&(t=t.index);return t},setPreventRecalculate:function(t){if(!0===t&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===t&&!0===this.preventingRecalculate){this.preventingRecalculate=!1;for(var e in this.needToRecalculate)this.calculateFaces(e);this.needToRecalculate=!1}},calculateFaces:function(t){if(this.preventingRecalculate)this.needToRecalculate[t]=!0;else for(var e=null,i=null,s=null,n=null,o=0,r=this.layers[t].height;o<r;o++)for(var a=0,h=this.layers[t].width;a<h;a++){var l=this.layers[t].data[o][a];l&&(e=this.getTileAbove(t,a,o),i=this.getTileBelow(t,a,o),s=this.getTileLeft(t,a,o),n=this.getTileRight(t,a,o),l.collides&&(l.faceTop=!0,l.faceBottom=!0,l.faceLeft=!0,l.faceRight=!0),e&&e.collides&&(l.faceTop=!1),i&&i.collides&&(l.faceBottom=!1),s&&s.collides&&(l.faceLeft=!1),n&&n.collides&&(l.faceRight=!1))}},getTileAbove:function(t,e,i){return i>0?this.layers[t].data[i-1][e]:null},getTileBelow:function(t,e,i){return i<this.layers[t].height-1?this.layers[t].data[i+1][e]:null},getTileLeft:function(t,e,i){return e>0?this.layers[t].data[i][e-1]:null},getTileRight:function(t,e,i){return e<this.layers[t].width-1?this.layers[t].data[i][e+1]:null},setLayer:function(t){t=this.getLayer(t),this.layers[t]&&(this.currentLayer=t)},hasTile:function(t,e,i){return i=this.getLayer(i),void 0!==this.layers[i].data[e]&&void 0!==this.layers[i].data[e][t]&&this.layers[i].data[e][t].index>-1},removeTile:function(t,i,s){if(s=this.getLayer(s),t>=0&&t<this.layers[s].width&&i>=0&&i<this.layers[s].height&&this.hasTile(t,i,s)){var n=this.layers[s].data[i][t];return this.layers[s].data[i][t]=new e.Tile(this.layers[s],-1,t,i,this.tileWidth,this.tileHeight),this.layers[s].dirty=!0,this.calculateFaces(s),n}},removeTileWorldXY:function(t,e,i,s,n){return n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.removeTile(t,e,n)},putTile:function(t,i,s,n){if(null===t)return this.removeTile(i,s,n);if(n=this.getLayer(n),i>=0&&i<this.layers[n].width&&s>=0&&s<this.layers[n].height){var o;return t instanceof e.Tile?(o=t.index,this.hasTile(i,s,n)?this.layers[n].data[s][i].copy(t):this.layers[n].data[s][i]=new e.Tile(n,o,i,s,t.width,t.height)):(o=t,this.hasTile(i,s,n)?this.layers[n].data[s][i].index=o:this.layers[n].data[s][i]=new e.Tile(this.layers[n],o,i,s,this.tileWidth,this.tileHeight)),this.collideIndexes.indexOf(o)>-1?this.layers[n].data[s][i].setCollision(!0,!0,!0,!0):this.layers[n].data[s][i].resetCollision(),this.layers[n].dirty=!0,this.calculateFaces(n),this.layers[n].data[s][i]}return null},putTileWorldXY:function(t,e,i,s,n,o){return o=this.getLayer(o),e=this.game.math.snapToFloor(e,s)/s,i=this.game.math.snapToFloor(i,n)/n,this.putTile(t,e,i,o)},searchTileIndex:function(t,e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=!1),s=this.getLayer(s);var o,r,a=0,h=this.layers[s].height,l=this.layers[s].width,c=this.layers[s].data;if(n)var u=[];if(i)for(d=h-1;d>=0;d--){o=c[d];for(p=l-1;p>=0;p--)if((r=o[p]).index===t)if(a>=e){if(!n)return r;u.push(r)}else a++}else for(var d=0;d<h;d++){o=c[d];for(var p=0;p<l;p++)if((r=o[p]).index===t)if(a>=e){if(!n)return r;u.push(r)}else a++}return n?u:null},getTile:function(t,e,i,s){return void 0===s&&(s=!1),i=this.getLayer(i),t>=0&&t<this.layers[i].width&&e>=0&&e<this.layers[i].height?-1===this.layers[i].data[e][t].index?s?this.layers[i].data[e][t]:null:this.layers[i].data[e][t]:null},getTileWorldXY:function(t,e,i,s,n,o){return void 0===i&&(i=this.tileWidth),void 0===s&&(s=this.tileHeight),n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.getTile(t,e,n,o)},copy:function(t,e,i,s,n){n=this.getLayer(n);{if(this.layers[n]){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.layers[n].width),void 0===s&&(s=this.layers[n].height),t<0&&(t=0),e<0&&(e=0),i>this.layers[n].width&&(i=this.layers[n].width),s>this.layers[n].height&&(s=this.layers[n].height),this._results.length=0,this._results.push({x:t,y:e,width:i,height:s,layer:n});for(var o=e;o<e+s;o++)for(var r=t;r<t+i;r++)this._results.push(this.layers[n].data[o][r]);return this._results}this._results.length=0}},paste:function(t,e,i,s){if(void 0===t&&(t=0),void 0===e&&(e=0),s=this.getLayer(s),i&&!(i.length<2)){for(var n=t-i[1].x,o=e-i[1].y,r=1;r<i.length;r++)this.layers[s].data[o+i[r].y][n+i[r].x].copy(i[r]);this.layers[s].dirty=!0,this.calculateFaces(s)}},swap:function(t,e,i,s,n,o,r){r=this.getLayer(r),this.copy(i,s,n,o,r),this._results.length<2||(this._tempA=t,this._tempB=e,this._results.forEach(this.swapHandler,this),this.paste(i,s,this._results,r))},swapHandler:function(t){t.index===this._tempA?t.index=this._tempB:t.index===this._tempB&&(t.index=this._tempA)},forEach:function(t,e,i,s,n,o,r){r=this.getLayer(r),this.copy(i,s,n,o,r),this._results.length<2||(this._results.forEach(t,e),this.paste(i,s,this._results,r))},replace:function(t,e,i,s,n,o,r){if(r=this.getLayer(r),this.copy(i,s,n,o,r),!(this._results.length<2)){for(var a=1;a<this._results.length;a++)this._results[a].index===t&&(this._results[a].index=e);this.paste(i,s,this._results,r)}},random:function(t,e,i,s,n){if(n=this.getLayer(n),this.copy(t,e,i,s,n),!(this._results.length<2)){for(var o=[],r=1;r<this._results.length;r++)if(this._results[r].index){var a=this._results[r].index;-1===o.indexOf(a)&&o.push(a)}for(var h=1;h<this._results.length;h++)this._results[h].index=this.game.rnd.pick(o);this.paste(t,e,this._results,n)}},shuffle:function(t,i,s,n,o){if(o=this.getLayer(o),this.copy(t,i,s,n,o),!(this._results.length<2)){for(var r=[],a=1;a<this._results.length;a++)this._results[a].index&&r.push(this._results[a].index);e.ArrayUtils.shuffle(r);for(var h=1;h<this._results.length;h++)this._results[h].index=r[h-1];this.paste(t,i,this._results,o)}},fill:function(t,e,i,s,n,o){if(o=this.getLayer(o),this.copy(e,i,s,n,o),!(this._results.length<2)){for(var r=1;r<this._results.length;r++)this._results[r].index=t;this.paste(e,i,this._results,o)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var t="",e=[""],i=0;i<this.layers[this.currentLayer].height;i++){for(var s=0;s<this.layers[this.currentLayer].width;s++)t+="%c  ",this.layers[this.currentLayer].data[i][s]>1?this.debugMap[this.layers[this.currentLayer].data[i][s]]?e.push("background: "+this.debugMap[this.layers[this.currentLayer].data[i][s]]):e.push("background: #ffffff"):e.push("background: rgb(0, 0, 0)");t+="\n"}e[0]=t,console.log.apply(console,e)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},e.Tilemap.prototype.constructor=e.Tilemap,Object.defineProperty(e.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(t){t!==this.currentLayer&&this.setLayer(t)}}),e.TilemapLayer=function(t,i,s,n,o){n|=0,o|=0,e.Sprite.call(this,t,0,0),this.map=i,this.index=s,this.layer=i.layers[s],this.canvas=e.CanvasPool.create(this,n,o),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution))),this.type=e.TILEMAPLAYER,this.physicsType=e.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 e.Point(this.layer.offsetX||0,this.layer.offsetY||0),this._results=[],t.device.canvasBitBltShift||(this.renderSettings.copyCanvas=e.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TilemapLayer.sharedCopyCanvas=null,e.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=e.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},e.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},e.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},e.TilemapLayer.prototype._renderCanvas=function(t){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,t)},e.TilemapLayer.prototype._renderWebGL=function(t){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,t)},e.TilemapLayer.prototype.destroy=function(){e.CanvasPool.remove(this),e.Component.Destroy.prototype.destroy.call(this)},e.TilemapLayer.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e,this.texture.frame.resize(t,e),this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.texture.baseTexture.width=t,this.texture.baseTexture.height=e,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},e.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},e.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},e.TilemapLayer.prototype._fixX=function(t){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?t:0===this.scrollFactorX&&0!==this.position.x?t-this.position.x:this._scrollX+(t-this._scrollX/this.scrollFactorX)},e.TilemapLayer.prototype._unfixX=function(t){return 1===this.scrollFactorX?t:this._scrollX/this.scrollFactorX+(t-this._scrollX)},e.TilemapLayer.prototype._fixY=function(t){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?t:0===this.scrollFactorY&&0!==this.position.y?t-this.position.y:this._scrollY+(t-this._scrollY/this.scrollFactorY)},e.TilemapLayer.prototype._unfixY=function(t){return 1===this.scrollFactorY?t:this._scrollY/this.scrollFactorY+(t-this._scrollY)},e.TilemapLayer.prototype.getTileX=function(t){return Math.floor(this._fixX(t)/this._mc.tileWidth)},e.TilemapLayer.prototype.getTileY=function(t){return Math.floor(this._fixY(t)/this._mc.tileHeight)},e.TilemapLayer.prototype.getTileXY=function(t,e,i){return i.x=this.getTileX(t),i.y=this.getTileY(e),i},e.TilemapLayer.prototype.getRayCastTiles=function(t,e,i,s){e||(e=this.rayStepRate),void 0===i&&(i=!1),void 0===s&&(s=!1);var n=this.getTiles(t.x,t.y,t.width,t.height,i,s);if(0===n.length)return[];for(var o=t.coordinatesOnLine(e),r=[],a=0;a<n.length;a++)for(var h=0;h<o.length;h++){var l=n[a],c=o[h];if(l.containsPoint(c[0],c[1])){r.push(l);break}}return r},e.TilemapLayer.prototype.getTiles=function(t,e,i,s,n,o){void 0===n&&(n=!1),void 0===o&&(o=!1);var r=!(n||o);t=this._fixX(t),e=this._fixY(e);for(var a=Math.floor(t/(this._mc.cw*this.scale.x)),h=Math.floor(e/(this._mc.ch*this.scale.y)),l=Math.ceil((t+i)/(this._mc.cw*this.scale.x))-a,c=Math.ceil((e+s)/(this._mc.ch*this.scale.y))-h;this._results.length;)this._results.pop();for(var u=h;u<h+c;u++)for(var d=a;d<a+l;d++){var p=this.layer.data[u];p&&p[d]&&(r||p[d].isInteresting(n,o))&&this._results.push(p[d])}return this._results.slice()},e.TilemapLayer.prototype.resolveTileset=function(t){var e=this._mc.tilesets;if(t<2e3)for(;e.length<t;)e.push(void 0);var i=this.map.tiles[t]&&this.map.tiles[t][2];if(null!==i){var s=this.map.tilesets[i];if(s&&s.containsTileIndex(t))return e[t]=s}return e[t]=null},e.TilemapLayer.prototype.resetTilesetCache=function(){for(var t=this._mc.tilesets;t.length;)t.pop()},e.TilemapLayer.prototype.setScale=function(t,e){t=t||1,e=e||t;for(var i=0;i<this.layer.data.length;i++)for(var s=this.layer.data[i],n=0;n<s.length;n++){var o=s[n];o.width=this.map.tileWidth*t,o.height=this.map.tileHeight*e,o.worldX=o.x*o.width,o.worldY=o.y*o.height}this.scale.setTo(t,e)},e.TilemapLayer.prototype.shiftCanvas=function(t,e,i){var s=t.canvas,n=s.width-Math.abs(e),o=s.height-Math.abs(i),r=0,a=0,h=e,l=i;e<0&&(r=-e,h=0),i<0&&(a=-i,l=0);var c=this.renderSettings.copyCanvas;if(c){(c.width<n||c.height<o)&&(c.width=n,c.height=o);var u=c.getContext("2d");u.clearRect(0,0,n,o),u.drawImage(s,r,a,n,o,0,0,n,o),t.clearRect(h,l,n,o),t.drawImage(c,0,0,n,o,h,l,n,o)}else t.save(),t.globalCompositeOperation="copy",t.drawImage(s,r,a,n,o,h,l,n,o),t.restore()},e.TilemapLayer.prototype.renderRegion=function(t,e,i,s,n,o){var r=this.context,a=this.layer.width,h=this.layer.height,l=this._mc.tileWidth,c=this._mc.tileHeight,u=this._mc.tilesets,d=NaN;this._wrap||(i<=n&&(i=Math.max(0,i),n=Math.min(a-1,n)),s<=o&&(s=Math.max(0,s),o=Math.min(h-1,o)));var p,f,g,m,y,v,x=i*l-t,b=(i+(1<<20)*a)%a;for(m=(s+(1<<20)*h)%h,v=o-s,f=s*c-e;v>=0;m++,v--,f+=c){m>=h&&(m-=h);var _=this.layer.data[m];for(g=b,y=n-i,p=x;y>=0;g++,y--,p+=l){g>=a&&(g-=a);var w=_[g];if(w&&!(w.index<0)){var T=w.index,P=u[T];void 0===P&&(P=this.resolveTileset(T)),w.alpha===d||this.debug||(r.globalAlpha=w.alpha,d=w.alpha),P?w.rotation||w.flipped?(r.save(),r.translate(p+w.centerX,f+w.centerY),r.rotate(w.rotation),w.flipped&&r.scale(-1,1),P.draw(r,-w.centerX,-w.centerY,T),r.restore()):P.draw(r,p,f,T):this.debugSettings.missingImageFill&&(r.fillStyle=this.debugSettings.missingImageFill,r.fillRect(p,f,l,c)),w.debug&&this.debugSettings.debuggedTileOverfill&&(r.fillStyle=this.debugSettings.debuggedTileOverfill,r.fillRect(p,f,l,c))}}}},e.TilemapLayer.prototype.renderDeltaScroll=function(t,e){var i=this._mc.scrollX,s=this._mc.scrollY,n=this.canvas.width,o=this.canvas.height,r=this._mc.tileWidth,a=this._mc.tileHeight,h=0,l=-r,c=0,u=-a;if(t<0?(h=n+t,l=n-1):t>0&&(l=t),e<0?(c=o+e,u=o-1):e>0&&(u=e),this.shiftCanvas(this.context,t,e),h=Math.floor((h+i)/r),l=Math.floor((l+i)/r),c=Math.floor((c+s)/a),u=Math.floor((u+s)/a),h<=l){this.context.clearRect(h*r-i,0,(l-h+1)*r,o);var d=Math.floor((0+s)/a),p=Math.floor((o-1+s)/a);this.renderRegion(i,s,h,d,l,p)}if(c<=u){this.context.clearRect(0,c*a-s,n,(u-c+1)*a);var f=Math.floor((0+i)/r),g=Math.floor((n-1+i)/r);this.renderRegion(i,s,f,c,g,u)}},e.TilemapLayer.prototype.renderFull=function(){var t=this._mc.scrollX,e=this._mc.scrollY,i=this.canvas.width,s=this.canvas.height,n=this._mc.tileWidth,o=this._mc.tileHeight,r=Math.floor(t/n),a=Math.floor((i-1+t)/n),h=Math.floor(e/o),l=Math.floor((s-1+e)/o);this.context.clearRect(0,0,i,s),this.renderRegion(t,e,r,h,a,l)},e.TilemapLayer.prototype.render=function(){var t=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,t=!0);var e=this.canvas.width,i=this.canvas.height,s=0|this._scrollX,n=0|this._scrollY,o=this._mc,r=o.scrollX-s,a=o.scrollY-n;if(t||0!==r||0!==a||o.renderWidth!==e||o.renderHeight!==i)return this.context.save(),o.scrollX=s,o.scrollY=n,o.renderWidth===e&&o.renderHeight===i||(o.renderWidth=e,o.renderHeight=i),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(t=!0)),!t&&this.renderSettings.enableScrollDelta&&Math.abs(r)+Math.abs(a)<Math.min(e,i)?this.renderDeltaScroll(r,a):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},e.TilemapLayer.prototype.renderDebug=function(){var t,e,i,s,n,o,r=this._mc.scrollX,a=this._mc.scrollY,h=this.context,l=this.canvas.width,c=this.canvas.height,u=this.layer.width,d=this.layer.height,p=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(r/p),m=Math.floor((l-1+r)/p),y=Math.floor(a/f),v=Math.floor((c-1+a)/f),x=g*p-r,b=y*f-a,_=(g+(1<<20)*u)%u,w=(y+(1<<20)*d)%d;for(h.strokeStyle=this.debugSettings.facingEdgeStroke,s=w,o=v-y,e=b;o>=0;s++,o--,e+=f){s>=d&&(s-=d);var T=this.layer.data[s];for(i=_,n=m-g,t=x;n>=0;i++,n--,t+=p){i>=u&&(i-=u);var P=T[i];!P||P.index<0||!P.collides||(this.debugSettings.collidingTileOverfill&&(h.fillStyle=this.debugSettings.collidingTileOverfill,h.fillRect(t,e,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(h.beginPath(),P.faceTop&&(h.moveTo(t,e),h.lineTo(t+this._mc.cw,e)),P.faceBottom&&(h.moveTo(t,e+this._mc.ch),h.lineTo(t+this._mc.cw,e+this._mc.ch)),P.faceLeft&&(h.moveTo(t,e),h.lineTo(t,e+this._mc.ch)),P.faceRight&&(h.moveTo(t+this._mc.cw,e),h.lineTo(t+this._mc.cw,e+this._mc.ch)),h.closePath(),h.stroke()))}}},Object.defineProperty(e.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(t){this._wrap=t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(t){this._scrollX=t}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(t){this._scrollY=t}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(t){this._mc.cw=0|t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(t){this._mc.ch=0|t,this.dirty=!0}}),e.TilemapParser={INSERT_NULL:!1,parse:function(t,i,s,n,o,r){if(void 0===s&&(s=32),void 0===n&&(n=32),void 0===o&&(o=10),void 0===r&&(r=10),void 0===i)return this.getEmptyData();if(null===i)return this.getEmptyData(s,n,o,r);var a=t.cache.getTilemapData(i);if(a){if(a.format===e.Tilemap.CSV)return this.parseCSV(i,a.data,s,n);if(!a.format||a.format===e.Tilemap.TILED_JSON)return this.parseTiledJSON(a.data)}else console.warn('No map data found for key "%s"',i)},parseCSV:function(t,i,s,n){for(var o=this.getEmptyData(),r=[],a=(i=i.trim()).split("\n"),h=a.length,l=0,c=0;c<a.length;c++){r[c]=[];for(var u=a[c].split(","),d=0;d<u.length;d++)r[c][d]=new e.Tile(o.layers[0],parseInt(u[d],10),d,c,s,n);0===l&&(l=u.length)}return o.format=e.Tilemap.CSV,o.name=t,o.width=l,o.height=h,o.tileWidth=s,o.tileHeight=n,o.widthInPixels=l*s,o.heightInPixels=h*n,o.layers[0].width=l,o.layers[0].height=h,o.layers[0].widthInPixels=o.widthInPixels,o.layers[0].heightInPixels=o.heightInPixels,o.layers[0].data=r,o},getEmptyData:function(t,e,i,s){return{width:void 0!==i&&null!==i?i:0,height:void 0!==s&&null!==s?s:0,tileWidth:void 0!==t&&null!==t?t:0,tileHeight:void 0!==e&&null!==e?e: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(t,e){var i={};for(var s in e){var n=e[s];void 0!==t[n]&&(i[n]=t[n])}return i},parseObjectGroup:function(t,e,i,s,n){var s=s||t.name,n=n||{x:0,y:0},o=this._slice;s||console.warn("No name found for objectGroup",t),void 0!==n.x&&void 0!==n.y||console.warn("Malformed xy properties in relativePosition",n),e[s]=e[s]||[],i[s]=i[s]||[];for(var r=0,a=t.objects.length;r<a;r++){var h=t.objects[r];if(h.gid){l={gid:h.gid,name:h.name,type:h.type||"",x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),e[s].push(l)}else if(h.polyline){var l={name:h.name,type:h.type,x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),l.polyline=[];for(c=0;c<h.polyline.length;c++)l.polyline.push([h.polyline[c].x,h.polyline[c].y]);i[s].push(l),e[s].push(l)}else if(h.polygon){(l=o(h,["name","type","x","y","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.polygon=[];for(var c=0;c<h.polygon.length;c++)l.polygon.push([h.polygon[c].x,h.polygon[c].y]);i[s].push(l),e[s].push(l)}else h.ellipse?((l=o(h,["name","type","ellipse","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,i[s].push(l),e[s].push(l)):((l=o(h,["name","type","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.rectangle=!0,i[s].push(l),e[s].push(l))}return{objectsCollection:e,collisionCollection:i}},parseTiledJSON:function(t){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 i={width:t.width,height:t.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,orientation:t.orientation,format:e.Tilemap.TILED_JSON,version:t.version,properties:t.properties,widthInPixels:t.width*t.tilewidth,heightInPixels:t.height*t.tileheight},s=[],n=0;n<t.layers.length;n++)if("tilelayer"===t.layers[n].type){var o=t.layers[n];if(!o.compression&&o.encoding&&"base64"===o.encoding){for(var r=window.atob(o.data),a=r.length,h=new Array(a),l=0;l<a;l+=4)h[l/4]=(r.charCodeAt(l)|r.charCodeAt(l+1)<<8|r.charCodeAt(l+2)<<16|r.charCodeAt(l+3)<<24)>>>0;o.data=h,delete o.encoding}else if(o.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',o.name);continue}D={name:o.name,x:o.x,y:o.y,width:o.width,height:o.height,widthInPixels:o.width*t.tilewidth,heightInPixels:o.height*t.tileheight,alpha:o.opacity,offsetX:o.offsetx,offsetY:o.offsety,visible:o.visible,properties:{},indexes:[],callbacks:[],bodies:[]};o.properties&&(D.properties=o.properties);for(var c,u,d,p=0,f=[],g=[],m=0,a=o.data.length;m<a;m++){if(c=0,u=!1,k=o.data[m],d=0,k>536870912)switch(k>2147483648&&(k-=2147483648,d+=4),k>1073741824&&(k-=1073741824,d+=2),k>536870912&&(k-=536870912,d+=1),d){case 5:c=Math.PI/2;break;case 6:c=Math.PI;break;case 3:c=3*Math.PI/2;break;case 4:c=0,u=!0;break;case 7:c=Math.PI/2,u=!0;break;case 2:c=Math.PI,u=!0;break;case 1:c=3*Math.PI/2,u=!0}k>0?((B=new e.Tile(D,k,p,g.length,t.tilewidth,t.tileheight)).rotation=c,B.flipped=u,0!==d&&(B.flippedVal=d),f.push(B)):e.TilemapParser.INSERT_NULL?f.push(null):f.push(new e.Tile(D,-1,p,g.length,t.tilewidth,t.tileheight)),++p===o.width&&(g.push(f),p=0,f=[])}D.data=g,s.push(D)}i.layers=s;for(var y=[],n=0;n<t.layers.length;n++)if("imagelayer"===t.layers[n].type){var v=t.layers[n],x={name:v.name,image:v.image,x:v.x,y:v.y,alpha:v.opacity,visible:v.visible,properties:{}};v.properties&&(x.properties=v.properties),y.push(x)}i.images=y;for(var b=[],_={},w=[],T=null,n=0;n<t.tilesets.length;n++){if((U=t.tilesets[n]).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",U.source);else if(U.image){var P=new e.Tileset(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);U.tileproperties&&(P.tileProperties=U.tileproperties),P.updateTileData(U.imagewidth,U.imageheight),b.push(P)}else{if(!U.tiles)throw new Error("Tileset "+U.name+" has no `image` or `tiles` property.");var C=new e.ImageCollection(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);for(var S in U.tiles){var x=U.tiles[S].image,k=U.firstgid+parseInt(S,10);C.addImage(k,x)}w.push(C)}for(var S in U.tiles)(O=U.tiles[S].objectgroup)&&(_[parseInt(S,10)+U.firstgid]=O);T&&(T.lastgid=U.firstgid-1),T=U}if(0===b.length&&0===w.length)throw new Error("This tilemap has no tilesets.");i.tilesets=b,i.imagecollections=w;for(var A={},M={},n=0;n<t.layers.length;n++)if("objectgroup"===t.layers[n].type){var O=t.layers[n];this.parseObjectGroup(O,A,M)}i.objects=A,i.collision=M,i.tiles=[];for(n=0;n<i.tilesets.length;n++)for(var p=(U=i.tilesets[n]).tileMargin,I=U.tileMargin,E=0,L=0,R=0,m=U.firstgid;m<U.firstgid+U.total&&(i.tiles[m]=[p,I,n],p+=U.tileWidth+U.tileSpacing,++E!==U.total)&&(++L!==U.columns||(p=U.tileMargin,I+=U.tileHeight+U.tileSpacing,L=0,++R!==U.rows));m++);for(var D,B,F,U,n=0;n<i.layers.length;n++){M[(D=i.layers[n]).name]=[],U=null;for(l=0;l<D.data.length;l++){f=D.data[l];for(var G=0;G<f.length;G++)null===(B=f[G])||B.index<0||(F=i.tiles[B.index][2],(U=i.tilesets[F]).tileProperties&&U.tileProperties[B.index-U.firstgid]&&(B.properties=e.Utils.mixin(U.tileProperties[B.index-U.firstgid],B.properties)),(O=_[B.index])&&this.parseObjectGroup(O,i.objects,i.collision,B.layer.name,{x:B.worldX+O.x,y:B.worldY+O.y}))}}return i}},e.Tileset=function(t,e,i,s,n,o,r){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===o&&(o=0),this.name=t,this.firstgid=0|e,this.tileWidth=0|i,this.tileHeight=0|s,this.tileMargin=0|n,this.tileSpacing=0|o,this.properties=r||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},e.Tileset.prototype={draw:function(t,e,i,s){var n=s-this.firstgid<<1;n>=0&&n+1<this.drawCoords.length&&t.drawImage(this.image,this.drawCoords[n],this.drawCoords[n+1],this.tileWidth,this.tileHeight,e,i,this.tileWidth,this.tileHeight)},containsTileIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},setImage:function(t){this.image=t,this.updateTileData(t.width,t.height)},setSpacing:function(t,e){this.tileMargin=0|t,this.tileSpacing=0|e,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(t,e){var i=(e-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),s=(t-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);i%1==0&&s%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,t,e,this.tileWidth,this.tileHeight,this.tileMargin,this.tileSpacing),i=Math.floor(i),s=Math.floor(s),(this.rows&&this.rows!==i||this.columns&&this.columns!==s)&&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,s,i,this.name,this.columns,this.rows),this.rows=i,this.columns=s,this.total=i*s,this.drawCoords.length=0;for(var n=this.tileMargin,o=this.tileMargin,r=0;r<this.rows;r++){for(var a=0;a<this.columns;a++)this.drawCoords.push(n),this.drawCoords.push(o),n+=this.tileWidth+this.tileSpacing;n=this.tileMargin,o+=this.tileHeight+this.tileSpacing}}},e.Tileset.prototype.constructor=e.Tileset,e.Particle=function(t,i,s,n,o){e.Sprite.call(this,t,i,s,n,o),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},e.Particle.prototype=Object.create(e.Sprite.prototype),e.Particle.prototype.constructor=e.Particle,e.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)},e.Particle.prototype.onEmit=function(){},e.Particle.prototype.setAlphaData=function(t){this.alphaData=t,this._a=t.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},e.Particle.prototype.setScaleData=function(t){this.scaleData=t,this._s=t.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},e.Particle.prototype.reset=function(t,i,s){return e.Component.Reset.prototype.reset.call(this,t,i,s),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},e.Particles=function(t){this.game=t,this.emitters={},this.ID=0},e.Particles.prototype={add:function(t){return this.emitters[t.id]=t,t},remove:function(t){delete this.emitters[t.id]}},e.Particles.prototype.constructor=e.Particles,e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(t,i,s,n){this.maxParticles=n||50,e.Group.call(this,t),this._id=this.game.particles.ID++,this.name="emitter"+this.id,this.type=e.EMITTER,this.physicsType=e.GROUP,this.area=new e.Rectangle(i,s,1,1),this.minAngle=null,this.maxAngle=null,this.minSpeed=0,this.maxSpeed=100,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.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=e.Particle,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this.on=!1,this.particleAnchor=new e.Point(.5,.5),this.blendMode=e.blendModes.NORMAL,this.emitX=i,this.emitY=s,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 e.Point(0,100),this._minParticleScale=new e.Point(1,1),this._maxParticleScale=new e.Point(1,1),this._total=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.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(t=0;t<this._flowQuantity;t++)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 t=this.children.length;t--;)this.children[t].exists&&this.children[t].update()},e.Particles.Arcade.Emitter.prototype.makeParticles=function(t,e,i,s,n,o){void 0===e&&(e=0),void 0===i&&(i=this.maxParticles),void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===o&&(o=null);var r,a=0,h=t,l=e;for(this._frames=e,i>this.maxParticles&&(this.maxParticles=i);a<i;)Array.isArray(t)&&(h=this.game.rnd.pick(t)),Array.isArray(e)&&(l=this.game.rnd.pick(e)),r=new this.particleClass(this.game,0,0,h,l,o),this.game.physics.arcade.enable(r,!1),r.body.checkCollision.none=!s,r.body.collideWorldBounds=n,r.body.skipQuadTree=!0,r.exists=!1,r.visible=!1,r.anchor.copyFrom(this.particleAnchor),this.add(r),a++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},e.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},e.Particles.Arcade.Emitter.prototype.explode=function(t,e){return void 0===e&&(e=this.maxParticles),this._flowTotal=0,this.start(!0,t,0,e,!1),this},e.Particles.Arcade.Emitter.prototype.flow=function(t,e,i,s,n){return void 0!==e&&null!==e||(e=250),void 0!==i&&0!==i||(i=1),void 0===s&&(s=-1),void 0===n&&(n=!0),i>this.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=s,n?(this.start(!0,t,e,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+e*this.game.time.slowMotion):this.start(!1,t,e,i),this},e.Particles.Arcade.Emitter.prototype.start=function(t,e,i,s,n){if(void 0===t&&(t=!0),void 0===e&&(e=0),void 0!==i&&null!==i||(i=250),void 0===s&&(s=0),void 0===n&&(n=!1),s>this.maxParticles&&(s=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=e,this.frequency=i,t||n)for(var o=0;o<s;o++)this.emitParticle();else this.on=!0,this._total=s,this._counter=0,this._timer=this.game.time.time+i*this.game.time.slowMotion;return this},e.Particles.Arcade.Emitter.prototype.emitParticle=function(t,e,i,s){void 0===t&&(t=null),void 0===e&&(e=null);var n=this.getNextParticle();if(null===n)return this.counts.failed++,this.counts.totalFailed++,!1;this.counts.emitted++,this.counts.totalEmitted++;var o=this.game.rnd;void 0!==i&&void 0!==s?n.loadTexture(i,s):void 0!==i&&(n.loadTexture(i),n.frame=Array.isArray(this._frames)?o.pick(this._frames):this._frames);var r=this.emitX,a=this.emitY;return null!==t?r=t:this.width>1&&(r=o.between(this.left,this.right)),null!==e?a=e:this.height>1&&(a=o.between(this.top,this.bottom)),this.resetParticle(n,r,a),!0},e.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var t=this.length;t--;){var e=this.next();if(!e.exists)return e}return null},e.Particles.Arcade.Emitter.prototype.resetParticle=function(t,e,i){var s=this.game.rnd;t.reset(e,i),t.angle=0,t.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(t):this.particleSendToBack&&this.sendToBack(t),this.autoScale?t.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?t.scale.set(s.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?t.scale.set(s.realInRange(this._minParticleScale.x,this._maxParticleScale.x),s.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):t.scale.set(this._minParticleScale.x,this._minParticleScale.y),this.autoAlpha?t.setAlphaData(this.alphaData):t.alpha=s.realInRange(this.minParticleAlpha,this.maxParticleAlpha),t.blendMode=this.blendMode;var n=t.body;n.updateBounds(),n.bounce.copyFrom(this.bounce),n.drag.copyFrom(this.particleDrag),null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:s.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:s.between(this.minSpeed,this.maxSpeed),n.velocity):(n.velocity.x=s.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),n.velocity.y=s.between(this.minParticleSpeed.y,this.maxParticleSpeed.y)),n.angularVelocity=s.between(this.minRotation,this.maxRotation),n.gravity.copyFrom(this.gravity),n.angularDrag=this.angularDrag,t.onEmit()},e.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),e.Group.prototype.destroy.call(this,!0,!1)},e.Particles.Arcade.Emitter.prototype.setSize=function(t,e){return this.area.width=t,this.area.height=e,this},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.x=t,this.maxParticleSpeed.x=e,this},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.y=t,this.maxParticleSpeed.y=e,this},e.Particles.Arcade.Emitter.prototype.setRotation=function(t,e){return t=t||0,e=e||0,this.minRotation=t,this.maxRotation=e,this},e.Particles.Arcade.Emitter.prototype.setAlpha=function(t,i,s,n,o){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=0),void 0===n&&(n=e.Easing.Linear.None),void 0===o&&(o=!1),this.minParticleAlpha=t,this.maxParticleAlpha=i,this.autoAlpha=!1,s>0&&t!==i){var r={v:t},a=this.game.make.tween(r).to({v:i},s,n);a.yoyo(o),this.alphaData=a.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},e.Particles.Arcade.Emitter.prototype.setScale=function(t,i,s,n,o,r,a){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=1),void 0===n&&(n=1),void 0===o&&(o=0),void 0===r&&(r=e.Easing.Linear.None),void 0===a&&(a=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(t,s),this._maxParticleScale.set(i,n),this.autoScale=!1,o>0&&(t!==i||s!==n)){var h={x:t,y:s},l=this.game.make.tween(h).to({x:i,y:n},o,r);l.yoyo(a),this.scaleData=l.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},e.Particles.Arcade.Emitter.prototype.setAngle=function(t,e,i,s){return this.minAngle=t,this.maxAngle=e,null!=i&&(this.minSpeed=i),null!=s&&(this.maxSpeed=s),this},e.Particles.Arcade.Emitter.prototype.at=function(t){return t.center?(this.emitX=t.center.x,this.emitY=t.center.y):(this.emitX=t.world.x+t.anchor.x*t.width,this.emitY=t.world.y+t.anchor.y*t.height),this},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(t){"number"==typeof t?this._gravity.y=t:this._gravity=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(t){this.area.width=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(t){this.area.height=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(t){this.emitX=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(t){this.emitY=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?1/0:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),e.Weapon=function(t,i){e.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 e.Rectangle(0,0,1,1),this.fireAngle=e.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 e.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=e.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=e.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new e.Rectangle,this.bulletBounds=t.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new e.Signal,this.onKill=new e.Signal,this.onFireLimit=new e.Signal,this.trackedSprite=null,this.trackedPointer=null,this.multiFire=!1,this._hasFired=!1,this.trackRotation=!1,this.trackOffset=new e.Point,this._nextFire=0,this._tempNextFire=0,this._rotatedPoint=new e.Point},e.Weapon.prototype=Object.create(e.Plugin.prototype),e.Weapon.prototype.constructor=e.Weapon,e.Weapon.KILL_NEVER=0,e.Weapon.KILL_LIFESPAN=1,e.Weapon.KILL_DISTANCE=2,e.Weapon.KILL_WEAPON_BOUNDS=3,e.Weapon.KILL_CAMERA_BOUNDS=4,e.Weapon.KILL_WORLD_BOUNDS=5,e.Weapon.KILL_STATIC_BOUNDS=6,e.Weapon.prototype.createBullets=function(t,i,s,n){return void 0===t&&(t=1),void 0===n&&(n=this.game.world),this.bullets&&!this.bullets.game&&(this.bullets=null),this.bullets||(this.bullets=this.game.add.physicsGroup(e.Physics.ARCADE,n),this.bullets.classType=this._bulletClass),0!==t&&(-1===t&&(this.autoExpandBulletsGroup=!0,t=1),this.bullets.createMultiple(t,i,s),this.bullets.setAll("data.bulletManager",this),this.bulletKey=i,this.bulletFrame=s),this},e.Weapon.prototype.forEach=function(t,e){return this.bullets.forEachExists(t,e,arguments),this},e.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},e.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.resetShots=function(t){return this.shots=0,void 0!==t&&(this.fireLimit=t),this},e.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},e.Weapon.prototype.update=function(){this._bulletKillType===e.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()},e.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},e.Weapon.prototype.trackSprite=function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=!1),this.trackedPointer=null,this.trackedSprite=t,this.trackRotation=s,this.trackOffset.set(e,i),this},e.Weapon.prototype.trackPointer=function(t,e,i){return void 0===t&&(t=this.game.input.activePointer),void 0===e&&(e=0),void 0===i&&(i=0),this.trackedPointer=t,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(e,i),this},e.Weapon.prototype.fireMany=function(t,e){this.multiFire=!0;var i=[],s=this;return e||this.trackedSprite||this.trackedPointer?t.forEach(function(t){i.push(s.fire(e,null,null,t.x,t.y))}):t.forEach(function(t){i.push(s.fire(t))}),i},e.Weapon.prototype.fireOffset=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fire(null,null,null,t,e)},e.Weapon.prototype.fire=function(t,i,s,n,o){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game.time.now<this._nextFire||this.fireLimit>0&&this.shots===this.fireLimit)return null;var r=this.bulletSpeed;0!==this.bulletSpeedVariance&&(r+=e.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&&(r+=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!==n&&(this.fireFrom.x+=n),void 0!==o&&(this.fireFrom.y+=o);var a=this.fireFrom.width>1?this.fireFrom.randomX:this.fireFrom.x,h=this.fireFrom.height>1?this.fireFrom.randomY:this.fireFrom.y,l=this.trackRotation?this.trackedSprite.angle:this.fireAngle;null!==i&&null!==s&&(l=this.game.math.radToDeg(Math.atan2(s-h,i-a))),0!==this.bulletAngleVariance&&(l+=e.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var c=0,u=0;0===l||180===l?c=Math.cos(this.game.math.degToRad(l))*r:90===l||270===l?u=Math.sin(this.game.math.degToRad(l))*r:(c=Math.cos(this.game.math.degToRad(l))*r,u=Math.sin(this.game.math.degToRad(l))*r);var d=null;if(this.autoExpandBulletsGroup?(d=this.bullets.getFirstExists(!1,!0,a,h,this.bulletKey,this.bulletFrame)).data.bulletManager=this:d=this.bullets.getFirstExists(!1),d){if(d.reset(a,h),d.data.fromX=a,d.data.fromY=h,d.data.killType=this.bulletKillType,d.data.killDistance=this.bulletKillDistance,d.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===e.Weapon.KILL_LIFESPAN&&(d.lifespan=this.bulletLifespan),d.angle=l+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===d.animations.getAnimation(this.bulletAnimation)){var p=this.anims[this.bulletAnimation];d.animations.add(p.name,p.frames,p.frameRate,p.loop,p.useNumericIndex)}d.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(d.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(d.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);d.data.bodyDirty&&(this._data.customBody&&d.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),d.body.collideWorldBounds=this.bulletCollideWorldBounds,d.data.bodyDirty=!1),d.body.velocity.set(c,u),d.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var f=0;if(0!==this.bulletSpeedVariance){var g=this.fireRate;(g+=e.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(g=0),f=this.game.time.now+g}else f=this.game.time.now+this.fireRate;this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=f,this.shots++):(this._nextFire=f,this.shots++),this.onFire.dispatch(d,this,r),this.fireLimit>0&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return d},e.Weapon.prototype.fireAtPointer=function(t){return void 0===t&&(t=this.game.input.activePointer),this.fire(null,t.worldX,t.worldY)},e.Weapon.prototype.fireAtSprite=function(t){return this.fire(null,t.world.x,t.world.y)},e.Weapon.prototype.fireAtXY=function(t,e){return this.fire(null,t,e)},e.Weapon.prototype.setBulletBodyOffset=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),this._data.customBody=!0,this._data.width=t,this._data.height=e,this._data.offsetX=i,this._data.offsetY=s,this.bullets.callAll("body.setSize","body",t,e,i,s),this.bullets.setAll("data.bodyDirty",!1),this},e.Weapon.prototype.setBulletFrames=function(t,i,s,n){return void 0===s&&(s=!0),void 0===n&&(n=!1),this.bulletFrames=e.ArrayUtils.numberArray(t,i),this.bulletFrameIndex=0,this.bulletFrameCycle=s,this.bulletFrameRandom=n,this},e.Weapon.prototype.addBulletAnimation=function(t,e,i,s,n){return this.anims[t]={name:t,frames:e,frameRate:i,loop:s,useNumericIndex:n},this.bullets.callAll("animations.add","animations",t,e,i,s,n),this.bulletAnimation=t,this},e.Weapon.prototype.debug=function(t,e,i){void 0===t&&(t=16),void 0===e&&(e=32),void 0===i&&(i=!1),this.game.debug.text("Weapon Plugin",t,e),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,t,e+24),i&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(e.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(t){this._bulletClass=t,this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(e.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(t){switch(t){case e.Weapon.KILL_STATIC_BOUNDS:case e.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case e.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case e.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=t}}),Object.defineProperty(e.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(t){this._bulletCollideWorldBounds=t,this.bullets.setAll("body.collideWorldBounds",t),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(e.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(t){this.fireFrom.x=t}}),Object.defineProperty(e.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(t){this.fireFrom.y=t}}),e.Bullet=function(t,i,s,n,o){e.Sprite.call(this,t,i,s,n,o),this.anchor.set(.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},e.Bullet.prototype=Object.create(e.Sprite.prototype),e.Bullet.prototype.constructor=e.Bullet,e.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},e.Bullet.prototype.update=function(){this.exists&&(this.data.killType>e.Weapon.KILL_LIFESPAN&&(this.data.killType===e.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))},e.Video=function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game=t,this.key=i,this.width=0,this.height=0,this.type=e.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new e.Signal,this.onChangeSource=new e.Signal,this.onComplete=new e.Signal,this.onAccess=new e.Signal,this.onError=new e.Signal,this.onTimeout=new e.Signal,this.onTouchUnlock=new e.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 n=this.game.cache.getVideo(i);n.isBlob?this.createVideoFromBlob(n.data):this.video=n.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else s&&this.createVideoFromURL(s,!1);this.video&&!s?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(e.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 e.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,e.BitmapData&&(this.snapshot=new e.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():n&&(n.locked=!1)},e.Video.prototype={connectToMediaStream:function(t,e){return t&&e&&(this.video=t,this.videoStream=e,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(t,e,i,s){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=!0),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;if(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!==e&&(this.video.width=e),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia({audio:t,video:s}).then(this.getUserMediaSuccess.bind(this)).catch(this.getUserMediaError.bind(this));else try{navigator.getUserMedia({audio:t,video:s},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(t){this.getUserMediaError(t)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(t){clearTimeout(this._timeOutID),this.onError.dispatch(this,t)},getUserMediaSuccess:function(t){clearTimeout(this._timeOutID),this.videoStream=t,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=t:void 0!==this.video.srcObject?this.video.srcObject=t:this.video.src=window.URL&&window.URL.createObjectURL(t)||t;var e=this;this.video.onloadeddata=function(){function t(){if(i>0)if(e.video.videoWidth>0){var s=e.video.videoWidth,n=e.video.videoHeight;isNaN(e.video.videoHeight)&&(n=s/(4/3)),e.video.play(),e.isStreaming=!0,e.baseTexture.source=e.video,e.updateTexture(null,s,n),e.onAccess.dispatch(e)}else window.setTimeout(t,500);else console.warn("Unable to connect to video stream. Webcam error?");i--}var i=10;t()}},createVideoFromBlob:function(t){var e=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(t){e.updateTexture(t)},!0),this.video.src=window.URL.createObjectURL(t),this.video.canplay=!0,this},createVideoFromURL:function(t,e,i){return void 0===e&&(e=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,e&&this.video.setAttribute("autoplay","autoplay"),void 0!==i&&(this.video.crossOrigin=i),this.video.setAttribute("playsinline","playsinline"),this.video.src=t,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=t,this},updateTexture:function(t,e,i){var s=!1;void 0!==e&&null!==e||(e=this.video.videoWidth,s=!0),void 0!==i&&null!==i||(i=this.video.videoHeight),this.width=e,this.height=i,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(e,i),this.texture.frame.resize(e,i),this.texture.width=e,this.texture.height=i,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(e,i),s&&null!==this.key&&(this.onChangeSource.dispatch(this,e,i),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(t,e){return this._pendingChangeSource?this:(void 0===t&&(t=!1),void 0===e&&(e=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=t?"loop":"",this.video.playbackRate=e,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,t,e)),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(t){t.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(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},addToWorld:function(t,e,i,s,n,o){n=n||1,o=o||1;var r=this.game.add.image(t,e,this);return r.anchor.set(i,s),r.scale.set(n,o),r},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(t,e){return void 0===e&&(e=!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=t,this.video.load(),this._autoplay=e,e||(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 t=this.game.cache.getVideo(this.key);t&&!t.isBlob&&(t.locked=!1)}return this.onTouchUnlock.dispatch(this),!0},grab:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=1),void 0===i&&(i=null),null!==this.snapshot)return t&&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,e,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(e.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(t){this.video.currentTime=t}}),Object.defineProperty(e.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.Video.prototype,"paused",{get:function(){return this._paused},set:function(t){if(t=t||null,!this.touchLocked)if(t){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(e.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(t){t<0?t=0:t>1&&(t=1),this.video&&(this.video.volume=t)}}),Object.defineProperty(e.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(t){this.video&&(this.video.playbackRate=t)}}),Object.defineProperty(e.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(t){t&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(e.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),e.Video.prototype.constructor=e.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=e.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=e.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new e.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return e.Device.canUseMultiply},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.Phaser=e):"undefined"!=typeof define&&define.amd?define("Phaser",t.Phaser=e):t.Phaser=e,e}).call(this);
//# sourceMappingURL=phaser-split.map