phaser4-rex-plugins
Version:
1 lines • 53.4 kB
JavaScript
var t,e;t=void 0,e=function(){var t=!1;!function(e){if(!t){void 0===e&&(e=0);var i=Phaser.VERSION.split("."),s=parseInt(i[0]);if(4===s){var r=parseInt(i[1]);r<e&&console.error(`Minimum supported version : ${s}.${r}`)}else console.error(`Can't supported version : ${s}`);t=!0}}();const e=Phaser.GameObjects.Zone,i=Phaser.Utils.Array.Add,s=Phaser.Utils.Array.Remove;class r extends e{constructor(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=1),super(t,e,i,s,r),this.children=[]}destroy(t){if(this.scene&&!this.ignoreDestroy){if(t)for(var e,i=this.children.length-1;i>=0;i--)(e=this.children[i]).parentContainer||e.displayList||e.destroy(t);this.clear(!t),super.destroy(t)}}contains(t){return-1!==this.children.indexOf(t)}add(t){var e=this;return i(this.children,t,0,(function(t){t.once("destroy",e.onChildDestroy,e)}),this),this}remove(t,e){var i=this;return s(this.children,t,(function(t){t.off("destroy",i.onChildDestroy,i),e&&t.destroy()})),this}onChildDestroy(t,e){this.remove(t,!1)}clear(t){for(var e,i=0,s=this.children.length;i<s;i++)(e=this.children[i]).off("destroy",this.onChildDestroy,this),t&&e.destroy();return this.children.length=0,this}}const n=Phaser.GameObjects.Components;Phaser.Class.mixin(r,[n.Alpha,n.Flip]);var a=function(t,e){var i;if(void 0===e)t.hasOwnProperty("rexContainer")&&(i=t.rexContainer.parent);else for(i=a(t);i&&i.name!==e;)i=a(i);return i};const l=Phaser.Math.DegToRad,h=Phaser.Math.RadToDeg;var o=function(t){if(!t.hasOwnProperty("rexContainer")){var e={parent:null,self:null,layer:null,x:0,y:0,syncPosition:!0,rotation:0,syncRotation:!0,scaleX:0,scaleY:0,syncScale:!0,alpha:0,syncAlpha:!0,syncScrollFactor:!0,syncCameraFilter:!0,syncDisplayList:!0,visible:!0,active:!0};Object.defineProperty(e,"angle",{get:function(){return h(this.rotation)},set:function(t){this.rotation=l(t)}}),Object.defineProperty(e,"displayWidth",{get:function(){return t.width*this.scaleX},set:function(e){this.scaleX=e/t.width}}),Object.defineProperty(e,"displayHeight",{get:function(){return t.height*this.scaleY},set:function(e){this.scaleY=e/t.height}}),t.rexContainer=e}return t.rexContainer},d={setParent(t,e){void 0===e&&(e=this);var i=o(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent(t,e){return"string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),a(t,e)},getTopmostParent(t){return void 0===t&&(t=this),function(t){for(var e=a(t);e;)t=e,e=a(e);return t}(t)}};const c=Phaser.Utils.Objects.GetValue,u=r.prototype.add;var v=function(t,e){this.setParent(t);var i=o(t);return C(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t).updateCameraFilter(t),u.call(this,t),g.call(this,t,i),this},p=function(t,e){this.setParent(t);var i=o(t);return C(i,e),i.x=t.x,i.y=t.y,i.rotation=t.rotation,i.scaleX=t.scaleX,i.scaleY=t.scaleY,i.alpha=t.alpha,i.visible=t.visible,i.active=t.active,this.updateChildPosition(t).updateChildAlpha(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),u.call(this,t),g.call(this,t,i),this},C=function(t,e){void 0===e&&(e=!0),"boolean"==typeof e?(t.syncPosition=e,t.syncRotation=e,t.syncScale=e,t.syncAlpha=e,t.syncScrollFactor=e,t.syncCameraFilter=e,t.syncDisplayList=e):(t.syncPosition=c(e,"syncPosition",!0),t.syncRotation=c(e,"syncRotation",!0),t.syncScale=c(e,"syncScale",!0),t.syncAlpha=c(e,"syncAlpha",!0),t.syncScrollFactor=c(e,"syncScrollFactor",!0),t.syncCameraFilter=c(e,"syncCameraFilter",!0),t.syncDisplayList=c(e,"syncDisplayList",!0))},g=function(t,e){this.addToParentContainer(t),e.syncDisplayList&&this.addToPatentLayer(t),this.addToRenderLayer(t)},f={add(t){return Array.isArray(t)?this.addMultiple(t):v.call(this,t),this},pin(t,e){return Array.isArray(t)?this.addMultiple(t,e):v.call(this,t,e),this},addMultiple(t){for(var e=Array.from(arguments),i=0,s=t.length;i<s;i++)e[0]=t[i],this.add.apply(this,e);return this},addLocal(t){return Array.isArray(t)?this.addMultiple(t):p.call(this,t),this},pinLocal(t,e){return Array.isArray(t)?this.addMultiple(t,e):p.call(this,t,e),this},addLocalMultiple(t){for(var e=0,i=t.length;e<i;e++)p.call(this,t[e]);return this}};const y=r.prototype.remove,b=r.prototype.clear;var m={remove(t,e){return a(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),y.call(this,t,e)),this},unpin(t,e){return a(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),y.call(this,t,e)),this},clear(t){for(var e=this.children,i=0,s=e.length;i<s;i++){var r=e[i];this.setParent(r,null),t||this.removeFromRenderLayer(r)}return b.call(this,t),this}},x={getLocalState:t=>o(t),resetChildState(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},T={worldToLocal(t){t.x-=this.x,t.y-=this.y;var e=Math.cos(-this.rotation),i=Math.sin(-this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x/=this.scaleX,t.y/=this.scaleY,t},localToWorld(t){t.x*=this.scaleX,t.y*=this.scaleY;var e=Math.cos(this.rotation),i=Math.sin(this.rotation),s=t.x,r=t.y;return t.x=s*e-r*i,t.y=s*i+r*e,t.x+=this.x,t.y+=this.y,t}},O=function(t,e){return t===e?1:t/e},P={updateChildPosition(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=o(t),i=e.parent;return e.syncPosition&&(t.x=e.x,t.y=e.y,i.localToWorld(t)),e.syncRotation&&(t.rotation=e.rotation+i.rotation),e.syncScale&&(t.scaleX=e.scaleX*i.scaleX,t.scaleY=e.scaleY*i.scaleY),t.isRexContainerLite&&(t.syncChildrenEnable=!0,t.syncPosition()),this},syncPosition(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState(t){var e=o(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=O(t.scaleX,i.scaleX),e.scaleY=O(t.scaleY,i.scaleY),e.rotation=t.rotation-i.rotation,this},setChildPosition(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition(t,e,i){var s=o(t);return s.x=e,s.y=i,this.updateChildPosition(t),this},resetLocalPositionState(){var t=o(this).parent;return t&&t.resetChildPositionState(this),this},getChildLocalX:t=>o(t).x,getChildLocalY:t=>o(t).y};const L=Phaser.Math.DegToRad;var w={updateChildRotation(t){var e=o(t),i=e.parent;return e.syncRotation&&(t.rotation=i.rotation+e.rotation),this},syncRotation(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState(t){var e=o(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildAngle(t,e){return t.angle=e,this.resetChildRotationState(t),this},setChildLocalRotation(t,e){return o(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle(t,e){return o(t).rotation=L(e),this.updateChildRotation(t),this},resetLocalRotationState(){var t=o(this).parent;return t&&t.resetChildRotationState(this),this},getChildLocalRotation:t=>o(t).rotation},M={updateChildScale(t){var e=o(t),i=e.parent;return e.syncScale&&(t.scaleX=i.scaleX*e.scaleX,t.scaleY=i.scaleY*e.scaleY),this},syncScale(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScale,this),this},resetChildScaleState(t){var e=o(t),i=e.parent;return e.scaleX=O(t.scaleX,i.scaleX),e.scaleY=O(t.scaleY,i.scaleY),this},setChildScale(t,e,i){return void 0===i&&(i=e),t.scaleX=e,t.scaleY=i,this.resetChildScaleState(t),this},setChildLocalScale(t,e,i){void 0===i&&(i=e);var s=o(t);return s.scaleX=e,s.scaleY=i,this.updateChildScale(t),this},setChildDisplaySize(t,e,i){return t.setDisplaySize(e,i),this.resetChildScaleState(t),this},resetLocalScaleState(){var t=o(this).parent;return t&&t.resetChildScaleState(this),this},getChildLocalScaleX:t=>o(t).scaleX,getChildLocalScaleY:t=>o(t).scaleY},k={updateChildVisible(t){var e=o(t),i=e.parent,s=!e.hasOwnProperty("maskVisible")||e.maskVisible,r=!i||i.visible;return t.visible=r&&e.visible&&s,this},syncVisible(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState(t){var e=o(t);return e.hasOwnProperty("maskVisible")&&delete e.maskVisible,e.visible=t.visible,this},setChildVisible(t,e){return this.setChildLocalVisible(t,e),this},setChildLocalVisible(t,e){return void 0===e&&(e=!0),o(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible(t,e){return void 0===e&&(e=!0),o(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState(){var t=o(this).parent;return t&&t.resetChildVisibleState(this),this},getChildLocalVisible:t=>o(t).visible},R={updateChildAlpha(t){var e=o(t),i=e.parent;return e.syncAlpha&&(t.alpha=i.alpha*e.alpha),this},syncAlpha(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState(t){var e=o(t),i=e.parent;return e.alpha=O(t.alpha,i.alpha),this},setChildAlpha(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha(t,e){return o(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState(){var t=o(this).parent;return t&&t.resetChildAlphaState(this),this},getChildLocalAlpha:t=>o(t).alpha},S={updateChildActive(t){var e=o(t),i=e.parent;return t.active=i.active&&e.active,this},syncActive(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState(t){return o(t).active=t.active,this},setChildActive(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive(t,e){return void 0===e&&(e=!0),o(t).active=e,this.updateChildActive(t),this},resetLocalActiveState(){var t=o(this).parent;return t&&t.resetChildActiveState(this),this},getChildLocalActive:t=>o(t).active},A={updateChildScrollFactor(t){var e=o(t),i=e.parent;return e.syncScrollFactor&&(t.scrollFactorX=i.scrollFactorX,t.scrollFactorY=i.scrollFactorY),this},syncScrollFactor(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},Y={updateCameraFilter(t){var e=o(t),i=e.parent;return e.syncCameraFilter&&(t.cameraFilter=i.cameraFilter),this},syncCameraFilter(){return this.syncChildrenEnable&&this.children.forEach(this.updateCameraFilter,this),this}},X={updateChildMask(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask(t){return this.mask=t,this},clearMask(t){void 0===t&&(t=!1);var e=this;return this._mask=null,this.setChildMaskVisible(this),this.children.forEach((function(t){t.clearMask&&t.clearMask(!1),t.hasOwnProperty("isRexContainerLite")||e.setChildMaskVisible(t)})),t&&this.mask&&this.mask.destroy(),this}},H=function(t,e){if(t.length<=1)return t;var i;void 0===e&&(e=!1);for(var s=0,r=t.length;s<r;s++){var n=t[s];if(n.displayList?i=n.displayList:n.parentContainer&&(i=n.parentContainer.list),i)break}return i||(i=n.scene.sys.displayList),i.depthSort&&(i.depthSort(),i=i.list),e?t.sort((function(t,e){return i.indexOf(e)-i.indexOf(t)})):t.sort((function(t,e){return i.indexOf(t)-i.indexOf(e)})),t},F=function(t){return t.filter((function(t){return!!t.displayList||!!t.parentContainer||void 0}))},_={setDepth(t,e){if(this.depth=t,!e&&this.children)for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)i[s].depth=t;return this},swapDepth(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth(t){if(this.depth+=t,this.children)for(var e=this.getAllChildren(),i=0,s=e.length;i<s;i++)e[i].depth+=t;return this},bringToTop(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);H(e,!1);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.bringToTop(r)}return this},bringMeToTop(){return this.bringToTop()},sendToBack(){var t=this.displayList;if(!t)return this;var e=this.getAllChildren([this]);H(e,!0);for(var i=0,s=e.length;i<s;i++){var r=e[i];t.exists(r)&&t.sendToBack(r)}return this},sendMeToBack(){return this.sendToBack()},moveDepthBelow(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);H(i,!1);for(var s=0,r=i.length;s<r;s++){var n=i[s];if(e.exists(n)){e.moveBelow(t,n);break}}return this},moveMyDepthBelow(t){return this.moveDepthBelow(t)},moveDepthAbove(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;var i=this.getAllChildren([this]);H(i,!0);for(var s=0,r=i.length;s<r;s++){var n=i[s];if(e.exists(n)){e.moveAbove(t,n);break}}return this},moveMyDepthAbove(t){return this.moveDepthAbove(t)},bringChildToTop(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=F(e),e=H(e,!1)):e=[t];var i=this.getAllChildren([this]);i=F(i);for(var s=(i=H(i,!1))[i.length-1],r=0,n=e.length;r<n;r++){var a=e[r];s!==a&&(a!==this&&s.displayList!==a.displayList||(s.displayList.moveAbove(a,s),s=a))}return this},sendChildToBack(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=F(e),e=H(e,!1)):e=[t];var i=this.getAllChildren([this]);i=F(i);for(var s=(i=H(i,!1))[0],r=e.length-1;r>=0;r--){var n=e[r];s!==n&&(n!==this&&s.displayList!==n.displayList||(s.displayList.moveBelow(n,s),s=n))}return this}},V=function(t,e){if(!e(t)&&t.isRexContainerLite)for(var i=t.children,s=0,r=i.length;s<r;s++)V(i[s],e)},E=function(t,e){for(var i=[t];i.length>0;){var s=i.shift();!e(s)&&s.isRexContainerLite&&i.push(...s.children)}};const G=Phaser.Utils.Array;var j={getChildren(t){if(t)for(var e=0,i=this.children.length;e<i;e++)t.push(this.children[e]);else t=this.children;return t},getAllChildren(t){void 0===t&&(t=[]);var e=this;return E(e,(function(i){i!==e&&t.push(i)})),t},getAllVisibleChildren(t){void 0===t&&(t=[]);var e=this;return E(e,(function(i){if(i!==e)return!i.visible||void t.push(i)})),t},bfs(t,e){return void 0===e&&(e=this),E(e,t),this},dfs(t,e){return void 0===e&&(e=this),V(e,t),this},contains(t){var e=a(t);return!!e&&(e===this||this.contains(e))},getByName(t,e){if(e){for(var i,s,r=[this];r.length;)for(var n=0,a=(i=r.shift()).children.length;n<a;n++){if((s=i.children[n]).name===t)return s;s.isRexContainerLite&&r.push(s)}return null}return G.GetFirst(this.children,"name",t)},getRandom(t,e){return G.GetRandom(this.children,t,e)},getFirst(t,e,i,s){return G.GetFirstElement(this.children,t,e,i,s)},getAll(t,e,i,s){return G.GetAll(this.children,t,e,i,s)},count(t,e,i,s){return G.CountAllMatching(this.children,t,e,i,s)},swap(t,e){return G.Swap(this.children,t,e),this},setAll(t,e,i,s){return G.SetAll(this.children,t,e,i,s),this}},D=function(t){for(var e=[],i=0,s=t.length;i<s;i++){var r=t[i];r.hasOwnProperty("rexContainer")&&e.push(r.rexContainer)}return e},I=function(t,e,i){if(i.parent){var s=i.parent,r=i.self;switch(e){case"x":case"y":s.updateChildPosition(r);break;case"angle":case"rotation":s.updateChildRotation(r);break;case"scaleX":case"scaleY":case"displayWidth":case"displayHeight":s.updateChildScale(r);break;case"alpha":s.updateChildAlpha(r);break;default:s.updateChildPosition(r),s.updateChildRotation(r),s.updateChildScale(r),s.updateChildAlpha(r)}}else t.remove()},B={tweenChild(t){var e=t.targets;Array.isArray(e)||(e=[e]);var i=this.scene||function(t){for(var e=0,i=t.length;e<i;e++){var s=t[e].scene;if(s)return s}return null}(e);if(i){t.targets=D(e);var s=i.tweens.add(t);return s.on("update",I),s}},tweenSelf(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=D(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),I(t,void 0,e)},t},tween(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}};const W=Phaser.GameObjects.Container,z=Phaser.GameObjects.Layer;var U=function(t){return t instanceof z},N=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return!!t.displayList||!!t.parentContainer}))},Z=function(t){var e=N(this);-1===e.indexOf(this)&&e.push(this),H(e),t.add(e)},$=function(t,e,i){if(this.scene){var s=N(this);H(s,e),t.remove(s),i&&s.forEach((function(t){t.addToDisplayList()}))}},J={addToContainer(t){return t instanceof W?(this._setParentContainerFlag=!0,Z.call(this,t),this._setParentContainerFlag=!1,this):this},addToLayer(t){return U(t)?(Z.call(this,t),this):this},removeFromContainer(){return this.parentContainer?(this._setParentContainerFlag=!0,$.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer(t){return void 0===t&&(t=!0),U(this.displayList)?($.call(this,this.displayList,!1,t),this):this},getParentContainer(){if(this.parentContainer)return this.parentContainer;for(var t=this.getParent();t;){var e=t.parentContainer;if(e)return e;t=t.getParent()}return null},addToParentContainer(t){if(!t.displayList)return this;var e=this.getParentContainer();return e?(t.isRexContainerLite?t.addToContainer(e):e.add(t),this):this},addToPatentLayer(t){if(!t.displayList)return this;var e=this.displayList;return e===t.displayList||U(e)&&(t.isRexContainerLite?t.addToLayer(e):e.add(t)),this}},q={hasLayer(){return!!this.privateRenderLayer},enableLayer(){if(this.hasLayer())return this;var t=this.scene.add.layer();return this.moveDepthBelow(t),this.addToLayer(t),this.privateRenderLayer=t,this},getLayer(){return this.hasLayer()||this.enableLayer(),this.privateRenderLayer},getRenderLayer(){if(this.hasLayer())return this.privateRenderLayer;for(var t=this.getParent();t;){var e=t.privateRenderLayer;if(e)return e;t=t.getParent()}return null},addToRenderLayer(t){if(!t.displayList)return this;var e=this.getRenderLayer();return e?(e===t.displayList||(t.isRexContainerLite?t.addToLayer(e):e.add(t),o(t).layer=e),this):this},removeFromRenderLayer(t){var e=o(t),i=e.layer;return i?(t.isRexContainerLite?t.removeFromLayer(!0):i.remove(t),e.layer=null,this):this}},K=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},Q=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const tt=Phaser.Geom.Rectangle,et=Phaser.Math.Vector2,it=Phaser.Math.RotateAround,st=Phaser.GameObjects.Container;var rt=function(t,e){if(void 0===e?e=new tt:!0===e&&(void 0===nt&&(nt=new tt),e=nt),t.getBounds&&!(t instanceof st))return t.getBounds(e);var i,s,r,n,a,l,h,o;if(t.parentContainer){var d=t.parentContainer.getBoundsTransformMatrix();at(t,e),d.transformPoint(e.x,e.y,e),i=e.x,s=e.y,lt(t,e),d.transformPoint(e.x,e.y,e),r=e.x,n=e.y,ht(t,e),d.transformPoint(e.x,e.y,e),a=e.x,l=e.y,ot(t,e),d.transformPoint(e.x,e.y,e),h=e.x,o=e.y}else at(t,e),i=e.x,s=e.y,lt(t,e),r=e.x,n=e.y,ht(t,e),a=e.x,l=e.y,ot(t,e),h=e.x,o=e.y;return e.x=Math.min(i,r,a,h),e.y=Math.min(s,n,l,o),e.width=Math.max(i,r,a,h)-e.x,e.height=Math.max(s,n,l,o)-e.y,e},nt=void 0,at=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===dt&&(dt=new et),e=dt),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-K(t)*t.originX,e.y=t.y-Q(t)*t.originY,ct(t,e,i))},lt=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===dt&&(dt=new et),e=dt),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-K(t)*t.originX+K(t),e.y=t.y-Q(t)*t.originY,ct(t,e,i))},ht=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===dt&&(dt=new et),e=dt),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-K(t)*t.originX,e.y=t.y-Q(t)*t.originY+Q(t),ct(t,e,i))},ot=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===dt&&(dt=new et),e=dt),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-K(t)*t.originX+K(t),e.y=t.y-Q(t)*t.originY+Q(t),ct(t,e,i))},dt=void 0,ct=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&it(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e};const ut=Phaser.Geom.Rectangle,vt=Phaser.Geom.Rectangle.Union;var pt,Ct=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e];return t},gt=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:Ct(e),i){e.length=t.length;for(var s=0,r=t.length;s<r;s++)e[s]=t[s]}else for(var n in t)e[n]=t[n];return e};const ft=Phaser.GameObjects.GameObject,yt=Phaser.GameObjects.Layer;var bt=Phaser.Utils.Objects.GetValue,mt=function(t){if(t){var e=t.gameObjects;Array.isArray(e)||(e=[e]);var i,s,r=t.renderTexture,n=t.saveTexture,a=bt(t,"x",void 0),l=bt(t,"y",void 0),h=bt(t,"width",void 0),o=bt(t,"height",void 0),d=bt(t,"originX",0),c=bt(t,"originY",0),u=bt(t,"padding",0);if(void 0===h||void 0===o||void 0===a||void 0===l){var v=function(t,e){var i;void 0===e?e=new ut:!0===e&&(void 0===pt&&(pt=new ut),e=pt),e.setTo(0,0,0,0);for(var s=!0,r=0,n=t.length;r<n;r++)if((i=t[r]).getBounds){var a=rt(i,!0);s?(e.setTo(a.x,a.y,a.width,a.height),s=!1):vt(a,e,e)}return e}(e,!0);void 0!==a&&void 0!==l?(h=2*Math.max(a-v.left,v.right-a),o=2*Math.max(l-v.top,v.bottom-l),d=.5,c=.5):(a=v.x,l=v.y,h=v.width,o=v.height,d=0,c=0),i=v.x,s=v.y}else i=a+(0-d)*h,s=l+(0-c)*o;i-=u,s-=u,h+=2*u,o+=2*u;var p,C=e[0].scene,g=C.sys.textures;return n&&!r&&(r=g.addDynamicTexture(n,h,o)),r||(r=C.add.renderTexture(0,0,h,o)),r.setPosition&&r.setPosition(a,l),r.width===h&&r.height===o||r.setSize(h,o),r.setOrigin&&r.setOrigin(d,c),r.camera.setScroll(i,s),e=H(gt(e)),r.draw(e).render(),n&&((p=r)instanceof ft||p instanceof yt?r.saveTexture(n):r.key!==n&&g.renameTexture(r.key,key)),r}},xt={snapshot(t){var e=this.scaleX,i=this.scaleY,s=1===e&&1===i;s||this.setScale(1),void 0===t&&(t={}),t.gameObjects=this.getAllVisibleChildren(),t.x=this.x,t.y=this.y,t.originX=this.originX,t.originY=this.originY;var r=mt(t),n=!!r.scene;return s||(this.setScale(e,i),n&&r.setScale(e,i)),n?r:this}};const Tt=Phaser.Utils.Objects.GetValue;var Ot=function(t,e,i,s,r,n,a,l){if(t.getBounds||void 0!==t.width&&void 0!==t.height){var h=at(t,Pt[0],l);h.x-=a,h.y-=a;var o=lt(t,Pt[1],l);o.x+=a,o.y-=a;var d=ot(t,Pt[2],l);d.x+=a,d.y+=a;var c=ht(t,Pt[3],l);c.x-=a,c.y+=a,null!==r&&e.fillStyle(r,n).fillPoints(Pt,!0,!0),null!==i&&e.lineStyle(s,i).strokePoints(Pt,!0,!0)}},Pt=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const Lt=Phaser.Utils.Objects.GetValue,wt=Phaser.Math.RotateAround;var Mt={changeOrigin:function(t,e){this.syncChildrenEnable=!1,function(t,e,i){void 0===i&&(i=e);var s={x:(e-t.originX)*t.displayWidth,y:(i-t.originY)*t.displayHeight};wt(s,0,0,t.rotation),t.originX=e,t.originY=i,t.x=t.x+s.x,t.y=t.y+s.y}(this,t,e),this.syncChildrenEnable=!0;for(var i=this.getAllChildren(),s=0,r=i.length;s<r;s++)this.resetChildPositionState(i[s]);return this},drawBounds:function(t,e){var i=Lt(e,"drawContainer",!0),s=Lt(e,"children");return void 0===s&&(s=this.getAllVisibleChildren([this])),i||(s=s.filter((function(t){return!t.isRexContainerLite}))),function(t,e,i){var s,r,n,a,l,h;if("number"==typeof i?s=i:(s=Tt(i,"color"),r=Tt(i,"lineWidth"),n=Tt(i,"fillColor"),a=Tt(i,"fillAlpha"),l=Tt(i,"padding"),h=Tt(i,"includeParent")),void 0===s&&(s=16777215),void 0===r&&(r=1),void 0===n&&(n=null),void 0===a&&(a=1),void 0===l&&(l=0),void 0===h&&(h=!0),Array.isArray(t))for(var o=0,d=t.length;o<d;o++)Ot(t[o],e,s,r,n,a,l,h);else Ot(t,e,s,r,n,a,l,h)}(s,t,e),this}};Object.assign(Mt,d,f,m,x,T,P,w,M,k,R,S,A,Y,X,_,j,B,J,q,xt);class kt extends r{constructor(t,e,i,s,r,n){Array.isArray(s)&&(n=s,s=void 0,r=void 0),super(t,e,i,s,r),this.type="rexContainerLite",this.isRexContainerLite=!0,this.syncChildrenEnable=!0,this._active=!0,this._mask=null,this._scrollFactorX=1,this._scrollFactorY=1,this._cameraFilter=0,this.privateRenderLayer=void 0,n&&this.add(n)}destroy(t){this.scene&&!this.ignoreDestroy&&(this.syncChildrenEnable=!1,super.destroy(t),this.privateRenderLayer&&this.privateRenderLayer.scene&&(this.privateRenderLayer.list.length=0,this.privateRenderLayer.destroy()))}resize(t,e){return this.setSize(t,e),this}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.syncPosition())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.syncPosition())}get rotation(){return super.rotation}set rotation(t){this.rotation!==t&&(super.rotation=t,this.syncPosition())}get scaleX(){return super.scaleX}set scaleX(t){this.scaleX!==t&&(super.scaleX=t,this.syncPosition())}get scaleY(){return super.scaleY}set scaleY(t){this.scaleY!==t&&(super.scaleY=t,this.syncPosition())}get scale(){return super.scale}set scale(t){this.scale!==t&&(super.scale=t,this.syncPosition())}get visible(){return super.visible}set visible(t){super.visible!==t&&(super.visible=t,this.syncVisible())}get alpha(){return super.alpha}set alpha(t){super.alpha!==t&&(super.alpha=t,this.syncAlpha())}get active(){return this._active}set active(t){this._active!==t&&(this._active=t,this.syncActive())}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.syncMask())}get scrollFactorX(){return this._scrollFactorX}set scrollFactorX(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}get scrollFactorY(){return this._scrollFactorY}set scrollFactorY(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}get cameraFilter(){return this._cameraFilter}set cameraFilter(t){this._cameraFilter!==t&&(this._cameraFilter=t,this.syncCameraFilter())}get list(){return this.children}static GetParent(t){return a(t)}get parentContainer(){return this._parentContainer}set parentContainer(t){this._parentContainer||t?this.setParentContainerFlag?this._parentContainer=t:this._parentContainer&&!t?(this.removeFromContainer(),this._parentContainer=t):t?(this._parentContainer=t,this.addToContainer(t)):this._parentContainer=t:this._parentContainer=t}get setParentContainerFlag(){if(this._setParentContainerFlag)return!0;var t=a(this);return!!t&&t.setParentContainerFlag}}Object.assign(kt.prototype,Mt);var Rt={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,n=i,a=0;a<s.length;a++){if(e=s[a],!r.hasOwnProperty(e)){n=i;break}r=n=r[e]}return n}(this.data,t,e)},incData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData(){return this.data&&Ct(this.data),this}};const St=Phaser.Display.Align;var At={center:St.CENTER,left:St.LEFT_CENTER,right:St.RIGHT_CENTER,top:St.TOP_CENTER,bottom:St.BOTTOM_CENTER,"left-top":St.TOP_LEFT,"top-left":St.TOP_LEFT,"left-center":St.LEFT_CENTER,"center-left":St.LEFT_CENTER,"left-bottom":St.BOTTOM_LEFT,"bottom-left":St.BOTTOM_LEFT,"center-top":St.TOP_CENTER,"top-center":St.TOP_CENTER,"center-center":St.CENTER,"center-bottom":St.BOTTOM_CENTER,"bottom-center":St.BOTTOM_CENTER,"right-top":St.TOP_RIGHT,"top-right":St.TOP_RIGHT,"right-center":St.RIGHT_CENTER,"center-right":St.RIGHT_CENTER,"right-bottom":St.BOTTOM_RIGHT,"bottom-right":St.BOTTOM_RIGHT};class Yt{constructor(t,e){this.container=null,this._deltaHeight=0,this.setParent(t)}setParent(t){this.parent=t,this.parentContainer=t.getParentContainer()}destroy(t){void 0===t&&(t=!1),t||this.destroyContainer(),this.deltaHeight=0,this.data=void 0,this.container=null,this.parent=void 0,this.parentContainer=void 0}get table(){return this.parent}get scrollMode(){return this.parentContainer.scrollMode}get colIndx(){return this.parent.cellIndxeToColIndex(this.index)}get rowIndx(){return this.parent.cellIndxeToRowIndex(this.index)}getContainer(){return this.container}setContainer(t){return t?(this.container&&this.container.destroy(),this.container=t,this.parentContainer.add(t),this):(this.destroyContainer(),this)}destroyContainer(){return this.container&&(this.container.destroy(),this.container=null),this}popContainer(){if(this.container){var t=this.container;return this.container=null,this.parentContainer.remove(t),t}return null}setXY(t,e){return this.container&&this.parentContainer.setChildLocalPosition(this.container,t,e),this}setCellContainerAlign(t){return"string"==typeof t&&(t=At[t]),this.cellContainerAlign=t,this}get deltaHeight(){return this._deltaHeight}set deltaHeight(t){null==t&&(t=0);var e=this.parent;0===this._deltaHeight&&0!==t?e.nonZeroDeltaHeightCount++:0!==this._deltaHeight&&0===t&&e.nonZeroDeltaHeightCount--;var i=this._deltaHeight!==t;if(this._deltaHeight=t,i){e.resetTotalRowsHeight();var s=0===this.scrollMode?"cellheightchange":"cellwidthchange";this.parentContainer.emit(s,this,this.container,this.parentContainer)}}get deltaWidth(){return this.deltaHeight}set deltaWidth(t){this.deltaHeight=t}setDeltaHeight(t){return this.deltaHeight=t,this}setDeltaWidth(t){return this.deltaHeight=t,this}get height(){return 0===this.scrollMode?this.deltaHeight+this.parent.defaultCellHeight:this.parent.defaultCellWidth}set height(t){1!==this.scrollMode&&this.setDeltaHeight(t-this.parent.defaultCellHeight)}setHeight(t){return this.height=t,this}get width(){return 0===this.scrollMode?this.parent.defaultCellWidth:this.deltaHeight+this.parent.defaultCellHeight}set width(t){0!==this.scrollMode&&this.setDeltaHeight(t-this.parent.defaultCellHeight)}setWidth(t){return this.width=t,this}get scene(){return this.parentContainer.scene}}Object.assign(Yt.prototype,Rt);class Xt{constructor(){this.items=[]}destroy(){this.clear(),this.items=void 0}pop(){return this.items.length>0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const Ht=Phaser.Utils.Objects.GetValue,Ft=Phaser.Utils.Array.SpliceOne;class _t{constructor(t,e){this.parent=t,this.cells=[],this.cellPool=new Xt,this.resetFromJSON(e)}resetFromJSON(t){void 0===t&&(t={}),this.colCount=void 0,this.nonZeroDeltaHeightCount=0,this.resetTotalRowsHeight();var e=t.cellHeight;void 0===e&&(e=60);var i=t.cellWidth;return void 0===i&&(i=60),this.setDefaultCellHeight(e),this.setDefaultCellWidth(i),this.initCells(Ht(t,"cellsCount",0)),this.setColumnCount(Ht(t,"columns",1)),this}destroy(t){this.cellPool.destroy(),this.cells=void 0,this.parent=void 0}get defaultCellHeightMode(){return 0===this.nonZeroDeltaHeightCount}setDefaultCellHeight(t){return this.defaultCellHeight=t,this}setDefaultCellWidth(t){return this.defaultCellWidth=t,this}initCells(t){var e=this.cells;e.length=t;for(var i=0;i<t;i++)e[i]=null;return this}insertNewCells(t,e){var i=this.cells;if(t===i.length){var s=t+e;i.legth=s;for(var r=t;r<s;r++)i[r]=null}else{var n=[];for(n.length=e,r=0;r<e;r++)n[r]=null;this.cells.splice(t,0,...n)}return this.resetTotalRowsHeight(),this}removeCells(t,e){for(var i=t+e,s=t;s<i;s++)this.freeCell(s);return i===this.cells.length?this.cells.length=t:(1===e?Ft(this.cells,t):this.cells.splice(t,e),this.buildCellIndex(t)),this.resetTotalRowsHeight(),this}setColumnCount(t){this.colCount=t,this.resetTotalRowsHeight();var e=this.parent;if(e.expandCellSize){var i=(0===e.scrollMode?e.width:e.height)/t;this.setDefaultCellWidth(i)}return this}get rowCount(){return Math.ceil(this.cells.length/this.colCount)}get cellsCount(){return this.cells.length}isValidCellIdx(t){return t>=0&&t<this.cells.length}heightToRowIndex(t,e){if(void 0===e&&(e=0),0===t)return 0;if(this.defaultCellHeightMode){var i=t/this.defaultCellHeight;return i=1===e?Math.ceil(i):Math.floor(i)}var s,r=this.rowCount,n=t;for(i=0;;){if(s=i>=0&&i<r,!((n-=this.getRowHeight(i))>0&&s)){if(0===n)return 2===e&&(i+=1),i;if(1===e){var a=i;(s=(i+=1)>=0&&i<r)||(i=a)}return i}i+=1}}widthToColIndex(t,e){if(0===t)return 0;var i=t/this.defaultCellWidth;return i=e?Math.ceil(i):Math.floor(i)}colRowToCellIndex(t,e){return t>=this.colCount?null:e*this.colCount+t}rowIndexToHeight(t,e){if(this.defaultCellHeightMode)return(e-t+1)*this.defaultCellHeight;for(var i=0,s=t;s<=e;s++)i+=this.getRowHeight(s);return i}colIndexToWidth(t,e){return(e-t+1)*this.defaultCellWidth}getRowHeight(t){var e=this.colCount;if(e<=1)return this.getCellHeight(this.colRowToCellIndex(0,t));for(var i,s=0,r=0;r<e;r++)s<(i=this.getCellHeight(this.colRowToCellIndex(r,t)))&&(s=i);return s}getColWidth(t){return this.defaultCellWidth}getCellHeight(t){if(!this.isValidCellIdx(t))return 0;var e;if(this.defaultCellHeightMode)e=this.defaultCellHeight;else{var i=this.getCell(t,!1),s=i?i.deltaHeight:0;e=this.defaultCellHeight+s}return e}resetTotalRowsHeight(){this._totalRowsHeight=null}get totalRowsHeight(){return null===this._totalRowsHeight&&(this._totalRowsHeight=this.rowIndexToHeight(0,this.rowCount-1)),this._totalRowsHeight}get totalColumnWidth(){return this.colCount*this.defaultCellWidth}cellIndxeToColIndex(t){return t%this.colCount}cellIndxeToRowIndex(t){return Math.floor(t/this.colCount)}getCell(t,e){if(!this.isValidCellIdx(t))return null;if(void 0===e&&(e=!0),null===this.cells[t]&&e){var i=this.newCell(t);this.cells[t]=i}return this.cells[t]}newCell(t){var e=this.cellPool.pop();return null===e?e=new Yt(this):e.setParent(this),e.index=t,e}buildCellIndex(t){void 0===t&&(t=0);for(var e,i=this.cells,s=t,r=i.length;s<r;s++)(e=i[s])&&(e.index=s);return this}getParentContainer(){return this.parent}freeCell(t){return"number"==typeof t&&(t=this.cells[t]),t?(t.destroy(),this.cellPool.push(t),this):this}}const Vt=Phaser.Scene;var Et=function(t){return t instanceof Vt},Gt=function(t){var e;return(t=null==(e=t)||"object"!=typeof e?null:Et(e)?e:e.scene&&Et(e.scene)?e.scene:e.parent&&e.parent.scene&&Et(e.parent.scene)?e.parent.scene:null)?t.sys.renderer:null},jt=function(t){var e=Gt(t);return!!e&&!!e.gl};const Dt=Phaser.Filters.Mask;var It=function(t,e,i){var s=function(t,e){var i=t._maskObject;return i?(void 0!==e&&void 0!==i.invert&&(i.invert=e),i):(i=jt(t)?new Dt(t.scene.cameras.main,t,e):t.createGeometryMask(),t._maskObject=i,t.once("destroy",(function(){i.destroy(),t._maskObject=void 0})),i)}(e,i);if(t.mask!==s){if(jt(t)){if(!t.filters){if(!t.enableFilters)return;t.enableFilters()}var r=t.filters.external.list;if(t.mask){var n=r.indexOf(t.mask);r[n]=e}else r.push(s)}else if(!t.setMask)return;t.mask=s}},Bt=function(t){if(t.mask){if(jt(t)){var e=t.filters.external.list,i=e.indexOf(t.mask);e.splice(i,1)}else if(!t.clearMask)return;t.mask=null}};const Wt=Phaser.Geom.Intersects.RectangleToRectangle,zt=Phaser.Geom.Rectangle.Overlaps;var Ut=function(t){if(!t.displayList&&!t.parentContainer)return!1;for(;;){var e=t.rexContainer;if(e){if(e.visible){var i=e.parent;if(i){t=i;continue}return!0}return!1}return t.visible}},Nt=function(t,e){var i=e.top,s=e.bottom,r=e.left,n=e.right,a=0;return a+=t.contains(r,i)?1:0,a+=t.contains(r,s)?1:0,a+=t.contains(n,i)?1:0,a+=t.contains(n,s)?1:0},Zt=function(t,e,i){e.hasOwnProperty("isRexContainerLite")?(e.syncChildrenEnable=!1,t.setChildMaskVisible(e,!0),e.syncChildrenEnable=!0):(Bt(e),t.setChildMaskVisible(e,!0))},$t=function(t,e,i){e.hasOwnProperty("isRexContainerLite")?(e.syncChildrenEnable=!1,t.setChildMaskVisible(e,!0),e.syncChildrenEnable=!0):(It(e,i),t.setChildMaskVisible(e,!0))},Jt=function(t,e,i){e.hasOwnProperty("isRexContainerLite")?(e.syncChildrenEnable=!1,t.setChildMaskVisible(e,!1),e.syncChildrenEnable=!0):(Bt(e),t.setChildMaskVisible(e,!1))};const qt=Phaser.GameObjects.Graphics.prototype.setPosition,Kt=Phaser.Geom.Rectangle,Qt=Phaser.Geom.Circle;var te=function(t,e,i,s,r){this.geom=function(t,e,i,s,r,n,a){if(1===t){s=s.left;var l=-e*(r-.5),h=-i*(n-.5),o=Math.min(e,i)/2+s;void 0!==a&&a instanceof Qt||(a=new Qt),a.setTo(l,h,o)}else{var d=-e*r-s.left,c=-i*n-s.top,u=e+s.left+s.right,v=i+s.top+s.bottom;void 0!==a&&a instanceof Kt||(a=new Kt),a.setTo(d,c,u,v)}return a}(this.shapeType,t,e,i,s,r,this.geom),this.clear().fillStyle(16777215),1===this.shapeType?this.fillCircleShape(this.geom):this.fillRectShape(this.geom)},ee={setPosition:function(t,e){var i=this.parent;return void 0===t&&(t=i.x),void 0===e&&(e=i.y),qt.call(this,t,e),this},resize:function(t,e,i){var s=this.parent;void 0===t&&(t=s.width),void 0===e&&(e=s.height),void 0===i?i=this.padding:"number"==typeof i&&(i=GetBoundsConfig(i));var r=this.width!==t||this.height!==e,n=this.padding!==i&&!function(t,e){for(var i in t){if(!(i in e))return!1;if(t[i]!==e[i])return!1}for(var i in e)if(!(i in t))return!1;return!0}(this.padding,i);return r||n?(this.width=t,this.height=e,n&>(i,this.padding),this.originX=s.originX,this.originY=s.originY,te.call(this,t,e,i,s.originX,s.originY),this):this},setOrigin:function(t,e){void 0===e&&(e=t);var i=this.parent;return void 0===t&&(t=i.originX),void 0===e&&(e=i.originY),this.originX===t&&this.originY===e||(this.originX=t,this.originY=e,te.call(this,this.width,this.height,this.padding,t,e)),this},contains:function(t,e){return t-=this.x,e-=this.y,this.geom.contains(t,e)}};const ie=Phaser.Utils.Objects.GetValue,se=Phaser.GameObjects.Graphics;class re extends se{constructor(t,e,i){var s,r;void 0===e&&(e=0),"string"==typeof e&&(e=ne[e]),super(t.scene),this.parent=t,this.shapeType=e,this.padding=(void 0===(s=i)&&(s=0),void 0===r&&(r={}),"number"==typeof s?(r.left=s,r.right=s,r.top=s,r.bottom=s):(r.left=ie(s,"left",0),r.right=ie(s,"right",0),r.top=ie(s,"top",0),r.bottom=ie(s,"bottom",0)),r),this.setPosition().resize().setVisible(!1),t.parentContainer?t.parentContainer.add(this):t.scene.add.existing(this)}destroy(){return this.parent=void 0,super.destroy(),this}}const ne={rectangle:0,circle:1};Object.assign(re.prototype,ee);var ae=function(t,e,i,s){var r=new re(e,i,s);return t&&!t.isRexSizer&&It(t,r),this.pin(r),r};const le=Phaser.Utils.Objects.GetValue,he={update:0,everyTick:1};var oe={setupChildrenMask(t){return!1===t||(this.setMaskUpdateMode(le(t,"updateMode",0)),this.enableChildrenMask(le(t,"padding",0)),this.setMaskLayer(le(t,"layer",void 0)),this.onMaskGameObjectVisible=le(t,"onVisible"),this.onMaskGameObjectInvisible=le(t,"onInvisible"),this.maskGameObjectCallbackScope=le(t,"scope"),this.startMaskUpdate()),this},destroyChildrenMask(){return this.childrenMaskGameObject?(this.stopMaskUpdate(),this.childrenMaskGameObject.destroy(),this.childrenMaskGameObject=void 0,this.onMaskGameObjectVisible=null,this.onMaskGameObjectInvisible=null,this.maskGameObjectCallbackScope=null,this):this},setMaskUpdateMode(t){return"string"==typeof t&&(t=he[t]),this.maskUpdateMode=t,this},startMaskUpdate(){this.scene.game.events.on("poststep",this.maskChildren,this)},stopMaskUpdate(){this.scene.game.events.off("poststep",this.maskChildren,this)},enableChildrenMask(t){return this.childrenMaskGameObject=ae.call(this,null,this,0,t),this},setMaskChildrenFlag(t){return void 0===t&&(t=!0),this.maskChildrenFlag=t,this},setMaskLayer(t){return this.maskLayer=t,this},maskChildren(){return this.childrenMaskGameObject&&this.maskChildrenFlag&&0!==this.alpha&&this.visible?(this.privateRenderLayer?It(this.privateRenderLayer,this.childrenMaskGameObject):this.maskLayer?(this.addToLayer(this.maskLayer),It(this.maskLayer,this.childrenMaskGameObject)):function({parent:t,maskGameObject:e,children:i,onVisible:s,onInvisible:r,scope:n}){if(e){void 0===i&&(i=t.getAllChildren());for(var a,l,h,o=!!s||!!r,d=t.getBounds(),c=0,u=i.length;c<u;c++)if((a=i[c])!==e&&Ut(a)){if(h=a.visible,a.getBounds)switch(l=a.getBounds(l),Nt(d,l)){case 4:Zt(t,a);break;case 0:Wt(d,l)||zt(d,l)?$t(t,a,e):Jt(t,a);break;default:$t(t,a,e)}else $t(t,a,e);if(o&&a.visible!==h){var v=a.visible?s:r;v&&(n?v.call(n,a,t):v(a,t))}}}}({parent:this,maskGameObject:this.childrenMaskGameObject,onVisible:this.onMaskGameObjectVisible,onInvisible:this.onMaskGameObjectInvisible,scope:this.maskGameObjectCallbackScope}),0===this.maskUpdateMode&&(this.maskChildrenFlag=!1),this):this},layoutChildrenMask(){if(!this.childrenMaskGameObject)return this;var t=this.childrenMaskGameObject;return t.setPosition().resize(),this.resetChildPositionState(t),this}},de=function(){},ce=new Phaser.GameObjects.Zone({sys:{queueDepthSort:de,events:{once:de}}},0,0,1,1);ce.setOrigin(0);var ue=0,ve=1,pe=2,Ce=4,ge=6,fe=8,ye=10,be=12,me=function(t){var e=Q(t);return t.y+e-e*t.originY},xe=function(t){var e=K(t);return t.x-e*t.originX+.5*e},Te=function(t,e){var i=Q(t);return t.y=e-i+i*t.originY,t},Oe=function(t,e){var i=K(t),s=i*t.originX;return t.x=e+s-.5*i,t},Pe=function(t){var e=K(t);return t.x-e*t.originX},Le=function(t,e){var i=K(t);return t.x=e+i*t.originX,t},we=function(t){var e=K(t);return t.x+e-e*t.originX},Me=function(t,e){var i=K(t);return t.x=e-i+i*t.originX,t},ke=function(t,e){var i=Q(t),s=i*t.originY;return t.y=e+s-.5*i,t},Re=function(t){var e=Q(t);return t.y-e*t.originY+.5*e},Se=function(t){var e=Q(t);return t.y-e*t.originY},Ae=function(t,e){var i=Q(t);return t.y=e+i*t.originY,t},Ye=[];Ye[11]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Oe(t,xe(e)+i),Te(t,me(e)+s),t},Ye[ye]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Le(t,Pe(e)-i),Te(t,me(e)+s),t},Ye[be]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Me(t,we(e)+i),Te(t,me(e)+s),t},Ye[ge]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),function(t,e,i){Oe(t,e),ke(t,i)}(t,xe(e)+i,Re(e)+s),t},Ye[Ce]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Le(t,Pe(e)-i),ke(t,Re(e)+s),t},Ye[fe]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Me(t,we(e)+i),ke(t,Re(e)+s),t},Ye[ve]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Oe(t,xe(e)+i),Ae(t,Se(e)-s),t},Ye[ue]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Le(t,Pe(e)-i),Ae(t,Se(e)-s),t},Ye[pe]=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),Me(t,we(e)+i),Ae(t,Se(e)-s),t};var Xe=function(t,e,i,s,r,n){ce.setPosition(e,i).setSize(s,r),function(t,e,i,s,r){Ye[i](t,e,s,r)}(t,ce,n)},He=function(t){var e,i=null;(e=t.getContainer())?(i=e,t.popContainer()):this.cellContainersPool&&null!==(i=this.cellContainersPool.getFirstDead())&&i.setActive(!0).setVisible(!0),this.emit("cellvisible",t,i,this),this.cellContainersPool&&((e=t.getContainer())?null===i?this.cellContainersPool.add(e):i!==e&&(this.cellContainersPool.add(e),this.cellContainersPool.killAndHide(i)):null!==i&&this.cellContainersPool.killAndHide(i))},Fe=function(t){if(this.emit("cellinvisible",t),this.cellContainersPool){var e=t.popContainer();e&&(e.setScale(1).setAlpha(1),this.cellContainersPool.killAndHide(e))}t.destroyContainer()},_e=function(){var t=this.preVisibleCells;this.preVisibleCells=this.visibleCells,this.visibleCells=t,this.visibleCells.clear()},Ve=function(t,e){e-=this.y+this.topLeftY,t-=this.x+this.topLeftX;var i=this.tableOY-(0===this.scrollMode?e:t),s=this.tableOX-(0===this.scrollMode?t:e),r=this.table,n=r.heightToRowIndex(-i,0),a=r.widthToColIndex(-s),l=r.colRowToCellIndex(a,n);return null===l?null:this.isCellVisible(l)?l:null};const Ee=Phaser.Math.Clamp;var Ge={setTableOY:function(t){var e=this.table,i=this.topTableOY,s=this.bottomTableOY,r=t>i,n=t<s;return this.clampTableOXY&&(e.rowCount<e.heightToRowIndex(this.instHeight,1)?t=0:r?t=i:n&&(t=s)),this._tableOY!==t&&(this._tableOY=t),r&&(this.execeedTopState||this.emit("execeedtop",this,t,i)),this.execeedTopState=r,n&&(this.execeedBottomState||this.emit("execeedbottom",this,t,s)),this.execeedBottomState=n,this},setTableOX:function(t){var e=this.table,i=this.leftTableOX,s=this.rightTableOX,r=t>this.leftTableOX,n=t<this.rightTableOX;return this.clampTableOXY&&(e.colCount<e.widthToColIndex(this.instWidth,!0)?t=0:r?t=i:n&&(t=s)),this._tableOX!==t&&(this._tableOX=t),r&&(this.execeedLeftState||this.emit("execeedleft",this,t,i)),this.execeedLeftState=r,n&&(this.execeedRightState||this.emit("execeedright",this,t,s)),this.execeedRightState=n,this},showCells:function(){if(0!==this.cellsCount){var t=this.scaleX,e=this.scaleY,i=1===t&&1===e;i||this.setScale(1);var s=this.table,r=this.tableOYOffset,n=this.tableOY+r,a=this.tableOX;this.startRowIndex=Math.max(s.heightToRowIndex(-n,2),0);for(var l=this.startRowIndex,h=Math.max(s.widthToColIndex(-a),0),o=h,d=s.colRowToCellIndex(o,l),c=this.bottomBound,u=this.rightBound,v=s.cellsCount-1,p=s.colCount-1,C=this.getCellTLX(o),g=C,f=this.getCellTLY(l)+r;f<c&&d<=v;){if(this.table.isValidCellIdx(d)){var y,b,m=s.getCell(d,!0);if(this.visibleCells.add(m),this.preVisibleCells.has(m)||this.showCell(m),0===this.scrollMode?(y=g,b=f):(y=f,b=g),null==m.cellContainerAlign)m.setXY(y,b);else{var x=m.getContainer();Xe(x,y,b,m.width,m.height,m.cellContainerAlign),m.setXY(x.x,x.y)}}g<u&&o<p?(g+=s.getColWidth(o),o+=1):(g=C,f+=s.getRowHeight(l),o=h,l+=1),d=s.colRowToCellIndex(o,l)}i||this.setScale(t,e)}},showCell:He,getCellTLX:function(t){var e=0===this.scrollMode?this.topLeftX:this.topLeftY;return this.tableOX+this.table.colIndexToWidth(0,t-1)+e},getCellTLY:function(t){var e=0===this.scrollMode?this.topLeftY:this.topLeftX;return this.tableOY+this.table.rowIndexToHeight(0,t-1)+e},hideCells:function(){var t=this.preVisibleCells,e=this.visibleCells,i=this;t.forEach((function(t){e.has(t)||i.hideCell(t)}))},hideCell:Fe,updateTable:function(t,e){return void 0===t&&(t=!1),void 0===e&&(e=!1),t&&(_e.call(this),this.hideCells()),_e.call(this),this.showCells(),this.hideCells(),this.setMaskChildrenFlag(),e&&(this.layoutChildrenMask(),this.maskChildren()),this},isCellVisible:function(t){var e=this.table.getCell(t,!1);return e&&this.visibleCells.has(e)},pointToCellIndex:Ve,pointToCellContainer:function(t,e){var i=Ve.call(this,t,e);if(null!==i)return this.getCellContainer(i)},eachVisibleCell:function(t,e){return function(t,e,i){for(var s=0,r=(t=Array.from(t)).length;s<r;s++)if(i){if(!1===e.call(i,t[s],s))break}else if(!1===e(t[s],s))break}(this.visibleCells,t,e),this},iterateVisibleCell:function(t,e){return function(t,e,i){var s=0;for(var r of t){if(i){if(!1===e.call(i,r,s))break}else if(!1===e(r,s))break;s++}}(this.visibleCells,t,e),this},eachCell:function(t,e){return this.table.cells.slice().forEach(t,e),this},iterateCell:function(t,e){return this.table.cells.forEach(t,e),this},setCellsCount:function(t){var e=this.cellsCount;return e===t||(e>t?this.removeCells(t,e-t):this.insertNewCells(e,t-e)),this},insertNewCells:function(t,e){return"object"==typeof t&&(t=t.index),void 0===e&&(e=1),e<=0||(t=Ee(t,0,this.cellsCount),this.table.insertNewCells(t,e)),this},removeCells:function(t,e){if("object"==typeof t&&(t=t.index),void 0===e&&(e=1),t<0&&(e+=t,t=0),e<=0)return this;if(t>this.cellsCount)return this;for(var i,s=t,r=t+e;s<r;s++)(i=this.getCell(s,!1))&&(this.visibleCells.has(i)&&(Fe.call(this,i),this.visibleCells.delete(i)),this.preVisibleCells.delete(i));return this.table.removeCells(t,e),this},setColumnCount:function(t){return this.table.colCount===t||this.table.setColumnCount(t),this},setGridSize:function(t,e){return this.setCellsCount(t*e),this.table.setColumnCount(t),this},updateVisibleCell:function(t){var e=this.table.getCell(t,!1);return e&&e.container?(He.call(this,e),this):this}};Object.assign(Ge,oe);const je=Phaser.GameObjects.Group,De=Phaser.Utils.Objects.GetValue;class Ie extends kt{constructor(t,e,i,s,r,n){void 0===n&&(n={}),super(t,e,i,s,r),this.type="rexGridTable",this._tableOX=0,this._tableOY=0,this.visibleCells=new Set,this.preVisibleCells=new Set,this.execeedTopState=!1,this.execeedBottomState=!1,this.execeedLeftState=!1,this.execeedRightState=!1,De(n,"reuseCellContainer",!1)&&(this.cellContainersPool=new je(t));var a,l,h,o=De(n,"cellVisibleCallback",null);if(null!==o){var d=De(n,"cellVisibleCallbackScope",void 0);this.on("cellvisible",o,d)}null!==(o=De(n,"cellInvisibleCallback",null))&&(d=De(n,"cellInvisibleCallbackScope",void 0),this.on("cellinvisible",o,d)),De(n,"enableLayer",!1)&&this.enableLayer(),this.setupChildrenMask(De(n,"mask",void 0)),this.setScrollMode(De(n,"scrollMode",0)),this.setClampMode(De(n,"clampTableOXY",!0)),this.setStartFromBottomEnable(De(n,"startFromBottom",!1));var c=0===this.scrollMode;c?(a=n.cellWidth,l=n.cellHeight,h=n.columns):(a=n.cellHeight,l=n.cellWidth,h=De(n,"rows",n.columns)),this.fixedCellSize=De(n,"fixedCellSize",!1),this.expandCellSize=!this.fixedCellSize&&void 0===a,h||(h=1),this.fixedCellSize?h=Math.max(Math.floor(this.instWidth/a),1):this.expandCellSize&&(a=(s=c?this.width:this.height)/h),n.cellWidth=a,n.cellHeight=l,n.columns=h,this.table=new _t(this,n),this.updateTable()}destroy(t){this.scene&&!this.ignoreDestroy&&(this.destroyChildrenMask(),this.table.destroy(t),this.table=void 0,this.cellContainersPool&&(this.cellContainersPool.destroy(!0),this.cellContainersPool=void 0),super.destroy(t))}setScrollMode(t){return"string"==typeof t&&(t=Be[t.toLowerCase()]),this.scrollMode=t,this}setClampMode(t){return void 0===t&&(t=!0),this.clampTableOXY=t,this}setStartFromBottomEnable(t){return void 0===t&&(t=!0),this.startFromBottomEnable=t,this}get tableOY(){return this._tableOY}get tableOX(){return this._tableOX}set tableOY(t){this.setTableOY(t).updateTable()}set tableOX(t){this.setTableOX(t).updateTable()}setTableOXY(t,e){return this.setTableOY(e).setTableOX(t),this}addTableOY(t){return this.setTableOY(this.tableOY+t),this}addTableOX(t){return this.setTableOX(this.tableOX+t),this}addTableOXY(t,e){return this.addTableOY(e).addTableOX(t),this}setTableOYByPercentage(t){return this.setTableOY(-this.tableVisibleHeight*t),this}getTableOYPercentage(){var t=this.tableVisibleHeight;return 0===t?0:this.tableOY/-t}setTableOXByPercentage(t){return this.setTableOX(-this.tableVisibleWidth*t),this}getTableOXPercentage(){var t=this.tableVisibleWidth;return 0===t?0:this.tableOX/-t}set t(t){this.setTableOYByPercentage(t).updateTable()}get t(){return this.getTableOYPercentage()}set s(t){this.setTableOXByPercentage(t).updateTable()}get s(){return this.getTableOXPercentage()}scrollToBottom(){if(this.t=1,0===this.t)return this;do{this.t=1}while(1!==this.t);return this}scrollToRow(t){this.scrollToBottom();var e=this.table.rowIndexToHeight(0,t-1);return this.setTableOY(-e).updateTable(),this}scrollToNextRow(t){return void 0===t&&(t=1),this.scrollToRow(this.startRowIndex+t),this}getCell(t){return this.table.getCell(t,!0)}getCellContainer(t){var e,i=this.table.getCell(t,!1);return i&&(e=i.getContainer()),e}