UNPKG

phaser4-rex-plugins

Version:
1 lines 51 kB
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 a=Phaser.GameObjects.Components;Phaser.Class.mixin(r,[a.Alpha,a.Flip]);var n=function(t,e){var i;if(void 0===e)t.hasOwnProperty("rexContainer")&&(i=t.rexContainer.parent);else for(i=n(t);i&&i.name!==e;)i=n(i);return i};const h=Phaser.Math.DegToRad,o=Phaser.Math.RadToDeg;var l=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 o(this.rotation)},set:function(t){this.rotation=h(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},c={setParent(t,e){void 0===e&&(e=this);var i=l(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),n(t,e)},getTopmostParent(t){return void 0===t&&(t=this),function(t){for(var e=n(t);e;)t=e,e=n(e);return t}(t)}};const d=Phaser.Utils.Objects.GetValue,u=r.prototype.add;var p=function(t,e){this.setParent(t);var i=l(t);return g(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t).updateCameraFilter(t),u.call(this,t),m.call(this,t,i),this},v=function(t,e){this.setParent(t);var i=l(t);return g(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),m.call(this,t,i),this},g=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=d(e,"syncPosition",!0),t.syncRotation=d(e,"syncRotation",!0),t.syncScale=d(e,"syncScale",!0),t.syncAlpha=d(e,"syncAlpha",!0),t.syncScrollFactor=d(e,"syncScrollFactor",!0),t.syncCameraFilter=d(e,"syncCameraFilter",!0),t.syncDisplayList=d(e,"syncDisplayList",!0))},m=function(t,e){this.addToParentContainer(t),e.syncDisplayList&&this.addToPatentLayer(t),this.addToRenderLayer(t)},y={add(t){return Array.isArray(t)?this.addMultiple(t):p.call(this,t),this},pin(t,e){return Array.isArray(t)?this.addMultiple(t,e):p.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):v.call(this,t),this},pinLocal(t,e){return Array.isArray(t)?this.addMultiple(t,e):v.call(this,t,e),this},addLocalMultiple(t){for(var e=0,i=t.length;e<i;e++)v.call(this,t[e]);return this}};const f=r.prototype.remove,C=r.prototype.clear;var b={remove(t,e){return n(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),f.call(this,t,e)),this},unpin(t,e){return n(t)!==this||(this.setParent(t,null),e||this.removeFromRenderLayer(t),f.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 C.call(this,t),this}},k={getLocalState:t=>l(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}},P={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}},S=function(t,e){return t===e?1:t/e},x={updateChildPosition(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=l(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=l(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=S(t.scaleX,i.scaleX),e.scaleY=S(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=l(t);return s.x=e,s.y=i,this.updateChildPosition(t),this},resetLocalPositionState(){var t=l(this).parent;return t&&t.resetChildPositionState(this),this},getChildLocalX:t=>l(t).x,getChildLocalY:t=>l(t).y};const T=Phaser.Math.DegToRad;var L={updateChildRotation(t){var e=l(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=l(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 l(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle(t,e){return l(t).rotation=T(e),this.updateChildRotation(t),this},resetLocalRotationState(){var t=l(this).parent;return t&&t.resetChildRotationState(this),this},getChildLocalRotation:t=>l(t).rotation},E={updateChildScale(t){var e=l(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=l(t),i=e.parent;return e.scaleX=S(t.scaleX,i.scaleX),e.scaleY=S(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=l(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=l(this).parent;return t&&t.resetChildScaleState(this),this},getChildLocalScaleX:t=>l(t).scaleX,getChildLocalScaleY:t=>l(t).scaleY},w={updateChildVisible(t){var e=l(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=l(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),l(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible(t,e){return void 0===e&&(e=!0),l(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState(){var t=l(this).parent;return t&&t.resetChildVisibleState(this),this},getChildLocalVisible:t=>l(t).visible},O={updateChildAlpha(t){var e=l(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=l(t),i=e.parent;return e.alpha=S(t.alpha,i.alpha),this},setChildAlpha(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha(t,e){return l(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState(){var t=l(this).parent;return t&&t.resetChildAlphaState(this),this},getChildLocalAlpha:t=>l(t).alpha},A={updateChildActive(t){var e=l(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 l(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),l(t).active=e,this.updateChildActive(t),this},resetLocalActiveState(){var t=l(this).parent;return t&&t.resetChildActiveState(this),this},getChildLocalActive:t=>l(t).active},R={updateChildScrollFactor(t){var e=l(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}},M={updateCameraFilter(t){var e=l(t),i=e.parent;return e.syncCameraFilter&&(t.cameraFilter=i.cameraFilter),this},syncCameraFilter(){return this.syncChildrenEnable&&this.children.forEach(this.updateCameraFilter,this),this}},F={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}},_=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 a=t[s];if(a.displayList?i=a.displayList:a.parentContainer&&(i=a.parentContainer.list),i)break}return i||(i=a.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},j=function(t){return t.filter((function(t){return!!t.displayList||!!t.parentContainer||void 0}))},I={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]);_(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]);_(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]);_(i,!1);for(var s=0,r=i.length;s<r;s++){var a=i[s];if(e.exists(a)){e.moveBelow(t,a);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]);_(i,!0);for(var s=0,r=i.length;s<r;s++){var a=i[s];if(e.exists(a)){e.moveAbove(t,a);break}}return this},moveMyDepthAbove(t){return this.moveDepthAbove(t)},bringChildToTop(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=j(e),e=_(e,!1)):e=[t];var i=this.getAllChildren([this]);i=j(i);for(var s=(i=_(i,!1))[i.length-1],r=0,a=e.length;r<a;r++){var n=e[r];s!==n&&(n!==this&&s.displayList!==n.displayList||(s.displayList.moveAbove(n,s),s=n))}return this},sendChildToBack(t){var e;t!==this&&t.isRexContainerLite?(e=t.getAllChildren([t]),e=j(e),e=_(e,!1)):e=[t];var i=this.getAllChildren([this]);i=j(i);for(var s=(i=_(i,!1))[0],r=e.length-1;r>=0;r--){var a=e[r];s!==a&&(a!==this&&s.displayList!==a.displayList||(s.displayList.moveBelow(a,s),s=a))}return this}},X=function(t,e){if(!e(t)&&t.isRexContainerLite)for(var i=t.children,s=0,r=i.length;s<r;s++)X(i[s],e)},Y=function(t,e){for(var i=[t];i.length>0;){var s=i.shift();!e(s)&&s.isRexContainerLite&&i.push(...s.children)}};const V=Phaser.Utils.Array;var D={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 Y(e,(function(i){i!==e&&t.push(i)})),t},getAllVisibleChildren(t){void 0===t&&(t=[]);var e=this;return Y(e,(function(i){if(i!==e)return!i.visible||void t.push(i)})),t},bfs(t,e){return void 0===e&&(e=this),Y(e,t),this},dfs(t,e){return void 0===e&&(e=this),X(e,t),this},contains(t){var e=n(t);return!!e&&(e===this||this.contains(e))},getByName(t,e){if(e){for(var i,s,r=[this];r.length;)for(var a=0,n=(i=r.shift()).children.length;a<n;a++){if((s=i.children[a]).name===t)return s;s.isRexContainerLite&&r.push(s)}return null}return V.GetFirst(this.children,"name",t)},getRandom(t,e){return V.GetRandom(this.children,t,e)},getFirst(t,e,i,s){return V.GetFirstElement(this.children,t,e,i,s)},getAll(t,e,i,s){return V.GetAll(this.children,t,e,i,s)},count(t,e,i,s){return V.CountAllMatching(this.children,t,e,i,s)},swap(t,e){return V.Swap(this.children,t,e),this},setAll(t,e,i,s){return V.SetAll(this.children,t,e,i,s),this}},G=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},B=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()},U={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=G(e);var s=i.tweens.add(t);return s.on("update",B),s}},tweenSelf(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=G(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),B(t,void 0,e)},t},tween(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}};const N=Phaser.GameObjects.Container,z=Phaser.GameObjects.Layer;var W=function(t){return t instanceof z},$=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return!!t.displayList||!!t.parentContainer}))},H=function(t){var e=$(this);-1===e.indexOf(this)&&e.push(this),_(e),t.add(e)},J=function(t,e,i){if(this.scene){var s=$(this);_(s,e),t.remove(s),i&&s.forEach((function(t){t.addToDisplayList()}))}},K={addToContainer(t){return t instanceof N?(this._setParentContainerFlag=!0,H.call(this,t),this._setParentContainerFlag=!1,this):this},addToLayer(t){return W(t)?(H.call(this,t),this):this},removeFromContainer(){return this.parentContainer?(this._setParentContainerFlag=!0,J.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer(t){return void 0===t&&(t=!0),W(this.displayList)?(J.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||W(e)&&(t.isRexContainerLite?t.addToLayer(e):e.add(t)),this}},Z={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),l(t).layer=e),this):this},removeFromRenderLayer(t){var e=l(t),i=e.layer;return i?(t.isRexContainerLite?t.removeFromLayer(!0):i.remove(t),e.layer=null,this):this}},q=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===at&&(at=new tt),e=at),t.getBounds&&!(t instanceof st))return t.getBounds(e);var i,s,r,a,n,h,o,l;if(t.parentContainer){var c=t.parentContainer.getBoundsTransformMatrix();nt(t,e),c.transformPoint(e.x,e.y,e),i=e.x,s=e.y,ht(t,e),c.transformPoint(e.x,e.y,e),r=e.x,a=e.y,ot(t,e),c.transformPoint(e.x,e.y,e),n=e.x,h=e.y,lt(t,e),c.transformPoint(e.x,e.y,e),o=e.x,l=e.y}else nt(t,e),i=e.x,s=e.y,ht(t,e),r=e.x,a=e.y,ot(t,e),n=e.x,h=e.y,lt(t,e),o=e.x,l=e.y;return e.x=Math.min(i,r,n,o),e.y=Math.min(s,a,h,l),e.width=Math.max(i,r,n,o)-e.x,e.height=Math.max(s,a,h,l)-e.y,e},at=void 0,nt=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===ct&&(ct=new et),e=ct),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-q(t)*t.originX,e.y=t.y-Q(t)*t.originY,dt(t,e,i))},ht=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===ct&&(ct=new et),e=ct),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-q(t)*t.originX+q(t),e.y=t.y-Q(t)*t.originY,dt(t,e,i))},ot=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===ct&&(ct=new et),e=ct),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-q(t)*t.originX,e.y=t.y-Q(t)*t.originY+Q(t),dt(t,e,i))},lt=function(t,e,i){return void 0===e?e=new et:!0===e&&(void 0===ct&&(ct=new et),e=ct),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-q(t)*t.originX+q(t),e.y=t.y-Q(t)*t.originY+Q(t),dt(t,e,i))},ct=void 0,dt=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,pt=Phaser.Geom.Rectangle.Union;var vt,gt=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}: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]}(e),i){e.length=t.length;for(var s=0,r=t.length;s<r;s++)e[s]=t[s]}else for(var a in t)e[a]=t[a];return e};const mt=Phaser.GameObjects.GameObject,yt=Phaser.GameObjects.Layer;var ft=function(t){return t instanceof mt||t instanceof yt},Ct=Phaser.Utils.Objects.GetValue,bt=function(t){if(t){var e=t.gameObjects;Array.isArray(e)||(e=[e]);var i,s,r=t.renderTexture,a=t.saveTexture,n=Ct(t,"x",void 0),h=Ct(t,"y",void 0),o=Ct(t,"width",void 0),l=Ct(t,"height",void 0),c=Ct(t,"originX",0),d=Ct(t,"originY",0),u=Ct(t,"padding",0);if(void 0===o||void 0===l||void 0===n||void 0===h){var p=function(t,e){var i;void 0===e?e=new ut:!0===e&&(void 0===vt&&(vt=new ut),e=vt),e.setTo(0,0,0,0);for(var s=!0,r=0,a=t.length;r<a;r++)if((i=t[r]).getBounds){var n=rt(i,!0);s?(e.setTo(n.x,n.y,n.width,n.height),s=!1):pt(n,e,e)}return e}(e,!0);void 0!==n&&void 0!==h?(o=2*Math.max(n-p.left,p.right-n),l=2*Math.max(h-p.top,p.bottom-h),c=.5,d=.5):(n=p.x,h=p.y,o=p.width,l=p.height,c=0,d=0),i=p.x,s=p.y}else i=n+(0-c)*o,s=h+(0-d)*l;i-=u,s-=u,o+=2*u,l+=2*u;var v=e[0].scene,g=v.sys.textures;return a&&!r&&(r=g.addDynamicTexture(a,o,l)),r||(r=v.add.renderTexture(0,0,o,l)),r.setPosition&&r.setPosition(n,h),r.width===o&&r.height===l||r.setSize(o,l),r.setOrigin&&r.setOrigin(c,d),r.camera.setScroll(i,s),e=_(gt(e)),r.draw(e).render(),a&&(ft(r)?r.saveTexture(a):r.key!==a&&g.renameTexture(r.key,key)),r}},kt={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=bt(t),a=!!r.scene;return s||(this.setScale(e,i),a&&r.setScale(e,i)),a?r:this}};const Pt=Phaser.Utils.Objects.GetValue;var St=function(t,e,i,s,r,a,n,h){if(t.getBounds||void 0!==t.width&&void 0!==t.height){var o=nt(t,xt[0],h);o.x-=n,o.y-=n;var l=ht(t,xt[1],h);l.x+=n,l.y-=n;var c=lt(t,xt[2],h);c.x+=n,c.y+=n;var d=ot(t,xt[3],h);d.x-=n,d.y+=n,null!==r&&e.fillStyle(r,a).fillPoints(xt,!0,!0),null!==i&&e.lineStyle(s,i).strokePoints(xt,!0,!0)}},xt=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const Tt=Phaser.Utils.Objects.GetValue,Lt=Phaser.Math.RotateAround;var Et={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};Lt(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=Tt(e,"drawContainer",!0),s=Tt(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,a,n,h,o;if("number"==typeof i?s=i:(s=Pt(i,"color"),r=Pt(i,"lineWidth"),a=Pt(i,"fillColor"),n=Pt(i,"fillAlpha"),h=Pt(i,"padding"),o=Pt(i,"includeParent")),void 0===s&&(s=16777215),void 0===r&&(r=1),void 0===a&&(a=null),void 0===n&&(n=1),void 0===h&&(h=0),void 0===o&&(o=!0),Array.isArray(t))for(var l=0,c=t.length;l<c;l++)St(t[l],e,s,r,a,n,h,o);else St(t,e,s,r,a,n,h,o)}(s,t,e),this}};Object.assign(Et,c,y,b,k,P,x,L,E,w,O,A,R,M,F,I,D,U,K,Z,kt);class wt extends r{constructor(t,e,i,s,r,a){Array.isArray(s)&&(a=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,a&&this.add(a)}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 n(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=n(this);return!!t&&t.setParentContainerFlag}}Object.assign(wt.prototype,Et);var Ot={setTransitionStartCallback(t,e){return this.onStartCallback=t,this.onStartCallbackScope=e,this},setTransitionProgressCallback(t,e){return this.onProgressCallback=t,this.onProgressCallbackScope=e,this},setTransitionCompleteCallback(t,e){return this.onCompleteCallback=t,this.onCompleteCallbackScope=e,this}},At={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const Rt=Phaser.Scene;var Mt=function(t){return t instanceof Rt},Ft=function(t){return null==t||"object"!=typeof t?null:Mt(t)?t:t.scene&&Mt(t.scene)?t.scene:t.parent&&t.parent.scene&&Mt(t.parent.scene)?t.parent.scene:null};const _t=Phaser.Game;var jt=function(t){return t instanceof _t};const It=Phaser.Utils.Objects.GetValue;class Xt{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(It(e,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this))}shutdown(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0)}destroy(t){this.shutdown(t)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(t,e){this.destroy(e)}setParent(t){var e;return this.parent=t,this.scene=Ft(t),this.game=null==(e=t)||"object"!=typeof e?null:jt(e)?e:jt(e.game)?e.game:Mt(e)?e.sys.game:Mt(e.scene)?e.scene.sys.game:void 0,this}}Object.assign(Xt.prototype,At);const Yt=Phaser.Utils.Objects.GetValue;class Vt extends Xt{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(Yt(e,"tickingMode",1))}boot(){2!==this.tickingMode||this.tickingState||this.startTicking()}shutdown(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),super.shutdown(t))}setTickingMode(t){"string"==typeof t&&(t=Dt[t]),this.tickingMode=t}startTicking(){this.tickingState=!0}stopTicking(){this.tickingState=!1}get isRunning(){return this._isRunning}set isRunning(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}start(){return this.isPaused=!1,this.isRunning=!0,this}pause(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}resume(){return this.isPaused&&(this.isPaused=!1,this.isRunning=!0),this}stop(){return this.isPaused=!1,this.isRunning=!1,this}complete(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}const Dt={no:0,lazy:1,always:2},Gt=Phaser.Utils.Objects.GetValue;class Bt extends Vt{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=Gt(e,"tickEventName",i),this.isSceneTicker=!Ut(this.tickEventName)}startTicking(){super.startTicking(),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this)}stopTicking(){super.stopTicking(),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this)}}var Ut=function(t){return"step"===t||"poststep"===t};const Nt=Phaser.Utils.Objects.GetValue,zt=Phaser.Math.Clamp;class Wt{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=Nt(t,"state",$t),this.timeScale=Nt(t,"timeScale",1),this.delay=Nt(t,"delay",0),this.repeat=Nt(t,"repeat",0),this.repeatCounter=Nt(t,"repeatCounter",0),this.repeatDelay=Nt(t,"repeatDelay",0),this.duration=Nt(t,"duration",0),this.nowTime=Nt(t,"nowTime",0),this.justRestart=Nt(t,"justRestart",!1)}toJSON(){return{state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}destroy(){}setTimeScale(t){return this.timeScale=t,this}setDelay(t){return void 0===t&&(t=0),this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatInfinity(){return this.repeat=-1,this}setRepeatDelay(t){return this.repeatDelay=t,this}start(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?Jt:Ht,this.repeatCounter=0,this}stop(){return this.state=$t,this}update(t,e){this.state!==$t&&this.state!==Zt&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=Kt)):(this.nowTime=this.duration,this.state=Zt):this.nowTime>=0&&(this.state=Jt))}get t(){var t;switch(this.state){case $t:case Ht:case Kt:t=0;break;case Jt:t=this.nowTime/this.duration;break;case Zt:t=1}return zt(t,0,1)}set t(t){(t=zt(t,-1,1))<0?(this.state=Ht,this.nowTime=-this.delay*t):(this.state=Jt,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===$t}get isDelay(){return this.state===Ht}get isCountDown(){return this.state===Jt}get isRunning(){return this.state===Ht||this.state===Jt}get isDone(){return this.state===Zt}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const $t=0,Ht=1,Jt=2,Kt=3,Zt=-1;class qt extends Bt{constructor(t,e){super(t,e),this.timer=new Wt}shutdown(t){this.isShutdown||(super.shutdown(t),this.timer.destroy(),this.timer=void 0)}start(){return this.timer.start(),super.start(),this}stop(){return this.timer.stop(),super.stop(),this}complete(){return this.timer.stop(),super.complete(),this}}const Qt=Phaser.Utils.Objects.GetValue,te=Phaser.Utils.Objects.GetAdvancedValue,ee=Phaser.Tweens.Builders.GetEaseFunction;class ie extends qt{resetFromJSON(t){return this.timer.resetFromJSON(Qt(t,"timer")),this.setEnable(Qt(t,"enable",!0)),this.setTarget(Qt(t,"target",this.parent)),this.setDelay(te(t,"delay",0)),this.setDuration(te(t,"duration",1e3)),this.setEase(Qt(t,"ease","Linear")),this.setRepeat(Qt(t,"repeat",0)),this}setEnable(t){return null==t&&(t=!0),this.enable=t,this}setTarget(t){return void 0===t&&(t=this.parent),this.target=t,this}setDelay(t){return this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=ee(t),this}start(){return this.timer.isRunning||super.start(),this}restart(){return this.timer.stop(),this.start.apply(this,arguments),this}stop(t){return void 0===t&&(t=!1),super.stop(),t&&(this.timer.setT(1),this.updateTarget(this.target,this.timer),this.complete()),this}update(t,e){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateTarget(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}updateTarget(t,e){}}const se=Phaser.Utils.Objects.GetValue,re=Phaser.Math.Linear;class ae extends ie{constructor(t,e){super(t,e),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=se(t,"key","value");var i=e[this.propertyKey];return this.fromValue=se(t,"from",i),this.toValue=se(t,"to",i),this.setEase(se(t,"ease",this.ease)),this.setDuration(se(t,"duration",this.duration)),this.setRepeat(se(t,"repeat",0)),this.setDelay(se(t,"delay",0)),this.setRepeatDelay(se(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),e[this.propertyKey]=this.fromValue,super.start(),this}updateTarget(t,e){var i=e.t;i=this.easeFn(i),t[this.propertyKey]=re(this.fromValue,this.toValue,i)}}var ne=[Phaser.GameObjects.Image,Phaser.GameObjects.Sprite,Phaser.GameObjects.Mesh,Phaser.GameObjects.Shader,Phaser.GameObjects.Video],he=[Phaser.GameObjects.BitmapText],oe=function(t,e,i){if(t&&(void 0!==e||void 0!==i))if(function(t){if(t.resize)return!0;if(!t.setSize)return!1;for(var e=0,i=ne.length;e<i;e++){var s=ne[e];if(s&&t instanceof s)return!1}return!0}(t)){var s,r;s=void 0===e?t.width:e/t.scaleX,r=void 0===i?t.height:i/t.scaleY,t.resize?t.resize(s,r):t.setSize(s,r)}else{var a=function(t){if(void 0===t.displayWidth)return!1;for(var e=0,i=he.length;e<i;e++){var s=he[e];if(s&&t instanceof s)return!1}return!0}(t);void 0!==e&&(a?t.displayWidth=e:t.scaleX=e/t.width),void 0!==i&&(a?t.displayHeight=i:t.scaleY=i/t.height)}},le=function(t,e,i,s){if(void 0===i)i=0;else{var r=typeof i;"boolean"===r?(s=i,i=0):"string"===r&&(i=ce[i])}void 0===s?s={}:!0===s&&(s=de);var a=e.width/t.width,n=e.height/t.height,h=i?Math.max(a,n):Math.min(a,n),o=t.width*h,l=t.height*h;return ft(s)?oe(s,o,l):(s.width=o,s.height=l),s};const ce={fit:0,FIT:0,envelop:1,ENVELOP:1};var de={},ue=function(){for(var t=this.scaleMode-1,e=0,i=this.images.length;e<i;e++){var s=this.images[e],r=le(s,this,t,!0).width/s.width;this.setChildLocalScale(s,r),s.biasScale=r}},pe=function(t){0===this.scaleMode?this.resize(t.width,t.height):ue.call(this)};const ve=Phaser.Utils.Objects.IsPlainObject,ge=Phaser.Utils.Objects.GetValue,me=Phaser.Utils.Array.GetRandom;var ye={out:0,in:1},fe=function(t,e,...i){for(var s=0,r=i.length;s<r;s++){var a=i[s];if(a&&a.hasOwnProperty(t))return a[t]}return e},Ce={setTransitionDirection(t){return"string"==typeof t&&(t=ye[t]),this.dir=t,this},setDuration(t){return this.duration=t,this},setEaseFunction(t){return this.easeFunction=t,this},setNextTexture(t,e){return this.nextImage.setTexture(t,e),pe.call(this,this.nextImage),this},transit(t,e,i){if(this.isRunning&&(this.ignoreCompleteEvent=!0,this.stop(),this.ignoreCompleteEvent=!1),void 0!==i&&(t={key:t,frame:e,mode:i}),this.currentTransitionMode=void 0,ve(t)){var s,r=t;t=ge(r,"key",void 0),e=ge(r,"frame",void 0),i=ge(r,"mode"),Array.isArray(i)&&(i=me(i)),this.transitionModes&&this.transitionModes.hasOwnProperty(i)&&(s=this.transitionModes[i],this.currentTransitionMode=i),this.setDuration(fe("duration",this.duration,r,s)).setEaseFunction(fe("ease",this.easeFunction,r,s)).setTransitionDirection(fe("dir",this.dir,r,s));var a=fe("mask",void 0,r,s);a&&this.setMaskGameObject(a),this.setMaskEnable(!0===a);var n=fe("onStart",void 0,r,s),h=fe("onProgress",void 0,r,s),o=fe("onComplete",void 0,r,s);void 0===n&&void 0===h&&void 0===o||this.setTransitionStartCallback(n,fe("onStartScope",void 0,r,s)).setTransitionProgressCallback(h,fe("onProgressScope",void 0,r,s)).setTransitionCompleteCallback(o,fe("onCompleteScope",void 0,r,s))}return this.setNextTexture(t,e),this.start(),this},addTransitionMode(t,e){return void 0===this.transitionModes&&(this.transitionModes={}),ve(t)&&(t=(e=t).name,delete e.name),this.transitionModes[t]=e,this},start(){return void 0===this.easeValueTask&&(this.easeValueTask=new ae(this,{eventEmitter:null})),this.easeValueTask.restart({key:"t",from:0,to:1,duration:this.duration,ease:this.easeFunction}),this},pause(){return this.easeValueTask&&this.easeValueTask.pause(),this},resume(){return this.easeValueTask&&this.easeValueTask.resume(),this},stop(){return this.easeValueTask&&this.easeValueTask.stop(),this.setT(1),this}};const be=Phaser.GameObjects.Graphics.prototype.setPosition,ke=Phaser.Geom.Rectangle,Pe=Phaser.Geom.Circle;var Se=function(t,e,i,s,r){this.geom=function(t,e,i,s,r,a,n){if(1===t){s=s.left;var h=-e*(r-.5),o=-i*(a-.5),l=Math.min(e,i)/2+s;void 0!==n&&n instanceof Pe||(n=new Pe),n.setTo(h,o,l)}else{var c=-e*r-s.left,d=-i*a-s.top,u=e+s.left+s.right,p=i+s.top+s.bottom;void 0!==n&&n instanceof ke||(n=new ke),n.setTo(c,d,u,p)}return n}(this.shapeType,t,e,i,s,r,this.geom),this.clear().fillStyle(16777215),1===this.shapeType?this.fillCircleShape(this.geom):this.fillRectShape(this.geom)},xe={setPosition:function(t,e){var i=this.parent;return void 0===t&&(t=i.x),void 0===e&&(e=i.y),be.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,a=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||a?(this.width=t,this.height=e,a&&gt(i,this.padding),this.originX=s.originX,this.originY=s.originY,Se.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,Se.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 Te=Phaser.Utils.Objects.GetValue,Le=Phaser.GameObjects.Graphics;class Ee extends Le{constructor(t,e,i){var s,r;void 0===e&&(e=0),"string"==typeof e&&(e=we[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=Te(s,"left",0),r.right=Te(s,"right",0),r.top=Te(s,"top",0),r.bottom=Te(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 we={rectangle:0,circle:1};Object.assign(Ee.prototype,xe);var Oe=function(t){var e=function(t){return(t=Ft(t))?t.sys.renderer:null}(t);return!!e&&!!e.gl};const Ae=Phaser.Filters.Mask;var Re=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=Oe(t)?new Ae(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(Oe(t)){if(!t.filters){if(!t.enableFilters)return;t.enableFilters()}var r=t.filters.external.list;if(t.mask){var a=r.indexOf(t.mask);r[a]=e}else r.push(s)}else if(!t.setMask)return;t.mask=s}},Me=function(t){if(t.mask){if(Oe(t)){var e=t.filters.external.list,i=e.indexOf(t.mask);e.splice(i,1)}else if(!t.clearMask)return;t.mask=null}},Fe={setMaskGameObject(t){if(!t)return this.removeMaskGameObject(),this;if(this.maskGameObject){if(!0===t&&this.maskGameObject instanceof Ee)return this;if(this.maskGameObject===t)return this;this.removeMaskGameObject()}return!0===t&&(t=new Ee(this)),t.resize(this.width,this.height).setOrigin(this.originX,this.originY).setPosition(0,0).setScale(1).setVisible(!1),this.addLocal(t),this.maskGameObject=t,this},removeMaskGameObject(t){return void 0===t&&(t=!0),Me(this.backImage),Me(this.frontImage),this.remove(this.maskGameObject,t),this.maskGameObject=void 0,this},setImageMaskEnable(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!1),e?(this.maskGameObject||this.setMaskGameObject(!0),Re(t,this.maskGameObject,i)):Me(t),this},setCurrentImageMaskEnable(t,e){return this.setImageMaskEnable(this.currentImage,t,e),this},setNextImageMaskEnable(t,e){return this.setImageMaskEnable(this.nextImage,t,e),this},setCellImagesMaskEnable(t,e){for(var i=this.getCellImages(),s=0,r=i.length;s<r;s++)this.setImageMaskEnable(i[s],t,e);return this},setMaskEnable(t,e){return this.setImageMaskEnable(this.backImage,t,e),this.setImageMaskEnable(this.frontImage,t,e),this.setCellImagesMaskEnable(t,e),this}};const _e=Phaser.Utils.Objects.GetValue,je=Phaser.GameObjects.Image,Ie=Phaser.Utils.Objects.IsPlainObject,Xe=Phaser.Math.RotateAround;var Ye={gridCutImage(t,e,i,s){void 0===s&&(s={}),s.objectPool=this.imagesPool;for(var r,a=function(t,e,i,s){Ie(e)&&(e=_e(s=e,"columns",1),i=_e(s,"rows",1));var r=_e(s,"createImageCallback");if(!r){var a=_e(s,"ImageClass",je);r=function(t,e,i){return new a(t,0,0,e,i)}}for(var n=_e(s,"originX",.5),h=_e(s,"originY",.5),o=_e(s,"add",!0),l=_e(s,"align",o),c=_e(s,"objectPool",void 0),d=t.scene,u=t.texture,p=function(t,e,i,s,r,a){var n,h;null==i&&(i="__BASE"),a||(h=a,"object"==typeof(n=i)&&(n=n.name),void 0===h&&(h=","),a="__BASE"===n?function(t,e){return`${t}${h}${e}`}:function(t,e){return`${n}_${t}${h}${e}`});for(var o,l,c,d=t.sys.textures.get(e),u="object"==typeof i?i:d.get(i),p=u.width/s,v=u.height/r,g=u.cutX,m=u.cutY,y=0,f=0,C=0;C<r;C++){y=0;for(var b=0;b<s;b++)c=a(b,C),o=y+g,l=f+m,d.add(c,0,o,l,p,v),y+=p;f+=v}return{getFrameNameCallback:a,cellWidth:p,cellHeight:v,columns:s,rows:r}}(d,u,t.frame,e,i),v=p.getFrameNameCallback,g=t.scaleX,m=t.scaleY,y=t.rotation,f=t.getTopLeft(),C=f.x,b=f.y,k=[],P=p.cellWidth*g,S=p.cellHeight*m,x=0;x<i;x++)for(var T=0;T<e;T++){var L,E=v(T,x);if(L=c&&c.length>0?c.pop().setTexture(u,E):r(d,u,E),o&&d.add.existing(L),l){var w=C+P*T+n*P,O=b+S*x+h*S;L.setOrigin(n,h).setPosition(w,O).setScale(g,m).setRotation(y),Xe(L,C,b,y)}k.push(L)}return k}(t,e,i,s),n=0,h=a.length;n<h;n++)(r=a[n]).setVisible(!0),this.add(r);return this.cellImages=a,this.setChildLocalVisible(t,!1),a},gridCutCurrentImage(t,e,i){return this.gridCutImage(this.currentImage,t,e,i)},gridCutNextImage(t,e,i){return this.gridCutImage(this.nextImage,t,e,i)},getCellImages(){return this.cellImages},freeCellImages(){if(0===this.cellImages.length)return this;for(var t,e,i=this.cellImages[0].texture,s=this.cellImages,r=0,a=s.length;r<a;r++)t=s[r],this.setChildLocalAlpha(t,1).setChildLocalScale(t,1).setChildLocalVisible(t,!1),t.clearMask(),e=t.frame.name,t.setTexture(),i.remove(e);return this.imagesPool.push(...s),s.length=0,this}},Ve={setFlipX(t){return this.flipX=t,this},setFlipY(t){return this.flipY=t,this},toggleFlipX(){return this.flipX=!this.flipX,this},toggleFlipY(){return this.flipY=!this.flipY,this},setFlip(t,e){return this.flipX=t,this.flipY=e,this},resetFlip(){return this.flipX=!1,this.flipY=!1,this}},De={};Object.assign(De,Ot,Ce,Fe,Ye,Ve);var Ge=function(t,e,i,s){},Be=function(t,e,i,s){t.setChildLocalAlpha(e,1-s).setChildLocalAlpha(i,s)},Ue=function(t,e,i,s){t.setChildLocalAlpha(e,1)};const Ne=Phaser.Utils.Objects.IsPlainObject,ze=Phaser.Utils.Objects.GetValue,We=Phaser.Math.Clamp;class $e extends wt{constructor(t,e,i,s,r,a){Ne(e)?(e=ze(a=e,"x",0),i=ze(a,"y",0),s=ze(a,"key",void 0),r=ze(a,"frame",void 0)):Ne(r)&&(a=r,r=void 0);var n=ze(a,"back",void 0),h=ze(a,"front",void 0);n||(n=t.add.image(e,i,s,r)),h||(h=t.add.image(e,i,s,r));var o=ze(a,"width",void 0),l=ze(a,"height",void 0),c=void 0!==o&&void 0!==l?1:0;void 0===o&&(o=h.width),void 0===l&&(l=h.height),super(t,e,i,o,l),this.type="rexTransitionImage",this._flipX=!1,this._flipY=!1,"string"==typeof(c=ze(a,"scaleMode",c))&&(c=Je[c]),this.scaleMode=c,n.setVisible(!1),this.addMultiple([n,h]),this.backImage=n,this.frontImage=h,this.images=[this.backImage,this.frontImage],this.maskGameObject=void 0,this.cellImages=[],this.imagesPool=[],this.transitionModes=void 0,this.currentTransitionMode=void 0;var d=ze(a,"onStart",void 0),u=ze(a,"onProgress",void 0),p=ze(a,"onComplete",void 0),v=ze(a,"dir",0);void 0===d&&void 0===u&&void 0===p&&(d=Ge,u=Be,p=Ue,v=0),this.setTransitionStartCallback(d,ze(a,"onStartScope",void 0)).setTransitionProgressCallback(u,ze(a,"onProgressScope",void 0)).setTransitionCompleteCallback(p,ze(a,"onCompleteScope",void 0)).setTransitionDirection(v).setDuration(ze(a,"duration",1e3)).setEaseFunction(ze(a,"ease","Linear"));var g=ze(a,"mask",void 0);g&&this.setMaskGameObject(g),this.setMaskEnable(!1),this.ignoreCompleteEvent=!1,pe.call(this,this.frontImage)}destroy(t){this.scene&&!this.ignoreDestroy&&(this.backImage=void 0,this.frontImage=void 0,this.images.length=0,this.maskGameObject=void 0,this.cellImages.length=0,this.imagesPool.length=0,this.transitionModes=void 0,super.destroy(t),this.onStartCallback=void 0,this.onStartCallbackScope=void 0,this.onProgressCallback=void 0,this.onProgressCallbackScope=void 0,this.onCompleteCallback=void 0,this.onCompleteCallbackScope=void 0,this.easeValueTask=void 0)}get currentImage(){return 0===this.dir?this.frontImage:this.backImage}get nextImage(){return 0===this.dir?this.backImage:this.frontImage}get texture(){return this.nextImage.texture}get frame(){return this.nextImage.frame}get tint(){return this._tint}set tint(t){this._tint!==t&&(this._tint=t,this.backImage.setTint(t),this.frontImage.setTint(t))}setTint(t){return this.tint=t,this}get flipX(){return this._flipX}set flipX(t){this._flipX!==t&&(this._flipX=t,this.backImage.setFlipX(t),this.frontImage.setFlipX(t))}setFlipX(t){return this.flipX=t,this}toggleFlipX(){return this.flipX=!this.flipX,this}get flipY(){return this._flipY}set flipY(t){this._flipY!==t&&(this._flipY=t,this.backImage.setFlipY(t),this.frontImage.setFlipY(t))}setFlipY(t){return this.flipY=t,this}toggleFlipY(){return this.flipY=!this.flipY,this}setFlip(t,e){return this.flipX=t,this.flipY=e,this}get t(){return this._t}set t(t){if(t=We(t,0,1),this._t!==t){this._t=t;var e=this.currentImage,i=this.nextImage;if(0===t&&(this.setChildVisible(this.frontImage,!0).setChildVisible(this.backImage,!0),He.call(this,this.onStartCallback,this.onStartCallbackScope,this,e,i,t)),He.call(this,this.onProgressCallback,this.onProgressCallbackScope,this,e,i,t),1===t){He.call(this,this.onCompleteCallback,this.onCompleteCallbackScope,this,e,i,t);var s=i.texture.key,r=i.frame.name;this.frontImage.setTexture(s,r),this.backImage.setTexture(s,r),pe.call(this,i),this.setChildVisible(this.frontImage,!0).setChildVisible(this.backImage,!1).setMaskEnable(!1).freeCellImages()}1!==t||this.ignoreCompleteEvent||this.emit("complete")}}setT(t){return this.t=t,this}get isRunning(){return!!this.easeValueTask&&this.easeValueTask.isRunning}setOrigin(t,e){return super.setOrigin(t,e),this.backImage.setOrigin(t,e),this.frontImage.setOrigin(t,e),this.maskGameObject&&this.maskGameObject.setOrigin(t,e),this}setTexture(t,e){return this.frontImage.setTexture(t,e),this.backImage.setTexture(t,e).setVisible(!1),pe.call(this,this.frontImage),this}setSize(t,e){return super.setSize(t,e),this.scaleMode&&ue.call(this),this}}var He=function(t,e,i,s,r,a){var n;t&&(this.scaleMode&&(s.biasScale>0&&(n=this.getChildLocalScaleX(s),n/=s.biasScale,this.setChildLocalScale(s,n)),r.biasScale&&(n=this.getChildLocalScaleX(r),n/=r.biasScale,this.setChildLocalScale(r,n))),e?t.call(e,i,s,r,a):t(i,s,r,a),this.scaleMode&&(s.biasScale>0&&(n=this.getChildLocalScaleX(s),n*=s.biasScale,this.setChildLocalScale(s,n)),r.biasScale&&(n=this.getChildLocalScaleX(r),n*=r.biasScale,this.setChildLocalScale(r,n))))};Object.assign($e.prototype,De);const Je={fit:1,FIT:1,envelop:2,ENVELOP:2};function Ke(t,e,i,s,r){var a=new $e(this.scene,t,e,i,s,r);return this.scene.add.existing(a),a}const Ze=Phaser.Utils.Objects.GetAdvancedValue,qe=Phaser.GameObjects.BuildGameObject;function Qe(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=Ze(t,"key",null),s=Ze(t,"frame",null),r=new $