text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexgridsizer=e()}(this,function(){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function t(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=s(n);if(r){var i=s(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return o(this,t)}}function u(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}function p(t,e,i){return(p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=u(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(i):r.value}})(t,e,i||t)}function h(t,e,i,n){return(h="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,e,i,n){var r,s,o,h,a=u(t,e);if(a){if((r=Object.getOwnPropertyDescriptor(a,e)).set)return r.set.call(n,i),!0;if(!r.writable)return!1}if(r=Object.getOwnPropertyDescriptor(n,e)){if(!r.writable)return!1;r.value=i,Object.defineProperty(n,e,r)}else h=i,(o=e)in(s=n)?Object.defineProperty(s,o,{value:h,enumerable:!0,configurable:!0,writable:!0}):s[o]=h;return!0})(t,e,i,n)}function l(t,e,i,n,r){if(!h(t,e,i,n||t)&&r)throw new Error("failed to set property");return i}function a(t){return function(t){if(Array.isArray(t))return d(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return d(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return d(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var v=Phaser.GameObjects.Zone,y=Phaser.Utils.Array.Add,g=Phaser.Utils.Array.Remove,m=function(){e(h,v);var o=c(h);function h(t,e,i,n,r){var s;return f(this,h),void 0===n&&(n=1),void 0===r&&(r=1),(s=o.call(this,t,e,i,n,r)).children=[],s}return t(h,[{key:"destroy",value:function(t){this.scene&&(this.clear(!t),p(s(h.prototype),"destroy",this).call(this,t))}},{key:"contains",value:function(t){return-1!==this.children.indexOf(t)}},{key:"add",value:function(t){return y(this.children,t,0,function(t){t.on("destroy",this.remove,this)},this),this}},{key:"remove",value:function(t,e){return g(this.children,t,function(t){t.off("destroy",this.remove,this),e&&t.destroy()}),this}},{key:"clear",value:function(t){for(var e,i=0,n=this.children.length;i<n;i++)(e=this.children[i]).off("destroy",this.remove,this),t&&e.destroy();return this.children.length=0,this}}]),h}(),b=Phaser.GameObjects.Components;Phaser.Class.mixin(m,[b.Alpha,b.Flip]);function C(t){var e;return t.hasOwnProperty("rexContainer")&&(e=t.rexContainer.parent),e}function P(t){return this.setParent(t),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),w.call(this,t),this}function k(t,e){return t===e?1:t/e}function S(t){return"[object Array]"===Object.prototype.toString.call(t)}var O={setParent:function(t,e){void 0===e&&(e=this);var i=this.getLocalState(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent:function(t){return void 0===t&&(t=this),C(t)},getTopmostParent:function(t){return void 0===t&&(t=this),function(t){for(var e=C(t);e;)e=C(t=e);return t}(t)}},w=m.prototype.add,x={add:function(t){return Array.isArray(t)?this.addMultiple(t):P.call(this,t),this},addMultiple:function(t){for(var e=0,i=t.length;e<i;e++)P.call(this,t[e]);return this}},_=m.prototype.remove,E=m.prototype.clear,X={remove:function(t,e){return this.getParent(t)!==this||(this.setParent(t,null),_.call(this,t,e)),this},clear:function(t){for(var e=0,i=this.children.length;e<i;e++)this.setParent(this.children[e],null);return E.call(this,t),this}},Y=Phaser.Math.RotateAround,j={worldToLocal:function(t){return t.x-=this.x,t.y-=this.y,Y(t,0,0,-this.rotation),t.x/=this.scaleX,t.y/=this.scaleY,t.x*=this.flipX?-1:1,t.y*=this.flipY?-1:1,t},localToWorld:function(t){return t.x*=this.flipX?-1:1,t.y*=this.flipY?-1:1,t.x*=this.scaleX,t.y*=this.scaleY,Y(t,0,0,this.rotation),t.x+=this.x,t.y+=this.y,t}},z={updateChildPosition:function(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=this.getLocalState(t);return t.x=e.x,t.y=e.y,this.localToWorld(t),t.scaleX=e.scaleX*this.scaleX,t.scaleY=e.scaleY*this.scaleY,void 0!==t.flipX&&(t.flipX=this.flipX?!e.flipX:e.flipX,t.flipY=this.flipY?!e.flipY:e.flipY),t.rotation=e.rotation+this.rotation,t.isRexContainerLite&&(t.syncChildrenEnable=!0,t.syncPosition()),this},syncPosition:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState:function(t){var e=this.getLocalState(t);return e.x=t.x,e.y=t.y,this.worldToLocal(e),e.scaleX=k(t.scaleX,this.scaleX),e.scaleY=k(t.scaleY,this.scaleY),void 0!==t.flipX&&(e.flipX=t.flipX,e.flipY=t.flipY),e.rotation=t.rotation-this.rotation,this},setChildPosition:function(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition:function(t,e,i){var n=this.getLocalState(t);return n.x=e,n.y=i,this.updateChildPosition(t),this}},A={updateChildVisible:function(t){return t.visible=this.visible&&this.getLocalState(t).visible,this},syncVisible:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState:function(t){return this.getLocalState(t).visible=t.visible,this},setChildVisible:function(t,e){return t.visible=e,this.resetChildVisibleState(t),this},setChildLocalVisible:function(t,e){return void 0===e&&(e=!0),this.getLocalState(t).visible=e,this.updateChildVisible(t),this}},M={updateChildAlpha:function(t){return t.alpha=this.alpha*this.getLocalState(t).alpha,this},syncAlpha:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState:function(t){return this.getLocalState(t).alpha=k(t.alpha,this.alpha),this},setChildAlpha:function(t,e){return t.alpha=e,this.resetChildAlphaState(t),this._add},setChildLocalAlpha:function(t,e){return this.getLocalState(t).alpha=e,this.updateChildAlpha(t),this}},T={updateChildActive:function(t){return t.active=this.active&&this.getLocalState(t).active,this},syncActive:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState:function(t){return this.getLocalState(t).active=t.active,this},setChildActive:function(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive:function(t,e){return void 0===e&&(e=!0),this.getLocalState(t).active=e,this.updateChildActive(t),this}},R={updateChildMask:function(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this}},F=Phaser.Utils.Array,D={getChildren:function(){return this.children},getAllChildren:function(t){void 0===t&&(t=[]);for(var e,i=this.children,n=0,r=i.length;n<r;n++){if(e=i[n],t.push(e),e.hasOwnProperty("isRexContainerLite"))t.push.apply(t,a(e.getAllChildren()))}return t},contains:function(t){var e=this.getParent(t);return!!e&&(e===this||this.contains(e))},getByName:function(t,e){if(e){for(var i,n,r=[this];r.length;)for(var s=0,o=(i=r.shift()).children.length;s<o;s++){if((n=i.children[s]).name===t)return n;n.isRexContainerLite&&r.push(n)}return null}return F.GetFirst(this.children,"name",t)},getRandom:function(t,e){return F.GetRandom(this.children,t,e)},getFirst:function(t,e,i,n){return F.GetFirstElement(this.children,t,e,i,n)},getAll:function(t,e,i,n){return F.GetAll(this.children,t,e,i,n)},count:function(t,e,i,n){return F.CountAllMatching(this.children,t,e,i,n)},swap:function(t,e){return F.Swap(this.children,t,e),this},moveTo:function(t,e){return F.MoveTo(this.children,t,e),this},setAll:function(t,e,i,n){return F.SetAll(this.children,t,e,i,n),this}},L={tweenChild:function(t){var e=t.targets;S(e)||(e=[e]);for(var i,n,r=[],s=0,o=e.length;s<o;s++)(n=e[s]).hasOwnProperty("rexContainer")&&(i=n.scene,r.push(n.rexContainer));if(i){t.targets=r;var h=i.tweens.add(t);return h.on("update",function(t,e,i){for(var n,r,s=0,o=i.length;s<o;s++)switch(n=i.parent,r=i.self,e){case"x":case"y":case"angle":case"rotation":case"scaleX":case"scaleY":case"flipX":case"flipY":n.updateChildPosition(r);break;case"alpha":n.updateChildAlpha(r)}}),h}},tween:function(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}},G={};Object.assign(G,O,x,X,{getLocalState:function(t){return t.hasOwnProperty("rexContainer")||(t.rexContainer={}),t.rexContainer},resetChildState:function(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState:function(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties:function(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},j,z,A,M,T,{updateChildScrollFactor:function(t){return t.setScrollFactor(this.scrollFactorX,this.scrollFactorY),this},syncScrollFactor:function(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},R,{setDepth:function(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),n=0,r=i.length;n<r;n++)i[n].depth=t;return this},swapDepth:function(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth:function(t){if(this.depth+=t,this.children)for(var e=this.getAllChildren(),i=0,n=e.length;i<n;i++)e[i].depth+=t;return this}},D,L);var N=function(){e(a,m);var h=c(a);function a(t,e,i,n,r,s){var o;return f(this,a),(o=h.call(this,t,e,i,n,r)).type="rexContainerLite",o.isRexContainerLite=!0,o.syncChildrenEnable=!0,o._active=!0,o._mask=null,o._scrollFactorX=1,o._scrollFactorY=1,s&&o.add(s),o}return t(a,[{key:"destroy",value:function(t){this.scene&&(this.syncChildrenEnable=!1,p(s(a.prototype),"destroy",this).call(this,t))}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}},{key:"x",get:function(){return this._x},set:function(t){this._x!==t&&(this._x=t,this.syncPosition())}},{key:"y",get:function(){return this._y},set:function(t){this._y!==t&&(this._y=t,this.syncPosition())}},{key:"rotation",get:function(){return p(s(a.prototype),"rotation",this)},set:function(t){this.rotation!==t&&(l(s(a.prototype),"rotation",t,this,!0),this.syncPosition())}},{key:"scaleX",get:function(){return p(s(a.prototype),"scaleX",this)},set:function(t){this.scaleX!==t&&(l(s(a.prototype),"scaleX",t,this,!0),this.syncPosition())}},{key:"scaleY",get:function(){return p(s(a.prototype),"scaleY",this)},set:function(t){this.scaleY!==t&&(l(s(a.prototype),"scaleY",t,this,!0),this.syncPosition())}},{key:"flipX",get:function(){return p(s(a.prototype),"flipX",this)},set:function(t){p(s(a.prototype),"flipX",this)!==t&&(l(s(a.prototype),"flipX",t,this,!0),this.syncPosition())}},{key:"flipY",get:function(){return p(s(a.prototype),"flipY",this)},set:function(t){p(s(a.prototype),"flipY",this)!==t&&(l(s(a.prototype),"flipY",t,this,!0),this.syncPosition())}},{key:"visible",get:function(){return p(s(a.prototype),"visible",this)},set:function(t){p(s(a.prototype),"visible",this)!==t&&(l(s(a.prototype),"visible",t,this,!0),this.syncVisible())}},{key:"alpha",get:function(){return p(s(a.prototype),"alpha",this)},set:function(t){p(s(a.prototype),"alpha",this)!==t&&(l(s(a.prototype),"alpha",t,this,!0),this.syncAlpha())}},{key:"active",get:function(){return this._active},set:function(t){this._active!==t&&(this._active=t,this.syncActive())}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.syncMask())}},{key:"scrollFactorX",get:function(){return this._scrollFactorX},set:function(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}},{key:"scrollFactorY",get:function(){return this._scrollFactorY},set:function(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}},{key:"list",get:function(){return this.children}}]),a}();Object.assign(N.prototype,G);function H(){}var W,U=Phaser.Display.Align,V={center:U.CENTER,left:U.LEFT_CENTER,right:U.RIGHT_CENTER,top:U.TOP_CENTER,bottom:U.BOTTOM_CENTER,"left-top":U.TOP_LEFT,"left-center":U.LEFT_CENTER,"left-bottom":U.BOTTOM_LEFT,"center-top":U.TOP_CENTER,"center-center":U.CENTER,"center-bottom":U.BOTTOM_CENTER,"right-top":U.TOP_RIGHT,"right-center":U.RIGHT_CENTER,"right-bottom":U.BOTTOM_RIGHT},I=new Phaser.GameObjects.Zone({sys:{queueDepthSort:H,events:{once:H}}},0,0,1,1);I.setOrigin(0);function B(t){return void 0!==t.displayWidth?t.displayWidth:t.width}function J(t){return void 0!==t.displayHeight?t.displayHeight:t.height}function Z(t){var e=J(t);return t.y+e-e*t.originY}function q(t){var e=B(t);return t.x-e*t.originX+.5*e}function $(t,e){var i=J(t);return t.y=e-i+i*t.originY,t}function K(t,e){var i=B(t),n=i*t.originX;return t.x=e+n-.5*i,t}function Q(t){var e=B(t);return t.x-e*t.originX}function tt(t,e){var i=B(t);return t.x=e+i*t.originX,t}function et(t){var e=B(t);return t.x+e-e*t.originX}function it(t,e){var i=B(t);return t.x=e-i+i*t.originX,t}function nt(t,e){var i=J(t),n=i*t.originY;return t.y=e+n-.5*i,t}function rt(t){var e=J(t);return t.y-e*t.originY+.5*e}function st(t){var e=J(t);return t.y-e*t.originY}function ot(t,e){var i=J(t);return t.y=e+i*t.originY,t}var ht=0,at=1,ut=2,ct=4,lt=6,dt=8,ft=10,pt=12,vt=[];vt[11]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),K(t,q(e)+i),$(t,Z(e)+n),t},vt[ft]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),tt(t,Q(e)-i),$(t,Z(e)+n),t},vt[pt]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),it(t,et(e)+i),$(t,Z(e)+n),t},vt[lt]=function(t,e,i,n){var r,s,o;return void 0===i&&(i=0),void 0===n&&(n=0),r=t,s=q(e)+i,o=rt(e)+n,K(r,s),nt(r,o),t},vt[ct]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),tt(t,Q(e)-i),nt(t,rt(e)+n),t},vt[dt]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),it(t,et(e)+i),nt(t,rt(e)+n),t},vt[at]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),K(t,q(e)+i),ot(t,st(e)-n),t},vt[ht]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),tt(t,Q(e)-i),ot(t,st(e)-n),t},vt[ut]=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),it(t,et(e)+i),ot(t,st(e)-n),t};function yt(t,e,i,n,r){return vt[i](t,e,n,r)}function gt(t,e){return void 0===e&&(e={}),"number"==typeof t?(e.left=t,e.right=t,e.top=t,e.bottom=t):(e.left=Ot(t,"left",0),e.right=Ot(t,"right",0),e.top=Ot(t,"top",0),e.bottom=Ot(t,"bottom",0)),e}function mt(t,e){return void 0===this.childrenMap&&(this.childrenMap={}),this.childrenMap[t]=e,this}function bt(t){return t instanceof zt}var Ct=Phaser.Utils.Objects.GetValue,Pt=Phaser.GameObjects.Group,kt=function(t){return t.add.text(0,0,"")},St=new Phaser.Geom.Rectangle,Ot=Phaser.Utils.Objects.GetValue,wt=N.prototype.add,xt={pin:function(t){return wt.call(this,t),this},addBackground:function(t,e,i){return void 0===this.backgroundChildren&&(this.backgroundChildren=[]),"string"==typeof e&&(i=e,e=void 0),void 0===e&&(e=0),this.pin(t),this.backgroundChildren.push(t),this.getSizerConfig(t).padding=gt(e),void 0!==i&&this.addChildrenMap(i,t),this},isBackground:function(t){return void 0!==this.backgroundChildren&&-1!==this.backgroundChildren.indexOf(t)}},_t=/(\S+)\[(\d+)\]/i,Et=Phaser.Geom.Rectangle,Xt=new Et,Yt=function(){function i(t,e){f(this,i),this.gameObject=t,this.scene=t.scene,this.resetFromJSON(e),this.boot()}return t(i,[{key:"resetFromJSON",value:function(t){var e,i,n,r,s,o,h,a;return void 0!==t.x?(e=null,i=t.x):void 0!==t.left?(e=0,i=t.left):void 0!==t.right?(e=1,i=t.right):void 0!==t.centerX&&(e=.5,i=t.centerX),void 0!==t.y?(n=null,r=t.y):void 0!==t.top?(n=0,r=t.top):void 0!==t.bottom?(n=1,r=t.bottom):void 0!==t.centerY&&(n=.5,r=t.centerY),void 0!==i&&(i=i.replace("left","0%").replace("right","100%").replace("center","50%").split("%"),s=parseFloat(i[0])/100,o=""===i[1]?0:parseFloat(i[1])),void 0!==r&&(r=r.replace("top","0%").replace("bottom","100%").replace("center","50%").split("%"),h=parseFloat(r[0])/100,a=""===r[1]?0:parseFloat(r[1])),this.setAlign(e,n),this.setPercentage(s,h),this.setOffset(o,a),this}},{key:"boot",value:function(){this.scene.scale.on("resize",this.anchor,this),this.gameObject.on("destroy",this.destroy,this),this.anchor()}},{key:"shutdown",value:function(){this.scene.scale.off("resize",this.anchor,this),this.gameObject=void 0,this.scene=void 0}},{key:"destroy",value:function(){this.shutdown()}},{key:"setAlign",value:function(t,e){return this.alignX=t,this.alignY=e,this}},{key:"setPercentage",value:function(t,e){return this.percentageX=t,this.percentageY=e,this}},{key:"setOffset",value:function(t,e){return this.offsetX=t,this.offsetY=e,this}},{key:"anchor",value:function(){return this.viewport=function(t,e){void 0===e?e=new Et:!0===e&&(e=Xt);var i=t.scale,n=i.canvasBounds,r=i.displayScale,s=i.autoCenter;return e.x=0<=n.x?0:-(n.x*r.x),e.y=0<=n.y?0:-(n.y*r.y),e.width=n.width*r.x-e.x,e.height=n.height*r.y-e.y,1!==s&&2!==s||(e.width-=e.x),1!==s&&3!==s||(e.height-=e.y),e}(this.scene,!0),this.updatePosition(),this}},{key:"updatePosition",value:function(){var t=this.gameObject;return null===this.alignX?t.x=this.anchorX:void 0!==this.alignX&&(t.x=this.anchorX+t.displayWidth*(t.originX-this.alignX)),null===this.alignY?this.gameObject.y=this.anchorY:void 0!==this.alignY&&(t.y=this.anchorY+t.displayHeight*(t.originY-this.alignY)),this}},{key:"anchorX",get:function(){return this.viewport.x+this.viewport.width*this.percentageX+this.offsetX}},{key:"anchorY",get:function(){return this.viewport.y+this.viewport.height*this.percentageY+this.offsetY}}]),i}(),jt={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]}},zt=Phaser.Scene,At=Phaser.GameObjects.GameObject,Mt=Phaser.Utils.Objects.GetValue,Tt=function(){function r(t,e){var i;f(this,r),this.parent=t,this.scene=bt(i=t)?i:i.scene&&bt(i.scene)?i.scene:i.parent&&i.parent.scene&&bt(i.parent.scene)?i.parent.scene:void 0;var n=Mt(e,"eventEmitter",!1);!0===n&&(n=void 0),this.setEventEmitter(n),this.boot()}return t(r,[{key:"boot",value:function(){this.parent instanceof At?this.parent.once&&this.parent.on("destroy",this.destroy,this):bt(this.parent)&&this.parent.events.once("shutdown",this.destroy,this)}},{key:"shutdown",value:function(){return this.stop(),bt(this.parent)&&this.parent.events.off("shutdown",this.destroy,this),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this}},{key:"destroy",value:function(){return this.shutdown(),this}},{key:"start",value:function(t){return this.isRunning||(this.tween=this.scene.tweens.add(t).on("complete",this.complete,this),!1===this.getEventEmitter()&&this.setEventEmitter(this.tween)),this}},{key:"restart",value:function(){return this.stop().start(),this}},{key:"stop",value:function(){return this.tween&&(this.getEventEmitter()===this.tween&&this.setEventEmitter(!1),this.tween.remove(),this.tween=void 0),this}},{key:"complete",value:function(){return this.stop(),this.getEventEmitter()&&this.emit("complete"),this}},{key:"isRunning",get:function(){return!!this.tween}}]),r}();Object.assign(Tt.prototype,jt);function Rt(t){return i=t,n="complete",new Promise(function(t,e){i.once(n,function(){t()})});var i,n}function Ft(t,e,i,n,r){return!(!t||!t.getBounds)&&(!(n&&!n(t,e,i))&&(!!(ce=t.getBounds(ce)).contains(e,i)&&!(r&&!r(t,e,i))))}function Dt(t,e,i,n,r){return Ft(t,e,i,le(n),de(r))}function Lt(t){return!(t.rexSizer&&t.rexSizer.hidden)}function Gt(t,e,i){!t||void 0===e&&void 0===i||(t.resize?(void 0===e&&(e=t.width),void 0===i&&(i=t.height),t.resize(e,i)):(void 0!==e&&(t.displayWidth=e),void 0!==i&&(t.displayHeight=i)))}var Nt=Phaser.Utils.Objects.GetValue,Ht=Phaser.Utils.Objects.GetAdvancedValue,Wt=function(){e(r,Tt);var n=c(r);function r(t,e){var i;return f(this,r),(i=n.call(this,t)).gameObject=t,i.scaleStart={},i.scaleEnd={},i.resetFromJSON(e),i}return t(r,[{key:"resetFromJSON",value:function(t){return this.setMode(Nt(t,"mode",0)),this.setScaleRange(Ht(t,"start",void 0),Ht(t,"end",0)),this.setDelay(Ht(t,"delay",0)),this.setDuration(Ht(t,"duration",1e3)),this.setEase(Nt(t,"ease",void 0)),this}},{key:"toJSON",value:function(){return{mode:this.mode,startX:this.startX,startY:this.startY,endX:this.endX,endY:this.endY,delay:this.delay,duration:this.duration}}},{key:"setMode",value:function(t){return"string"==typeof t&&(t=Ut[t]),this.mode=t,this}},{key:"setScaleRange",value:function(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=Ht(t,"x",this.gameObject.scaleX),this.startY=Ht(t,"y",this.gameObject.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=Ht(e,"x",void 0),this.endY=Ht(e,"y",void 0)),this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this}},{key:"start",value:function(){if(this.isRunning)return this;var t={targets:this.gameObject,delay:this.delay,duration:this.duration,ease:this.ease,yoyo:2==this.mode,repeat:2==this.mode?-1:0};return void 0!==this.startX&&void 0!==this.endX&&(this.gameObject.scaleX=this.startX,t.scaleX=this.endX),void 0!==this.startY&&void 0!==this.endY&&(this.gameObject.scaleY=this.startY,t.scaleY=this.endY),p(s(r.prototype),"start",this).call(this,t),this}},{key:"complete",value:function(){return p(s(r.prototype),"complete",this).call(this),1===this.mode&&this.gameObject.destroy(),this}}]),r}(),Ut={stop:0,destroy:1,yoyo:2},Vt={},It=Phaser.Utils.Objects.IsPlainObject,Bt={popUp:function(t,e,i){if(It(t)){var n=t;t=n.duration,e=n.orientation,i=n.ease}this._scale=function(t,e,i,n,r){switch(i){case Vt.mode=0:case"x":Vt.start={x:0};break;case 1:case"y":Vt.start={y:0};break;default:Vt.start=0}return Vt.end=1,Vt.duration=e,Vt.ease=void 0===n?"Cubic":n,void 0===r?r=new Wt(t,Vt):r.resetFromJSON(Vt),r.restart(),r}(this,t,e,i,this._scale),this._scale.once("complete",function(){this.emit("popup.complete",this)},this);var r=this.getParentSizer();if(r){var s=this;this._scale.on("update",function(){r.resetChildPositionState(s)})}return this},popUpPromise:function(t,e,i){return this.popUp(t,e,i),Rt(this._scale)},scaleDownDestroy:function(t,e,i,n){if(It(t)){var r=t;t=r.duration,e=r.orientation,i=r.ease,n=r.destroy}this._scale=function(t,e,i,n,r,s){r instanceof Wt&&(s=r,r=void 0),void 0===r&&(r=!0);var o={};switch(o.mode=r?1:0,i){case 0:case"x":o.end={x:0};break;case 1:case"y":o.end={y:0};break;default:o.end=0}return o.duration=e,o.ease=void 0===n?"Linear":n,void 0===s?s=new Wt(t,o):s.resetFromJSON(o),s.restart(),s}(this,t,e,i,n,this._scale),this._scale.once("complete",function(){this.emit("scaledown.complete",this)},this);var s=this.getParentSizer();if(s){var o=this;this._scale.on("update",function(){s.resetChildPositionState(o)})}return this},scaleDownDestroyPromise:function(t,e,i,n){return this.scaleDownDestroy(t,e,i,n),Rt(this._scale)},scaleDown:function(t,e,i){return this.scaleDownDestroy(t,e,i,!1),this},scaleDownPromise:function(t,e,i){return this.scaleDown(t,e,i),Rt(this._scale)}},Jt=Phaser.Utils.Objects.GetValue,Zt=Phaser.Utils.Objects.GetAdvancedValue,qt=function(){e(r,Tt);var n=c(r);function r(t,e){var i;return f(this,r),(i=n.call(this,t)).gameObject=t,i.alphaStart=void 0,i.alphaEnd=void 0,i.resetFromJSON(e),i}return t(r,[{key:"resetFromJSON",value:function(t){return this.setMode(Jt(t,"mode",0)),this.setAlphaRange(Zt(t,"start",this.gameObject.alpha),Zt(t,"end",0)),this.setDelay(Zt(t,"delay",0)),this.setDuration(Zt(t,"duration",1e3)),this}},{key:"toJSON",value:function(){return{mode:this.mode,start:this.alphaStart,end:this.alphaEnd,delay:this.delay,duration:this.duration}}},{key:"shutdown",value:function(){return p(s(r.prototype),"shutdown",this).call(this),this.gameObject=void 0,this}},{key:"setMode",value:function(t){return"string"==typeof t&&(t=$t[t]),this.mode=t,this}},{key:"setAlphaRange",value:function(t,e){return this.alphaStart=t,this.alphaEnd=e,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"start",value:function(){return this.isRunning||(this.gameObject.setAlpha(this.alphaStart),p(s(r.prototype),"start",this).call(this,{targets:this.gameObject,alpha:this.alphaEnd,delay:this.delay,duration:this.duration,ease:"Linear",yoyo:2==this.mode,repeat:2==this.mode?-1:0})),this}},{key:"complete",value:function(){return p(s(r.prototype),"complete",this).call(this),1===this.mode&&this.gameObject.destroy(),this}}]),r}(),$t={stop:0,destroy:1,yoyo:2},Kt=Phaser.Utils.Objects.IsPlainObject,Qt={},te={},ee=Phaser.Utils.Objects.IsPlainObject,ie={fadeIn:function(t,e){var i,n,r,s,o,h;ee(t)&&(t=t.duration);this._fade=(n=t,r=e,s=(i=this)._fade,h=Kt(r)?(o=r.start,r.end):r,void 0===o&&(o=0),void 0===h&&(h=i.alpha),Qt.mode=0,Qt.start=o,Qt.end=h,Qt.duration=n,void 0===s?s=new qt(i,Qt):s.resetFromJSON(Qt),s.restart(),s),this._fade.once("complete",function(){this.emit("fadein.complete",this)},this);var a=this.getParentSizer();if(a){var u=this;this._fade.on("update",function(){a.resetChildAlphaState(u)})}return this},fadeInPromoise:function(t,e){return this.fadeIn(t,e),Rt(this._fade)},fadeOutDestroy:function(t,e){if(ee(t)){var i=t;t=i.duration,e=i.destroy}var n,r,s,o;this._fade=(r=t,s=e,o=(n=this)._fade,s instanceof qt&&(o=s,s=void 0),void 0===s&&(s=!0),te.mode=s?1:0,te.end=0,te.duration=r,void 0===o?o=new qt(n,te):o.resetFromJSON(te),o.restart(),o),this._fade.once("complete",function(){this.emit("fadeout.complete",this)},this);var h=this.getParentSizer();if(h){var a=this;this._fade.on("update",function(){h.resetChildAlphaState(a)})}return this},fadeOutDestroyPromise:function(t,e){return this.fadeOutDestroy(t,e),Rt(this._fade)},fadeOut:function(t){return this.fadeOutDestroy(t,!1),this},fadeOutPromise:function(t){return this.fadeOut(t),Rt(this._fade)}},ne=Phaser.Utils.Objects.GetValue,re=Phaser.Utils.Objects.GetAdvancedValue,se=function(){e(r,Tt);var n=c(r);function r(t,e){var i;return f(this,r),(i=n.call(this,t)).gameObject=t,i.resetFromJSON(e),i}return t(r,[{key:"resetFromJSON",value:function(t){if(this.setMode(ne(t,"mode",0)),t&&(t.hasOwnProperty("x")||t.hasOwnProperty("y"))){var e=re(t,"x",void 0),i=re(t,"y",void 0);this.setTargetPosition(e,i)}else this.setTargetPosition(t);return this.setDelay(re(t,"delay",0)),this.setDuration(re(t,"duration",1e3)),this.setEase(ne(t,"ease",void 0)),this}},{key:"toJSON",value:function(){return{mode:this.mode,startX:this.startX,startY:this.startY,endX:this.endX,endY:this.endY,delay:this.delay,duration:this.duration}}},{key:"setMode",value:function(t){return"string"==typeof t&&(t=oe[t]),this.mode=t,this}},{key:"setTargetPosition",value:function(t,e){if("number"==typeof t||"number"==typeof e)this.startX=this.gameObject.x,this.startY=this.gameObject.y,this.endX=t,this.endY=e;else{var i=t;this.startX=re(i,"startX",void 0),this.startY=re(i,"startY",void 0),this.endX=re(i,"endX",void 0),this.endY=re(i,"endY",void 0)}return this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this}},{key:"start",value:function(){if(this.isRunning)return this;var t={targets:this.gameObject,delay:this.delay,duration:this.duration,ease:this.ease,yoyo:2==this.mode,repeat:2==this.mode?-1:0};return void 0!==this.startX&&void 0!==this.endX&&(this.gameObject.setX(this.startX),t.x=this.endX),void 0!==this.startY&&void 0!==this.endY&&(this.gameObject.setY(this.startY),t.y=this.endY),p(s(r.prototype),"start",this).call(this,t),this}},{key:"complete",value:function(){return p(s(r.prototype),"complete",this).call(this),1===this.mode&&this.gameObject.destroy(),this}}]),r}(),oe={stop:0,destroy:1,yoyo:2},he=function(t,e){if("number"==typeof t)return t;var i=t[0],n=parseFloat(t.substr(2));switch(i){case"+":return e+n;case"-":return e-n;case"*":return e*n;case"/":return e/n}},ae=Phaser.Utils.Objects.IsPlainObject,ue={moveFrom:function(t,e,i,n,r){if(ae(e)){var s=e;e=s.x,i=s.y,t=s.duration,n=s.ease}this._easeMove=function(t,e,i,n,r,s,o){s instanceof se&&(o=s,s=void 0),void 0===s&&(s=!1);var h={};return h.mode=s?1:0,void 0!==i&&(h.startX=he(i,t.x),h.endX=t.x),void 0!==n&&(h.startY=he(n,t.y),h.endY=t.y),h.duration=e,h.ease=void 0===r?"Linear":r,void 0===o?o=new se(t,h):o.resetFromJSON(h),o.restart(),o}(this,t,e,i,n,r,this._easeMove),this._easeMove.once("complete",function(){this.emit("movefrom.complete",this)},this);var o=this.getParentSizer();if(o){var h=this;this._easeMove.on("update",function(){o.resetChildPositionState(h)})}return this},moveFromPromise:function(t,e,i,n,r){return this.moveFrom(t,e,i,n,r),Rt(this._easeMove)},moveFromDestroy:function(t,e,i,n){return this.moveFrom(t,e,i,n,!0),this},moveFromDestroyPromise:function(t,e,i,n){return this.moveFromDestroy(t,e,i,n),Rt(this._easeMove)},moveTo:function(t,e,i,n,r){if(ae(e)){var s=e;e=s.x,i=s.y,t=s.duration,n=s.ease}this._easeMove=function(t,e,i,n,r,s,o){s instanceof se&&(o=s,s=void 0),void 0===s&&(s=!1);var h={};return h.mode=s?1:0,void 0!==i&&(h.startX=t.x,h.endX=he(i,t.x)),void 0!==n&&(h.startY=t.y,h.endY=he(n,t.y)),h.duration=e,h.ease=void 0===r?"Linear":r,void 0===o?o=new se(t,h):o.resetFromJSON(h),o.restart(),o}(this,t,e,i,n,r,this._easeMove),this._easeMove.once("complete",function(){this.emit("moveto.complete",this)},this);var o=this.getParentSizer();if(o){var h=this;this._easeMove.on("update",function(){o.resetChildPositionState(h)})}return this},moveToPromise:function(t,e,i,n,r){return this.moveTo(t,e,i,n,r),Rt(this._easeMove)},moveToDestroy:function(t,e,i,n){return this.moveTo(t,e,i,n,!0),this},moveToDestroyPromise:function(t,e,i,n){return this.moveToDestroy(t,e,i,n,!0),Rt(this._easeMove)}},ce=void 0,le=function(n){return n?function(t,e,i){return!!Lt(t)&&(n(t,e,i),!0)}:Lt},de=function(t){return t},fe=Phaser.Display.Align.CENTER,pe=function(t,e,i){var n=this.getTopmostSizer();n.x+=e-this.x,n.y+=i-this.y},ve={getSizerConfig:function(t){return t.hasOwnProperty("rexSizer")||(t.rexSizer={}),t.rexSizer},pushIntoBounds:function(t){return void 0===t&&(t=function(t,e){void 0===e&&(void 0===W&&(W=new Phaser.Geom.Rectangle),e=W);var i=t.game.config;return e.setTo(0,0,i.width,i.height),e}(this.scene)),this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this},drawBounds:function(t,e){var i,n,r,s,o=t.scene;if("number"==typeof e)i=e;else{i=Ct(e,"color",16777215);var h=Ct(e,"name",!1);h&&(n=Ct(h,"createTextCallback",kt),r=Ct(h,"createTextCallbackScope",void 0),"string"==typeof(s=Ct(h,"align","left-top"))&&(s=V[s]))}if(n&&!t.children){t.children=new Pt(o),t.on("destroy",function(){t.children.destroy(!0),t.children=void 0});var a=t.clear.bind(t);t.clear=function(){a(),t.children.clear(!1,!0)}}for(var u,c,l=this.getAllChildren([this]),d=0,f=l.length;d<f;d++)(u=l[d]).getBounds&&(i&&t.lineStyle(1,i).strokeRectShape(u.getBounds(St)),u.name&&n&&(c=r?n.call(r,o):n(o))&&(c.setText(u.name),t.children.add(c),I.setPosition(St.x,St.y).setSize(St.width,St.height),yt(c,I,s)));return this},getChildrenWidth:function(){return 0},getChildrenHeight:function(){return 0},addChildrenMap:mt,addElement:mt,getElement:function(t,e){if("string"==typeof t&&(t=t.split(".")),0!==t.length){var i=t.shift(),n=null;if("#"===i.charAt(0))i=i.substring(1),n=this.getByName(i,e);else if(-1===i.indexOf("["))this.childrenMap&&(n=this.childrenMap[i]);else{var r=i.match(_t);if(null!=r&&this.childrenMap){var s=this.childrenMap[r[1]];s&&(n=s[r[2]])}}return 0===t.length?n:n&&n.childrenMap?n.getElement(t):null}},getAllChildrenSizers:function(t){void 0===t&&(t=[]);for(var e=t.length,i=this.getChildrenSizers(t),n=t.length,r=e;r<n;r++)i[r].getAllChildrenSizers(t);return t},getChildrenSizers:function(t){return void 0===t&&(t=[]),t},preLayout:function(t){if(!t){this._layoutInit();for(var e,i=this.getChildrenSizers(),n=0,r=i.length;n<r;n++)!(e=i[n]).rexSizer.hidden&&e.dirty&&i[n].preLayout()}},_layoutInit:function(){this._childrenWidth=void 0,this._childrenHeight=void 0},layout:function(t,e,i){return this.rexSizer.hidden||!this.dirty?this:(this.preLayout(t),void 0===e&&(e=Math.max(this.childrenWidth,this.minWidth)),void 0===i&&(i=Math.max(this.childrenHeight,this.minHeight)),this.resize(this.minWidth,this.minHeight),this.layoutBackgrounds(),this.postLayout())},layoutBackgrounds:function(){if(void 0!==this.backgroundChildren)for(var t,e,i,n,r,s,o,h=this.backgroundChildren,a=this.left,u=this.top,c=this.width,l=this.height,d=0,f=h.length;d<f;d++)(e=(t=h[d]).rexSizer).hidden||(n=a+(i=e.padding).left,r=u+i.top,s=c-i.left-i.right,o=l-i.top-i.bottom,Gt(t,s,o),I.setPosition(n,r).setSize(s,o),yt(t,I,fe),this.resetChildPositionState(t))},postLayout:function(){return this._anchor&&this._anchor.updatePosition(),this},setAnchor:function(t){return void 0===this._anchor?this._anchor=new Yt(this,t):this._anchor.resetFromJSON(t),this},isInTouching:function(t,e){return void 0===e&&(e=this),function(t,e,i,n){if(e)return Ft(t,e.x,e.y,i,n);for(var r=t.scene.input.manager,s=r.pointersTotal,o=r.pointers,h=0;h<s;h++)if(e=o[h],Ft(t,e.x,e.y,i,n))return!0;return!1}(e,t)},pointToChild:function(t,e,i,n,r){var s;if((s=i)&&"function"==typeof s||(r=i,n=i=void 0),void 0===r&&(r=this.sizerChildren?this.sizerChildren:this.children),S(r)){for(var o,h=0,a=r.length;h<a;h++)if(o=r[h],Dt(o,t,e,i,n))return o}else for(var u in r)if(o=r[u],Dt(o,t,e,i,n))return o;return null},setDraggable:function(t,e){var i=n(t);return"string"===i?t=this.getElement(t):void 0!==t&&"object"==i||(e=t,t=this),void 0===e&&(e=!0),t.input&&t.input.hasOwnProperty("draggable")?t.input.draggable=e:e&&(t.setInteractive(),t.scene.input.setDraggable(t),t.on("drag",pe,this)),this}};Object.assign(ve,xt,{getParentSizer:function(t){return this.getParent(t)},getTopmostSizer:function(t){return this.getTopmostParent(t)}},Bt,ie,ue);var ye=Phaser.Utils.Objects.GetValue,ge=function(){e(u,N);var a=c(u);function u(t,e,i,n,r,s){var o;f(this,u),(o=a.call(this,t,e,i,2,2)).isRexSizer=!0,o.setMinSize(n,r),o.setName(ye(s,"name","")),o.rexSizer={},o.backgroundChildren=void 0,o.sizerChildren=void 0;var h=ye(s,"anchor",void 0);return h&&o.setAnchor(h),o.space=gt(ye(s,"space",0)),o.setDraggable(ye(s,"draggable",!1)),o.setDirty(!0),o}return t(u,[{key:"destroy",value:function(t){this.scene&&(void 0!==this.backgroundChildren&&(this.backgroundChildren.length=0),p(s(u.prototype),"destroy",this).call(this,t))}},{key:"setMinSize",value:function(t,e){return this.setMinWidth(t).setMinHeight(e),this}},{key:"setMinWidth",value:function(t){return null==t&&(t=0),this.minWidth=t,this}},{key:"setMinHeight",value:function(t){return null==t&&(t=0),this.minHeight=t,this}},{key:"setDirty",value:function(t){return void 0===t&&(t=!0),this.dirty=t,this}},{key:"alignLeft",value:function(t){return this.left=t,this}},{key:"alignRight",value:function(t){return this.right=t,this}},{key:"alignCenterX",value:function(t){return this.centerX=t,this}},{key:"alignTop",value:function(t){return this.top=t,this}},{key:"alignBottom",value:function(t){return this.bottom=t,this}},{key:"alignCenterY",value:function(t){return this.centerY=t,this}},{key:"childrenWidth",get:function(){return void 0===this._childrenWidth&&(this._childrenWidth=this.getChildrenWidth()),this._childrenWidth}},{key:"childrenHeight",get:function(){return void 0===this._childrenHeight&&(this._childrenHeight=this.getChildrenHeight()),this._childrenHeight}},{key:"left",get:function(){return this.x-B(this)*this.originX},set:function(t){this.x+=t-this.left}},{key:"right",get:function(){return this.left+B(this)},set:function(t){this.x+=t-this.right}},{key:"centerX",get:function(){return this.left+B(this)/2},set:function(t){this.x+=t-this.centerX}},{key:"top",get:function(){return this.y-J(this)*this.originY},set:function(t){this.y+=t-this.top}},{key:"bottom",get:function(){return this.top+J(this)},set:function(t){this.y+=t-this.bottom}},{key:"centerY",get:function(){return this.top+J(this)/2},set:function(t){this.y+=t-this.centerY}},{key:"innerLeft",get:function(){return this.left+this.space.left}},{key:"innerRight",get:function(){return this.right-this.space.right}},{key:"innerTop",get:function(){return this.top+this.space.top}},{key:"innerBottom",get:function(){return this.bottom-this.space.bottom}},{key:"innerWidth",get:function(){return this.width-this.space.left-this.space.right}},{key:"innerHeight",get:function(){return this.height-this.space.top-this.space.bottom}}]),u}();Object.assign(ge.prototype,ve);function me(){return Array.prototype.reduce.call(arguments,ke,0)}function be(t,e){var i,n=t.rexSizer;if(n.expand){var r=n.padding;i=e-r.left-r.right}return i}function Ce(t,e){var i,n=t.rexSizer;if(n.expand){var r=n.padding;i=e-r.top-r.bottom}return i}function Pe(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=t.length-1);for(var r=i;r<=n;r++)t[r]=e;return t}var ke=function(t,e){return t+e},Se=Phaser.Utils.Objects.IsPlainObject,Oe=Phaser.Utils.Objects.GetValue,we=Phaser.Display.Align.CENTER,xe={add:function(t,e,i,n,r,s,o){this.pin(t),Se(e)&&(e=Oe(h=e,"column",void 0),i=Oe(h,"row",void 0),n=Oe(h,"align",we),r=Oe(h,"padding",0),s=Oe(h,"expand",!1),o=Oe(h,"key",void 0));var h,a=function(t,e,i,n,r){if("number"==typeof t||"number"==typeof e)if(void 0===t){for(var s=0;s<n;s++)if(!i[o=e*n+s])return o}else if(void 0===e){for(s=0;s<r;s++)if(!i[o=s*n+t])return o}else{if(!i[o=e*n+t])return o}else if(!0===e){var o;for(s=0;s<n;s++)for(var h=0;h<r;h++)if(!i[o=h*n+s])return o}else{s=0;for(var a=i.length;s<a;s++)if(!i[s])return s}return null}(e,i,this.sizerChildren,this.columnCount,this.rowCount);return null===a||("string"==typeof n&&(n=V[n]),void 0===n&&(n=we),void 0===r&&(r=0),void 0===s&&(s=!0),(h=this.getSizerConfig(t)).align=n,h.padding=gt(r),h.expand=s,this.sizerChildren[a]=t,void 0!==o&&this.addChildrenMap(o,t)),this}},_e=Phaser.Utils.Array.Remove,Ee=N.prototype.remove,Xe=N.prototype.clear,Ye={remove:function(t,e){if(this.getParentSizer(t)!==this)return this;if(this.isBackground(t))_e(this.backgroundChildren,t);else{var i=this.sizerChildren.indexOf(t);-1!==i&&(this.sizerChildren[i]=null)}return Ee.call(this,t,e),this},removeAt:function(t,e,i){var n=this.getChildAt(t,e);return n&&this.remove(n,i),this},removeAll:function(t){for(var e=0,i=this.sizerChildren;e<i;e++)this.sizerChildren[e]&&this.remove(this.sizerChildren[e],t);return this},clear:function(t){return Pe(this.sizerChildren,null),this.backgroundChildren&&(this.backgroundChildren.length=0),Xe.call(this,t),this}},je=Phaser.Utils.Objects.GetValue,ze={getChildrenWidth:function(){if(this.rexSizer.hidden)return 0;for(var t,e,i,n,r=0,s=this.sizerChildren,o=0;o<this.columnCount;o++){if((t=0)===this.columnProportions[o]){for(var h=0;h<this.rowCount;h++)(e=s[h*this.columnCount+o])&&(e.rexSizer.hidden||(n=e.isRexSizer?Math.max(e.minWidth,e.childrenWidth):B(e),n+=(i=e.rexSizer.padding).left+i.right,t=Math.max(t,n)));r+=t}this.columnWidth[o]=t}return r+me.apply(void 0,[this.space.left].concat(a(this.space.column),[this.space.right]))},getChildrenHeight:function(){if(this.rexSizer.hidden)return 0;for(var t,e,i,n,r=0,s=this.sizerChildren,o=0;o<this.rowCount;o++){if((t=0)===this.rowProportions[o]){for(var h=0;h<this.columnCount;h++)(e=s[o*this.columnCount+h])&&(e.rexSizer.hidden||(n=e.isRexSizer?Math.max(e.minHeight,e.childrenHeight):J(e),n+=(i=e.rexSizer.padding).top+i.bottom,t=Math.max(t,n)));r+=t}this.rowHeight[o]=t}return r+me.apply(void 0,[this.space.top].concat(a(this.space.row),[this.space.bottom]))},getChildrenSizers:function(t){void 0===t&&(t=[]);for(var e,i=this.sizerChildren,n=0,r=i.length;n<r;n++)(e=i[n])&&e.isRexSizer&&t.push(e);return t},layout:function(t,e,i){if(this.rexSizer.hidden||!this.dirty)return this;this.preLayout(t);var n,r,s,o,h=this.totalColumnProportions,a=this.totalRowProportions;if(void 0===e)if(t&&0<h){var u=this.rexSizer.padding;e=t.width-u.left-u.right}else e=Math.max(this.childrenWidth,this.minWidth);if(void 0===i)if(t&&0<a){var u=this.rexSizer.padding;i=t.height-u.top-u.bottom}else i=Math.max(this.childrenHeight,this.minHeight);this.resize(e,i),n=0<h?(this.width-this.childrenWidth)/h:0,r=0<a?(this.height-this.childrenHeight)/a:0;for(var c,l,d,f,p,v,y,g,m,b,C=this.innerLeft,P=C,k=this.innerTop,S=this.space.column,O=this.space.row,w=0;w<this.rowCount;w++){b=0===(g=this.rowProportions[w])?this.rowHeight[w]:g*r,P=C;for(var x=0;x<this.columnCount;x++)m=0===(y=this.columnProportions[x])?this.columnWidth[x]:y*n,(s=this.getChildAt(x,w))&&!s.rexSizer.hidden&&(p=be(s,m),v=Ce(s,b),s.isRexSizer?s.layout(this,p,v):Gt(s,p,v),c=P+(u=(o=s.rexSizer).padding).left,d=m-u.left-u.right,l=k+u.top,f=b-u.top-u.bottom,I.setPosition(c,l).setSize(d,f),yt(s,I,o.align),this.resetChildPositionState(s)),P+=m+S[x];k+=b+O[w]}return this.layoutBackgrounds(),this.postLayout()},resetGrid:function(t,e,i,n,r){if(void 0===i&&(i=0),void 0===n&&(n=0),this.columnCount=t,this.rowCount=e,void 0===this.sizerChildren?this.sizerChildren=[]:this.removeAll(),this.sizerChildren.length=t*e,Pe(this.sizerChildren,null),this.columnProportions=[],this.columnProportions.length=t,"number"==typeof i)Pe(this.columnProportions,i);else for(var s=0;s<t;s++)this.columnProportions[s]=i[s]||0;if(this.rowProportions=[],this.rowProportions.length=e,"number"==typeof n)Pe(this.rowProportions,n);else for(s=0;s<e;s++)this.rowProportions[s]=n[s]||0;this.columnWidth=[],this.columnWidth.length=t,this.rowHeight=[],this.rowHeight.length=e,this.space.column=[],this.space.column.length=t-1;var o=je(r,"column",0);if("number"==typeof o)Pe(this.space.column,o);else{s=0;for(var h=this.space.column.length;s<h;s++)this.space.column[s]=o[s]||0}this.space.row=[],this.space.row.length=e-1;var a=je(r,"row",0);if("number"==typeof a)Pe(this.space.row,a);else for(s=0,h=this.space.row.length;s<h;s++)this.space.row[s]=a[s]||0;return this}};Object.assign(ze,xe,Ye);var Ae=Phaser.Utils.Objects.IsPlainObject,Me=Phaser.Utils.Objects.GetValue,Te=function(){e(d,ge);var l=c(d);function d(t,e,i,n,r,s,o,h,a,u){var c;return f(this,d),Ae(e)?(e=Me(u=e,"x",0),i=Me(u,"y",0),n=Me(u,"width",void 0),r=Me(u,"height",void 0),s=Me(u,"column",0),o=Me(u,"row",0),h=Me(u,"columnProportions",0),a=Me(u,"rowProportions",0)):Ae(n)?(n=Me(u=n,"width",void 0),r=Me(u,"height",void 0),s=Me(u,"column",0),o=Me(u,"row",0),h=Me(u,"columnProportions",0),a=Me(u,"rowProportions",0)):Ae(s)?(s=Me(u=s,"column",0),o=Me(u,"row",0),h=Me(u,"columnProportions",0),a=Me(u,"rowProportions",0)):Ae(h)&&(h=Me(u=h,"columnProportions",0),a=Me(u,"rowProportions",0)),(c=l.call(this,t,e,i,n,r,u)).type="rexGridSizer",c.resetGrid(s,o,h,a,Me(u,"space",void 0)),c.addChildrenMap("items",c.sizerChildren),c}return t(d,[{key:"destroy",value:function(t){this.scene&&(this.sizerChildren.length=0,p(s(d.prototype),"destroy",this).call(this,t))}},{key:"setColumnProportion",value:function(t,e){return t>=this.columnProportions.length||(this.columnProportions[t]=e),this}},{key:"setRowProportion",value:function(t,e){return t>=this.rowProportions.length||(this.rowProportions[t]=e),this}},{key:"getChildAt",value:function(t,e){return this.sizerChildren[e*this.columnCount+t]}},{key:"childToGridIndex",value:function(t,e){if(!t)return null;var i=this.sizerChildren.indexOf(t);return-1===i?null:(void 0===e&&(e={}),e.x=i%this.columnCount,e.y=Math.floor(i/this.columnCount),e)}},{key:"totalColumnProportions",get:function(){for(var t,e=0,i=0;i<this.columnCount;i++)0<(t=this.columnProportions[i])&&(e+=t);return e}},{key:"totalRowProportions",get:function(){for(var t,e=0,i=0;i<this.rowCount;i++)0<(t=this.rowProportions[i])&&(e+=t);return e}}]),d}();return Object.assign(Te.prototype,ze),Te});
  